@wonderflow/react-components 10.8.0 → 10.9.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 (171) hide show
  1. package/dist/components/accordion/accordion-context.d.ts +12 -0
  2. package/dist/components/accordion/accordion-context.d.ts.map +1 -0
  3. package/dist/components/accordion/accordion-context.js +13 -0
  4. package/dist/components/accordion/accordion-item.d.ts +10 -0
  5. package/dist/components/accordion/accordion-item.d.ts.map +1 -0
  6. package/dist/components/accordion/accordion-item.js +9 -0
  7. package/dist/components/accordion/accordion.d.ts +18 -0
  8. package/dist/components/accordion/accordion.d.ts.map +1 -0
  9. package/dist/components/accordion/accordion.js +8 -0
  10. package/dist/components/accordion/accordion.module.css +1 -0
  11. package/dist/components/accordion/accordion.stories.d.ts +12 -0
  12. package/dist/components/accordion/accordion.stories.d.ts.map +1 -0
  13. package/dist/components/accordion/accordion.stories.js +17 -0
  14. package/dist/components/accordion/index.d.ts +5 -0
  15. package/dist/components/accordion/index.d.ts.map +1 -0
  16. package/dist/components/accordion/index.js +2 -0
  17. package/dist/components/aspect-ratio/aspect-ratio.stories.d.ts +6 -0
  18. package/dist/components/aspect-ratio/aspect-ratio.stories.d.ts.map +1 -0
  19. package/dist/components/aspect-ratio/aspect-ratio.stories.js +12 -0
  20. package/dist/components/autocomplete/autocomplete.stories.d.ts +15 -0
  21. package/dist/components/autocomplete/autocomplete.stories.d.ts.map +1 -0
  22. package/dist/components/autocomplete/autocomplete.stories.js +19 -0
  23. package/dist/components/avatar/avatar.d.ts +1 -1
  24. package/dist/components/avatar/avatar.stories.d.ts +10 -0
  25. package/dist/components/avatar/avatar.stories.d.ts.map +1 -0
  26. package/dist/components/avatar/avatar.stories.js +19 -0
  27. package/dist/components/button/button.stories.d.ts +9 -0
  28. package/dist/components/button/button.stories.d.ts.map +1 -0
  29. package/dist/components/button/button.stories.js +55 -0
  30. package/dist/components/card/card.stories.d.ts +10 -0
  31. package/dist/components/card/card.stories.d.ts.map +1 -0
  32. package/dist/components/card/card.stories.js +47 -0
  33. package/dist/components/chip/chip.stories.d.ts +6 -0
  34. package/dist/components/chip/chip.stories.d.ts.map +1 -0
  35. package/dist/components/chip/chip.stories.js +30 -0
  36. package/dist/components/circular-progress/circular-progress.stories.d.ts +10 -0
  37. package/dist/components/circular-progress/circular-progress.stories.d.ts.map +1 -0
  38. package/dist/components/circular-progress/circular-progress.stories.js +30 -0
  39. package/dist/components/clamp-text/clamp-text.stories.d.ts +7 -0
  40. package/dist/components/clamp-text/clamp-text.stories.d.ts.map +1 -0
  41. package/dist/components/clamp-text/clamp-text.stories.js +25 -0
  42. package/dist/components/container/container.stories.d.ts +10 -0
  43. package/dist/components/container/container.stories.d.ts.map +1 -0
  44. package/dist/components/container/container.stories.js +48 -0
  45. package/dist/components/datetime/datetime.stories.d.ts +7 -0
  46. package/dist/components/datetime/datetime.stories.d.ts.map +1 -0
  47. package/dist/components/datetime/datetime.stories.js +22 -0
  48. package/dist/components/disclosure/disclosure.d.ts +1 -1
  49. package/dist/components/disclosure/disclosure.d.ts.map +1 -1
  50. package/dist/components/disclosure/disclosure.js +8 -7
  51. package/dist/components/disclosure/disclosure.stories.d.ts +24 -0
  52. package/dist/components/disclosure/disclosure.stories.d.ts.map +1 -0
  53. package/dist/components/disclosure/disclosure.stories.js +32 -0
  54. package/dist/components/drawer/drawer.stories.d.ts +7 -0
  55. package/dist/components/drawer/drawer.stories.d.ts.map +1 -0
  56. package/dist/components/drawer/drawer.stories.js +36 -0
  57. package/dist/components/elevator/elevator.stories.d.ts +7 -0
  58. package/dist/components/elevator/elevator.stories.d.ts.map +1 -0
  59. package/dist/components/elevator/elevator.stories.js +17 -0
  60. package/dist/components/grid/grid.stories.d.ts +9 -0
  61. package/dist/components/grid/grid.stories.d.ts.map +1 -0
  62. package/dist/components/grid/grid.stories.js +11 -0
  63. package/dist/components/icon-button/icon-button.stories.d.ts +6 -0
  64. package/dist/components/icon-button/icon-button.stories.d.ts.map +1 -0
  65. package/dist/components/icon-button/icon-button.stories.js +33 -0
  66. package/dist/components/index.d.ts +1 -0
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +1 -0
  69. package/dist/components/info-state/info-state.stories.d.ts +71 -0
  70. package/dist/components/info-state/info-state.stories.d.ts.map +1 -0
  71. package/dist/components/info-state/info-state.stories.js +40 -0
  72. package/dist/components/input-group/input-group.stories.d.ts +10 -0
  73. package/dist/components/input-group/input-group.stories.d.ts.map +1 -0
  74. package/dist/components/input-group/input-group.stories.js +13 -0
  75. package/dist/components/linear-progress/linear-progress.d.ts +1 -1
  76. package/dist/components/linear-progress/linear-progress.stories.d.ts +18 -0
  77. package/dist/components/linear-progress/linear-progress.stories.d.ts.map +1 -0
  78. package/dist/components/linear-progress/linear-progress.stories.js +27 -0
  79. package/dist/components/list/list.stories.d.ts +15 -0
  80. package/dist/components/list/list.stories.d.ts.map +1 -0
  81. package/dist/components/list/list.stories.js +27 -0
  82. package/dist/components/masonry/masonry.stories.d.ts +7 -0
  83. package/dist/components/masonry/masonry.stories.d.ts.map +1 -0
  84. package/dist/components/masonry/masonry.stories.js +24 -0
  85. package/dist/components/menu/menu-item/menu-item.stories.d.ts +10 -0
  86. package/dist/components/menu/menu-item/menu-item.stories.d.ts.map +1 -0
  87. package/dist/components/menu/menu-item/menu-item.stories.js +33 -0
  88. package/dist/components/menu/menu.stories.d.ts +41 -0
  89. package/dist/components/menu/menu.stories.d.ts.map +1 -0
  90. package/dist/components/menu/menu.stories.js +24 -0
  91. package/dist/components/modal/modal.stories.d.ts +12 -0
  92. package/dist/components/modal/modal.stories.d.ts.map +1 -0
  93. package/dist/components/modal/modal.stories.js +23 -0
  94. package/dist/components/overlay-container/overlay-container.stories.d.ts +6 -0
  95. package/dist/components/overlay-container/overlay-container.stories.d.ts.map +1 -0
  96. package/dist/components/overlay-container/overlay-container.stories.js +17 -0
  97. package/dist/components/pagination/pagination.stories.d.ts +6 -0
  98. package/dist/components/pagination/pagination.stories.d.ts.map +1 -0
  99. package/dist/components/pagination/pagination.stories.js +421 -0
  100. package/dist/components/popover/popover.stories.d.ts +22 -0
  101. package/dist/components/popover/popover.stories.d.ts.map +1 -0
  102. package/dist/components/popover/popover.stories.js +45 -0
  103. package/dist/components/prose/prose.stories.d.ts +7 -0
  104. package/dist/components/prose/prose.stories.d.ts.map +1 -0
  105. package/dist/components/prose/prose.stories.js +12 -0
  106. package/dist/components/select/select.d.ts +1 -1
  107. package/dist/components/select/select.stories.d.ts +33 -0
  108. package/dist/components/select/select.stories.d.ts.map +1 -0
  109. package/dist/components/select/select.stories.js +47 -0
  110. package/dist/components/selection-controls/checkbox.stories.d.ts +30 -0
  111. package/dist/components/selection-controls/checkbox.stories.d.ts.map +1 -0
  112. package/dist/components/selection-controls/checkbox.stories.js +34 -0
  113. package/dist/components/selection-controls/radio.stories.d.ts +21 -0
  114. package/dist/components/selection-controls/radio.stories.d.ts.map +1 -0
  115. package/dist/components/selection-controls/radio.stories.js +30 -0
  116. package/dist/components/selection-controls/toggle.stories.d.ts +8 -0
  117. package/dist/components/selection-controls/toggle.stories.d.ts.map +1 -0
  118. package/dist/components/selection-controls/toggle.stories.js +22 -0
  119. package/dist/components/separator/separator.stories.d.ts +6 -0
  120. package/dist/components/separator/separator.stories.d.ts.map +1 -0
  121. package/dist/components/separator/separator.stories.js +8 -0
  122. package/dist/components/skeleton/skeleton.stories.d.ts +9 -0
  123. package/dist/components/skeleton/skeleton.stories.d.ts.map +1 -0
  124. package/dist/components/skeleton/skeleton.stories.js +38 -0
  125. package/dist/components/slider/slider.stories.d.ts +39 -0
  126. package/dist/components/slider/slider.stories.d.ts.map +1 -0
  127. package/dist/components/slider/slider.stories.js +33 -0
  128. package/dist/components/snackbar/snackbar.stories.d.ts +7 -0
  129. package/dist/components/snackbar/snackbar.stories.d.ts.map +1 -0
  130. package/dist/components/snackbar/snackbar.stories.js +22 -0
  131. package/dist/components/spinner/spinner.d.ts +1 -1
  132. package/dist/components/spinner/spinner.stories.d.ts +10 -0
  133. package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
  134. package/dist/components/spinner/spinner.stories.js +19 -0
  135. package/dist/components/split-button/split-button.stories.d.ts +8 -0
  136. package/dist/components/split-button/split-button.stories.d.ts.map +1 -0
  137. package/dist/components/split-button/split-button.stories.js +36 -0
  138. package/dist/components/stack/stack.stories.d.ts +6 -0
  139. package/dist/components/stack/stack.stories.d.ts.map +1 -0
  140. package/dist/components/stack/stack.stories.js +40 -0
  141. package/dist/components/star-meter/star-meter.stories.d.ts +7 -0
  142. package/dist/components/star-meter/star-meter.stories.d.ts.map +1 -0
  143. package/dist/components/star-meter/star-meter.stories.js +24 -0
  144. package/dist/components/symbol/symbol.stories.d.ts +16 -0
  145. package/dist/components/symbol/symbol.stories.d.ts.map +1 -0
  146. package/dist/components/symbol/symbol.stories.js +30 -0
  147. package/dist/components/tab/tab.stories.d.ts +21 -0
  148. package/dist/components/tab/tab.stories.d.ts.map +1 -0
  149. package/dist/components/tab/tab.stories.js +46 -0
  150. package/dist/components/tab/tabs-panel.d.ts +1 -0
  151. package/dist/components/tab/tabs-panel.d.ts.map +1 -1
  152. package/dist/components/table/table.stories.d.ts +22 -0
  153. package/dist/components/table/table.stories.d.ts.map +1 -0
  154. package/dist/components/table/table.stories.js +1187 -0
  155. package/dist/components/text/text.stories.d.ts +7 -0
  156. package/dist/components/text/text.stories.d.ts.map +1 -0
  157. package/dist/components/text/text.stories.js +39 -0
  158. package/dist/components/textfield/textfield.d.ts +1 -1
  159. package/dist/components/textfield/textfield.stories.d.ts +62 -0
  160. package/dist/components/textfield/textfield.stories.d.ts.map +1 -0
  161. package/dist/components/textfield/textfield.stories.js +83 -0
  162. package/dist/components/title/title.stories.d.ts +7 -0
  163. package/dist/components/title/title.stories.d.ts.map +1 -0
  164. package/dist/components/title/title.stories.js +38 -0
  165. package/dist/components/toggle-button/toggle-button.stories.d.ts +16 -0
  166. package/dist/components/toggle-button/toggle-button.stories.d.ts.map +1 -0
  167. package/dist/components/toggle-button/toggle-button.stories.js +29 -0
  168. package/dist/components/tooltip/tooltip.stories.d.ts +7 -0
  169. package/dist/components/tooltip/tooltip.stories.d.ts.map +1 -0
  170. package/dist/components/tooltip/tooltip.stories.js +22 -0
  171. package/package.json +6 -5
@@ -0,0 +1,1187 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useMemo, useState, } from 'react';
3
+ import { Button, IconButton, Menu, Popover, Separator, Stack, Title, } from '../..';
4
+ import { Table } from './table';
5
+ const firstData = {
6
+ firstName: 'Gianni',
7
+ lastName: 'Morandi',
8
+ address: 'Via Roma, 1, Treno',
9
+ uid: 3456789542556789,
10
+ info: 123123.12,
11
+ };
12
+ const story = {
13
+ title: 'Layouts/Table',
14
+ parameters: {
15
+ centered: { disable: true },
16
+ },
17
+ args: {
18
+ stripes: false,
19
+ selectableRows: false,
20
+ showSeparators: true,
21
+ showHeader: false,
22
+ columns: [
23
+ {
24
+ id: 'firstName',
25
+ Header: 'First Name',
26
+ accessor: row => row.firstName,
27
+ },
28
+ {
29
+ id: 'lastName',
30
+ Header: 'Last Name',
31
+ accessor: row => row.lastName,
32
+ },
33
+ {
34
+ id: 'address',
35
+ Header: 'Address',
36
+ accessor: row => row.address,
37
+ },
38
+ {
39
+ id: 'uid',
40
+ Header: 'UID',
41
+ accessor: row => row.uid,
42
+ minWidth: 200,
43
+ align: 'end',
44
+ },
45
+ {
46
+ id: 'info',
47
+ Header: 'Info',
48
+ accessor: row => row.info,
49
+ disableSortBy: true,
50
+ align: 'end',
51
+ minWidth: 180,
52
+ },
53
+ ],
54
+ data: [
55
+ {
56
+ ...firstData,
57
+ subRows: [
58
+ {
59
+ firstName: 'ciao',
60
+ lastName: 'Stuffo',
61
+ address: 'Via Roma, 15 Monza',
62
+ uid: 123123,
63
+ info: 12,
64
+ subRows: [
65
+ {
66
+ firstName: '1',
67
+ lastName: 'Stuffo',
68
+ address: 'Via Roma, 15 Monza',
69
+ uid: 123123,
70
+ info: 12,
71
+ subRows: [
72
+ {
73
+ firstName: '1',
74
+ lastName: 'Stuffo',
75
+ address: 'Via Roma, 15 Monza',
76
+ uid: 123123,
77
+ info: 12,
78
+ subRows: [
79
+ {
80
+ firstName: '1',
81
+ lastName: 'Stuffo',
82
+ address: 'Via Roma, 15 Monza',
83
+ uid: 123123,
84
+ info: 12,
85
+ subRows: [
86
+ {
87
+ firstName: '1',
88
+ lastName: 'Stuffo',
89
+ address: 'Via Roma, 15 Monza',
90
+ uid: 123123,
91
+ info: 12,
92
+ subRows: [
93
+ {
94
+ firstName: '1',
95
+ lastName: 'Stuffo',
96
+ address: 'Via Roma, 15 Monza',
97
+ uid: 123123,
98
+ info: 12,
99
+ subRows: [
100
+ {
101
+ firstName: '1',
102
+ lastName: 'Stuffo',
103
+ address: 'Via Roma, 15 Monza',
104
+ uid: 123123,
105
+ info: 12,
106
+ subRows: [
107
+ {
108
+ firstName: '1',
109
+ lastName: 'Stuffo',
110
+ address: 'Via Roma, 15 Monza',
111
+ uid: 123123,
112
+ info: 12,
113
+ subRows: [
114
+ {
115
+ firstName: '1',
116
+ lastName: 'Stuffo',
117
+ address: 'Via Roma, 15 Monza',
118
+ uid: 123123,
119
+ info: 12,
120
+ },
121
+ {
122
+ firstName: '2',
123
+ lastName: 'Stuffo',
124
+ address: 'Via Roma, 15 Monza',
125
+ uid: 123123,
126
+ info: 12,
127
+ },
128
+ {
129
+ firstName: '3',
130
+ lastName: 'Stuffo',
131
+ address: 'Via Roma, 15 Monza',
132
+ uid: 123123,
133
+ info: 12,
134
+ },
135
+ ],
136
+ },
137
+ {
138
+ firstName: '2',
139
+ lastName: 'Stuffo',
140
+ address: 'Via Roma, 15 Monza',
141
+ uid: 123123,
142
+ info: 12,
143
+ },
144
+ {
145
+ firstName: '3',
146
+ lastName: 'Stuffo',
147
+ address: 'Via Roma, 15 Monza',
148
+ uid: 123123,
149
+ info: 12,
150
+ },
151
+ ],
152
+ },
153
+ {
154
+ firstName: '2',
155
+ lastName: 'Stuffo',
156
+ address: 'Via Roma, 15 Monza',
157
+ uid: 123123,
158
+ info: 12,
159
+ },
160
+ {
161
+ firstName: '3',
162
+ lastName: 'Stuffo',
163
+ address: 'Via Roma, 15 Monza',
164
+ uid: 123123,
165
+ info: 12,
166
+ },
167
+ ],
168
+ },
169
+ {
170
+ firstName: '2',
171
+ lastName: 'Stuffo',
172
+ address: 'Via Roma, 15 Monza',
173
+ uid: 123123,
174
+ info: 12,
175
+ },
176
+ {
177
+ firstName: '3',
178
+ lastName: 'Stuffo',
179
+ address: 'Via Roma, 15 Monza',
180
+ uid: 123123,
181
+ info: 12,
182
+ },
183
+ ],
184
+ },
185
+ {
186
+ firstName: '2',
187
+ lastName: 'Stuffo',
188
+ address: 'Via Roma, 15 Monza',
189
+ uid: 123123,
190
+ info: 12,
191
+ },
192
+ {
193
+ firstName: '3',
194
+ lastName: 'Stuffo',
195
+ address: 'Via Roma, 15 Monza',
196
+ uid: 123123,
197
+ info: 12,
198
+ },
199
+ ],
200
+ },
201
+ {
202
+ firstName: '2',
203
+ lastName: 'Stuffo',
204
+ address: 'Via Roma, 15 Monza',
205
+ uid: 123123,
206
+ info: 12,
207
+ },
208
+ {
209
+ firstName: '3',
210
+ lastName: 'Stuffo',
211
+ address: 'Via Roma, 15 Monza',
212
+ uid: 123123,
213
+ info: 12,
214
+ },
215
+ ],
216
+ },
217
+ {
218
+ firstName: '2',
219
+ lastName: 'Stuffo',
220
+ address: 'Via Roma, 15 Monza',
221
+ uid: 123123,
222
+ info: 12,
223
+ },
224
+ {
225
+ firstName: '3',
226
+ lastName: 'Stuffo',
227
+ address: 'Via Roma, 15 Monza',
228
+ uid: 123123,
229
+ info: 12,
230
+ },
231
+ ],
232
+ },
233
+ {
234
+ firstName: '2',
235
+ lastName: 'Stuffo',
236
+ address: 'Via Roma, 15 Monza',
237
+ uid: 123123,
238
+ info: 12,
239
+ },
240
+ {
241
+ firstName: '3',
242
+ lastName: 'Stuffo',
243
+ address: 'Via Roma, 15 Monza',
244
+ uid: 123123,
245
+ info: 12,
246
+ },
247
+ ],
248
+ },
249
+ ],
250
+ },
251
+ {
252
+ firstName: 'Simone',
253
+ lastName: 'Lastname',
254
+ address: 'Via Roma, 12, Bologna',
255
+ uid: '345367890',
256
+ canBeDeleted: true,
257
+ info: 123.96,
258
+ },
259
+ {
260
+ firstName: 'Matteo',
261
+ lastName: 'Staffone',
262
+ address: 'Via Roma, 13, Genova',
263
+ uid: 23456789,
264
+ info: _jsx("code", { children: "23456789" }),
265
+ subRows: [
266
+ {
267
+ firstName: '1',
268
+ lastName: 'Stuffo',
269
+ address: 'Via Roma, 15 Monza',
270
+ uid: 123123,
271
+ info: 12,
272
+ },
273
+ {
274
+ firstName: '2',
275
+ lastName: 'Stuffo',
276
+ address: 'Via Roma, 15 Monza',
277
+ uid: 123123,
278
+ info: 12,
279
+ subRows: [
280
+ {
281
+ firstName: '1',
282
+ lastName: 'Stuffo',
283
+ address: 'Via Roma, 15 Monza',
284
+ uid: 123123,
285
+ info: 12,
286
+ subRows: [
287
+ {
288
+ firstName: '1',
289
+ lastName: 'Stuffo',
290
+ address: 'Via Roma, 15 Monza',
291
+ uid: 123123,
292
+ info: 12,
293
+ },
294
+ {
295
+ firstName: '2',
296
+ lastName: 'Stuffo',
297
+ address: 'Via Roma, 15 Monza',
298
+ uid: 123123,
299
+ info: 12,
300
+ },
301
+ {
302
+ firstName: '3',
303
+ lastName: 'Stuffo',
304
+ address: 'Via Roma, 15 Monza',
305
+ uid: 123123,
306
+ info: 12,
307
+ },
308
+ ],
309
+ },
310
+ {
311
+ firstName: '2',
312
+ lastName: 'Stuffo',
313
+ address: 'Via Roma, 15 Monza',
314
+ uid: 123123,
315
+ info: 12,
316
+ },
317
+ {
318
+ firstName: '3',
319
+ lastName: 'Stuffo',
320
+ address: 'Via Roma, 15 Monza',
321
+ uid: 123123,
322
+ info: 12,
323
+ },
324
+ ],
325
+ },
326
+ {
327
+ firstName: '3',
328
+ lastName: 'Stuffo',
329
+ address: 'Via Roma, 15 Monza',
330
+ uid: 123123,
331
+ info: 12,
332
+ subRows: [
333
+ {
334
+ firstName: '1',
335
+ lastName: 'Stuffo',
336
+ address: 'Via Roma, 15 Monza',
337
+ uid: 123123,
338
+ info: 12,
339
+ },
340
+ {
341
+ firstName: '2',
342
+ lastName: 'Stuffo',
343
+ address: 'Via Roma, 15 Monza',
344
+ uid: 123123,
345
+ info: 12,
346
+ },
347
+ {
348
+ firstName: '3',
349
+ lastName: 'Stuffo',
350
+ address: 'Via Roma, 15 Monza',
351
+ uid: 123123,
352
+ info: 12,
353
+ },
354
+ ],
355
+ },
356
+ ],
357
+ },
358
+ {
359
+ firstName: 'Emanuele',
360
+ lastName: 'Staffo',
361
+ address: 'Via Roma, 14, Milano',
362
+ uid: '2345678',
363
+ info: 1234,
364
+ },
365
+ {
366
+ firstName: 'Simone',
367
+ lastName: 'Stuffo',
368
+ address: 'Via Roma, 15 Monza',
369
+ uid: 123123,
370
+ info: 12,
371
+ subRows: [
372
+ {
373
+ firstName: 'ciao',
374
+ lastName: 'Stuffo',
375
+ address: 'Via Roma, 15 Monza',
376
+ uid: 123123,
377
+ info: 12,
378
+ },
379
+ ],
380
+ },
381
+ {
382
+ firstName: 'Luca',
383
+ lastName: 'Morandi',
384
+ address: 'Via Roma, 1, Treno',
385
+ uid: 3456795423556789,
386
+ info: 123123.12,
387
+ subRows: [
388
+ {
389
+ firstName: 'ciao',
390
+ lastName: 'Stuffo',
391
+ address: 'Via Roma, 15 Monza',
392
+ uid: 123123,
393
+ info: 12,
394
+ },
395
+ ],
396
+ },
397
+ {
398
+ firstName: 'Mattia',
399
+ lastName: 'Lastname',
400
+ address: 'Via Roma, 12, Bologna',
401
+ uid: 345367890,
402
+ info: 123.96,
403
+ },
404
+ {
405
+ firstName: 'Morfeo',
406
+ lastName: 'Staffone',
407
+ address: 'Via Roma, 13, Genova',
408
+ uid: 3434235,
409
+ info: 12.1213,
410
+ },
411
+ {
412
+ firstName: 'Gianluca',
413
+ lastName: 'Staffo',
414
+ address: 'Via Roma, 14, Milano',
415
+ uid: 2345678,
416
+ info: 1234,
417
+ },
418
+ {
419
+ firstName: 'Simone',
420
+ lastName: 'Stuffo',
421
+ address: 'Via Roma, 15 Monza',
422
+ uid: 123123,
423
+ info: 12,
424
+ },
425
+ {
426
+ firstName: 'Simone',
427
+ lastName: 'Stuffo',
428
+ address: 'Via Roma, 15 Monza',
429
+ uid: 123123,
430
+ info: 12,
431
+ },
432
+ {
433
+ firstName: 'Simone',
434
+ lastName: 'Stuffo',
435
+ address: 'Via Roma, 15 Monza',
436
+ uid: 123123,
437
+ info: 12,
438
+ },
439
+ {
440
+ firstName: 'Simone',
441
+ lastName: 'Stuffo',
442
+ address: 'Via Roma, 15 Monza',
443
+ uid: 123123,
444
+ info: 12,
445
+ },
446
+ {
447
+ firstName: 'Simone',
448
+ lastName: 'Stuffo',
449
+ address: 'Via Roma, 15 Monza',
450
+ uid: 123123,
451
+ info: 12,
452
+ },
453
+ {
454
+ firstName: 'Simone',
455
+ lastName: 'Stuffo',
456
+ address: 'Via Roma, 15 Monza',
457
+ uid: 123123,
458
+ info: 12,
459
+ },
460
+ {
461
+ firstName: 'Simone',
462
+ lastName: 'Stuffo',
463
+ address: 'Via Roma, 15 Monza',
464
+ uid: 123123,
465
+ info: 12,
466
+ },
467
+ ],
468
+ dataWithIds: [
469
+ {
470
+ ...firstData,
471
+ _id: '1',
472
+ subRows: [
473
+ {
474
+ _id: '1.1',
475
+ firstName: 'ciao',
476
+ lastName: 'Stuffo',
477
+ address: 'Via Roma, 15 Monza',
478
+ uid: 123123,
479
+ info: 12,
480
+ subRows: [
481
+ {
482
+ _id: '1.1.1',
483
+ firstName: '1',
484
+ lastName: 'Stuffo',
485
+ address: 'Via Roma, 15 Monza',
486
+ uid: 123123,
487
+ info: 12,
488
+ subRows: [
489
+ {
490
+ _id: '1.1.1.1',
491
+ firstName: '1',
492
+ lastName: 'Stuffo',
493
+ address: 'Via Roma, 15 Monza',
494
+ uid: 123123,
495
+ info: 12,
496
+ subRows: [
497
+ {
498
+ _id: '1.1.1.1.1',
499
+ firstName: '1',
500
+ lastName: 'Stuffo',
501
+ address: 'Via Roma, 15 Monza',
502
+ uid: 123123,
503
+ info: 12,
504
+ subRows: [
505
+ {
506
+ _id: '1.1.1.1.1.1',
507
+ firstName: '1',
508
+ lastName: 'Stuffo',
509
+ address: 'Via Roma, 15 Monza',
510
+ uid: 123123,
511
+ info: 12,
512
+ subRows: [
513
+ {
514
+ _id: '1.1.1.1.1.1.1',
515
+ firstName: '1',
516
+ lastName: 'Stuffo',
517
+ address: 'Via Roma, 15 Monza',
518
+ uid: 123123,
519
+ info: 12,
520
+ subRows: [
521
+ {
522
+ _id: '1.1.1.1.1.1.1.1',
523
+ firstName: '1',
524
+ lastName: 'Stuffo',
525
+ address: 'Via Roma, 15 Monza',
526
+ uid: 123123,
527
+ info: 12,
528
+ subRows: [
529
+ {
530
+ _id: '1.1.1.1.1.1.1.1.1',
531
+ firstName: '1',
532
+ lastName: 'Stuffo',
533
+ address: 'Via Roma, 15 Monza',
534
+ uid: 123123,
535
+ info: 12,
536
+ subRows: [
537
+ {
538
+ _id: '1.1.1.1.1.1.1.1.1.1',
539
+ firstName: '1',
540
+ lastName: 'Stuffo',
541
+ address: 'Via Roma, 15 Monza',
542
+ uid: 123123,
543
+ info: 12,
544
+ },
545
+ {
546
+ _id: '1.1.1.1.1.1.1.1.1.2',
547
+ firstName: '2',
548
+ lastName: 'Stuffo',
549
+ address: 'Via Roma, 15 Monza',
550
+ uid: 123123,
551
+ info: 12,
552
+ },
553
+ {
554
+ _id: '1.1.1.1.1.1.1.1.1.3',
555
+ firstName: '3',
556
+ lastName: 'Stuffo',
557
+ address: 'Via Roma, 15 Monza',
558
+ uid: 123123,
559
+ info: 12,
560
+ },
561
+ ],
562
+ },
563
+ {
564
+ _id: '1.1.1.1.1.1.1.1.2',
565
+ firstName: '2',
566
+ lastName: 'Stuffo',
567
+ address: 'Via Roma, 15 Monza',
568
+ uid: 123123,
569
+ info: 12,
570
+ },
571
+ {
572
+ _id: '1.1.1.1.1.1.1.1.3',
573
+ firstName: '3',
574
+ lastName: 'Stuffo',
575
+ address: 'Via Roma, 15 Monza',
576
+ uid: 123123,
577
+ info: 12,
578
+ },
579
+ ],
580
+ },
581
+ {
582
+ _id: '1.1.1.1.1.1.1.2',
583
+ firstName: '2',
584
+ lastName: 'Stuffo',
585
+ address: 'Via Roma, 15 Monza',
586
+ uid: 123123,
587
+ info: 12,
588
+ },
589
+ {
590
+ _id: '1.1.1.1.1.1.1.3',
591
+ firstName: '3',
592
+ lastName: 'Stuffo',
593
+ address: 'Via Roma, 15 Monza',
594
+ uid: 123123,
595
+ info: 12,
596
+ },
597
+ ],
598
+ },
599
+ {
600
+ _id: '1.1.1.1.1.1.2',
601
+ firstName: '2',
602
+ lastName: 'Stuffo',
603
+ address: 'Via Roma, 15 Monza',
604
+ uid: 123123,
605
+ info: 12,
606
+ },
607
+ {
608
+ _id: '1.1.1.1.1.1.3',
609
+ firstName: '3',
610
+ lastName: 'Stuffo',
611
+ address: 'Via Roma, 15 Monza',
612
+ uid: 123123,
613
+ info: 12,
614
+ },
615
+ ],
616
+ },
617
+ {
618
+ _id: '1.1.1.1.1.2',
619
+ firstName: '2',
620
+ lastName: 'Stuffo',
621
+ address: 'Via Roma, 15 Monza',
622
+ uid: 123123,
623
+ info: 12,
624
+ },
625
+ {
626
+ _id: '1.1.1.1.1.3',
627
+ firstName: '3',
628
+ lastName: 'Stuffo',
629
+ address: 'Via Roma, 15 Monza',
630
+ uid: 123123,
631
+ info: 12,
632
+ },
633
+ ],
634
+ },
635
+ {
636
+ _id: '1.1.1.1.2',
637
+ firstName: '2',
638
+ lastName: 'Stuffo',
639
+ address: 'Via Roma, 15 Monza',
640
+ uid: 123123,
641
+ info: 12,
642
+ },
643
+ {
644
+ _id: '1.1.1.1.3',
645
+ firstName: '3',
646
+ lastName: 'Stuffo',
647
+ address: 'Via Roma, 15 Monza',
648
+ uid: 123123,
649
+ info: 12,
650
+ },
651
+ ],
652
+ },
653
+ {
654
+ _id: '1.1.1.2',
655
+ firstName: '2',
656
+ lastName: 'Stuffo',
657
+ address: 'Via Roma, 15 Monza',
658
+ uid: 123123,
659
+ info: 12,
660
+ },
661
+ {
662
+ _id: '1.1.1.3',
663
+ firstName: '3',
664
+ lastName: 'Stuffo',
665
+ address: 'Via Roma, 15 Monza',
666
+ uid: 123123,
667
+ info: 12,
668
+ },
669
+ ],
670
+ },
671
+ {
672
+ _id: '1.1.2',
673
+ firstName: '2',
674
+ lastName: 'Stuffo',
675
+ address: 'Via Roma, 15 Monza',
676
+ uid: 123123,
677
+ info: 12,
678
+ },
679
+ {
680
+ _id: '1.1.3',
681
+ firstName: '3',
682
+ lastName: 'Stuffo',
683
+ address: 'Via Roma, 15 Monza',
684
+ uid: 123123,
685
+ info: 12,
686
+ },
687
+ ],
688
+ },
689
+ ],
690
+ },
691
+ {
692
+ _id: '2',
693
+ firstName: 'Simone',
694
+ lastName: 'Lastname',
695
+ address: 'Via Roma, 12, Bologna',
696
+ uid: '345367890',
697
+ canBeDeleted: true,
698
+ info: 123.96,
699
+ },
700
+ {
701
+ _id: '3',
702
+ firstName: 'Matteo',
703
+ lastName: 'Staffone',
704
+ address: 'Via Roma, 13, Genova',
705
+ uid: 23456789,
706
+ info: _jsx("code", { children: "23456789" }),
707
+ subRows: [
708
+ {
709
+ _id: '3.1',
710
+ firstName: '1',
711
+ lastName: 'Stuffo',
712
+ address: 'Via Roma, 15 Monza',
713
+ uid: 123123,
714
+ info: 12,
715
+ },
716
+ {
717
+ _id: '3.2',
718
+ firstName: '2',
719
+ lastName: 'Stuffo',
720
+ address: 'Via Roma, 15 Monza',
721
+ uid: 123123,
722
+ info: 12,
723
+ subRows: [
724
+ {
725
+ _id: '3.2.1',
726
+ firstName: '1',
727
+ lastName: 'Stuffo',
728
+ address: 'Via Roma, 15 Monza',
729
+ uid: 123123,
730
+ info: 12,
731
+ subRows: [
732
+ {
733
+ _id: '3.2.1.1',
734
+ firstName: '1',
735
+ lastName: 'Stuffo',
736
+ address: 'Via Roma, 15 Monza',
737
+ uid: 123123,
738
+ info: 12,
739
+ },
740
+ {
741
+ _id: '3.2.1.2',
742
+ firstName: '2',
743
+ lastName: 'Stuffo',
744
+ address: 'Via Roma, 15 Monza',
745
+ uid: 123123,
746
+ info: 12,
747
+ },
748
+ {
749
+ _id: '3.2.1.3',
750
+ firstName: '3',
751
+ lastName: 'Stuffo',
752
+ address: 'Via Roma, 15 Monza',
753
+ uid: 123123,
754
+ info: 12,
755
+ },
756
+ ],
757
+ },
758
+ {
759
+ _id: '3.2.2',
760
+ firstName: '2',
761
+ lastName: 'Stuffo',
762
+ address: 'Via Roma, 15 Monza',
763
+ uid: 123123,
764
+ info: 12,
765
+ },
766
+ {
767
+ _id: '3.2.3',
768
+ firstName: '3',
769
+ lastName: 'Stuffo',
770
+ address: 'Via Roma, 15 Monza',
771
+ uid: 123123,
772
+ info: 12,
773
+ },
774
+ ],
775
+ },
776
+ {
777
+ _id: '3.3',
778
+ firstName: '3',
779
+ lastName: 'Stuffo',
780
+ address: 'Via Roma, 15 Monza',
781
+ uid: 123123,
782
+ info: 12,
783
+ subRows: [
784
+ {
785
+ _id: '3.3.1',
786
+ firstName: '1',
787
+ lastName: 'Stuffo',
788
+ address: 'Via Roma, 15 Monza',
789
+ uid: 123123,
790
+ info: 12,
791
+ },
792
+ {
793
+ _id: '3.3.2',
794
+ firstName: '2',
795
+ lastName: 'Stuffo',
796
+ address: 'Via Roma, 15 Monza',
797
+ uid: 123123,
798
+ info: 12,
799
+ },
800
+ {
801
+ _id: '3.3.3',
802
+ firstName: '3',
803
+ lastName: 'Stuffo',
804
+ address: 'Via Roma, 15 Monza',
805
+ uid: 123123,
806
+ info: 12,
807
+ },
808
+ ],
809
+ },
810
+ ],
811
+ },
812
+ {
813
+ _id: '4',
814
+ firstName: 'Emanuele',
815
+ lastName: 'Staffo',
816
+ address: 'Via Roma, 14, Milano',
817
+ uid: '2345678',
818
+ info: 1234,
819
+ },
820
+ {
821
+ _id: '5',
822
+ firstName: 'Simone',
823
+ lastName: 'Stuffo',
824
+ address: 'Via Roma, 15 Monza',
825
+ uid: 123123,
826
+ info: 12,
827
+ subRows: [
828
+ {
829
+ _id: '5.1',
830
+ firstName: 'ciao',
831
+ lastName: 'Stuffo',
832
+ address: 'Via Roma, 15 Monza',
833
+ uid: 123123,
834
+ info: 12,
835
+ },
836
+ ],
837
+ },
838
+ {
839
+ _id: '6',
840
+ firstName: 'Luca',
841
+ lastName: 'Morandi',
842
+ address: 'Via Roma, 1, Treno',
843
+ uid: 3456795423556789,
844
+ info: 123123.12,
845
+ subRows: [
846
+ {
847
+ _id: '6.1',
848
+ firstName: 'ciao',
849
+ lastName: 'Stuffo',
850
+ address: 'Via Roma, 15 Monza',
851
+ uid: 123123,
852
+ info: 12,
853
+ },
854
+ ],
855
+ },
856
+ {
857
+ _id: '7',
858
+ firstName: 'Mattia',
859
+ lastName: 'Lastname',
860
+ address: 'Via Roma, 12, Bologna',
861
+ uid: 345367890,
862
+ info: 123.96,
863
+ },
864
+ {
865
+ _id: '8',
866
+ firstName: 'Morfeo',
867
+ lastName: 'Staffone',
868
+ address: 'Via Roma, 13, Genova',
869
+ uid: 3434235,
870
+ info: 12.1213,
871
+ },
872
+ {
873
+ _id: '9',
874
+ firstName: 'Gianluca',
875
+ lastName: 'Staffo',
876
+ address: 'Via Roma, 14, Milano',
877
+ uid: 2345678,
878
+ info: 1234,
879
+ },
880
+ {
881
+ _id: '10',
882
+ firstName: 'Simone',
883
+ lastName: 'Stuffo',
884
+ address: 'Via Roma, 15 Monza',
885
+ uid: 123123,
886
+ info: 12,
887
+ },
888
+ {
889
+ _id: '11',
890
+ firstName: 'Simone',
891
+ lastName: 'Stuffo',
892
+ address: 'Via Roma, 15 Monza',
893
+ uid: 123123,
894
+ info: 12,
895
+ },
896
+ {
897
+ _id: '12',
898
+ firstName: 'Simone',
899
+ lastName: 'Stuffo',
900
+ address: 'Via Roma, 15 Monza',
901
+ uid: 123123,
902
+ info: 12,
903
+ },
904
+ {
905
+ _id: '13',
906
+ firstName: 'Simone',
907
+ lastName: 'Stuffo',
908
+ address: 'Via Roma, 15 Monza',
909
+ uid: 123123,
910
+ info: 12,
911
+ },
912
+ {
913
+ _id: '14',
914
+ firstName: 'Simone',
915
+ lastName: 'Stuffo',
916
+ address: 'Via Roma, 15 Monza',
917
+ uid: 123123,
918
+ info: 12,
919
+ },
920
+ {
921
+ _id: '15',
922
+ firstName: 'Simone',
923
+ lastName: 'Stuffo',
924
+ address: 'Via Roma, 15 Monza',
925
+ uid: 123123,
926
+ info: 12,
927
+ },
928
+ {
929
+ _id: '16',
930
+ firstName: 'Simone',
931
+ lastName: 'Stuffo',
932
+ address: 'Via Roma, 15 Monza',
933
+ uid: 123123,
934
+ info: 12,
935
+ },
936
+ ],
937
+ },
938
+ };
939
+ export default story;
940
+ const CustomExpandableComponent = ({ data }) => (_jsx(Stack, { vPadding: 16, hPadding: 16, rowGap: 32, children: Object.keys(data).map((item, i) => (_jsxs("div", { style: { background: 'var(--dimmed-1)', padding: 24, minHeight: 50 * (i + 1) }, children: [_jsx(Title, { level: "6", children: typeof data[item] === 'string' ? data[item] : null }), "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Labore, nostrum minima, debitis qui magni voluptatum."] }, item))) }));
941
+ const CustomEmptyComponent = () => (_jsx("div", { title: "No data to show", children: "It seems there is no data to show inside this table. If data should be present,please check if columns are visible by using the table controls." }));
942
+ const Template = ({ dataWithIds, ...args }) => (_jsx(Table, { emptyComponent: _jsx(CustomEmptyComponent, {}), onRowExpandChange: rows => console.log(rows), ...args }));
943
+ export const Simple = Template.bind({});
944
+ const SelectionTemplate = ({ dataWithIds, data, ...args }) => {
945
+ const [tableData, setTableData] = useState(dataWithIds);
946
+ const [selectedRowIds, setSelectedRowIds] = useState([]);
947
+ const onDelete = (selectedRowIds) => {
948
+ const newTableData = tableData.filter(({ _id }) => !selectedRowIds.includes(_id));
949
+ setSelectedRowIds([]);
950
+ setTableData(newTableData);
951
+ };
952
+ return (_jsx(Table, { data: tableData, selectedRowIds: selectedRowIds, onSelectedRowsChange: setSelectedRowIds, selectedActions: selectedRowIds => _jsx(Button, { onClick: () => onDelete(selectedRowIds), children: "Delete rows" }), emptyComponent: _jsx(CustomEmptyComponent, {}), ...args }));
953
+ };
954
+ export const SelectedRows = SelectionTemplate.bind({});
955
+ SelectedRows.args = {
956
+ title: 'With selectable rows',
957
+ selectableRows: true,
958
+ showPagination: true,
959
+ };
960
+ const HidingColumnTemplate = ({ dataWithIds, columns, ...args }) => {
961
+ const tableColumns = [
962
+ ...columns,
963
+ {
964
+ id: 'birthday',
965
+ Header: 'Birthday',
966
+ accessor: row => row.birthday,
967
+ },
968
+ {
969
+ id: 'gender',
970
+ Header: 'Gender',
971
+ accessor: row => row.gender,
972
+ },
973
+ {
974
+ id: 'height',
975
+ Header: 'Height',
976
+ accessor: row => row.height,
977
+ },
978
+ {
979
+ id: 'weight',
980
+ Header: 'Weight',
981
+ accessor: row => row.weight,
982
+ },
983
+ ];
984
+ return (_jsx(Table, { emptyComponent: _jsx(CustomEmptyComponent, {}), columns: tableColumns, ...args }));
985
+ };
986
+ export const HidingColumn = HidingColumnTemplate.bind({});
987
+ HidingColumn.args = {
988
+ showHeader: true,
989
+ columnsControl: true,
990
+ };
991
+ export const defaultHiddenColumns = Template.bind({});
992
+ defaultHiddenColumns.args = {
993
+ showHeader: true,
994
+ columnsControl: true,
995
+ defaultHiddenColumns: ['address', 'uid'],
996
+ };
997
+ export const Scrollable = Template.bind({});
998
+ Scrollable.args = {
999
+ columnsControl: true,
1000
+ showHeader: true,
1001
+ background: 'var(--global-background)',
1002
+ title: 'Scrollable table',
1003
+ height: '400px',
1004
+ };
1005
+ export const WithTableActions = Template.bind({});
1006
+ WithTableActions.args = {
1007
+ columnsControl: true,
1008
+ title: 'Custom title element',
1009
+ showHeader: true,
1010
+ actions: _jsx(Button, { children: "Custom action" }),
1011
+ };
1012
+ export const CustomExpandable = Template.bind({});
1013
+ CustomExpandable.args = {
1014
+ columnsControl: true,
1015
+ showHeader: true,
1016
+ selectableRows: true,
1017
+ expandableRowComponent: data => _jsx(CustomExpandableComponent, { data: data }),
1018
+ };
1019
+ export const Pagination = SelectionTemplate.bind({});
1020
+ Pagination.args = {
1021
+ columnsControl: true,
1022
+ showHeader: true,
1023
+ selectableRows: true,
1024
+ itemsPerPage: 3,
1025
+ pageClusters: [3, 6, 9, 12],
1026
+ showPagination: true,
1027
+ };
1028
+ const RowActionsTemplate = ({ columns, ...args }) => {
1029
+ const tableColumns = useMemo(() => [
1030
+ {
1031
+ id: 'actions',
1032
+ disableSortBy: true,
1033
+ isToggable: true,
1034
+ isCollapsed: true,
1035
+ accessor: _ => (_jsxs(Stack, { direction: "row", fill: false, children: [_jsx(IconButton, { icon: "astronomy", kind: "flat", dimension: "small" }), _jsx(Popover, { trigger: _jsx(IconButton, { icon: "more-vert", kind: "flat", dimension: "small" }), children: _jsxs(Menu, { children: [_jsx(Menu.Item, { dimension: "small", autoFocus: true, icon: "ctrl-right", children: "Sample long menu item" }), _jsx(Menu.Item, { dimension: "small", icon: "arrow-down-to-bracket", children: "Short menu label" }), _jsx(Separator, {}), _jsx(Menu.Item, { dimension: "small", icon: "view", children: "Even shorter" }), _jsx(Menu.Item, { dimension: "small", disabled: true, children: "Really?" })] }) })] })),
1036
+ },
1037
+ ...columns
1038
+ ], [columns]);
1039
+ return (_jsx(Table, { columns: tableColumns, ...args }));
1040
+ };
1041
+ export const RowActions = RowActionsTemplate.bind({});
1042
+ RowActions.args = {
1043
+ columnsControl: true,
1044
+ showHeader: true,
1045
+ selectableRows: true,
1046
+ };
1047
+ export const NoData = Template.bind({});
1048
+ NoData.args = {
1049
+ columnsControl: true,
1050
+ showHeader: true,
1051
+ selectableRows: true,
1052
+ data: [],
1053
+ };
1054
+ const ManualPaginationTemplate = ({ data, dataWithIds, ...args }) => {
1055
+ const [allData, setAllData] = useState(dataWithIds);
1056
+ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 5 });
1057
+ const [selectedRowIds, setSelectedRowIds] = useState(['4', '9', '12']);
1058
+ const pageData = useMemo(() => {
1059
+ const { pageIndex, pageSize } = pagination;
1060
+ const newIndexStart = pageIndex * pageSize;
1061
+ const newIndexEnd = (pageIndex * pageSize) + pageSize;
1062
+ return allData.slice(newIndexStart, newIndexEnd);
1063
+ }, [allData, pagination]);
1064
+ const onDelete = (selectedRowIds) => {
1065
+ const newTableData = allData.filter(({ _id }) => !selectedRowIds.includes(_id));
1066
+ setSelectedRowIds([]);
1067
+ setAllData(newTableData);
1068
+ };
1069
+ return (_jsx(Table, { ...args, data: pageData, onSelectedRowsChange: setSelectedRowIds, selectedRowIds: selectedRowIds, selectedActions: () => _jsx(Button, { onClick: () => onDelete(selectedRowIds), children: "Delete rows" }), onPaginationChange: (newPagination) => {
1070
+ if (newPagination.pageIndex !== pagination.pageIndex || newPagination.pageSize !== pagination.pageSize) {
1071
+ setPagination(newPagination);
1072
+ }
1073
+ }, totalRows: allData.length, emptyComponent: _jsx(CustomEmptyComponent, {}) }));
1074
+ };
1075
+ export const ManualPagination = ManualPaginationTemplate.bind({});
1076
+ ManualPagination.args = {
1077
+ columnsControl: true,
1078
+ showHeader: true,
1079
+ selectableRows: true,
1080
+ showPagination: true,
1081
+ itemsPerPage: 5,
1082
+ };
1083
+ export const Loading = Template.bind({});
1084
+ Loading.args = {
1085
+ data: [],
1086
+ columnsControl: true,
1087
+ showHeader: true,
1088
+ loading: true,
1089
+ };
1090
+ const ManualSortingTemplate = ({ data, dataWithIds, ...args }) => {
1091
+ const [pageData, setPageData] = useState(dataWithIds.slice(0, 5));
1092
+ const [sortBy, setSortBy] = useState([]);
1093
+ const fetchData = useCallback(({ pageIndex, pageSize }) => {
1094
+ const result = [...dataWithIds];
1095
+ if (sortBy.length === 0) {
1096
+ setPageData(result.slice(pageIndex * pageSize, pageIndex * pageSize + pageSize));
1097
+ return;
1098
+ }
1099
+ const sorting = sortBy[0];
1100
+ result.sort((dataA, dataB) => {
1101
+ const isTypeNumber = typeof dataB[sorting.id] === 'number' || typeof dataA[sorting.id] === 'number';
1102
+ if (isTypeNumber) {
1103
+ const numberA = Number(dataA[sorting.id]);
1104
+ const numberB = Number(dataB[sorting.id]);
1105
+ return sorting.desc ? numberB - numberA : numberA - numberB;
1106
+ }
1107
+ const stringA = String(dataA[sorting.id]);
1108
+ const stringB = String(dataB[sorting.id]);
1109
+ return sorting.desc
1110
+ ? stringB.localeCompare(stringA)
1111
+ : stringA.localeCompare(stringB);
1112
+ });
1113
+ setPageData(result.slice(pageIndex * pageSize, pageIndex * pageSize + pageSize));
1114
+ }, [dataWithIds, sortBy]);
1115
+ return (_jsx(Table, { data: pageData, onSortChange: sortBy => setSortBy(sortBy), onPaginationChange: fetchData, totalRows: dataWithIds.length, emptyComponent: _jsx(CustomEmptyComponent, {}), ...args }));
1116
+ };
1117
+ export const ManualSorting = ManualSortingTemplate.bind({});
1118
+ ManualSorting.args = {
1119
+ isManualSorted: true,
1120
+ columnsControl: true,
1121
+ selectableRows: true,
1122
+ showPagination: true,
1123
+ itemsPerPage: 5,
1124
+ };
1125
+ const ManualPaginationFilteringTemplate = ({ data, dataWithIds, ...args }) => {
1126
+ const [allData, setAllData] = useState(dataWithIds);
1127
+ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 5 });
1128
+ const pageData = useMemo(() => {
1129
+ const { pageIndex, pageSize } = pagination;
1130
+ const newIndexStart = pageIndex * pageSize;
1131
+ const newIndexEnd = (pageIndex * pageSize) + pageSize;
1132
+ return allData.slice(newIndexStart, newIndexEnd);
1133
+ }, [allData, pagination]);
1134
+ const onDelete = (selectedRowIds) => {
1135
+ const newTableData = allData.filter(({ _id }) => !selectedRowIds.includes(_id));
1136
+ setAllData(newTableData);
1137
+ };
1138
+ return (_jsx(Table, { ...args, data: pageData, actions: _jsx(Button, { onClick: () => setAllData(allData.filter(r => r.lastName === 'Stuffo')), children: "Filter Stuffo" }), selectedActions: selectedRowIds => _jsx(Button, { onClick: () => onDelete(selectedRowIds), children: "Delete rows" }), onPaginationChange: (newPagination) => {
1139
+ if (newPagination.pageIndex !== pagination.pageIndex || newPagination.pageSize !== pagination.pageSize) {
1140
+ setPagination(newPagination);
1141
+ }
1142
+ }, totalRows: allData.length, emptyComponent: _jsx(CustomEmptyComponent, {}) }));
1143
+ };
1144
+ export const ManualPaginationFiltering = ManualPaginationFilteringTemplate.bind({});
1145
+ ManualPaginationFiltering.args = {
1146
+ isManualSorted: true,
1147
+ columnsControl: true,
1148
+ showHeader: true,
1149
+ selectableRows: true,
1150
+ showPagination: true,
1151
+ itemsPerPage: 5,
1152
+ };
1153
+ const PreselectedRowsTemplate = ({ dataWithIds, data, ...args }) => {
1154
+ const [tableData, setTableData] = useState(dataWithIds);
1155
+ const [selectedRowIds, setSelectedRowIds] = useState(['2', '4', '9', '12']);
1156
+ const onDelete = (selectedRowIds) => {
1157
+ const newTableData = tableData.filter(({ _id }) => !selectedRowIds.includes(_id));
1158
+ setSelectedRowIds([]);
1159
+ setTableData(newTableData);
1160
+ };
1161
+ return (_jsx(Table, { data: tableData, selectedRowIds: selectedRowIds, onSelectedRowsChange: setSelectedRowIds, selectedActions: selectedRowIds => _jsx(Button, { onClick: () => onDelete(selectedRowIds), children: "Delete rows" }), emptyComponent: _jsx(CustomEmptyComponent, {}), ...args }));
1162
+ };
1163
+ export const PreselectedRows = PreselectedRowsTemplate.bind({});
1164
+ PreselectedRows.args = {
1165
+ title: 'With selectable rows',
1166
+ selectableRows: true,
1167
+ showPagination: true,
1168
+ };
1169
+ const AsyncDataTemplate = ({ data, columns }) => {
1170
+ const [innerData, setInnerData] = useState([]);
1171
+ const [loading, setLoading] = useState(true);
1172
+ useEffect(() => {
1173
+ setLoading(true);
1174
+ const dataTimeout = setTimeout(() => {
1175
+ setInnerData(data);
1176
+ setLoading(false);
1177
+ }, 2500);
1178
+ return () => {
1179
+ clearTimeout(dataTimeout);
1180
+ };
1181
+ }, [data]);
1182
+ return (_jsx(Table, { title: "Alphabet", columns: columns, data: innerData, loading: loading, showHeader: true, selectableRows: true }));
1183
+ };
1184
+ export const AsyncData = AsyncDataTemplate.bind({});
1185
+ AsyncData.args = {
1186
+ title: 'With selectable rows',
1187
+ };