@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,68 +0,0 @@
|
|
|
1
|
-
import { Button } from "../Button";
|
|
2
|
-
import { Heading3 } from "../Heading";
|
|
3
|
-
import { Icon } from "../Icon";
|
|
4
|
-
import { Paragraph } from "../Paragraph";
|
|
5
|
-
import { Stack } from "../Stack";
|
|
6
|
-
|
|
7
|
-
export function PdfNavigation({
|
|
8
|
-
currentIndex,
|
|
9
|
-
total,
|
|
10
|
-
onPrev,
|
|
11
|
-
onNext,
|
|
12
|
-
disablePrev,
|
|
13
|
-
disableNext,
|
|
14
|
-
extraActions,
|
|
15
|
-
testid,
|
|
16
|
-
fileName,
|
|
17
|
-
}: {
|
|
18
|
-
currentIndex: number;
|
|
19
|
-
total: number;
|
|
20
|
-
onPrev: () => void;
|
|
21
|
-
onNext: () => void;
|
|
22
|
-
disablePrev: boolean;
|
|
23
|
-
disableNext: boolean;
|
|
24
|
-
extraActions?: React.ReactNode;
|
|
25
|
-
testid?: string;
|
|
26
|
-
fileName?: string;
|
|
27
|
-
}) {
|
|
28
|
-
// TODO: Bring back horizontalMobile for 1st and 2nd stack after confirming navigation for multi-page/file
|
|
29
|
-
return (
|
|
30
|
-
<div className="w-full">
|
|
31
|
-
<Stack
|
|
32
|
-
horizontal
|
|
33
|
-
items="center"
|
|
34
|
-
justify="between"
|
|
35
|
-
sizing="layout-group"
|
|
36
|
-
testid={testid ? `${testid}-pdf-navigation` : undefined}
|
|
37
|
-
>
|
|
38
|
-
<Stack horizontal items="center">
|
|
39
|
-
<Button
|
|
40
|
-
iconOnly
|
|
41
|
-
variant="tertiary"
|
|
42
|
-
onClick={onPrev}
|
|
43
|
-
leftIcon={<Icon name="chevron_backward" />}
|
|
44
|
-
disabled={disablePrev}
|
|
45
|
-
testid={testid ? `${testid}-pdf-file-previous-button` : undefined}
|
|
46
|
-
/>
|
|
47
|
-
<Heading3 className="text-text-primary-normal whitespace-nowrap">
|
|
48
|
-
{currentIndex + 1} / {total}
|
|
49
|
-
</Heading3>
|
|
50
|
-
<Button
|
|
51
|
-
iconOnly
|
|
52
|
-
variant="tertiary"
|
|
53
|
-
onClick={onNext}
|
|
54
|
-
rightIcon={<Icon name="chevron_forward" />}
|
|
55
|
-
disabled={disableNext}
|
|
56
|
-
testid={testid ? `${testid}-pdf-file-next-button` : undefined}
|
|
57
|
-
/>
|
|
58
|
-
<Paragraph>
|
|
59
|
-
{fileName?.endsWith(".pdf") ? fileName : `${fileName}.pdf`}
|
|
60
|
-
</Paragraph>
|
|
61
|
-
</Stack>
|
|
62
|
-
{extraActions && (
|
|
63
|
-
<div className="flex items-center gap-2">{extraActions}</div>
|
|
64
|
-
)}
|
|
65
|
-
</Stack>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { usePdf } from "@mikecousins/react-pdf";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
|
|
4
|
-
export function PdfPage({
|
|
5
|
-
file,
|
|
6
|
-
pageNumber,
|
|
7
|
-
testid,
|
|
8
|
-
isMobile,
|
|
9
|
-
}: {
|
|
10
|
-
file: string;
|
|
11
|
-
pageNumber: number;
|
|
12
|
-
testid?: string;
|
|
13
|
-
isMobile?: boolean;
|
|
14
|
-
}) {
|
|
15
|
-
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
16
|
-
|
|
17
|
-
const { pdfDocument } = usePdf({
|
|
18
|
-
file,
|
|
19
|
-
page: pageNumber,
|
|
20
|
-
canvasRef,
|
|
21
|
-
workerSrc: "/scripts/pdf.worker.min.mjs",
|
|
22
|
-
scale: isMobile ? 1 : 1.3,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!pdfDocument) return null;
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<canvas
|
|
29
|
-
ref={canvasRef}
|
|
30
|
-
data-testid={testid}
|
|
31
|
-
style={{ width: "100%", height: "auto" }}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useCallback, useState } from "react";
|
|
4
|
-
import { Modal } from "../Modal";
|
|
5
|
-
import { PDFElement } from "./PDFElement";
|
|
6
|
-
import { DownloadIcon } from "./DownloadIcon";
|
|
7
|
-
import { PdfNavigation } from "./PDFNavigation";
|
|
8
|
-
|
|
9
|
-
type PDFViewerProps = {
|
|
10
|
-
isOpen: boolean;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
encodedPdfs: { fileName: string; base64: string }[];
|
|
13
|
-
customActions?: React.ReactNode;
|
|
14
|
-
testid?: string;
|
|
15
|
-
isMobile?: boolean;
|
|
16
|
-
title?: string;
|
|
17
|
-
withPagination?: boolean;
|
|
18
|
-
customFooter?: boolean;
|
|
19
|
-
error?: React.ReactNode;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function PDFViewer(props: PDFViewerProps) {
|
|
23
|
-
const {
|
|
24
|
-
isOpen,
|
|
25
|
-
onClose,
|
|
26
|
-
encodedPdfs,
|
|
27
|
-
customActions,
|
|
28
|
-
testid,
|
|
29
|
-
isMobile,
|
|
30
|
-
title,
|
|
31
|
-
customFooter = false,
|
|
32
|
-
withPagination = true,
|
|
33
|
-
error,
|
|
34
|
-
} = props;
|
|
35
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
36
|
-
const [isDownloading, setIsDownloading] = useState(false);
|
|
37
|
-
|
|
38
|
-
const handleDownload = useCallback(() => {
|
|
39
|
-
setIsDownloading(true);
|
|
40
|
-
const link = document.createElement("a");
|
|
41
|
-
const currentPdf = encodedPdfs[currentIndex];
|
|
42
|
-
if (!currentPdf) {
|
|
43
|
-
setIsDownloading(false);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
link.href = `data:application/pdf;base64,${currentPdf.base64}`;
|
|
47
|
-
link.download = currentPdf.fileName.endsWith(".pdf")
|
|
48
|
-
? currentPdf.fileName
|
|
49
|
-
: `${currentPdf.fileName}.pdf`;
|
|
50
|
-
document.body.appendChild(link);
|
|
51
|
-
link.click();
|
|
52
|
-
document.body.removeChild(link);
|
|
53
|
-
setIsDownloading(false);
|
|
54
|
-
}, [currentIndex, encodedPdfs]);
|
|
55
|
-
|
|
56
|
-
if (!encodedPdfs.length) return null;
|
|
57
|
-
|
|
58
|
-
function handleNextFile() {
|
|
59
|
-
if (currentIndex < encodedPdfs.length - 1) {
|
|
60
|
-
setCurrentIndex((prev) => prev + 1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function handlePreviousFile() {
|
|
65
|
-
if (currentIndex > 0) {
|
|
66
|
-
setCurrentIndex((prev) => prev - 1);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function handleClose() {
|
|
71
|
-
setCurrentIndex(0);
|
|
72
|
-
setIsDownloading(false);
|
|
73
|
-
onClose();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<Modal
|
|
78
|
-
testid={testid}
|
|
79
|
-
open={isOpen}
|
|
80
|
-
customFooter={customFooter}
|
|
81
|
-
onClose={handleClose}
|
|
82
|
-
noWrapper
|
|
83
|
-
showButtons={
|
|
84
|
-
isMobile && customFooter ? !!customActions : !!encodedPdfs.length
|
|
85
|
-
}
|
|
86
|
-
customActions={
|
|
87
|
-
!!encodedPdfs.length && !isMobile && withPagination ? (
|
|
88
|
-
<PdfNavigation
|
|
89
|
-
testid={testid}
|
|
90
|
-
currentIndex={currentIndex}
|
|
91
|
-
total={encodedPdfs.length}
|
|
92
|
-
onPrev={handlePreviousFile}
|
|
93
|
-
onNext={handleNextFile}
|
|
94
|
-
disablePrev={currentIndex === 0}
|
|
95
|
-
disableNext={currentIndex === encodedPdfs.length - 1}
|
|
96
|
-
extraActions={customActions}
|
|
97
|
-
fileName={encodedPdfs[currentIndex].fileName}
|
|
98
|
-
/>
|
|
99
|
-
) : (
|
|
100
|
-
customActions
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
fixedHeightScrolling
|
|
104
|
-
headerIconAlign="right"
|
|
105
|
-
headerIcon={
|
|
106
|
-
!isMobile ? (
|
|
107
|
-
<DownloadIcon
|
|
108
|
-
testid={testid ? `${testid}-download-icon` : undefined}
|
|
109
|
-
onClick={handleDownload}
|
|
110
|
-
isDownloading={isDownloading}
|
|
111
|
-
/>
|
|
112
|
-
) : undefined
|
|
113
|
-
}
|
|
114
|
-
title={
|
|
115
|
-
isMobile ? (title ?? encodedPdfs[currentIndex].fileName) : undefined
|
|
116
|
-
}
|
|
117
|
-
size={isMobile ? "screen" : "large"}
|
|
118
|
-
headerClassname="bg-brand-400 desktop:bg-background-grouped-primary-normal p-mobile-layout-padding text-brand-text-action-primary-normal"
|
|
119
|
-
>
|
|
120
|
-
<PDFElement
|
|
121
|
-
testid={testid}
|
|
122
|
-
b64={encodedPdfs[currentIndex].base64}
|
|
123
|
-
isMobile={isMobile}
|
|
124
|
-
error={error}
|
|
125
|
-
/>
|
|
126
|
-
</Modal>
|
|
127
|
-
);
|
|
128
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from "react";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import { Icon } from "./Icon";
|
|
4
|
-
import { paddingUsingComponentGap } from "../classNames";
|
|
5
|
-
import { Subheader } from "./Subheader";
|
|
6
|
-
|
|
7
|
-
export interface PaginationProps {
|
|
8
|
-
/** Total number of pages (>=1). Component returns null if < 2. */
|
|
9
|
-
totalPages: number;
|
|
10
|
-
/** Current page (1-based, controlled). */
|
|
11
|
-
currentPage: number;
|
|
12
|
-
/** Parent controls state; we just notify desired target page. */
|
|
13
|
-
onPageChange: (page: number) => void;
|
|
14
|
-
id?: string;
|
|
15
|
-
testid?: string;
|
|
16
|
-
className?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const Pagination = ({
|
|
21
|
-
totalPages,
|
|
22
|
-
currentPage,
|
|
23
|
-
onPageChange,
|
|
24
|
-
id,
|
|
25
|
-
testid,
|
|
26
|
-
className,
|
|
27
|
-
disabled,
|
|
28
|
-
}: PaginationProps) => {
|
|
29
|
-
const goTo = useCallback(
|
|
30
|
-
(page: number) => {
|
|
31
|
-
if (disabled) return;
|
|
32
|
-
onPageChange(page);
|
|
33
|
-
},
|
|
34
|
-
[onPageChange, disabled],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const handleKey = (e: React.KeyboardEvent) => {
|
|
38
|
-
if (disabled) return;
|
|
39
|
-
if (e.key === "ArrowLeft") {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
goTo(currentPage - 1);
|
|
42
|
-
} else if (e.key === "ArrowRight") {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
goTo(currentPage + 1);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type PageToken = number | "ellipsis";
|
|
49
|
-
|
|
50
|
-
const pageTokens: PageToken[] = useMemo(() => {
|
|
51
|
-
// If 5 or fewer pages, show all directly
|
|
52
|
-
if (totalPages <= 5) {
|
|
53
|
-
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Build a focused window around current page
|
|
57
|
-
const pages = new Set<number>();
|
|
58
|
-
pages.add(1);
|
|
59
|
-
pages.add(totalPages);
|
|
60
|
-
|
|
61
|
-
if (currentPage <= 3) {
|
|
62
|
-
// Near the start – show first 4 pages
|
|
63
|
-
pages.add(2);
|
|
64
|
-
pages.add(3);
|
|
65
|
-
pages.add(4);
|
|
66
|
-
} else if (currentPage >= totalPages - 2) {
|
|
67
|
-
// Near the end – show last 4 pages
|
|
68
|
-
pages.add(totalPages - 1);
|
|
69
|
-
pages.add(totalPages - 2);
|
|
70
|
-
pages.add(totalPages - 3);
|
|
71
|
-
} else {
|
|
72
|
-
// Middle – show current, one before & one after
|
|
73
|
-
pages.add(currentPage - 1);
|
|
74
|
-
pages.add(currentPage);
|
|
75
|
-
pages.add(currentPage + 1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const sorted = Array.from(pages).sort((a, b) => a - b);
|
|
79
|
-
|
|
80
|
-
const tokens: PageToken[] = [];
|
|
81
|
-
for (let i = 0; i < sorted.length; i++) {
|
|
82
|
-
const value = sorted[i];
|
|
83
|
-
const prev = sorted[i - 1];
|
|
84
|
-
if (i > 0) {
|
|
85
|
-
if (value - prev === 2) {
|
|
86
|
-
// Single gap – include the missing number
|
|
87
|
-
tokens.push(prev + 1);
|
|
88
|
-
} else if (value - prev > 2) {
|
|
89
|
-
// Larger gap – ellipsis
|
|
90
|
-
tokens.push("ellipsis");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
tokens.push(value);
|
|
94
|
-
}
|
|
95
|
-
return tokens;
|
|
96
|
-
}, [totalPages, currentPage]);
|
|
97
|
-
|
|
98
|
-
if (totalPages <= 1) return null;
|
|
99
|
-
|
|
100
|
-
const buttonClass = clsx(
|
|
101
|
-
"cursor-pointer disabled:cursor-default",
|
|
102
|
-
paddingUsingComponentGap,
|
|
103
|
-
"w-8 h-8",
|
|
104
|
-
"flex items-center justify-center",
|
|
105
|
-
"bg-transparent",
|
|
106
|
-
"box-content",
|
|
107
|
-
"hover:bg-background-grouped-secondary-normal",
|
|
108
|
-
"focus:bg-background-grouped-secondary-normal focus:outline-0",
|
|
109
|
-
"disabled:bg-transparent disabled:text-text-action-primary-disabled",
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<nav
|
|
114
|
-
id={id}
|
|
115
|
-
data-testid={testid}
|
|
116
|
-
aria-label="Pagination"
|
|
117
|
-
onKeyDown={handleKey}
|
|
118
|
-
className={clsx(
|
|
119
|
-
"flex items-center",
|
|
120
|
-
"border border-border-primary-normal",
|
|
121
|
-
"bg-background-grouped-primary-normal",
|
|
122
|
-
"rounded-sm",
|
|
123
|
-
className,
|
|
124
|
-
)}
|
|
125
|
-
>
|
|
126
|
-
<button
|
|
127
|
-
disabled={disabled || currentPage <= 1}
|
|
128
|
-
aria-label="Previous page"
|
|
129
|
-
onClick={() => goTo(currentPage - 1)}
|
|
130
|
-
className={clsx(buttonClass, "border-r-1 border-border-primary-normal")}
|
|
131
|
-
>
|
|
132
|
-
<Icon name="keyboard_arrow_left" />
|
|
133
|
-
</button>
|
|
134
|
-
|
|
135
|
-
<ul className={clsx("flex items-center")}>
|
|
136
|
-
{pageTokens.map((token, index) => {
|
|
137
|
-
if (token === "ellipsis") {
|
|
138
|
-
return (
|
|
139
|
-
<li
|
|
140
|
-
key={`ellipsis-${index}`}
|
|
141
|
-
className="w-8 h-8 select-none text-text-action-primary-disabled"
|
|
142
|
-
>
|
|
143
|
-
…
|
|
144
|
-
</li>
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
const selected = token === currentPage;
|
|
148
|
-
return (
|
|
149
|
-
<li key={token}>
|
|
150
|
-
<button
|
|
151
|
-
aria-label={`Page ${token}`}
|
|
152
|
-
aria-current={selected ? "page" : undefined}
|
|
153
|
-
disabled={disabled}
|
|
154
|
-
onClick={() => goTo(token)}
|
|
155
|
-
className={clsx(
|
|
156
|
-
buttonClass,
|
|
157
|
-
selected &&
|
|
158
|
-
"border-x-1 bg-background-grouped-secondary-normal border-border-primary-normal",
|
|
159
|
-
)}
|
|
160
|
-
>
|
|
161
|
-
<Subheader align="center" weight="bold">
|
|
162
|
-
{token}
|
|
163
|
-
</Subheader>
|
|
164
|
-
</button>
|
|
165
|
-
</li>
|
|
166
|
-
);
|
|
167
|
-
})}
|
|
168
|
-
</ul>
|
|
169
|
-
|
|
170
|
-
<button
|
|
171
|
-
disabled={disabled || currentPage >= totalPages}
|
|
172
|
-
aria-label="Next page"
|
|
173
|
-
onClick={() => goTo(currentPage + 1)}
|
|
174
|
-
className={clsx(buttonClass, "border-l-1 border-border-primary-normal")}
|
|
175
|
-
>
|
|
176
|
-
<Icon name="keyboard_arrow_right" />
|
|
177
|
-
</button>
|
|
178
|
-
</nav>
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
Pagination.displayName = "Pagination";
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { componentPaddingXUsingComponentGap, typography } from "../classNames";
|
|
3
|
-
import { AsProps, TextAttributes, TypographyProps } from "../types";
|
|
4
|
-
|
|
5
|
-
type Tags = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "span" | "p";
|
|
6
|
-
|
|
7
|
-
type ParagraphProps = {
|
|
8
|
-
as?: Tags;
|
|
9
|
-
id?: string;
|
|
10
|
-
testid?: string;
|
|
11
|
-
} & AsProps<Tags> &
|
|
12
|
-
TextAttributes &
|
|
13
|
-
TypographyProps;
|
|
14
|
-
|
|
15
|
-
export const Paragraph = ({
|
|
16
|
-
className,
|
|
17
|
-
color,
|
|
18
|
-
padded,
|
|
19
|
-
align = "left",
|
|
20
|
-
tall,
|
|
21
|
-
addOverflow,
|
|
22
|
-
children,
|
|
23
|
-
as = "p",
|
|
24
|
-
id,
|
|
25
|
-
testid,
|
|
26
|
-
...props
|
|
27
|
-
}: ParagraphProps) => {
|
|
28
|
-
const Element = as;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Element
|
|
32
|
-
id={id}
|
|
33
|
-
data-testid={testid}
|
|
34
|
-
{...props}
|
|
35
|
-
className={clsx(
|
|
36
|
-
typography.paragraph,
|
|
37
|
-
className,
|
|
38
|
-
padded && componentPaddingXUsingComponentGap,
|
|
39
|
-
align === "left" && "text-left",
|
|
40
|
-
align === "center" && "text-center",
|
|
41
|
-
align === "right" && "text-right",
|
|
42
|
-
tall && "!leading-6",
|
|
43
|
-
addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden",
|
|
44
|
-
)}
|
|
45
|
-
style={{
|
|
46
|
-
...props.style,
|
|
47
|
-
color: color ? `var(--color-${color})` : undefined,
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
{children}
|
|
51
|
-
</Element>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
Paragraph.displayName = "Paragraph";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { ComponentProps, useState } from "react";
|
|
4
|
-
import { InputBase, InputBaseProps } from "./Input";
|
|
5
|
-
import { Icon } from "./Icon";
|
|
6
|
-
import { Tooltip } from "./Tooltip";
|
|
7
|
-
|
|
8
|
-
export const Password = ({
|
|
9
|
-
id,
|
|
10
|
-
testid,
|
|
11
|
-
...props
|
|
12
|
-
}: Omit<ComponentProps<"input">, "type" | "children" | "id"> &
|
|
13
|
-
InputBaseProps) => {
|
|
14
|
-
const [show, setShow] = useState(false);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<InputBase
|
|
18
|
-
id={id}
|
|
19
|
-
testid={testid}
|
|
20
|
-
{...props}
|
|
21
|
-
type={show ? "text" : "password"}
|
|
22
|
-
after={<WhichIcon id={id} testid={testid} show={show} setShow={setShow} />}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type WhichIconProps = {
|
|
28
|
-
id?: string;
|
|
29
|
-
testid?: string;
|
|
30
|
-
show: boolean;
|
|
31
|
-
setShow: (value: boolean) => void;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const WhichIcon = ({ id, testid, show, setShow }: WhichIconProps) => {
|
|
35
|
-
if (show) {
|
|
36
|
-
return (
|
|
37
|
-
<Tooltip message="Show">
|
|
38
|
-
<Icon
|
|
39
|
-
id={id ? `${id}-toggle-visibility` : undefined}
|
|
40
|
-
testid={testid ? `${testid}-toggle-visibility` : undefined}
|
|
41
|
-
name="visibility_off"
|
|
42
|
-
className="cursor-pointer"
|
|
43
|
-
onClick={() => setShow(false)}
|
|
44
|
-
/>
|
|
45
|
-
</Tooltip>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Tooltip message="Hide">
|
|
51
|
-
<Icon
|
|
52
|
-
id={id ? `${id}-toggle-visibility` : undefined}
|
|
53
|
-
testid={testid ? `${testid}-toggle-visibility` : undefined}
|
|
54
|
-
name="visibility"
|
|
55
|
-
className="cursor-pointer"
|
|
56
|
-
onClick={() => setShow(true)}
|
|
57
|
-
/>
|
|
58
|
-
</Tooltip>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
Password.displayName = "Password";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { clsx } from "clsx";
|
|
2
|
-
import type { ProductPreviewImage } from "./index";
|
|
3
|
-
|
|
4
|
-
export type CarouselPaginationProps = {
|
|
5
|
-
images: ProductPreviewImage[];
|
|
6
|
-
currentIndex: number;
|
|
7
|
-
onSelect: (index: number) => void;
|
|
8
|
-
className?: string;
|
|
9
|
-
};
|
|
10
|
-
export function CarouselPagination({
|
|
11
|
-
images,
|
|
12
|
-
currentIndex,
|
|
13
|
-
onSelect,
|
|
14
|
-
className,
|
|
15
|
-
}: CarouselPaginationProps) {
|
|
16
|
-
if (!images?.length) return null;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div
|
|
20
|
-
className={clsx(
|
|
21
|
-
"flex items-center justify-center w-full px-4 md:hidden",
|
|
22
|
-
className,
|
|
23
|
-
)}
|
|
24
|
-
aria-label="Image navigation"
|
|
25
|
-
>
|
|
26
|
-
{/* Pagination squares in grid layout */}
|
|
27
|
-
<div
|
|
28
|
-
className="grid gap-2 place-items-center"
|
|
29
|
-
style={{
|
|
30
|
-
gridTemplateColumns: `repeat(${Math.min(images.length, 8)}, 1fr)`,
|
|
31
|
-
}}
|
|
32
|
-
role="tablist"
|
|
33
|
-
>
|
|
34
|
-
{images.map((_, index) => (
|
|
35
|
-
<button
|
|
36
|
-
key={index}
|
|
37
|
-
type="button"
|
|
38
|
-
onClick={() => onSelect(index)}
|
|
39
|
-
className={clsx(
|
|
40
|
-
"w-4 h-4 transition-all duration-200 focus:outline-none",
|
|
41
|
-
index === currentIndex
|
|
42
|
-
? "ring-2 ring-brand-400"
|
|
43
|
-
: "ring ring-neutral-300",
|
|
44
|
-
)}
|
|
45
|
-
aria-label={`Go to image ${index + 1}`}
|
|
46
|
-
role="tab"
|
|
47
|
-
aria-selected={index === currentIndex}
|
|
48
|
-
tabIndex={index === currentIndex ? 0 : -1}
|
|
49
|
-
/>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}
|