@powerhousedao/document-engineering 1.10.0 → 1.12.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 (139) hide show
  1. package/dist/src/scalars/components/amount-field/amount-field-validations.d.ts +1 -1
  2. package/dist/src/scalars/components/amount-field/amount-field-validations.d.ts.map +1 -1
  3. package/dist/src/scalars/components/amount-field/amount-field-validations.js +1 -12
  4. package/dist/src/scalars/components/amount-field/amount-field-validations.js.map +1 -1
  5. package/dist/src/scalars/components/fragments/id-autocomplete/use-id-autocomplete.js +1 -1
  6. package/dist/src/scalars/components/fragments/id-autocomplete/use-id-autocomplete.js.map +1 -1
  7. package/dist/src/scalars/components/fragments/radio-group-field/radio-group-field.d.ts +1 -0
  8. package/dist/src/scalars/components/fragments/radio-group-field/radio-group-field.d.ts.map +1 -1
  9. package/dist/src/scalars/components/fragments/with-field-validation/with-field-validation.js +2 -2
  10. package/dist/src/scalars/components/fragments/with-field-validation/with-field-validation.js.map +1 -1
  11. package/dist/src/ui/components/data-entry/amount-input/amount-input.d.ts.map +1 -1
  12. package/dist/src/ui/components/data-entry/amount-input/amount-input.js +3 -5
  13. package/dist/src/ui/components/data-entry/amount-input/amount-input.js.map +1 -1
  14. package/dist/src/ui/components/data-entry/amount-input/utils.js +1 -1
  15. package/dist/src/ui/components/data-entry/amount-input/utils.js.map +1 -1
  16. package/dist/src/ui/components/data-entry/currency-code-picker/currency-code-picker.d.ts.map +1 -1
  17. package/dist/src/ui/components/data-entry/currency-code-picker/currency-code-picker.js +2 -2
  18. package/dist/src/ui/components/data-entry/currency-code-picker/currency-code-picker.js.map +1 -1
  19. package/dist/src/ui/components/data-entry/input/subcomponent/text-diff.d.ts.map +1 -1
  20. package/dist/src/ui/components/data-entry/input/subcomponent/text-diff.js +56 -21
  21. package/dist/src/ui/components/data-entry/input/subcomponent/text-diff.js.map +1 -1
  22. package/dist/src/ui/components/data-entry/number-input/use-number-input.js +2 -1
  23. package/dist/src/ui/components/data-entry/number-input/use-number-input.js.map +1 -1
  24. package/dist/src/ui/components/data-entry/radio-group/radio-group.d.ts +2 -1
  25. package/dist/src/ui/components/data-entry/radio-group/radio-group.d.ts.map +1 -1
  26. package/dist/src/ui/components/data-entry/radio-group/radio-group.js +2 -2
  27. package/dist/src/ui/components/data-entry/radio-group/radio-group.js.map +1 -1
  28. package/dist/src/ui/components/data-entry/select/command-list-item.d.ts +1 -1
  29. package/dist/src/ui/components/data-entry/select/command-list-item.d.ts.map +1 -1
  30. package/dist/src/ui/components/data-entry/select/command-list-item.js +2 -2
  31. package/dist/src/ui/components/data-entry/select/command-list-item.js.map +1 -1
  32. package/dist/src/ui/components/data-entry/select/content.d.ts +0 -1
  33. package/dist/src/ui/components/data-entry/select/content.d.ts.map +1 -1
  34. package/dist/src/ui/components/data-entry/select/content.js +5 -5
  35. package/dist/src/ui/components/data-entry/select/content.js.map +1 -1
  36. package/dist/src/ui/components/data-entry/select/select.d.ts.map +1 -1
  37. package/dist/src/ui/components/data-entry/select/select.js +3 -3
  38. package/dist/src/ui/components/data-entry/select/select.js.map +1 -1
  39. package/dist/src/ui/components/data-entry/select/selected-content.d.ts +0 -1
  40. package/dist/src/ui/components/data-entry/select/selected-content.d.ts.map +1 -1
  41. package/dist/src/ui/components/data-entry/select/selected-content.js +3 -3
  42. package/dist/src/ui/components/data-entry/select/selected-content.js.map +1 -1
  43. package/dist/src/ui/components/data-entry/select/types.d.ts +4 -4
  44. package/dist/src/ui/components/data-entry/select/types.d.ts.map +1 -1
  45. package/dist/src/ui/components/data-entry/url-input/types.d.ts +2 -4
  46. package/dist/src/ui/components/data-entry/url-input/types.d.ts.map +1 -1
  47. package/dist/src/ui/components/data-entry/url-input/url-input-diff.d.ts +1 -1
  48. package/dist/src/ui/components/data-entry/url-input/url-input-diff.d.ts.map +1 -1
  49. package/dist/src/ui/components/data-entry/url-input/url-input-diff.js +2 -2
  50. package/dist/src/ui/components/data-entry/url-input/url-input-diff.js.map +1 -1
  51. package/dist/src/ui/components/data-entry/url-input/url-input.d.ts.map +1 -1
  52. package/dist/src/ui/components/data-entry/url-input/url-input.js +2 -2
  53. package/dist/src/ui/components/data-entry/url-input/url-input.js.map +1 -1
  54. package/dist/src/ui/components/icon-components/ArrowDownUp.d.ts +7 -0
  55. package/dist/src/ui/components/icon-components/ArrowDownUp.d.ts.map +1 -0
  56. package/dist/src/ui/components/icon-components/ArrowDownUp.js +7 -0
  57. package/dist/src/ui/components/icon-components/ArrowDownUp.js.map +1 -0
  58. package/dist/src/ui/components/icon-components/index.d.ts +1 -1
  59. package/dist/src/ui/components/icon-components/index.d.ts.map +1 -1
  60. package/dist/src/ui/components/icon-components/index.js +3 -0
  61. package/dist/src/ui/components/icon-components/index.js.map +1 -1
  62. package/dist/src/ui/components/object-set-table/examples/api-usage/api-usage.d.ts.map +1 -1
  63. package/dist/src/ui/components/object-set-table/examples/api-usage/api-usage.js +5 -2
  64. package/dist/src/ui/components/object-set-table/examples/api-usage/api-usage.js.map +1 -1
  65. package/dist/src/ui/components/object-set-table/examples/computed-columns/computed-columns.d.ts.map +1 -1
  66. package/dist/src/ui/components/object-set-table/examples/computed-columns/computed-columns.js +1 -0
  67. package/dist/src/ui/components/object-set-table/examples/computed-columns/computed-columns.js.map +1 -1
  68. package/dist/src/ui/components/object-set-table/examples/custom-rendering/custom-rendering.d.ts.map +1 -1
  69. package/dist/src/ui/components/object-set-table/examples/custom-rendering/custom-rendering.js +4 -1
  70. package/dist/src/ui/components/object-set-table/examples/custom-rendering/custom-rendering.js.map +1 -1
  71. package/dist/src/ui/components/object-set-table/index.d.ts +2 -0
  72. package/dist/src/ui/components/object-set-table/index.d.ts.map +1 -1
  73. package/dist/src/ui/components/object-set-table/index.js +2 -0
  74. package/dist/src/ui/components/object-set-table/index.js.map +1 -1
  75. package/dist/src/ui/components/object-set-table/logic/selection-manager.d.ts.map +1 -1
  76. package/dist/src/ui/components/object-set-table/logic/selection-manager.js +2 -0
  77. package/dist/src/ui/components/object-set-table/logic/selection-manager.js.map +1 -1
  78. package/dist/src/ui/components/object-set-table/logic/table-api.d.ts +33 -2
  79. package/dist/src/ui/components/object-set-table/logic/table-api.d.ts.map +1 -1
  80. package/dist/src/ui/components/object-set-table/logic/table-api.js +53 -0
  81. package/dist/src/ui/components/object-set-table/logic/table-api.js.map +1 -1
  82. package/dist/src/ui/components/object-set-table/logic/types.d.ts +9 -1
  83. package/dist/src/ui/components/object-set-table/logic/types.d.ts.map +1 -1
  84. package/dist/src/ui/components/object-set-table/mock-data.js +14 -14
  85. package/dist/src/ui/components/object-set-table/mock-data.js.map +1 -1
  86. package/dist/src/ui/components/object-set-table/object-set-table.d.ts +1 -1
  87. package/dist/src/ui/components/object-set-table/object-set-table.d.ts.map +1 -1
  88. package/dist/src/ui/components/object-set-table/object-set-table.js +12 -5
  89. package/dist/src/ui/components/object-set-table/object-set-table.js.map +1 -1
  90. package/dist/src/ui/components/object-set-table/subcomponents/body.d.ts +2 -6
  91. package/dist/src/ui/components/object-set-table/subcomponents/body.d.ts.map +1 -1
  92. package/dist/src/ui/components/object-set-table/subcomponents/body.js +7 -106
  93. package/dist/src/ui/components/object-set-table/subcomponents/body.js.map +1 -1
  94. package/dist/src/ui/components/object-set-table/subcomponents/cells/render-cell.d.ts +11 -0
  95. package/dist/src/ui/components/object-set-table/subcomponents/cells/render-cell.d.ts.map +1 -0
  96. package/dist/src/ui/components/object-set-table/subcomponents/cells/render-cell.js +62 -0
  97. package/dist/src/ui/components/object-set-table/subcomponents/cells/render-cell.js.map +1 -0
  98. package/dist/src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.d.ts +2 -2
  99. package/dist/src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.d.ts.map +1 -1
  100. package/dist/src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.js.map +1 -1
  101. package/dist/src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.d.ts +2 -2
  102. package/dist/src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.d.ts.map +1 -1
  103. package/dist/src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.js +2 -2
  104. package/dist/src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.js.map +1 -1
  105. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/{default-header.renderer.d.ts → default-header-renderer.d.ts} +1 -1
  106. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header-renderer.d.ts.map +1 -0
  107. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header-renderer.js +36 -0
  108. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header-renderer.js.map +1 -0
  109. package/dist/src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.d.ts +3 -0
  110. package/dist/src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.d.ts.map +1 -0
  111. package/dist/src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.js +17 -0
  112. package/dist/src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.js.map +1 -0
  113. package/dist/src/ui/components/object-set-table/subcomponents/header.d.ts.map +1 -1
  114. package/dist/src/ui/components/object-set-table/subcomponents/header.js +32 -17
  115. package/dist/src/ui/components/object-set-table/subcomponents/header.js.map +1 -1
  116. package/dist/src/ui/components/object-set-table/subcomponents/rows/render-row.d.ts +9 -0
  117. package/dist/src/ui/components/object-set-table/subcomponents/rows/render-row.d.ts.map +1 -0
  118. package/dist/src/ui/components/object-set-table/subcomponents/rows/render-row.js +62 -0
  119. package/dist/src/ui/components/object-set-table/subcomponents/rows/render-row.js.map +1 -0
  120. package/dist/src/ui/components/object-set-table/subcomponents/sort-indicator.d.ts +7 -0
  121. package/dist/src/ui/components/object-set-table/subcomponents/sort-indicator.d.ts.map +1 -0
  122. package/dist/src/ui/components/object-set-table/subcomponents/sort-indicator.js +7 -0
  123. package/dist/src/ui/components/object-set-table/subcomponents/sort-indicator.js.map +1 -0
  124. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-provider.d.ts +1 -1
  125. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-provider.d.ts.map +1 -1
  126. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-provider.js +2 -0
  127. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-provider.js.map +1 -1
  128. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.d.ts +19 -1
  129. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.d.ts.map +1 -1
  130. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.js +49 -6
  131. package/dist/src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.js.map +1 -1
  132. package/dist/src/ui/components/object-set-table/types.d.ts +64 -3
  133. package/dist/src/ui/components/object-set-table/types.d.ts.map +1 -1
  134. package/dist/style.css +491 -35
  135. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  136. package/package.json +1 -1
  137. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header.renderer.d.ts.map +0 -1
  138. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header.renderer.js +0 -16
  139. package/dist/src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header.renderer.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { Input } from '../../../data-entry/input/index.js';
4
+ import { isCellEqual } from '../../utils.js';
5
+ import { useInternalTableState } from '../table-provider/table-provider.js';
6
+ import { DefaultTableCell } from './default-cell.js';
7
+ const RenderCell = ({ rowItem, column, rowIndex, columnIndex, renderEmptyCell = false, }) => {
8
+ const { config, state: { dispatch, selectedCellIndex, isCellEditMode }, api, } = useInternalTableState();
9
+ /**
10
+ * Create a handler for the click event on the table cell
11
+ * This handler is used to enter cell edit mode or select a cell
12
+ */
13
+ const createCellClickHandler = useCallback((index, column, columnDef) => (e) => {
14
+ // if the cell is being edited, ignore clicking on it
15
+ if (isCellEditMode && selectedCellIndex?.row === index && selectedCellIndex.column === column) {
16
+ return;
17
+ }
18
+ // if shift or ctrl is pressed, the user is probably trying to select rows
19
+ if (!e.ctrlKey && !e.metaKey && !e.shiftKey) {
20
+ if (e.detail === 2 && columnDef.editable) {
21
+ // TODO: move this to the api
22
+ dispatch?.({
23
+ type: 'ENTER_CELL_EDIT_MODE',
24
+ payload: { row: index, column },
25
+ });
26
+ }
27
+ else {
28
+ api.selection.selectCell(index, column);
29
+ }
30
+ }
31
+ }, [dispatch, isCellEditMode]);
32
+ const currentCellIndex = {
33
+ row: rowIndex,
34
+ column: columnIndex,
35
+ };
36
+ const isThisCellSelected = isCellEqual(selectedCellIndex, currentCellIndex);
37
+ /**
38
+ * If the cell is empty, we don't want to render anything
39
+ * so we're going to return a default table cell with no content
40
+ */
41
+ if (renderEmptyCell) {
42
+ return (_jsx(DefaultTableCell, { onClick: createCellClickHandler(rowIndex, columnIndex, column), isSelected: isThisCellSelected, isEditable: false }, column.field));
43
+ }
44
+ const cellContext = {
45
+ row: rowItem,
46
+ column,
47
+ rowIndex,
48
+ columnIndex,
49
+ tableConfig: config,
50
+ };
51
+ // get and format the cell value
52
+ const cellValue = column.valueFormatter?.(column.valueGetter?.(rowItem, cellContext), cellContext);
53
+ const isThisCellEditMode = isCellEditMode && isThisCellSelected;
54
+ return (_jsx(DefaultTableCell, { onClick: createCellClickHandler(rowIndex, columnIndex, column), isSelected: isThisCellSelected, isEditable: column.editable ?? false, children: isThisCellEditMode ? (_jsx(Input, { className: "max-w-full", autoFocus: true, defaultValue: column.valueGetter?.(rowItem, cellContext), onKeyDown: (e) => {
55
+ if (e.key === 'Enter') {
56
+ const newValue = e.target.value;
57
+ column.onSave?.(newValue, cellContext);
58
+ }
59
+ } })) : (column.renderCell?.(cellValue, cellContext)) }, column.field));
60
+ };
61
+ export { RenderCell };
62
+ //# sourceMappingURL=render-cell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-cell.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/cells/render-cell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAUpD,MAAM,UAAU,GAAG,CAAqB,EACtC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,WAAW,EACX,eAAe,GAAG,KAAK,GACJ,EAAE,EAAE;IACvB,MAAM,EACJ,MAAM,EACN,KAAK,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,EAAE,EACtD,GAAG,GACJ,GAAG,qBAAqB,EAAK,CAAA;IAE9B;;;OAGG;IACH,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,KAAa,EAAE,MAAc,EAAE,SAAuB,EAAE,EAAE,CAAC,CAAC,CAAyC,EAAE,EAAE;QACxG,qDAAqD;QACrD,IAAI,cAAc,IAAI,iBAAiB,EAAE,GAAG,KAAK,KAAK,IAAI,iBAAiB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9F,OAAM;QACR,CAAC;QAED,0EAA0E;QAC1E,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACzC,6BAA6B;gBAC7B,QAAQ,EAAE,CAAC;oBACT,IAAI,EAAE,sBAAsB;oBAC5B,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE;iBAChC,CAAC,CAAA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AE,WAAW,CAAW,EAClE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBACf,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;oBACtB,MAAM,QAAQ,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAA;oBACrD,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;gBACxC,CAAC;YACH,CAAC,GACD,CACH,CAAC,CAAC,CAAC,CACF,MAAM,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAC5C,IAnBI,MAAM,CAAC,KAAK,CAoBA,CACpB,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { CellType, RenderCellFn } from '../../types.js';
2
- declare const getRenderFn: <T>(type: CellType | undefined) => RenderCellFn<T>;
1
+ import type { ColumnType, RenderCellFn } from '../../types.js';
2
+ declare const getRenderFn: <T>(type: ColumnType | undefined) => RenderCellFn<T>;
3
3
  export { getRenderFn };
4
4
  //# sourceMappingURL=get-render-fn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-render-fn.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK5D,QAAA,MAAM,WAAW,GAAI,CAAC,EAAE,MAAM,QAAQ,GAAG,SAAS,KAAG,YAAY,CAAC,CAAC,CAalE,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"get-render-fn.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK9D,QAAA,MAAM,WAAW,GAAI,CAAC,EAAE,MAAM,UAAU,GAAG,SAAS,KAAG,YAAY,CAAC,CAAC,CAapE,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-render-fn.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,GAAG,CAAI,IAA0B,EAAmB,EAAE;IACrE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,cAAc,CAAA;QACvB,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAA;QACzB,KAAK,SAAS;YACZ,OAAO,iBAAiB,CAAA;QAC1B,KAAK,SAAS;YACZ,OAAO,cAAc,CAAA;QACvB;YACE,OAAO,cAAc,CAAA;IACzB,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"get-render-fn.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-cell-renderers/get-render-fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,GAAG,CAAI,IAA4B,EAAmB,EAAE;IACvE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,cAAc,CAAA;QACvB,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAA;QACzB,KAAK,SAAS;YACZ,OAAO,iBAAiB,CAAA;QAC1B,KAAK,SAAS;YACZ,OAAO,cAAc,CAAA;QACvB;YACE,OAAO,cAAc,CAAA;IACzB,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { CellType, ColumnAlignment } from '../../types.js';
2
- declare const defaultColumnAlignment: (cellType: CellType) => ColumnAlignment;
1
+ import type { ColumnAlignment, ColumnType } from '../../types.js';
2
+ declare const defaultColumnAlignment: (columnType: ColumnType) => ColumnAlignment;
3
3
  export { defaultColumnAlignment };
4
4
  //# sourceMappingURL=default-column-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-column-config.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE/D,QAAA,MAAM,sBAAsB,GAAI,UAAU,QAAQ,KAAG,eAUpD,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
1
+ {"version":3,"file":"default-column-config.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEjE,QAAA,MAAM,sBAAsB,GAAI,YAAY,UAAU,KAAG,eAUxD,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
- const defaultColumnAlignment = (cellType) => {
2
- switch (cellType) {
1
+ const defaultColumnAlignment = (columnType) => {
2
+ switch (columnType) {
3
3
  case 'number':
4
4
  return 'right';
5
5
  case 'text':
@@ -1 +1 @@
1
- {"version":3,"file":"default-column-config.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,CAAC,QAAkB,EAAmB,EAAE;IACrE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAA;QAEhB,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS,CAAC;QACf;YACE,OAAO,MAAM,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
1
+ {"version":3,"file":"default-column-config.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-fns/default-column-config.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,CAAC,UAAsB,EAAmB,EAAE;IACzE,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAA;QAEhB,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS,CAAC;QACf;YACE,OAAO,MAAM,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import type { CellContext } from '../../types.js';
2
2
  declare const defaultHeaderRenderer: <T, V = string>(value: V, context: CellContext<T>) => import("react/jsx-runtime").JSX.Element;
3
3
  export { defaultHeaderRenderer };
4
- //# sourceMappingURL=default-header.renderer.d.ts.map
4
+ //# sourceMappingURL=default-header-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-header-renderer.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header-renderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AA2CjD,QAAA,MAAM,qBAAqB,GAAI,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,4CAE9E,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from '../../../../../scalars/lib/utils.js';
3
+ import { SortIndicator } from '../sort-indicator.js';
4
+ import { useInternalTableState } from '../table-provider/table-provider.js';
5
+ const DefaultHeaderContent = ({ value, context }) => {
6
+ const { state } = useInternalTableState();
7
+ let classes = '';
8
+ if (context.column.width)
9
+ classes += ` w-[${context.column.width}]`;
10
+ if (context.column.minWidth)
11
+ classes += ` min-w-[${context.column.minWidth}]`;
12
+ if (context.column.maxWidth)
13
+ classes += ` max-w-[${context.column.maxWidth}]`;
14
+ if (context.column.align) {
15
+ const align = context.column.align;
16
+ switch (align) {
17
+ case 'left':
18
+ classes += ' justify-start';
19
+ break;
20
+ case 'center':
21
+ classes += ' justify-center';
22
+ break;
23
+ case 'right':
24
+ classes += ' justify-end';
25
+ break;
26
+ }
27
+ }
28
+ const isSorted = context.columnIndex === state.sortState?.columnIndex;
29
+ const sortingDirection = state.sortState?.direction ?? null;
30
+ return (_jsxs("div", { className: cn('flex items-center gap-2', 'px-[12px] py-[15px] text-left text-[14px] font-medium leading-[14px] text-gray-500', classes), children: [_jsx("span", { children: value }), context.column.sortable && _jsx(SortIndicator, { direction: isSorted ? sortingDirection : null })] }));
31
+ };
32
+ const defaultHeaderRenderer = (value, context) => {
33
+ return _jsx(DefaultHeaderContent, { value: value, context: context });
34
+ };
35
+ export { defaultHeaderRenderer };
36
+ //# sourceMappingURL=default-header-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-header-renderer.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-header-renderers/default-header-renderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAA;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAE3E,MAAM,o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C,CAAC,IAAI,GAAI,IACxF,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAgB,KAAQ,EAAE,OAAuB,EAAE,EAAE;IACjF,OAAO,KAAC,oBAAoB,IAAC,KAAK,EAAE,KAAe,EAAE,OAAO,EAAE,OAAO,GAAI,CAAA;AAC3E,CAAC,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ColumnType, SortFn } from '../../types.js';
2
+ export declare const defaultSortFns: <T = unknown>(columnType: ColumnType) => SortFn<T>;
3
+ //# sourceMappingURL=default-sort-fns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-sort-fns.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAUxD,eAAO,MAAM,cAAc,GAAI,CAAC,GAAG,OAAO,EAAE,YAAY,UAAU,KAAG,MAAM,CAAC,CAAC,CAU5E,CAAA"}
@@ -0,0 +1,17 @@
1
+ const defaultSortNumberFn = (a, b) => {
2
+ return Number(a) - Number(b);
3
+ };
4
+ const defaultSortTextFn = (a, b) => {
5
+ return a.localeCompare(b);
6
+ };
7
+ export const defaultSortFns = (columnType) => {
8
+ switch (columnType) {
9
+ case 'number':
10
+ return defaultSortNumberFn;
11
+ case 'boolean':
12
+ case 'text':
13
+ default:
14
+ return defaultSortTextFn;
15
+ }
16
+ };
17
+ //# sourceMappingURL=default-sort-fns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-sort-fns.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/default-sort-columns/default-sort-fns.ts"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE;IACrD,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE;IACnD,OAAQ,CAAY,CAAC,aAAa,CAAC,CAAW,CAAC,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAc,UAAsB,EAAa,EAAE;IAC/E,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,mBAAmB,CAAA;QAE5B,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ;YACE,OAAO,iBAAiB,CAAA;IAC5B,CAAC;AACH,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAe,MAAM,OAAO,CAAA;AAE5C,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,aAAa,CAAA;AAKzD,UAAU,gBAAgB;IACxB,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA4CrC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAwB,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,aAAa,CAAA;AAKzD,UAAU,gBAAgB;IACxB,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAiErC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback } from 'react';
2
+ import { useCallback, useMemo } from 'react';
3
3
  import { cn } from '../../../../scalars/lib/utils.js';
4
4
  import { getColumnTitle } from '../utils.js';
5
5
  import { HeaderNumberTd } from './header/header-number-td.js';
@@ -11,22 +11,37 @@ const TableHeader = ({ columns }) => {
11
11
  return;
12
12
  api.selection.toggleSelectAll();
13
13
  }, [config.allowRowSelection, api.selection]);
14
- const isAllRowsSelected = selectedRowIndexes.length === config.data.length;
15
- return (_jsx("thead", { children: _jsxs("tr", { className: cn('border-gray-300', !selectedRowIndexes.includes(0) && 'border-b'), children: [_jsx(HeaderNumberTd, { isAllRowsSelected: isAllRowsSelected, handleSelectAllRows: handleSelectAllRows }), columns.map((column, columnIndex) => {
16
- const cellContext = {
17
- rowIndex: -1, // the header row has no row
18
- row: undefined,
19
- column,
20
- columnIndex,
21
- tableConfig: config,
22
- };
23
- const style = {
24
- width: column.width ?? 'auto',
25
- minWidth: column.minWidth ?? 'auto',
26
- maxWidth: column.maxWidth ?? column.width ?? 'auto',
27
- };
28
- return (_jsx("th", { style: style, children: column.renderHeader(getColumnTitle(column), cellContext) }, column.field));
29
- })] }) }));
14
+ const isAllRowsSelected = selectedRowIndexes.length === api.getTotalRowsCount();
15
+ const columnHeaders = useMemo(() => {
16
+ return columns.map((column, columnIndex) => {
17
+ const cellContext = {
18
+ rowIndex: -1, // the header row has no row
19
+ row: undefined,
20
+ column,
21
+ columnIndex,
22
+ tableConfig: config,
23
+ };
24
+ const style = {
25
+ width: column.width ?? 'auto',
26
+ minWidth: column.minWidth ?? 'auto',
27
+ maxWidth: column.maxWidth ?? column.width ?? 'auto',
28
+ };
29
+ const onSort = () => {
30
+ if (!column.sortable)
31
+ return;
32
+ const tableState = api._getState();
33
+ if (tableState.sortState?.columnIndex === columnIndex) {
34
+ const nextDirection = tableState.sortState.direction === 'asc' ? 'desc' : null;
35
+ api.sortRows(columnIndex, nextDirection);
36
+ }
37
+ else {
38
+ api.sortRows(columnIndex, 'asc');
39
+ }
40
+ };
41
+ return (_jsx("th", { className: cn('group/header-cell', column.sortable ? 'cursor-pointer' : ''), style: style, onClick: onSort, children: column.renderHeader(getColumnTitle(column), cellContext) }, column.field));
42
+ });
43
+ }, [api, columns, config]);
44
+ return (_jsx("thead", { children: _jsxs("tr", { className: cn('border-gray-300', !selectedRowIndexes.includes(0) && 'border-b'), children: [_jsx(HeaderNumberTd, { isAllRowsSelected: isAllRowsSelected, handleSelectAllRows: handleSelectAllRows }), columnHeaders] }) }));
30
45
  };
31
46
  export { TableHeader };
32
47
  //# sourceMappingURL=header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"header.js","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAW,WAAW,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,kCAAkC,CAAA;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAM1E,MAAM,WAAW,GAAyB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACxD,MAAM,EACJ,MAAM,EACN,KAAK,EAAE,EAAE,kBAAkB,EAAE,EAC7B,GAAG,GACJ,GAAG,qBAAqB,EAAE,CAAA;IAE3B,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3C,IAAI,CAAC,MAAM,CAAC,iBAAiB;YAAE,OAAM;QAErC,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,CAAA;IACjC,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAA;IAE7C,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAA;IAE1E,OAAO,CACL,0BACE,cAAI,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,aACjF,KAAC,cAAc,IAAC,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,GAAI,EACjG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;oBACnC,MAAM,WAAW,GAAyB;wBACxC,QAAQ,EAAE,CAAC,CAAC,EAAE,4BAA4B;wBAC1C,GAAG,EAAE,SAAS;wBACd,MAAM;wBACN,WAAW;wBACX,WAAW,EAAE,MAAM;qBACpB,CAAA;oBAED,MAAM,KAAK,GAAwB;wBACjC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM;wBAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM;wBACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM;qBACpD,CAAA;oBAED,OAAO,CACL,aAAI,KAAK,EAAE,KAAK,YAEb,MAAM,CAAC,YAAa,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,IAFrC,MAAM,CAAC,KAAK,CAG9B,CACN,CAAA;gBACH,CAAC,CAAC,IACC,GACC,CACT,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"header.js","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAW,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,kCAAkC,CAAA;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AA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,WAAW,EAAE,CAAC;oBACtD,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;oBAC9E,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;gBAC1C,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;gBAClC,CAAC;YACH,CAAC,CAAA;YAED,OAAO,CACL,aACE,SAAS,EAAE,EAAE,CAAC,mBAAmB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3E,KAAK,EAAE,KAAK,EAEZ,OAAO,EAAE,MAAM,YAGd,MAAM,CAAC,YAAa,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,IAJrD,MAAM,CAAC,KAAK,CAKd,CACN,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IAE1B,OAAO,CACL,0BACE,cAAI,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,aACjF,KAAC,cAAc,IAAC,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,GAAI,EACjG,aAAa,IACX,GACC,CACT,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { DataType } from '../../types.js';
2
+ interface RenderRowProps<T extends DataType> {
3
+ item: T;
4
+ rowIndex: number;
5
+ emptyRow?: boolean;
6
+ }
7
+ declare const RenderRow: <T extends DataType>({ item, rowIndex, emptyRow }: RenderRowProps<T>) => import("react/jsx-runtime").JSX.Element;
8
+ export { RenderRow };
9
+ //# sourceMappingURL=render-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-row.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/rows/render-row.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAO9C,UAAU,cAAc,CAAC,CAAC,SAAS,QAAQ;IACzC,IAAI,EAAE,CAAC,CAAA;IACP,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,QAAA,MAAM,SAAS,GAAI,CAAC,SAAS,QAAQ,EAAE,8BAAsC,cAAc,CAAC,CAAC,CAAC,4CAsF7F,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ import { RowNumberCell } from '../cells/row-number-cell.js';
4
+ import { useInternalTableState } from '../table-provider/table-provider.js';
5
+ import { TableRow } from './table-row.js';
6
+ import { RenderCell } from '../cells/render-cell.js';
7
+ import { InformationCell } from '../cells/information-cell.js';
8
+ const RenderRow = ({ item, rowIndex, emptyRow = false }) => {
9
+ const { config, state: { selectedRowIndexes, selectedCellIndex }, api, } = useInternalTableState();
10
+ const { allowRowSelection } = config;
11
+ /**
12
+ * Create a handler for the click event on the table numbering cell
13
+ * This handler is used to select a row when the ctrl key is pressed
14
+ * or select single rows when the index is clicked
15
+ */
16
+ const createSelectRowOnClickHandler = useCallback((index) => (e) => {
17
+ if (!allowRowSelection)
18
+ return;
19
+ if (e.ctrlKey || e.metaKey) {
20
+ e.stopPropagation();
21
+ api.selection.toggleRow(index);
22
+ }
23
+ else if (e.shiftKey) {
24
+ return; // just let the row handle it
25
+ }
26
+ else {
27
+ api.selection.selectRow(index);
28
+ }
29
+ }, [allowRowSelection, api.selection]);
30
+ /**
31
+ * Create a handler for the click event on the table row
32
+ * This handler is used to select a row when the ctrl key is pressed
33
+ * in any other place other than the index cell or select a range of rows
34
+ * when the shift key is pressed
35
+ */
36
+ const createAddSelectedRowHandler = useCallback((index) => (e) => {
37
+ if (!allowRowSelection)
38
+ return;
39
+ if (e.ctrlKey || e.metaKey) {
40
+ api.selection.toggleRow(index);
41
+ }
42
+ else if (e.shiftKey) {
43
+ // Prevent text selection when shift key is pressed
44
+ document.getSelection()?.removeAllRanges();
45
+ api.selection.selectFromLastActiveRow(index);
46
+ }
47
+ }, [allowRowSelection, api.selection]);
48
+ /**
49
+ * Prevent text selection when shift key is pressed so that we
50
+ * can select a range of rows while keeping a good user experience
51
+ */
52
+ const handleMouseDown = useCallback((event) => {
53
+ if (event.shiftKey) {
54
+ document.getSelection()?.removeAllRanges();
55
+ }
56
+ }, []);
57
+ return (_jsxs(TableRow, { index: rowIndex, onClick: createAddSelectedRowHandler(rowIndex), onMouseDown: handleMouseDown, children: [_jsx(RowNumberCell, { index: rowIndex + 1, handleSelectRowOnClick: createSelectRowOnClickHandler(rowIndex), selected: selectedRowIndexes.includes(rowIndex) || selectedCellIndex?.row === rowIndex }), config.columns.map((column, columnIndex) => {
58
+ return (_jsx(RenderCell, { rowItem: item, column: column, rowIndex: rowIndex, columnIndex: columnIndex, renderEmptyCell: emptyRow }, column.field));
59
+ }), api.isEditable() && _jsx(InformationCell, {})] }));
60
+ };
61
+ export { RenderRow };
62
+ //# sourceMappingURL=render-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-row.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/rows/render-row.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,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AA"}
@@ -0,0 +1,7 @@
1
+ import type { SortDirection } from '../types.js';
2
+ interface SortIndicatorProps {
3
+ direction: SortDirection | null;
4
+ }
5
+ declare const SortIndicator: ({ direction }: SortIndicatorProps) => import("react/jsx-runtime").JSX.Element;
6
+ export { SortIndicator };
7
+ //# sourceMappingURL=sort-indicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-indicator.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/sort-indicator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,aAAa,GAAG,IAAI,CAAA;CAChC;AAED,QAAA,MAAM,aAAa,GAAI,eAAe,kBAAkB,4CA8BvD,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from '../../../../scalars/lib/utils.js';
3
+ const SortIndicator = ({ direction }) => {
4
+ return (_jsxs("svg", { className: cn('text-gray-500 group-hover/header-cell:text-gray-600', direction === 'desc' && '[&_path:first-child]:stroke-gray-900', direction === 'asc' && '[&_path:last-child]:stroke-gray-900'), width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M14 10.6667L11.3333 13.3334M11.3333 13.3334L8.66666 10.6667M11.3333 13.3334V2.66675", stroke: "currentcolor", strokeWidth: "1.33", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M2 5.33341L4.66667 2.66675M4.66667 2.66675L7.33333 5.33341M4.66667 2.66675V13.3334", stroke: "currentcolor", strokeWidth: "1.33", strokeLinecap: "round", strokeLinejoin: "round" })] }));
5
+ };
6
+ export { SortIndicator };
7
+ //# sourceMappingURL=sort-indicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-indicator.js","sourceRoot":"","sources":["../../../../../../src/ui/components/object-set-table/subcomponents/sort-indicator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kCAAkC,CAAA;AAOrD,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAsB,EAAE,EAAE;IAC1D,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,qDAAqD,EACrD,SAAS,KAAK,MAAM,IAAI,sCAAsC,EAC9D,SAAS,KAAK,KAAK,IAAI,qCAAqC,CAC7D,EACD,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,aAElC,eACE,CAAC,EAAC,qFAAqF,EACvF,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,MAAM,EAClB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,EACF,eACE,CAAC,EAAC,oFAAoF,EACtF,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,MAAM,EAClB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,IACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -20,6 +20,6 @@ interface TableProviderProps<T extends DataType = DataType> {
20
20
  tableRef: React.RefObject<HTMLTableElement>;
21
21
  }
22
22
  declare const TableProvider: <T extends DataType>({ children, config, tableRef }: TableProviderProps<T>) => import("react/jsx-runtime").JSX.Element;
23
- declare const useInternalTableState: <T extends DataType = any>() => TableContextValue<T>;
23
+ declare const useInternalTableState: <T extends DataType = unknown>() => TableContextValue<T>;
24
24
  export { TableProvider, useInternalTableState };
25
25
  //# sourceMappingURL=table-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-provider.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAsD,MAAM,OAAO,CAAA;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAG7E,UAAU,iBAAiB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IACvD,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACpB,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC3B,SAAS,EAAE,YAAY,CAAA;CACxB;AAID,UAAU,kBAAkB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IACxD,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;CAC5C;AAED,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,QAAQ,EAAE,gCAAgC,kBAAkB,CAAC,CAAC,CAAC,4CA8C/F,CAAA;AAED,QAAA,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,GAAG,GAAG,2BAMtD,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}
1
+ {"version":3,"file":"table-provider.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAsD,MAAM,OAAO,CAAA;AACzG,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAG7E,UAAU,iBAAiB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IACvD,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;IACpB,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC3B,SAAS,EAAE,YAAY,CAAA;CACxB;AAID,UAAU,kBAAkB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IACxD,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAC/B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;CAC5C;AAED,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,QAAQ,EAAE,gCAAgC,kBAAkB,CAAC,CAAC,CAAC,4CAgD/F,CAAA;AAED,QAAA,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,GAAG,OAAO,2BAM1D,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}
@@ -7,6 +7,7 @@ const TableContext = createContext(null);
7
7
  const TableProvider = ({ children, config, tableRef }) => {
8
8
  const [state, dispatch] = useReducer((tableReducer), {
9
9
  columns: config.columns,
10
+ defaultData: [...config.data],
10
11
  data: config.data,
11
12
  allowRowSelection: config.allowRowSelection ?? true,
12
13
  showRowNumbers: config.showRowNumbers ?? true,
@@ -14,6 +15,7 @@ const TableProvider = ({ children, config, tableRef }) => {
14
15
  lastSelectedRowIndex: null,
15
16
  selectedCellIndex: null,
16
17
  isCellEditMode: false,
18
+ sortState: null,
17
19
  });
18
20
  useEffect(() => {
19
21
  dispatch({ type: 'SET_DISPATCH', payload: dispatch });
@@ -1 +1 @@
1
- {"version":3,"file":"table-provider.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEzG,OAAO,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AASnD,MAAM,YAAY,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAclE,MAAM,aAAa,GAAG,CAAqB,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAyB,EAAE,EAAE;IAClG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,CAAA,YAAe,CAAA,EAAE;QACpD,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,IAAI;QACnD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;QAC7C,kBAAkB,EAAE,EAAE;QACtB,oBAAoB,EAAE,IAAI;QAC1B,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;IACvD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;IAChC,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAA;QACxB,SAAS,CAAC,OAAO,GAAG,MAAM,CAAA;IAC5B,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IAEnB,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,QAAQ,CAAI,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;QAClE,MAAM,SAAS,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;QAEnD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAA;QACnC,CAAC;QAED,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IACjC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE7B,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,KAAK;YACL,GAAG;YACH,SAAS;SACV,YAEA,QAAQ,GACa,CACzB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,GAA6B,EAAE;IAC3D,MAAM,OAAO,GAAG,UAAU,CAA8B,YAAY,CAAC,CAAA;IACrE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}
1
+ {"version":3,"file":"table-provider.js","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CA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,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,QAAQ,CAAI,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;QAClE,MAAM,SAAS,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;QAEnD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAA;QACnC,CAAC;QAED,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IACjC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE7B,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,KAAK;YACL,GAAG;YACH,SAAS;SACV,YAEA,QAAQ,GACa,CACzB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,GAAiC,EAAE;IAC/D,MAAM,OAAO,GAAG,UAAU,CAA8B,YAAY,CAAC,CAAA;IACrE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}
@@ -1,6 +1,7 @@
1
- import type { ColumnDef, DataType, TableCellIndex } from '../../types.js';
1
+ import type { ColumnDef, DataType, ObjectSetTableConfig, SortDirection, TableCellIndex } from '../../types.js';
2
2
  interface TableState<T extends DataType = DataType> {
3
3
  dispatch?: React.Dispatch<TableAction<T>>;
4
+ defaultData: T[];
4
5
  columns: ColumnDef[];
5
6
  data: T[];
6
7
  allowRowSelection: boolean;
@@ -9,6 +10,10 @@ interface TableState<T extends DataType = DataType> {
9
10
  lastSelectedRowIndex: number | null;
10
11
  selectedCellIndex: TableCellIndex | null;
11
12
  isCellEditMode: boolean;
13
+ sortState: {
14
+ columnIndex: number;
15
+ direction: SortDirection;
16
+ } | null;
12
17
  }
13
18
  type TableAction<T extends DataType = DataType> = {
14
19
  type: 'SET_DISPATCH';
@@ -33,8 +38,14 @@ type TableAction<T extends DataType = DataType> = {
33
38
  };
34
39
  } | {
35
40
  type: 'TOGGLE_SELECT_ALL_ROWS';
41
+ payload: {
42
+ totalRows?: number;
43
+ };
36
44
  } | {
37
45
  type: 'SELECT_ALL_ROWS';
46
+ payload: {
47
+ totalRows?: number;
48
+ };
38
49
  } | {
39
50
  type: 'SELECT_ROW_RANGE';
40
51
  payload: {
@@ -47,6 +58,13 @@ type TableAction<T extends DataType = DataType> = {
47
58
  } | {
48
59
  type: 'ENTER_CELL_EDIT_MODE';
49
60
  payload: TableCellIndex;
61
+ } | {
62
+ type: 'SORT_COLUMN';
63
+ payload: {
64
+ columnIndex: number;
65
+ direction: SortDirection | null;
66
+ tableConfig: ObjectSetTableConfig<T>;
67
+ };
50
68
  };
51
69
  declare const tableReducer: <T extends DataType>(state: TableState<T>, action: TableAction<T>) => TableState<T>;
52
70
  export { tableReducer };
@@ -1 +1 @@
1
- {"version":3,"file":"table-reducer.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEzE,UAAU,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAChD,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IAEzC,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,iBAAiB,EAAE,OAAO,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,kBAAkB,EAAE,MAAM,EAAE,CA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C,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CA8GpG,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"table-reducer.d.ts","sourceRoot":"","sources":["../../../../../../../src/ui/components/object-set-table/subcomponents/table-provider/table-reducer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE9G,UAAU,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAChD,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IAEzC,WAAW,EAAE,CAAC,EAAE,CAAA;IAEhB,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,iBAAiB,EAAE,OAAO,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAA;IAEnC,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAA;IACxC,cAAc,EAAE,OAAO,CAAA;IAEvB,SAAS,EAAE;QACT,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,aAAa,CAAA;KACzB,GAAG,IAAI,CAAA;CACT;AAED,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAC1C;IACE,IAAI,EAAE,cAAc,CAAA;IACpB,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;CACxC,GACD;IACE,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB,GACD;IACE,IAAI,EAAE,UAAU,CAAA;IAChB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E,WAAW,EAAE,UAAU,EAAE,CAAA"}
@@ -41,25 +41,26 @@ const tableReducer = (state, action) => {
41
41
  : [...state.selectedRowIndexes, action.payload.index],
42
42
  };
43
43
  }
44
- case 'TOGGLE_SELECT_ALL_ROWS':
44
+ case 'TOGGLE_SELECT_ALL_ROWS': {
45
+ const totalRows = action.payload.totalRows ?? state.data.length;
45
46
  return {
46
47
  ...state,
47
48
  selectedCellIndex: null,
48
49
  lastSelectedRowIndex: null,
49
- selectedRowIndexes: state.selectedRowIndexes.length === state.data.length
50
- ? []
51
- : Array.from({ length: state.data.length }, (_, index) => index),
50
+ selectedRowIndexes: state.selectedRowIndexes.length === totalRows ? [] : Array.from({ length: totalRows }, (_, index) => index),
52
51
  };
52
+ }
53
53
  case 'SELECT_ALL_ROWS': {
54
+ const totalRows = action.payload.totalRows ?? state.data.length;
54
55
  // if all the rows are already selected, do nothing
55
- if (state.selectedRowIndexes.length === state.data.length) {
56
+ if (state.selectedRowIndexes.length === totalRows) {
56
57
  return { ...state };
57
58
  }
58
59
  return {
59
60
  ...state,
60
61
  selectedCellIndex: null,
61
62
  lastSelectedRowIndex: null,
62
- selectedRowIndexes: Array.from({ length: state.data.length }, (_, index) => index),
63
+ selectedRowIndexes: Array.from({ length: totalRows }, (_, index) => index),
63
64
  };
64
65
  }
65
66
  case 'SELECT_ROW_RANGE': {
@@ -96,6 +97,48 @@ const tableReducer = (state, action) => {
96
97
  isCellEditMode: true,
97
98
  };
98
99
  }
100
+ case 'SORT_COLUMN': {
101
+ const column = state.columns[action.payload.columnIndex];
102
+ const sortDirection = action.payload.direction;
103
+ const sortFn = column.rowComparator;
104
+ if (sortDirection === null) {
105
+ // do not sort the data, just use the default unsorted data
106
+ return {
107
+ ...state,
108
+ data: [...state.defaultData],
109
+ sortState: null,
110
+ };
111
+ }
112
+ const data = [...state.defaultData].sort((rowA, rowB) => {
113
+ const columnValueA = column.valueGetter(rowA, {
114
+ row: rowA,
115
+ rowIndex: -1,
116
+ column,
117
+ columnIndex: action.payload.columnIndex,
118
+ tableConfig: action.payload.tableConfig,
119
+ });
120
+ const columnValueB = column.valueGetter(rowB, {
121
+ row: rowB,
122
+ rowIndex: -1,
123
+ column,
124
+ columnIndex: action.payload.columnIndex,
125
+ tableConfig: action.payload.tableConfig,
126
+ });
127
+ return sortFn(columnValueA, columnValueB, {
128
+ tableConfig: action.payload.tableConfig,
129
+ columnDef: column,
130
+ data: state.data,
131
+ });
132
+ });
133
+ return {
134
+ ...state,
135
+ data: sortDirection === 'asc' ? data : data.reverse(),
136
+ sortState: {
137
+ columnIndex: action.payload.columnIndex,
138
+ direction: sortDirection,
139
+ },
140
+ };
141
+ }
99
142
  default:
100
143
  return state;
101
144
  }