@dmsi/wedgekit-react 0.0.550 → 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.
- package/dist/{chunk-U3QGZAVS.js → chunk-JADOJNBI.js} +4 -4
- package/dist/{chunk-N2KPADIL.js → chunk-WNGFRQ4Y.js} +7 -7
- package/dist/{chunk-ZVY3TLXL.js → chunk-ZIPJMN2E.js} +4 -4
- package/dist/components/Alert.js +2 -2
- package/dist/components/CalendarRange.js +10 -10
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +10 -10
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +10 -10
- package/dist/components/DataGrid/PinnedColumns.js +10 -10
- package/dist/components/DataGrid/TableBody/LoadingCell.js +10 -10
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +10 -10
- package/dist/components/DataGrid/TableBody/index.js +10 -10
- package/dist/components/DataGrid/index.js +10 -10
- package/dist/components/DataGrid/utils.js +10 -10
- package/dist/components/DateInput.js +10 -10
- package/dist/components/DateRangeInput.js +10 -10
- package/dist/components/FilterGroup.js +5 -5
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +10 -10
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +10 -10
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +5 -5
- package/dist/components/MobileDataGrid/index.js +10 -10
- package/dist/components/Modal.js +4 -4
- package/dist/components/ModalButtons.js +2 -2
- package/dist/components/ModalHeader.js +2 -2
- package/dist/components/NavigationTab.js +2 -2
- package/dist/components/NavigationTabs.js +2 -2
- package/dist/components/NestedMenu.js +3 -3
- package/dist/components/Notification.js +3 -3
- package/dist/components/OptionPill.js +2 -2
- package/dist/components/PDFViewer/DownloadIcon.js +2 -2
- package/dist/components/PDFViewer/PDFNavigation.js +2 -2
- package/dist/components/PDFViewer/index.js +6 -6
- package/dist/components/ProductImagePreview/index.js +1 -1
- package/dist/components/Stepper.js +3 -3
- package/dist/components/Toast.js +3 -3
- package/dist/components/Upload.js +3 -3
- package/dist/components/index.js +16 -16
- package/package.json +8 -9
- package/src/brand.css +0 -125
- package/src/classNames.ts +0 -174
- package/src/components/AccessChangerTabItem.tsx +0 -71
- package/src/components/Accordion.tsx +0 -108
- package/src/components/Alert.tsx +0 -81
- package/src/components/Breadcrumbs.tsx +0 -142
- package/src/components/Button.tsx +0 -216
- package/src/components/CalendarRange.tsx +0 -628
- package/src/components/Caption.tsx +0 -144
- package/src/components/Card.tsx +0 -88
- package/src/components/Checkbox.tsx +0 -206
- package/src/components/CompactImagesPreview.tsx +0 -135
- package/src/components/ContentTab.tsx +0 -84
- package/src/components/ContentTabs.tsx +0 -136
- package/src/components/DMSiLogo.tsx +0 -33
- package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +0 -35
- package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +0 -74
- package/src/components/DataGrid/PinnedColumns.tsx +0 -183
- package/src/components/DataGrid/TableBody/LoadingCell.tsx +0 -44
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -157
- package/src/components/DataGrid/TableBody/index.tsx +0 -185
- package/src/components/DataGrid/index.tsx +0 -756
- package/src/components/DataGrid/types.ts +0 -98
- package/src/components/DataGrid/utils.tsx +0 -15
- package/src/components/DataGridCell.tsx +0 -526
- package/src/components/DataTable.tsx +0 -881
- package/src/components/DateInput.tsx +0 -306
- package/src/components/DateRangeInput.tsx +0 -758
- package/src/components/DebugJson.tsx +0 -28
- package/src/components/Display.tsx +0 -66
- package/src/components/EditingContext.tsx +0 -43
- package/src/components/EmptyCartIcon.tsx +0 -18
- package/src/components/FilterGroup.tsx +0 -264
- package/src/components/FullViewportBox.tsx +0 -19
- package/src/components/Grid.tsx +0 -97
- package/src/components/Heading.tsx +0 -72
- package/src/components/HorizontalDivider.tsx +0 -22
- package/src/components/Icon.tsx +0 -39
- package/src/components/ImagePlaceholder.tsx +0 -22
- package/src/components/Input.tsx +0 -609
- package/src/components/InputGroup.tsx +0 -59
- package/src/components/Label.tsx +0 -46
- package/src/components/Link.tsx +0 -117
- package/src/components/List.tsx +0 -18
- package/src/components/ListGroup.tsx +0 -82
- package/src/components/LiveChatComponent.tsx +0 -56
- package/src/components/LoadingScrim.tsx +0 -33
- package/src/components/LogoAgilityTopBar.tsx +0 -54
- package/src/components/LogoDMSiTopBar.tsx +0 -33
- package/src/components/LogoMillworkTopBar.tsx +0 -119
- package/src/components/MainBar.tsx +0 -91
- package/src/components/MaxViewportBox.tsx +0 -19
- package/src/components/Menu.tsx +0 -316
- package/src/components/MenuOption.tsx +0 -330
- package/src/components/MobileDataGrid/ColumnList.tsx +0 -66
- package/src/components/MobileDataGrid/ColumnSelector/index.tsx +0 -97
- package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +0 -25
- package/src/components/MobileDataGrid/GridContextProvider/index.tsx +0 -132
- package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +0 -10
- package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +0 -27
- package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +0 -138
- package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +0 -81
- package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +0 -42
- package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +0 -68
- package/src/components/MobileDataGrid/dataGridReducer.ts +0 -55
- package/src/components/MobileDataGrid/index.tsx +0 -92
- package/src/components/MobileDataGrid/types.ts +0 -4
- package/src/components/Modal.tsx +0 -312
- package/src/components/ModalButtons.tsx +0 -62
- package/src/components/ModalContent.tsx +0 -31
- package/src/components/ModalHeader.tsx +0 -78
- package/src/components/ModalScrim.tsx +0 -42
- package/src/components/NavigationTab.tsx +0 -95
- package/src/components/NavigationTabs.tsx +0 -70
- package/src/components/NestedMenu.tsx +0 -131
- package/src/components/Notification.tsx +0 -128
- package/src/components/OptionPill.tsx +0 -139
- package/src/components/OrderCheckIcon.tsx +0 -19
- package/src/components/PDFViewer/DownloadIcon.tsx +0 -25
- package/src/components/PDFViewer/PDFElement.tsx +0 -90
- package/src/components/PDFViewer/PDFNavigation.tsx +0 -68
- package/src/components/PDFViewer/PDFPage.tsx +0 -34
- package/src/components/PDFViewer/index.tsx +0 -128
- package/src/components/Pagination.tsx +0 -182
- package/src/components/Paragraph.tsx +0 -55
- package/src/components/Password.tsx +0 -62
- package/src/components/ProductImagePreview/CarouselPagination.tsx +0 -54
- package/src/components/ProductImagePreview/MobileImageCarousel.tsx +0 -226
- package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +0 -219
- package/src/components/ProductImagePreview/Thumbnail.tsx +0 -55
- package/src/components/ProductImagePreview/ZoomWindow.tsx +0 -136
- package/src/components/ProductImagePreview/index.tsx +0 -182
- package/src/components/ProductImagePreview/useProductImagePreview.ts +0 -211
- package/src/components/ProjectBar.tsx +0 -82
- package/src/components/Radio.tsx +0 -146
- package/src/components/Search.tsx +0 -152
- package/src/components/SearchResultImage/index.tsx +0 -39
- package/src/components/Select.tsx +0 -114
- package/src/components/SideMenu.tsx +0 -30
- package/src/components/SideMenuGroup.tsx +0 -95
- package/src/components/SideMenuItem.tsx +0 -109
- package/src/components/SimpleTable.tsx +0 -77
- package/src/components/SkeletonParagraph.tsx +0 -31
- package/src/components/Spinner.tsx +0 -32
- package/src/components/Stack.tsx +0 -347
- package/src/components/StatusPill.tsx +0 -59
- package/src/components/Stepper.tsx +0 -128
- package/src/components/Subheader.tsx +0 -50
- package/src/components/Surface.tsx +0 -37
- package/src/components/Swatch.tsx +0 -1341
- package/src/components/Textarea.tsx +0 -102
- package/src/components/Theme.tsx +0 -27
- package/src/components/Time.tsx +0 -460
- package/src/components/Toast.tsx +0 -268
- package/src/components/Tooltip.tsx +0 -159
- package/src/components/TopBar.tsx +0 -139
- package/src/components/Upload.tsx +0 -107
- package/src/components/WorldpayIframe.tsx +0 -7
- package/src/components/index.ts +0 -34
- package/src/components/useMenuSystem.tsx +0 -456
- package/src/components/useMounted.tsx +0 -14
- package/src/darkmode.css +0 -278
- package/src/fonts.css +0 -23
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useInfiniteScroll.tsx +0 -40
- package/src/hooks/useKeydown.ts +0 -42
- package/src/hooks/useMatchesMedia.ts +0 -18
- package/src/hooks/useTableLayout.ts +0 -106
- package/src/index.css +0 -800
- package/src/index.tsx +0 -5
- package/src/types.ts +0 -150
- package/src/utils/date.ts +0 -236
- package/src/utils/formatting.tsx +0 -81
- package/src/utils/index.ts +0 -4
- package/src/utils/mergeObjectArrays.ts +0 -18
- package/src/utils.ts +0 -24
- package/dist/{chunk-7FQ7PGUF.js → chunk-7COWXCPA.js} +3 -3
- package/dist/{chunk-NKCFYM7A.js → chunk-7SFFUICM.js} +3 -3
- package/dist/{chunk-25RZP3VR.js → chunk-AKJUBFJK.js} +3 -3
- package/dist/{chunk-TAPYQBQU.js → chunk-CMMQTIVM.js} +3 -3
- package/dist/{chunk-GYEXSNFP.js → chunk-FWCVZWE6.js} +3 -3
- package/dist/{chunk-MV6W7OMC.js → chunk-QMMPHXVE.js} +3 -3
- package/dist/{chunk-GG5OZTI5.js → chunk-XRE52QTN.js} +3 -3
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
2
|
-
import { MobileDataGridHeader } from "./MobileDataGridHeader";
|
|
3
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
4
|
-
import { GridContextProvider } from "./GridContextProvider";
|
|
5
|
-
import { RowDetailModalProvider } from "./RowDetailModalProvider";
|
|
6
|
-
import { GridContextType } from "./GridContextProvider/GridContext";
|
|
7
|
-
import { ColumnList } from "./ColumnList";
|
|
8
|
-
import { Stack } from "../Stack";
|
|
9
|
-
import { RowActions, RowData } from "./types";
|
|
10
|
-
|
|
11
|
-
export type MobileDataGridProps<T> = {
|
|
12
|
-
columns: ColumnDef<T>[];
|
|
13
|
-
data: T[];
|
|
14
|
-
header?: string | ((ctx: GridContextType<T>) => React.ReactNode);
|
|
15
|
-
getId: (data: T) => string | number | undefined;
|
|
16
|
-
renderLink?: (data: T) => React.ReactNode;
|
|
17
|
-
primaryKey: keyof T;
|
|
18
|
-
id?: string;
|
|
19
|
-
testid?: string;
|
|
20
|
-
enableColumnSelector?: boolean;
|
|
21
|
-
enableRowSelection?: boolean;
|
|
22
|
-
onRowSelect?: (row: T, selectedIds: (string | number)[]) => void;
|
|
23
|
-
withBorder?: boolean;
|
|
24
|
-
footer?: (ctx: GridContextType<T>) => React.ReactNode;
|
|
25
|
-
numberOfColumnsToShow?: number;
|
|
26
|
-
renderChevron?: boolean;
|
|
27
|
-
hideHeader?: boolean;
|
|
28
|
-
rowActions?: RowActions<T>;
|
|
29
|
-
rounded?: boolean;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export function MobileDataGrid<T extends RowData>(
|
|
33
|
-
props: MobileDataGridProps<T> & ComponentProps<"div">,
|
|
34
|
-
) {
|
|
35
|
-
const {
|
|
36
|
-
columns,
|
|
37
|
-
data,
|
|
38
|
-
renderLink,
|
|
39
|
-
renderChevron,
|
|
40
|
-
getId,
|
|
41
|
-
id,
|
|
42
|
-
testid,
|
|
43
|
-
enableColumnSelector,
|
|
44
|
-
enableRowSelection,
|
|
45
|
-
header,
|
|
46
|
-
withBorder = true,
|
|
47
|
-
footer,
|
|
48
|
-
onRowSelect,
|
|
49
|
-
numberOfColumnsToShow,
|
|
50
|
-
primaryKey,
|
|
51
|
-
hideHeader,
|
|
52
|
-
rowActions,
|
|
53
|
-
rounded,
|
|
54
|
-
} = props;
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<GridContextProvider<T>
|
|
58
|
-
initialColumns={columns}
|
|
59
|
-
id={id}
|
|
60
|
-
testid={testid}
|
|
61
|
-
data={data}
|
|
62
|
-
getId={getId}
|
|
63
|
-
onRowSelect={onRowSelect}
|
|
64
|
-
numberOfColumnsToShow={numberOfColumnsToShow}
|
|
65
|
-
primaryKey={primaryKey}
|
|
66
|
-
>
|
|
67
|
-
<Stack
|
|
68
|
-
height="full"
|
|
69
|
-
rounded={rounded}
|
|
70
|
-
overflowX="hidden"
|
|
71
|
-
overflowY="hidden"
|
|
72
|
-
>
|
|
73
|
-
{!hideHeader && (
|
|
74
|
-
<MobileDataGridHeader<T>
|
|
75
|
-
header={header}
|
|
76
|
-
enableColumnSelector={enableColumnSelector}
|
|
77
|
-
enableRowSelection={enableRowSelection}
|
|
78
|
-
/>
|
|
79
|
-
)}
|
|
80
|
-
<ColumnList<T>
|
|
81
|
-
withBorder={withBorder}
|
|
82
|
-
renderLink={renderLink}
|
|
83
|
-
renderChevron={renderChevron}
|
|
84
|
-
enableRowSelection={enableRowSelection}
|
|
85
|
-
footer={footer}
|
|
86
|
-
rowActions={rowActions}
|
|
87
|
-
/>
|
|
88
|
-
</Stack>
|
|
89
|
-
<RowDetailModalProvider />
|
|
90
|
-
</GridContextProvider>
|
|
91
|
-
);
|
|
92
|
-
}
|
package/src/components/Modal.tsx
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { PropsWithChildren, useCallback, useEffect, useRef } from "react";
|
|
5
|
-
import { ModalHeader } from "./ModalHeader";
|
|
6
|
-
import { ModalContent } from "./ModalContent";
|
|
7
|
-
import { ModalButtons } from "./ModalButtons";
|
|
8
|
-
import { ModalScrim } from "./ModalScrim";
|
|
9
|
-
import { createPortal } from "react-dom";
|
|
10
|
-
import { findDocumentRoot } from "../utils";
|
|
11
|
-
import { usePrevious } from "react-use";
|
|
12
|
-
import { useMatchesMobile } from "../hooks";
|
|
13
|
-
import { useMounted } from "./useMounted";
|
|
14
|
-
|
|
15
|
-
type ModalProps = PropsWithChildren<{
|
|
16
|
-
id?: string;
|
|
17
|
-
testid?: string;
|
|
18
|
-
title?: string;
|
|
19
|
-
open?: boolean;
|
|
20
|
-
size?: "small" | "medium" | "large" | "x-large" | "screen";
|
|
21
|
-
className?: string;
|
|
22
|
-
onClose?: () => void;
|
|
23
|
-
onContinue?: () => void;
|
|
24
|
-
closeOnBackdropClick?: boolean;
|
|
25
|
-
showButtons?: boolean;
|
|
26
|
-
hideCloseIcon?: boolean;
|
|
27
|
-
headerIcon?: React.ReactNode;
|
|
28
|
-
headerIconAlign?: "left" | "center" | "right";
|
|
29
|
-
fixedHeightScrolling?: boolean;
|
|
30
|
-
customActions?: React.ReactNode;
|
|
31
|
-
headerClassname?: string;
|
|
32
|
-
backgroundColor?: string; // full twcss color with bg- prefix
|
|
33
|
-
noWrapper?: boolean;
|
|
34
|
-
customFooter?: boolean;
|
|
35
|
-
titleAs?: React.ComponentType<{ children: React.ReactNode }>;
|
|
36
|
-
}>;
|
|
37
|
-
|
|
38
|
-
const fadeInScale = (element: HTMLElement, duration = 300) =>
|
|
39
|
-
element.animate(
|
|
40
|
-
[
|
|
41
|
-
{ opacity: 0, transform: "scale(0.95)" },
|
|
42
|
-
{ opacity: 1, transform: "scale(1)" },
|
|
43
|
-
],
|
|
44
|
-
{
|
|
45
|
-
duration,
|
|
46
|
-
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
47
|
-
fill: "both",
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const fadeOutScale = (element: HTMLElement, duration = 200) =>
|
|
52
|
-
element.animate(
|
|
53
|
-
[
|
|
54
|
-
{ opacity: 1, transform: "scale(1)" },
|
|
55
|
-
{ opacity: 0, transform: "scale(0.95)" },
|
|
56
|
-
],
|
|
57
|
-
{
|
|
58
|
-
duration,
|
|
59
|
-
easing: "ease-in-out",
|
|
60
|
-
fill: "both",
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const bgFadeIn = (element: HTMLElement, duration = 300) =>
|
|
65
|
-
element.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
66
|
-
duration,
|
|
67
|
-
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
68
|
-
fill: "both",
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const bgFadeOut = (element: HTMLElement, duration = 200) =>
|
|
72
|
-
element.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
73
|
-
duration,
|
|
74
|
-
easing: "ease-in-out",
|
|
75
|
-
fill: "both",
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const whenAllAnimationsFinish = (
|
|
79
|
-
animations: Animation[],
|
|
80
|
-
callback: () => void,
|
|
81
|
-
) => {
|
|
82
|
-
let finishedCount = 0;
|
|
83
|
-
|
|
84
|
-
animations.forEach((animation) => {
|
|
85
|
-
animation.onfinish = () => {
|
|
86
|
-
finishedCount += 1;
|
|
87
|
-
if (finishedCount === animations.length) {
|
|
88
|
-
callback();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const sizes = {
|
|
95
|
-
small: {
|
|
96
|
-
sizeClass: "max-h-screen desktop:max-w-120 rounded-sm",
|
|
97
|
-
},
|
|
98
|
-
medium: {
|
|
99
|
-
sizeClass:
|
|
100
|
-
"desktop:max-w-180 w-screen desktop:h-fit h-screen desktop:w-full max-w-240",
|
|
101
|
-
},
|
|
102
|
-
large: {
|
|
103
|
-
sizeClass:
|
|
104
|
-
"desktop:max-w-240 w-screen desktop:h-fit h-screen desktop:w-full max-w-240",
|
|
105
|
-
},
|
|
106
|
-
"x-large": {
|
|
107
|
-
sizeClass:
|
|
108
|
-
"desktop:max-w-300 w-screen desktop:h-fit h-screen desktop:w-full max-w-240",
|
|
109
|
-
},
|
|
110
|
-
screen: {
|
|
111
|
-
sizeClass: "w-screen h-screen max-w-screen !rounded-none",
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const Modal = ({
|
|
116
|
-
id,
|
|
117
|
-
testid,
|
|
118
|
-
title,
|
|
119
|
-
open = false,
|
|
120
|
-
size = "small",
|
|
121
|
-
className,
|
|
122
|
-
children,
|
|
123
|
-
onClose,
|
|
124
|
-
onContinue,
|
|
125
|
-
closeOnBackdropClick = true,
|
|
126
|
-
showButtons = false,
|
|
127
|
-
hideCloseIcon = false,
|
|
128
|
-
headerIcon,
|
|
129
|
-
headerIconAlign,
|
|
130
|
-
fixedHeightScrolling = false,
|
|
131
|
-
customActions,
|
|
132
|
-
headerClassname,
|
|
133
|
-
customFooter,
|
|
134
|
-
noWrapper,
|
|
135
|
-
titleAs: TitleComponent,
|
|
136
|
-
}: ModalProps) => {
|
|
137
|
-
const mounted = useMounted();
|
|
138
|
-
|
|
139
|
-
const modalRef = useRef<HTMLDivElement>(null);
|
|
140
|
-
const bgRef = useRef<HTMLDivElement>(null);
|
|
141
|
-
|
|
142
|
-
const wasOpen = usePrevious(open);
|
|
143
|
-
|
|
144
|
-
const isMobile = useMatchesMobile();
|
|
145
|
-
|
|
146
|
-
const computedFixedHeightScrolling = isMobile || fixedHeightScrolling;
|
|
147
|
-
|
|
148
|
-
useEffect(() => {
|
|
149
|
-
if (!mounted) return;
|
|
150
|
-
if (!modalRef.current || !bgRef.current) {
|
|
151
|
-
console.error("Modal or background reference is not set.");
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (wasOpen === undefined) return;
|
|
155
|
-
if (wasOpen && !open) {
|
|
156
|
-
const modalAnimation = fadeOutScale(modalRef.current);
|
|
157
|
-
const bgAnimation = bgFadeOut(bgRef.current);
|
|
158
|
-
whenAllAnimationsFinish([modalAnimation, bgAnimation], () => {
|
|
159
|
-
if (onClose) {
|
|
160
|
-
onClose();
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
} else if (!wasOpen && open) {
|
|
164
|
-
fadeInScale(modalRef.current);
|
|
165
|
-
bgFadeIn(bgRef.current);
|
|
166
|
-
}
|
|
167
|
-
}, [mounted, onClose, open, wasOpen]);
|
|
168
|
-
|
|
169
|
-
const handleKeyDown = useCallback(
|
|
170
|
-
(e: KeyboardEvent) => {
|
|
171
|
-
if (e.key === "Escape") {
|
|
172
|
-
if (onClose) {
|
|
173
|
-
e.preventDefault();
|
|
174
|
-
onClose();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
[onClose],
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const handleClose = useCallback(() => {
|
|
182
|
-
if (onClose) {
|
|
183
|
-
onClose();
|
|
184
|
-
}
|
|
185
|
-
}, [onClose]);
|
|
186
|
-
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (open) {
|
|
189
|
-
document.addEventListener("keyup", handleKeyDown);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return () => {
|
|
193
|
-
document.removeEventListener("keyup", handleKeyDown);
|
|
194
|
-
};
|
|
195
|
-
}, [open, handleKeyDown]);
|
|
196
|
-
|
|
197
|
-
// Effect to lock scroll when modal is open
|
|
198
|
-
useEffect(() => {
|
|
199
|
-
if (!open) return;
|
|
200
|
-
|
|
201
|
-
const scrollY = window.scrollY;
|
|
202
|
-
const body = document.body;
|
|
203
|
-
|
|
204
|
-
// Lock scroll
|
|
205
|
-
body.style.position = "fixed";
|
|
206
|
-
body.style.top = `-${scrollY}px`;
|
|
207
|
-
body.style.left = "0";
|
|
208
|
-
body.style.right = "0";
|
|
209
|
-
body.style.overflow = "hidden";
|
|
210
|
-
body.style.width = "100%";
|
|
211
|
-
|
|
212
|
-
return () => {
|
|
213
|
-
// Restore scroll
|
|
214
|
-
body.style.position = "";
|
|
215
|
-
body.style.top = "";
|
|
216
|
-
body.style.left = "";
|
|
217
|
-
body.style.right = "";
|
|
218
|
-
body.style.overflow = "";
|
|
219
|
-
body.style.width = "";
|
|
220
|
-
|
|
221
|
-
window.scrollTo(0, scrollY);
|
|
222
|
-
};
|
|
223
|
-
}, [open]);
|
|
224
|
-
|
|
225
|
-
const { sizeClass } = sizes[size] ?? sizes.small;
|
|
226
|
-
|
|
227
|
-
const backgroundClickHandler = useCallback(
|
|
228
|
-
(e: React.MouseEvent<HTMLElement>) => {
|
|
229
|
-
const target = e.target as HTMLElement;
|
|
230
|
-
const currentTarget = e.currentTarget as HTMLElement;
|
|
231
|
-
if (currentTarget.contains(target) && currentTarget !== target) {
|
|
232
|
-
e.stopPropagation();
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (open && closeOnBackdropClick) {
|
|
237
|
-
handleClose();
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
[open, closeOnBackdropClick, handleClose],
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
if (!mounted) {
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return createPortal(
|
|
248
|
-
<ModalScrim
|
|
249
|
-
id={id ? `${id}-scrim` : undefined}
|
|
250
|
-
testid={testid ? `${testid}-scrim` : undefined}
|
|
251
|
-
size={size}
|
|
252
|
-
ref={bgRef}
|
|
253
|
-
show={open}
|
|
254
|
-
onClick={backgroundClickHandler}
|
|
255
|
-
>
|
|
256
|
-
<div
|
|
257
|
-
id={id}
|
|
258
|
-
data-testid={testid}
|
|
259
|
-
ref={modalRef}
|
|
260
|
-
className={clsx(
|
|
261
|
-
"shadow-md rounded-sm flex flex-col overflow-hidden w-full opacity-0 h-fit",
|
|
262
|
-
computedFixedHeightScrolling &&
|
|
263
|
-
size !== "screen" &&
|
|
264
|
-
"desktop:max-h-[calc(100vh-32px)] desktop:h-auto",
|
|
265
|
-
className,
|
|
266
|
-
!className?.includes("bg-") && "bg-white",
|
|
267
|
-
sizeClass,
|
|
268
|
-
)}
|
|
269
|
-
onClick={(e) => e.stopPropagation()}
|
|
270
|
-
>
|
|
271
|
-
<ModalHeader
|
|
272
|
-
id={id ? `${id}-header` : undefined}
|
|
273
|
-
testid={testid ? `${testid}-header` : undefined}
|
|
274
|
-
title={title}
|
|
275
|
-
onClose={handleClose}
|
|
276
|
-
hideCloseIcon={hideCloseIcon}
|
|
277
|
-
headerIcon={headerIcon}
|
|
278
|
-
headerIconAlign={headerIconAlign}
|
|
279
|
-
headerClassname={headerClassname}
|
|
280
|
-
titleAs={TitleComponent}
|
|
281
|
-
/>
|
|
282
|
-
{children && (size !== "screen" || noWrapper) ? (
|
|
283
|
-
<ModalContent
|
|
284
|
-
id={id ? `${id}-content` : undefined}
|
|
285
|
-
testid={testid ? `${testid}-content` : undefined}
|
|
286
|
-
fixedHeightScrolling={computedFixedHeightScrolling}
|
|
287
|
-
>
|
|
288
|
-
{children}
|
|
289
|
-
</ModalContent>
|
|
290
|
-
) : (
|
|
291
|
-
children
|
|
292
|
-
)}
|
|
293
|
-
{showButtons ? (
|
|
294
|
-
customFooter ? (
|
|
295
|
-
customActions
|
|
296
|
-
) : (
|
|
297
|
-
<ModalButtons
|
|
298
|
-
id={id ? `${id}-buttons` : undefined}
|
|
299
|
-
testid={testid ? `${testid}-buttons` : undefined}
|
|
300
|
-
onClose={handleClose}
|
|
301
|
-
onContinue={onContinue}
|
|
302
|
-
customActions={customActions}
|
|
303
|
-
/>
|
|
304
|
-
)
|
|
305
|
-
) : null}
|
|
306
|
-
</div>
|
|
307
|
-
</ModalScrim>,
|
|
308
|
-
findDocumentRoot(bgRef.current),
|
|
309
|
-
);
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
Modal.displayName = "Modal";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { Button } from "./Button";
|
|
3
|
-
import { Icon } from "./Icon";
|
|
4
|
-
import { layoutGroupGap, layoutPaddding } from "../classNames";
|
|
5
|
-
|
|
6
|
-
type ModalButtonsProps = {
|
|
7
|
-
title?: string;
|
|
8
|
-
onClose?: () => void;
|
|
9
|
-
onContinue?: () => void;
|
|
10
|
-
sampleWidth?: boolean;
|
|
11
|
-
customActions?: React.ReactNode;
|
|
12
|
-
id?: string;
|
|
13
|
-
testid?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const ModalButtons = ({
|
|
17
|
-
onClose,
|
|
18
|
-
onContinue,
|
|
19
|
-
customActions,
|
|
20
|
-
id,
|
|
21
|
-
testid,
|
|
22
|
-
}: ModalButtonsProps) => {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
id={id}
|
|
26
|
-
data-testid={testid}
|
|
27
|
-
className={clsx(
|
|
28
|
-
"border-t border-neutral-300 flex justify-end",
|
|
29
|
-
layoutPaddding,
|
|
30
|
-
layoutGroupGap,
|
|
31
|
-
)}
|
|
32
|
-
>
|
|
33
|
-
{customActions ?? (
|
|
34
|
-
<>
|
|
35
|
-
<Button
|
|
36
|
-
id={id ? `${id}-close-button` : undefined}
|
|
37
|
-
testid={testid ? `${testid}-close-button` : undefined}
|
|
38
|
-
variant="secondary"
|
|
39
|
-
leftIcon={<Icon name="close" size={24} />}
|
|
40
|
-
onClick={onClose}
|
|
41
|
-
className="max-sm:w-full"
|
|
42
|
-
>
|
|
43
|
-
Close
|
|
44
|
-
</Button>
|
|
45
|
-
|
|
46
|
-
<Button
|
|
47
|
-
id={id ? `${id}-continue-button` : undefined}
|
|
48
|
-
testid={testid ? `${testid}-continue-button` : undefined}
|
|
49
|
-
variant="primary"
|
|
50
|
-
leftIcon={<Icon name="check" size={24} />}
|
|
51
|
-
className="max-sm:w-full"
|
|
52
|
-
onClick={onContinue} // Assuming you want to close the modal on continue
|
|
53
|
-
>
|
|
54
|
-
Continue
|
|
55
|
-
</Button>
|
|
56
|
-
</>
|
|
57
|
-
)}
|
|
58
|
-
</div>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
ModalButtons.displayName = "ModalButtons";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { layoutPaddding } from "../classNames";
|
|
3
|
-
|
|
4
|
-
export interface ModalContentProps {
|
|
5
|
-
fixedHeightScrolling?: boolean;
|
|
6
|
-
id?: string;
|
|
7
|
-
testid?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function ModalContent({
|
|
11
|
-
fixedHeightScrolling,
|
|
12
|
-
children,
|
|
13
|
-
id,
|
|
14
|
-
testid
|
|
15
|
-
}: React.PropsWithChildren<ModalContentProps>) {
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
id={id}
|
|
19
|
-
data-testid={testid}
|
|
20
|
-
className={clsx(
|
|
21
|
-
"flex-grow desktop:flex-grow-0",
|
|
22
|
-
layoutPaddding,
|
|
23
|
-
fixedHeightScrolling && "overflow-auto",
|
|
24
|
-
)}
|
|
25
|
-
>
|
|
26
|
-
{children}
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
ModalContent.displayName = "ModalContent";
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Heading2 } from "./Heading";
|
|
2
|
-
|
|
3
|
-
import { Button } from "./Button";
|
|
4
|
-
import { Icon } from "./Icon";
|
|
5
|
-
import { layoutGroupGap, layoutPaddding } from "../classNames";
|
|
6
|
-
import clsx from "clsx";
|
|
7
|
-
|
|
8
|
-
type ModalHeaderProps = {
|
|
9
|
-
title?: string;
|
|
10
|
-
hideCloseIcon?: boolean;
|
|
11
|
-
headerIcon?: React.ReactNode;
|
|
12
|
-
headerIconAlign?: "left" | "center" | "right";
|
|
13
|
-
onClose?: () => void;
|
|
14
|
-
id?: string;
|
|
15
|
-
testid?: string;
|
|
16
|
-
headerClassname?: string;
|
|
17
|
-
titleAs?: React.ComponentType<{ children: React.ReactNode }>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const ModalHeader = ({
|
|
21
|
-
title,
|
|
22
|
-
hideCloseIcon,
|
|
23
|
-
headerIcon,
|
|
24
|
-
headerIconAlign,
|
|
25
|
-
onClose,
|
|
26
|
-
id,
|
|
27
|
-
testid,
|
|
28
|
-
headerClassname,
|
|
29
|
-
titleAs: TitleComponent,
|
|
30
|
-
}: ModalHeaderProps) => {
|
|
31
|
-
const Title = TitleComponent || Heading2;
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div
|
|
35
|
-
id={id}
|
|
36
|
-
data-testid={testid}
|
|
37
|
-
className={clsx(
|
|
38
|
-
"flex justify-between items-center",
|
|
39
|
-
headerIconAlign === "center" && "justify-center",
|
|
40
|
-
headerIconAlign === "right" && "justify-end",
|
|
41
|
-
headerIconAlign === "left" && "justify-start",
|
|
42
|
-
layoutPaddding,
|
|
43
|
-
layoutGroupGap,
|
|
44
|
-
headerClassname,
|
|
45
|
-
)}
|
|
46
|
-
>
|
|
47
|
-
<div className={clsx("flex items-center flex-1", layoutGroupGap)}>
|
|
48
|
-
{headerIcon}
|
|
49
|
-
{title && (
|
|
50
|
-
<Title
|
|
51
|
-
id={id ? `${id}-title` : undefined}
|
|
52
|
-
testid={testid ? `${testid}-title` : undefined}
|
|
53
|
-
as="p"
|
|
54
|
-
>
|
|
55
|
-
{title}
|
|
56
|
-
</Title>
|
|
57
|
-
)}
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
{!hideCloseIcon && (
|
|
61
|
-
<Button
|
|
62
|
-
id={id ? `${id}-close-button` : undefined}
|
|
63
|
-
testid={testid ? `${testid}-close-button` : undefined}
|
|
64
|
-
iconOnly
|
|
65
|
-
variant="tertiary"
|
|
66
|
-
onClick={onClose}
|
|
67
|
-
leftIcon={
|
|
68
|
-
<span className="text-brand-text-action-primary-normal desktop:text-icon-primary-normal contents">
|
|
69
|
-
<Icon name="close" size={24} />
|
|
70
|
-
</span>
|
|
71
|
-
}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
ModalHeader.displayName = "ModalHeader";
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
3
|
-
|
|
4
|
-
type ModalScrimProps = PropsWithChildren<{
|
|
5
|
-
sampleWidth?: boolean;
|
|
6
|
-
show?: boolean;
|
|
7
|
-
size?: "small" | "medium" | "large" | "x-large" | "screen";
|
|
8
|
-
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
9
|
-
ref?: React.Ref<HTMLDivElement>;
|
|
10
|
-
id?: string;
|
|
11
|
-
testid?: string;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
export const ModalScrim = ({
|
|
15
|
-
show = false,
|
|
16
|
-
size = "small",
|
|
17
|
-
children,
|
|
18
|
-
onClick,
|
|
19
|
-
ref,
|
|
20
|
-
id,
|
|
21
|
-
testid,
|
|
22
|
-
}: ModalScrimProps) => {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
id={id}
|
|
26
|
-
data-testid={testid}
|
|
27
|
-
className={clsx(
|
|
28
|
-
"overflow-y-auto h-screen transition-[visibility,opacity,background] ease-in-out duration-100 grid place-content-center group bg-neutral-600/50 fixed opacity-0",
|
|
29
|
-
!show && " pointer-events-none",
|
|
30
|
-
size === "small" && "p-4",
|
|
31
|
-
size === "screen" ? "desktop:p-0" : "desktop:p-4",
|
|
32
|
-
"inset-0 z-50",
|
|
33
|
-
)}
|
|
34
|
-
onMouseDown={onClick}
|
|
35
|
-
ref={ref}
|
|
36
|
-
>
|
|
37
|
-
{children}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
ModalScrim.displayName = "ModalScrim";
|