@dmsi/wedgekit-react 0.0.551 → 0.0.552

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 (137) hide show
  1. package/package.json +2 -3
  2. package/src/brand.css +0 -125
  3. package/src/classNames.ts +0 -174
  4. package/src/components/AccessChangerTabItem.tsx +0 -71
  5. package/src/components/Accordion.tsx +0 -108
  6. package/src/components/Alert.tsx +0 -81
  7. package/src/components/Breadcrumbs.tsx +0 -142
  8. package/src/components/Button.tsx +0 -216
  9. package/src/components/CalendarRange.tsx +0 -628
  10. package/src/components/Caption.tsx +0 -144
  11. package/src/components/Card.tsx +0 -88
  12. package/src/components/Checkbox.tsx +0 -206
  13. package/src/components/CompactImagesPreview.tsx +0 -135
  14. package/src/components/ContentTab.tsx +0 -84
  15. package/src/components/ContentTabs.tsx +0 -136
  16. package/src/components/DMSiLogo.tsx +0 -33
  17. package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +0 -35
  18. package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +0 -74
  19. package/src/components/DataGrid/PinnedColumns.tsx +0 -183
  20. package/src/components/DataGrid/TableBody/LoadingCell.tsx +0 -44
  21. package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -157
  22. package/src/components/DataGrid/TableBody/index.tsx +0 -185
  23. package/src/components/DataGrid/index.tsx +0 -756
  24. package/src/components/DataGrid/types.ts +0 -98
  25. package/src/components/DataGrid/utils.tsx +0 -15
  26. package/src/components/DataGridCell.tsx +0 -526
  27. package/src/components/DataTable.tsx +0 -881
  28. package/src/components/DateInput.tsx +0 -306
  29. package/src/components/DateRangeInput.tsx +0 -758
  30. package/src/components/DebugJson.tsx +0 -28
  31. package/src/components/Display.tsx +0 -66
  32. package/src/components/EditingContext.tsx +0 -43
  33. package/src/components/EmptyCartIcon.tsx +0 -18
  34. package/src/components/FilterGroup.tsx +0 -264
  35. package/src/components/FullViewportBox.tsx +0 -19
  36. package/src/components/Grid.tsx +0 -97
  37. package/src/components/Heading.tsx +0 -72
  38. package/src/components/HorizontalDivider.tsx +0 -22
  39. package/src/components/Icon.tsx +0 -39
  40. package/src/components/ImagePlaceholder.tsx +0 -22
  41. package/src/components/Input.tsx +0 -609
  42. package/src/components/InputGroup.tsx +0 -59
  43. package/src/components/Label.tsx +0 -46
  44. package/src/components/Link.tsx +0 -117
  45. package/src/components/List.tsx +0 -18
  46. package/src/components/ListGroup.tsx +0 -82
  47. package/src/components/LiveChatComponent.tsx +0 -56
  48. package/src/components/LoadingScrim.tsx +0 -33
  49. package/src/components/LogoAgilityTopBar.tsx +0 -54
  50. package/src/components/LogoDMSiTopBar.tsx +0 -33
  51. package/src/components/LogoMillworkTopBar.tsx +0 -119
  52. package/src/components/MainBar.tsx +0 -91
  53. package/src/components/MaxViewportBox.tsx +0 -19
  54. package/src/components/Menu.tsx +0 -316
  55. package/src/components/MenuOption.tsx +0 -330
  56. package/src/components/MobileDataGrid/ColumnList.tsx +0 -66
  57. package/src/components/MobileDataGrid/ColumnSelector/index.tsx +0 -97
  58. package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +0 -25
  59. package/src/components/MobileDataGrid/GridContextProvider/index.tsx +0 -132
  60. package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +0 -10
  61. package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +0 -27
  62. package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +0 -138
  63. package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +0 -81
  64. package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +0 -42
  65. package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +0 -68
  66. package/src/components/MobileDataGrid/dataGridReducer.ts +0 -55
  67. package/src/components/MobileDataGrid/index.tsx +0 -92
  68. package/src/components/MobileDataGrid/types.ts +0 -4
  69. package/src/components/Modal.tsx +0 -312
  70. package/src/components/ModalButtons.tsx +0 -62
  71. package/src/components/ModalContent.tsx +0 -31
  72. package/src/components/ModalHeader.tsx +0 -78
  73. package/src/components/ModalScrim.tsx +0 -42
  74. package/src/components/NavigationTab.tsx +0 -95
  75. package/src/components/NavigationTabs.tsx +0 -70
  76. package/src/components/NestedMenu.tsx +0 -131
  77. package/src/components/Notification.tsx +0 -128
  78. package/src/components/OptionPill.tsx +0 -139
  79. package/src/components/OrderCheckIcon.tsx +0 -19
  80. package/src/components/PDFViewer/DownloadIcon.tsx +0 -25
  81. package/src/components/PDFViewer/PDFElement.tsx +0 -90
  82. package/src/components/PDFViewer/PDFNavigation.tsx +0 -68
  83. package/src/components/PDFViewer/PDFPage.tsx +0 -34
  84. package/src/components/PDFViewer/index.tsx +0 -128
  85. package/src/components/Pagination.tsx +0 -182
  86. package/src/components/Paragraph.tsx +0 -55
  87. package/src/components/Password.tsx +0 -62
  88. package/src/components/ProductImagePreview/CarouselPagination.tsx +0 -54
  89. package/src/components/ProductImagePreview/MobileImageCarousel.tsx +0 -226
  90. package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +0 -219
  91. package/src/components/ProductImagePreview/Thumbnail.tsx +0 -55
  92. package/src/components/ProductImagePreview/ZoomWindow.tsx +0 -136
  93. package/src/components/ProductImagePreview/index.tsx +0 -182
  94. package/src/components/ProductImagePreview/useProductImagePreview.ts +0 -211
  95. package/src/components/ProjectBar.tsx +0 -82
  96. package/src/components/Radio.tsx +0 -146
  97. package/src/components/Search.tsx +0 -152
  98. package/src/components/SearchResultImage/index.tsx +0 -39
  99. package/src/components/Select.tsx +0 -114
  100. package/src/components/SideMenu.tsx +0 -30
  101. package/src/components/SideMenuGroup.tsx +0 -95
  102. package/src/components/SideMenuItem.tsx +0 -109
  103. package/src/components/SimpleTable.tsx +0 -77
  104. package/src/components/SkeletonParagraph.tsx +0 -31
  105. package/src/components/Spinner.tsx +0 -32
  106. package/src/components/Stack.tsx +0 -347
  107. package/src/components/StatusPill.tsx +0 -59
  108. package/src/components/Stepper.tsx +0 -128
  109. package/src/components/Subheader.tsx +0 -50
  110. package/src/components/Surface.tsx +0 -37
  111. package/src/components/Swatch.tsx +0 -1341
  112. package/src/components/Textarea.tsx +0 -102
  113. package/src/components/Theme.tsx +0 -27
  114. package/src/components/Time.tsx +0 -460
  115. package/src/components/Toast.tsx +0 -268
  116. package/src/components/Tooltip.tsx +0 -159
  117. package/src/components/TopBar.tsx +0 -139
  118. package/src/components/Upload.tsx +0 -107
  119. package/src/components/WorldpayIframe.tsx +0 -7
  120. package/src/components/index.ts +0 -34
  121. package/src/components/useMenuSystem.tsx +0 -456
  122. package/src/components/useMounted.tsx +0 -14
  123. package/src/darkmode.css +0 -278
  124. package/src/fonts.css +0 -23
  125. package/src/hooks/index.ts +0 -4
  126. package/src/hooks/useInfiniteScroll.tsx +0 -40
  127. package/src/hooks/useKeydown.ts +0 -42
  128. package/src/hooks/useMatchesMedia.ts +0 -18
  129. package/src/hooks/useTableLayout.ts +0 -106
  130. package/src/index.css +0 -800
  131. package/src/index.tsx +0 -5
  132. package/src/types.ts +0 -150
  133. package/src/utils/date.ts +0 -236
  134. package/src/utils/formatting.tsx +0 -81
  135. package/src/utils/index.ts +0 -4
  136. package/src/utils/mergeObjectArrays.ts +0 -18
  137. package/src/utils.ts +0 -24
@@ -1,97 +0,0 @@
1
- import { useCallback, useRef, useState } from "react";
2
- import { Button, Icon, Menu } from "../..";
3
- import { Checkbox, MenuOption } from "../..";
4
- import { useGridContext } from "../GridContextProvider/useGridContext";
5
-
6
- export function ColumnSelector<T>() {
7
- const context = useGridContext<T>();
8
- const ref = useRef<HTMLDivElement>(null);
9
- const [show, setShow] = useState(false);
10
- const {
11
- columns,
12
- id,
13
- testid,
14
- visibleColumns,
15
- numberOfColumnsToShow,
16
- primaryKey,
17
- resetColumnVisibility,
18
- dispatch,
19
- } = context;
20
-
21
- const toggleColumnVisibility = useCallback(
22
- (index: number, visible: boolean) => {
23
- dispatch({ type: "UPDATE", index, payload: { meta: { visible } } });
24
- },
25
- [dispatch],
26
- );
27
-
28
- return (
29
- <div
30
- id={id ? `${id}-column-selector` : undefined}
31
- data-testid={testid}
32
- className="text-text-secondary-normal border-l border-brand-200 p-mobile-container-padding"
33
- ref={ref}
34
- >
35
- <Button
36
- id={id ? `${id}-button` : undefined}
37
- testid={testid ? `${testid}-button` : undefined}
38
- onClick={() => setShow((prev) => !prev)}
39
- variant="navigation"
40
- iconOnly
41
- size={24}
42
- leftIcon={<Icon name="tune" />}
43
- ></Button>
44
- <Menu
45
- id={id ? `${id}-menu` : undefined}
46
- testid={testid ? `${testid}-menu` : undefined}
47
- positionTo={ref}
48
- position="bottom-right"
49
- show={show}
50
- setShow={setShow}
51
- calculateMinMaxHeight
52
- >
53
- <Button
54
- id={id ? `${id}-reset-button` : undefined}
55
- testid={testid ? `${testid}-reset-button` : undefined}
56
- variant="tertiary"
57
- onClick={() => {
58
- resetColumnVisibility();
59
- setShow(false);
60
- }}
61
- >
62
- Reset to default
63
- </Button>
64
- {columns
65
- .filter((x) => x.meta?.inVisibilityMenu)
66
- .map((column) => (
67
- <MenuOption
68
- key={id ? `${id}-option-${column.id}` : undefined}
69
- testid={testid ? `${testid}-option-${column.id}` : undefined}
70
- >
71
- <Checkbox
72
- id={id ? `${id}-checkbox-${column.id}` : undefined}
73
- testid={testid ? `${testid}-checkbox-${column.id}` : undefined}
74
- label={column.header?.toString()}
75
- checked={
76
- !!column.meta?.visible || column.id === String(primaryKey)
77
- }
78
- disabled={
79
- (typeof numberOfColumnsToShow !== "undefined" &&
80
- // account for header+link occupying one slot
81
- visibleColumns.length >= numberOfColumnsToShow - 1 &&
82
- column.meta?.visible !== true) ||
83
- column.id === String(primaryKey)
84
- }
85
- onChange={(e) => {
86
- toggleColumnVisibility(
87
- columns.findIndex(({ id }) => id === column.id),
88
- e.target.checked,
89
- );
90
- }}
91
- />
92
- </MenuOption>
93
- ))}
94
- </Menu>
95
- </div>
96
- );
97
- }
@@ -1,25 +0,0 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
- import { createContext, Dispatch } from "react";
3
- import { Action } from "../dataGridReducer";
4
-
5
- export type GridContextType<T = unknown> = {
6
- columns: ColumnDef<T>[];
7
- selectedRowIds: (string | number)[];
8
- data: T[];
9
- dispatch: Dispatch<Action<T>>;
10
- getId: (data: T) => string | number | undefined;
11
- resetColumnVisibility: () => void;
12
- handleRowSelect: (item: T) => void;
13
- handleRowSelectAll: () => void;
14
- id?: string;
15
- testid?: string;
16
- numberOfColumnsToShow?: number;
17
- visibleColumns: ColumnDef<T>[];
18
- primaryKey?: keyof T;
19
- isRowDetailOpen: boolean;
20
- currentRow: T | null;
21
- openRowDetail: (row: T) => void;
22
- closeRowDetail: () => void;
23
- };
24
-
25
- export const GridContext = createContext<GridContextType | null>(null);
@@ -1,132 +0,0 @@
1
- import { useCallback, useMemo, useReducer, useState } from "react";
2
- import { dataGridReducer } from "../dataGridReducer";
3
- import { GridContext, GridContextType } from "./GridContext";
4
- import { ColumnDef } from "@tanstack/react-table";
5
-
6
- type GridContextProps<T> = {
7
- initialColumns: ColumnDef<T>[];
8
- data: T[];
9
- getId: (data: T) => string | number | undefined;
10
- id?: string;
11
- testid?: string;
12
- children?: React.ReactNode;
13
- onRowSelect?: (row: T, selectedIds: (string | number)[]) => void;
14
- numberOfColumnsToShow?: number;
15
- primaryKey?: keyof T;
16
- };
17
-
18
- export function GridContextProvider<T>(props: GridContextProps<T>) {
19
- const {
20
- initialColumns,
21
- id,
22
- testid,
23
- children,
24
- data,
25
- numberOfColumnsToShow,
26
- primaryKey,
27
- getId,
28
- onRowSelect,
29
- } = props;
30
- const [columns, dispatch] = useReducer(dataGridReducer<T>, initialColumns);
31
- const [selectedRowIds, setSelectedRowIds] = useState<(string | number)[]>([]);
32
- const [currentRow, setCurrentRow] = useState<T | null>(null);
33
-
34
- const resetColumnVisibility = useCallback(() => {
35
- // use initialColumns' meta?.visible data in columns.
36
- const newColumns = columns.map((column) => {
37
- const initialColumn = initialColumns.find((c) => c.id === column.id);
38
- return {
39
- ...column,
40
- meta: {
41
- ...column.meta,
42
- visible: initialColumn?.meta?.visible,
43
- },
44
- };
45
- });
46
- dispatch({ type: "SET", payload: newColumns });
47
- }, [columns, initialColumns]);
48
-
49
- const handleRowSelect = useCallback(
50
- (item: T) => {
51
- const rowId = getId(item) ?? "";
52
- if (!rowId) return;
53
- const nextSelected = selectedRowIds.includes(rowId)
54
- ? selectedRowIds.filter((id) => id !== rowId)
55
- : [...selectedRowIds, rowId];
56
-
57
- setSelectedRowIds(nextSelected);
58
- if (onRowSelect) onRowSelect(item, nextSelected);
59
- },
60
- [getId, onRowSelect, selectedRowIds],
61
- );
62
-
63
- const handleRowSelectAll = useCallback(() => {
64
- setSelectedRowIds((prev) => {
65
- if (prev.length === data.length) {
66
- // Select none
67
- return [];
68
- }
69
- // Select all
70
- return data.map(getId).filter((id) => id !== undefined);
71
- });
72
- }, [data, getId]);
73
-
74
- const openRowDetail = useCallback((row: T) => {
75
- setCurrentRow(row);
76
- }, []);
77
-
78
- const closeRowDetail = useCallback(() => {
79
- setCurrentRow(null);
80
- }, []);
81
-
82
- const visibleColumns = useMemo(() => {
83
- // header+link counts as the first column when limiting
84
- const effectiveLimit =
85
- typeof numberOfColumnsToShow === "number"
86
- ? Math.max(numberOfColumnsToShow - 1, 0)
87
- : undefined;
88
- if (primaryKey) {
89
- const pkColumn = columns.find((col) => col.id === String(primaryKey));
90
- const otherColumns = columns.filter(
91
- (col) => col.id !== String(primaryKey),
92
- );
93
- const orderedColumns = pkColumn
94
- ? [pkColumn, ...otherColumns]
95
- : [...otherColumns];
96
- return orderedColumns
97
- .filter((x) => x.meta?.visible !== false)
98
- .slice(0, effectiveLimit);
99
- }
100
- return columns
101
- .filter((x) => x.meta?.visible !== false)
102
- .slice(0, effectiveLimit);
103
- }, [columns, numberOfColumnsToShow, primaryKey]);
104
-
105
- return (
106
- <GridContext.Provider
107
- value={
108
- {
109
- columns,
110
- testid,
111
- id,
112
- data,
113
- selectedRowIds,
114
- visibleColumns,
115
- numberOfColumnsToShow,
116
- primaryKey,
117
- dispatch,
118
- getId,
119
- resetColumnVisibility,
120
- handleRowSelect,
121
- handleRowSelectAll,
122
- isRowDetailOpen: !!currentRow,
123
- currentRow,
124
- openRowDetail,
125
- closeRowDetail,
126
- } as GridContextType<unknown> | null
127
- }
128
- >
129
- {children}
130
- </GridContext.Provider>
131
- );
132
- }
@@ -1,10 +0,0 @@
1
- import { useContext } from "react";
2
- import { GridContext, GridContextType } from "./GridContext";
3
-
4
- export function useGridContext<T>() {
5
- const ctx = useContext(GridContext) as GridContextType<T> | null;
6
- if (!ctx) {
7
- throw new Error("useGridContext must be used within GridContextProvider");
8
- }
9
- return ctx;
10
- }
@@ -1,27 +0,0 @@
1
- import { Paragraph } from "../../Paragraph";
2
- import { ColumnDef } from "@tanstack/react-table";
3
- import { formatDate } from "../../../utils";
4
-
5
- export function MobileDataGridColumn<T extends Record<string, unknown>>(props: {
6
- column: ColumnDef<T>;
7
- data: T;
8
- }) {
9
- const { column, data } = props;
10
-
11
- let value: unknown;
12
- if (column.id) {
13
- value = data[column.id];
14
- if (column.meta?.format === "date" && typeof value === "string") {
15
- value = formatDate(value);
16
- }
17
- }
18
-
19
- return (
20
- <div className="grid grid-cols-2 gap-2 flex-1">
21
- <Paragraph color="text-secondary-normal" className="text-left">
22
- {column.header?.toString()}:
23
- </Paragraph>{" "}
24
- {value ? (value as React.ReactNode) : null}
25
- </div>
26
- );
27
- }
@@ -1,138 +0,0 @@
1
- import { Icon } from "../../Icon";
2
- import { Paragraph } from "../../Paragraph";
3
- import { Stack } from "../../Stack";
4
- import { useGridContext } from "../GridContextProvider/useGridContext";
5
- import { Checkbox } from "../../Checkbox";
6
- import clsx from "clsx";
7
- import { MobileDataGridColumn } from "./MobileDataGridColumn";
8
- import { Subheader } from "../../Subheader";
9
- import { RowActions } from "../types";
10
- import { layoutGroupGap, layoutPaddingX, paddingYUsingLayoutGroupGap } from "../../../classNames";
11
-
12
- export function MobileDataGridCard<T extends Record<string, unknown>>({
13
- renderLink,
14
- renderChevron = true,
15
- data,
16
- enableRowSelection,
17
- selected,
18
- rowActions,
19
- }: {
20
- renderLink?: (data: T) => React.ReactNode;
21
- renderChevron?: boolean;
22
- data: T;
23
- enableRowSelection?: boolean;
24
- selected?: boolean;
25
- rowActions?: RowActions<T>;
26
- }) {
27
- const context = useGridContext<T>();
28
- const { id, testid, visibleColumns, getId, handleRowSelect, openRowDetail } =
29
- context;
30
-
31
- return (
32
- <li
33
- id={id ? `${id}-card-${getId(data)}` : undefined}
34
- data-testid={testid ? `${testid}-card-${getId(data)}` : undefined}
35
- className={clsx(
36
- "flex flex-col",
37
- "hover:bg-action-100 cursor-pointer list-none",
38
- selected ? "bg-action-100" : "bg-background-grouped-primary-normal",
39
- layoutGroupGap,
40
- layoutPaddingX,
41
- paddingYUsingLayoutGroupGap
42
- )}
43
- onClick={() => openRowDetail(data)}
44
- >
45
- <Stack sizing="component">
46
- <Stack horizontal horizontalMobile items="center" justify="between">
47
- {enableRowSelection && (
48
- <Stack
49
- sizing="component"
50
- padding
51
- width="fit"
52
- style={{ paddingLeft: 0, paddingRight: 8 }}
53
- onClick={(e) => e.stopPropagation()}
54
- >
55
- <Checkbox
56
- id={id ? `${id}-${getId(data)}-select-checkbox` : undefined}
57
- testid={
58
- testid
59
- ? `${testid}-${getId(data)}-select-checkbox`
60
- : undefined
61
- }
62
- checked={selected}
63
- onChange={() => handleRowSelect(data)}
64
- />
65
- </Stack>
66
- )}
67
- <Stack
68
- sizing="component"
69
- padding
70
- onClick={(e) => e.stopPropagation()}
71
- style={{ paddingInline: 0 }}
72
- >
73
- {renderLink ? (
74
- renderLink(data)
75
- ) : (
76
- <Subheader>
77
- {String(data[context.primaryKey as string] ?? "")}
78
- </Subheader>
79
- )}
80
- </Stack>
81
- <Stack
82
- horizontal
83
- horizontalMobile
84
- items="center"
85
- justify="end"
86
- sizing="component"
87
- onClick={(e) => e.stopPropagation()}
88
- >
89
- {rowActions &&
90
- (typeof rowActions === "function"
91
- ? rowActions(data)
92
- : rowActions)}
93
- </Stack>
94
- </Stack>
95
-
96
- <Stack sizing="layout-group">
97
- {visibleColumns
98
- .filter((x) => x.meta?.visible !== false && !x.id?.startsWith("__"))
99
- .map((column, index) =>
100
- column.meta?.useCustomRenderer &&
101
- column.meta.mobileCell &&
102
- column.id ? (
103
- <div
104
- key={`${column.id}-${index}`}
105
- className="grid grid-cols-2 gap-2 items-center flex-1"
106
- >
107
- <Paragraph
108
- color="text-secondary-normal"
109
- className="text-left"
110
- >
111
- {column.header?.toString()}:
112
- </Paragraph>{" "}
113
- <column.meta.mobileCell
114
- column={column}
115
- row={data}
116
- cellValue={data[column.id]}
117
- />
118
- </div>
119
- ) : (
120
- <MobileDataGridColumn
121
- key={`${column.id}-${index}`}
122
- column={column}
123
- data={data}
124
- />
125
- ),
126
- )}
127
- </Stack>
128
- </Stack>
129
- {renderChevron && (
130
- <Stack items="center" justify="center" horizontal horizontalMobile>
131
- <span className="text-icon-primary-normal">
132
- <Icon name="keyboard_arrow_down" />
133
- </span>
134
- </Stack>
135
- )}
136
- </li>
137
- );
138
- }
@@ -1,81 +0,0 @@
1
- import { Checkbox } from "../Checkbox";
2
- import { Heading3 } from "../Heading";
3
- import { Stack } from "../Stack";
4
- import { Theme } from "../Theme";
5
- import { ColumnSelector } from "./ColumnSelector";
6
- import { GridContextType } from "./GridContextProvider/GridContext";
7
- import { useGridContext } from "./GridContextProvider/useGridContext";
8
-
9
- export function MobileDataGridHeader<T>({
10
- header: Header,
11
- enableColumnSelector,
12
- enableRowSelection,
13
- }: {
14
- header?: string | ((ctx: GridContextType<T>) => React.ReactNode);
15
- enableColumnSelector?: boolean;
16
- enableRowSelection?: boolean;
17
- }) {
18
- const ctx = useGridContext<T>();
19
- const {
20
- id,
21
- testid,
22
- selectedRowIds,
23
- data,
24
- primaryKey,
25
- columns,
26
- handleRowSelectAll,
27
- } = ctx;
28
-
29
- if (typeof Header === "undefined" && !primaryKey) return null;
30
- if (typeof Header === "function") return <Header {...ctx} />;
31
- if (typeof Header === "string" || primaryKey)
32
- return (
33
- <div
34
- id={id ? `${id}-header` : undefined}
35
- data-testid={testid ? `${testid}-header` : undefined}
36
- className="sticky top-0"
37
- >
38
- <Theme theme="brand">
39
- <Stack
40
- horizontal
41
- horizontalMobile
42
- items="center"
43
- justify="between"
44
- backgroundColor="background-primary-normal"
45
- style={{ borderTopRightRadius: 4, borderTopLeftRadius: 4 }}
46
- >
47
- {enableRowSelection && (
48
- <div className="p-mobile-component-padding border-r border-brand-200 max-w-fit h-full">
49
- <Checkbox
50
- id={id ? `${id}-select-all-checkbox` : undefined}
51
- testid={testid ? `${testid}-select-all-checkbox` : undefined}
52
- checked={selectedRowIds.length === data.length}
53
- indeterminate={
54
- !!selectedRowIds.length &&
55
- selectedRowIds.length !== data.length
56
- }
57
- onChange={handleRowSelectAll}
58
- />
59
- </div>
60
- )}
61
- <Stack
62
- horizontal
63
- horizontalMobile
64
- items="center"
65
- sizing="component"
66
- padding
67
- >
68
- <Heading3 as="span" color="text-primary-normal">
69
- {typeof Header === "string"
70
- ? Header
71
- : columns
72
- .find((col) => col.id === primaryKey)
73
- ?.header?.toString()}
74
- </Heading3>
75
- </Stack>
76
- {enableColumnSelector && <ColumnSelector />}
77
- </Stack>
78
- </Theme>
79
- </div>
80
- );
81
- }
@@ -1,42 +0,0 @@
1
- import { Paragraph } from "../../Paragraph";
2
- import { Stack } from "../../Stack";
3
- import { useGridContext } from "../GridContextProvider/useGridContext";
4
- import { MobileDataGridColumn } from "../MobileDataGridCard/MobileDataGridColumn";
5
-
6
- export function ModalContent() {
7
- const context = useGridContext<Record<string, unknown>>();
8
- const { columns, currentRow } = context;
9
-
10
- if (!currentRow) return null;
11
- return (
12
- <Stack sizing="layout-group">
13
- {columns
14
- .filter((x) => !x.id?.startsWith("__"))
15
- .map((column, index) =>
16
- column.meta?.useCustomRenderer &&
17
- column.meta.mobileCell &&
18
- column.id ? (
19
- <div
20
- key={`${column.id}-${index}`}
21
- className="grid grid-cols-2 gap-2 items-center flex-1"
22
- >
23
- <Paragraph color="text-secondary-normal" className="text-left">
24
- {column.header?.toString()}:
25
- </Paragraph>{" "}
26
- <column.meta.mobileCell
27
- column={column}
28
- row={currentRow}
29
- cellValue={currentRow?.[column.id as string]}
30
- />
31
- </div>
32
- ) : (
33
- <MobileDataGridColumn
34
- key={`${column.id}-${index}`}
35
- column={column}
36
- data={currentRow}
37
- />
38
- ),
39
- )}
40
- </Stack>
41
- );
42
- }
@@ -1,68 +0,0 @@
1
- import { Button } from "../../Button";
2
- import { Heading2 } from "../../Heading";
3
- import { Icon } from "../../Icon";
4
- import { Modal } from "../../Modal";
5
- import { Stack } from "../../Stack";
6
- import { useGridContext } from "../GridContextProvider/useGridContext";
7
- import { ModalContent } from "./ModalContent";
8
-
9
- export function RowDetailModalProvider() {
10
- const context = useGridContext<Record<string, unknown>>();
11
- const {
12
- id,
13
- testid,
14
- isRowDetailOpen,
15
- currentRow,
16
- primaryKey,
17
- closeRowDetail,
18
- } = context;
19
-
20
- // TODO: implement modal UI later
21
- // Also verify if modal is opening in orders screen.doesn't seem to work in storybooks
22
- return (
23
- <Modal
24
- fixedHeightScrolling
25
- open={isRowDetailOpen}
26
- onClose={closeRowDetail}
27
- hideCloseIcon
28
- size="medium"
29
- className="!p-0"
30
- headerIcon={
31
- <Stack
32
- horizontal
33
- horizontalMobile
34
- items="center"
35
- justify="between"
36
- width="full"
37
- >
38
- <Heading2>
39
- {(currentRow?.[primaryKey ?? "id"] as string | undefined) ??
40
- "Grid Detail"}
41
- </Heading2>
42
- <Button
43
- id={id ? `${id}-open-in-new-button` : undefined}
44
- testid={testid ? `${testid}-open-in-new-button` : undefined}
45
- iconOnly
46
- variant="tertiary"
47
- onClick={closeRowDetail}
48
- leftIcon={
49
- <span className="text-icon-primary-normal contents">
50
- <Icon name="open_in_new" size={24} />
51
- </span>
52
- }
53
- />
54
- </Stack>
55
- }
56
- customActions={
57
- <Button onClick={closeRowDetail} className="w-full">
58
- Close
59
- </Button>
60
- }
61
- showButtons
62
- >
63
- <div className="bg-white max-h-full flex flex-col flex-grow-1">
64
- <ModalContent />
65
- </div>
66
- </Modal>
67
- );
68
- }
@@ -1,55 +0,0 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
-
3
- export type Action<T> =
4
- | {
5
- payload: ColumnDef<T>[];
6
- type: "SET";
7
- }
8
- | {
9
- type: "INSERT";
10
- pos: "LEADING" | "TRAILING";
11
- payload: ColumnDef<T>;
12
- }
13
- | { type: "INSERT"; pos: "INDEX"; index: number; payload: ColumnDef<T> }
14
- | {
15
- type: "UPDATE";
16
- index?: number;
17
- id?: string | number;
18
- payload: Partial<ColumnDef<T>>;
19
- };
20
- export function dataGridReducer<T>(
21
- state: ColumnDef<T>[],
22
- action: Action<T>,
23
- ): ColumnDef<T>[] {
24
- const { type, payload } = action;
25
-
26
- let itemIndex: number | null = null;
27
- if (action.type === "INSERT" && action.pos === "INDEX")
28
- itemIndex = action.index;
29
- if (action.type === "UPDATE")
30
- itemIndex =
31
- action.index ??
32
- state.filter(({ id }) => !!id).findIndex(({ id }) => id === action.id);
33
- switch (type) {
34
- case "SET":
35
- return [...payload];
36
- case "UPDATE":
37
- if (typeof itemIndex !== "number" || itemIndex < 0)
38
- throw new Error("action.(id | index) must be provided.");
39
-
40
- return [
41
- ...state.slice(0, itemIndex),
42
- {
43
- ...state[itemIndex],
44
- ...payload,
45
- meta: {
46
- ...(state[itemIndex].meta ?? {}),
47
- ...(payload.meta ?? {}),
48
- },
49
- },
50
- ...state.slice(itemIndex + 1),
51
- ] as ColumnDef<T>[];
52
- default:
53
- throw new Error("Action type not implemented.");
54
- }
55
- }