Skip to content

Commit 52311d3

Browse files
Merge pull request #269 from HybridFox/feature/table
Feature/table
2 parents 5eecf73 + b0f494a commit 52311d3

File tree

26 files changed

+1526
-5
lines changed

26 files changed

+1526
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
66

77
## [Unreleased]
88

9+
### Added
10+
- `Table` - added table component
911

1012
## v6.2.1 - 2021-12-13
1113

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"start": "npx styleguidist server",
1515
"test": "jest --coverage",
1616
"bootstrap": "lerna bootstrap --hoist",
17-
"build": "lerna exec --parallel -- rollup -c",
17+
"build": "lerna exec --sort -- rollup -c",
1818
"postbuild": "rollup -c",
1919
"publish": "lerna publish --skip-git --skip-npm",
2020
"prepublish": "npm run build"
@@ -69,7 +69,7 @@
6969
"dependencies": {
7070
"@a-ui/core": "^5.0.0",
7171
"classnames": "~2.2.6",
72-
"moment": "^2.24.0",
72+
"moment": "^2.29.1",
7373
"react-input-mask": "^2.0.4",
7474
"react-modal": "~3.5.1",
7575
"rxjs": "^6.6.2"

packages/autocomplete/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"dependencies": {
1111
"classnames": "~2.2.6",
1212
"react": "^16.13.1",
13-
"react-dom": "^16.13.1"
13+
"react-dom": "^16.13.1",
14+
"icon": "0.0.1-0",
15+
"taglist": "0.0.1-0"
1416
}
1517
}

packages/calendar/src/Datepicker/Body.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ class Body extends Component {
131131
)
132132
}
133133
}
134-
export default Body;
134+
export default Body;

packages/form/src/Datepicker/Datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Datepicker extends Component<Props> {
104104
if (this.datepicker && this.datepicker.contains(e.target)) {
105105
return;
106106
}
107-
107+
108108
this.setState({ open: false });
109109
};
110110

packages/table/Readme.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
2+
### Full example
3+
Full fledged table:
4+
```js
5+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js');
6+
7+
const [sorting, setSorting] = React.useState();
8+
const [pagination, setPagination] = React.useState({
9+
itemsPerPage: 10,
10+
totalItems: 1829,
11+
currentPage: 1
12+
});
13+
14+
<Table
15+
tableId="1"
16+
columns={TABLE_MOCK_COLUMNS()}
17+
rows={TABLE_MOCK_ROWS.slice(0, 10)}
18+
filters={TABLE_MOCK_FILTER}
19+
sorting={sorting}
20+
sortingChanged={(e) => console.log('sorting changed', e) || setSorting(e)}
21+
paginationChanged={(e) => console.log('pagination changed', e) || setPagination(e)}
22+
filtersChanged={(e) => console.log('filters changed', e)}
23+
itemsPerPage={pagination.itemsPerPage}
24+
totalItems={pagination.totalItems}
25+
currentPage={pagination.currentPage}
26+
/>
27+
```
28+
29+
### Filter examples
30+
Filters values:
31+
32+
| Key | Value | Description |
33+
|-------------|-----------------------------------------------------------|------------------------------------------------------------------|
34+
| id | _string_ | ID to identify the filter when returning data |
35+
| display | "generic" / "optional" | "generic" to show as the main filter, "optional" if the filter should appear under the extra filter dropdown |
36+
| type | "input" / "datepicker" / "select" / "telephone-number" | Type of field to show |
37+
| label | _string_ | Label of the field |
38+
| placeholder | _string_ | Placeholder of the field |
39+
| options | _{ id: string; label: string; }[]_ | Options to use if "select" type |
40+
41+
Table with only 1 `generic` filter:
42+
```js static
43+
const FILTERS = [{
44+
id: "smartfilter",
45+
display: "generic",
46+
type: "input",
47+
label: "Zoek op voornaam",
48+
placeholder: "Zoek op voornaam",
49+
}]
50+
```
51+
52+
```js
53+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js');
54+
55+
<Table
56+
tableId="1"
57+
columns={TABLE_MOCK_COLUMNS()}
58+
rows={TABLE_MOCK_ROWS.slice(0, 2)}
59+
filters={[{
60+
id: "smartfilter",
61+
display: "generic",
62+
type: "input",
63+
label: "Zoek op voornaam",
64+
placeholder: "Zoek op voornaam",
65+
}]}
66+
/>
67+
```
68+
69+
Only optional filters:
70+
```js static
71+
const FILTERS = [{
72+
id: "firstName",
73+
type: "input",
74+
label: "Zoek op voornaam",
75+
placeholder: "Zoek op voornaam",
76+
}, {
77+
id: "lastName",
78+
type: "input",
79+
label: "Zoek op achternaam",
80+
placeholder: "Zoek op achternaam",
81+
}]
82+
```
83+
84+
```js
85+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js');
86+
87+
<Table
88+
tableId="1"
89+
columns={TABLE_MOCK_COLUMNS()}
90+
rows={TABLE_MOCK_ROWS.slice(0, 2)}
91+
filters={[{
92+
id: "firstName",
93+
type: "input",
94+
label: "Zoek op voornaam",
95+
placeholder: "Zoek op voornaam",
96+
}, {
97+
id: "lastName",
98+
type: "input",
99+
label: "Zoek op achternaam",
100+
placeholder: "Zoek op achternaam",
101+
}]}
102+
/>
103+
```
104+
105+
### State examples
106+
Loading table
107+
```js
108+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js');
109+
110+
<Table tableId="2" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 5)} loading={true} />
111+
```
112+
113+
Without column sorting
114+
```js
115+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js');
116+
117+
<Table tableId="2" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} disableColumnSorting={true} />
118+
```
119+
120+
Styles
121+
```js
122+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_NESTED_ROWS } = require('./src/mocks/Table.mock.js');
123+
124+
<>
125+
<div className="u-margin-bottom">
126+
<Table tableId="3" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 4)} striped={false} />
127+
</div>
128+
129+
<div className="u-margin-bottom">
130+
<Table tableId="4" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} type="primary" />
131+
</div>
132+
133+
<Table tableId="5" columns={TABLE_MOCK_COLUMNS()} rows={TABLE_MOCK_ROWS.slice(0, 2)} type="secondary" />
134+
</>
135+
```
136+
137+
Extra table actions
138+
```js
139+
const { TABLE_MOCK_COLUMNS, TABLE_MOCK_ROWS, TABLE_MOCK_FILTER } = require('./src/mocks/Table.mock.js');
140+
const Button = require('../button').default;
141+
142+
<Table
143+
tableId="5"
144+
columns={TABLE_MOCK_COLUMNS()}
145+
rows={TABLE_MOCK_ROWS.slice(0, 2)}
146+
extraTableActions={(
147+
<Button icon="ai-pencil-1" className="u-margin-right-xs" />
148+
)}
149+
filters={TABLE_MOCK_FILTER}
150+
/>
151+
```

packages/table/package-lock.json

Lines changed: 156 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/table/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "table",
3+
"version": "0.0.1-0",
4+
"description": "",
5+
"main": "dist/index.cjs.js",
6+
"module": "dist/index.esm.js",
7+
"keywords": [],
8+
"author": "",
9+
"license": "ISC",
10+
"dependencies": {
11+
"react": "^16.13.1",
12+
"react-dom": "^16.13.1",
13+
"rc-slider": "~8.6.1",
14+
"classnames": "~2.2.6",
15+
"moment": "^2.24.0",
16+
"react-input-mask": "^2.0.4",
17+
"icon": "0.0.1-0"
18+
}
19+
}

0 commit comments

Comments
 (0)