Skip to content

Feat: TreeList component #2030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7d7acab
feat(web): add TreeList component file
mohdashraf010897 Jul 29, 2022
ba93c11
feat(web): export TreeList component
mohdashraf010897 Jul 29, 2022
cebe7d6
feat(web): implemented UI props for TreeList component
mohdashraf010897 Jul 29, 2022
7c9970e
fea(web): add search input in TreeList component
mohdashraf010897 Jul 29, 2022
2a54a23
feat(web): customRender
mohdashraf010897 Jul 29, 2022
df4b659
feat(web): add custom renderer prop to TreeList example
mohdashraf010897 Jul 29, 2022
88ab942
feat(web): add checkbox and radio buttons display
mohdashraf010897 Jul 29, 2022
1031c47
feat(web): add checkbox and radio buttons display
mohdashraf010897 Jul 29, 2022
ec31b3f
feat(web): adding showCheckbox and showRadio props to example
mohdashraf010897 Jul 29, 2022
bfca47f
feat(web): add transformation util from rawData to local state
mohdashraf010897 Aug 4, 2022
4db6cf7
feat(web): import transformation utils
mohdashraf010897 Aug 4, 2022
9e72738
feat(web): add support for query generation
mohdashraf010897 Aug 4, 2022
affaed8
feat(web): add TreeList component to work with ReactiveComponent
mohdashraf010897 Aug 4, 2022
610415c
sync reactivecore submodule
mohdashraf010897 Aug 4, 2022
c6385e0
fix(web): bug with deselecting non-leaf nodes
mohdashraf010897 Aug 4, 2022
ec79a26
fix(vue): move imports from src to lib
mohdashraf010897 Aug 4, 2022
a0d2a91
feat(web): commit pre-testing changes
mohdashraf010897 Aug 4, 2022
7cec765
fix(web): styling issues with TreeList component
mohdashraf010897 Aug 9, 2022
0932790
fix(web): styling issues with TreeList component
mohdashraf010897 Aug 9, 2022
86f4476
fix(web): multiselect functionality
mohdashraf010897 Aug 9, 2022
4632dfc
fix(web): TreeList single mode functionality
mohdashraf010897 Aug 9, 2022
d5c57b1
feat(web): enhance Treelist ui
mohdashraf010897 Aug 9, 2022
8d3ac71
merge next
mohdashraf010897 Aug 9, 2022
f6ed730
feat(web): add missing props
mohdashraf010897 Aug 9, 2022
8cece49
feat(web): configure treelist example
mohdashraf010897 Aug 9, 2022
7f57f5e
feat(web): setup snapshot tests for TreeList
mohdashraf010897 Aug 9, 2022
d0d2a7f
sync submodule
mohdashraf010897 Aug 9, 2022
128b8f6
fix(web): add missing props
mohdashraf010897 Aug 10, 2022
46ce18e
fix: example
bietkul Aug 10, 2022
edd32c4
Merge branch 'next' of github.com:appbaseio/reactivesearch into feat/…
bietkul Aug 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/web/examples/TreeList/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
},
"modules": false,
"loose": true
}
],
"react"
]
}
8 changes: 8 additions & 0 deletions packages/web/examples/TreeList/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Build
dist

# Packages
node_modules

# Directory
.directory
14 changes: 14 additions & 0 deletions packages/web/examples/TreeList/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>TreeList Example</title>
<link href="https://use.fontawesome.com/releases/v5.0.2/css/all.css" rel="stylesheet" />
</head>
<body>
<div id="root"></div>
<script src="dist/index.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions packages/web/examples/TreeList/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "treelist",
"version": "1.0.0",
"description": "TreeList example for ReactiveSearch",
"main": "index.js",
"license": "Apache-2.0",
"dependencies": {
"@appbaseio/reactivesearch": "3.37.2",
"react": "^16.7.0-alpha.2",
"react-dom": "^16.7.0-alpha.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"style-loader": "^0.20.3",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.0",
"webpack-dev-server": "^3.1.14"
},
"scripts": {
"build": "webpack -p --progress",
"start": "webpack-dev-server --hot --inline --progress --colors --port 8001"
}
}
148 changes: 148 additions & 0 deletions packages/web/examples/TreeList/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* layout */

body {
max-width: 1200px;
margin: 0 auto;
padding-top: 15px;
}

.row {
display: flex;
flex-direction: row;
width: 100%;
}

.col {
flex: 1;
padding: 15px;
}

.row > .col:first-child {
border-right: 1px solid #ccc;
max-width: 400px;
}

.row > .col:last-child {
background: #fafafa;
}

.flex {
display: flex;
}

.wrap {
flex-wrap: wrap;
}

.column {
flex-direction: column;
}

.align-center {
align-items: center;
}

.justify-center {
justify-content: center;
}

.justify-space-between {
justify-content: space-between;
}

.text-center {
text-align: center;
}

@media all and (max-width: 767px) {
.row {
flex-direction: column;
}

.row > .col:first-child {
border-right: none;
max-width: none;
}
}

/* apps */

.authors-list {
color: #9d9d9d;
font-weight: bold;
}

.ratings-list {
padding: 10px 0;
}

.avg-rating {
color: #6b6b6b;
margin-left: 5px;
}

.stars {
color: gold;
}

.location {
color: salmon;
margin-right: 5px;
}

.meetup-location {
margin: 4px 0;
}

.book-title {
white-space: normal;
margin-top: 4px;
}

.book-title-card {
white-space: normal;
margin-top: 4px;
max-height: 45px;
}

.book-image {
height: 150px;
width: 110px;
background-size: cover;
}

.book-header {
font-weight: bold;
margin-bottom: 5px;
}

.book-content {
background: white;
margin: 10px 0;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.meetup-title {
white-space: normal;
}

.meetup-topics {
height: 35px;
overflow: hidden;
}

.meetup-topic {
background-color: #dedede;
color: #555;
padding: 5px 10px;
margin: 5px;
border-radius: 4px;
}

.meetup-topic:first-child {
margin-left: 0;
}

.col .meetup-list-image {
background-size: cover;
}
76 changes: 76 additions & 0 deletions packages/web/examples/TreeList/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React, { Component } from 'react';
import ReactDOM from 'react-dom';

import { ReactiveBase, TreeList, ReactiveList, SelectedFilters } from '@appbaseio/reactivesearch';

import './index.css';

class Main extends Component {
render() {
return (
<ReactiveBase
app="best-buy-dataset"
url="https://a03a1cb71321:75b6603d-9456-4a5a-af6b-a487b309eb61@appbase-demo-ansible-abxiydt-arc.searchbase.io"
enableAppbase
>
<div className="row">
<div className="col">
<TreeList
componentId="BookSensor"
showCount
title="TreeList UI"
showCheckbox
mode="multiple"
URLParams
dataField={['class.keyword', 'subclass.keyword']}
/>
</div>

<div className="col">
<SelectedFilters />
<ReactiveList
componentId="SearchResult"
dataField="original_title"
className="result-list-container"
from={0}
size={5}
renderItem={this.reactiveList}
react={{
and: ['BookSensor'],
}}
defaultQuery={() => ({
track_total_hits: true,
})}
includeFields={['class', 'subclass', 'name', 'image', 'salePrice']}
/>
</div>
</div>
</ReactiveBase>
);
}

reactiveList(data) {
return (
<div className="flex book-content" key={data._id}>
<img src={data.image} alt="Book Cover" className="book-image" />
<div className="flex column justify-center" style={{ marginLeft: 20 }}>
<div className="book-header">{data.name}</div>
<div className="flex column justify-space-between">
<div>
<div>
<span className="authors-list">
{data.class} > {data.subclass}
</span>
</div>
<div className="ratings-list flex align-center">
Sale Price 💰 <b>{data.salePrice}</b>
</div>
</div>
</div>
</div>
</div>
);
}
}

ReactDOM.render(<Main />, document.getElementById('root'));
29 changes: 29 additions & 0 deletions packages/web/examples/TreeList/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const path = require('path');

module.exports = {
mode: 'development',
devServer: { compress: true, disableHostCheck: true },
context: path.resolve(__dirname, 'src'),
entry: {
main: './index.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
publicPath: 'dist/',
},
module: {
rules: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /.css?$/,
loader: ['style-loader', 'css-loader'],
exclude: /node_modules/,
},
],
},
};
3 changes: 3 additions & 0 deletions packages/web/src/components/basic/ReactiveComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import DynamicRangeSlider from '../range/DynamicRangeSlider';
import RatingsFilter from '../range/RatingsFilter';
import RangeInput from '../range/RangeInput';
import ReactiveChart from '../chart/ReactiveChart';
import TreeList from '../list/TreeList';

class ReactiveComponent extends Component {
constructor(props) {
Expand Down Expand Up @@ -421,6 +422,8 @@ const ForwardRefComponent = React.forwardRef((props, ref) => (
<PreferencesConsumer userProps={props}>
{(preferenceProps) => {
switch (preferenceProps.componentType) {
case componentTypes.treeList:
return <TreeList {...preferenceProps} />;
case componentTypes.reactiveList:
return <ReactiveList {...preferenceProps} />;
case componentTypes.dataSearch:
Expand Down
38 changes: 38 additions & 0 deletions packages/web/src/components/list/TreeList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';

import { CommonProps } from '../..';
import * as types from '../../types';

export interface TreeListProps extends CommonProps {
componentId: string;
className?: string;
style?: types.style;
showRadio?: boolean;
showCheckbox?: boolean;
mode: 'single' | 'multiple';
showCount?: boolean;
showSearch?: boolean;
showIcon?: boolean;
icon: types.children;
showLeafIcon?: boolean;
leafIcon: types.children;
showLine?: boolean;
switcherIcon: (expanded: boolean) => types.children;
render?: (data: any) => any;
renderItem: (item: any, count?: number, isSelected?: boolean) => any;
dataField: types.stringArray;
showFilter?: boolean;
index?: string;
onValueChange?: (...args: any[]) => any;
onChange?: (...args: any[]) => any;
onError?: (...args: any[]) => any;
defaultValue?: types.stringArray;
value?: types.stringArray;
beforeValueChange?: (...args: any[]) => any;
customQuery?: (...args: any[]) => any;
defaultQuery?: (...args: any[]) => any;
}

declare const TreeList: React.ComponentClass<TreeListProps>;

export default TreeList;
Loading