@commercetools-uikit/data-table-manager 19.8.0 → 19.10.0

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 (31) hide show
  1. package/README.md +50 -35
  2. package/column-settings-manager/dist/commercetools-uikit-data-table-manager-column-settings-manager.cjs.d.ts +2 -0
  3. package/column-settings-manager/dist/commercetools-uikit-data-table-manager-column-settings-manager.cjs.dev.js +43 -0
  4. package/column-settings-manager/dist/commercetools-uikit-data-table-manager-column-settings-manager.cjs.js +7 -0
  5. package/column-settings-manager/dist/commercetools-uikit-data-table-manager-column-settings-manager.cjs.prod.js +43 -0
  6. package/column-settings-manager/dist/commercetools-uikit-data-table-manager-column-settings-manager.esm.js +35 -0
  7. package/column-settings-manager/package.json +4 -0
  8. package/data-table-manager-provider/dist/commercetools-uikit-data-table-manager-data-table-manager-provider.cjs.dev.js +6 -4
  9. package/data-table-manager-provider/dist/commercetools-uikit-data-table-manager-data-table-manager-provider.cjs.prod.js +6 -4
  10. package/data-table-manager-provider/dist/commercetools-uikit-data-table-manager-data-table-manager-provider.esm.js +6 -4
  11. package/dist/column-settings-manager-1430ee4f.esm.js +463 -0
  12. package/dist/column-settings-manager-92b54563.cjs.dev.js +494 -0
  13. package/dist/column-settings-manager-b08669e8.cjs.prod.js +407 -0
  14. package/dist/commercetools-uikit-data-table-manager.cjs.dev.js +139 -461
  15. package/dist/commercetools-uikit-data-table-manager.cjs.prod.js +134 -380
  16. package/dist/commercetools-uikit-data-table-manager.esm.js +141 -452
  17. package/dist/{data-table-manager-provider-3f60b85b.esm.js → data-table-manager-provider-32eb58dd.esm.js} +41 -9
  18. package/dist/{data-table-manager-provider-6c690fc1.cjs.dev.js → data-table-manager-provider-c64c81aa.cjs.prod.js} +43 -10
  19. package/dist/{data-table-manager-provider-ddf7fb63.cjs.prod.js → data-table-manager-provider-fc238633.cjs.dev.js} +43 -10
  20. package/dist/declarations/src/column-settings-manager/column-settings-manager.d.ts +26 -0
  21. package/dist/declarations/src/column-settings-manager/export-types.d.ts +3 -0
  22. package/dist/declarations/src/column-settings-manager/index.d.ts +2 -0
  23. package/dist/declarations/src/constants.d.ts +2 -0
  24. package/dist/declarations/src/data-table-manager-provider/data-table-manager-provider.d.ts +11 -2
  25. package/dist/declarations/src/data-table-manager-provider/types.d.ts +62 -0
  26. package/dist/declarations/src/export-types.d.ts +2 -0
  27. package/dist/declarations/src/index.d.ts +1 -0
  28. package/dist/declarations/src/settings-container/index.d.ts +2 -0
  29. package/dist/declarations/src/settings-container/settings-container.d.ts +23 -0
  30. package/dist/declarations/src/types.d.ts +203 -2
  31. package/package.json +29 -25
@@ -3,52 +3,253 @@ export type TColumnData = {
3
3
  key: string;
4
4
  label: ReactNode;
5
5
  };
6
+ export type TAdditionalSettings = {
7
+ key: string;
8
+ [key: string]: unknown;
9
+ };
6
10
  export type TDisplaySettingsProps = {
11
+ /**
12
+ * Set this to override the default label of the display settings.
13
+ */
14
+ displaySettingsLabel?: string;
15
+ /**
16
+ * Set this flag to `false` to show the display settings panel option.
17
+ *
18
+ * @@defaultValue@@: true
19
+ */
7
20
  disableDisplaySettings?: boolean;
21
+ /**
22
+ * Set this to `true` to reduce the paddings of all cells, allowing the table to display
23
+ * more data in less space.
24
+ *
25
+ * @@defaultValue@@: true
26
+ */
8
27
  isCondensed?: boolean;
28
+ /**
29
+ * Set this to `true` to allow text in a cell to wrap.
30
+ * <br>
31
+ * This is required if `disableDisplaySettings` is set to `false`.
32
+ *
33
+ * @@defaultValue@@: false
34
+ */
9
35
  isWrappingText?: boolean;
36
+ /**
37
+ * A React element to be rendered as the primary button, useful when the display settings work as a form.
38
+ */
10
39
  primaryButton?: ReactElement;
40
+ /**
41
+ * A React element to be rendered as the secondary button, useful when the display settings work as a form.
42
+ */
11
43
  secondaryButton?: ReactElement;
12
44
  };
13
45
  export type TColumnManagerProps = {
46
+ /**
47
+ * Set this to override the default label of the column manager.
48
+ */
49
+ columnManagerLabel?: string;
50
+ /**
51
+ * Set this to `true` to show a search input for the hidden columns panel.
52
+ */
14
53
  areHiddenColumnsSearchable?: boolean;
54
+ /**
55
+ * Set this to `false` to show the column settings panel option.
56
+ *
57
+ * @@defaultValue@@: true
58
+ */
15
59
  disableColumnManager?: boolean;
60
+ /**
61
+ * The keys of the visible columns.
62
+ */
16
63
  visibleColumnKeys: string[];
64
+ /**
65
+ * The keys of the visible columns.
66
+ */
17
67
  hideableColumns?: TColumnData[];
68
+ /**
69
+ * A callback function, called when the search input for the hidden columns panel changes.
70
+ */
18
71
  searchHiddenColumns?: (searchTerm: string) => Promise<void> | void;
72
+ /**
73
+ * Placeholder value of the search input for the hidden columns panel.
74
+ */
19
75
  searchHiddenColumnsPlaceholder?: string;
76
+ /**
77
+ * A React element to be rendered as the primary button, useful when the column settings work as a form.
78
+ */
20
79
  primaryButton?: ReactElement;
80
+ /**
81
+ * A React element to be rendered as the secondary button, useful when the column settings work as a form.
82
+ */
21
83
  secondaryButton?: ReactElement;
22
84
  };
85
+ export type TCustomSettingsProps = {
86
+ key: string;
87
+ customPanelTitle: string;
88
+ type?: 'columnManager';
89
+ customComponent?: React.ComponentType<{
90
+ updateCustomSettings?: (settings: TAdditionalSettings) => void;
91
+ additionalSettings: Record<string, unknown>;
92
+ onClose?: () => void;
93
+ columnManager?: TColumnManagerProps;
94
+ onUpdateColumns?: (nextVisibleColumns: TColumnData[], key?: string) => void;
95
+ onSettingsChange?: (settingName: string, settingValue: boolean | string[], key?: string) => void;
96
+ managerTheme?: 'light' | 'dark';
97
+ customColumns?: TColumnData[];
98
+ selectedColumns?: TColumnData[];
99
+ availableColumns?: TColumnManagerProps;
100
+ }>;
101
+ settingsPayload: Record<string, unknown>;
102
+ };
23
103
  export type TDataTableSettingsProps = {
104
+ additionalSettings: Record<string, unknown>;
24
105
  topBar?: ReactNode;
25
- onSettingsChange?: (settingName: string, settingValue: boolean | string[]) => void;
106
+ onSettingsChange?: (settingName: string, settingValue: boolean | string[] | Record<string, unknown>, key?: string) => void;
26
107
  displaySettings?: TDisplaySettingsProps;
27
108
  columnManager?: TColumnManagerProps;
109
+ customSettings?: TCustomSettingsProps[];
28
110
  managerTheme?: 'light' | 'dark';
111
+ updateCustomSettings?: (settings: TAdditionalSettings) => void;
112
+ selectedColumns?: TColumnData[];
113
+ customColumnManager?: TColumnManagerProps & {
114
+ disableCustomColumnManager?: boolean;
115
+ };
29
116
  };
30
117
  export interface TRow {
31
118
  id: string;
32
119
  }
33
120
  export type TColumnProps<Row extends TRow = TRow> = {
121
+ /**
122
+ * The unique key of the column that is used to identify your data type.
123
+ * You can use this value to determine which value from a row item should be rendered.
124
+ * <br>
125
+ * For example, if the data is a list of users, where each user has a `firstName` property,
126
+ * the column key should be `firstName`, which renders the correct value by default.
127
+ * The key can also be some custom or computed value, in which case you need to provide
128
+ * an explicit mapping of the value by implementing either the `itemRendered` function or
129
+ * the column-specific `renderItem` function.
130
+ */
34
131
  key: string;
132
+ /**
133
+ * The label of the column that will be shown on the column header.
134
+ */
35
135
  label: ReactNode;
136
+ /**
137
+ * Sets a width for this column. Accepts the same values as the ones specified for
138
+ * individual [grid-template-columns](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns).
139
+ * <br>
140
+ * For example, using `minmax` pairs (e.g. `minmax(200px, 400px)`), a combinations of
141
+ * fraction values (`1fr`/`2fr`/etc), or fixed values such as `200px`.
142
+ * By default, the column grows according to the content and respecting the total table available width.
143
+ */
36
144
  width?: string;
145
+ /**
146
+ * Use this to override the table's own `horizontalCellAlignment` prop for this specific column.
147
+ */
37
148
  align?: 'left' | 'center' | 'right';
149
+ /**
150
+ * A callback function, called when the header cell is clicked.
151
+ */
38
152
  onClick?: (event: MouseEventHandler) => void;
153
+ /**
154
+ * A callback function to render the content of cells under this column, overriding
155
+ * the default `itemRenderer` prop of the table.
156
+ */
39
157
  renderItem?: (row: Row, isRowCollapsed: boolean) => ReactNode;
158
+ /**
159
+ * Use this prop to place an `Icon` or `IconButton` on the left of the column label.
160
+ * It is advised to place these types of components through this prop instead of `label`,
161
+ * in order to properly position and align the elements.
162
+ * This is particularly useful for medium-sized icons which require more vertical space than the typography.
163
+ */
40
164
  headerIcon?: ReactNode;
165
+ /**
166
+ * Set this to `true` to allow text content of this cell to be truncated with an ellipsis,
167
+ * instead of breaking into multiple lines.
168
+ * <br>
169
+ * NOTE: when using this option, it is recommended to specify a `width` for the column, because
170
+ * if the table doesn't have enough space for all columns, it will start clipping the columns
171
+ * with _truncated_ content, and if no `width` is set (or the value is set `auto` -- the default)
172
+ * it can shrink until the column disappears completely.
173
+ * By enforcing a minimum width for these columns, the table will respect them and grow horizontally,
174
+ * adding scrollbars if needed.
175
+ */
41
176
  isTruncated?: boolean;
177
+ /**
178
+ * Set this to `true` to show a sorting button, which calls `onSortChange` upon being clicked.
179
+ * You should enable this flag for every column you want to be able to sort.
180
+ * When at least one column is sortable, the table props `sortBy`, `sortDirection` and `onSortChange` should be provided.
181
+ */
42
182
  isSortable?: boolean;
183
+ /**
184
+ * Set this to `true` to prevent this column from being manually resized by dragging
185
+ * the edge of the header with a mouse.
186
+ */
43
187
  disableResizing?: boolean;
188
+ /**
189
+ * Set this to `true` to prevent click event propagation for this cell.
190
+ * You might want this if you need the column to have its own call-to-action or input while
191
+ * the row also has a defined `onRowClick`.
192
+ */
44
193
  shouldIgnoreRowClick?: boolean;
45
194
  };
46
195
  export type TDataTableManagerProps<Row extends TRow = TRow> = {
196
+ /**
197
+ * Each object requires a unique `key` which should correspond to property key of
198
+ * the items of `rows` that you want to render under this column, and a `label`
199
+ * which defines the name shown on the header.
200
+ * The list of columns to be rendered.
201
+ * Each column can be customized (see properties below).
202
+ */
47
203
  columns: TColumnProps<Row>[];
204
+ /**
205
+ * Any React node. Usually you want to render the `<DataTable>` component.
206
+ * <br>
207
+ * Note that the child component will implicitly receive the props `columns` and `isCondensed` from the `<DataTableManager>`.
208
+ */
48
209
  children?: ReactElement;
210
+ /**
211
+ * The managed display settings of the table.
212
+ */
49
213
  displaySettings?: TDataTableSettingsProps['displaySettings'];
214
+ /**
215
+ * The managed column settings of the table.
216
+ */
50
217
  columnManager?: TDataTableSettingsProps['columnManager'];
51
- onSettingsChange?: (settingName: string, settingValue: boolean | string[]) => void;
218
+ /**
219
+ * A callback function, called when any of the properties of either display settings or column settings is modified.
220
+ */
221
+ onSettingsChange?: (settingName: string, settingValue: boolean | string[] | Record<string, unknown>) => void;
222
+ /**
223
+ * A React node for rendering additional information within the table manager.
224
+ */
52
225
  topBar?: ReactNode;
226
+ /**
227
+ * Sets the background theme of the Card that contains the settings
228
+ */
53
229
  managerTheme?: 'light' | 'dark';
230
+ /**
231
+ * Manage custom settings for the table
232
+ */
233
+ customSettings?: TDataTableSettingsProps['customSettings'];
234
+ /**
235
+ * A callback function used to update the custom settings.
236
+ * */
237
+ updateCustomSettings?: (settings: TAdditionalSettings) => void;
238
+ /**
239
+ * The selected columns to be displayed.
240
+ */
241
+ selectedColumns?: TColumnData[];
242
+ /**
243
+ * Custom column manager settings.
244
+ */
245
+ customColumnManager?: TColumnManagerProps & {
246
+ disableCustomColumnManager?: boolean;
247
+ };
248
+ /**
249
+ * The columns of the nested items to be rendered in the table. Just like the columns, Each object requires a unique `key` which should correspond to property key of
250
+ * the items of `rows` that you want to render under this column, and a `label`
251
+ * which defines the name shown on the header.
252
+ * The list of columns to be rendered.
253
+ */
254
+ customColumns?: TColumnProps<Row>[];
54
255
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/data-table-manager",
3
3
  "description": "This component enhances the DataTable component and additionally provides a UI and state management to handle configuration of the table such as column manager.",
4
- "version": "19.8.0",
4
+ "version": "19.10.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -18,34 +18,38 @@
18
18
  "main": "dist/commercetools-uikit-data-table-manager.cjs.js",
19
19
  "module": "dist/commercetools-uikit-data-table-manager.esm.js",
20
20
  "preconstruct": {
21
- "entrypoints": ["./index.ts", "data-table-manager-provider/index.ts"]
21
+ "entrypoints": [
22
+ "./index.ts",
23
+ "data-table-manager-provider/index.ts",
24
+ "column-settings-manager/index.ts"
25
+ ]
22
26
  },
23
- "files": ["dist", "data-table-manager-provider"],
27
+ "files": ["dist", "data-table-manager-provider", "column-settings-manager"],
24
28
  "dependencies": {
25
29
  "@babel/runtime": "^7.20.13",
26
30
  "@babel/runtime-corejs3": "^7.20.13",
27
- "@commercetools-uikit/accessible-button": "19.8.0",
28
- "@commercetools-uikit/accessible-hidden": "19.8.0",
29
- "@commercetools-uikit/async-select-input": "19.8.0",
30
- "@commercetools-uikit/card": "19.8.0",
31
- "@commercetools-uikit/collapsible-motion": "19.8.0",
32
- "@commercetools-uikit/design-system": "19.8.0",
33
- "@commercetools-uikit/dropdown-menu": "19.8.0",
34
- "@commercetools-uikit/field-label": "19.8.0",
35
- "@commercetools-uikit/grid": "19.8.0",
36
- "@commercetools-uikit/hooks": "19.8.0",
37
- "@commercetools-uikit/icon-button": "19.8.0",
38
- "@commercetools-uikit/icons": "19.8.0",
39
- "@commercetools-uikit/primary-button": "19.8.0",
40
- "@commercetools-uikit/radio-input": "19.8.0",
41
- "@commercetools-uikit/secondary-button": "19.8.0",
42
- "@commercetools-uikit/secondary-icon-button": "19.8.0",
43
- "@commercetools-uikit/select-input": "19.8.0",
44
- "@commercetools-uikit/spacings": "19.8.0",
45
- "@commercetools-uikit/tag": "19.8.0",
46
- "@commercetools-uikit/text": "19.8.0",
47
- "@commercetools-uikit/tooltip": "19.8.0",
48
- "@commercetools-uikit/utils": "19.8.0",
31
+ "@commercetools-uikit/accessible-button": "19.10.0",
32
+ "@commercetools-uikit/accessible-hidden": "19.10.0",
33
+ "@commercetools-uikit/async-select-input": "19.10.0",
34
+ "@commercetools-uikit/card": "19.10.0",
35
+ "@commercetools-uikit/collapsible-motion": "19.10.0",
36
+ "@commercetools-uikit/design-system": "19.10.0",
37
+ "@commercetools-uikit/dropdown-menu": "19.10.0",
38
+ "@commercetools-uikit/field-label": "19.10.0",
39
+ "@commercetools-uikit/grid": "19.10.0",
40
+ "@commercetools-uikit/hooks": "19.10.0",
41
+ "@commercetools-uikit/icon-button": "19.10.0",
42
+ "@commercetools-uikit/icons": "19.10.0",
43
+ "@commercetools-uikit/primary-button": "19.10.0",
44
+ "@commercetools-uikit/radio-input": "19.10.0",
45
+ "@commercetools-uikit/secondary-button": "19.10.0",
46
+ "@commercetools-uikit/secondary-icon-button": "19.10.0",
47
+ "@commercetools-uikit/select-input": "19.10.0",
48
+ "@commercetools-uikit/spacings": "19.10.0",
49
+ "@commercetools-uikit/tag": "19.10.0",
50
+ "@commercetools-uikit/text": "19.10.0",
51
+ "@commercetools-uikit/tooltip": "19.10.0",
52
+ "@commercetools-uikit/utils": "19.10.0",
49
53
  "@emotion/react": "^11.10.5",
50
54
  "@emotion/styled": "^11.10.5",
51
55
  "debounce-promise": "^3.1.2",