@dmsi/wedgekit-react 0.0.369 → 0.0.371
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-RLLQRVM7.js → chunk-2H35FETR.js} +18 -10
- package/dist/chunk-2IKT6IHB.js +190 -0
- package/dist/chunk-4UNWXB4A.js +89 -0
- package/dist/chunk-5IFPG6TS.js +17 -0
- package/dist/{chunk-6GAYJCFE.js → chunk-6DPFKSCT.js} +1 -1
- package/dist/{chunk-ZFOANBWG.js → chunk-AG43RS4Q.js} +2 -1
- package/dist/chunk-AJ5M6MVX.js +7 -0
- package/dist/chunk-AT4AWD6B.js +44 -0
- package/dist/chunk-BQNPOGD5.js +105 -0
- package/dist/chunk-CQFPNZTN.js +172 -0
- package/dist/chunk-EJSPFQCY.js +29 -0
- package/dist/chunk-ER6RCOH3.js +97 -0
- package/dist/{chunk-4VER5OEU.js → chunk-FBE2HGEF.js} +35 -11
- package/dist/chunk-HPQWEZJL.js +45 -0
- package/dist/{chunk-URCLLHO5.js → chunk-IBX6DVHU.js} +376 -102
- package/dist/{chunk-I3WFZOFY.js → chunk-J5V2JRIK.js} +1 -1
- package/dist/chunk-JGJUVJKD.js +283 -0
- package/dist/chunk-KEMCFN4U.js +78 -0
- package/dist/chunk-M6TSTDNZ.js +22 -0
- package/dist/chunk-M7INAUAJ.js +140 -0
- package/dist/chunk-MBZ55T2D.js +51 -0
- package/dist/chunk-N6PNLLNS.js +77 -0
- package/dist/{chunk-ZA5E7ZYM.js → chunk-NXGUDYRR.js} +1 -1
- package/dist/chunk-P36QKH26.js +143 -0
- package/dist/chunk-PTRZHGHA.js +89 -0
- package/dist/chunk-QVWYTQKL.js +29 -0
- package/dist/{chunk-6CPGOW6J.js → chunk-T36HX6QY.js} +6 -4
- package/dist/chunk-U6PUOGG4.js +114 -0
- package/dist/{chunk-NQXZBWDZ.js → chunk-V6U7LU6M.js} +15 -6
- package/dist/chunk-VJVY6NPF.js +32 -0
- package/dist/chunk-VVXPGI2P.js +61 -0
- package/dist/{chunk-ARQBSR3I.js → chunk-YCKRVNJ3.js} +4 -4
- package/dist/chunk-YYHQLQDQ.js +68 -0
- package/dist/components/Accordion.cjs +47 -14
- package/dist/components/Accordion.js +2 -2
- package/dist/components/CalendarRange.cjs +700 -46
- package/dist/components/CalendarRange.css +186 -3
- package/dist/components/CalendarRange.js +43 -11
- package/dist/components/CompactImagesPreview.cjs +485 -0
- package/dist/components/CompactImagesPreview.js +13 -0
- package/dist/components/ContentTabs.cjs +3 -2
- package/dist/components/ContentTabs.js +3 -2
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +4687 -0
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.css +5051 -0
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +62 -0
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +4687 -0
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.css +5051 -0
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +62 -0
- package/dist/components/DataGrid/PinnedColumns.cjs +4687 -0
- package/dist/components/DataGrid/PinnedColumns.css +5051 -0
- package/dist/components/DataGrid/PinnedColumns.js +62 -0
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +4689 -0
- package/dist/components/DataGrid/TableBody/LoadingCell.css +5051 -0
- package/dist/components/DataGrid/TableBody/LoadingCell.js +62 -0
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +4689 -0
- package/dist/components/DataGrid/TableBody/TableBodyRow.css +5051 -0
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +62 -0
- package/dist/components/DataGrid/TableBody/index.cjs +4689 -0
- package/dist/components/DataGrid/TableBody/index.css +5051 -0
- package/dist/components/DataGrid/TableBody/index.js +62 -0
- package/dist/components/DataGrid/index.cjs +4692 -0
- package/dist/components/DataGrid/index.css +5051 -0
- package/dist/components/DataGrid/index.js +65 -0
- package/dist/components/DataGrid/utils.cjs +4687 -0
- package/dist/components/DataGrid/utils.css +5051 -0
- package/dist/components/DataGrid/utils.js +62 -0
- package/dist/components/DataGridCell.js +6 -6
- package/dist/components/DateInput.cjs +721 -67
- package/dist/components/DateInput.css +186 -3
- package/dist/components/DateInput.js +45 -13
- package/dist/components/DateRangeInput.cjs +721 -67
- package/dist/components/DateRangeInput.css +186 -3
- package/dist/components/DateRangeInput.js +45 -13
- package/dist/components/FilterGroup.js +3 -3
- package/dist/components/Grid.cjs +3 -1
- package/dist/components/Grid.js +3 -92
- package/dist/components/ImagePlaceholder.cjs +65 -0
- package/dist/components/ImagePlaceholder.js +7 -0
- package/dist/components/Input.js +2 -2
- package/dist/components/MenuOption.js +2 -2
- package/dist/components/MobileDataGrid/ColumnList.cjs +845 -0
- package/dist/components/MobileDataGrid/ColumnList.js +17 -0
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +4797 -0
- package/dist/components/MobileDataGrid/ColumnSelector/index.css +5051 -0
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +62 -0
- package/dist/components/MobileDataGrid/GridContextProvider/GridContext.cjs +31 -0
- package/dist/components/MobileDataGrid/GridContextProvider/GridContext.js +7 -0
- package/dist/components/MobileDataGrid/GridContextProvider/index.cjs +177 -0
- package/dist/components/MobileDataGrid/GridContextProvider/index.js +8 -0
- package/dist/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.cjs +269 -0
- package/dist/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.js +9 -0
- package/dist/components/MobileDataGrid/MobileDataGridCard/index.cjs +790 -0
- package/dist/components/MobileDataGrid/MobileDataGridCard/index.js +16 -0
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +5059 -0
- package/dist/components/MobileDataGrid/MobileDataGridHeader.css +5051 -0
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +62 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.cjs +509 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.js +13 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.cjs +1261 -0
- package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +27 -0
- package/dist/components/MobileDataGrid/index.cjs +5521 -0
- package/dist/components/MobileDataGrid/index.css +5051 -0
- package/dist/components/MobileDataGrid/index.js +62 -0
- package/dist/components/Modal.cjs +24 -13
- package/dist/components/Modal.js +3 -3
- package/dist/components/ModalHeader.cjs +6 -4
- package/dist/components/ModalHeader.js +1 -1
- package/dist/components/ModalScrim.cjs +2 -1
- package/dist/components/ModalScrim.js +1 -1
- package/dist/components/NestedMenu.js +4 -4
- package/dist/components/Notification.cjs +15 -6
- package/dist/components/Notification.js +1 -1
- package/dist/components/PDFViewer/DownloadIcon.cjs +394 -0
- package/dist/components/PDFViewer/DownloadIcon.js +10 -0
- package/dist/components/PDFViewer/PDFElement.cjs +515 -0
- package/dist/components/PDFViewer/PDFElement.js +11 -0
- package/dist/components/{MobileDataGrid.cjs → PDFViewer/PDFNavigation.cjs} +318 -402
- package/dist/components/PDFViewer/PDFNavigation.js +13 -0
- package/dist/components/PDFViewer/PDFPage.cjs +56 -0
- package/dist/components/PDFViewer/PDFPage.js +7 -0
- package/dist/components/{PDFViewer.cjs → PDFViewer/index.cjs} +290 -202
- package/dist/components/PDFViewer/index.js +29 -0
- package/dist/components/Password.js +2 -2
- package/dist/components/ProductImagePreview/CarouselPagination.cjs +75 -0
- package/dist/components/ProductImagePreview/CarouselPagination.js +7 -0
- package/dist/components/ProductImagePreview/MobileImageCarousel.cjs +214 -0
- package/dist/components/ProductImagePreview/MobileImageCarousel.js +7 -0
- package/dist/components/ProductImagePreview/ProductPrimaryImage.cjs +255 -0
- package/dist/components/ProductImagePreview/ProductPrimaryImage.js +9 -0
- package/dist/components/ProductImagePreview/Thumbnail.cjs +105 -0
- package/dist/components/ProductImagePreview/Thumbnail.js +8 -0
- package/dist/components/ProductImagePreview/ZoomWindow.cjs +198 -0
- package/dist/components/ProductImagePreview/ZoomWindow.js +8 -0
- package/dist/components/ProductImagePreview/index.cjs +1369 -0
- package/dist/components/ProductImagePreview/index.js +22 -0
- package/dist/components/Search.js +3 -3
- package/dist/components/Select.js +3 -3
- package/dist/components/SideMenuGroup.cjs +15 -6
- package/dist/components/SideMenuGroup.js +1 -1
- package/dist/components/SideMenuItem.cjs +15 -6
- package/dist/components/SideMenuItem.js +1 -1
- package/dist/components/SkeletonParagraph.cjs +33 -0
- package/dist/components/SkeletonParagraph.js +10 -0
- package/dist/components/Stack.cjs +15 -6
- package/dist/components/Stack.js +1 -1
- package/dist/components/Stepper.cjs +61 -53
- package/dist/components/Stepper.js +63 -55
- package/dist/components/Surface.js +3 -39
- package/dist/components/Swatch.cjs +15 -6
- package/dist/components/Swatch.js +4 -4
- package/dist/components/Time.cjs +15 -6
- package/dist/components/Time.js +5 -5
- package/dist/components/Upload.cjs +15 -6
- package/dist/components/Upload.js +1 -1
- package/dist/components/index.cjs +2559 -14
- package/dist/components/index.css +186 -3
- package/dist/components/index.js +57 -14
- package/dist/index.css +186 -3
- package/package.json +1 -1
- package/src/components/Accordion.tsx +23 -4
- package/src/components/CompactImagesPreview.tsx +99 -0
- package/src/components/ContentTabs.tsx +3 -1
- package/src/components/DataGrid/types.ts +5 -0
- package/src/components/Grid.tsx +2 -0
- package/src/components/ImagePlaceholder.tsx +22 -0
- package/src/components/MobileDataGrid/ColumnList.tsx +66 -0
- package/src/components/MobileDataGrid/ColumnSelector/index.tsx +97 -0
- package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +25 -0
- package/src/components/MobileDataGrid/GridContextProvider/index.tsx +132 -0
- package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +10 -0
- package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +20 -0
- package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +129 -0
- package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +80 -0
- package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +42 -0
- package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +68 -0
- package/src/components/MobileDataGrid/dataGridReducer.ts +55 -0
- package/src/components/MobileDataGrid/index.tsx +92 -0
- package/src/components/MobileDataGrid/types.ts +4 -0
- package/src/components/Modal.tsx +31 -12
- package/src/components/ModalButtons.tsx +1 -1
- package/src/components/ModalHeader.tsx +5 -2
- package/src/components/ModalScrim.tsx +3 -2
- package/src/components/PDFViewer/DownloadIcon.tsx +22 -0
- package/src/components/PDFViewer/PDFElement.tsx +90 -0
- package/src/components/PDFViewer/PDFNavigation.tsx +68 -0
- package/src/components/PDFViewer/PDFPage.tsx +34 -0
- package/src/components/PDFViewer/index.tsx +128 -0
- package/src/components/ProductImagePreview/CarouselPagination.tsx +54 -0
- package/src/components/ProductImagePreview/MobileImageCarousel.tsx +226 -0
- package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +218 -0
- package/src/components/ProductImagePreview/Thumbnail.tsx +49 -0
- package/src/components/ProductImagePreview/ZoomWindow.tsx +136 -0
- package/src/components/ProductImagePreview/index.tsx +182 -0
- package/src/components/ProductImagePreview/useProductImagePreview.ts +211 -0
- package/src/components/SkeletonParagraph.tsx +5 -0
- package/src/components/Stack.tsx +29 -6
- package/src/components/Stepper.tsx +5 -1
- package/src/components/index.ts +4 -0
- package/src/types.ts +2 -1
- package/dist/components/MobileDataGrid.js +0 -150
- package/dist/components/PDFViewer.js +0 -250
- package/src/components/MobileDataGrid.tsx +0 -163
- package/src/components/PDFViewer.tsx +0 -264
- package/dist/{chunk-OXSBIBGT.js → chunk-CKQNJNU3.js} +3 -3
- package/dist/{chunk-RJUN52HJ.js → chunk-ZL5X7KP6.js} +3 -3
|
@@ -63,6 +63,7 @@ __export(components_exports, {
|
|
|
63
63
|
Button: () => Button,
|
|
64
64
|
Card: () => Card,
|
|
65
65
|
Checkbox: () => Checkbox,
|
|
66
|
+
CompactImagesPreview: () => CompactImagesPreview,
|
|
66
67
|
DataCellHeader: () => DataCellHeader,
|
|
67
68
|
DataGrid: () => DataGrid,
|
|
68
69
|
DataGridCell: () => DataGridCell,
|
|
@@ -73,7 +74,10 @@ __export(components_exports, {
|
|
|
73
74
|
Label: () => Label,
|
|
74
75
|
Menu: () => Menu,
|
|
75
76
|
MenuOption: () => MenuOption,
|
|
77
|
+
MobileDataGrid: () => MobileDataGrid,
|
|
78
|
+
PDFViewer: () => PDFViewer,
|
|
76
79
|
Paragraph: () => Paragraph,
|
|
80
|
+
ProductImagePreview: () => ProductImagePreview,
|
|
77
81
|
Search: () => Search,
|
|
78
82
|
Select: () => Select,
|
|
79
83
|
Subheader: () => Subheader,
|
|
@@ -4119,7 +4123,9 @@ var Stack = (_a) => {
|
|
|
4119
4123
|
noGap,
|
|
4120
4124
|
marginTop,
|
|
4121
4125
|
marginBottom,
|
|
4122
|
-
testid
|
|
4126
|
+
testid,
|
|
4127
|
+
bottom,
|
|
4128
|
+
zIndex
|
|
4123
4129
|
} = _b, props = __objRest(_b, [
|
|
4124
4130
|
"children",
|
|
4125
4131
|
"items",
|
|
@@ -4156,8 +4162,11 @@ var Stack = (_a) => {
|
|
|
4156
4162
|
"noGap",
|
|
4157
4163
|
"marginTop",
|
|
4158
4164
|
"marginBottom",
|
|
4159
|
-
"testid"
|
|
4165
|
+
"testid",
|
|
4166
|
+
"bottom",
|
|
4167
|
+
"zIndex"
|
|
4160
4168
|
]);
|
|
4169
|
+
var _a2, _b2, _c, _d, _e;
|
|
4161
4170
|
const flexClassNames = getFlexClassNames({ items, justify, grow });
|
|
4162
4171
|
const gapClassNames = useGapClassNames(sizing);
|
|
4163
4172
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
@@ -4168,9 +4177,9 @@ var Stack = (_a) => {
|
|
|
4168
4177
|
}, props), {
|
|
4169
4178
|
style: {
|
|
4170
4179
|
height: height === "full" ? "100%" : height !== void 0 ? `${height}px` : void 0,
|
|
4171
|
-
maxHeight: maxHeight !== void 0 ? `${maxHeight}px` : void 0,
|
|
4172
|
-
|
|
4173
|
-
|
|
4180
|
+
maxHeight: maxHeight !== void 0 ? isNaN(+maxHeight) ? maxHeight : `${maxHeight}px` : (_a2 = props.style) == null ? void 0 : _a2.maxHeight,
|
|
4181
|
+
maxWidth: maxWidth !== void 0 ? isNaN(+maxWidth) ? maxWidth : `${maxWidth}px` : (_b2 = props.style) == null ? void 0 : _b2.maxWidth,
|
|
4182
|
+
minHeight: minHeight !== void 0 ? isNaN(+minHeight) ? minHeight : `${minHeight}px` : (_c = props.style) == null ? void 0 : _c.minHeight,
|
|
4174
4183
|
width: width !== void 0 && typeof width === "number" ? `${width}px` : void 0,
|
|
4175
4184
|
minWidth: minWidth !== void 0 ? `${minWidth}px` : void 0,
|
|
4176
4185
|
border: borderColor ? `1px solid var(--color-${borderColor})` : void 0,
|
|
@@ -4179,7 +4188,11 @@ var Stack = (_a) => {
|
|
|
4179
4188
|
flexShrink: flexShrink !== void 0 ? flexShrink : void 0,
|
|
4180
4189
|
position: position !== void 0 ? position : void 0,
|
|
4181
4190
|
top: top !== void 0 ? `${top}px` : void 0,
|
|
4182
|
-
|
|
4191
|
+
bottom: bottom !== void 0 ? `${bottom}px` : void 0,
|
|
4192
|
+
left: left !== void 0 ? `${left}px` : void 0,
|
|
4193
|
+
borderBlock: (_d = props.style) == null ? void 0 : _d.borderBlock,
|
|
4194
|
+
marginInline: (_e = props.style) == null ? void 0 : _e.marginInline,
|
|
4195
|
+
zIndex: zIndex !== void 0 ? zIndex : void 0
|
|
4183
4196
|
},
|
|
4184
4197
|
className: (0, import_clsx20.default)(
|
|
4185
4198
|
"scrollbar-thin",
|
|
@@ -4229,7 +4242,14 @@ var Stack = (_a) => {
|
|
|
4229
4242
|
// src/components/Accordion.tsx
|
|
4230
4243
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4231
4244
|
function Accordion(props) {
|
|
4232
|
-
const {
|
|
4245
|
+
const {
|
|
4246
|
+
isOpen,
|
|
4247
|
+
onClick,
|
|
4248
|
+
className,
|
|
4249
|
+
disabled,
|
|
4250
|
+
testid,
|
|
4251
|
+
titleAlign = "center"
|
|
4252
|
+
} = props;
|
|
4233
4253
|
const {
|
|
4234
4254
|
title,
|
|
4235
4255
|
before,
|
|
@@ -4262,13 +4282,30 @@ function Accordion(props) {
|
|
|
4262
4282
|
onClick: handleClick,
|
|
4263
4283
|
testid,
|
|
4264
4284
|
children: [
|
|
4265
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4285
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4286
|
+
Stack,
|
|
4287
|
+
{
|
|
4288
|
+
sizing: "component",
|
|
4289
|
+
horizontal: true,
|
|
4290
|
+
horizontalMobile: true,
|
|
4291
|
+
justify: "between",
|
|
4292
|
+
items: "center",
|
|
4293
|
+
children: [
|
|
4294
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Stack, { sizing: "layout-group", horizontal: true, items: titleAlign, children: [
|
|
4295
|
+
before,
|
|
4296
|
+
typeof title === "string" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4297
|
+
Paragraph,
|
|
4298
|
+
{
|
|
4299
|
+
testid: testid ? `${testid}-title` : void 0,
|
|
4300
|
+
className: "text-text-primary-normal",
|
|
4301
|
+
children: title
|
|
4302
|
+
}
|
|
4303
|
+
) : title
|
|
4304
|
+
] }),
|
|
4305
|
+
after
|
|
4306
|
+
]
|
|
4307
|
+
}
|
|
4308
|
+
),
|
|
4272
4309
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4273
4310
|
"div",
|
|
4274
4311
|
{
|
|
@@ -4295,12 +4332,2517 @@ function Accordion(props) {
|
|
|
4295
4332
|
}
|
|
4296
4333
|
);
|
|
4297
4334
|
}
|
|
4335
|
+
|
|
4336
|
+
// src/components/Heading.tsx
|
|
4337
|
+
var import_clsx22 = __toESM(require("clsx"), 1);
|
|
4338
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4339
|
+
var Heading = (_a) => {
|
|
4340
|
+
var _b = _a, {
|
|
4341
|
+
className,
|
|
4342
|
+
children,
|
|
4343
|
+
as,
|
|
4344
|
+
color,
|
|
4345
|
+
align,
|
|
4346
|
+
variant = "heading1",
|
|
4347
|
+
id,
|
|
4348
|
+
testid
|
|
4349
|
+
} = _b, props = __objRest(_b, [
|
|
4350
|
+
"className",
|
|
4351
|
+
"children",
|
|
4352
|
+
"as",
|
|
4353
|
+
"color",
|
|
4354
|
+
"align",
|
|
4355
|
+
"variant",
|
|
4356
|
+
"id",
|
|
4357
|
+
"testid"
|
|
4358
|
+
]);
|
|
4359
|
+
const defaultElement = variant === "heading1" ? "h1" : variant === "heading2" ? "h2" : "h3";
|
|
4360
|
+
const Element = as != null ? as : defaultElement;
|
|
4361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4362
|
+
Element,
|
|
4363
|
+
__spreadProps(__spreadValues({
|
|
4364
|
+
id,
|
|
4365
|
+
"data-testid": testid,
|
|
4366
|
+
className: (0, import_clsx22.default)(
|
|
4367
|
+
typography[variant],
|
|
4368
|
+
className,
|
|
4369
|
+
align === "left" && "text-left",
|
|
4370
|
+
align === "center" && "text-center",
|
|
4371
|
+
align === "right" && "text-right"
|
|
4372
|
+
),
|
|
4373
|
+
style: __spreadProps(__spreadValues({}, props.style), {
|
|
4374
|
+
color: color ? `var(--color-${color})` : void 0
|
|
4375
|
+
})
|
|
4376
|
+
}, props), {
|
|
4377
|
+
children
|
|
4378
|
+
})
|
|
4379
|
+
);
|
|
4380
|
+
};
|
|
4381
|
+
Heading.displayName = "Heading";
|
|
4382
|
+
var Heading1 = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading1" }));
|
|
4383
|
+
var Heading2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading2" }));
|
|
4384
|
+
var Heading3 = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading3" }));
|
|
4385
|
+
Heading1.displayName = "Heading1";
|
|
4386
|
+
Heading2.displayName = "Heading2";
|
|
4387
|
+
Heading3.displayName = "Heading3";
|
|
4388
|
+
|
|
4389
|
+
// src/components/Theme.tsx
|
|
4390
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4391
|
+
function Theme({
|
|
4392
|
+
theme,
|
|
4393
|
+
children,
|
|
4394
|
+
id,
|
|
4395
|
+
testid,
|
|
4396
|
+
ref
|
|
4397
|
+
}) {
|
|
4398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4399
|
+
"div",
|
|
4400
|
+
{
|
|
4401
|
+
id,
|
|
4402
|
+
"data-testid": testid,
|
|
4403
|
+
className: "contents",
|
|
4404
|
+
"data-theme": theme,
|
|
4405
|
+
ref: (e) => {
|
|
4406
|
+
if (ref) ref.current = e;
|
|
4407
|
+
},
|
|
4408
|
+
children
|
|
4409
|
+
}
|
|
4410
|
+
);
|
|
4411
|
+
}
|
|
4412
|
+
|
|
4413
|
+
// src/components/MobileDataGrid/ColumnSelector/index.tsx
|
|
4414
|
+
var import_react21 = require("react");
|
|
4415
|
+
|
|
4416
|
+
// src/components/MobileDataGrid/GridContextProvider/useGridContext.ts
|
|
4417
|
+
var import_react20 = require("react");
|
|
4418
|
+
|
|
4419
|
+
// src/components/MobileDataGrid/GridContextProvider/GridContext.tsx
|
|
4420
|
+
var import_react19 = require("react");
|
|
4421
|
+
var GridContext = (0, import_react19.createContext)(null);
|
|
4422
|
+
|
|
4423
|
+
// src/components/MobileDataGrid/GridContextProvider/useGridContext.ts
|
|
4424
|
+
function useGridContext() {
|
|
4425
|
+
const ctx = (0, import_react20.useContext)(GridContext);
|
|
4426
|
+
if (!ctx) {
|
|
4427
|
+
throw new Error("useGridContext must be used within GridContextProvider");
|
|
4428
|
+
}
|
|
4429
|
+
return ctx;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
// src/components/MobileDataGrid/ColumnSelector/index.tsx
|
|
4433
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4434
|
+
function ColumnSelector() {
|
|
4435
|
+
const context = useGridContext();
|
|
4436
|
+
const ref = (0, import_react21.useRef)(null);
|
|
4437
|
+
const [show, setShow] = (0, import_react21.useState)(false);
|
|
4438
|
+
const {
|
|
4439
|
+
columns,
|
|
4440
|
+
id,
|
|
4441
|
+
testid,
|
|
4442
|
+
visibleColumns,
|
|
4443
|
+
numberOfColumnsToShow,
|
|
4444
|
+
primaryKey,
|
|
4445
|
+
resetColumnVisibility,
|
|
4446
|
+
dispatch
|
|
4447
|
+
} = context;
|
|
4448
|
+
const toggleColumnVisibility = (0, import_react21.useCallback)(
|
|
4449
|
+
(index, visible) => {
|
|
4450
|
+
dispatch({ type: "UPDATE", index, payload: { meta: { visible } } });
|
|
4451
|
+
},
|
|
4452
|
+
[dispatch]
|
|
4453
|
+
);
|
|
4454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4455
|
+
"div",
|
|
4456
|
+
{
|
|
4457
|
+
id: id ? `${id}-column-selector` : void 0,
|
|
4458
|
+
"data-testid": testid,
|
|
4459
|
+
className: "text-text-secondary-normal border-l border-brand-200 p-mobile-container-padding",
|
|
4460
|
+
ref,
|
|
4461
|
+
children: [
|
|
4462
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4463
|
+
Button,
|
|
4464
|
+
{
|
|
4465
|
+
id: id ? `${id}-button` : void 0,
|
|
4466
|
+
testid: testid ? `${testid}-button` : void 0,
|
|
4467
|
+
onClick: () => setShow((prev) => !prev),
|
|
4468
|
+
variant: "navigation",
|
|
4469
|
+
iconOnly: true,
|
|
4470
|
+
size: 24,
|
|
4471
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Icon, { name: "tune" })
|
|
4472
|
+
}
|
|
4473
|
+
),
|
|
4474
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4475
|
+
Menu,
|
|
4476
|
+
{
|
|
4477
|
+
id: id ? `${id}-menu` : void 0,
|
|
4478
|
+
testid: testid ? `${testid}-menu` : void 0,
|
|
4479
|
+
positionTo: ref,
|
|
4480
|
+
position: "bottom-right",
|
|
4481
|
+
show,
|
|
4482
|
+
setShow,
|
|
4483
|
+
calculateMinMaxHeight: true,
|
|
4484
|
+
children: [
|
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4486
|
+
Button,
|
|
4487
|
+
{
|
|
4488
|
+
id: id ? `${id}-reset-button` : void 0,
|
|
4489
|
+
testid: testid ? `${testid}-reset-button` : void 0,
|
|
4490
|
+
variant: "tertiary",
|
|
4491
|
+
onClick: () => {
|
|
4492
|
+
resetColumnVisibility();
|
|
4493
|
+
setShow(false);
|
|
4494
|
+
},
|
|
4495
|
+
children: "Reset to default"
|
|
4496
|
+
}
|
|
4497
|
+
),
|
|
4498
|
+
columns.filter((x) => {
|
|
4499
|
+
var _a;
|
|
4500
|
+
return (_a = x.meta) == null ? void 0 : _a.inVisibilityMenu;
|
|
4501
|
+
}).map((column) => {
|
|
4502
|
+
var _a, _b, _c;
|
|
4503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4504
|
+
MenuOption,
|
|
4505
|
+
{
|
|
4506
|
+
testid: testid ? `${testid}-option-${column.id}` : void 0,
|
|
4507
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4508
|
+
Checkbox,
|
|
4509
|
+
{
|
|
4510
|
+
id: id ? `${id}-checkbox-${column.id}` : void 0,
|
|
4511
|
+
testid: testid ? `${testid}-checkbox-${column.id}` : void 0,
|
|
4512
|
+
label: (_a = column.header) == null ? void 0 : _a.toString(),
|
|
4513
|
+
checked: !!((_b = column.meta) == null ? void 0 : _b.visible) || column.id === String(primaryKey),
|
|
4514
|
+
disabled: typeof numberOfColumnsToShow !== "undefined" && // account for header+link occupying one slot
|
|
4515
|
+
visibleColumns.length >= numberOfColumnsToShow - 1 && ((_c = column.meta) == null ? void 0 : _c.visible) !== true || column.id === String(primaryKey),
|
|
4516
|
+
onChange: (e) => {
|
|
4517
|
+
toggleColumnVisibility(
|
|
4518
|
+
columns.findIndex(({ id: id2 }) => id2 === column.id),
|
|
4519
|
+
e.target.checked
|
|
4520
|
+
);
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
)
|
|
4524
|
+
},
|
|
4525
|
+
id ? `${id}-option-${column.id}` : void 0
|
|
4526
|
+
);
|
|
4527
|
+
})
|
|
4528
|
+
]
|
|
4529
|
+
}
|
|
4530
|
+
)
|
|
4531
|
+
]
|
|
4532
|
+
}
|
|
4533
|
+
);
|
|
4534
|
+
}
|
|
4535
|
+
|
|
4536
|
+
// src/components/MobileDataGrid/MobileDataGridHeader.tsx
|
|
4537
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4538
|
+
function MobileDataGridHeader({
|
|
4539
|
+
header: Header,
|
|
4540
|
+
enableColumnSelector,
|
|
4541
|
+
enableRowSelection
|
|
4542
|
+
}) {
|
|
4543
|
+
var _a, _b;
|
|
4544
|
+
const ctx = useGridContext();
|
|
4545
|
+
const {
|
|
4546
|
+
id,
|
|
4547
|
+
testid,
|
|
4548
|
+
selectedRowIds,
|
|
4549
|
+
data,
|
|
4550
|
+
primaryKey,
|
|
4551
|
+
columns,
|
|
4552
|
+
handleRowSelectAll
|
|
4553
|
+
} = ctx;
|
|
4554
|
+
if (typeof Header === "undefined" && !primaryKey) return null;
|
|
4555
|
+
if (typeof Header === "function") return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Header, __spreadValues({}, ctx));
|
|
4556
|
+
if (typeof Header === "string" || primaryKey)
|
|
4557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4558
|
+
"div",
|
|
4559
|
+
{
|
|
4560
|
+
id: id ? `${id}-header` : void 0,
|
|
4561
|
+
"data-testid": testid ? `${testid}-header` : void 0,
|
|
4562
|
+
className: "sticky top-0",
|
|
4563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Theme, { theme: "brand", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
4564
|
+
Stack,
|
|
4565
|
+
{
|
|
4566
|
+
horizontal: true,
|
|
4567
|
+
horizontalMobile: true,
|
|
4568
|
+
items: "center",
|
|
4569
|
+
justify: "between",
|
|
4570
|
+
backgroundColor: "background-primary-normal",
|
|
4571
|
+
children: [
|
|
4572
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "p-mobile-component-padding border-r border-brand-200 max-w-fit h-full", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4573
|
+
Checkbox,
|
|
4574
|
+
{
|
|
4575
|
+
id: id ? `${id}-select-all-checkbox` : void 0,
|
|
4576
|
+
testid: testid ? `${testid}-select-all-checkbox` : void 0,
|
|
4577
|
+
checked: selectedRowIds.length === data.length,
|
|
4578
|
+
indeterminate: !!selectedRowIds.length && selectedRowIds.length !== data.length,
|
|
4579
|
+
onChange: handleRowSelectAll
|
|
4580
|
+
}
|
|
4581
|
+
) }),
|
|
4582
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4583
|
+
Stack,
|
|
4584
|
+
{
|
|
4585
|
+
horizontal: true,
|
|
4586
|
+
horizontalMobile: true,
|
|
4587
|
+
items: "center",
|
|
4588
|
+
sizing: "component",
|
|
4589
|
+
padding: true,
|
|
4590
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Heading3, { as: "span", color: "text-primary-normal", children: typeof Header === "string" ? Header : (_b = (_a = columns.find((col) => col.id === primaryKey)) == null ? void 0 : _a.header) == null ? void 0 : _b.toString() })
|
|
4591
|
+
}
|
|
4592
|
+
),
|
|
4593
|
+
enableColumnSelector && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ColumnSelector, {})
|
|
4594
|
+
]
|
|
4595
|
+
}
|
|
4596
|
+
) })
|
|
4597
|
+
}
|
|
4598
|
+
);
|
|
4599
|
+
}
|
|
4600
|
+
|
|
4601
|
+
// src/components/MobileDataGrid/GridContextProvider/index.tsx
|
|
4602
|
+
var import_react22 = require("react");
|
|
4603
|
+
|
|
4604
|
+
// src/components/MobileDataGrid/dataGridReducer.ts
|
|
4605
|
+
function dataGridReducer(state, action) {
|
|
4606
|
+
var _a, _b, _c;
|
|
4607
|
+
const { type, payload } = action;
|
|
4608
|
+
let itemIndex = null;
|
|
4609
|
+
if (action.type === "INSERT" && action.pos === "INDEX")
|
|
4610
|
+
itemIndex = action.index;
|
|
4611
|
+
if (action.type === "UPDATE")
|
|
4612
|
+
itemIndex = (_a = action.index) != null ? _a : state.filter(({ id }) => !!id).findIndex(({ id }) => id === action.id);
|
|
4613
|
+
switch (type) {
|
|
4614
|
+
case "SET":
|
|
4615
|
+
return [...payload];
|
|
4616
|
+
case "UPDATE":
|
|
4617
|
+
if (typeof itemIndex !== "number" || itemIndex < 0)
|
|
4618
|
+
throw new Error("action.(id | index) must be provided.");
|
|
4619
|
+
return [
|
|
4620
|
+
...state.slice(0, itemIndex),
|
|
4621
|
+
__spreadProps(__spreadValues(__spreadValues({}, state[itemIndex]), payload), {
|
|
4622
|
+
meta: __spreadValues(__spreadValues({}, (_b = state[itemIndex].meta) != null ? _b : {}), (_c = payload.meta) != null ? _c : {})
|
|
4623
|
+
}),
|
|
4624
|
+
...state.slice(itemIndex + 1)
|
|
4625
|
+
];
|
|
4626
|
+
default:
|
|
4627
|
+
throw new Error("Action type not implemented.");
|
|
4628
|
+
}
|
|
4629
|
+
}
|
|
4630
|
+
|
|
4631
|
+
// src/components/MobileDataGrid/GridContextProvider/index.tsx
|
|
4632
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
4633
|
+
function GridContextProvider(props) {
|
|
4634
|
+
const {
|
|
4635
|
+
initialColumns,
|
|
4636
|
+
id,
|
|
4637
|
+
testid,
|
|
4638
|
+
children,
|
|
4639
|
+
data,
|
|
4640
|
+
numberOfColumnsToShow,
|
|
4641
|
+
primaryKey,
|
|
4642
|
+
getId,
|
|
4643
|
+
onRowSelect
|
|
4644
|
+
} = props;
|
|
4645
|
+
const [columns, dispatch] = (0, import_react22.useReducer)(dataGridReducer, initialColumns);
|
|
4646
|
+
const [selectedRowIds, setSelectedRowIds] = (0, import_react22.useState)([]);
|
|
4647
|
+
const [currentRow, setCurrentRow] = (0, import_react22.useState)(null);
|
|
4648
|
+
const resetColumnVisibility = (0, import_react22.useCallback)(() => {
|
|
4649
|
+
const newColumns = columns.map((column) => {
|
|
4650
|
+
var _a;
|
|
4651
|
+
const initialColumn = initialColumns.find((c) => c.id === column.id);
|
|
4652
|
+
return __spreadProps(__spreadValues({}, column), {
|
|
4653
|
+
meta: __spreadProps(__spreadValues({}, column.meta), {
|
|
4654
|
+
visible: (_a = initialColumn == null ? void 0 : initialColumn.meta) == null ? void 0 : _a.visible
|
|
4655
|
+
})
|
|
4656
|
+
});
|
|
4657
|
+
});
|
|
4658
|
+
dispatch({ type: "SET", payload: newColumns });
|
|
4659
|
+
}, [columns, initialColumns]);
|
|
4660
|
+
const handleRowSelect = (0, import_react22.useCallback)(
|
|
4661
|
+
(item) => {
|
|
4662
|
+
var _a;
|
|
4663
|
+
const rowId = (_a = getId(item)) != null ? _a : "";
|
|
4664
|
+
if (!rowId) return;
|
|
4665
|
+
const nextSelected = selectedRowIds.includes(rowId) ? selectedRowIds.filter((id2) => id2 !== rowId) : [...selectedRowIds, rowId];
|
|
4666
|
+
setSelectedRowIds(nextSelected);
|
|
4667
|
+
if (onRowSelect) onRowSelect(item, nextSelected);
|
|
4668
|
+
},
|
|
4669
|
+
[getId, onRowSelect, selectedRowIds]
|
|
4670
|
+
);
|
|
4671
|
+
const handleRowSelectAll = (0, import_react22.useCallback)(() => {
|
|
4672
|
+
setSelectedRowIds((prev) => {
|
|
4673
|
+
if (prev.length === data.length) {
|
|
4674
|
+
return [];
|
|
4675
|
+
}
|
|
4676
|
+
return data.map(getId).filter((id2) => id2 !== void 0);
|
|
4677
|
+
});
|
|
4678
|
+
}, [data, getId]);
|
|
4679
|
+
const openRowDetail = (0, import_react22.useCallback)((row) => {
|
|
4680
|
+
setCurrentRow(row);
|
|
4681
|
+
}, []);
|
|
4682
|
+
const closeRowDetail = (0, import_react22.useCallback)(() => {
|
|
4683
|
+
setCurrentRow(null);
|
|
4684
|
+
}, []);
|
|
4685
|
+
const visibleColumns = (0, import_react22.useMemo)(() => {
|
|
4686
|
+
const effectiveLimit = typeof numberOfColumnsToShow === "number" ? Math.max(numberOfColumnsToShow - 1, 0) : void 0;
|
|
4687
|
+
if (primaryKey) {
|
|
4688
|
+
const pkColumn = columns.find((col) => col.id === String(primaryKey));
|
|
4689
|
+
const otherColumns = columns.filter(
|
|
4690
|
+
(col) => col.id !== String(primaryKey)
|
|
4691
|
+
);
|
|
4692
|
+
const orderedColumns = pkColumn ? [pkColumn, ...otherColumns] : [...otherColumns];
|
|
4693
|
+
return orderedColumns.filter((x) => {
|
|
4694
|
+
var _a;
|
|
4695
|
+
return ((_a = x.meta) == null ? void 0 : _a.visible) !== false;
|
|
4696
|
+
}).slice(0, effectiveLimit);
|
|
4697
|
+
}
|
|
4698
|
+
return columns.filter((x) => {
|
|
4699
|
+
var _a;
|
|
4700
|
+
return ((_a = x.meta) == null ? void 0 : _a.visible) !== false;
|
|
4701
|
+
}).slice(0, effectiveLimit);
|
|
4702
|
+
}, [columns, numberOfColumnsToShow, primaryKey]);
|
|
4703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4704
|
+
GridContext.Provider,
|
|
4705
|
+
{
|
|
4706
|
+
value: {
|
|
4707
|
+
columns,
|
|
4708
|
+
testid,
|
|
4709
|
+
id,
|
|
4710
|
+
data,
|
|
4711
|
+
selectedRowIds,
|
|
4712
|
+
visibleColumns,
|
|
4713
|
+
numberOfColumnsToShow,
|
|
4714
|
+
primaryKey,
|
|
4715
|
+
dispatch,
|
|
4716
|
+
getId,
|
|
4717
|
+
resetColumnVisibility,
|
|
4718
|
+
handleRowSelect,
|
|
4719
|
+
handleRowSelectAll,
|
|
4720
|
+
isRowDetailOpen: !!currentRow,
|
|
4721
|
+
currentRow,
|
|
4722
|
+
openRowDetail,
|
|
4723
|
+
closeRowDetail
|
|
4724
|
+
},
|
|
4725
|
+
children
|
|
4726
|
+
}
|
|
4727
|
+
);
|
|
4728
|
+
}
|
|
4729
|
+
|
|
4730
|
+
// src/components/Modal.tsx
|
|
4731
|
+
var import_clsx27 = __toESM(require("clsx"), 1);
|
|
4732
|
+
var import_react24 = require("react");
|
|
4733
|
+
|
|
4734
|
+
// src/components/ModalHeader.tsx
|
|
4735
|
+
var import_clsx23 = __toESM(require("clsx"), 1);
|
|
4736
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4737
|
+
var ModalHeader = ({
|
|
4738
|
+
title,
|
|
4739
|
+
hideCloseIcon,
|
|
4740
|
+
headerIcon,
|
|
4741
|
+
headerIconAlign,
|
|
4742
|
+
onClose,
|
|
4743
|
+
id,
|
|
4744
|
+
testid,
|
|
4745
|
+
headerClassname
|
|
4746
|
+
}) => {
|
|
4747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
4748
|
+
"div",
|
|
4749
|
+
{
|
|
4750
|
+
id,
|
|
4751
|
+
"data-testid": testid,
|
|
4752
|
+
className: (0, import_clsx23.default)(
|
|
4753
|
+
"flex justify-between items-center",
|
|
4754
|
+
headerIconAlign === "center" && "justify-center",
|
|
4755
|
+
headerIconAlign === "right" && "justify-end",
|
|
4756
|
+
headerIconAlign === "left" && "justify-start",
|
|
4757
|
+
layoutPaddding,
|
|
4758
|
+
layoutGroupGap,
|
|
4759
|
+
headerClassname
|
|
4760
|
+
),
|
|
4761
|
+
children: [
|
|
4762
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: (0, import_clsx23.default)("flex items-center flex-1", layoutGroupGap), children: [
|
|
4763
|
+
headerIcon,
|
|
4764
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4765
|
+
Heading2,
|
|
4766
|
+
{
|
|
4767
|
+
id: id ? `${id}-title` : void 0,
|
|
4768
|
+
testid: testid ? `${testid}-title` : void 0,
|
|
4769
|
+
as: "p",
|
|
4770
|
+
children: title
|
|
4771
|
+
}
|
|
4772
|
+
)
|
|
4773
|
+
] }),
|
|
4774
|
+
!hideCloseIcon && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4775
|
+
Button,
|
|
4776
|
+
{
|
|
4777
|
+
id: id ? `${id}-close-button` : void 0,
|
|
4778
|
+
testid: testid ? `${testid}-close-button` : void 0,
|
|
4779
|
+
iconOnly: true,
|
|
4780
|
+
variant: "tertiary",
|
|
4781
|
+
onClick: onClose,
|
|
4782
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "text-brand-text-action-primary-normal desktop:text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Icon, { name: "close", size: 24 }) })
|
|
4783
|
+
}
|
|
4784
|
+
)
|
|
4785
|
+
]
|
|
4786
|
+
}
|
|
4787
|
+
);
|
|
4788
|
+
};
|
|
4789
|
+
ModalHeader.displayName = "ModalHeader";
|
|
4790
|
+
|
|
4791
|
+
// src/components/ModalContent.tsx
|
|
4792
|
+
var import_clsx24 = __toESM(require("clsx"), 1);
|
|
4793
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
4794
|
+
function ModalContent({
|
|
4795
|
+
fixedHeightScrolling,
|
|
4796
|
+
children,
|
|
4797
|
+
id,
|
|
4798
|
+
testid
|
|
4799
|
+
}) {
|
|
4800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4801
|
+
"div",
|
|
4802
|
+
{
|
|
4803
|
+
id,
|
|
4804
|
+
"data-testid": testid,
|
|
4805
|
+
className: (0, import_clsx24.default)(
|
|
4806
|
+
"flex-grow desktop:flex-grow-0",
|
|
4807
|
+
layoutPaddding,
|
|
4808
|
+
fixedHeightScrolling && "overflow-auto"
|
|
4809
|
+
),
|
|
4810
|
+
children
|
|
4811
|
+
}
|
|
4812
|
+
);
|
|
4813
|
+
}
|
|
4814
|
+
ModalContent.displayName = "ModalContent";
|
|
4815
|
+
|
|
4816
|
+
// src/components/ModalButtons.tsx
|
|
4817
|
+
var import_clsx25 = __toESM(require("clsx"), 1);
|
|
4818
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4819
|
+
var ModalButtons = ({
|
|
4820
|
+
onClose,
|
|
4821
|
+
onContinue,
|
|
4822
|
+
customActions,
|
|
4823
|
+
id,
|
|
4824
|
+
testid
|
|
4825
|
+
}) => {
|
|
4826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4827
|
+
"div",
|
|
4828
|
+
{
|
|
4829
|
+
id,
|
|
4830
|
+
"data-testid": testid,
|
|
4831
|
+
className: (0, import_clsx25.default)(
|
|
4832
|
+
"border-t border-neutral-300 flex justify-end",
|
|
4833
|
+
layoutPaddding,
|
|
4834
|
+
layoutGroupGap
|
|
4835
|
+
),
|
|
4836
|
+
children: customActions != null ? customActions : /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
4837
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4838
|
+
Button,
|
|
4839
|
+
{
|
|
4840
|
+
id: id ? `${id}-close-button` : void 0,
|
|
4841
|
+
testid: testid ? `${testid}-close-button` : void 0,
|
|
4842
|
+
variant: "secondary",
|
|
4843
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Icon, { name: "close", size: 24 }),
|
|
4844
|
+
onClick: onClose,
|
|
4845
|
+
className: "max-sm:w-full",
|
|
4846
|
+
children: "Close"
|
|
4847
|
+
}
|
|
4848
|
+
),
|
|
4849
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4850
|
+
Button,
|
|
4851
|
+
{
|
|
4852
|
+
id: id ? `${id}-continue-button` : void 0,
|
|
4853
|
+
testid: testid ? `${testid}-continue-button` : void 0,
|
|
4854
|
+
variant: "primary",
|
|
4855
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Icon, { name: "check", size: 24 }),
|
|
4856
|
+
className: "max-sm:w-full",
|
|
4857
|
+
onClick: onContinue,
|
|
4858
|
+
children: "Continue"
|
|
4859
|
+
}
|
|
4860
|
+
)
|
|
4861
|
+
] })
|
|
4862
|
+
}
|
|
4863
|
+
);
|
|
4864
|
+
};
|
|
4865
|
+
ModalButtons.displayName = "ModalButtons";
|
|
4866
|
+
|
|
4867
|
+
// src/components/ModalScrim.tsx
|
|
4868
|
+
var import_clsx26 = __toESM(require("clsx"), 1);
|
|
4869
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4870
|
+
var ModalScrim = ({
|
|
4871
|
+
show = false,
|
|
4872
|
+
size = "small",
|
|
4873
|
+
children,
|
|
4874
|
+
onClick,
|
|
4875
|
+
ref,
|
|
4876
|
+
id,
|
|
4877
|
+
testid
|
|
4878
|
+
}) => {
|
|
4879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4880
|
+
"div",
|
|
4881
|
+
{
|
|
4882
|
+
id,
|
|
4883
|
+
"data-testid": testid,
|
|
4884
|
+
className: (0, import_clsx26.default)(
|
|
4885
|
+
"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",
|
|
4886
|
+
!show && " pointer-events-none",
|
|
4887
|
+
size === "small" && "p-4",
|
|
4888
|
+
size === "screen" ? "desktop:p-0" : "desktop:p-4",
|
|
4889
|
+
"inset-0 z-50"
|
|
4890
|
+
),
|
|
4891
|
+
onMouseDown: onClick,
|
|
4892
|
+
ref,
|
|
4893
|
+
children
|
|
4894
|
+
}
|
|
4895
|
+
);
|
|
4896
|
+
};
|
|
4897
|
+
ModalScrim.displayName = "ModalScrim";
|
|
4898
|
+
|
|
4899
|
+
// src/components/Modal.tsx
|
|
4900
|
+
var import_react_dom3 = require("react-dom");
|
|
4901
|
+
var import_react_use = require("react-use");
|
|
4902
|
+
|
|
4903
|
+
// src/components/useMounted.tsx
|
|
4904
|
+
var import_react23 = require("react");
|
|
4905
|
+
var useMounted = () => {
|
|
4906
|
+
const [isMounted, setIsMounted] = (0, import_react23.useState)(false);
|
|
4907
|
+
(0, import_react23.useEffect)(() => {
|
|
4908
|
+
setIsMounted(true);
|
|
4909
|
+
return () => setIsMounted(false);
|
|
4910
|
+
}, []);
|
|
4911
|
+
return isMounted;
|
|
4912
|
+
};
|
|
4913
|
+
|
|
4914
|
+
// src/components/Modal.tsx
|
|
4915
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4916
|
+
var fadeInScale = (element, duration = 300) => element.animate(
|
|
4917
|
+
[
|
|
4918
|
+
{ opacity: 0, transform: "scale(0.95)" },
|
|
4919
|
+
{ opacity: 1, transform: "scale(1)" }
|
|
4920
|
+
],
|
|
4921
|
+
{
|
|
4922
|
+
duration,
|
|
4923
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
4924
|
+
fill: "both"
|
|
4925
|
+
}
|
|
4926
|
+
);
|
|
4927
|
+
var fadeOutScale = (element, duration = 200) => element.animate(
|
|
4928
|
+
[
|
|
4929
|
+
{ opacity: 1, transform: "scale(1)" },
|
|
4930
|
+
{ opacity: 0, transform: "scale(0.95)" }
|
|
4931
|
+
],
|
|
4932
|
+
{
|
|
4933
|
+
duration,
|
|
4934
|
+
easing: "ease-in-out",
|
|
4935
|
+
fill: "both"
|
|
4936
|
+
}
|
|
4937
|
+
);
|
|
4938
|
+
var bgFadeIn = (element, duration = 300) => element.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
4939
|
+
duration,
|
|
4940
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
4941
|
+
fill: "both"
|
|
4942
|
+
});
|
|
4943
|
+
var bgFadeOut = (element, duration = 200) => element.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
4944
|
+
duration,
|
|
4945
|
+
easing: "ease-in-out",
|
|
4946
|
+
fill: "both"
|
|
4947
|
+
});
|
|
4948
|
+
var whenAllAnimationsFinish = (animations, callback) => {
|
|
4949
|
+
let finishedCount = 0;
|
|
4950
|
+
animations.forEach((animation) => {
|
|
4951
|
+
animation.onfinish = () => {
|
|
4952
|
+
finishedCount += 1;
|
|
4953
|
+
if (finishedCount === animations.length) {
|
|
4954
|
+
callback();
|
|
4955
|
+
}
|
|
4956
|
+
};
|
|
4957
|
+
});
|
|
4958
|
+
};
|
|
4959
|
+
var sizes = {
|
|
4960
|
+
small: {
|
|
4961
|
+
sizeClass: "max-h-screen desktop:max-w-120 rounded-sm"
|
|
4962
|
+
},
|
|
4963
|
+
medium: {
|
|
4964
|
+
sizeClass: "desktop:max-w-180 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
|
|
4965
|
+
},
|
|
4966
|
+
large: {
|
|
4967
|
+
sizeClass: "desktop:max-w-240 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
|
|
4968
|
+
},
|
|
4969
|
+
"x-large": {
|
|
4970
|
+
sizeClass: "desktop:max-w-300 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
|
|
4971
|
+
},
|
|
4972
|
+
screen: {
|
|
4973
|
+
sizeClass: "w-screen h-screen max-w-screen !rounded-none"
|
|
4974
|
+
}
|
|
4975
|
+
};
|
|
4976
|
+
var Modal = ({
|
|
4977
|
+
id,
|
|
4978
|
+
testid,
|
|
4979
|
+
title,
|
|
4980
|
+
open = false,
|
|
4981
|
+
size = "small",
|
|
4982
|
+
className,
|
|
4983
|
+
children,
|
|
4984
|
+
onClose,
|
|
4985
|
+
onContinue,
|
|
4986
|
+
closeOnBackdropClick = true,
|
|
4987
|
+
showButtons = false,
|
|
4988
|
+
hideCloseIcon = false,
|
|
4989
|
+
headerIcon,
|
|
4990
|
+
headerIconAlign,
|
|
4991
|
+
fixedHeightScrolling = false,
|
|
4992
|
+
customActions,
|
|
4993
|
+
headerClassname,
|
|
4994
|
+
customFooter,
|
|
4995
|
+
noWrapper
|
|
4996
|
+
}) => {
|
|
4997
|
+
var _a;
|
|
4998
|
+
const mounted = useMounted();
|
|
4999
|
+
const modalRef = (0, import_react24.useRef)(null);
|
|
5000
|
+
const bgRef = (0, import_react24.useRef)(null);
|
|
5001
|
+
const wasOpen = (0, import_react_use.usePrevious)(open);
|
|
5002
|
+
const isMobile = useMatchesMobile();
|
|
5003
|
+
const computedFixedHeightScrolling = isMobile || fixedHeightScrolling;
|
|
5004
|
+
(0, import_react24.useEffect)(() => {
|
|
5005
|
+
if (!mounted) return;
|
|
5006
|
+
if (!modalRef.current || !bgRef.current) {
|
|
5007
|
+
console.error("Modal or background reference is not set.");
|
|
5008
|
+
return;
|
|
5009
|
+
}
|
|
5010
|
+
if (wasOpen === void 0) return;
|
|
5011
|
+
if (wasOpen && !open) {
|
|
5012
|
+
const modalAnimation = fadeOutScale(modalRef.current);
|
|
5013
|
+
const bgAnimation = bgFadeOut(bgRef.current);
|
|
5014
|
+
whenAllAnimationsFinish([modalAnimation, bgAnimation], () => {
|
|
5015
|
+
if (onClose) {
|
|
5016
|
+
onClose();
|
|
5017
|
+
}
|
|
5018
|
+
});
|
|
5019
|
+
} else if (!wasOpen && open) {
|
|
5020
|
+
fadeInScale(modalRef.current);
|
|
5021
|
+
bgFadeIn(bgRef.current);
|
|
5022
|
+
}
|
|
5023
|
+
}, [mounted, onClose, open, wasOpen]);
|
|
5024
|
+
const handleKeyDown = (0, import_react24.useCallback)(
|
|
5025
|
+
(e) => {
|
|
5026
|
+
if (e.key === "Escape") {
|
|
5027
|
+
if (onClose) {
|
|
5028
|
+
e.preventDefault();
|
|
5029
|
+
onClose();
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
},
|
|
5033
|
+
[onClose]
|
|
5034
|
+
);
|
|
5035
|
+
const handleClose = (0, import_react24.useCallback)(() => {
|
|
5036
|
+
if (onClose) {
|
|
5037
|
+
onClose();
|
|
5038
|
+
}
|
|
5039
|
+
}, [onClose]);
|
|
5040
|
+
(0, import_react24.useEffect)(() => {
|
|
5041
|
+
if (open) {
|
|
5042
|
+
document.addEventListener("keyup", handleKeyDown);
|
|
5043
|
+
}
|
|
5044
|
+
return () => {
|
|
5045
|
+
document.removeEventListener("keyup", handleKeyDown);
|
|
5046
|
+
};
|
|
5047
|
+
}, [open, handleKeyDown]);
|
|
5048
|
+
(0, import_react24.useEffect)(() => {
|
|
5049
|
+
if (!open) return;
|
|
5050
|
+
const scrollY = window.scrollY;
|
|
5051
|
+
const body = document.body;
|
|
5052
|
+
body.style.position = "fixed";
|
|
5053
|
+
body.style.top = `-${scrollY}px`;
|
|
5054
|
+
body.style.left = "0";
|
|
5055
|
+
body.style.right = "0";
|
|
5056
|
+
body.style.overflow = "hidden";
|
|
5057
|
+
body.style.width = "100%";
|
|
5058
|
+
return () => {
|
|
5059
|
+
body.style.position = "";
|
|
5060
|
+
body.style.top = "";
|
|
5061
|
+
body.style.left = "";
|
|
5062
|
+
body.style.right = "";
|
|
5063
|
+
body.style.overflow = "";
|
|
5064
|
+
body.style.width = "";
|
|
5065
|
+
window.scrollTo(0, scrollY);
|
|
5066
|
+
};
|
|
5067
|
+
}, [open]);
|
|
5068
|
+
const { sizeClass } = (_a = sizes[size]) != null ? _a : sizes.small;
|
|
5069
|
+
const backgroundClickHandler = (0, import_react24.useCallback)(
|
|
5070
|
+
(e) => {
|
|
5071
|
+
const target = e.target;
|
|
5072
|
+
const currentTarget = e.currentTarget;
|
|
5073
|
+
if (currentTarget.contains(target) && currentTarget !== target) {
|
|
5074
|
+
e.stopPropagation();
|
|
5075
|
+
return;
|
|
5076
|
+
}
|
|
5077
|
+
if (open && closeOnBackdropClick) {
|
|
5078
|
+
handleClose();
|
|
5079
|
+
}
|
|
5080
|
+
},
|
|
5081
|
+
[open, closeOnBackdropClick, handleClose]
|
|
5082
|
+
);
|
|
5083
|
+
if (!mounted) {
|
|
5084
|
+
return null;
|
|
5085
|
+
}
|
|
5086
|
+
return (0, import_react_dom3.createPortal)(
|
|
5087
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5088
|
+
ModalScrim,
|
|
5089
|
+
{
|
|
5090
|
+
id: id ? `${id}-scrim` : void 0,
|
|
5091
|
+
testid: testid ? `${testid}-scrim` : void 0,
|
|
5092
|
+
size,
|
|
5093
|
+
ref: bgRef,
|
|
5094
|
+
show: open,
|
|
5095
|
+
onClick: backgroundClickHandler,
|
|
5096
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
5097
|
+
"div",
|
|
5098
|
+
{
|
|
5099
|
+
id,
|
|
5100
|
+
"data-testid": testid,
|
|
5101
|
+
ref: modalRef,
|
|
5102
|
+
className: (0, import_clsx27.default)(
|
|
5103
|
+
"shadow-md rounded-sm flex flex-col overflow-hidden w-full opacity-0 h-fit",
|
|
5104
|
+
computedFixedHeightScrolling && size !== "screen" && "desktop:max-h-[calc(100vh-32px)] desktop:h-auto",
|
|
5105
|
+
className,
|
|
5106
|
+
!(className == null ? void 0 : className.includes("bg-")) && "bg-white",
|
|
5107
|
+
sizeClass
|
|
5108
|
+
),
|
|
5109
|
+
onClick: (e) => e.stopPropagation(),
|
|
5110
|
+
children: [
|
|
5111
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5112
|
+
ModalHeader,
|
|
5113
|
+
{
|
|
5114
|
+
id: id ? `${id}-header` : void 0,
|
|
5115
|
+
testid: testid ? `${testid}-header` : void 0,
|
|
5116
|
+
title,
|
|
5117
|
+
onClose: handleClose,
|
|
5118
|
+
hideCloseIcon,
|
|
5119
|
+
headerIcon,
|
|
5120
|
+
headerIconAlign,
|
|
5121
|
+
headerClassname
|
|
5122
|
+
}
|
|
5123
|
+
),
|
|
5124
|
+
children && (size !== "screen" || noWrapper) ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5125
|
+
ModalContent,
|
|
5126
|
+
{
|
|
5127
|
+
id: id ? `${id}-content` : void 0,
|
|
5128
|
+
testid: testid ? `${testid}-content` : void 0,
|
|
5129
|
+
fixedHeightScrolling: computedFixedHeightScrolling,
|
|
5130
|
+
children
|
|
5131
|
+
}
|
|
5132
|
+
) : children,
|
|
5133
|
+
showButtons ? customFooter ? customActions : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5134
|
+
ModalButtons,
|
|
5135
|
+
{
|
|
5136
|
+
id: id ? `${id}-buttons` : void 0,
|
|
5137
|
+
testid: testid ? `${testid}-buttons` : void 0,
|
|
5138
|
+
onClose: handleClose,
|
|
5139
|
+
onContinue,
|
|
5140
|
+
customActions
|
|
5141
|
+
}
|
|
5142
|
+
) : null
|
|
5143
|
+
]
|
|
5144
|
+
}
|
|
5145
|
+
)
|
|
5146
|
+
}
|
|
5147
|
+
),
|
|
5148
|
+
findDocumentRoot(bgRef.current)
|
|
5149
|
+
);
|
|
5150
|
+
};
|
|
5151
|
+
Modal.displayName = "Modal";
|
|
5152
|
+
|
|
5153
|
+
// src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx
|
|
5154
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
5155
|
+
function MobileDataGridColumn(props) {
|
|
5156
|
+
var _a;
|
|
5157
|
+
const { column, data } = props;
|
|
5158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mb-2 grid grid-cols-2 gap-2 px-3 flex-1", children: [
|
|
5159
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Paragraph, { color: "text-secondary-normal", className: "text-left", children: [
|
|
5160
|
+
(_a = column.header) == null ? void 0 : _a.toString(),
|
|
5161
|
+
":"
|
|
5162
|
+
] }),
|
|
5163
|
+
" ",
|
|
5164
|
+
column.id && data[column.id] ? data[column.id] : null
|
|
5165
|
+
] });
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5168
|
+
// src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx
|
|
5169
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
5170
|
+
function ModalContent2() {
|
|
5171
|
+
const context = useGridContext();
|
|
5172
|
+
const { columns, currentRow } = context;
|
|
5173
|
+
if (!currentRow) return null;
|
|
5174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Stack, { sizing: "layout-group", children: columns.filter((x) => {
|
|
5175
|
+
var _a;
|
|
5176
|
+
return !((_a = x.id) == null ? void 0 : _a.startsWith("__"));
|
|
5177
|
+
}).map(
|
|
5178
|
+
(column, index) => {
|
|
5179
|
+
var _a, _b;
|
|
5180
|
+
return ((_a = column.meta) == null ? void 0 : _a.useCustomRenderer) && column.meta.mobileCell && column.id ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
5181
|
+
"div",
|
|
5182
|
+
{
|
|
5183
|
+
className: "mb-2 grid grid-cols-2 gap-2 px-3 items-center flex-1",
|
|
5184
|
+
children: [
|
|
5185
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Paragraph, { color: "text-secondary-normal", className: "text-left", children: [
|
|
5186
|
+
(_b = column.header) == null ? void 0 : _b.toString(),
|
|
5187
|
+
":"
|
|
5188
|
+
] }),
|
|
5189
|
+
" ",
|
|
5190
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5191
|
+
column.meta.mobileCell,
|
|
5192
|
+
{
|
|
5193
|
+
column,
|
|
5194
|
+
row: currentRow,
|
|
5195
|
+
cellValue: currentRow == null ? void 0 : currentRow[column.id]
|
|
5196
|
+
}
|
|
5197
|
+
)
|
|
5198
|
+
]
|
|
5199
|
+
},
|
|
5200
|
+
`${column.id}-${index}`
|
|
5201
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5202
|
+
MobileDataGridColumn,
|
|
5203
|
+
{
|
|
5204
|
+
column,
|
|
5205
|
+
data: currentRow
|
|
5206
|
+
},
|
|
5207
|
+
`${column.id}-${index}`
|
|
5208
|
+
);
|
|
5209
|
+
}
|
|
5210
|
+
) });
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
// src/components/MobileDataGrid/RowDetailModalProvider/index.tsx
|
|
5214
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
5215
|
+
function RowDetailModalProvider() {
|
|
5216
|
+
var _a;
|
|
5217
|
+
const context = useGridContext();
|
|
5218
|
+
const {
|
|
5219
|
+
id,
|
|
5220
|
+
testid,
|
|
5221
|
+
isRowDetailOpen,
|
|
5222
|
+
currentRow,
|
|
5223
|
+
primaryKey,
|
|
5224
|
+
closeRowDetail
|
|
5225
|
+
} = context;
|
|
5226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
5227
|
+
Modal,
|
|
5228
|
+
{
|
|
5229
|
+
fixedHeightScrolling: true,
|
|
5230
|
+
open: isRowDetailOpen,
|
|
5231
|
+
onClose: closeRowDetail,
|
|
5232
|
+
hideCloseIcon: true,
|
|
5233
|
+
size: "medium",
|
|
5234
|
+
className: "!p-0",
|
|
5235
|
+
headerIcon: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
5236
|
+
Stack,
|
|
5237
|
+
{
|
|
5238
|
+
horizontal: true,
|
|
5239
|
+
horizontalMobile: true,
|
|
5240
|
+
items: "center",
|
|
5241
|
+
justify: "between",
|
|
5242
|
+
width: "full",
|
|
5243
|
+
children: [
|
|
5244
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Heading2, { children: (_a = currentRow == null ? void 0 : currentRow[primaryKey != null ? primaryKey : "id"]) != null ? _a : "Grid Detail" }),
|
|
5245
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
5246
|
+
Button,
|
|
5247
|
+
{
|
|
5248
|
+
id: id ? `${id}-open-in-new-button` : void 0,
|
|
5249
|
+
testid: testid ? `${testid}-open-in-new-button` : void 0,
|
|
5250
|
+
iconOnly: true,
|
|
5251
|
+
variant: "tertiary",
|
|
5252
|
+
onClick: closeRowDetail,
|
|
5253
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "open_in_new", size: 24 }) })
|
|
5254
|
+
}
|
|
5255
|
+
)
|
|
5256
|
+
]
|
|
5257
|
+
}
|
|
5258
|
+
),
|
|
5259
|
+
customActions: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Button, { onClick: closeRowDetail, className: "w-full", children: "Close" }),
|
|
5260
|
+
showButtons: true,
|
|
5261
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "bg-white max-h-full flex flex-col flex-grow-1", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ModalContent2, {}) })
|
|
5262
|
+
}
|
|
5263
|
+
);
|
|
5264
|
+
}
|
|
5265
|
+
|
|
5266
|
+
// src/components/MobileDataGrid/ColumnList.tsx
|
|
5267
|
+
var import_clsx29 = __toESM(require("clsx"), 1);
|
|
5268
|
+
|
|
5269
|
+
// src/components/MobileDataGrid/MobileDataGridCard/index.tsx
|
|
5270
|
+
var import_clsx28 = __toESM(require("clsx"), 1);
|
|
5271
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
5272
|
+
function MobileDataGridCard({
|
|
5273
|
+
renderLink,
|
|
5274
|
+
renderChevron = true,
|
|
5275
|
+
data,
|
|
5276
|
+
enableRowSelection,
|
|
5277
|
+
selected,
|
|
5278
|
+
rowActions
|
|
5279
|
+
}) {
|
|
5280
|
+
var _a;
|
|
5281
|
+
const context = useGridContext();
|
|
5282
|
+
const { id, testid, visibleColumns, getId, handleRowSelect, openRowDetail } = context;
|
|
5283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
5284
|
+
"li",
|
|
5285
|
+
{
|
|
5286
|
+
id: id ? `${id}-card-${getId(data)}` : void 0,
|
|
5287
|
+
"data-testid": testid ? `${testid}-card-${getId(data)}` : void 0,
|
|
5288
|
+
className: (0, import_clsx28.default)(
|
|
5289
|
+
"hover:bg-action-100 cursor-pointer list-none",
|
|
5290
|
+
selected ? "bg-action-100" : "bg-background-grouped-primary-normal"
|
|
5291
|
+
),
|
|
5292
|
+
onClick: () => openRowDetail(data),
|
|
5293
|
+
children: [
|
|
5294
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Stack, { sizing: "component", children: [
|
|
5295
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Stack, { horizontal: true, horizontalMobile: true, items: "center", justify: "between", children: [
|
|
5296
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5297
|
+
Stack,
|
|
5298
|
+
{
|
|
5299
|
+
sizing: "component",
|
|
5300
|
+
padding: true,
|
|
5301
|
+
width: "fit",
|
|
5302
|
+
onClick: (e) => e.stopPropagation(),
|
|
5303
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5304
|
+
Checkbox,
|
|
5305
|
+
{
|
|
5306
|
+
id: id ? `${id}-${getId(data)}-select-checkbox` : void 0,
|
|
5307
|
+
testid: testid ? `${testid}-${getId(data)}-select-checkbox` : void 0,
|
|
5308
|
+
checked: selected,
|
|
5309
|
+
onChange: () => handleRowSelect(data)
|
|
5310
|
+
}
|
|
5311
|
+
)
|
|
5312
|
+
}
|
|
5313
|
+
),
|
|
5314
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5315
|
+
Stack,
|
|
5316
|
+
{
|
|
5317
|
+
sizing: "component",
|
|
5318
|
+
padding: true,
|
|
5319
|
+
onClick: (e) => e.stopPropagation(),
|
|
5320
|
+
children: renderLink ? renderLink(data) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Subheader, { children: String((_a = data[context.primaryKey]) != null ? _a : "") })
|
|
5321
|
+
}
|
|
5322
|
+
),
|
|
5323
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5324
|
+
Stack,
|
|
5325
|
+
{
|
|
5326
|
+
horizontal: true,
|
|
5327
|
+
horizontalMobile: true,
|
|
5328
|
+
items: "center",
|
|
5329
|
+
justify: "end",
|
|
5330
|
+
sizing: "component",
|
|
5331
|
+
onClick: (e) => e.stopPropagation(),
|
|
5332
|
+
children: rowActions && (typeof rowActions === "function" ? rowActions(data) : rowActions)
|
|
5333
|
+
}
|
|
5334
|
+
)
|
|
5335
|
+
] }),
|
|
5336
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Stack, { sizing: "layout-group", children: visibleColumns.filter((x) => {
|
|
5337
|
+
var _a2, _b;
|
|
5338
|
+
return ((_a2 = x.meta) == null ? void 0 : _a2.visible) !== false && !((_b = x.id) == null ? void 0 : _b.startsWith("__"));
|
|
5339
|
+
}).map(
|
|
5340
|
+
(column, index) => {
|
|
5341
|
+
var _a2, _b;
|
|
5342
|
+
return ((_a2 = column.meta) == null ? void 0 : _a2.useCustomRenderer) && column.meta.mobileCell && column.id ? /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
5343
|
+
"div",
|
|
5344
|
+
{
|
|
5345
|
+
className: "mb-2 grid grid-cols-2 gap-2 px-3 items-center flex-1",
|
|
5346
|
+
children: [
|
|
5347
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
5348
|
+
Paragraph,
|
|
5349
|
+
{
|
|
5350
|
+
color: "text-secondary-normal",
|
|
5351
|
+
className: "text-left",
|
|
5352
|
+
children: [
|
|
5353
|
+
(_b = column.header) == null ? void 0 : _b.toString(),
|
|
5354
|
+
":"
|
|
5355
|
+
]
|
|
5356
|
+
}
|
|
5357
|
+
),
|
|
5358
|
+
" ",
|
|
5359
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5360
|
+
column.meta.mobileCell,
|
|
5361
|
+
{
|
|
5362
|
+
column,
|
|
5363
|
+
row: data,
|
|
5364
|
+
cellValue: data[column.id]
|
|
5365
|
+
}
|
|
5366
|
+
)
|
|
5367
|
+
]
|
|
5368
|
+
},
|
|
5369
|
+
`${column.id}-${index}`
|
|
5370
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
5371
|
+
MobileDataGridColumn,
|
|
5372
|
+
{
|
|
5373
|
+
column,
|
|
5374
|
+
data
|
|
5375
|
+
},
|
|
5376
|
+
`${column.id}-${index}`
|
|
5377
|
+
);
|
|
5378
|
+
}
|
|
5379
|
+
) })
|
|
5380
|
+
] }),
|
|
5381
|
+
renderChevron && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Stack, { items: "center", justify: "center", horizontal: true, horizontalMobile: true, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Icon, { name: "keyboard_arrow_down" }) })
|
|
5382
|
+
]
|
|
5383
|
+
}
|
|
5384
|
+
);
|
|
5385
|
+
}
|
|
5386
|
+
|
|
5387
|
+
// src/components/MobileDataGrid/ColumnList.tsx
|
|
5388
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
5389
|
+
function ColumnList(props) {
|
|
5390
|
+
const {
|
|
5391
|
+
withBorder,
|
|
5392
|
+
renderLink,
|
|
5393
|
+
renderChevron,
|
|
5394
|
+
footer: Footer,
|
|
5395
|
+
enableRowSelection,
|
|
5396
|
+
rowActions
|
|
5397
|
+
} = props;
|
|
5398
|
+
const ctx = useGridContext();
|
|
5399
|
+
const { id, testid, data, getId, selectedRowIds } = ctx;
|
|
5400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
5401
|
+
"div",
|
|
5402
|
+
{
|
|
5403
|
+
className: (0, import_clsx29.default)(
|
|
5404
|
+
"flex flex-col flex-1 relative overflow-y-auto overflow-x-hidden",
|
|
5405
|
+
!!Footer && "mb-20"
|
|
5406
|
+
),
|
|
5407
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
5408
|
+
"ul",
|
|
5409
|
+
{
|
|
5410
|
+
id,
|
|
5411
|
+
"data-testid": testid,
|
|
5412
|
+
className: (0, import_clsx29.default)(
|
|
5413
|
+
"rounded absolute top-0 left-0 w-full flex-1",
|
|
5414
|
+
"divide-y divide-border-primary-normal",
|
|
5415
|
+
withBorder && "border border-border-primary-normal"
|
|
5416
|
+
),
|
|
5417
|
+
children: [
|
|
5418
|
+
data.map((item) => {
|
|
5419
|
+
const id2 = getId(item);
|
|
5420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
5421
|
+
MobileDataGridCard,
|
|
5422
|
+
{
|
|
5423
|
+
data: item,
|
|
5424
|
+
renderLink,
|
|
5425
|
+
enableRowSelection,
|
|
5426
|
+
selected: !!id2 && selectedRowIds.includes(id2),
|
|
5427
|
+
renderChevron,
|
|
5428
|
+
rowActions
|
|
5429
|
+
},
|
|
5430
|
+
id2
|
|
5431
|
+
);
|
|
5432
|
+
}),
|
|
5433
|
+
!!Footer && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "fixed left-0 right-0 bottom-0 flex flex-col w-full min-h-20", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Footer, __spreadValues({}, ctx)) })
|
|
5434
|
+
]
|
|
5435
|
+
}
|
|
5436
|
+
)
|
|
5437
|
+
}
|
|
5438
|
+
);
|
|
5439
|
+
}
|
|
5440
|
+
|
|
5441
|
+
// src/components/MobileDataGrid/index.tsx
|
|
5442
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
5443
|
+
function MobileDataGrid(props) {
|
|
5444
|
+
const {
|
|
5445
|
+
columns,
|
|
5446
|
+
data,
|
|
5447
|
+
renderLink,
|
|
5448
|
+
renderChevron,
|
|
5449
|
+
getId,
|
|
5450
|
+
id,
|
|
5451
|
+
testid,
|
|
5452
|
+
enableColumnSelector,
|
|
5453
|
+
enableRowSelection,
|
|
5454
|
+
header,
|
|
5455
|
+
withBorder = true,
|
|
5456
|
+
footer,
|
|
5457
|
+
onRowSelect,
|
|
5458
|
+
numberOfColumnsToShow,
|
|
5459
|
+
primaryKey,
|
|
5460
|
+
hideHeader,
|
|
5461
|
+
rowActions,
|
|
5462
|
+
rounded
|
|
5463
|
+
} = props;
|
|
5464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
5465
|
+
GridContextProvider,
|
|
5466
|
+
{
|
|
5467
|
+
initialColumns: columns,
|
|
5468
|
+
id,
|
|
5469
|
+
testid,
|
|
5470
|
+
data,
|
|
5471
|
+
getId,
|
|
5472
|
+
onRowSelect,
|
|
5473
|
+
numberOfColumnsToShow,
|
|
5474
|
+
primaryKey,
|
|
5475
|
+
children: [
|
|
5476
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
5477
|
+
Stack,
|
|
5478
|
+
{
|
|
5479
|
+
height: "full",
|
|
5480
|
+
rounded,
|
|
5481
|
+
overflowX: "hidden",
|
|
5482
|
+
overflowY: "hidden",
|
|
5483
|
+
children: [
|
|
5484
|
+
!hideHeader && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
5485
|
+
MobileDataGridHeader,
|
|
5486
|
+
{
|
|
5487
|
+
header,
|
|
5488
|
+
enableColumnSelector,
|
|
5489
|
+
enableRowSelection
|
|
5490
|
+
}
|
|
5491
|
+
),
|
|
5492
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
5493
|
+
ColumnList,
|
|
5494
|
+
{
|
|
5495
|
+
withBorder,
|
|
5496
|
+
renderLink,
|
|
5497
|
+
renderChevron,
|
|
5498
|
+
enableRowSelection,
|
|
5499
|
+
footer,
|
|
5500
|
+
rowActions
|
|
5501
|
+
}
|
|
5502
|
+
)
|
|
5503
|
+
]
|
|
5504
|
+
}
|
|
5505
|
+
),
|
|
5506
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RowDetailModalProvider, {})
|
|
5507
|
+
]
|
|
5508
|
+
}
|
|
5509
|
+
);
|
|
5510
|
+
}
|
|
5511
|
+
|
|
5512
|
+
// src/components/ImagePlaceholder.tsx
|
|
5513
|
+
var import_react25 = require("react");
|
|
5514
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
5515
|
+
function ImagePlaceholder(props) {
|
|
5516
|
+
const clipId = (0, import_react25.useId)();
|
|
5517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
5518
|
+
"svg",
|
|
5519
|
+
__spreadProps(__spreadValues({
|
|
5520
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5521
|
+
width: 242,
|
|
5522
|
+
height: 243,
|
|
5523
|
+
fill: "none"
|
|
5524
|
+
}, props), {
|
|
5525
|
+
children: [
|
|
5526
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("g", { clipPath: `url(#${clipId})`, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("rect", { width: props.width, height: props.width, fill: "#F7F7F7", rx: 2 }) }),
|
|
5527
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("rect", { width: props.width, height: props.width, fill: "#fff", rx: 2 }) }) })
|
|
5528
|
+
]
|
|
5529
|
+
})
|
|
5530
|
+
);
|
|
5531
|
+
}
|
|
5532
|
+
|
|
5533
|
+
// src/components/ProductImagePreview/Thumbnail.tsx
|
|
5534
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
5535
|
+
function Thumbnail({
|
|
5536
|
+
width,
|
|
5537
|
+
height,
|
|
5538
|
+
src,
|
|
5539
|
+
alt,
|
|
5540
|
+
isActive,
|
|
5541
|
+
onClick,
|
|
5542
|
+
isPlaceholder = false
|
|
5543
|
+
}) {
|
|
5544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5545
|
+
"button",
|
|
5546
|
+
{
|
|
5547
|
+
type: "button",
|
|
5548
|
+
onClick,
|
|
5549
|
+
className: [
|
|
5550
|
+
"cursor-pointer relative overflow-hidden rounded aspect-square w-full",
|
|
5551
|
+
// base radius, square when no explicit size
|
|
5552
|
+
"focus:outline-none",
|
|
5553
|
+
isActive && !isPlaceholder && "ring-[3px] ring-offset-1 ring-border-action-normal ring-offset-white opacity-70"
|
|
5554
|
+
].join(" "),
|
|
5555
|
+
style: { maxWidth: width, maxHeight: height, aspectRatio: "1 / 1" },
|
|
5556
|
+
"aria-pressed": isActive && !isPlaceholder ? "true" : "false",
|
|
5557
|
+
children: isPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ImagePlaceholder, { width: 115, height: 115 }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5558
|
+
"img",
|
|
5559
|
+
{
|
|
5560
|
+
src,
|
|
5561
|
+
alt,
|
|
5562
|
+
className: "object-cover w-full h-full select-none",
|
|
5563
|
+
draggable: false,
|
|
5564
|
+
loading: "lazy"
|
|
5565
|
+
}
|
|
5566
|
+
)
|
|
5567
|
+
}
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
5570
|
+
|
|
5571
|
+
// src/components/Grid.tsx
|
|
5572
|
+
var import_react26 = require("react");
|
|
5573
|
+
var import_clsx30 = __toESM(require("clsx"), 1);
|
|
5574
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
5575
|
+
var COLUMNS_WITH_SIDE_MENU_MAP = {
|
|
5576
|
+
1: "grid-cols-1",
|
|
5577
|
+
2: "sm:grid-cols-2",
|
|
5578
|
+
3: "sm:grid-cols-2 md:grid-cols-3",
|
|
5579
|
+
4: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",
|
|
5580
|
+
5: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",
|
|
5581
|
+
6: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",
|
|
5582
|
+
7: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6",
|
|
5583
|
+
8: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6",
|
|
5584
|
+
9: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6",
|
|
5585
|
+
10: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6",
|
|
5586
|
+
11: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-8",
|
|
5587
|
+
12: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-8"
|
|
5588
|
+
};
|
|
5589
|
+
var COLUMNS_WITHOUT_SIDE_MENU_MAP = {
|
|
5590
|
+
1: "grid-cols-1",
|
|
5591
|
+
2: "sm:grid-cols-2",
|
|
5592
|
+
3: "sm:grid-cols-2 md:grid-cols-3",
|
|
5593
|
+
4: "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4",
|
|
5594
|
+
5: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",
|
|
5595
|
+
6: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6",
|
|
5596
|
+
7: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-7",
|
|
5597
|
+
8: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-8",
|
|
5598
|
+
9: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-9",
|
|
5599
|
+
10: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-10",
|
|
5600
|
+
11: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-11",
|
|
5601
|
+
12: "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12"
|
|
5602
|
+
};
|
|
5603
|
+
var getChildCountBasedClasses = (childCount, hasSideMenu) => {
|
|
5604
|
+
if (hasSideMenu) {
|
|
5605
|
+
if (childCount <= 1) return "grid-cols-1";
|
|
5606
|
+
if (childCount <= 2) return "sm:grid-cols-2";
|
|
5607
|
+
if (childCount === 3) return "sm:grid-cols-2 md:grid-cols-3";
|
|
5608
|
+
if (childCount <= 5) return "sm:grid-cols-2 md:grid-cols-3";
|
|
5609
|
+
return "sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6";
|
|
5610
|
+
}
|
|
5611
|
+
if (childCount <= 1) return "grid-cols-1";
|
|
5612
|
+
if (childCount <= 2) return "sm:grid-cols-2";
|
|
5613
|
+
if (childCount === 3) return "sm:grid-cols-2 md:grid-cols-3";
|
|
5614
|
+
if (childCount <= 5) return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4";
|
|
5615
|
+
if (childCount <= 6)
|
|
5616
|
+
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6";
|
|
5617
|
+
if (childCount === 7)
|
|
5618
|
+
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6";
|
|
5619
|
+
if (childCount <= 11)
|
|
5620
|
+
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 2xl:grid-cols-8";
|
|
5621
|
+
return "sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12";
|
|
5622
|
+
};
|
|
5623
|
+
var getGridClasses = (childCount, hasSideMenu, columns) => {
|
|
5624
|
+
var _a;
|
|
5625
|
+
if (columns) {
|
|
5626
|
+
const map = hasSideMenu ? COLUMNS_WITH_SIDE_MENU_MAP : COLUMNS_WITHOUT_SIDE_MENU_MAP;
|
|
5627
|
+
return (_a = map[columns]) != null ? _a : map[12];
|
|
5628
|
+
}
|
|
5629
|
+
return getChildCountBasedClasses(childCount, hasSideMenu != null ? hasSideMenu : false);
|
|
5630
|
+
};
|
|
5631
|
+
var Grid = ({
|
|
5632
|
+
children,
|
|
5633
|
+
sizing = "container",
|
|
5634
|
+
padding,
|
|
5635
|
+
hasSideMenu = false,
|
|
5636
|
+
columns,
|
|
5637
|
+
id,
|
|
5638
|
+
testid,
|
|
5639
|
+
style
|
|
5640
|
+
}) => {
|
|
5641
|
+
const childCount = import_react26.Children.count(children);
|
|
5642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
5643
|
+
"div",
|
|
5644
|
+
{
|
|
5645
|
+
id,
|
|
5646
|
+
"data-testid": testid,
|
|
5647
|
+
className: (0, import_clsx30.default)(
|
|
5648
|
+
padding && sizing === "container" && "p-mobile-container-padding desktop:p-desktop-container-padding compact:p-desktop-compact-container-padding",
|
|
5649
|
+
padding && sizing === "layout" && "p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding",
|
|
5650
|
+
padding && sizing === "layout-group" && "p-mobile-layout-group-padding desktop:p-desktop-layout-group-padding compact:p-desktop-compact-layout-group-padding",
|
|
5651
|
+
padding && sizing === "component" && "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding",
|
|
5652
|
+
sizing === "layout-group" && "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-compact-layout-group-gap",
|
|
5653
|
+
sizing === "layout" && "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-compact-layout-gap",
|
|
5654
|
+
sizing === "container" && "gap-mobile-container-gap desktop:gap-desktop-container-gap compact:gap-compact-container-gap",
|
|
5655
|
+
sizing === "component" && "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-compact-component-gap",
|
|
5656
|
+
"w-full grid",
|
|
5657
|
+
getGridClasses(childCount, hasSideMenu, columns)
|
|
5658
|
+
),
|
|
5659
|
+
style,
|
|
5660
|
+
children
|
|
5661
|
+
}
|
|
5662
|
+
);
|
|
5663
|
+
};
|
|
5664
|
+
|
|
5665
|
+
// src/components/ProductImagePreview/ProductPrimaryImage.tsx
|
|
5666
|
+
var import_react27 = require("react");
|
|
5667
|
+
|
|
5668
|
+
// src/components/Spinner.tsx
|
|
5669
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
5670
|
+
var Spinner = ({ size = "small", testid }) => {
|
|
5671
|
+
const dimension = size === "large" ? 48 : 24;
|
|
5672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
5673
|
+
"svg",
|
|
5674
|
+
{
|
|
5675
|
+
"data-testid": testid,
|
|
5676
|
+
width: dimension,
|
|
5677
|
+
height: dimension,
|
|
5678
|
+
viewBox: "0 0 24 24",
|
|
5679
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5680
|
+
fill: "#1D1E1E",
|
|
5681
|
+
className: "spinner",
|
|
5682
|
+
"aria-label": "Loading",
|
|
5683
|
+
children: [
|
|
5684
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1" }),
|
|
5685
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "17.666", cy: "6.334", r: "2", opacity: "0.125" }),
|
|
5686
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "20", cy: "12", r: "2", opacity: "0.25" }),
|
|
5687
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "17.666", cy: "17.666", r: "2", opacity: "0.375" }),
|
|
5688
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "12", cy: "20", r: "2", opacity: "0.5" }),
|
|
5689
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "6.334", cy: "17.666", r: "2", opacity: "0.625" }),
|
|
5690
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "4", cy: "12", r: "2", opacity: "0.75" }),
|
|
5691
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("circle", { cx: "6.334", cy: "6.334", r: "2", opacity: "0.875" })
|
|
5692
|
+
]
|
|
5693
|
+
}
|
|
5694
|
+
);
|
|
5695
|
+
};
|
|
5696
|
+
Spinner.displayName = "Spinner";
|
|
5697
|
+
|
|
5698
|
+
// src/components/ProductImagePreview/ProductPrimaryImage.tsx
|
|
5699
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
5700
|
+
function ProductPrimaryImage({
|
|
5701
|
+
image,
|
|
5702
|
+
width,
|
|
5703
|
+
height,
|
|
5704
|
+
zoomEnabled = false,
|
|
5705
|
+
zoomLensSize = 140,
|
|
5706
|
+
scrollToZoomEnabled = false,
|
|
5707
|
+
className = "",
|
|
5708
|
+
isPlaceholder = false,
|
|
5709
|
+
onZoomPositionChange,
|
|
5710
|
+
onScrollZoom
|
|
5711
|
+
}) {
|
|
5712
|
+
const containerRef = (0, import_react27.useRef)(null);
|
|
5713
|
+
const lastPointRef = (0, import_react27.useRef)(null);
|
|
5714
|
+
const rafRef = (0, import_react27.useRef)(null);
|
|
5715
|
+
const [active, setActive] = (0, import_react27.useState)(false);
|
|
5716
|
+
const [, forceRerender] = (0, import_react27.useState)(0);
|
|
5717
|
+
const [imageLoading, setImageLoading] = (0, import_react27.useState)(true);
|
|
5718
|
+
const [imageError, setImageError] = (0, import_react27.useState)(false);
|
|
5719
|
+
const imageSrc = (0, import_react27.useMemo)(() => image == null ? void 0 : image.src, [image == null ? void 0 : image.src]);
|
|
5720
|
+
const schedule = () => {
|
|
5721
|
+
if (rafRef.current != null) return;
|
|
5722
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
5723
|
+
rafRef.current = null;
|
|
5724
|
+
forceRerender((n) => n + 1);
|
|
5725
|
+
});
|
|
5726
|
+
};
|
|
5727
|
+
const handlePointerEnter = (0, import_react27.useCallback)(() => {
|
|
5728
|
+
if (!zoomEnabled) return;
|
|
5729
|
+
setActive(true);
|
|
5730
|
+
const el = containerRef.current;
|
|
5731
|
+
if (el) {
|
|
5732
|
+
const r = el.getBoundingClientRect();
|
|
5733
|
+
const pt2 = lastPointRef.current;
|
|
5734
|
+
onZoomPositionChange == null ? void 0 : onZoomPositionChange(
|
|
5735
|
+
pt2 ? __spreadProps(__spreadValues({}, pt2), { w: r.width, h: r.height, lensSize: zoomLensSize }) : null,
|
|
5736
|
+
true
|
|
5737
|
+
);
|
|
5738
|
+
}
|
|
5739
|
+
}, [zoomEnabled, onZoomPositionChange, zoomLensSize]);
|
|
5740
|
+
const handlePointerLeave = (0, import_react27.useCallback)(() => {
|
|
5741
|
+
if (!zoomEnabled) return;
|
|
5742
|
+
setActive(false);
|
|
5743
|
+
lastPointRef.current = null;
|
|
5744
|
+
onZoomPositionChange == null ? void 0 : onZoomPositionChange(null, false);
|
|
5745
|
+
}, [zoomEnabled, onZoomPositionChange]);
|
|
5746
|
+
const handlePointerMove = (0, import_react27.useCallback)(
|
|
5747
|
+
(e) => {
|
|
5748
|
+
if (!zoomEnabled || !active) return;
|
|
5749
|
+
if (e.pointerType === "touch") return;
|
|
5750
|
+
const el = containerRef.current;
|
|
5751
|
+
if (!el) return;
|
|
5752
|
+
const rect = el.getBoundingClientRect();
|
|
5753
|
+
const rawX = (e.clientX - rect.left) / rect.width;
|
|
5754
|
+
const rawY = (e.clientY - rect.top) / rect.height;
|
|
5755
|
+
const size = zoomLensSize != null ? zoomLensSize : 140;
|
|
5756
|
+
const left = Math.max(
|
|
5757
|
+
0,
|
|
5758
|
+
Math.min(rect.width - size, rawX * rect.width - size / 2)
|
|
5759
|
+
);
|
|
5760
|
+
const top = Math.max(
|
|
5761
|
+
0,
|
|
5762
|
+
Math.min(rect.height - size, rawY * rect.height - size / 2)
|
|
5763
|
+
);
|
|
5764
|
+
const centerXNorm = (left + size / 2) / rect.width;
|
|
5765
|
+
const centerYNorm = (top + size / 2) / rect.height;
|
|
5766
|
+
lastPointRef.current = {
|
|
5767
|
+
x: centerXNorm,
|
|
5768
|
+
y: centerYNorm
|
|
5769
|
+
};
|
|
5770
|
+
schedule();
|
|
5771
|
+
onZoomPositionChange == null ? void 0 : onZoomPositionChange(
|
|
5772
|
+
lastPointRef.current ? __spreadProps(__spreadValues({}, lastPointRef.current), {
|
|
5773
|
+
w: rect.width,
|
|
5774
|
+
h: rect.height,
|
|
5775
|
+
lensSize: zoomLensSize
|
|
5776
|
+
}) : null,
|
|
5777
|
+
true
|
|
5778
|
+
);
|
|
5779
|
+
},
|
|
5780
|
+
[zoomEnabled, active, onZoomPositionChange, zoomLensSize]
|
|
5781
|
+
);
|
|
5782
|
+
(0, import_react27.useEffect)(() => {
|
|
5783
|
+
const container = containerRef.current;
|
|
5784
|
+
if (!container || !scrollToZoomEnabled) return;
|
|
5785
|
+
const handleNativeWheel = (e) => {
|
|
5786
|
+
e.preventDefault();
|
|
5787
|
+
e.stopPropagation();
|
|
5788
|
+
if (!zoomEnabled || !active) return;
|
|
5789
|
+
const delta = e.deltaY > 0 ? -0.2 : 0.2;
|
|
5790
|
+
onScrollZoom == null ? void 0 : onScrollZoom(delta);
|
|
5791
|
+
};
|
|
5792
|
+
container.addEventListener("wheel", handleNativeWheel, { passive: false });
|
|
5793
|
+
return () => {
|
|
5794
|
+
container.removeEventListener("wheel", handleNativeWheel);
|
|
5795
|
+
};
|
|
5796
|
+
}, [scrollToZoomEnabled, zoomEnabled, active, onScrollZoom]);
|
|
5797
|
+
if (!image && !isPlaceholder) return null;
|
|
5798
|
+
const pt = lastPointRef.current;
|
|
5799
|
+
let lensStyle;
|
|
5800
|
+
if (pt && active && zoomEnabled) {
|
|
5801
|
+
const size = zoomLensSize;
|
|
5802
|
+
const leftRaw = pt.x * width - size / 2;
|
|
5803
|
+
const topRaw = pt.y * height - size / 2;
|
|
5804
|
+
lensStyle = {
|
|
5805
|
+
width: size,
|
|
5806
|
+
height: size,
|
|
5807
|
+
left: Math.max(0, Math.min(width - size, leftRaw)),
|
|
5808
|
+
top: Math.max(0, Math.min(height - size, topRaw))
|
|
5809
|
+
};
|
|
5810
|
+
}
|
|
5811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5812
|
+
"div",
|
|
5813
|
+
{
|
|
5814
|
+
ref: containerRef,
|
|
5815
|
+
className: [
|
|
5816
|
+
"relative overflow-hidden bg-white rounded flex items-center justify-center select-none",
|
|
5817
|
+
zoomEnabled ? "cursor-crosshair" : "",
|
|
5818
|
+
className
|
|
5819
|
+
].join(" "),
|
|
5820
|
+
style: { maxWidth: width, maxHeight: height, aspectRatio: "1 / 1" },
|
|
5821
|
+
onPointerEnter: handlePointerEnter,
|
|
5822
|
+
onPointerLeave: handlePointerLeave,
|
|
5823
|
+
onPointerMove: handlePointerMove,
|
|
5824
|
+
children: [
|
|
5825
|
+
imageLoading && !imageError && !isPlaceholder && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-neutral-50", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Spinner, { size: "small" }) }),
|
|
5826
|
+
isPlaceholder ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ImagePlaceholder, { width, height }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5827
|
+
"img",
|
|
5828
|
+
{
|
|
5829
|
+
src: imageSrc,
|
|
5830
|
+
alt: (image == null ? void 0 : image.alt) || "Product image",
|
|
5831
|
+
className: "object-cover w-full h-full select-none",
|
|
5832
|
+
draggable: false,
|
|
5833
|
+
loading: "lazy",
|
|
5834
|
+
onLoad: () => setImageLoading(false),
|
|
5835
|
+
onError: () => {
|
|
5836
|
+
setImageLoading(false);
|
|
5837
|
+
setImageError(true);
|
|
5838
|
+
}
|
|
5839
|
+
},
|
|
5840
|
+
imageSrc
|
|
5841
|
+
),
|
|
5842
|
+
zoomEnabled && active && lensStyle && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5843
|
+
"div",
|
|
5844
|
+
{
|
|
5845
|
+
"aria-hidden": true,
|
|
5846
|
+
className: "absolute pointer-events-none border border-white/70 shadow-[0_0_0_1px_rgba(0,0,0,0.15)] rounded-md bg-white/10 backdrop-blur-[1px]",
|
|
5847
|
+
style: lensStyle
|
|
5848
|
+
}
|
|
5849
|
+
)
|
|
5850
|
+
]
|
|
5851
|
+
}
|
|
5852
|
+
);
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5855
|
+
// src/components/ProductImagePreview/ZoomWindow.tsx
|
|
5856
|
+
var import_react28 = require("react");
|
|
5857
|
+
|
|
5858
|
+
// src/components/Surface.tsx
|
|
5859
|
+
var import_clsx31 = __toESM(require("clsx"), 1);
|
|
5860
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5861
|
+
var Surface = (_a) => {
|
|
5862
|
+
var _b = _a, {
|
|
5863
|
+
children,
|
|
5864
|
+
className,
|
|
5865
|
+
elevation = 0,
|
|
5866
|
+
id
|
|
5867
|
+
} = _b, props = __objRest(_b, [
|
|
5868
|
+
"children",
|
|
5869
|
+
"className",
|
|
5870
|
+
"elevation",
|
|
5871
|
+
"id"
|
|
5872
|
+
]);
|
|
5873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5874
|
+
"div",
|
|
5875
|
+
__spreadProps(__spreadValues({
|
|
5876
|
+
id,
|
|
5877
|
+
className: (0, import_clsx31.default)(
|
|
5878
|
+
"rounded-base",
|
|
5879
|
+
{
|
|
5880
|
+
"shadow-2": elevation === 2,
|
|
5881
|
+
"shadow-4": elevation === 4,
|
|
5882
|
+
"shadow-16": elevation === 16
|
|
5883
|
+
},
|
|
5884
|
+
className
|
|
5885
|
+
)
|
|
5886
|
+
}, props), {
|
|
5887
|
+
children
|
|
5888
|
+
})
|
|
5889
|
+
);
|
|
5890
|
+
};
|
|
5891
|
+
Surface.displayName = "Surface";
|
|
5892
|
+
|
|
5893
|
+
// src/components/ProductImagePreview/ZoomWindow.tsx
|
|
5894
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5895
|
+
function ZoomWindow({
|
|
5896
|
+
image,
|
|
5897
|
+
width,
|
|
5898
|
+
height,
|
|
5899
|
+
pointer,
|
|
5900
|
+
active,
|
|
5901
|
+
zoomFactor = 2,
|
|
5902
|
+
scaleFactor = 2,
|
|
5903
|
+
primaryImagePosition,
|
|
5904
|
+
offset = 10,
|
|
5905
|
+
className = ""
|
|
5906
|
+
}) {
|
|
5907
|
+
const imageSrc = (0, import_react28.useMemo)(() => image == null ? void 0 : image.src, [image == null ? void 0 : image.src]);
|
|
5908
|
+
if (!image || !active || !pointer) return null;
|
|
5909
|
+
const zoomWindowSize = pointer.lensSize * scaleFactor;
|
|
5910
|
+
const baseW = pointer.w || width;
|
|
5911
|
+
const baseH = pointer.h || height;
|
|
5912
|
+
const scaledW = baseW * zoomFactor;
|
|
5913
|
+
const scaledH = baseH * zoomFactor;
|
|
5914
|
+
const centerX = pointer.x * baseW * zoomFactor;
|
|
5915
|
+
const centerY = pointer.y * baseH * zoomFactor;
|
|
5916
|
+
const imageOffsetX = zoomWindowSize / 2 - centerX;
|
|
5917
|
+
const imageOffsetY = zoomWindowSize / 2 - centerY;
|
|
5918
|
+
const calculatePosition = () => {
|
|
5919
|
+
if (!primaryImagePosition) {
|
|
5920
|
+
return {
|
|
5921
|
+
position: "fixed",
|
|
5922
|
+
zIndex: 999,
|
|
5923
|
+
top: "50%",
|
|
5924
|
+
left: "50%",
|
|
5925
|
+
transform: "translate(-50%, -50%)"
|
|
5926
|
+
};
|
|
5927
|
+
}
|
|
5928
|
+
const lensLeft = primaryImagePosition.left + pointer.x * primaryImagePosition.width - pointer.lensSize / 2;
|
|
5929
|
+
const lensTop = primaryImagePosition.top + pointer.y * primaryImagePosition.height - pointer.lensSize / 2;
|
|
5930
|
+
let left = lensLeft + pointer.lensSize + offset;
|
|
5931
|
+
let top = lensTop;
|
|
5932
|
+
const { innerWidth, innerHeight } = window;
|
|
5933
|
+
if (left + zoomWindowSize > innerWidth) {
|
|
5934
|
+
left = lensLeft - zoomWindowSize - offset;
|
|
5935
|
+
}
|
|
5936
|
+
if (top + zoomWindowSize > innerHeight) {
|
|
5937
|
+
top = lensTop + pointer.lensSize - zoomWindowSize;
|
|
5938
|
+
}
|
|
5939
|
+
if (top < 0) {
|
|
5940
|
+
top = lensTop;
|
|
5941
|
+
}
|
|
5942
|
+
if (left < 0) {
|
|
5943
|
+
left = lensLeft + pointer.lensSize + offset;
|
|
5944
|
+
}
|
|
5945
|
+
return {
|
|
5946
|
+
position: "fixed",
|
|
5947
|
+
zIndex: 999,
|
|
5948
|
+
left,
|
|
5949
|
+
top
|
|
5950
|
+
};
|
|
5951
|
+
};
|
|
5952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5953
|
+
Surface,
|
|
5954
|
+
{
|
|
5955
|
+
elevation: 16,
|
|
5956
|
+
className,
|
|
5957
|
+
style: __spreadValues({
|
|
5958
|
+
width: zoomWindowSize,
|
|
5959
|
+
height: zoomWindowSize,
|
|
5960
|
+
position: "fixed",
|
|
5961
|
+
zIndex: 999,
|
|
5962
|
+
overflow: "hidden",
|
|
5963
|
+
pointerEvents: "none",
|
|
5964
|
+
userSelect: "none"
|
|
5965
|
+
}, calculatePosition()),
|
|
5966
|
+
"aria-hidden": true,
|
|
5967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5968
|
+
"img",
|
|
5969
|
+
{
|
|
5970
|
+
src: imageSrc,
|
|
5971
|
+
alt: "",
|
|
5972
|
+
className: "pointer-events-none select-none max-w-none object-cover",
|
|
5973
|
+
style: {
|
|
5974
|
+
width: scaledW,
|
|
5975
|
+
height: scaledH,
|
|
5976
|
+
transform: `translate(${imageOffsetX}px, ${imageOffsetY}px)`
|
|
5977
|
+
},
|
|
5978
|
+
draggable: false,
|
|
5979
|
+
loading: "lazy"
|
|
5980
|
+
},
|
|
5981
|
+
imageSrc
|
|
5982
|
+
)
|
|
5983
|
+
}
|
|
5984
|
+
);
|
|
5985
|
+
}
|
|
5986
|
+
|
|
5987
|
+
// src/components/ProductImagePreview/CarouselPagination.tsx
|
|
5988
|
+
var import_clsx32 = require("clsx");
|
|
5989
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5990
|
+
function CarouselPagination({
|
|
5991
|
+
images,
|
|
5992
|
+
currentIndex,
|
|
5993
|
+
onSelect,
|
|
5994
|
+
className
|
|
5995
|
+
}) {
|
|
5996
|
+
if (!(images == null ? void 0 : images.length)) return null;
|
|
5997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5998
|
+
"div",
|
|
5999
|
+
{
|
|
6000
|
+
className: (0, import_clsx32.clsx)(
|
|
6001
|
+
"flex items-center justify-center w-full px-4 md:hidden",
|
|
6002
|
+
className
|
|
6003
|
+
),
|
|
6004
|
+
"aria-label": "Image navigation",
|
|
6005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
6006
|
+
"div",
|
|
6007
|
+
{
|
|
6008
|
+
className: "grid gap-2 place-items-center",
|
|
6009
|
+
style: {
|
|
6010
|
+
gridTemplateColumns: `repeat(${Math.min(images.length, 8)}, 1fr)`
|
|
6011
|
+
},
|
|
6012
|
+
role: "tablist",
|
|
6013
|
+
children: images.map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
6014
|
+
"button",
|
|
6015
|
+
{
|
|
6016
|
+
type: "button",
|
|
6017
|
+
onClick: () => onSelect(index),
|
|
6018
|
+
className: (0, import_clsx32.clsx)(
|
|
6019
|
+
"w-4 h-4 transition-all duration-200 focus:outline-none",
|
|
6020
|
+
index === currentIndex ? "ring-2 ring-brand-400" : "ring ring-neutral-300"
|
|
6021
|
+
),
|
|
6022
|
+
"aria-label": `Go to image ${index + 1}`,
|
|
6023
|
+
role: "tab",
|
|
6024
|
+
"aria-selected": index === currentIndex,
|
|
6025
|
+
tabIndex: index === currentIndex ? 0 : -1
|
|
6026
|
+
},
|
|
6027
|
+
index
|
|
6028
|
+
))
|
|
6029
|
+
}
|
|
6030
|
+
)
|
|
6031
|
+
}
|
|
6032
|
+
);
|
|
6033
|
+
}
|
|
6034
|
+
|
|
6035
|
+
// src/components/ProductImagePreview/MobileImageCarousel.tsx
|
|
6036
|
+
var import_react29 = require("react");
|
|
6037
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
6038
|
+
function MobileImageCarousel({
|
|
6039
|
+
images,
|
|
6040
|
+
currentIndex,
|
|
6041
|
+
width = 483,
|
|
6042
|
+
height = 483,
|
|
6043
|
+
onChangeIndex,
|
|
6044
|
+
className = ""
|
|
6045
|
+
}) {
|
|
6046
|
+
const containerRef = (0, import_react29.useRef)(null);
|
|
6047
|
+
const [isDragging, setIsDragging] = (0, import_react29.useState)(false);
|
|
6048
|
+
const [startX, setStartX] = (0, import_react29.useState)(0);
|
|
6049
|
+
const [currentTranslate, setCurrentTranslate] = (0, import_react29.useState)(0);
|
|
6050
|
+
const [prevTranslate, setPrevTranslate] = (0, import_react29.useState)(0);
|
|
6051
|
+
const [containerWidth, setContainerWidth] = (0, import_react29.useState)(width);
|
|
6052
|
+
const imageSize = Math.min(containerWidth * 0.6, height * 0.6);
|
|
6053
|
+
const gap = 16;
|
|
6054
|
+
const getTranslateX = (0, import_react29.useCallback)(
|
|
6055
|
+
(index) => {
|
|
6056
|
+
const containerCenter = containerWidth / 2;
|
|
6057
|
+
const imageCenter = imageSize / 2;
|
|
6058
|
+
const totalOffset = index * (imageSize + gap);
|
|
6059
|
+
return containerCenter - imageCenter - totalOffset;
|
|
6060
|
+
},
|
|
6061
|
+
[containerWidth, imageSize, gap]
|
|
6062
|
+
);
|
|
6063
|
+
(0, import_react29.useEffect)(() => {
|
|
6064
|
+
const translateX = getTranslateX(currentIndex);
|
|
6065
|
+
setCurrentTranslate(translateX);
|
|
6066
|
+
setPrevTranslate(translateX);
|
|
6067
|
+
}, [currentIndex, getTranslateX]);
|
|
6068
|
+
(0, import_react29.useEffect)(() => {
|
|
6069
|
+
const updateContainerWidth = () => {
|
|
6070
|
+
if (containerRef.current) {
|
|
6071
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
6072
|
+
setContainerWidth(rect.width);
|
|
6073
|
+
}
|
|
6074
|
+
};
|
|
6075
|
+
updateContainerWidth();
|
|
6076
|
+
const resizeObserver = new ResizeObserver(updateContainerWidth);
|
|
6077
|
+
if (containerRef.current) {
|
|
6078
|
+
resizeObserver.observe(containerRef.current);
|
|
6079
|
+
}
|
|
6080
|
+
return () => resizeObserver.disconnect();
|
|
6081
|
+
}, []);
|
|
6082
|
+
const handleStart = (0, import_react29.useCallback)((clientX) => {
|
|
6083
|
+
setIsDragging(true);
|
|
6084
|
+
setStartX(clientX);
|
|
6085
|
+
}, []);
|
|
6086
|
+
const handleMove = (0, import_react29.useCallback)(
|
|
6087
|
+
(clientX) => {
|
|
6088
|
+
if (!isDragging) return;
|
|
6089
|
+
const currentPosition = clientX;
|
|
6090
|
+
const diff = currentPosition - startX;
|
|
6091
|
+
setCurrentTranslate(prevTranslate + diff);
|
|
6092
|
+
},
|
|
6093
|
+
[isDragging, startX, prevTranslate]
|
|
6094
|
+
);
|
|
6095
|
+
const handleEnd = (0, import_react29.useCallback)(() => {
|
|
6096
|
+
if (!isDragging) return;
|
|
6097
|
+
setIsDragging(false);
|
|
6098
|
+
const moved = currentTranslate - prevTranslate;
|
|
6099
|
+
const threshold = imageSize / 3;
|
|
6100
|
+
let newIndex = currentIndex;
|
|
6101
|
+
if (moved > threshold && currentIndex > 0) {
|
|
6102
|
+
newIndex = currentIndex - 1;
|
|
6103
|
+
} else if (moved < -threshold && currentIndex < images.length - 1) {
|
|
6104
|
+
newIndex = currentIndex + 1;
|
|
6105
|
+
}
|
|
6106
|
+
if (newIndex !== currentIndex) {
|
|
6107
|
+
onChangeIndex(newIndex);
|
|
6108
|
+
} else {
|
|
6109
|
+
setCurrentTranslate(prevTranslate);
|
|
6110
|
+
}
|
|
6111
|
+
}, [
|
|
6112
|
+
isDragging,
|
|
6113
|
+
currentTranslate,
|
|
6114
|
+
prevTranslate,
|
|
6115
|
+
currentIndex,
|
|
6116
|
+
imageSize,
|
|
6117
|
+
images.length,
|
|
6118
|
+
onChangeIndex
|
|
6119
|
+
]);
|
|
6120
|
+
const handleMouseDown = (e) => {
|
|
6121
|
+
e.preventDefault();
|
|
6122
|
+
handleStart(e.clientX);
|
|
6123
|
+
};
|
|
6124
|
+
const handleMouseMove = (e) => {
|
|
6125
|
+
e.preventDefault();
|
|
6126
|
+
handleMove(e.clientX);
|
|
6127
|
+
};
|
|
6128
|
+
const handleMouseUp = () => {
|
|
6129
|
+
handleEnd();
|
|
6130
|
+
};
|
|
6131
|
+
const handleMouseLeave = () => {
|
|
6132
|
+
handleEnd();
|
|
6133
|
+
};
|
|
6134
|
+
const handleTouchStart = (e) => {
|
|
6135
|
+
handleStart(e.touches[0].clientX);
|
|
6136
|
+
};
|
|
6137
|
+
const handleTouchMove = (e) => {
|
|
6138
|
+
handleMove(e.touches[0].clientX);
|
|
6139
|
+
};
|
|
6140
|
+
const handleTouchEnd = () => {
|
|
6141
|
+
handleEnd();
|
|
6142
|
+
};
|
|
6143
|
+
const handleImageClick = (0, import_react29.useCallback)(
|
|
6144
|
+
(index) => {
|
|
6145
|
+
if (!isDragging && index !== currentIndex) {
|
|
6146
|
+
onChangeIndex(index);
|
|
6147
|
+
}
|
|
6148
|
+
},
|
|
6149
|
+
[isDragging, currentIndex, onChangeIndex]
|
|
6150
|
+
);
|
|
6151
|
+
if (!images.length) return null;
|
|
6152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: `md:hidden w-full ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6153
|
+
"div",
|
|
6154
|
+
{
|
|
6155
|
+
ref: containerRef,
|
|
6156
|
+
className: "relative overflow-hidden cursor-grab active:cursor-grabbing select-none w-full",
|
|
6157
|
+
style: {
|
|
6158
|
+
height: imageSize
|
|
6159
|
+
},
|
|
6160
|
+
onMouseDown: handleMouseDown,
|
|
6161
|
+
onMouseMove: handleMouseMove,
|
|
6162
|
+
onMouseUp: handleMouseUp,
|
|
6163
|
+
onMouseLeave: handleMouseLeave,
|
|
6164
|
+
onTouchStart: handleTouchStart,
|
|
6165
|
+
onTouchMove: handleTouchMove,
|
|
6166
|
+
onTouchEnd: handleTouchEnd,
|
|
6167
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6168
|
+
"div",
|
|
6169
|
+
{
|
|
6170
|
+
className: "flex items-center",
|
|
6171
|
+
style: {
|
|
6172
|
+
transform: `translateX(${currentTranslate}px)`,
|
|
6173
|
+
transition: isDragging ? "none" : "transform 0.3s ease-out",
|
|
6174
|
+
gap: `${gap}px`
|
|
6175
|
+
},
|
|
6176
|
+
children: images.map((image, index) => {
|
|
6177
|
+
const isActive = index === currentIndex;
|
|
6178
|
+
const distance = Math.abs(index - currentIndex);
|
|
6179
|
+
const shouldRender = distance <= 2;
|
|
6180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6181
|
+
"div",
|
|
6182
|
+
{
|
|
6183
|
+
className: "flex-shrink-0 transition-opacity duration-300",
|
|
6184
|
+
style: {
|
|
6185
|
+
width: imageSize,
|
|
6186
|
+
height: imageSize,
|
|
6187
|
+
opacity: isActive ? 1 : Math.max(0.3, 1 - distance * 0.3)
|
|
6188
|
+
},
|
|
6189
|
+
onClick: () => handleImageClick(index),
|
|
6190
|
+
children: shouldRender ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6191
|
+
"img",
|
|
6192
|
+
{
|
|
6193
|
+
src: image.src,
|
|
6194
|
+
alt: image.alt || `Product image ${index + 1}`,
|
|
6195
|
+
className: "w-full h-full object-cover",
|
|
6196
|
+
draggable: false,
|
|
6197
|
+
loading: distance <= 1 ? "eager" : "lazy",
|
|
6198
|
+
style: {
|
|
6199
|
+
aspectRatio: "1 / 1"
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6202
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6203
|
+
"div",
|
|
6204
|
+
{
|
|
6205
|
+
className: "w-full h-full bg-neutral-100 rounded-md border border-gray-200",
|
|
6206
|
+
style: {
|
|
6207
|
+
aspectRatio: "1 / 1"
|
|
6208
|
+
},
|
|
6209
|
+
"aria-hidden": "true"
|
|
6210
|
+
}
|
|
6211
|
+
)
|
|
6212
|
+
},
|
|
6213
|
+
image.src + index
|
|
6214
|
+
);
|
|
6215
|
+
})
|
|
6216
|
+
}
|
|
6217
|
+
)
|
|
6218
|
+
}
|
|
6219
|
+
) });
|
|
6220
|
+
}
|
|
6221
|
+
|
|
6222
|
+
// src/components/ProductImagePreview/useProductImagePreview.ts
|
|
6223
|
+
var import_react30 = require("react");
|
|
6224
|
+
function useProductImagePreview(props) {
|
|
6225
|
+
const {
|
|
6226
|
+
images,
|
|
6227
|
+
currentIndex,
|
|
6228
|
+
zoomEnabled = false,
|
|
6229
|
+
zoomFactor = 2,
|
|
6230
|
+
scrollToZoomEnabled = false,
|
|
6231
|
+
onChangeIndex,
|
|
6232
|
+
isMobile = false
|
|
6233
|
+
} = props;
|
|
6234
|
+
const hasImages = !!(images == null ? void 0 : images.length);
|
|
6235
|
+
const safeIndex = hasImages && currentIndex >= 0 && currentIndex < images.length ? currentIndex : 0;
|
|
6236
|
+
const active = (0, import_react30.useMemo)(() => {
|
|
6237
|
+
return hasImages ? images[safeIndex] : void 0;
|
|
6238
|
+
}, [hasImages, images, safeIndex]);
|
|
6239
|
+
const [zoomPoint, setZoomPoint] = (0, import_react30.useState)(null);
|
|
6240
|
+
const [zoomActive, setZoomActive] = (0, import_react30.useState)(false);
|
|
6241
|
+
const [currentZoomFactor, setCurrentZoomFactor] = (0, import_react30.useState)(zoomFactor);
|
|
6242
|
+
const [primaryImagePosition, setPrimaryImagePosition] = (0, import_react30.useState)(null);
|
|
6243
|
+
const primaryImageRef = (0, import_react30.useRef)(null);
|
|
6244
|
+
const cleanupRef = (0, import_react30.useRef)(null);
|
|
6245
|
+
const effectiveZoomEnabled = zoomEnabled && !isMobile;
|
|
6246
|
+
const effectiveScrollToZoomEnabled = scrollToZoomEnabled && !isMobile;
|
|
6247
|
+
(0, import_react30.useEffect)(() => {
|
|
6248
|
+
if (!effectiveZoomEnabled) return;
|
|
6249
|
+
const setupTracking = () => {
|
|
6250
|
+
const element = primaryImageRef.current;
|
|
6251
|
+
if (!element) return;
|
|
6252
|
+
const updatePosition = () => {
|
|
6253
|
+
if (element) {
|
|
6254
|
+
setPrimaryImagePosition(element.getBoundingClientRect());
|
|
6255
|
+
}
|
|
6256
|
+
};
|
|
6257
|
+
updatePosition();
|
|
6258
|
+
const resizeObserver = new ResizeObserver(updatePosition);
|
|
6259
|
+
resizeObserver.observe(element);
|
|
6260
|
+
window.addEventListener("scroll", updatePosition);
|
|
6261
|
+
window.addEventListener("resize", updatePosition);
|
|
6262
|
+
cleanupRef.current = () => {
|
|
6263
|
+
resizeObserver.disconnect();
|
|
6264
|
+
window.removeEventListener("scroll", updatePosition);
|
|
6265
|
+
window.removeEventListener("resize", updatePosition);
|
|
6266
|
+
};
|
|
6267
|
+
};
|
|
6268
|
+
if (primaryImageRef.current) {
|
|
6269
|
+
setupTracking();
|
|
6270
|
+
} else {
|
|
6271
|
+
const frameId = requestAnimationFrame(setupTracking);
|
|
6272
|
+
return () => cancelAnimationFrame(frameId);
|
|
6273
|
+
}
|
|
6274
|
+
return () => {
|
|
6275
|
+
if (cleanupRef.current) {
|
|
6276
|
+
cleanupRef.current();
|
|
6277
|
+
cleanupRef.current = null;
|
|
6278
|
+
}
|
|
6279
|
+
};
|
|
6280
|
+
}, [effectiveZoomEnabled]);
|
|
6281
|
+
const handleSelect = (0, import_react30.useCallback)(
|
|
6282
|
+
(idx) => {
|
|
6283
|
+
if (idx === safeIndex) return;
|
|
6284
|
+
onChangeIndex(idx);
|
|
6285
|
+
},
|
|
6286
|
+
[safeIndex, onChangeIndex]
|
|
6287
|
+
);
|
|
6288
|
+
const handleNext = (0, import_react30.useCallback)(() => {
|
|
6289
|
+
if (!hasImages) return;
|
|
6290
|
+
const nextIndex = (safeIndex + 1) % images.length;
|
|
6291
|
+
onChangeIndex(nextIndex);
|
|
6292
|
+
}, [hasImages, safeIndex, images.length, onChangeIndex]);
|
|
6293
|
+
const handlePrevious = (0, import_react30.useCallback)(() => {
|
|
6294
|
+
if (!hasImages) return;
|
|
6295
|
+
const previousIndex = safeIndex === 0 ? images.length - 1 : safeIndex - 1;
|
|
6296
|
+
onChangeIndex(previousIndex);
|
|
6297
|
+
}, [hasImages, safeIndex, images.length, onChangeIndex]);
|
|
6298
|
+
const handleZoomPositionChange = (0, import_react30.useCallback)(
|
|
6299
|
+
(p, active2) => {
|
|
6300
|
+
if (isMobile) return;
|
|
6301
|
+
setZoomPoint(p);
|
|
6302
|
+
setZoomActive(active2);
|
|
6303
|
+
},
|
|
6304
|
+
[isMobile]
|
|
6305
|
+
);
|
|
6306
|
+
const handleScrollZoom = (0, import_react30.useCallback)(
|
|
6307
|
+
(delta) => {
|
|
6308
|
+
if (!effectiveScrollToZoomEnabled) return;
|
|
6309
|
+
const newZoomFactor = Math.max(1, Math.min(5, currentZoomFactor + delta));
|
|
6310
|
+
setCurrentZoomFactor(newZoomFactor);
|
|
6311
|
+
},
|
|
6312
|
+
[effectiveScrollToZoomEnabled, currentZoomFactor]
|
|
6313
|
+
);
|
|
6314
|
+
(0, import_react30.useEffect)(() => {
|
|
6315
|
+
setCurrentZoomFactor(zoomFactor);
|
|
6316
|
+
}, [zoomFactor]);
|
|
6317
|
+
return {
|
|
6318
|
+
// State
|
|
6319
|
+
zoomPoint,
|
|
6320
|
+
zoomActive,
|
|
6321
|
+
currentZoomFactor,
|
|
6322
|
+
primaryImagePosition,
|
|
6323
|
+
hasImages,
|
|
6324
|
+
safeIndex,
|
|
6325
|
+
active,
|
|
6326
|
+
// Refs
|
|
6327
|
+
primaryImageRef,
|
|
6328
|
+
// Handlers
|
|
6329
|
+
handleSelect,
|
|
6330
|
+
handleZoomPositionChange,
|
|
6331
|
+
handleScrollZoom,
|
|
6332
|
+
handleNext,
|
|
6333
|
+
handlePrevious
|
|
6334
|
+
};
|
|
6335
|
+
}
|
|
6336
|
+
|
|
6337
|
+
// src/components/ProductImagePreview/index.tsx
|
|
6338
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
6339
|
+
var PLACEHOLDER_IMAGES = [
|
|
6340
|
+
{ src: "", alt: "placeholder" },
|
|
6341
|
+
{ src: "", alt: "placeholder" }
|
|
6342
|
+
];
|
|
6343
|
+
function ProductImagePreview(props) {
|
|
6344
|
+
const {
|
|
6345
|
+
width = 483,
|
|
6346
|
+
height = 483,
|
|
6347
|
+
thumbsPerRow = 4,
|
|
6348
|
+
zoomEnabled = false,
|
|
6349
|
+
scrollToZoomEnabled = false,
|
|
6350
|
+
images,
|
|
6351
|
+
currentIndex,
|
|
6352
|
+
onChangeIndex,
|
|
6353
|
+
zoomLensSize,
|
|
6354
|
+
zoomFactor = 2,
|
|
6355
|
+
zoomWindowScaleFactor = 2.5,
|
|
6356
|
+
zoomWindowOffset = 10
|
|
6357
|
+
} = props;
|
|
6358
|
+
const isMobile = useMatchesMobile();
|
|
6359
|
+
const {
|
|
6360
|
+
zoomPoint,
|
|
6361
|
+
zoomActive,
|
|
6362
|
+
currentZoomFactor,
|
|
6363
|
+
primaryImagePosition,
|
|
6364
|
+
safeIndex,
|
|
6365
|
+
active,
|
|
6366
|
+
primaryImageRef,
|
|
6367
|
+
handleSelect,
|
|
6368
|
+
handleZoomPositionChange,
|
|
6369
|
+
handleScrollZoom
|
|
6370
|
+
} = useProductImagePreview({
|
|
6371
|
+
images,
|
|
6372
|
+
currentIndex,
|
|
6373
|
+
zoomEnabled,
|
|
6374
|
+
zoomFactor,
|
|
6375
|
+
scrollToZoomEnabled,
|
|
6376
|
+
onChangeIndex,
|
|
6377
|
+
isMobile
|
|
6378
|
+
});
|
|
6379
|
+
if (typeof isMobile === "undefined") return null;
|
|
6380
|
+
const effectiveZoomEnabled = zoomEnabled && !isMobile;
|
|
6381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { sizing: "layout", style: { width, position: "relative" }, children: [
|
|
6382
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "hidden md:block", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex gap-4 items-start", children: [
|
|
6383
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { ref: primaryImageRef, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6384
|
+
ProductPrimaryImage,
|
|
6385
|
+
{
|
|
6386
|
+
image: active,
|
|
6387
|
+
width,
|
|
6388
|
+
height,
|
|
6389
|
+
zoomEnabled: effectiveZoomEnabled,
|
|
6390
|
+
zoomLensSize,
|
|
6391
|
+
scrollToZoomEnabled: scrollToZoomEnabled && !isMobile,
|
|
6392
|
+
onZoomPositionChange: handleZoomPositionChange,
|
|
6393
|
+
onScrollZoom: handleScrollZoom,
|
|
6394
|
+
isPlaceholder: images.length === 0
|
|
6395
|
+
}
|
|
6396
|
+
) }),
|
|
6397
|
+
effectiveZoomEnabled && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6398
|
+
ZoomWindow,
|
|
6399
|
+
{
|
|
6400
|
+
image: active,
|
|
6401
|
+
width,
|
|
6402
|
+
height,
|
|
6403
|
+
pointer: zoomPoint,
|
|
6404
|
+
active: zoomActive,
|
|
6405
|
+
zoomFactor: currentZoomFactor,
|
|
6406
|
+
scaleFactor: zoomWindowScaleFactor,
|
|
6407
|
+
primaryImagePosition,
|
|
6408
|
+
offset: zoomWindowOffset
|
|
6409
|
+
}
|
|
6410
|
+
)
|
|
6411
|
+
] }) }),
|
|
6412
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6413
|
+
MobileImageCarousel,
|
|
6414
|
+
{
|
|
6415
|
+
images,
|
|
6416
|
+
currentIndex: safeIndex,
|
|
6417
|
+
width,
|
|
6418
|
+
height,
|
|
6419
|
+
onChangeIndex: handleSelect
|
|
6420
|
+
}
|
|
6421
|
+
),
|
|
6422
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "hidden md:block", children: images.length <= 3 ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6423
|
+
"div",
|
|
6424
|
+
{
|
|
6425
|
+
className: "flex justify-center gap-4",
|
|
6426
|
+
style: { width: "100%", maxWidth: width },
|
|
6427
|
+
"aria-label": "Product image thumbnails",
|
|
6428
|
+
children: (images.length === 0 ? PLACEHOLDER_IMAGES : images).map(
|
|
6429
|
+
(img, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { style: { maxWidth: "115px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6430
|
+
Thumbnail,
|
|
6431
|
+
{
|
|
6432
|
+
src: img.src,
|
|
6433
|
+
alt: img.alt || `Thumbnail ${i + 1}`,
|
|
6434
|
+
isActive: i === safeIndex,
|
|
6435
|
+
onClick: () => handleSelect(i),
|
|
6436
|
+
isPlaceholder: images.length === 0
|
|
6437
|
+
}
|
|
6438
|
+
) }, img.src + i)
|
|
6439
|
+
)
|
|
6440
|
+
}
|
|
6441
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6442
|
+
Grid,
|
|
6443
|
+
{
|
|
6444
|
+
sizing: "layout-group",
|
|
6445
|
+
"aria-label": "Product image thumbnails",
|
|
6446
|
+
style: {
|
|
6447
|
+
width: "100%",
|
|
6448
|
+
maxWidth: width
|
|
6449
|
+
},
|
|
6450
|
+
columns: thumbsPerRow > 12 ? 12 : thumbsPerRow < 1 ? 1 : thumbsPerRow,
|
|
6451
|
+
children: (images.length === 0 ? PLACEHOLDER_IMAGES : images).map(
|
|
6452
|
+
(img, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6453
|
+
Thumbnail,
|
|
6454
|
+
{
|
|
6455
|
+
src: img.src,
|
|
6456
|
+
alt: img.alt || `Thumbnail ${i + 1}`,
|
|
6457
|
+
isActive: i === safeIndex,
|
|
6458
|
+
onClick: () => handleSelect(i),
|
|
6459
|
+
isPlaceholder: images.length === 0
|
|
6460
|
+
},
|
|
6461
|
+
img.src + i
|
|
6462
|
+
)
|
|
6463
|
+
)
|
|
6464
|
+
}
|
|
6465
|
+
) }),
|
|
6466
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
6467
|
+
CarouselPagination,
|
|
6468
|
+
{
|
|
6469
|
+
images,
|
|
6470
|
+
currentIndex: safeIndex,
|
|
6471
|
+
onSelect: handleSelect
|
|
6472
|
+
}
|
|
6473
|
+
)
|
|
6474
|
+
] });
|
|
6475
|
+
}
|
|
6476
|
+
|
|
6477
|
+
// src/components/CompactImagesPreview.tsx
|
|
6478
|
+
var import_react31 = require("react");
|
|
6479
|
+
var import_clsx33 = __toESM(require("clsx"), 1);
|
|
6480
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
6481
|
+
function CompactImagesPreview(props) {
|
|
6482
|
+
const {
|
|
6483
|
+
sources,
|
|
6484
|
+
currentSourceIndex = 0,
|
|
6485
|
+
activeImageHeight = 243,
|
|
6486
|
+
activeImageWidth = 242,
|
|
6487
|
+
thumbnailWidth = 30.5,
|
|
6488
|
+
thumbnailHeight = 30,
|
|
6489
|
+
enableThumbnailBorder = false,
|
|
6490
|
+
placeholderImageUri,
|
|
6491
|
+
onChangeSource
|
|
6492
|
+
} = props;
|
|
6493
|
+
const isMobile = useMatchesMobile();
|
|
6494
|
+
const imagesCount = sources.length;
|
|
6495
|
+
const handleThumbnailClick = (0, import_react31.useCallback)(
|
|
6496
|
+
(newIndex) => {
|
|
6497
|
+
if (newIndex === currentSourceIndex) return;
|
|
6498
|
+
if (newIndex < 0 || newIndex >= imagesCount) return;
|
|
6499
|
+
onChangeSource(newIndex);
|
|
6500
|
+
},
|
|
6501
|
+
[currentSourceIndex, onChangeSource, imagesCount]
|
|
6502
|
+
);
|
|
6503
|
+
if (!sources.length || currentSourceIndex >= sources.length || typeof isMobile === "undefined")
|
|
6504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6505
|
+
"img",
|
|
6506
|
+
{
|
|
6507
|
+
className: "object-center",
|
|
6508
|
+
style: { width: activeImageWidth, height: activeImageHeight },
|
|
6509
|
+
src: placeholderImageUri,
|
|
6510
|
+
alt: "placeholder image"
|
|
6511
|
+
}
|
|
6512
|
+
);
|
|
6513
|
+
const currentSource = sources[currentSourceIndex];
|
|
6514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Stack, { sizing: "layout", children: [
|
|
6515
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6516
|
+
"img",
|
|
6517
|
+
{
|
|
6518
|
+
style: {
|
|
6519
|
+
width: isMobile ? "100%" : activeImageWidth,
|
|
6520
|
+
height: activeImageHeight,
|
|
6521
|
+
objectPosition: "center"
|
|
6522
|
+
},
|
|
6523
|
+
src: currentSource.uri,
|
|
6524
|
+
alt: currentSource.name
|
|
6525
|
+
}
|
|
6526
|
+
),
|
|
6527
|
+
sources.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "flex flex-row flex-wrap items-center gap-3", children: sources.map((source, index) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6528
|
+
"button",
|
|
6529
|
+
{
|
|
6530
|
+
onClick: (e) => {
|
|
6531
|
+
e.preventDefault();
|
|
6532
|
+
handleThumbnailClick(index);
|
|
6533
|
+
},
|
|
6534
|
+
className: (0, import_clsx33.default)(
|
|
6535
|
+
"cursor-pointer",
|
|
6536
|
+
currentSourceIndex === index && enableThumbnailBorder ? "ring-2 ring-offset-2 ring-brand-400 transition-discrete duration-300" : "ring-brand-400/0"
|
|
6537
|
+
),
|
|
6538
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6539
|
+
"img",
|
|
6540
|
+
{
|
|
6541
|
+
src: source.uri,
|
|
6542
|
+
alt: source.name,
|
|
6543
|
+
style: {
|
|
6544
|
+
width: thumbnailWidth,
|
|
6545
|
+
height: thumbnailHeight,
|
|
6546
|
+
objectPosition: "center"
|
|
6547
|
+
}
|
|
6548
|
+
}
|
|
6549
|
+
)
|
|
6550
|
+
},
|
|
6551
|
+
`compact-image-${source.uri}-${index}`
|
|
6552
|
+
)) })
|
|
6553
|
+
] });
|
|
6554
|
+
}
|
|
6555
|
+
|
|
6556
|
+
// src/components/PDFViewer/index.tsx
|
|
6557
|
+
var import_react34 = require("react");
|
|
6558
|
+
|
|
6559
|
+
// src/components/PDFViewer/PDFElement.tsx
|
|
6560
|
+
var import_react_pdf2 = require("@mikecousins/react-pdf");
|
|
6561
|
+
var import_react33 = require("react");
|
|
6562
|
+
|
|
6563
|
+
// src/components/PDFViewer/PDFPage.tsx
|
|
6564
|
+
var import_react_pdf = require("@mikecousins/react-pdf");
|
|
6565
|
+
var import_react32 = require("react");
|
|
6566
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
6567
|
+
function PdfPage({
|
|
6568
|
+
file,
|
|
6569
|
+
pageNumber,
|
|
6570
|
+
testid,
|
|
6571
|
+
isMobile
|
|
6572
|
+
}) {
|
|
6573
|
+
const canvasRef = (0, import_react32.useRef)(null);
|
|
6574
|
+
const { pdfDocument } = (0, import_react_pdf.usePdf)({
|
|
6575
|
+
file,
|
|
6576
|
+
page: pageNumber,
|
|
6577
|
+
canvasRef,
|
|
6578
|
+
workerSrc: "/scripts/pdf.worker.min.mjs",
|
|
6579
|
+
scale: isMobile ? 1 : 1.3
|
|
6580
|
+
});
|
|
6581
|
+
if (!pdfDocument) return null;
|
|
6582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
6583
|
+
"canvas",
|
|
6584
|
+
{
|
|
6585
|
+
ref: canvasRef,
|
|
6586
|
+
"data-testid": testid,
|
|
6587
|
+
style: { width: "100%", height: "auto" }
|
|
6588
|
+
}
|
|
6589
|
+
);
|
|
6590
|
+
}
|
|
6591
|
+
|
|
6592
|
+
// src/components/PDFViewer/PDFElement.tsx
|
|
6593
|
+
var import_clsx34 = __toESM(require("clsx"), 1);
|
|
6594
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
6595
|
+
function PDFElement({
|
|
6596
|
+
b64,
|
|
6597
|
+
testid,
|
|
6598
|
+
isMobile,
|
|
6599
|
+
error
|
|
6600
|
+
}) {
|
|
6601
|
+
var _a;
|
|
6602
|
+
const canvasRef = (0, import_react33.useRef)(null);
|
|
6603
|
+
const { pdfDocument } = (0, import_react_pdf2.usePdf)({
|
|
6604
|
+
file: `data:application/pdf;base64,${b64}`,
|
|
6605
|
+
workerSrc: "/scripts/pdf.worker.min.mjs",
|
|
6606
|
+
scale: isMobile ? 1 : 1.3,
|
|
6607
|
+
canvasRef
|
|
6608
|
+
});
|
|
6609
|
+
const pagesArr = new Array((_a = pdfDocument == null ? void 0 : pdfDocument.numPages) != null ? _a : 1).fill(null);
|
|
6610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6611
|
+
"div",
|
|
6612
|
+
{
|
|
6613
|
+
className: "flex flex-col space-y-4",
|
|
6614
|
+
style: !isMobile ? {
|
|
6615
|
+
minHeight: 871,
|
|
6616
|
+
minWidth: 654
|
|
6617
|
+
} : void 0,
|
|
6618
|
+
children: !!pdfDocument && !!b64 && !error ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Stack, { sizing: "layout-group", children: pagesArr.length > 1 ? pagesArr.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6619
|
+
"div",
|
|
6620
|
+
{
|
|
6621
|
+
className: (0, import_clsx34.default)(
|
|
6622
|
+
"flex justify-center border-border-primary-normal",
|
|
6623
|
+
isMobile ? "border-0" : "border"
|
|
6624
|
+
),
|
|
6625
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6626
|
+
PdfPage,
|
|
6627
|
+
{
|
|
6628
|
+
testid: testid ? `${testid}-pdf_page_${i + 1}` : void 0,
|
|
6629
|
+
file: `data:application/pdf;base64,${b64}`,
|
|
6630
|
+
pageNumber: i + 1
|
|
6631
|
+
}
|
|
6632
|
+
)
|
|
6633
|
+
},
|
|
6634
|
+
`${testid}-pdf-page-${i + 1}`
|
|
6635
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6636
|
+
"div",
|
|
6637
|
+
{
|
|
6638
|
+
className: (0, import_clsx34.default)(
|
|
6639
|
+
"flex justify-center border-border-primary-normal",
|
|
6640
|
+
isMobile ? "border-0" : "border"
|
|
6641
|
+
),
|
|
6642
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6643
|
+
"canvas",
|
|
6644
|
+
{
|
|
6645
|
+
"data-testid": testid ? `${testid}-pdf-content` : void 0,
|
|
6646
|
+
ref: canvasRef,
|
|
6647
|
+
style: { width: "100%", height: "auto" }
|
|
6648
|
+
}
|
|
6649
|
+
)
|
|
6650
|
+
}
|
|
6651
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
6652
|
+
Stack,
|
|
6653
|
+
{
|
|
6654
|
+
justify: "center",
|
|
6655
|
+
items: "center",
|
|
6656
|
+
height: "full",
|
|
6657
|
+
flexGrow: 1,
|
|
6658
|
+
"data-testid": testid ? `${testid}-pdf-${error ? "error" : "loading"}` : void 0,
|
|
6659
|
+
children: error ? error : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Spinner, { size: "large" })
|
|
6660
|
+
}
|
|
6661
|
+
)
|
|
6662
|
+
}
|
|
6663
|
+
);
|
|
6664
|
+
}
|
|
6665
|
+
|
|
6666
|
+
// src/components/PDFViewer/DownloadIcon.tsx
|
|
6667
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
6668
|
+
function DownloadIcon({
|
|
6669
|
+
onClick,
|
|
6670
|
+
isDownloading,
|
|
6671
|
+
testid
|
|
6672
|
+
}) {
|
|
6673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
6674
|
+
Button,
|
|
6675
|
+
{
|
|
6676
|
+
testid,
|
|
6677
|
+
iconOnly: true,
|
|
6678
|
+
variant: "tertiary",
|
|
6679
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Icon, { name: isDownloading ? "cached" : "download" }),
|
|
6680
|
+
onClick
|
|
6681
|
+
}
|
|
6682
|
+
);
|
|
6683
|
+
}
|
|
6684
|
+
|
|
6685
|
+
// src/components/PDFViewer/PDFNavigation.tsx
|
|
6686
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
6687
|
+
function PdfNavigation({
|
|
6688
|
+
currentIndex,
|
|
6689
|
+
total,
|
|
6690
|
+
onPrev,
|
|
6691
|
+
onNext,
|
|
6692
|
+
disablePrev,
|
|
6693
|
+
disableNext,
|
|
6694
|
+
extraActions,
|
|
6695
|
+
testid,
|
|
6696
|
+
fileName
|
|
6697
|
+
}) {
|
|
6698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
6699
|
+
Stack,
|
|
6700
|
+
{
|
|
6701
|
+
horizontal: true,
|
|
6702
|
+
items: "center",
|
|
6703
|
+
justify: "between",
|
|
6704
|
+
sizing: "layout-group",
|
|
6705
|
+
testid: testid ? `${testid}-pdf-navigation` : void 0,
|
|
6706
|
+
children: [
|
|
6707
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { horizontal: true, items: "center", children: [
|
|
6708
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
6709
|
+
Button,
|
|
6710
|
+
{
|
|
6711
|
+
iconOnly: true,
|
|
6712
|
+
variant: "tertiary",
|
|
6713
|
+
onClick: onPrev,
|
|
6714
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { name: "chevron_backward" }),
|
|
6715
|
+
disabled: disablePrev,
|
|
6716
|
+
testid: testid ? `${testid}-pdf-file-previous-button` : void 0
|
|
6717
|
+
}
|
|
6718
|
+
),
|
|
6719
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Heading3, { className: "text-text-primary-normal whitespace-nowrap", children: [
|
|
6720
|
+
currentIndex + 1,
|
|
6721
|
+
" / ",
|
|
6722
|
+
total
|
|
6723
|
+
] }),
|
|
6724
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
6725
|
+
Button,
|
|
6726
|
+
{
|
|
6727
|
+
iconOnly: true,
|
|
6728
|
+
variant: "tertiary",
|
|
6729
|
+
onClick: onNext,
|
|
6730
|
+
rightIcon: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { name: "chevron_forward" }),
|
|
6731
|
+
disabled: disableNext,
|
|
6732
|
+
testid: testid ? `${testid}-pdf-file-next-button` : void 0
|
|
6733
|
+
}
|
|
6734
|
+
),
|
|
6735
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Paragraph, { children: (fileName == null ? void 0 : fileName.endsWith(".pdf")) ? fileName : `${fileName}.pdf` })
|
|
6736
|
+
] }),
|
|
6737
|
+
extraActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "flex items-center gap-2", children: extraActions })
|
|
6738
|
+
]
|
|
6739
|
+
}
|
|
6740
|
+
) });
|
|
6741
|
+
}
|
|
6742
|
+
|
|
6743
|
+
// src/components/PDFViewer/index.tsx
|
|
6744
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
6745
|
+
function PDFViewer(props) {
|
|
6746
|
+
const {
|
|
6747
|
+
isOpen,
|
|
6748
|
+
onClose,
|
|
6749
|
+
encodedPdfs,
|
|
6750
|
+
customActions,
|
|
6751
|
+
testid,
|
|
6752
|
+
isMobile,
|
|
6753
|
+
title,
|
|
6754
|
+
customFooter = false,
|
|
6755
|
+
withPagination = true,
|
|
6756
|
+
error
|
|
6757
|
+
} = props;
|
|
6758
|
+
const [currentIndex, setCurrentIndex] = (0, import_react34.useState)(0);
|
|
6759
|
+
const [isDownloading, setIsDownloading] = (0, import_react34.useState)(false);
|
|
6760
|
+
const handleDownload = (0, import_react34.useCallback)(() => {
|
|
6761
|
+
setIsDownloading(true);
|
|
6762
|
+
const link = document.createElement("a");
|
|
6763
|
+
const currentPdf = encodedPdfs[currentIndex];
|
|
6764
|
+
if (!currentPdf) {
|
|
6765
|
+
setIsDownloading(false);
|
|
6766
|
+
return;
|
|
6767
|
+
}
|
|
6768
|
+
link.href = `data:application/pdf;base64,${currentPdf.base64}`;
|
|
6769
|
+
link.download = currentPdf.fileName.endsWith(".pdf") ? currentPdf.fileName : `${currentPdf.fileName}.pdf`;
|
|
6770
|
+
document.body.appendChild(link);
|
|
6771
|
+
link.click();
|
|
6772
|
+
document.body.removeChild(link);
|
|
6773
|
+
setIsDownloading(false);
|
|
6774
|
+
}, [currentIndex, encodedPdfs]);
|
|
6775
|
+
if (!encodedPdfs.length) return null;
|
|
6776
|
+
function handleNextFile() {
|
|
6777
|
+
if (currentIndex < encodedPdfs.length - 1) {
|
|
6778
|
+
setCurrentIndex((prev) => prev + 1);
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
function handlePreviousFile() {
|
|
6782
|
+
if (currentIndex > 0) {
|
|
6783
|
+
setCurrentIndex((prev) => prev - 1);
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
function handleClose() {
|
|
6787
|
+
setCurrentIndex(0);
|
|
6788
|
+
setIsDownloading(false);
|
|
6789
|
+
onClose();
|
|
6790
|
+
}
|
|
6791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6792
|
+
Modal,
|
|
6793
|
+
{
|
|
6794
|
+
testid,
|
|
6795
|
+
open: isOpen,
|
|
6796
|
+
customFooter,
|
|
6797
|
+
onClose: handleClose,
|
|
6798
|
+
noWrapper: true,
|
|
6799
|
+
showButtons: isMobile && customFooter ? !!customActions : !!encodedPdfs.length,
|
|
6800
|
+
customActions: !!encodedPdfs.length && !isMobile && withPagination ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6801
|
+
PdfNavigation,
|
|
6802
|
+
{
|
|
6803
|
+
testid,
|
|
6804
|
+
currentIndex,
|
|
6805
|
+
total: encodedPdfs.length,
|
|
6806
|
+
onPrev: handlePreviousFile,
|
|
6807
|
+
onNext: handleNextFile,
|
|
6808
|
+
disablePrev: currentIndex === 0,
|
|
6809
|
+
disableNext: currentIndex === encodedPdfs.length - 1,
|
|
6810
|
+
extraActions: customActions,
|
|
6811
|
+
fileName: encodedPdfs[currentIndex].fileName
|
|
6812
|
+
}
|
|
6813
|
+
) : customActions,
|
|
6814
|
+
fixedHeightScrolling: true,
|
|
6815
|
+
headerIconAlign: "right",
|
|
6816
|
+
headerIcon: !isMobile ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6817
|
+
DownloadIcon,
|
|
6818
|
+
{
|
|
6819
|
+
testid: testid ? `${testid}-download-icon` : void 0,
|
|
6820
|
+
onClick: handleDownload,
|
|
6821
|
+
isDownloading
|
|
6822
|
+
}
|
|
6823
|
+
) : void 0,
|
|
6824
|
+
title: isMobile ? title != null ? title : encodedPdfs[currentIndex].fileName : void 0,
|
|
6825
|
+
size: isMobile ? "screen" : "large",
|
|
6826
|
+
headerClassname: "bg-brand-400 desktop:bg-background-grouped-primary-normal p-mobile-layout-padding text-brand-text-action-primary-normal",
|
|
6827
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6828
|
+
PDFElement,
|
|
6829
|
+
{
|
|
6830
|
+
testid,
|
|
6831
|
+
b64: encodedPdfs[currentIndex].base64,
|
|
6832
|
+
isMobile,
|
|
6833
|
+
error
|
|
6834
|
+
}
|
|
6835
|
+
)
|
|
6836
|
+
}
|
|
6837
|
+
);
|
|
6838
|
+
}
|
|
4298
6839
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4299
6840
|
0 && (module.exports = {
|
|
4300
6841
|
Accordion,
|
|
4301
6842
|
Button,
|
|
4302
6843
|
Card,
|
|
4303
6844
|
Checkbox,
|
|
6845
|
+
CompactImagesPreview,
|
|
4304
6846
|
DataCellHeader,
|
|
4305
6847
|
DataGrid,
|
|
4306
6848
|
DataGridCell,
|
|
@@ -4311,7 +6853,10 @@ function Accordion(props) {
|
|
|
4311
6853
|
Label,
|
|
4312
6854
|
Menu,
|
|
4313
6855
|
MenuOption,
|
|
6856
|
+
MobileDataGrid,
|
|
6857
|
+
PDFViewer,
|
|
4314
6858
|
Paragraph,
|
|
6859
|
+
ProductImagePreview,
|
|
4315
6860
|
Search,
|
|
4316
6861
|
Select,
|
|
4317
6862
|
Subheader,
|