@dmsi/wedgekit-react 0.0.207 → 0.0.209

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 (45) hide show
  1. package/dist/{chunk-WNQ53SVY.js → chunk-E6Y7ZHQX.js} +45 -1
  2. package/dist/{chunk-WXHRJSDG.js → chunk-ERW3AMED.js} +1 -1
  3. package/dist/{chunk-2JRZCC2K.js → chunk-JITZWSPR.js} +3 -3
  4. package/dist/{chunk-WE55TGZZ.js → chunk-NIHZMIOL.js} +1 -1
  5. package/dist/{chunk-RXPS5GVE.js → chunk-Q3TNALWH.js} +17 -26
  6. package/dist/{chunk-M3433XEJ.js → chunk-T3F37S6Z.js} +15 -1
  7. package/dist/{chunk-2B5T4NCT.js → chunk-UKSJPFN2.js} +2 -2
  8. package/dist/components/DataGridCell.cjs +814 -824
  9. package/dist/components/DataGridCell.js +7 -6
  10. package/dist/components/DateInput.cjs +23 -23
  11. package/dist/components/DateInput.js +4 -4
  12. package/dist/components/DateRangeInput.cjs +23 -23
  13. package/dist/components/DateRangeInput.js +4 -4
  14. package/dist/components/Menu.cjs +38 -35
  15. package/dist/components/Menu.js +6 -4
  16. package/dist/components/MenuOption.cjs +7 -4
  17. package/dist/components/MenuOption.js +5 -2
  18. package/dist/components/Modal.cjs +15 -12
  19. package/dist/components/Modal.js +5 -3
  20. package/dist/components/NestedMenu.cjs +9 -6
  21. package/dist/components/NestedMenu.js +5 -2
  22. package/dist/components/PDFViewer.cjs +22 -19
  23. package/dist/components/PDFViewer.js +5 -3
  24. package/dist/components/ProjectBar.cjs +3 -0
  25. package/dist/components/ProjectBar.js +4 -1
  26. package/dist/components/Time.js +2 -1
  27. package/dist/components/index.cjs +963 -905
  28. package/dist/components/index.js +70 -45
  29. package/dist/components/useMenuSystem.cjs +22 -19
  30. package/dist/components/useMenuSystem.js +5 -2
  31. package/dist/hooks/index.cjs +66 -2
  32. package/dist/hooks/index.js +8 -3
  33. package/dist/utils/index.cjs +25 -0
  34. package/dist/utils/index.js +3 -1
  35. package/package.json +1 -1
  36. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -4
  37. package/src/components/DataGrid/TableBody/index.tsx +14 -3
  38. package/src/components/DataGrid/index.tsx +58 -35
  39. package/src/components/DataGridCell.tsx +11 -17
  40. package/src/hooks/index.ts +1 -0
  41. package/src/hooks/useTableLayout.ts +68 -0
  42. package/src/utils/index.ts +1 -0
  43. package/src/utils/mergeObjectArrays.ts +18 -0
  44. package/src/utils.ts +1 -0
  45. /package/dist/{chunk-6LN6QT6M.js → chunk-VXWSAIB5.js} +0 -0
@@ -1,3 +1,7 @@
1
+ import {
2
+ mergeObjectArrays
3
+ } from "./chunk-T3F37S6Z.js";
4
+
1
5
  // src/hooks/useKeydown.ts
2
6
  import { useEffect } from "react";
3
7
  function useKeydown(keys, isActive) {
@@ -71,9 +75,49 @@ var useMatchesMedia = (query) => {
71
75
  };
72
76
  var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
73
77
 
78
+ // src/hooks/useTableLayout.ts
79
+ import { useState as useState2, useEffect as useEffect3, useCallback } from "react";
80
+ function useTableLayout(initialColumns, key) {
81
+ const [columns, setColumns] = useState2(initialColumns);
82
+ const [isReady, setIsReady] = useState2(false);
83
+ const [layoutSignal, setLayoutSignal] = useState2(0);
84
+ useEffect3(() => {
85
+ if (!key) return setIsReady(true);
86
+ const savedLayout = localStorage.getItem(`${key}-tableLayout`);
87
+ if (savedLayout) {
88
+ setColumns(
89
+ mergeObjectArrays(
90
+ initialColumns,
91
+ JSON.parse(savedLayout)
92
+ )
93
+ );
94
+ }
95
+ if (!savedLayout) handleSaveLayout(initialColumns, true);
96
+ setLayoutSignal((prev) => prev + 1);
97
+ setIsReady(true);
98
+ }, []);
99
+ const handleSaveLayout = useCallback(
100
+ (setter, _internal) => {
101
+ if (!isReady && !_internal) return null;
102
+ const newColumns = typeof setter === "function" ? setter(columns) : setter;
103
+ if (JSON.stringify(newColumns) === JSON.stringify(columns) && !_internal)
104
+ return null;
105
+ if (key) {
106
+ localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
107
+ }
108
+ setColumns(newColumns);
109
+ setLayoutSignal((prev) => prev + 1);
110
+ return newColumns;
111
+ },
112
+ [columns, isReady, key]
113
+ );
114
+ return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
115
+ }
116
+
74
117
  export {
75
118
  useKeydown,
76
119
  useInfiniteScroll,
77
120
  useMatchesMedia,
78
- useMatchesMobile
121
+ useMatchesMobile,
122
+ useTableLayout
79
123
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useMatchesMobile
3
- } from "./chunk-WNQ53SVY.js";
3
+ } from "./chunk-E6Y7ZHQX.js";
4
4
  import {
5
5
  Label
6
6
  } from "./chunk-CJVTFYI4.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useMenuPosition
3
- } from "./chunk-WE55TGZZ.js";
3
+ } from "./chunk-NIHZMIOL.js";
4
4
  import {
5
5
  useMatchesMobile
6
- } from "./chunk-WNQ53SVY.js";
6
+ } from "./chunk-E6Y7ZHQX.js";
7
7
  import {
8
8
  findDocumentRoot
9
- } from "./chunk-6LN6QT6M.js";
9
+ } from "./chunk-VXWSAIB5.js";
10
10
  import {
11
11
  __objRest,
12
12
  __spreadProps,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useMatchesMobile
3
- } from "./chunk-WNQ53SVY.js";
3
+ } from "./chunk-E6Y7ZHQX.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-BBZEL7EG.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Menu
3
- } from "./chunk-2JRZCC2K.js";
3
+ } from "./chunk-JITZWSPR.js";
4
4
  import {
5
5
  useSubMenuSystem
6
- } from "./chunk-WE55TGZZ.js";
6
+ } from "./chunk-NIHZMIOL.js";
7
7
  import {
8
8
  MenuOption
9
- } from "./chunk-WXHRJSDG.js";
9
+ } from "./chunk-ERW3AMED.js";
10
10
  import {
11
11
  Search
12
12
  } from "./chunk-2WRRRPEB.js";
@@ -30,10 +30,10 @@ import {
30
30
  import { useSortable } from "@dnd-kit/sortable";
31
31
  import clsx from "clsx";
32
32
  import {
33
- memo,
34
33
  useEffect,
35
34
  useRef,
36
- useState
35
+ useState,
36
+ memo
37
37
  } from "react";
38
38
  import { jsx, jsxs } from "react/jsx-runtime";
39
39
  var DataGridCell = memo(
@@ -54,6 +54,7 @@ var DataGridCell = memo(
54
54
  warning,
55
55
  center,
56
56
  width,
57
+ minWidth,
57
58
  testid
58
59
  } = _b, props = __objRest(_b, [
59
60
  "id",
@@ -71,6 +72,7 @@ var DataGridCell = memo(
71
72
  "warning",
72
73
  "center",
73
74
  "width",
75
+ "minWidth",
74
76
  "testid"
75
77
  ]);
76
78
  const Element = type === "header" ? "th" : "td";
@@ -144,7 +146,7 @@ var DataGridCell = memo(
144
146
  id,
145
147
  "data-testid": testid,
146
148
  className: clsx("flex h-10", !width && "flex-1"),
147
- style: { width }
149
+ style: { width, minWidth }
148
150
  }, props), {
149
151
  "data-theme": type === "header" && !locked ? "brand" : void 0,
150
152
  children: /* @__PURE__ */ jsx(
@@ -185,7 +187,7 @@ function DataCellHeader(_a) {
185
187
  "testid",
186
188
  "useMenuDefaultMinWidth"
187
189
  ]);
188
- var _a2, _b2, _c;
190
+ var _a2;
189
191
  const [showMenu, setShowMenu] = useState(false);
190
192
  const [filter, setFilter] = useState(
191
193
  (_a2 = header.column.getFilterValue()) != null ? _a2 : ""
@@ -219,7 +221,7 @@ function DataCellHeader(_a) {
219
221
  const style = __spreadValues({
220
222
  position: "relative",
221
223
  whiteSpace: "nowrap",
222
- width: (_c = (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.headerWidth) != null ? _c : header.column.getSize(),
224
+ minWidth: header.column.getSize(),
223
225
  "--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
224
226
  "--color-icon-on-action-primary-normal": "var(--color-text-brand-primary-normal)",
225
227
  "--background-action-secondary-normal": "var(--color-text-brand-primary-normal)"
@@ -233,6 +235,7 @@ function DataCellHeader(_a) {
233
235
  type: "header",
234
236
  component: "header",
235
237
  style,
238
+ minWidth: `${header.column.getSize()}px`,
236
239
  onClick: header.column.getToggleSortingHandler(),
237
240
  onRightClick: () => setShowMenu(!showMenu)
238
241
  }, props), {
@@ -256,8 +259,8 @@ function DataCellHeader(_a) {
256
259
  id: id ? `${id}-filter-option` : void 0,
257
260
  testid: testid ? `${testid}-filter-option` : void 0
258
261
  }, subMenuListeners), {
259
- subMenu: (_d) => {
260
- var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
262
+ subMenu: (_b2) => {
263
+ var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
261
264
  return /* @__PURE__ */ jsxs(
262
265
  Menu,
263
266
  __spreadProps(__spreadValues({
@@ -330,8 +333,8 @@ function DataCellHeader(_a) {
330
333
  setShowMenu(!showMenu);
331
334
  }
332
335
  }, subMenuListeners), {
333
- subMenu: (_f) => {
334
- var _g = _f, { menuId, subMenuLevel } = _g, props2 = __objRest(_g, ["menuId", "subMenuLevel"]);
336
+ subMenu: (_d) => {
337
+ var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
335
338
  return /* @__PURE__ */ jsxs(
336
339
  Menu,
337
340
  __spreadProps(__spreadValues({}, props2), {
@@ -419,7 +422,6 @@ function DraggableCellHeader(_a) {
419
422
  "header",
420
423
  "children"
421
424
  ]);
422
- var _a2, _b2;
423
425
  const { attributes, isDragging, listeners, setNodeRef, transform, node } = useSortable({
424
426
  id: header.column.id
425
427
  });
@@ -430,7 +432,6 @@ function DraggableCellHeader(_a) {
430
432
  transition: "width transform 0.2s ease-in-out",
431
433
  whiteSpace: "nowrap",
432
434
  zIndex: isDragging ? 1 : 0,
433
- width: (_b2 = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : header.column.getSize(),
434
435
  "--color-text-primary-normal": "var(--color-action-000)",
435
436
  "--color-icon-on-action-primary-normal": "var(--color-action-000)",
436
437
  userSelect: "none"
@@ -456,7 +457,6 @@ function DragAlongCell(_a) {
456
457
  "cell",
457
458
  "children"
458
459
  ]);
459
- var _a2, _b2, _c, _d;
460
460
  const { isDragging, setNodeRef, transform } = useSortable({
461
461
  id: cell.column.id
462
462
  });
@@ -465,19 +465,10 @@ function DragAlongCell(_a) {
465
465
  position: "relative",
466
466
  transform: CSS.Translate.toString(transform),
467
467
  transition: "width transform 0.2s ease-in-out",
468
- width: (_b2 = (_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : cell.column.getSize(),
468
+ minWidth: cell.column.getSize(),
469
469
  zIndex: isDragging ? 1 : 0
470
470
  };
471
- return /* @__PURE__ */ jsx(
472
- DataGridCell,
473
- __spreadProps(__spreadValues({
474
- style,
475
- ref: setNodeRef,
476
- width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`
477
- }, props), {
478
- children
479
- })
480
- );
471
+ return /* @__PURE__ */ jsx(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
481
472
  }
482
473
  DragAlongCell.displayName = "DragAlongCell";
483
474
 
@@ -1,3 +1,7 @@
1
+ import {
2
+ __spreadValues
3
+ } from "./chunk-BBZEL7EG.js";
4
+
1
5
  // src/utils/date.ts
2
6
  function parseInputDate(input) {
3
7
  const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
@@ -124,6 +128,15 @@ function isValidDateRangeOrder(fromDate, toDate) {
124
128
  return to >= from;
125
129
  }
126
130
 
131
+ // src/utils/mergeObjectArrays.ts
132
+ function mergeObjectArrays(arr1, arr2) {
133
+ const maxLength = Math.max(arr1.length, arr2.length);
134
+ return Array.from(
135
+ { length: maxLength },
136
+ (_, i) => __spreadValues(__spreadValues({}, arr1[i] || {}), arr2[i] || {})
137
+ );
138
+ }
139
+
127
140
  export {
128
141
  parseInputDate,
129
142
  isValidDate,
@@ -137,5 +150,6 @@ export {
137
150
  isValidDateRange,
138
151
  formatDatePartsToDisplay,
139
152
  formatDate,
140
- isValidDateRangeOrder
153
+ isValidDateRangeOrder,
154
+ mergeObjectArrays
141
155
  };
@@ -15,10 +15,10 @@ import {
15
15
  } from "./chunk-ZFOANBWG.js";
16
16
  import {
17
17
  useMatchesMobile
18
- } from "./chunk-WNQ53SVY.js";
18
+ } from "./chunk-E6Y7ZHQX.js";
19
19
  import {
20
20
  findDocumentRoot
21
- } from "./chunk-6LN6QT6M.js";
21
+ } from "./chunk-VXWSAIB5.js";
22
22
 
23
23
  // src/components/Modal.tsx
24
24
  import clsx from "clsx";