@dmsi/wedgekit-react 0.0.214 → 0.0.216

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 (53) hide show
  1. package/dist/{chunk-UKSJPFN2.js → chunk-3M23BFB4.js} +3 -3
  2. package/dist/{chunk-2WRRRPEB.js → chunk-BHFIS4ZV.js} +1 -1
  3. package/dist/{chunk-JITZWSPR.js → chunk-NA3ODQCN.js} +2 -2
  4. package/dist/{chunk-33W2KSCB.js → chunk-OC6RTDZT.js} +7 -6
  5. package/dist/{chunk-ERW3AMED.js → chunk-QHHNFGEX.js} +1 -1
  6. package/dist/{chunk-CZ55LUFC.js → chunk-SC24WU65.js} +8 -8
  7. package/dist/{chunk-NIHZMIOL.js → chunk-VP36B2MM.js} +1 -1
  8. package/dist/{chunk-E6Y7ZHQX.js → chunk-ZU2K7BD3.js} +36 -22
  9. package/dist/components/DataGridCell.js +9 -9
  10. package/dist/components/DateInput.js +7 -7
  11. package/dist/components/DateRangeInput.js +7 -7
  12. package/dist/components/FilterGroup.js +5 -5
  13. package/dist/components/Input.js +2 -2
  14. package/dist/components/Menu.js +3 -3
  15. package/dist/components/MenuOption.js +3 -3
  16. package/dist/components/MobileDataGrid.js +3 -3
  17. package/dist/components/Modal.js +5 -5
  18. package/dist/components/ModalButtons.js +2 -2
  19. package/dist/components/ModalHeader.js +2 -2
  20. package/dist/components/NavigationTab.js +2 -2
  21. package/dist/components/NavigationTabs.js +2 -2
  22. package/dist/components/NestedMenu.js +3 -3
  23. package/dist/components/Notification.js +3 -3
  24. package/dist/components/OptionPill.js +2 -2
  25. package/dist/components/PDFViewer.js +7 -7
  26. package/dist/components/Password.js +2 -2
  27. package/dist/components/ProjectBar.js +1 -1
  28. package/dist/components/Search.js +3 -3
  29. package/dist/components/Select.cjs +6 -5
  30. package/dist/components/Select.js +3 -3
  31. package/dist/components/Stepper.js +5 -5
  32. package/dist/components/Time.js +3 -3
  33. package/dist/components/Toast.js +3 -3
  34. package/dist/components/Upload.js +3 -3
  35. package/dist/components/index.cjs +94 -62
  36. package/dist/components/index.css +3 -0
  37. package/dist/components/index.js +74 -52
  38. package/dist/components/useMenuSystem.js +2 -2
  39. package/dist/hooks/index.cjs +30 -21
  40. package/dist/hooks/index.js +1 -1
  41. package/dist/index.css +3 -0
  42. package/package.json +1 -1
  43. package/src/components/DataGrid/PinnedColumns.tsx +1 -1
  44. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +16 -6
  45. package/src/components/DataGrid/index.tsx +60 -30
  46. package/src/components/DataGrid/types.ts +2 -0
  47. package/src/components/Select.tsx +1 -1
  48. package/src/hooks/useTableLayout.ts +44 -28
  49. package/dist/{chunk-ED7FXZRX.js → chunk-BW2MWMVM.js} +3 -3
  50. package/dist/{chunk-7W4I2NK3.js → chunk-GW7OVMMC.js} +3 -3
  51. package/dist/{chunk-FYW64H7N.js → chunk-JFPRYMID.js} +3 -3
  52. package/dist/{chunk-A5ROZWIH.js → chunk-R4H6D4SZ.js} +3 -3
  53. package/dist/{chunk-47KTDBGA.js → chunk-T7UCZWWK.js} +3 -3
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  import {
3
3
  InputBase
4
- } from "../chunk-7W4I2NK3.js";
5
- import "../chunk-5UH6QUFB.js";
4
+ } from "../chunk-GW7OVMMC.js";
6
5
  import "../chunk-CJVTFYI4.js";
7
- import {
8
- Button
9
- } from "../chunk-SK742QNF.js";
6
+ import "../chunk-5UH6QUFB.js";
10
7
  import {
11
8
  Icon
12
9
  } from "../chunk-UAPWR2KE.js";
10
+ import {
11
+ Button
12
+ } from "../chunk-SK742QNF.js";
13
13
  import {
14
14
  componentGap
15
15
  } from "../chunk-RDLEIAQU.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  findDocumentRoot
3
3
  } from "../chunk-VXWSAIB5.js";
4
- import "../chunk-T3F37S6Z.js";
5
4
  import {
6
5
  InputBase
7
- } from "../chunk-7W4I2NK3.js";
8
- import "../chunk-5UH6QUFB.js";
6
+ } from "../chunk-GW7OVMMC.js";
9
7
  import "../chunk-CJVTFYI4.js";
8
+ import "../chunk-T3F37S6Z.js";
9
+ import "../chunk-5UH6QUFB.js";
10
10
  import {
11
11
  Stack
12
12
  } from "../chunk-BOWQUDUU.js";
@@ -5,12 +5,12 @@ import {
5
5
  import {
6
6
  Paragraph
7
7
  } from "../chunk-CJELWEO2.js";
8
- import {
9
- Button
10
- } from "../chunk-SK742QNF.js";
11
8
  import {
12
9
  Icon
13
10
  } from "../chunk-UAPWR2KE.js";
11
+ import {
12
+ Button
13
+ } from "../chunk-SK742QNF.js";
14
14
  import {
15
15
  componentGap,
16
16
  componentPadding,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Paragraph
3
3
  } from "../chunk-CJELWEO2.js";
4
- import {
5
- Button
6
- } from "../chunk-SK742QNF.js";
7
4
  import {
8
5
  Icon
9
6
  } from "../chunk-UAPWR2KE.js";
7
+ import {
8
+ Button
9
+ } from "../chunk-SK742QNF.js";
10
10
  import {
11
11
  componentGap
12
12
  } from "../chunk-RDLEIAQU.js";
@@ -515,38 +515,47 @@ var import_react5 = require("react");
515
515
  function useTableLayout(initialColumns, key) {
516
516
  const [columns, setColumns] = (0, import_react5.useState)(initialColumns);
517
517
  const [isReady, setIsReady] = (0, import_react5.useState)(false);
518
- const [layoutSignal, setLayoutSignal] = (0, import_react5.useState)(0);
518
+ const renderCountRef = (0, import_react5.useRef)(0);
519
+ const handleSaveLayout = (0, import_react5.useCallback)(
520
+ (setter, _internal) => {
521
+ if (!isReady && !_internal || !key) return;
522
+ setColumns((prevColumns) => {
523
+ const newColumns = typeof setter === "function" ? setter(prevColumns) : setter;
524
+ if (JSON.stringify(newColumns) === JSON.stringify(prevColumns) && !_internal)
525
+ return prevColumns;
526
+ localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
527
+ return newColumns;
528
+ });
529
+ },
530
+ [isReady, key]
531
+ );
519
532
  (0, import_react5.useEffect)(() => {
520
533
  if (!key) return setIsReady(true);
534
+ if (renderCountRef.current > 1) {
535
+ throw new Error(
536
+ `useTableLayout should only be called once per component render cycle.
537
+ ${renderCountRef.current} Renders detected.
538
+ Check dependency stability`
539
+ );
540
+ }
541
+ renderCountRef.current += 1;
521
542
  const savedLayout = localStorage.getItem(`${key}-tableLayout`);
522
543
  if (savedLayout) {
523
- setColumns(
544
+ handleSaveLayout(
524
545
  mergeObjectArrays(
525
546
  initialColumns,
526
547
  JSON.parse(savedLayout)
527
- )
548
+ ),
549
+ true
528
550
  );
529
551
  }
530
552
  if (!savedLayout) handleSaveLayout(initialColumns, true);
531
- setLayoutSignal((prev) => prev + 1);
532
553
  setIsReady(true);
533
- }, []);
534
- const handleSaveLayout = (0, import_react5.useCallback)(
535
- (setter, _internal) => {
536
- if (!isReady && !_internal) return null;
537
- const newColumns = typeof setter === "function" ? setter(columns) : setter;
538
- if (JSON.stringify(newColumns) === JSON.stringify(columns) && !_internal)
539
- return null;
540
- if (key) {
541
- localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
542
- }
543
- setColumns(newColumns);
544
- setLayoutSignal((prev) => prev + 1);
545
- return newColumns;
546
- },
547
- [columns, isReady, key]
548
- );
549
- return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
554
+ return () => {
555
+ renderCountRef.current = 0;
556
+ };
557
+ }, [handleSaveLayout, initialColumns, key]);
558
+ return { columns, setColumns: handleSaveLayout, isReady };
550
559
  }
551
560
 
552
561
  // src/components/MenuOption.tsx
@@ -2338,6 +2347,7 @@ function TableBodyRow({
2338
2347
  "tr",
2339
2348
  {
2340
2349
  className: (0, import_clsx10.default)(
2350
+ "min-h-10",
2341
2351
  "transition-colors hover:bg-background-action-secondary-hover",
2342
2352
  row.getIsSelected() && "!bg-background-action-secondary-hover",
2343
2353
  isError && "!bg-background-action-critical-secondary-hover",
@@ -2357,21 +2367,28 @@ function TableBodyRow({
2357
2367
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { style: { display: "flex", width: virtualPaddingLeft } })
2358
2368
  ) : null,
2359
2369
  columns.map((column) => {
2360
- var _a2;
2370
+ var _a2, _b, _c, _d;
2361
2371
  const cell = locked ? column : visibleCells[column.index];
2362
2372
  if (!cell) {
2363
2373
  return;
2364
2374
  }
2375
+ const cellAlignment = (_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.align;
2365
2376
  const cellValue = cell.getValue();
2366
- return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.default.Fragment, { children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2377
+ return ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.default.Fragment, { children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2367
2378
  CellElement,
2368
2379
  {
2369
2380
  id: id ? `${id}-row-${row.id}-cell-${cell.id}` : void 0,
2370
2381
  testid: testid ? `${testid}-row-${row.id}-cell-${cell.id}` : void 0,
2371
2382
  cell,
2372
- className: (0, import_clsx10.default)({
2373
- "justify-end": typeof cellValue === "number"
2374
- }),
2383
+ className: (0, import_clsx10.default)(
2384
+ cellAlignment ? {
2385
+ "justify-start": cellAlignment === "left",
2386
+ "justify-end": cellAlignment === "right"
2387
+ } : {
2388
+ "justify-end": typeof cellValue === "number"
2389
+ }
2390
+ ),
2391
+ width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`,
2375
2392
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2376
2393
  Tooltip,
2377
2394
  {
@@ -2810,7 +2827,7 @@ function PinnedColumns(_a) {
2810
2827
  testid: pinnedTestId
2811
2828
  }, props), {
2812
2829
  table,
2813
- locked: true,
2830
+ locked: !enableColumnSelector,
2814
2831
  pinDirection
2815
2832
  })
2816
2833
  )
@@ -2828,6 +2845,7 @@ var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
2828
2845
  var NO_RESULTS_HEIGHT = "h-[185px]";
2829
2846
  function DataGrid({
2830
2847
  id,
2848
+ rowIdAccessor,
2831
2849
  testid,
2832
2850
  data,
2833
2851
  columns,
@@ -2856,11 +2874,7 @@ function DataGrid({
2856
2874
  const [localSorting, setLocalSorting] = (0, import_react16.useState)([]);
2857
2875
  const [localColumnFilters, setLocalColumnFilters] = (0, import_react16.useState)([]);
2858
2876
  const [localRowSelection, setLocalRowSelection] = (0, import_react16.useState)({});
2859
- const {
2860
- columns: tableColumns,
2861
- setColumns: setTableColumns,
2862
- layoutSignal
2863
- } = useTableLayout(columns, id != null ? id : testid);
2877
+ const { columns: tableColumns, setColumns: setTableColumns } = useTableLayout(columns, id != null ? id : testid);
2864
2878
  const [columnOrder, setColumnOrder] = (0, import_react16.useState)(
2865
2879
  tableColumns.map((c) => c.id)
2866
2880
  );
@@ -2872,10 +2886,23 @@ function DataGrid({
2872
2886
  })
2873
2887
  )
2874
2888
  );
2889
+ const resetColumnVisibility = (0, import_react16.useCallback)(
2890
+ (updateOrder) => {
2891
+ setColumnVisibility(
2892
+ Object.fromEntries(
2893
+ tableColumns.filter((column) => !!column.id).map((column) => {
2894
+ var _a2, _b2;
2895
+ return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
2896
+ })
2897
+ )
2898
+ );
2899
+ if (updateOrder) setColumnOrder(tableColumns.map((c) => c.id));
2900
+ },
2901
+ [tableColumns]
2902
+ );
2875
2903
  (0, import_react16.useEffect)(() => {
2876
- setColumnOrder(tableColumns.map((c) => c.id));
2877
- resetColumnVisibility();
2878
- }, [layoutSignal]);
2904
+ resetColumnVisibility(true);
2905
+ }, [resetColumnVisibility]);
2879
2906
  const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
2880
2907
  const setSortingState = pagination ? (updaterOrValue) => {
2881
2908
  const value = typeof updaterOrValue === "function" ? updaterOrValue(
@@ -2888,11 +2915,21 @@ function DataGrid({
2888
2915
  const value = typeof updaterOrValue === "function" ? updaterOrValue(externalColumnFilters != null ? externalColumnFilters : []) : updaterOrValue;
2889
2916
  (onColumnFiltersChange != null ? onColumnFiltersChange : setLocalColumnFilters)(value);
2890
2917
  } : setLocalColumnFilters;
2891
- const rowSelection = pagination ? externalRowSelection != null ? externalRowSelection : localRowSelection : localRowSelection;
2892
- const setRowSelection = pagination ? (updaterOrValue) => {
2893
- const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
2894
- (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
2895
- } : setLocalRowSelection;
2918
+ const rowSelection = externalRowSelection != null ? externalRowSelection : localRowSelection;
2919
+ const setRowSelection = (0, import_react16.useCallback)(
2920
+ (updaterOrValue) => {
2921
+ if (pagination) {
2922
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
2923
+ (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
2924
+ } else if (externalRowSelection && onRowSelectionChange) {
2925
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
2926
+ onRowSelectionChange(value);
2927
+ } else {
2928
+ setLocalRowSelection(updaterOrValue);
2929
+ }
2930
+ },
2931
+ [externalRowSelection, onRowSelectionChange, pagination]
2932
+ );
2896
2933
  const dndId = (0, import_react16.useId)();
2897
2934
  const containerRef = import_react16.default.useRef(null);
2898
2935
  const toggleColumnVisibility = (0, import_react16.useCallback)(
@@ -2909,16 +2946,6 @@ function DataGrid({
2909
2946
  },
2910
2947
  [setTableColumns]
2911
2948
  );
2912
- const resetColumnVisibility = (0, import_react16.useCallback)(() => {
2913
- setColumnVisibility(
2914
- Object.fromEntries(
2915
- tableColumns.filter((column) => !!column.id).map((column) => {
2916
- var _a2, _b2;
2917
- return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
2918
- })
2919
- )
2920
- );
2921
- }, [tableColumns]);
2922
2949
  const table = (0, import_react_table3.useReactTable)({
2923
2950
  columns: tableColumns,
2924
2951
  data,
@@ -2926,7 +2953,7 @@ function DataGrid({
2926
2953
  getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
2927
2954
  getFilteredRowModel: (0, import_react_table3.getFilteredRowModel)(),
2928
2955
  columnResizeMode: "onChange",
2929
- getRowId: (row, index) => {
2956
+ getRowId: rowIdAccessor ? (row) => String(row[rowIdAccessor]) : (row, index) => {
2930
2957
  var _a2;
2931
2958
  return String((_a2 = row.id) != null ? _a2 : index + 1);
2932
2959
  },
@@ -3095,38 +3122,42 @@ function DataGrid({
3095
3122
  )
3096
3123
  ) : null,
3097
3124
  virtualColumns.map((virtualColumn) => {
3098
- var _a2, _b2, _c2;
3125
+ var _a2, _b2, _c2, _d2, _e2;
3099
3126
  const header = headerGroup.headers[virtualColumn.index];
3100
3127
  if (!header) {
3101
3128
  return;
3102
3129
  }
3103
3130
  if (typeof header.column.columnDef.header === "string") {
3104
3131
  const cellValue = (_a2 = table.getRowModel().rows[0]) == null ? void 0 : _a2.getValue(header.column.id);
3132
+ const cellAlignment = ((_c2 = (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.align) != null ? _c2 : cellValue === "number") ? "right" : "left";
3105
3133
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3106
3134
  DraggableCellHeader,
3107
3135
  {
3108
3136
  id: id ? `${id}-header-${header.id}` : void 0,
3109
3137
  testid: testid ? `${testid}-header-${header.id}` : void 0,
3110
3138
  header,
3111
- locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
3139
+ locked: (_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.locked,
3112
3140
  center: centerHeader,
3113
3141
  className: (0, import_clsx13.default)(
3114
3142
  header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
3115
3143
  "group",
3116
- {
3144
+ cellAlignment ? {
3145
+ "justify-start": cellAlignment === "left",
3146
+ "justify-end": cellAlignment === "right"
3147
+ } : {
3117
3148
  "justify-end": typeof cellValue === "number"
3118
3149
  }
3119
3150
  ),
3120
3151
  useMenuDefaultMinWidth,
3121
3152
  children: [
3122
- typeof cellValue !== "number" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
3153
+ cellAlignment === "left" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
3123
3154
  getSortIcon(header.column.getIsSorted()),
3124
3155
  !header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
3125
3156
  header.column.getNextSortingOrder(),
3126
3157
  true
3127
3158
  ),
3128
3159
  header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
3129
- typeof cellValue === "number" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
3160
+ cellAlignment === "right" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
3130
3161
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3131
3162
  "div",
3132
3163
  {
@@ -3150,7 +3181,7 @@ function DataGrid({
3150
3181
  header.id
3151
3182
  );
3152
3183
  }
3153
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: ((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3184
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: ((_e2 = header.column.columnDef.meta) == null ? void 0 : _e2.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3154
3185
  DataGridCell,
3155
3186
  {
3156
3187
  id: id ? `${id}-header-${header.id}` : void 0,
@@ -3387,17 +3418,18 @@ var Select = (_a) => {
3387
3418
  "displayValue",
3388
3419
  "value"
3389
3420
  ]);
3421
+ var _a2;
3390
3422
  const inputRef = (0, import_react17.useRef)(null);
3391
3423
  const inputContainerRef = (0, import_react17.useRef)(null);
3392
3424
  const preventFocusOnInitialRender = (0, import_react17.useRef)(true);
3393
3425
  const [show, setShow] = (0, import_react17.useState)(false);
3394
3426
  (0, import_react17.useEffect)(() => {
3395
- var _a2;
3427
+ var _a3;
3396
3428
  if (preventFocusOnInitialRender.current) {
3397
3429
  preventFocusOnInitialRender.current = false;
3398
3430
  return;
3399
3431
  }
3400
- (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
3432
+ (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
3401
3433
  }, [value]);
3402
3434
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
3403
3435
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -3440,11 +3472,11 @@ var Select = (_a) => {
3440
3472
  removeRoundness,
3441
3473
  focus: show,
3442
3474
  onChange: (e) => {
3443
- var _a2;
3444
- return (_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
3475
+ var _a3;
3476
+ return (_a3 = props.onChange) == null ? void 0 : _a3.call(props, e);
3445
3477
  }
3446
3478
  }, props), {
3447
- value: displayValue != null ? displayValue : value
3479
+ value: (_a2 = displayValue != null ? displayValue : value) != null ? _a2 : props.onChange ? "" : void 0
3448
3480
  })
3449
3481
  ),
3450
3482
  renderMenu ? renderMenu({
@@ -796,6 +796,9 @@
796
796
  .min-h-6 {
797
797
  min-height: calc(var(--spacing) * 6);
798
798
  }
799
+ .min-h-10 {
800
+ min-height: calc(var(--spacing) * 10);
801
+ }
799
802
  .min-h-19 {
800
803
  min-height: calc(var(--spacing) * 19);
801
804
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-3WNXMCZV.js";
4
4
  import {
5
5
  Select
6
- } from "../chunk-33W2KSCB.js";
6
+ } from "../chunk-OC6RTDZT.js";
7
7
  import {
8
8
  Checkbox
9
9
  } from "../chunk-E3UOI2D2.js";
@@ -12,31 +12,31 @@ import {
12
12
  DataGridCell,
13
13
  DragAlongCell,
14
14
  DraggableCellHeader
15
- } from "../chunk-CZ55LUFC.js";
16
- import {
17
- Menu
18
- } from "../chunk-JITZWSPR.js";
19
- import "../chunk-NIHZMIOL.js";
15
+ } from "../chunk-SC24WU65.js";
20
16
  import {
21
17
  MenuOption
22
- } from "../chunk-ERW3AMED.js";
18
+ } from "../chunk-QHHNFGEX.js";
19
+ import {
20
+ Menu
21
+ } from "../chunk-NA3ODQCN.js";
22
+ import "../chunk-VP36B2MM.js";
23
23
  import {
24
24
  useInfiniteScroll,
25
25
  useTableLayout
26
- } from "../chunk-E6Y7ZHQX.js";
26
+ } from "../chunk-ZU2K7BD3.js";
27
+ import "../chunk-WVUIIBRR.js";
27
28
  import "../chunk-VXWSAIB5.js";
28
- import "../chunk-T3F37S6Z.js";
29
29
  import {
30
30
  Search
31
- } from "../chunk-2WRRRPEB.js";
31
+ } from "../chunk-BHFIS4ZV.js";
32
32
  import {
33
33
  Input
34
- } from "../chunk-7W4I2NK3.js";
35
- import "../chunk-5UH6QUFB.js";
34
+ } from "../chunk-GW7OVMMC.js";
36
35
  import {
37
36
  Label
38
37
  } from "../chunk-CJVTFYI4.js";
39
- import "../chunk-WVUIIBRR.js";
38
+ import "../chunk-T3F37S6Z.js";
39
+ import "../chunk-5UH6QUFB.js";
40
40
  import {
41
41
  Subheader
42
42
  } from "../chunk-KGVKHWUK.js";
@@ -50,12 +50,12 @@ import {
50
50
  import {
51
51
  Paragraph
52
52
  } from "../chunk-CJELWEO2.js";
53
- import {
54
- Button
55
- } from "../chunk-SK742QNF.js";
56
53
  import {
57
54
  Icon
58
55
  } from "../chunk-UAPWR2KE.js";
56
+ import {
57
+ Button
58
+ } from "../chunk-SK742QNF.js";
59
59
  import {
60
60
  componentGap,
61
61
  componentPadding
@@ -153,6 +153,7 @@ function TableBodyRow({
153
153
  "tr",
154
154
  {
155
155
  className: clsx2(
156
+ "min-h-10",
156
157
  "transition-colors hover:bg-background-action-secondary-hover",
157
158
  row.getIsSelected() && "!bg-background-action-secondary-hover",
158
159
  isError && "!bg-background-action-critical-secondary-hover",
@@ -172,21 +173,28 @@ function TableBodyRow({
172
173
  /* @__PURE__ */ jsx2("td", { style: { display: "flex", width: virtualPaddingLeft } })
173
174
  ) : null,
174
175
  columns.map((column) => {
175
- var _a2;
176
+ var _a2, _b, _c, _d;
176
177
  const cell = locked ? column : visibleCells[column.index];
177
178
  if (!cell) {
178
179
  return;
179
180
  }
181
+ const cellAlignment = (_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.align;
180
182
  const cellValue = cell.getValue();
181
- return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ jsx2(React.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ jsx2(
183
+ return ((_b = cell.column.columnDef.meta) == null ? void 0 : _b.useCustomRenderer) ? /* @__PURE__ */ jsx2(React.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ jsx2(
182
184
  CellElement,
183
185
  {
184
186
  id: id ? `${id}-row-${row.id}-cell-${cell.id}` : void 0,
185
187
  testid: testid ? `${testid}-row-${row.id}-cell-${cell.id}` : void 0,
186
188
  cell,
187
- className: clsx2({
188
- "justify-end": typeof cellValue === "number"
189
- }),
189
+ className: clsx2(
190
+ cellAlignment ? {
191
+ "justify-start": cellAlignment === "left",
192
+ "justify-end": cellAlignment === "right"
193
+ } : {
194
+ "justify-end": typeof cellValue === "number"
195
+ }
196
+ ),
197
+ width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`,
190
198
  children: /* @__PURE__ */ jsx2(
191
199
  Tooltip,
192
200
  {
@@ -625,7 +633,7 @@ function PinnedColumns(_a) {
625
633
  testid: pinnedTestId
626
634
  }, props), {
627
635
  table,
628
- locked: true,
636
+ locked: !enableColumnSelector,
629
637
  pinDirection
630
638
  })
631
639
  )
@@ -643,6 +651,7 @@ var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
643
651
  var NO_RESULTS_HEIGHT = "h-[185px]";
644
652
  function DataGrid({
645
653
  id,
654
+ rowIdAccessor,
646
655
  testid,
647
656
  data,
648
657
  columns,
@@ -671,11 +680,7 @@ function DataGrid({
671
680
  const [localSorting, setLocalSorting] = useState3([]);
672
681
  const [localColumnFilters, setLocalColumnFilters] = useState3([]);
673
682
  const [localRowSelection, setLocalRowSelection] = useState3({});
674
- const {
675
- columns: tableColumns,
676
- setColumns: setTableColumns,
677
- layoutSignal
678
- } = useTableLayout(columns, id != null ? id : testid);
683
+ const { columns: tableColumns, setColumns: setTableColumns } = useTableLayout(columns, id != null ? id : testid);
679
684
  const [columnOrder, setColumnOrder] = useState3(
680
685
  tableColumns.map((c) => c.id)
681
686
  );
@@ -687,10 +692,23 @@ function DataGrid({
687
692
  })
688
693
  )
689
694
  );
695
+ const resetColumnVisibility = useCallback(
696
+ (updateOrder) => {
697
+ setColumnVisibility(
698
+ Object.fromEntries(
699
+ tableColumns.filter((column) => !!column.id).map((column) => {
700
+ var _a2, _b2;
701
+ return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
702
+ })
703
+ )
704
+ );
705
+ if (updateOrder) setColumnOrder(tableColumns.map((c) => c.id));
706
+ },
707
+ [tableColumns]
708
+ );
690
709
  useEffect(() => {
691
- setColumnOrder(tableColumns.map((c) => c.id));
692
- resetColumnVisibility();
693
- }, [layoutSignal]);
710
+ resetColumnVisibility(true);
711
+ }, [resetColumnVisibility]);
694
712
  const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
695
713
  const setSortingState = pagination ? (updaterOrValue) => {
696
714
  const value = typeof updaterOrValue === "function" ? updaterOrValue(
@@ -703,11 +721,21 @@ function DataGrid({
703
721
  const value = typeof updaterOrValue === "function" ? updaterOrValue(externalColumnFilters != null ? externalColumnFilters : []) : updaterOrValue;
704
722
  (onColumnFiltersChange != null ? onColumnFiltersChange : setLocalColumnFilters)(value);
705
723
  } : setLocalColumnFilters;
706
- const rowSelection = pagination ? externalRowSelection != null ? externalRowSelection : localRowSelection : localRowSelection;
707
- const setRowSelection = pagination ? (updaterOrValue) => {
708
- const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
709
- (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
710
- } : setLocalRowSelection;
724
+ const rowSelection = externalRowSelection != null ? externalRowSelection : localRowSelection;
725
+ const setRowSelection = useCallback(
726
+ (updaterOrValue) => {
727
+ if (pagination) {
728
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
729
+ (onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
730
+ } else if (externalRowSelection && onRowSelectionChange) {
731
+ const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
732
+ onRowSelectionChange(value);
733
+ } else {
734
+ setLocalRowSelection(updaterOrValue);
735
+ }
736
+ },
737
+ [externalRowSelection, onRowSelectionChange, pagination]
738
+ );
711
739
  const dndId = useId();
712
740
  const containerRef = React3.useRef(null);
713
741
  const toggleColumnVisibility = useCallback(
@@ -724,16 +752,6 @@ function DataGrid({
724
752
  },
725
753
  [setTableColumns]
726
754
  );
727
- const resetColumnVisibility = useCallback(() => {
728
- setColumnVisibility(
729
- Object.fromEntries(
730
- tableColumns.filter((column) => !!column.id).map((column) => {
731
- var _a2, _b2;
732
- return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
733
- })
734
- )
735
- );
736
- }, [tableColumns]);
737
755
  const table = useReactTable({
738
756
  columns: tableColumns,
739
757
  data,
@@ -741,7 +759,7 @@ function DataGrid({
741
759
  getSortedRowModel: getSortedRowModel(),
742
760
  getFilteredRowModel: getFilteredRowModel(),
743
761
  columnResizeMode: "onChange",
744
- getRowId: (row, index) => {
762
+ getRowId: rowIdAccessor ? (row) => String(row[rowIdAccessor]) : (row, index) => {
745
763
  var _a2;
746
764
  return String((_a2 = row.id) != null ? _a2 : index + 1);
747
765
  },
@@ -910,38 +928,42 @@ function DataGrid({
910
928
  )
911
929
  ) : null,
912
930
  virtualColumns.map((virtualColumn) => {
913
- var _a2, _b2, _c2;
931
+ var _a2, _b2, _c2, _d2, _e2;
914
932
  const header = headerGroup.headers[virtualColumn.index];
915
933
  if (!header) {
916
934
  return;
917
935
  }
918
936
  if (typeof header.column.columnDef.header === "string") {
919
937
  const cellValue = (_a2 = table.getRowModel().rows[0]) == null ? void 0 : _a2.getValue(header.column.id);
938
+ const cellAlignment = ((_c2 = (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.align) != null ? _c2 : cellValue === "number") ? "right" : "left";
920
939
  return /* @__PURE__ */ jsxs5(
921
940
  DraggableCellHeader,
922
941
  {
923
942
  id: id ? `${id}-header-${header.id}` : void 0,
924
943
  testid: testid ? `${testid}-header-${header.id}` : void 0,
925
944
  header,
926
- locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
945
+ locked: (_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.locked,
927
946
  center: centerHeader,
928
947
  className: clsx5(
929
948
  header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
930
949
  "group",
931
- {
950
+ cellAlignment ? {
951
+ "justify-start": cellAlignment === "left",
952
+ "justify-end": cellAlignment === "right"
953
+ } : {
932
954
  "justify-end": typeof cellValue === "number"
933
955
  }
934
956
  ),
935
957
  useMenuDefaultMinWidth,
936
958
  children: [
937
- typeof cellValue !== "number" && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.columnDef.header }),
959
+ cellAlignment === "left" && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.columnDef.header }),
938
960
  getSortIcon(header.column.getIsSorted()),
939
961
  !header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
940
962
  header.column.getNextSortingOrder(),
941
963
  true
942
964
  ),
943
965
  header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
944
- typeof cellValue === "number" && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.columnDef.header }),
966
+ cellAlignment === "right" && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.columnDef.header }),
945
967
  /* @__PURE__ */ jsx8(
946
968
  "div",
947
969
  {
@@ -965,7 +987,7 @@ function DataGrid({
965
987
  header.id
966
988
  );
967
989
  }
968
- return /* @__PURE__ */ jsx8(React3.Fragment, { children: ((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.checkbox) ? /* @__PURE__ */ jsx8(
990
+ return /* @__PURE__ */ jsx8(React3.Fragment, { children: ((_e2 = header.column.columnDef.meta) == null ? void 0 : _e2.checkbox) ? /* @__PURE__ */ jsx8(
969
991
  DataGridCell,
970
992
  {
971
993
  id: id ? `${id}-header-${header.id}` : void 0,