@syook/react-tabulous 3.0.3 → 4.0.0-beta-0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +206 -197
- package/lib/index.esm.js +19 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/types/App.d.ts +4 -0
- package/lib/types/__tests__/reactTabulous/components/base/gridBody.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/base/gridFooterPlaceholder.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/bulkAction/bulkActions.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/cell/columnCell.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/columnBody/columnBody.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderCheckbox.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderItem.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderMenu.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaders.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/containers/gridRoot.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/filter/index.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/filter/inputCategories.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/gridHeader.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/pagination/pagination.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbar.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarColumns.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarDensity.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarExport.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarFilter.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarQuickFilter.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/button/button.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/checkbox.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/divider.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/icon.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/iconButton/iconButton.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/input/input.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/inputError/index.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/inputLabel/index.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/loader.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/menu.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/popup/popup.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/select/select.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/switch.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/components/widgets/typography.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/context/dataGridContextProvider.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/helpers/classnames.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/helpers/debounce.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/helpers/getColumnsAndSearchKeys.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/helpers/toCamelCase.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useDragHandler.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridColumn.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridColumnHeaders.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridDensity.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridExport.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridFilter.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridPagination.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridPin.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridResize.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridRootProps.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridRowSelection.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridSearch.test.d.ts +1 -0
- package/lib/types/__tests__/reactTabulous/hooks/useGridSort.test.d.ts +1 -0
- package/lib/types/data/index.d.ts +83 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/base/gridBody.d.ts +2 -0
- package/lib/types/reactTabulous/components/base/gridFooterPlaceholder.d.ts +2 -0
- package/lib/types/reactTabulous/components/base/index.d.ts +2 -0
- package/lib/types/reactTabulous/components/bulkAction/index.d.ts +9 -0
- package/lib/types/reactTabulous/components/cell/columnCell.d.ts +12 -0
- package/lib/types/reactTabulous/components/cell/gridActionsCellItem.d.ts +10 -0
- package/lib/types/reactTabulous/components/columnBody/columnBody.d.ts +2 -0
- package/lib/types/reactTabulous/components/columnBody/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/columnHeaders/columnHeaderCheckbox.d.ts +7 -0
- package/lib/types/reactTabulous/components/columnHeaders/columnHeaderItem.d.ts +31 -0
- package/lib/types/reactTabulous/components/columnHeaders/columnHeaderMenu.d.ts +18 -0
- package/lib/types/reactTabulous/components/columnHeaders/columnHeaders.d.ts +2 -0
- package/lib/types/reactTabulous/components/columnHeaders/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/containers/gridRoot.d.ts +2 -0
- package/lib/types/reactTabulous/components/containers/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/filter/index.d.ts +13 -0
- package/lib/types/reactTabulous/components/filter/inputCategories.d.ts +13 -0
- package/lib/types/reactTabulous/components/gridHeader.d.ts +2 -0
- package/lib/types/reactTabulous/components/index.d.ts +3 -0
- package/lib/types/reactTabulous/components/overlayWrapper/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/overlayWrapper/overlayWrapper.d.ts +6 -0
- package/lib/types/reactTabulous/components/pagination/index.d.ts +1 -0
- package/lib/types/reactTabulous/components/pagination/pagination.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbar.d.ts +6 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbarColumns.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbarDensity.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbarExport.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbarFilter.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/gridToolbarQuickFilter.d.ts +2 -0
- package/lib/types/reactTabulous/components/toolbar/index.d.ts +6 -0
- package/lib/types/reactTabulous/components/widgets/button/buttonStyle.d.ts +5 -0
- package/lib/types/reactTabulous/components/widgets/button/index.d.ts +21 -0
- package/lib/types/reactTabulous/components/widgets/checkbox.d.ts +7 -0
- package/lib/types/reactTabulous/components/widgets/divider.d.ts +2 -0
- package/lib/types/reactTabulous/components/widgets/icon.d.ts +41 -0
- package/lib/types/reactTabulous/components/widgets/iconButton/index.d.ts +12 -0
- package/lib/types/reactTabulous/components/widgets/index.d.ts +12 -0
- package/lib/types/reactTabulous/components/widgets/input/index.d.ts +26 -0
- package/lib/types/reactTabulous/components/widgets/input/inputStyle.d.ts +5 -0
- package/lib/types/reactTabulous/components/widgets/inputError/index.d.ts +8 -0
- package/lib/types/reactTabulous/components/widgets/inputLabel/index.d.ts +13 -0
- package/lib/types/reactTabulous/components/widgets/loader.d.ts +1 -0
- package/lib/types/reactTabulous/components/widgets/menu.d.ts +16 -0
- package/lib/types/reactTabulous/components/widgets/popup/index.d.ts +12 -0
- package/lib/types/reactTabulous/components/widgets/select/index.d.ts +13 -0
- package/lib/types/reactTabulous/components/widgets/select/selectStyle.d.ts +5 -0
- package/lib/types/reactTabulous/components/widgets/switch.d.ts +8 -0
- package/lib/types/reactTabulous/components/widgets/typography.d.ts +28 -0
- package/lib/types/reactTabulous/constant/index.d.ts +10 -0
- package/lib/types/reactTabulous/constant/noRowsOverlay.d.ts +2 -0
- package/lib/types/reactTabulous/context/dataGridContextProvider.d.ts +6 -0
- package/lib/types/reactTabulous/context/dataGridRootPropsContext.d.ts +3 -0
- package/lib/types/reactTabulous/context/index.d.ts +1 -0
- package/lib/types/reactTabulous/context/test-utils.d.ts +5 -0
- package/lib/types/reactTabulous/helpers/classnames.d.ts +2 -0
- package/lib/types/reactTabulous/helpers/debounce.d.ts +1 -0
- package/lib/types/reactTabulous/helpers/getColumnsAndSearchKeys.d.ts +5 -0
- package/lib/types/reactTabulous/helpers/toCamelCase.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useClickAwayListener.d.ts +2 -0
- package/lib/types/reactTabulous/hooks/useDragHandler.d.ts +8 -0
- package/lib/types/reactTabulous/hooks/useGridColumn.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridColumnHeaders.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridDensity.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridExport.d.ts +3 -0
- package/lib/types/reactTabulous/hooks/useGridFilter.d.ts +6 -0
- package/lib/types/reactTabulous/hooks/useGridPagination.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridPin.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridResize.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridRootProps.d.ts +48 -0
- package/lib/types/reactTabulous/hooks/useGridRowSelection.d.ts +1 -0
- package/lib/types/reactTabulous/hooks/useGridSearch.d.ts +5 -0
- package/lib/types/reactTabulous/hooks/useGridSort.d.ts +4 -0
- package/lib/types/reactTabulous/index.d.ts +2 -0
- package/lib/types/reactTabulous/models/columnDef/columnDef.d.ts +72 -0
- package/lib/types/reactTabulous/models/columnDef/columnPin.d.ts +48 -0
- package/lib/types/reactTabulous/models/columnDef/columnType.d.ts +2 -0
- package/lib/types/reactTabulous/models/columnDef/index.d.ts +3 -0
- package/lib/types/reactTabulous/models/gridDensity.d.ts +4 -0
- package/lib/types/reactTabulous/models/gridFiltersModel.d.ts +9 -0
- package/lib/types/reactTabulous/models/gridRows.d.ts +2 -0
- package/lib/types/reactTabulous/models/gridSortModel.d.ts +1 -0
- package/lib/types/reactTabulous/models/index.d.ts +7 -0
- package/lib/types/reactTabulous/models/logger.d.ts +6 -0
- package/lib/types/reactTabulous/models/props/dataGridProps.d.ts +158 -0
- package/lib/types/reactTabulous/models/props/index.d.ts +1 -0
- package/lib/types/reactTabulous/reactTabulous/index.d.ts +1 -0
- package/lib/types/reactTabulous/reactTabulous/reactTabulous.d.ts +5 -0
- package/lib/types/reactTabulous/reactTabulous/reactTabulousStyle.d.ts +5 -0
- package/lib/types/setupTests.d.ts +1 -0
- package/package.json +107 -75
- package/CHANGELOG.md +0 -27
- package/lib/react-tabulous.min.js +0 -2
- package/lib/react-tabulous.min.js.LICENSE.txt +0 -20
package/README.md
CHANGED
|
@@ -6,82 +6,71 @@ To use in your own project, install it via npm package.
|
|
|
6
6
|
|
|
7
7
|
`npm i @syook/react-tabulous`
|
|
8
8
|
|
|
9
|
-
Or you can clone
|
|
9
|
+
Or you can clone.
|
|
10
10
|
|
|
11
11
|
`git clone git@github.com:syook/react-tabulous.git`
|
|
12
12
|
|
|
13
|
-
`npm run build`
|
|
14
|
-
|
|
15
|
-
The files will be under `./lib` folder.
|
|
16
|
-
|
|
17
13
|
## Options
|
|
18
14
|
|
|
19
15
|
### a. Available Column Options
|
|
20
16
|
|
|
21
|
-
| Option
|
|
22
|
-
|
|
|
23
|
-
| `headerName`
|
|
24
|
-
| `type`
|
|
25
|
-
| `field`
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| Option | Description | Type |
|
|
39
|
-
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
40
|
-
| `isVisible` | Function which returns if the action is visible or not | Function |
|
|
41
|
-
| `isDisabled` | Function which returns if the action is disabled or not | Function |
|
|
42
|
-
| `function` | Function to be executed on action event | Function |
|
|
43
|
-
| `icon` | Icon name to represent the action | Function |
|
|
44
|
-
| `name` | Name of action | string |
|
|
45
|
-
| `color` | color of action component | string |
|
|
46
|
-
| `iconColor` | color of icon | string |
|
|
47
|
-
| `size` | size of icon | string |
|
|
48
|
-
| `inverted` | to enable inverted behaviour of action element | function |
|
|
49
|
-
| `iconInverted` | to enable inverted behaviour of icon | boolean |
|
|
50
|
-
| `className` | any custom classname to be applied for action element | string |
|
|
51
|
-
| `iconClassName` | any custom classname to be applied for icon | string |
|
|
52
|
-
| `hasCustomComponent` | if the action is any custom component other than button | boolean |
|
|
53
|
-
| `customComponent` | custom component above the table along with filter button (has access to filtered data in table layout, visible columns, searchText and filtered original data ), {tableData, columns, searchText, filteredTableData} | function |
|
|
17
|
+
| Option | Description | Type | isRequired | Default |
|
|
18
|
+
| -------------- | -------------------------------------------------------------------------- | -------- | ---------- | ------- |
|
|
19
|
+
| `headerName` | Name of Column to be shown in header | String | true | |
|
|
20
|
+
| `type` | type of the field | String | true | |
|
|
21
|
+
| `field` | path to get value to be displayed | String | true | |
|
|
22
|
+
| `valueGetter` | should return string that to be displayed in the cell or used in filter | Function | false | null |
|
|
23
|
+
| `renderCell` | returns the element to be shown in the column cell | Function | false | null |
|
|
24
|
+
| `description` | shows the description of the column on hover in tooltip | String | false | '' |
|
|
25
|
+
| `isSortable` | is column sortable | Boolean | false | false |
|
|
26
|
+
| `isSearchable` | is column searchable | Boolean | false | false |
|
|
27
|
+
| `isFilterable` | is column filterable | Boolean | false | false |
|
|
28
|
+
| `isVisible` | should hide/show the column or not | Boolean | false | true |
|
|
29
|
+
| `options` | array of options if the type is MultiSelect or Single Select | Array | false | [] |
|
|
30
|
+
| `isResizable` | is column resizable | Boolean | false | false |
|
|
31
|
+
| `pinned` | String='left' or 'right', where to fix the column | String | false | null |
|
|
32
|
+
| `width` | to fix column width to a value in pixels if width exceeding this threshold | Number | false | null |
|
|
54
33
|
|
|
55
34
|
### c. Available Types
|
|
56
35
|
|
|
57
36
|
| Type | Filter queries available | Extra props needed |
|
|
58
37
|
| ----------------- | --------------------------------------------------------------- | ------------------ |
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
38
|
+
| `string` | contains, does not contains, is, is not, is empty, is not empty |
|
|
39
|
+
| `dateTime`/`date` | is, is not, is after, is before, is empty, is not empty |
|
|
40
|
+
| `number` | =, =/ , < , <=, > , >= , is empty, is not empty |
|
|
41
|
+
| `singleSelect` | has any of, has none of, is empty, is not empty | options: [] |
|
|
42
|
+
| `multiSelect` | is, is not, is empty, is not empty, | options: [] |
|
|
64
43
|
|
|
65
44
|
### d. Component Props
|
|
66
45
|
|
|
67
|
-
| Prop
|
|
68
|
-
|
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
46
|
+
| Prop | Description | Default | Required | Type |
|
|
47
|
+
| ------------------------------- | ------------------------------------------------------- | --------- | -------- | ------------------- |
|
|
48
|
+
| `data` | data for the table | | true | |
|
|
49
|
+
| `columns` | columns for the table | | | |
|
|
50
|
+
| `emptyPlaceholder` | placeholder for empty cells | '' | false | String |
|
|
51
|
+
| `checkboxSelection` | shows checkbox for bulk actions | false | false | Boolean |
|
|
52
|
+
| `bulkActions` | bulk actions to show when checkbox selected | [] | false | String[] |
|
|
53
|
+
| `onBulkActionClick` | onClick of bulk action | null | false | Function |
|
|
54
|
+
| `loading` | loading state inside the table | false | false | Boolean |
|
|
55
|
+
| `defaultPageSize` | rows per page in the table | 10 | false | Number |
|
|
56
|
+
| `noRowsOverlay` | shows when there is no data to display | ReactNode | false | String or ReactNode |
|
|
57
|
+
| `density` | density of the rows | standard | false | string |
|
|
58
|
+
| `hidePagination` | hides pagination | false | false | Boolean |
|
|
59
|
+
| `hideFooterRowCount` | hides row count in footer | false | false | Boolean |
|
|
60
|
+
| `hideFooter` | hides footer | false | false | Boolean |
|
|
61
|
+
| `disableColumnReorder` | disables column reordering | false | false | Boolean |
|
|
62
|
+
| `disableColumnResize` | disables column resizing | false | false | Boolean |
|
|
63
|
+
| `disableColumnPinning` | disables column pinning | false | false | Boolean |
|
|
64
|
+
| `disableColumnFilter` | disables column filtering | false | false | Boolean |
|
|
65
|
+
| `disableColumnSelector` | disables column show and hiding | false | false | Boolean |
|
|
66
|
+
| `disableDensitySelector` | disables changing of row density | false | false | Boolean |
|
|
67
|
+
| `disableColumnMenu` | disables showing column menu | false | false | Boolean |
|
|
68
|
+
| `disableMultipleColumnsSorting` | disables sorting option in each column | false | false | Boolean |
|
|
69
|
+
| `disableSearch` | disables search | false | false | Boolean |
|
|
70
|
+
| `disableColumnExport` | disables column export | false | false | Boolean |
|
|
71
|
+
| `fetchOnPageChange` | page, rows per page or sorting change for paginated API | null | false | Function |
|
|
72
|
+
| `rowsCount` | shows rows count if it is paginated API | false | false | Boolean |
|
|
73
|
+
| `customExport` | custom export function | null | false | Boolean |
|
|
85
74
|
|
|
86
75
|
## Example
|
|
87
76
|
|
|
@@ -89,154 +78,174 @@ The files will be under `./lib` folder.
|
|
|
89
78
|
...
|
|
90
79
|
|
|
91
80
|
import ReactTabulous from 'react-tabulous';
|
|
92
|
-
import
|
|
93
|
-
import { Button, Input } from 'semantic-ui-react';
|
|
81
|
+
import { Button, IconButton, Select } from 'commonComponents/widgets';
|
|
94
82
|
|
|
95
83
|
...
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
isFilterable: true,
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
headerName: 'Price',
|
|
150
|
-
field: 'price',
|
|
151
|
-
type: 'Number',
|
|
152
|
-
cell: rowObject => rowObject.price,
|
|
153
|
-
isSortable: true,
|
|
154
|
-
isSearchable: true,
|
|
155
|
-
isFilterable: true,
|
|
156
|
-
isResizable: true,
|
|
157
|
-
},
|
|
85
|
+
const minAge = 20;
|
|
86
|
+
const maxAge = 80;
|
|
87
|
+
|
|
88
|
+
const workPlaceOptions = ['Bengaluru', 'Mumbai', 'Delhi', 'Chennai', 'Hyderabad'];
|
|
89
|
+
|
|
90
|
+
function generateUniqueId(): number {
|
|
91
|
+
const random: number = Math.floor(Math.random() * 10000); // Generate a random number between 0 and 9999
|
|
92
|
+
const id: string = random.toString().padStart(4, '0'); // Convert the random number to a string and ensure that it has exactly 4 digits
|
|
93
|
+
return +id;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getRandomBirthDate(): Date {
|
|
97
|
+
const minYear: number = 1900;
|
|
98
|
+
const minMonth: number = 0;
|
|
99
|
+
const currentYear: number = new Date().getFullYear();
|
|
100
|
+
const currentMonth: number = new Date().getMonth();
|
|
101
|
+
const minDate: Date = new Date(minYear, minMonth, 1);
|
|
102
|
+
const currentDate: Date = new Date(currentYear, currentMonth, 1);
|
|
103
|
+
const diffTime: number = Math.abs(currentDate.getTime() - minDate.getTime());
|
|
104
|
+
const diffDays: number = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
105
|
+
const randomDays: number = Math.floor(Math.random() * diffDays);
|
|
106
|
+
const randomDate: Date = new Date(minDate);
|
|
107
|
+
randomDate.setDate(minDate.getDate() + randomDays);
|
|
108
|
+
return randomDate;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const data = Array.from({ length: 50 }, (_, i) => {
|
|
112
|
+
const id = generateUniqueId();
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id,
|
|
116
|
+
name: `test${i + 1}`,
|
|
117
|
+
email: `test${i + 1}@test.com`,
|
|
118
|
+
age: Math.floor(Math.random() * (maxAge - minAge + 1)) + minAge,,
|
|
119
|
+
birthDate: getRandomBirthDate(),
|
|
120
|
+
level: Math.ceil(Math.random() * 3),
|
|
121
|
+
workPlace: workPlaceOptions[Math.floor(Math.random() * workPlaceOptions.length)]
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const columns = [
|
|
126
|
+
{
|
|
127
|
+
field: 'id',
|
|
128
|
+
headerName: 'ID',
|
|
129
|
+
type: 'number',
|
|
130
|
+
isFilterable: true,
|
|
131
|
+
isSortable: true,
|
|
132
|
+
isSearchable: true
|
|
133
|
+
},
|
|
158
134
|
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
135
|
+
field: 'name',
|
|
136
|
+
headerName: 'Name',
|
|
137
|
+
type: 'string',
|
|
138
|
+
isFilterable: true,
|
|
139
|
+
isSortable: true,
|
|
140
|
+
isSearchable: true
|
|
141
|
+
},
|
|
167
142
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
143
|
+
field: 'age',
|
|
144
|
+
headerName: 'Age',
|
|
145
|
+
type: 'number',
|
|
146
|
+
isFilterable: true,
|
|
147
|
+
isSortable: true,
|
|
148
|
+
isSearchable: true
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
field: 'level',
|
|
152
|
+
headerName: 'Level',
|
|
153
|
+
type: 'string',
|
|
154
|
+
renderCell: (row: any) => {
|
|
155
|
+
const level = row?.level ?? 1;
|
|
156
|
+
const levelText = level === 1 ? 'Beginner' : level === 2 ? 'Intermediate' : 'Advanced';
|
|
157
|
+
const levelColor = level === 1 ? 'green' : level === 2 ? 'orange' : 'red';
|
|
158
|
+
return <span style={{ color: levelColor }}>{levelText}</span>;
|
|
159
|
+
},
|
|
160
|
+
isFilterable: true,
|
|
161
|
+
isSortable: true,
|
|
162
|
+
isSearchable: true
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
field: 'birthDate',
|
|
166
|
+
headerName: 'Birth Date',
|
|
167
|
+
type: 'date',
|
|
168
|
+
isFilterable: true,
|
|
169
|
+
isSortable: true,
|
|
170
|
+
isSearchable: true
|
|
171
|
+
},
|
|
179
172
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
isResizable: true,
|
|
188
|
-
defaultWidth: 200,
|
|
189
|
-
},
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
updatingObjectId = () => false;
|
|
193
|
-
|
|
194
|
-
actionDefs = [
|
|
173
|
+
field: 'email',
|
|
174
|
+
headerName: 'Email Address',
|
|
175
|
+
type: 'string',
|
|
176
|
+
isFilterable: true,
|
|
177
|
+
// isSortable: true,
|
|
178
|
+
isSearchable: true
|
|
179
|
+
},
|
|
195
180
|
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
field: 'workPlace',
|
|
182
|
+
headerName: 'Work Place',
|
|
183
|
+
type: 'string',
|
|
184
|
+
renderCell: (row: any) => {
|
|
185
|
+
const workPlace = row?.workPlace ?? '';
|
|
186
|
+
|
|
187
|
+
const onChange = (event: any) => {
|
|
188
|
+
console.log(event.target.value);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return <Select value={workPlace} options={workPlaceOptions} onChange={onChange} />;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
204
194
|
{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
195
|
+
field: 'action',
|
|
196
|
+
headerName: 'Action',
|
|
197
|
+
type: 'action',
|
|
198
|
+
renderCell: (row: any) => {
|
|
199
|
+
const onClick = () => {
|
|
200
|
+
alert(JSON.stringify(row, null, 2));
|
|
201
|
+
console.log(row);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<div style={{ display: 'flex' }}>
|
|
206
|
+
<IconButton name="add" onClick={onClick} type="transparent" size={16} />
|
|
207
|
+
<IconButton name="close" onClick={onClick} type="transparent" size={16} />
|
|
208
|
+
<Button size="small" variant="contained" onClick={onClick}>
|
|
209
|
+
Click
|
|
210
|
+
</Button>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
const customComponent = React.useCallback(
|
|
218
|
+
(filteredAndSortedData: any, searchText: string, columns: any) => {
|
|
219
|
+
return (
|
|
220
|
+
<div>
|
|
221
|
+
<Button
|
|
222
|
+
onClick={() => {
|
|
223
|
+
console.log('Button clicked', filteredAndSortedData, searchText, columns);
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
Create New User
|
|
227
|
+
</Button>
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
},
|
|
231
|
+
[]
|
|
232
|
+
);
|
|
225
233
|
|
|
226
234
|
...
|
|
227
235
|
|
|
228
236
|
<ReactTabulous
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
data={data}
|
|
238
|
+
columns={columns}
|
|
239
|
+
emptyPlaceholder="N/A"
|
|
240
|
+
checkboxSelection
|
|
241
|
+
noRowsOverlay={<NoRowsOverlay />}
|
|
242
|
+
defaultPageSize={50}
|
|
243
|
+
bulkActions={['delete', 'edit']}
|
|
244
|
+
onBulkActionClick={(action, selectedRows) => {
|
|
245
|
+
console.log(action, selectedRows);
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
{customComponent}
|
|
240
249
|
</ReactTabulous>
|
|
241
250
|
|
|
242
251
|
...
|