@dmsi/wedgekit-react 0.0.415 → 0.0.418
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-3HBYDOYE.js +114 -0
- package/dist/{chunk-JIMJIJOF.js → chunk-5TGP5EFM.js} +2 -2
- package/dist/{chunk-2HMCS25C.js → chunk-6LHBY2IH.js} +1 -1
- package/dist/{chunk-6I5LZ2ZC.js → chunk-7AXHAWJX.js} +3 -3
- package/dist/{chunk-MQX7GFLX.js → chunk-CANJ2YPW.js} +24 -6
- package/dist/{chunk-QQ5G773N.js → chunk-DCLNAUC4.js} +1 -1
- package/dist/{chunk-GB4ZTUQV.js → chunk-DTW7JCBR.js} +36 -0
- package/dist/chunk-ESCNCQGI.js +9 -0
- package/dist/chunk-IFHMGICR.js +66 -0
- package/dist/{chunk-ZHZIIVJN.js → chunk-IMOIZFJZ.js} +5 -5
- package/dist/chunk-KBJZUVLM.js +65 -0
- package/dist/{chunk-AA6GE3TH.js → chunk-LUPHOXAQ.js} +1 -1
- package/dist/{chunk-44TDIHUP.js → chunk-P3MIP2FD.js} +1 -1
- package/dist/{chunk-7ULLUUVJ.js → chunk-PQWWVBSR.js} +1 -1
- package/dist/{chunk-ERW5DEIO.js → chunk-RQLWSLVE.js} +1 -1
- package/dist/{chunk-BK7SPR6Y.js → chunk-TQIKP534.js} +4 -4
- package/dist/chunk-TYAQWVIM.js +159 -0
- package/dist/{chunk-KZZKQLKF.js → chunk-W55J2KJZ.js} +1 -1
- package/dist/chunk-Y2GK27RX.js +79 -0
- package/dist/components/Accordion.cjs +74 -2
- package/dist/components/Accordion.js +3 -3
- package/dist/components/CalendarRange.cjs +231 -53
- package/dist/components/CalendarRange.css +169 -65
- package/dist/components/CalendarRange.js +24 -16
- package/dist/components/Card.cjs +38 -2
- package/dist/components/Card.js +1 -1
- package/dist/components/CompactImagesPreview.cjs +59 -5
- package/dist/components/CompactImagesPreview.js +2 -2
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +189 -11
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.css +169 -65
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +24 -16
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +198 -20
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.css +169 -65
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +24 -16
- package/dist/components/DataGrid/PinnedColumns.cjs +214 -36
- package/dist/components/DataGrid/PinnedColumns.css +169 -65
- package/dist/components/DataGrid/PinnedColumns.js +24 -16
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +190 -12
- package/dist/components/DataGrid/TableBody/LoadingCell.css +169 -65
- package/dist/components/DataGrid/TableBody/LoadingCell.js +24 -16
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +196 -18
- package/dist/components/DataGrid/TableBody/TableBodyRow.css +169 -65
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +24 -16
- package/dist/components/DataGrid/TableBody/index.cjs +211 -33
- package/dist/components/DataGrid/TableBody/index.css +169 -65
- package/dist/components/DataGrid/TableBody/index.js +24 -16
- package/dist/components/DataGrid/index.cjs +300 -122
- package/dist/components/DataGrid/index.css +169 -65
- package/dist/components/DataGrid/index.js +24 -16
- package/dist/components/DataGrid/utils.cjs +190 -12
- package/dist/components/DataGrid/utils.css +169 -65
- package/dist/components/DataGrid/utils.js +24 -16
- package/dist/components/DateInput.cjs +250 -72
- package/dist/components/DateInput.css +169 -65
- package/dist/components/DateInput.js +24 -16
- package/dist/components/DateRangeInput.cjs +250 -72
- package/dist/components/DateRangeInput.css +169 -65
- package/dist/components/DateRangeInput.js +24 -16
- package/dist/components/Grid.cjs +81 -76
- package/dist/components/Grid.js +1 -1
- package/dist/components/ListGroup.cjs +553 -0
- package/dist/components/ListGroup.js +11 -0
- package/dist/components/MobileDataGrid/ColumnList.cjs +36 -0
- package/dist/components/MobileDataGrid/ColumnList.js +3 -3
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +197 -19
- package/dist/components/MobileDataGrid/ColumnSelector/index.css +169 -65
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +24 -16
- package/dist/components/MobileDataGrid/MobileDataGridCard/index.cjs +36 -0
- package/dist/components/MobileDataGrid/MobileDataGridCard/index.js +2 -2
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +241 -27
- package/dist/components/MobileDataGrid/MobileDataGridHeader.css +169 -65
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +24 -16
- package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.cjs +36 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.js +2 -2
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.cjs +36 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +5 -5
- package/dist/components/MobileDataGrid/index.cjs +743 -529
- package/dist/components/MobileDataGrid/index.css +169 -65
- package/dist/components/MobileDataGrid/index.js +24 -16
- package/dist/components/Modal.js +2 -2
- package/dist/components/Notification.cjs +36 -0
- package/dist/components/Notification.js +1 -1
- package/dist/components/PDFViewer/PDFElement.cjs +36 -0
- package/dist/components/PDFViewer/PDFElement.js +2 -2
- package/dist/components/PDFViewer/PDFNavigation.cjs +36 -0
- package/dist/components/PDFViewer/PDFNavigation.js +2 -2
- package/dist/components/PDFViewer/index.cjs +36 -0
- package/dist/components/PDFViewer/index.js +8 -111
- package/dist/components/Pagination.cjs +427 -0
- package/dist/components/Pagination.js +10 -0
- package/dist/components/ProductImagePreview/index.cjs +139 -127
- package/dist/components/ProductImagePreview/index.js +4 -4
- package/dist/components/SideMenuGroup.cjs +36 -0
- package/dist/components/SideMenuGroup.js +1 -1
- package/dist/components/SideMenuItem.cjs +36 -0
- package/dist/components/SideMenuItem.js +1 -1
- package/dist/components/SimpleTable.cjs +36 -0
- package/dist/components/SimpleTable.js +2 -2
- package/dist/components/SkeletonParagraph.js +3 -6
- package/dist/components/Stack.cjs +36 -0
- package/dist/components/Stack.js +1 -1
- package/dist/components/Swatch.cjs +36 -0
- package/dist/components/Swatch.js +1 -1
- package/dist/components/Time.cjs +36 -0
- package/dist/components/Time.js +1 -1
- package/dist/components/Tooltip.cjs +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Upload.cjs +36 -0
- package/dist/components/Upload.js +1 -1
- package/dist/components/index.cjs +694 -131
- package/dist/components/index.css +169 -65
- package/dist/components/index.js +37 -17
- package/dist/index.css +169 -65
- package/package.json +1 -1
- package/src/components/Card.tsx +60 -2
- package/src/components/CompactImagesPreview.tsx +54 -30
- package/src/components/Grid.tsx +59 -91
- package/src/components/ListGroup.tsx +82 -0
- package/src/components/Pagination.tsx +182 -0
- package/src/components/Stack.tsx +76 -0
- package/src/components/Tooltip.tsx +4 -3
- package/src/components/index.ts +4 -0
- package/dist/chunk-ER6RCOH3.js +0 -97
- package/dist/chunk-EZCH4PQS.js +0 -29
- package/dist/{chunk-D6YCMQPO.js → chunk-SBCFBHNG.js} +3 -3
package/src/components/Grid.tsx
CHANGED
|
@@ -1,128 +1,96 @@
|
|
|
1
|
-
import { ComponentProps
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
2
|
import { Sizing } from "../types";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type Breakpoint = "mobile" | "compact" | "desktop";
|
|
6
|
+
|
|
7
|
+
export type GridColumnCount = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
8
|
+
|
|
9
|
+
export type GridProps = {
|
|
6
10
|
children: React.ReactNode;
|
|
11
|
+
/** Design system sizing context controlling gap + optional padding token sets */
|
|
7
12
|
sizing?: Sizing;
|
|
13
|
+
/** Adds the sizing-based padding classes when true */
|
|
8
14
|
padding?: boolean;
|
|
9
|
-
|
|
10
|
-
columns
|
|
15
|
+
/** Base column count applied at all breakpoints unless overridden */
|
|
16
|
+
columns: GridColumnCount;
|
|
17
|
+
/** Explicit responsive column overrides. e.g. { mobile:2, desktop-compact:3, desktop:6 } */
|
|
18
|
+
responsive?: Partial<Record<Breakpoint, GridColumnCount>>;
|
|
11
19
|
id?: string;
|
|
12
20
|
testid?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: ComponentProps<"div">["style"];
|
|
13
23
|
} & Omit<ComponentProps<"div">, "className">;
|
|
14
24
|
|
|
15
|
-
//
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
10: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6",
|
|
27
|
-
11: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-8",
|
|
28
|
-
12: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-8",
|
|
25
|
+
// Mapping helpers for sizing tokens -> gap & padding classes (centralised to reduce repetition)
|
|
26
|
+
const GAP_BY_SIZING: Partial<Record<Sizing, string>> = {
|
|
27
|
+
none: "gap-0",
|
|
28
|
+
"layout-group":
|
|
29
|
+
"gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-compact-layout-group-gap",
|
|
30
|
+
layout:
|
|
31
|
+
"gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-compact-layout-gap",
|
|
32
|
+
container:
|
|
33
|
+
"gap-mobile-container-gap desktop:gap-desktop-container-gap compact:gap-compact-container-gap",
|
|
34
|
+
component:
|
|
35
|
+
"gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-compact-component-gap",
|
|
29
36
|
};
|
|
30
37
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
10: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-10",
|
|
42
|
-
11: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-11",
|
|
43
|
-
12: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12",
|
|
38
|
+
const PADDING_BY_SIZING: Partial<Record<Sizing, string>> = {
|
|
39
|
+
none: "p-0",
|
|
40
|
+
container:
|
|
41
|
+
"p-mobile-container-padding desktop:p-desktop-container-padding compact:p-desktop-compact-container-padding",
|
|
42
|
+
layout:
|
|
43
|
+
"p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding",
|
|
44
|
+
"layout-group":
|
|
45
|
+
"p-mobile-layout-group-padding desktop:p-desktop-layout-group-padding compact:p-desktop-compact-layout-group-padding",
|
|
46
|
+
component:
|
|
47
|
+
"p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding",
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
/** Build column classes from provided props. No child-count heuristics. */
|
|
51
|
+
const buildColumnClasses = (
|
|
52
|
+
base: GridColumnCount,
|
|
53
|
+
responsive?: Partial<Record<Breakpoint, GridColumnCount>>,
|
|
49
54
|
): string => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (childCount <= 1) return "grid-cols-1";
|
|
59
|
-
if (childCount <= 2) return "sm:grid-cols-2";
|
|
60
|
-
if (childCount === 3) return "sm:grid-cols-2 md:grid-cols-3";
|
|
61
|
-
if (childCount <= 5) return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4";
|
|
62
|
-
if (childCount <= 6)
|
|
63
|
-
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6";
|
|
64
|
-
if (childCount === 7)
|
|
65
|
-
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6";
|
|
66
|
-
if (childCount <= 11)
|
|
67
|
-
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-8";
|
|
68
|
-
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12";
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const getGridClasses = (
|
|
72
|
-
childCount: number,
|
|
73
|
-
hasSideMenu?: boolean,
|
|
74
|
-
columns?: number,
|
|
75
|
-
) => {
|
|
76
|
-
if (columns) {
|
|
77
|
-
const map = hasSideMenu
|
|
78
|
-
? COLUMNS_WITH_SIDE_MENU_MAP
|
|
79
|
-
: COLUMNS_WITHOUT_SIDE_MENU_MAP;
|
|
80
|
-
return map[columns] ?? map[12];
|
|
55
|
+
const classes: string[] = [`grid-cols-${base}`];
|
|
56
|
+
if (responsive) {
|
|
57
|
+
(
|
|
58
|
+
Object.entries(responsive) as Array<[Breakpoint, GridColumnCount]>
|
|
59
|
+
).forEach(([bp, value]) => {
|
|
60
|
+
if (value && value > 0) classes.push(`${bp}:grid-cols-${value}`);
|
|
61
|
+
});
|
|
81
62
|
}
|
|
82
|
-
|
|
83
|
-
return getChildCountBasedClasses(childCount, hasSideMenu ?? false);
|
|
63
|
+
return classes.join(" ");
|
|
84
64
|
};
|
|
85
65
|
|
|
86
66
|
export const Grid = ({
|
|
87
67
|
children,
|
|
88
68
|
sizing = "container",
|
|
89
69
|
padding,
|
|
90
|
-
hasSideMenu = false,
|
|
91
70
|
columns,
|
|
71
|
+
responsive,
|
|
92
72
|
id,
|
|
93
73
|
testid,
|
|
94
74
|
style,
|
|
75
|
+
className,
|
|
76
|
+
...rest
|
|
95
77
|
}: GridProps) => {
|
|
96
|
-
const
|
|
78
|
+
const columnClasses = buildColumnClasses(columns, responsive);
|
|
79
|
+
|
|
97
80
|
return (
|
|
98
81
|
<div
|
|
99
82
|
id={id}
|
|
100
83
|
data-testid={testid}
|
|
84
|
+
style={style}
|
|
85
|
+
{...rest}
|
|
101
86
|
className={clsx(
|
|
102
|
-
padding &&
|
|
103
|
-
sizing === "container" &&
|
|
104
|
-
"p-mobile-container-padding desktop:p-desktop-container-padding compact:p-desktop-compact-container-padding",
|
|
105
|
-
padding &&
|
|
106
|
-
sizing === "layout" &&
|
|
107
|
-
"p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding",
|
|
108
|
-
padding &&
|
|
109
|
-
sizing === "layout-group" &&
|
|
110
|
-
"p-mobile-layout-group-padding desktop:p-desktop-layout-group-padding compact:p-desktop-compact-layout-group-padding",
|
|
111
|
-
padding &&
|
|
112
|
-
sizing === "component" &&
|
|
113
|
-
"p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding",
|
|
114
|
-
sizing === "layout-group" &&
|
|
115
|
-
"gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-compact-layout-group-gap",
|
|
116
|
-
sizing === "layout" &&
|
|
117
|
-
"gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-compact-layout-gap",
|
|
118
|
-
sizing === "container" &&
|
|
119
|
-
"gap-mobile-container-gap desktop:gap-desktop-container-gap compact:gap-compact-container-gap",
|
|
120
|
-
sizing === "component" &&
|
|
121
|
-
"gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-compact-component-gap",
|
|
122
87
|
"w-full grid",
|
|
123
|
-
|
|
88
|
+
GAP_BY_SIZING[sizing] ?? GAP_BY_SIZING.container,
|
|
89
|
+
padding && (PADDING_BY_SIZING[sizing] ?? PADDING_BY_SIZING.container),
|
|
90
|
+
columnClasses,
|
|
91
|
+
"grid-cols-1 desktop:grid-cols-4",
|
|
92
|
+
className,
|
|
124
93
|
)}
|
|
125
|
-
style={style}
|
|
126
94
|
>
|
|
127
95
|
{children}
|
|
128
96
|
</div>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { Stack } from "./Stack";
|
|
4
|
+
import { Icon } from "./Icon";
|
|
5
|
+
import { Label } from "./Label";
|
|
6
|
+
|
|
7
|
+
export type ListGroupProps = {
|
|
8
|
+
/** Heading title displayed in the clickable header */
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
/** Start open by default */
|
|
11
|
+
defaultOpen?: boolean;
|
|
12
|
+
/** Controlled open state (if provided component becomes controlled) */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/** Called when the accordion toggles (newState) */
|
|
15
|
+
onToggle?: (open: boolean) => void;
|
|
16
|
+
/** Optional test id */
|
|
17
|
+
testid?: string;
|
|
18
|
+
/** Disable user toggling */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Adds a border around the group */
|
|
22
|
+
bordered?: boolean;
|
|
23
|
+
/** Adds padding to the content area (uses layout sizing tokens) */
|
|
24
|
+
padded?: boolean;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ListGroup is a simple accordion-like container that reveals its children.
|
|
30
|
+
* It uses Stack for consistent spacing and layout.
|
|
31
|
+
*/
|
|
32
|
+
export function ListGroup({
|
|
33
|
+
title,
|
|
34
|
+
defaultOpen = false,
|
|
35
|
+
open: controlledOpen,
|
|
36
|
+
onToggle,
|
|
37
|
+
testid,
|
|
38
|
+
disabled,
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
}: ListGroupProps) {
|
|
42
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
43
|
+
const isControlled = controlledOpen !== undefined;
|
|
44
|
+
const isOpen = isControlled ? controlledOpen : uncontrolledOpen;
|
|
45
|
+
|
|
46
|
+
const toggle = () => {
|
|
47
|
+
if (disabled) return;
|
|
48
|
+
const next = !isOpen;
|
|
49
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
50
|
+
onToggle?.(next);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div data-testid={testid} className={clsx("rounded-sm", className)}>
|
|
55
|
+
<Stack sizing="layout" noGap>
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
onClick={toggle}
|
|
59
|
+
className={clsx(
|
|
60
|
+
"w-full flex items-center justify-between text-left",
|
|
61
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
62
|
+
)}
|
|
63
|
+
aria-expanded={isOpen}
|
|
64
|
+
>
|
|
65
|
+
<Label>{title}</Label>
|
|
66
|
+
<Icon
|
|
67
|
+
name="expand_more"
|
|
68
|
+
className={clsx(
|
|
69
|
+
"transition-transform duration-200",
|
|
70
|
+
isOpen ? "rotate-180" : "rotate-0",
|
|
71
|
+
)}
|
|
72
|
+
/>
|
|
73
|
+
</button>
|
|
74
|
+
{isOpen && (
|
|
75
|
+
<Stack sizing="layout" paddingTop>
|
|
76
|
+
{children}
|
|
77
|
+
</Stack>
|
|
78
|
+
)}
|
|
79
|
+
</Stack>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
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";
|
package/src/components/Stack.tsx
CHANGED
|
@@ -17,6 +17,10 @@ type StackProps = {
|
|
|
17
17
|
padding?: boolean;
|
|
18
18
|
paddingX?: boolean;
|
|
19
19
|
paddingY?: boolean;
|
|
20
|
+
paddingBottom?: boolean;
|
|
21
|
+
paddingTop?: boolean;
|
|
22
|
+
paddingLeft?: boolean;
|
|
23
|
+
paddingRight?: boolean;
|
|
20
24
|
margin?: boolean;
|
|
21
25
|
marginX?: boolean;
|
|
22
26
|
marginY?: boolean;
|
|
@@ -33,6 +37,10 @@ type StackProps = {
|
|
|
33
37
|
minHeight?: number | string;
|
|
34
38
|
maxHeight?: number | string;
|
|
35
39
|
borderColor?: BorderColorTokens;
|
|
40
|
+
borderTopColor?: BorderColorTokens;
|
|
41
|
+
borderRightColor?: BorderColorTokens;
|
|
42
|
+
borderBottomColor?: BorderColorTokens;
|
|
43
|
+
borderLeftColor?: BorderColorTokens;
|
|
36
44
|
backgroundColor?: BackgroundColorTokens;
|
|
37
45
|
overflowY?: "hidden" | "scroll" | "auto" | "inherit";
|
|
38
46
|
overflowX?: "hidden" | "scroll" | "auto" | "inherit";
|
|
@@ -96,6 +104,10 @@ export const Stack = ({
|
|
|
96
104
|
padding,
|
|
97
105
|
paddingX,
|
|
98
106
|
paddingY,
|
|
107
|
+
paddingBottom,
|
|
108
|
+
paddingTop,
|
|
109
|
+
paddingLeft,
|
|
110
|
+
paddingRight,
|
|
99
111
|
margin,
|
|
100
112
|
marginX,
|
|
101
113
|
marginY,
|
|
@@ -111,6 +123,10 @@ export const Stack = ({
|
|
|
111
123
|
height,
|
|
112
124
|
maxHeight,
|
|
113
125
|
borderColor,
|
|
126
|
+
borderTopColor,
|
|
127
|
+
borderRightColor,
|
|
128
|
+
borderBottomColor,
|
|
129
|
+
borderLeftColor,
|
|
114
130
|
backgroundColor,
|
|
115
131
|
sizing = "none",
|
|
116
132
|
overflowY = "inherit",
|
|
@@ -172,6 +188,18 @@ export const Stack = ({
|
|
|
172
188
|
border: borderColor
|
|
173
189
|
? `1px solid var(--color-${borderColor})`
|
|
174
190
|
: undefined,
|
|
191
|
+
borderTop: borderTopColor
|
|
192
|
+
? `1px solid var(--color-${borderTopColor})`
|
|
193
|
+
: undefined,
|
|
194
|
+
borderRight: borderRightColor
|
|
195
|
+
? `1px solid var(--color-${borderRightColor})`
|
|
196
|
+
: undefined,
|
|
197
|
+
borderBottom: borderBottomColor
|
|
198
|
+
? `1px solid var(--color-${borderBottomColor})`
|
|
199
|
+
: undefined,
|
|
200
|
+
borderLeft: borderLeftColor
|
|
201
|
+
? `1px solid var(--color-${borderLeftColor})`
|
|
202
|
+
: undefined,
|
|
175
203
|
backgroundColor: backgroundColor
|
|
176
204
|
? `var(--color-${backgroundColor})`
|
|
177
205
|
: undefined,
|
|
@@ -235,6 +263,54 @@ export const Stack = ({
|
|
|
235
263
|
paddingY &&
|
|
236
264
|
sizing === "component" &&
|
|
237
265
|
"py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding",
|
|
266
|
+
paddingBottom &&
|
|
267
|
+
sizing === "container" &&
|
|
268
|
+
"pb-mobile-container-padding desktop:pb-desktop-container-padding compact:pb-desktop-compact-container-padding",
|
|
269
|
+
paddingBottom &&
|
|
270
|
+
sizing === "layout" &&
|
|
271
|
+
"pb-mobile-layout-padding desktop:pb-desktop-layout-padding compact:pb-desktop-compact-layout-padding",
|
|
272
|
+
paddingBottom &&
|
|
273
|
+
sizing === "layout-group" &&
|
|
274
|
+
"pb-mobile-layout-group-padding desktop:pb-desktop-layout-group-padding compact:pb-desktop-compact-layout-group-padding",
|
|
275
|
+
paddingBottom &&
|
|
276
|
+
sizing === "component" &&
|
|
277
|
+
"pb-mobile-component-padding desktop:pb-desktop-component-padding compact:pb-desktop-compact-component-padding",
|
|
278
|
+
paddingTop &&
|
|
279
|
+
sizing === "container" &&
|
|
280
|
+
"pt-mobile-container-padding desktop:pt-desktop-container-padding compact:pt-desktop-compact-container-padding",
|
|
281
|
+
paddingTop &&
|
|
282
|
+
sizing === "layout" &&
|
|
283
|
+
"pt-mobile-layout-padding desktop:pt-desktop-layout-padding compact:pt-desktop-compact-layout-padding",
|
|
284
|
+
paddingTop &&
|
|
285
|
+
sizing === "layout-group" &&
|
|
286
|
+
"pt-mobile-layout-group-padding desktop:pt-desktop-layout-group-padding compact:pt-desktop-compact-layout-group-padding",
|
|
287
|
+
paddingTop &&
|
|
288
|
+
sizing === "component" &&
|
|
289
|
+
"pt-mobile-component-padding desktop:pt-desktop-component-padding compact:pt-desktop-compact-component-padding",
|
|
290
|
+
paddingLeft &&
|
|
291
|
+
sizing === "container" &&
|
|
292
|
+
"pl-mobile-container-padding desktop:pl-desktop-container-padding compact:pl-desktop-compact-container-padding",
|
|
293
|
+
paddingLeft &&
|
|
294
|
+
sizing === "layout" &&
|
|
295
|
+
"pl-mobile-layout-padding desktop:pl-desktop-layout-padding compact:pl-desktop-compact-layout-padding",
|
|
296
|
+
paddingLeft &&
|
|
297
|
+
sizing === "layout-group" &&
|
|
298
|
+
"pl-mobile-layout-group-padding desktop:pl-desktop-layout-group-padding compact:pl-desktop-compact-layout-group-padding",
|
|
299
|
+
paddingLeft &&
|
|
300
|
+
sizing === "component" &&
|
|
301
|
+
"pl-mobile-component-padding desktop:pl-desktop-component-padding compact:pl-desktop-compact-component-padding",
|
|
302
|
+
paddingRight &&
|
|
303
|
+
sizing === "container" &&
|
|
304
|
+
"pr-mobile-container-padding desktop:pr-desktop-container-padding compact:pr-desktop-compact-container-padding",
|
|
305
|
+
paddingRight &&
|
|
306
|
+
sizing === "layout" &&
|
|
307
|
+
"pr-mobile-layout-padding desktop:pr-desktop-layout-padding compact:pr-desktop-compact-layout-padding",
|
|
308
|
+
paddingRight &&
|
|
309
|
+
sizing === "layout-group" &&
|
|
310
|
+
"pr-mobile-layout-group-padding desktop:pr-desktop-layout-group-padding compact:pr-desktop-compact-layout-group-padding",
|
|
311
|
+
paddingRight &&
|
|
312
|
+
sizing === "component" &&
|
|
313
|
+
"pr-mobile-component-padding desktop:pr-desktop-component-padding compact:pr-desktop-compact-component-padding",
|
|
238
314
|
margin &&
|
|
239
315
|
sizing === "container" &&
|
|
240
316
|
"m-mobile-container-padding desktop:m-desktop-container-padding compact:m-compact-container-padding",
|
|
@@ -30,7 +30,7 @@ export const Tooltip = ({
|
|
|
30
30
|
children,
|
|
31
31
|
showOnTruncation = false,
|
|
32
32
|
offset = 8,
|
|
33
|
-
keepHidden = false
|
|
33
|
+
keepHidden = false,
|
|
34
34
|
}: TooltipProps) => {
|
|
35
35
|
const ref = useRef<HTMLDivElement>(null);
|
|
36
36
|
const tooltipRef = useRef<HTMLDivElement>(null);
|
|
@@ -105,13 +105,14 @@ export const Tooltip = ({
|
|
|
105
105
|
id={id}
|
|
106
106
|
data-testid={testid}
|
|
107
107
|
ref={ref}
|
|
108
|
-
className="relative inline-grid grid-cols-[auto_1fr] items-center"
|
|
108
|
+
className="relative inline-grid grid-cols-[auto_1fr] items-center cursor-pointer"
|
|
109
109
|
onMouseEnter={handleMouseEnter}
|
|
110
110
|
onMouseLeave={handleMouseLeave}
|
|
111
111
|
>
|
|
112
112
|
{children}
|
|
113
113
|
|
|
114
|
-
{!keepHidden &&
|
|
114
|
+
{!keepHidden &&
|
|
115
|
+
isVisible &&
|
|
115
116
|
typeof document !== "undefined" &&
|
|
116
117
|
createPortal(
|
|
117
118
|
<div
|
package/src/components/index.ts
CHANGED
|
@@ -24,3 +24,7 @@ export { MobileDataGrid } from "./MobileDataGrid";
|
|
|
24
24
|
export { ProductImagePreview } from "./ProductImagePreview";
|
|
25
25
|
export { CompactImagesPreview } from "./CompactImagesPreview";
|
|
26
26
|
export { SimpleTable } from "./SimpleTable";
|
|
27
|
+
export { PDFViewer } from "./PDFViewer";
|
|
28
|
+
export { ListGroup } from "./ListGroup";
|
|
29
|
+
export { Pagination } from "./Pagination";
|
|
30
|
+
export { SkeletonParagraph } from "./SkeletonParagraph";
|