@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.
Files changed (153) hide show
  1. package/README.md +206 -197
  2. package/lib/index.esm.js +19 -0
  3. package/lib/index.esm.js.map +1 -0
  4. package/lib/index.js +19 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/types/App.d.ts +4 -0
  7. package/lib/types/__tests__/reactTabulous/components/base/gridBody.test.d.ts +1 -0
  8. package/lib/types/__tests__/reactTabulous/components/base/gridFooterPlaceholder.test.d.ts +1 -0
  9. package/lib/types/__tests__/reactTabulous/components/bulkAction/bulkActions.test.d.ts +1 -0
  10. package/lib/types/__tests__/reactTabulous/components/cell/columnCell.test.d.ts +1 -0
  11. package/lib/types/__tests__/reactTabulous/components/columnBody/columnBody.test.d.ts +1 -0
  12. package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderCheckbox.test.d.ts +1 -0
  13. package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderItem.test.d.ts +1 -0
  14. package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaderMenu.test.d.ts +1 -0
  15. package/lib/types/__tests__/reactTabulous/components/columnHeaders/columnHeaders.test.d.ts +1 -0
  16. package/lib/types/__tests__/reactTabulous/components/containers/gridRoot.test.d.ts +1 -0
  17. package/lib/types/__tests__/reactTabulous/components/filter/index.test.d.ts +1 -0
  18. package/lib/types/__tests__/reactTabulous/components/filter/inputCategories.test.d.ts +1 -0
  19. package/lib/types/__tests__/reactTabulous/components/gridHeader.test.d.ts +1 -0
  20. package/lib/types/__tests__/reactTabulous/components/pagination/pagination.test.d.ts +1 -0
  21. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbar.test.d.ts +1 -0
  22. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarColumns.test.d.ts +1 -0
  23. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarDensity.test.d.ts +1 -0
  24. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarExport.test.d.ts +1 -0
  25. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarFilter.test.d.ts +1 -0
  26. package/lib/types/__tests__/reactTabulous/components/toolbar/gridToolbarQuickFilter.test.d.ts +1 -0
  27. package/lib/types/__tests__/reactTabulous/components/widgets/button/button.test.d.ts +1 -0
  28. package/lib/types/__tests__/reactTabulous/components/widgets/checkbox.test.d.ts +1 -0
  29. package/lib/types/__tests__/reactTabulous/components/widgets/divider.test.d.ts +1 -0
  30. package/lib/types/__tests__/reactTabulous/components/widgets/icon.test.d.ts +1 -0
  31. package/lib/types/__tests__/reactTabulous/components/widgets/iconButton/iconButton.test.d.ts +1 -0
  32. package/lib/types/__tests__/reactTabulous/components/widgets/input/input.test.d.ts +1 -0
  33. package/lib/types/__tests__/reactTabulous/components/widgets/inputError/index.test.d.ts +1 -0
  34. package/lib/types/__tests__/reactTabulous/components/widgets/inputLabel/index.test.d.ts +1 -0
  35. package/lib/types/__tests__/reactTabulous/components/widgets/loader.test.d.ts +1 -0
  36. package/lib/types/__tests__/reactTabulous/components/widgets/menu.test.d.ts +1 -0
  37. package/lib/types/__tests__/reactTabulous/components/widgets/popup/popup.test.d.ts +1 -0
  38. package/lib/types/__tests__/reactTabulous/components/widgets/select/select.test.d.ts +1 -0
  39. package/lib/types/__tests__/reactTabulous/components/widgets/switch.test.d.ts +1 -0
  40. package/lib/types/__tests__/reactTabulous/components/widgets/typography.test.d.ts +1 -0
  41. package/lib/types/__tests__/reactTabulous/context/dataGridContextProvider.test.d.ts +1 -0
  42. package/lib/types/__tests__/reactTabulous/helpers/classnames.test.d.ts +1 -0
  43. package/lib/types/__tests__/reactTabulous/helpers/debounce.test.d.ts +1 -0
  44. package/lib/types/__tests__/reactTabulous/helpers/getColumnsAndSearchKeys.test.d.ts +1 -0
  45. package/lib/types/__tests__/reactTabulous/helpers/toCamelCase.test.d.ts +1 -0
  46. package/lib/types/__tests__/reactTabulous/hooks/useDragHandler.test.d.ts +1 -0
  47. package/lib/types/__tests__/reactTabulous/hooks/useGridColumn.test.d.ts +1 -0
  48. package/lib/types/__tests__/reactTabulous/hooks/useGridColumnHeaders.test.d.ts +1 -0
  49. package/lib/types/__tests__/reactTabulous/hooks/useGridDensity.test.d.ts +1 -0
  50. package/lib/types/__tests__/reactTabulous/hooks/useGridExport.test.d.ts +1 -0
  51. package/lib/types/__tests__/reactTabulous/hooks/useGridFilter.test.d.ts +1 -0
  52. package/lib/types/__tests__/reactTabulous/hooks/useGridPagination.test.d.ts +1 -0
  53. package/lib/types/__tests__/reactTabulous/hooks/useGridPin.test.d.ts +1 -0
  54. package/lib/types/__tests__/reactTabulous/hooks/useGridResize.test.d.ts +1 -0
  55. package/lib/types/__tests__/reactTabulous/hooks/useGridRootProps.test.d.ts +1 -0
  56. package/lib/types/__tests__/reactTabulous/hooks/useGridRowSelection.test.d.ts +1 -0
  57. package/lib/types/__tests__/reactTabulous/hooks/useGridSearch.test.d.ts +1 -0
  58. package/lib/types/__tests__/reactTabulous/hooks/useGridSort.test.d.ts +1 -0
  59. package/lib/types/data/index.d.ts +83 -0
  60. package/lib/types/index.d.ts +1 -0
  61. package/lib/types/reactTabulous/components/base/gridBody.d.ts +2 -0
  62. package/lib/types/reactTabulous/components/base/gridFooterPlaceholder.d.ts +2 -0
  63. package/lib/types/reactTabulous/components/base/index.d.ts +2 -0
  64. package/lib/types/reactTabulous/components/bulkAction/index.d.ts +9 -0
  65. package/lib/types/reactTabulous/components/cell/columnCell.d.ts +12 -0
  66. package/lib/types/reactTabulous/components/cell/gridActionsCellItem.d.ts +10 -0
  67. package/lib/types/reactTabulous/components/columnBody/columnBody.d.ts +2 -0
  68. package/lib/types/reactTabulous/components/columnBody/index.d.ts +1 -0
  69. package/lib/types/reactTabulous/components/columnHeaders/columnHeaderCheckbox.d.ts +7 -0
  70. package/lib/types/reactTabulous/components/columnHeaders/columnHeaderItem.d.ts +31 -0
  71. package/lib/types/reactTabulous/components/columnHeaders/columnHeaderMenu.d.ts +18 -0
  72. package/lib/types/reactTabulous/components/columnHeaders/columnHeaders.d.ts +2 -0
  73. package/lib/types/reactTabulous/components/columnHeaders/index.d.ts +1 -0
  74. package/lib/types/reactTabulous/components/containers/gridRoot.d.ts +2 -0
  75. package/lib/types/reactTabulous/components/containers/index.d.ts +1 -0
  76. package/lib/types/reactTabulous/components/filter/index.d.ts +13 -0
  77. package/lib/types/reactTabulous/components/filter/inputCategories.d.ts +13 -0
  78. package/lib/types/reactTabulous/components/gridHeader.d.ts +2 -0
  79. package/lib/types/reactTabulous/components/index.d.ts +3 -0
  80. package/lib/types/reactTabulous/components/overlayWrapper/index.d.ts +1 -0
  81. package/lib/types/reactTabulous/components/overlayWrapper/overlayWrapper.d.ts +6 -0
  82. package/lib/types/reactTabulous/components/pagination/index.d.ts +1 -0
  83. package/lib/types/reactTabulous/components/pagination/pagination.d.ts +2 -0
  84. package/lib/types/reactTabulous/components/toolbar/gridToolbar.d.ts +6 -0
  85. package/lib/types/reactTabulous/components/toolbar/gridToolbarColumns.d.ts +2 -0
  86. package/lib/types/reactTabulous/components/toolbar/gridToolbarDensity.d.ts +2 -0
  87. package/lib/types/reactTabulous/components/toolbar/gridToolbarExport.d.ts +2 -0
  88. package/lib/types/reactTabulous/components/toolbar/gridToolbarFilter.d.ts +2 -0
  89. package/lib/types/reactTabulous/components/toolbar/gridToolbarQuickFilter.d.ts +2 -0
  90. package/lib/types/reactTabulous/components/toolbar/index.d.ts +6 -0
  91. package/lib/types/reactTabulous/components/widgets/button/buttonStyle.d.ts +5 -0
  92. package/lib/types/reactTabulous/components/widgets/button/index.d.ts +21 -0
  93. package/lib/types/reactTabulous/components/widgets/checkbox.d.ts +7 -0
  94. package/lib/types/reactTabulous/components/widgets/divider.d.ts +2 -0
  95. package/lib/types/reactTabulous/components/widgets/icon.d.ts +41 -0
  96. package/lib/types/reactTabulous/components/widgets/iconButton/index.d.ts +12 -0
  97. package/lib/types/reactTabulous/components/widgets/index.d.ts +12 -0
  98. package/lib/types/reactTabulous/components/widgets/input/index.d.ts +26 -0
  99. package/lib/types/reactTabulous/components/widgets/input/inputStyle.d.ts +5 -0
  100. package/lib/types/reactTabulous/components/widgets/inputError/index.d.ts +8 -0
  101. package/lib/types/reactTabulous/components/widgets/inputLabel/index.d.ts +13 -0
  102. package/lib/types/reactTabulous/components/widgets/loader.d.ts +1 -0
  103. package/lib/types/reactTabulous/components/widgets/menu.d.ts +16 -0
  104. package/lib/types/reactTabulous/components/widgets/popup/index.d.ts +12 -0
  105. package/lib/types/reactTabulous/components/widgets/select/index.d.ts +13 -0
  106. package/lib/types/reactTabulous/components/widgets/select/selectStyle.d.ts +5 -0
  107. package/lib/types/reactTabulous/components/widgets/switch.d.ts +8 -0
  108. package/lib/types/reactTabulous/components/widgets/typography.d.ts +28 -0
  109. package/lib/types/reactTabulous/constant/index.d.ts +10 -0
  110. package/lib/types/reactTabulous/constant/noRowsOverlay.d.ts +2 -0
  111. package/lib/types/reactTabulous/context/dataGridContextProvider.d.ts +6 -0
  112. package/lib/types/reactTabulous/context/dataGridRootPropsContext.d.ts +3 -0
  113. package/lib/types/reactTabulous/context/index.d.ts +1 -0
  114. package/lib/types/reactTabulous/context/test-utils.d.ts +5 -0
  115. package/lib/types/reactTabulous/helpers/classnames.d.ts +2 -0
  116. package/lib/types/reactTabulous/helpers/debounce.d.ts +1 -0
  117. package/lib/types/reactTabulous/helpers/getColumnsAndSearchKeys.d.ts +5 -0
  118. package/lib/types/reactTabulous/helpers/toCamelCase.d.ts +1 -0
  119. package/lib/types/reactTabulous/hooks/useClickAwayListener.d.ts +2 -0
  120. package/lib/types/reactTabulous/hooks/useDragHandler.d.ts +8 -0
  121. package/lib/types/reactTabulous/hooks/useGridColumn.d.ts +1 -0
  122. package/lib/types/reactTabulous/hooks/useGridColumnHeaders.d.ts +1 -0
  123. package/lib/types/reactTabulous/hooks/useGridDensity.d.ts +1 -0
  124. package/lib/types/reactTabulous/hooks/useGridExport.d.ts +3 -0
  125. package/lib/types/reactTabulous/hooks/useGridFilter.d.ts +6 -0
  126. package/lib/types/reactTabulous/hooks/useGridPagination.d.ts +1 -0
  127. package/lib/types/reactTabulous/hooks/useGridPin.d.ts +1 -0
  128. package/lib/types/reactTabulous/hooks/useGridResize.d.ts +1 -0
  129. package/lib/types/reactTabulous/hooks/useGridRootProps.d.ts +48 -0
  130. package/lib/types/reactTabulous/hooks/useGridRowSelection.d.ts +1 -0
  131. package/lib/types/reactTabulous/hooks/useGridSearch.d.ts +5 -0
  132. package/lib/types/reactTabulous/hooks/useGridSort.d.ts +4 -0
  133. package/lib/types/reactTabulous/index.d.ts +2 -0
  134. package/lib/types/reactTabulous/models/columnDef/columnDef.d.ts +72 -0
  135. package/lib/types/reactTabulous/models/columnDef/columnPin.d.ts +48 -0
  136. package/lib/types/reactTabulous/models/columnDef/columnType.d.ts +2 -0
  137. package/lib/types/reactTabulous/models/columnDef/index.d.ts +3 -0
  138. package/lib/types/reactTabulous/models/gridDensity.d.ts +4 -0
  139. package/lib/types/reactTabulous/models/gridFiltersModel.d.ts +9 -0
  140. package/lib/types/reactTabulous/models/gridRows.d.ts +2 -0
  141. package/lib/types/reactTabulous/models/gridSortModel.d.ts +1 -0
  142. package/lib/types/reactTabulous/models/index.d.ts +7 -0
  143. package/lib/types/reactTabulous/models/logger.d.ts +6 -0
  144. package/lib/types/reactTabulous/models/props/dataGridProps.d.ts +158 -0
  145. package/lib/types/reactTabulous/models/props/index.d.ts +1 -0
  146. package/lib/types/reactTabulous/reactTabulous/index.d.ts +1 -0
  147. package/lib/types/reactTabulous/reactTabulous/reactTabulous.d.ts +5 -0
  148. package/lib/types/reactTabulous/reactTabulous/reactTabulousStyle.d.ts +5 -0
  149. package/lib/types/setupTests.d.ts +1 -0
  150. package/package.json +107 -75
  151. package/CHANGELOG.md +0 -27
  152. package/lib/react-tabulous.min.js +0 -2
  153. 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 and build it.
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 | Description | Type | isRequired | Default |
22
- | ---------------- | ----------------------------------------------------------------------------------- | ------------------ | ---------- | ------- |
23
- | `headerName` | Name of Column to be shown in header | String | true | |
24
- | `type` | type of the field | String | true | |
25
- | `field` | String='path to get value to be displayed' function='function should return string' | String or function | true | |
26
- | `cell` | returns the element to be shown in the column cell | Function | false | |
27
- | `isSortable` | is column sortable | Boolean | false | |
28
- | `isSearchable` | is column searchable | Boolean | false | |
29
- | `isFilterable` | is column filterable | Boolean | false | |
30
- | `omitInHideList` | should the column be omitted in table and show/hide dropdown | Boolean | false | |
31
- | `options` | array of options if the type is MultiSelect or Single Select | Array | false | [] |
32
- | `isResizable` | is column resizable | Boolean | false | false |
33
- | `fixed` | String='left' or 'right', where to fix the column | String | false | null |
34
- | `defaultWidth` | to fix column width to a value in pixels if width exceeding this threshold | Number | false | null |
35
-
36
- ### b. Action Config Options : actions will be shown in action column in table
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
- | `String` | contains, does not contains, is, is not, is empty, is not empty |
60
- | `DateTime`/`Date` | is, is not, is after, is before, is empty, is not empty |
61
- | `Number` | =, =/ , < , <=, > , >= , is empty, is not empty |
62
- | `SingleSelect` | has any of, has none of, is empty, is not empty | options: [] |
63
- | `MultiSelect` | is, is not, is empty, is not empty, | options: [] |
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 | Description | Default | Required | Type |
68
- | ---------------------- | --------------------------------------------------------------- | ------- | -------- | -------- |
69
- | `mandatoryFields` | '' | | true | |
70
- | `data` | data for the table | | true | |
71
- | `columnDefs` | is, is not, is empty, is not empty, | | true | |
72
- | `actionDefs` | contains, does not contains, is, is not, is empty, is not empty | | false | |
73
- | `bulkActionDefs` | is, is not, is after, is before, is empty, is not empty | | false | |
74
- | `name` | name of the table | | false | string |
75
- | `includeAction` | to show actions column | false | false | boolean |
76
- | `isShowSerialNumber` | to show serial number column | false | false | boolean |
77
- | `enableIcon` | to show icon in serial number column | false | false | boolean |
78
- | `showIcon` | function which returns JSX element(Icon) to render | | false | function |
79
- | `isAllowDeepSearch` | allow a deep search in the data for the searched keyword | false | false | boolean |
80
- | `emptyCellPlaceHolder` | placeholder for empty cells | | false | string |
81
- | `accentColor` | colors for top bar buttons | | false | string |
82
- | `hideBulkCount` | hide bulk select count for bulk actions | false | false | boolean |
83
- | `showResetButton` | display reset button | true | false | boolean |
84
- | `hidePagination` | hide pagination | false | false | boolean |
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 format from 'date-fns/format'
93
- import { Button, Input } from 'semantic-ui-react';
81
+ import { Button, IconButton, Select } from 'commonComponents/widgets';
94
82
 
95
83
  ...
96
84
 
97
- onDelete = ids => {
98
- console.log('onDelete', ids);
99
- };
100
-
101
- onShow = rowObject => {
102
- console.log('onShow', rowObject);
103
- };
104
-
105
- onEdit = rowObject => {
106
- console.log('onEdit', rowObject);
107
- };
108
-
109
- onInputChange = ({ rowObject, value: newValue }) => {
110
- console.log({ rowObject, newValue });
111
- };
112
-
113
- columnDefs = [
114
- {
115
- headerName: 'Name',
116
- field: 'name',
117
- type: 'String',
118
- cell: rowObject => (
119
- <Input value={rowObject.name} onChange={(_e, { value }) => this.onInputChange({ value, rowObject })} />
120
- ),
121
- isSortable: true,
122
- isSearchable: true,
123
- isFilterable: true,
124
- },
125
- {
126
- headerName: 'Description',
127
- field: 'description',
128
- type: 'String',
129
- cell: rowObject => rowObject.description,
130
- isSortable: true,
131
- isSearchable: true,
132
- isFilterable: true,
133
- isResizable: true,
134
- },
135
- {
136
- headerName: 'Category',
137
- field: 'category',
138
- type: 'SingleSelect',
139
- cell: rowObject => rowObject.category,
140
- options: ['Grocery', 'Electronics', 'Home', 'Shoes', 'Computers', 'Outdoors', 'Clothing'].map((category, index) => ({
141
- value: index,
142
- label: category,
143
- })),
144
- isSortable: true,
145
- isSearchable: true,
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
- headerName: 'Expertise',
160
- field: 'isExpertised',
161
- type: 'Boolean',
162
- cell: rowObject => (rowObject.isExpertised ? 'Yes' : 'No'),
163
- isSortable: true,
164
- isSearchable: false,
165
- isFilterable: true,
166
- },
135
+ field: 'name',
136
+ headerName: 'Name',
137
+ type: 'string',
138
+ isFilterable: true,
139
+ isSortable: true,
140
+ isSearchable: true
141
+ },
167
142
  {
168
- headerName: 'Availability',
169
- field: 'availability',
170
- type: 'MultiSelect',
171
- cell: rowObject => rowObject.availability.join(', '),
172
- options: ['Yes', 'No', 'Maybe'].map(a => ({ value: a, label: a })),
173
- isSortable: true,
174
- isSearchable: false,
175
- isFilterable: true,
176
- fixed: 'left',
177
- defaultWidth: 100,
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
- headerName: 'Started at',
181
- field: 'created',
182
- cell: rowObject => format(new Date(rowObject.created), 'dd-MMM-yyyy hh:mm a'),
183
- type: 'Date',
184
- isSortable: true,
185
- isSearchable: false,
186
- isFilterable: true,
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
- name: 'Show',
197
- isVisible: _rowObject => true,
198
- isDisabled: rowObject => this.updatingObjectId === (rowObject['id'] || rowObject['_id']),
199
- isLoading: rowObject => this.updatingObjectId === (rowObject['id'] || rowObject['_id']),
200
- function: this.onShow,
201
- icon: 'eye',
202
- color: '#85C1E9',
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
- name: 'Delete',
206
- isVisible: rowObject => !rowObject.isDeleted,
207
- isDisabled: rowObject => this.updatingObjectId === (rowObject['id'] || rowObject['_id']),
208
- isLoading: rowObject => this.updatingObjectId === (rowObject['id'] || rowObject['_id']),
209
- function: rowObject => this.onDelete(rowObject),
210
- icon: 'trash',
211
- color: '#E8515D',
212
- },
213
- ];
214
-
215
- bulkActionDefs = [{ action: 'delete', function: this.onDelete }];
216
-
217
- customComponents = () => (
218
- <>
219
- <Button disabled size="small" onClick={() => null}>
220
- Button 1
221
- </Button>
222
- <Button onClick={() => null}>Button 2</Button>
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
- actionDefs={this.actionDefs}
230
- bulkActionDefs={this.bulkActionDefs}
231
- data={this.state.data || []}
232
- includeAction={true}
233
- mandatoryFields={['Name']}
234
- name={'Table Name'}
235
- columnDefs={this.columnDefs}
236
- isShowSerialNumber={true}
237
- isAllowDeepSearch={true}
238
- showResetButton={true}>
239
- {this.customComponents}
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
  ...