@dmsi/wedgekit-react 0.0.81 → 0.0.83

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 (46) hide show
  1. package/dist/{chunk-6R2HCLEL.js → chunk-37TJJQL3.js} +2 -2
  2. package/dist/{chunk-B6PDZCU7.js → chunk-5GUW4DUY.js} +1 -1
  3. package/dist/{chunk-ATOEGP3V.js → chunk-CKSDMI2Q.js} +14 -7
  4. package/dist/{chunk-2DCVAATK.js → chunk-MQWWNAO3.js} +4 -4
  5. package/dist/{chunk-FOC6LTSX.js → chunk-UPBBOZM3.js} +1 -1
  6. package/dist/{chunk-SWA5WVQO.js → chunk-WNQ53SVY.js} +30 -0
  7. package/dist/components/DataGridCell.cjs +53 -43
  8. package/dist/components/DataGridCell.js +5 -5
  9. package/dist/components/Menu.cjs +17 -14
  10. package/dist/components/Menu.js +3 -3
  11. package/dist/components/MenuOption.cjs +10 -7
  12. package/dist/components/MenuOption.js +2 -2
  13. package/dist/components/Modal.cjs +18 -15
  14. package/dist/components/Modal.js +3 -3
  15. package/dist/components/NestedMenu.cjs +12 -9
  16. package/dist/components/NestedMenu.js +2 -2
  17. package/dist/components/PDFViewer.cjs +21 -18
  18. package/dist/components/PDFViewer.js +3 -3
  19. package/dist/components/ProjectBar.cjs +6 -3
  20. package/dist/components/ProjectBar.js +1 -1
  21. package/dist/components/TopBar.cjs +1 -1
  22. package/dist/components/TopBar.js +1 -1
  23. package/dist/components/{DataGrid.cjs → index.cjs} +1424 -1335
  24. package/dist/components/{DataGrid.js → index.js} +948 -883
  25. package/dist/components/useMenuSystem.cjs +20 -17
  26. package/dist/components/useMenuSystem.js +2 -2
  27. package/dist/hooks/index.cjs +34 -3
  28. package/dist/hooks/index.js +3 -1
  29. package/package.json +6 -1
  30. package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +32 -0
  31. package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +66 -0
  32. package/src/components/DataGrid/PinnedColumns.tsx +145 -0
  33. package/src/components/DataGrid/TableBody/LoadingCell.tsx +40 -0
  34. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +129 -0
  35. package/src/components/DataGrid/TableBody/index.tsx +159 -0
  36. package/src/components/{DataGrid.tsx → DataGrid/index.tsx} +42 -678
  37. package/src/components/DataGrid/types.ts +86 -0
  38. package/src/components/DataGrid/utils.tsx +15 -0
  39. package/src/components/DataGridCell.tsx +37 -21
  40. package/src/components/TopBar.tsx +1 -1
  41. package/src/components/index.ts +20 -0
  42. package/src/hooks/index.ts +1 -0
  43. package/dist/chunk-AWQSSKCK.js +0 -32
  44. package/dist/components/useInfiniteScroll.cjs +0 -57
  45. package/dist/components/useInfiniteScroll.js +0 -8
  46. /package/src/{components → hooks}/useInfiniteScroll.tsx +0 -0
@@ -0,0 +1,86 @@
1
+ import {
2
+ ColumnDef,
3
+ ColumnFiltersState,
4
+ SortingState,
5
+ } from "@tanstack/react-table";
6
+
7
+ import { ReactNode } from "react";
8
+
9
+ // TanStack Table
10
+ import {
11
+ FilterFn,
12
+ Header,
13
+ PartialKeys,
14
+ RowData,
15
+ Table,
16
+ TableOptionsResolved,
17
+ } from "@tanstack/react-table";
18
+
19
+ // Types
20
+ export interface DataGridPagination {
21
+ pageIndex: number;
22
+ pageSize: number;
23
+ total: number;
24
+ onPageChange: (pageIndex: number) => void;
25
+ onPageSizeChange?: (pageSize: number) => void;
26
+ }
27
+
28
+ export interface DataGridProps<T extends Record<string, unknown>> {
29
+ id?: string;
30
+ data: T[];
31
+ columns: ColumnDef<T>[];
32
+ status?: string;
33
+ locked?: boolean;
34
+ isLoadingMore?: boolean;
35
+ onLoadMore?: () => void;
36
+ hasMore?: boolean;
37
+ pagination?: DataGridPagination;
38
+ showFilterRow?: boolean;
39
+ sorting?: SortingState;
40
+ onSortingChange?: (state: SortingState) => void;
41
+ columnFilters?: ColumnFiltersState;
42
+ onColumnFiltersChange?: (filters: ColumnFiltersState) => void;
43
+ rowSelection?: Record<string, boolean>;
44
+ onRowSelectionChange?: (selection: Record<string, boolean>) => void;
45
+ filteredSortedData?: T[];
46
+ totalRowCount: number;
47
+ hideStatusBar?: boolean;
48
+ centerHeader?: boolean;
49
+ enableColumnSelector?: boolean;
50
+ predeterminedLeftPins?: string[];
51
+ predeterminedRightPins?: string[];
52
+ useMenuDefaultMinWidth?: boolean;
53
+ }
54
+
55
+ declare module "@tanstack/react-table" {
56
+ interface TableOptions<TData extends RowData>
57
+ extends PartialKeys<
58
+ TableOptionsResolved<TData>,
59
+ "state" | "onStateChange" | "renderFallbackValue"
60
+ > {
61
+ filterFns?: FilterFns;
62
+ }
63
+ interface FilterFns {
64
+ endsWith?: FilterFn<RowData>;
65
+ startsWith?: FilterFn<RowData>;
66
+ }
67
+
68
+ interface ColumnMeta<TData extends RowData, TValue> {
69
+ filterVariant?: "text" | "select" | "range";
70
+ className?: string;
71
+ sticky?: boolean;
72
+ useCustomRenderer?: boolean;
73
+ locked?: boolean;
74
+ checkbox?: boolean;
75
+ headerWidth?: string;
76
+ visible?: boolean;
77
+ inVisibilityMenu?: boolean;
78
+ filterRowCell?: ({
79
+ header,
80
+ table,
81
+ }: {
82
+ header: Header<TData, TValue>;
83
+ table: Table<TData>;
84
+ }) => ReactNode;
85
+ }
86
+ }
@@ -0,0 +1,15 @@
1
+ import clsx from "clsx";
2
+ import { Icon } from "..";
3
+ import { SortDirection } from "@tanstack/react-table";
4
+
5
+ export function getSortIcon(sort: SortDirection | false, nextSort = false) {
6
+ const iconClassName = clsx(
7
+ "text-icon-on-action-primary-normal",
8
+ nextSort && "hidden group-hover:block",
9
+ );
10
+ if (sort === "asc")
11
+ return <Icon size={16} className={iconClassName} name="arrow_upward" />;
12
+ if (sort === "desc")
13
+ return <Icon size={16} className={iconClassName} name="arrow_downward" />;
14
+ return null;
15
+ }
@@ -197,14 +197,17 @@ export type DataGridCellHeaderProps<T> = {
197
197
  width?: string;
198
198
  setNodeRef?: (node: HTMLElement | null) => void;
199
199
  node?: RefObject<HTMLElement | null>;
200
- } & DataGridCellProps & ComponentProps<"th">;
200
+ useMenuDefaultMinWidth?: boolean;
201
+ } & DataGridCellProps &
202
+ ComponentProps<"th">;
201
203
 
202
- export function DataCellHeader<T extends unknown>({
204
+ export function DataCellHeader<T>({
203
205
  header,
204
206
  children,
205
207
  setNodeRef,
206
208
  node,
207
209
  id,
210
+ useMenuDefaultMinWidth,
208
211
  ...props
209
212
  }: DataGridCellHeaderProps<T>) {
210
213
  const [showMenu, setShowMenu] = useState(false);
@@ -213,22 +216,25 @@ export function DataCellHeader<T extends unknown>({
213
216
  );
214
217
  const ref = useRef<HTMLElement>(null);
215
218
  const predeterminedPinned = useRef(false);
216
-
219
+
217
220
  const {
218
221
  menuRootRef,
219
222
  isMenuActive,
220
223
  registerSubMenu,
221
224
  listeners: subMenuListeners,
222
- mobileHide
225
+ mobileHide,
223
226
  } = useSubMenuSystem(node ? node : ref);
224
227
 
225
228
  useEffect(() => {
226
- const columnPinning = header.getContext().table.options.initialState?.columnPinning;
229
+ const columnPinning =
230
+ header.getContext().table.options.initialState?.columnPinning;
227
231
  const left = columnPinning?.left ? columnPinning.left : [];
228
232
  const right = columnPinning?.right ? columnPinning.right : [];
229
-
230
- predeterminedPinned.current = [...left, ...right].includes(header.column.id);
231
- }, [])
233
+
234
+ predeterminedPinned.current = [...left, ...right].includes(
235
+ header.column.id,
236
+ );
237
+ }, []);
232
238
 
233
239
  useEffect(() => {
234
240
  const handler = setTimeout(() => {
@@ -245,7 +251,7 @@ export function DataCellHeader<T extends unknown>({
245
251
  whiteSpace: "nowrap",
246
252
  width: header.column.getSize(),
247
253
  "--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
248
- ...props.style
254
+ ...props.style,
249
255
  };
250
256
 
251
257
  return (
@@ -269,6 +275,7 @@ export function DataCellHeader<T extends unknown>({
269
275
  show={showMenu}
270
276
  setShow={setShowMenu}
271
277
  mobileHide={mobileHide}
278
+ useDefaultMinWidth={useMenuDefaultMinWidth}
272
279
  >
273
280
  <MenuOption
274
281
  id={id ? `${id}-filter-option` : undefined}
@@ -281,6 +288,7 @@ export function DataCellHeader<T extends unknown>({
281
288
  ref={(el) => {
282
289
  registerSubMenu(menuId, el);
283
290
  }}
291
+ useDefaultMinWidth={useMenuDefaultMinWidth}
284
292
  >
285
293
  <div className={clsx(paddingUsingComponentGap)}>
286
294
  <Search
@@ -325,7 +333,7 @@ export function DataCellHeader<T extends unknown>({
325
333
  >
326
334
  Filter
327
335
  </MenuOption>
328
-
336
+
329
337
  {!predeterminedPinned.current && header.column.getCanPin() && (
330
338
  <MenuOption
331
339
  onClick={() => {
@@ -341,29 +349,37 @@ export function DataCellHeader<T extends unknown>({
341
349
  }}
342
350
  >
343
351
  <MenuOption
344
- selected={header.column.getIsPinned() === 'left'}
352
+ selected={header.column.getIsPinned() === "left"}
345
353
  onClick={() => {
346
- if (header.column.getIsPinned() === 'left') {
347
- header.column.pin(false)
354
+ if (header.column.getIsPinned() === "left") {
355
+ header.column.pin(false);
348
356
  } else {
349
- header.column.pin('left')
357
+ header.column.pin("left");
350
358
  }
351
359
  }}
352
- after={header.column.getIsPinned() === 'left' && <Icon name="check" />}
360
+ after={
361
+ header.column.getIsPinned() === "left" && (
362
+ <Icon name="check" />
363
+ )
364
+ }
353
365
  >
354
366
  Left
355
367
  </MenuOption>
356
368
 
357
369
  <MenuOption
358
- selected={header.column.getIsPinned() === 'right'}
370
+ selected={header.column.getIsPinned() === "right"}
359
371
  onClick={() => {
360
- if (header.column.getIsPinned() === 'right') {
361
- header.column.pin(false)
372
+ if (header.column.getIsPinned() === "right") {
373
+ header.column.pin(false);
362
374
  } else {
363
- header.column.pin('right')
375
+ header.column.pin("right");
364
376
  }
365
377
  }}
366
- after={header.column.getIsPinned() === 'right' && <Icon name="check" />}
378
+ after={
379
+ header.column.getIsPinned() === "right" && (
380
+ <Icon name="check" />
381
+ )
382
+ }
367
383
  >
368
384
  Right
369
385
  </MenuOption>
@@ -433,6 +449,7 @@ export function DraggableCellHeader<T extends Record<string, any>>({
433
449
  zIndex: isDragging ? 1 : 0,
434
450
  width: header.column.getSize(),
435
451
  "--color-text-primary-normal": "var(--color-neutral-000)",
452
+ userSelect: "none",
436
453
  };
437
454
 
438
455
  return (
@@ -463,7 +480,6 @@ export function DragAlongCell<T extends RowData, TValue>({
463
480
  const { isDragging, setNodeRef, transform } = useSortable({
464
481
  id: cell.column.id,
465
482
  });
466
-
467
483
 
468
484
  const style: CSSProperties = {
469
485
  opacity: isDragging ? 0.8 : 1,
@@ -58,7 +58,7 @@ export const TopBarBase = ({
58
58
  className={clsx(
59
59
  "hidden desktop:flex items-center shrink-0 ml-auto",
60
60
  "[&>a]:leading-6",
61
- layoutGroupGap,
61
+ layoutGap,
62
62
  )}
63
63
  >
64
64
  {topNavLinks}
@@ -0,0 +1,20 @@
1
+ export {
2
+ DataCellHeader,
3
+ DataGridCell,
4
+ DragAlongCell,
5
+ DraggableCellHeader,
6
+ } from "./DataGridCell";
7
+ export { DataGrid } from "./DataGrid";
8
+ export type { ColumnDef } from "./DataGrid";
9
+ export { Label } from "./Label";
10
+ export { Select } from "./Select";
11
+ export { Subheader } from "./Subheader";
12
+ export { Icon } from "./Icon";
13
+ export { Checkbox } from "./Checkbox";
14
+ export { Paragraph } from "./Paragraph";
15
+ export { Button } from "./Button";
16
+ export { Menu } from "./Menu";
17
+ export { MenuOption } from "./MenuOption";
18
+ export { Search } from "./Search";
19
+ export { Tooltip } from "./Tooltip";
20
+ export { Input } from "./Input";
@@ -1,2 +1,3 @@
1
1
  export { useKeydown } from "./useKeydown";
2
+ export { useInfiniteScroll } from "./useInfiniteScroll";
2
3
  export { useMatchesMedia, useMatchesMobile } from "./useMatchesMedia";
@@ -1,32 +0,0 @@
1
- // src/components/useInfiniteScroll.tsx
2
- import { useEffect } from "react";
3
- function useInfiniteScroll({
4
- containerRef,
5
- onLoadMore,
6
- isLoading,
7
- offset = 50,
8
- enabled = true
9
- // ✅ Add this
10
- }) {
11
- useEffect(() => {
12
- if (!enabled) return;
13
- const handleScroll = () => {
14
- const el2 = containerRef.current;
15
- if (!el2 || isLoading) return;
16
- const { scrollTop, scrollHeight, clientHeight } = el2;
17
- const isNearBottom = scrollTop + clientHeight >= scrollHeight - offset;
18
- if (isNearBottom) {
19
- onLoadMore();
20
- }
21
- };
22
- const el = containerRef.current;
23
- if (el) el.addEventListener("scroll", handleScroll);
24
- return () => {
25
- if (el) el.removeEventListener("scroll", handleScroll);
26
- };
27
- }, [containerRef, onLoadMore, isLoading, offset, enabled]);
28
- }
29
-
30
- export {
31
- useInfiniteScroll
32
- };
@@ -1,57 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/components/useInfiniteScroll.tsx
22
- var useInfiniteScroll_exports = {};
23
- __export(useInfiniteScroll_exports, {
24
- useInfiniteScroll: () => useInfiniteScroll
25
- });
26
- module.exports = __toCommonJS(useInfiniteScroll_exports);
27
- var import_react = require("react");
28
- function useInfiniteScroll({
29
- containerRef,
30
- onLoadMore,
31
- isLoading,
32
- offset = 50,
33
- enabled = true
34
- // ✅ Add this
35
- }) {
36
- (0, import_react.useEffect)(() => {
37
- if (!enabled) return;
38
- const handleScroll = () => {
39
- const el2 = containerRef.current;
40
- if (!el2 || isLoading) return;
41
- const { scrollTop, scrollHeight, clientHeight } = el2;
42
- const isNearBottom = scrollTop + clientHeight >= scrollHeight - offset;
43
- if (isNearBottom) {
44
- onLoadMore();
45
- }
46
- };
47
- const el = containerRef.current;
48
- if (el) el.addEventListener("scroll", handleScroll);
49
- return () => {
50
- if (el) el.removeEventListener("scroll", handleScroll);
51
- };
52
- }, [containerRef, onLoadMore, isLoading, offset, enabled]);
53
- }
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {
56
- useInfiniteScroll
57
- });
@@ -1,8 +0,0 @@
1
- "use client";
2
- import {
3
- useInfiniteScroll
4
- } from "../chunk-AWQSSKCK.js";
5
- import "../chunk-ORMEWXMH.js";
6
- export {
7
- useInfiniteScroll
8
- };
File without changes