@dmsi/wedgekit-react 0.0.79 → 0.0.80

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.
@@ -0,0 +1,887 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __defProps = Object.defineProperties;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
+ var __objRest = (source, exclude) => {
27
+ var target = {};
28
+ for (var prop in source)
29
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
30
+ target[prop] = source[prop];
31
+ if (source != null && __getOwnPropSymbols)
32
+ for (var prop of __getOwnPropSymbols(source)) {
33
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
34
+ target[prop] = source[prop];
35
+ }
36
+ return target;
37
+ };
38
+ var __export = (target, all) => {
39
+ for (var name in all)
40
+ __defProp(target, name, { get: all[name], enumerable: true });
41
+ };
42
+ var __copyProps = (to, from, except, desc) => {
43
+ if (from && typeof from === "object" || typeof from === "function") {
44
+ for (let key of __getOwnPropNames(from))
45
+ if (!__hasOwnProp.call(to, key) && key !== except)
46
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
47
+ }
48
+ return to;
49
+ };
50
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
51
+ // If the importer is in node compatibility mode or this is not an ESM
52
+ // file that has been converted to a CommonJS file using a Babel-
53
+ // compatible transform (i.e. "__esModule" has not been set), then set
54
+ // "default" to the CommonJS "module.exports" for node compatibility.
55
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
+ mod
57
+ ));
58
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
59
+
60
+ // src/components/PDFViewer.tsx
61
+ var PDFViewer_exports = {};
62
+ __export(PDFViewer_exports, {
63
+ PDFViewer: () => PDFViewer
64
+ });
65
+ module.exports = __toCommonJS(PDFViewer_exports);
66
+ var import_react_pdf = require("@mikecousins/react-pdf");
67
+ var import_react5 = require("react");
68
+
69
+ // src/components/Modal.tsx
70
+ var import_clsx9 = __toESM(require("clsx"), 1);
71
+ var import_react4 = require("react");
72
+
73
+ // src/components/Heading.tsx
74
+ var import_clsx2 = __toESM(require("clsx"), 1);
75
+
76
+ // src/classNames.ts
77
+ var import_clsx = __toESM(require("clsx"), 1);
78
+ var typography = {
79
+ display1: (0, import_clsx.default)(
80
+ "font-sans font-semibold",
81
+ "text-display-1-mobile desktop:text-display-1-desktop compact:text-display-1-desktop-compact",
82
+ "leading-display-1-mobile desktop:leading-display-1-desktop"
83
+ ),
84
+ display2: (0, import_clsx.default)(
85
+ "font-sans font-bold",
86
+ "text-display-2-mobile desktop:text-display-2-desktop compact:text-display-2-desktop-compact",
87
+ "leading-display-2-mobile desktop:leading-display-2-desktop"
88
+ ),
89
+ heading1: (0, import_clsx.default)(
90
+ "font-sans font-semibold",
91
+ "text-heading-1-mobile desktop:text-heading-1-desktop compact:text-heading-1-desktop-compact",
92
+ "leading-heading-1-mobile desktop:leading-heading-1-desktop"
93
+ ),
94
+ heading2: (0, import_clsx.default)(
95
+ "font-sans font-normal",
96
+ "text-heading-2-mobile desktop:text-heading-2-desktop compact:text-heading-2-desktop-compact",
97
+ "leading-heading-2-mobile desktop:leading-heading-2-desktop"
98
+ ),
99
+ heading3: (0, import_clsx.default)(
100
+ "font-sans font-semibold",
101
+ "text-heading-3-mobile desktop:text-heading-3-desktop compact:text-heading-3-desktop-compact",
102
+ "leading-heading-3-mobile desktop:leading-heading-3-desktop"
103
+ ),
104
+ subheader: (0, import_clsx.default)(
105
+ "font-sans font-semibold",
106
+ "text-subheader-mobile desktop:text-subheader-desktop compact:text-subheader-desktop-compact",
107
+ "leading-subheader-mobile desktop:leading-subheader-desktop"
108
+ ),
109
+ link: (0, import_clsx.default)(
110
+ "font-sans font-normal",
111
+ "text-link-mobile desktop:text-link-desktop compact:text-link-desktop-compact",
112
+ "leading-link-mobile desktop:leading-link-desktop"
113
+ ),
114
+ buttonLabel: (0, import_clsx.default)(
115
+ "font-sans font-semibold",
116
+ "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
117
+ "leading-label-mobile desktop:leading-label-desktop"
118
+ ),
119
+ label: (0, import_clsx.default)(
120
+ "font-sans font-semibold",
121
+ "text-label-mobile desktop:text-label-desktop compact:text-label-desktop-compact",
122
+ "leading-label-mobile desktop:leading-label-desktop"
123
+ ),
124
+ paragraph: (0, import_clsx.default)(
125
+ "font-sans font-normal",
126
+ "text-paragraph-mobile desktop:text-paragraph-desktop compact:text-paragraph-desktop-compact",
127
+ "leading-paragraph-mobile desktop:leading-paragraph-desktop"
128
+ ),
129
+ caption: (0, import_clsx.default)(
130
+ "font-sans font-normal",
131
+ "text-caption-mobile desktop:text-caption-desktop compact:text-caption-desktop-compact",
132
+ "leading-caption-mobile desktop:leading-caption-desktop"
133
+ )
134
+ };
135
+ var baseTransition = (0, import_clsx.default)(
136
+ "transition-colors duration-100 ease-in-out"
137
+ );
138
+ var componentGap = (0, import_clsx.default)(
139
+ "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-desktop-compact-component-gap"
140
+ );
141
+ var paddingUsingComponentGap = (0, import_clsx.default)(
142
+ "p-mobile-component-gap desktop:p-desktop-component-gap compact:p-desktop-compact-component-gap"
143
+ );
144
+ var paddingXUsingLayoutGroupGap = (0, import_clsx.default)(
145
+ "px-mobile-layout-group-gap desktop:px-desktop-layout-group-gap compact:px-desktop-compact-layout-group-gap"
146
+ );
147
+ var paddingYUsingLayoutGroupGap = (0, import_clsx.default)(
148
+ "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
149
+ );
150
+ var componentPadding = (0, import_clsx.default)(
151
+ "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding"
152
+ );
153
+ var componentPaddingBottom = (0, import_clsx.default)(
154
+ "pb-mobile-component-padding desktop:pb-desktop-component-padding compact:pb-desktop-compact-component-padding"
155
+ );
156
+ var componentPaddingX = (0, import_clsx.default)(
157
+ "px-mobile-component-padding desktop:px-desktop-component-padding compact:px-desktop-compact-component-padding"
158
+ );
159
+ var componentPaddingY = (0, import_clsx.default)(
160
+ "py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding"
161
+ );
162
+ var componentPaddingXUsingComponentGap = (0, import_clsx.default)(
163
+ "px-mobile-component-gap desktop:px-desktop-component-gap compact:px-desktop-compact-component-gap"
164
+ );
165
+ var componentPaddingYUsingComponentGap = (0, import_clsx.default)(
166
+ "py-mobile-component-gap desktop:py-desktop-component-gap compact:py-desktop-compact-component-gap"
167
+ );
168
+ var componentPaddingMinusBorder = (0, import_clsx.default)(
169
+ "p-[calc(var(--spacing-mobile-component-padding)_-_1px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_1px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_1px)]"
170
+ );
171
+ var componentPaddingMinus2pxBorder = (0, import_clsx.default)(
172
+ "p-[calc(var(--spacing-mobile-component-padding)_-_2px)] desktop:p-[calc(var(--spacing-desktop-component-padding)_-_2px)] compact:p-[calc(var(--spacing-desktop-compact-component-padding)_-_2px)]"
173
+ );
174
+ var layoutPaddding = (0, import_clsx.default)(
175
+ "p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding"
176
+ );
177
+ var layoutPaddingBottom = (0, import_clsx.default)(
178
+ "pb-mobile-layout-padding desktop:pb-desktop-layout-padding compact:pb-desktop-compact-layout-padding"
179
+ );
180
+ var layoutPaddingY = (0, import_clsx.default)(
181
+ "py-mobile-layout-padding desktop:py-desktop-layout-padding compact:py-desktop-compact-layout-padding"
182
+ );
183
+ var containerPaddingX = (0, import_clsx.default)(
184
+ "px-mobile-container-padding desktop:px-desktop-container-padding compact:px-desktop-compact-container-padding"
185
+ );
186
+ var containerPaddingY = (0, import_clsx.default)(
187
+ "py-mobile-container-padding desktop:py-desktop-container-padding compact:py-desktop-compact-container-padding"
188
+ );
189
+ var layoutGroupGapPaddingY = (0, import_clsx.default)(
190
+ "py-mobile-layout-group-gap desktop:py-desktop-layout-group-gap compact:py-desktop-compact-layout-group-gap"
191
+ );
192
+ var layoutGroupGap = (0, import_clsx.default)(
193
+ "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-desktop-compact-layout-group-gap"
194
+ );
195
+ var layoutGap = (0, import_clsx.default)(
196
+ "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-desktop-compact-layout-gap"
197
+ );
198
+ var gapUsingContainerPadding = (0, import_clsx.default)(
199
+ "gap-mobile-container-padding desktop:gap-desktop-container-padding compact:gap-desktop-compact-container-padding"
200
+ );
201
+
202
+ // src/components/Heading.tsx
203
+ var import_jsx_runtime = require("react/jsx-runtime");
204
+ var Heading = (_a) => {
205
+ var _b = _a, {
206
+ className,
207
+ children,
208
+ as,
209
+ color,
210
+ align,
211
+ variant = "heading1",
212
+ id
213
+ } = _b, props = __objRest(_b, [
214
+ "className",
215
+ "children",
216
+ "as",
217
+ "color",
218
+ "align",
219
+ "variant",
220
+ "id"
221
+ ]);
222
+ const defaultElement = variant === "heading1" ? "h1" : variant === "heading2" ? "h2" : "h3";
223
+ const Element = as != null ? as : defaultElement;
224
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
+ Element,
226
+ __spreadProps(__spreadValues({
227
+ id,
228
+ className: (0, import_clsx2.default)(
229
+ typography[variant],
230
+ className,
231
+ align === "left" && "text-left",
232
+ align === "center" && "text-center",
233
+ align === "right" && "text-right"
234
+ ),
235
+ style: __spreadProps(__spreadValues({}, props.style), {
236
+ color: color ? `var(--color-${color})` : void 0
237
+ })
238
+ }, props), {
239
+ children
240
+ })
241
+ );
242
+ };
243
+ Heading.displayName = "Heading";
244
+ var Heading1 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading1" }));
245
+ var Heading2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading2" }));
246
+ var Heading3 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Heading, __spreadProps(__spreadValues({}, props), { variant: "heading3" }));
247
+ Heading1.displayName = "Heading1";
248
+ Heading2.displayName = "Heading2";
249
+ Heading3.displayName = "Heading3";
250
+
251
+ // src/components/Button.tsx
252
+ var import_clsx3 = __toESM(require("clsx"), 1);
253
+ var import_jsx_runtime2 = require("react/jsx-runtime");
254
+ var Button = (_a) => {
255
+ var _b = _a, {
256
+ variant = "primary",
257
+ as = "button",
258
+ block,
259
+ leftIcon,
260
+ rightIcon,
261
+ className,
262
+ classNameLabel,
263
+ disabled = false,
264
+ children,
265
+ iconOnly = false,
266
+ colorClassName,
267
+ href,
268
+ id
269
+ } = _b, props = __objRest(_b, [
270
+ "variant",
271
+ "as",
272
+ "block",
273
+ "leftIcon",
274
+ "rightIcon",
275
+ "className",
276
+ "classNameLabel",
277
+ "disabled",
278
+ "children",
279
+ "iconOnly",
280
+ "colorClassName",
281
+ "href",
282
+ "id"
283
+ ]);
284
+ const primaryVariantStyles = variant === "primary" && (0, import_clsx3.default)(
285
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
286
+ "bg-background-action-primary-normal border-background-action-primary-normal",
287
+ "hover:bg-background-action-primary-hover hover:border-background-action-primary-hover",
288
+ "focus:bg-background-action-primary-hover focus:border-background-action-primary-hover focus:outline-0",
289
+ "active:bg-background-action-primary-active active:border-background-action-primary-active",
290
+ "disabled:bg-background-action-primary-disabled disabled:border-background-action-primary-disabled disabled:text-text-on-action-primary-disabled"
291
+ );
292
+ const secondaryVariantStyles = variant === "secondary" && (0, import_clsx3.default)(
293
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
294
+ "bg-background-action-secondary-normal border-border-action-normal",
295
+ "hover:bg-background-action-secondary-hover hover:border-border-action-hover hover:text-text-action-primary-hover",
296
+ "focus:bg-background-action-secondary-hover focus:border-border-action-hover focus:text-text-action-primary-hover focus:outline-0",
297
+ "active:bg-background-action-secondary-active active:border-border-action-active active:text-text-action-primary-active",
298
+ "disabled:bg-background-action-primary-disabled disabled:border-border-action-disabled disabled:text-text-action-primary-disabled"
299
+ );
300
+ const tertiaryVariantStyles = variant === "tertiary" && (0, import_clsx3.default)(
301
+ "bg-transparent border-transparent",
302
+ iconOnly ? (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-icon-action-primary-normal" : (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-primary-normal",
303
+ "bg-transparent border-transparent",
304
+ "hover:bg-background-action-secondary-hover hover:border-background-action-secondary-hover hover:text-text-action-primary-hover",
305
+ "focus:bg-background-action-secondary-hover focus:border-background-action-secondary-hover focus:text-text-action-primary-hover focus:outline-0",
306
+ "active:bg-background-action-secondary-active active:border-transparent active:text-text-action-primary-active",
307
+ "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-primary-disabled"
308
+ );
309
+ const primaryCriticalVariantStyles = variant === "primary-critical" && (0, import_clsx3.default)(
310
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
311
+ "bg-background-action-critical-primary-normal border-background-action-critical-primary-normal",
312
+ "hover:bg-background-action-critical-primary-hover hover:border-background-action-critical-primary-hover",
313
+ "focus:bg-background-action-critical-primary-hover focus:border-background-action-critical-primary-hover focus:outline-0",
314
+ "active:bg-background-action-critical-primary-active active:border-background-action-critical-primary-active",
315
+ "disabled:bg-background-action-critical-primary-disabled disabled:border-background-action-critical-primary-disabled disabled:text-text-on-action-primary-disabled"
316
+ );
317
+ const secondaryCriticalVariantStyles = variant === "secondary-critical" && (0, import_clsx3.default)(
318
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
319
+ "bg-background-action-critical-secondary-normal border-border-action-critical-normal",
320
+ "hover:bg-background-action-critical-secondary-hover hover:border-border-action-critical-hover hover:text-text-action-critical-hover",
321
+ "focus:bg-background-action-critical-secondary-hover focus:border-border-action-critical-hover focus:text-text-action-critical-hover focus:outline-0",
322
+ "active:bg-background-action-critical-secondary-active active:border-border-action-critical-active active:text-text-action-critical-active",
323
+ "disabled:bg-background-action-critical-disabled disabled:border-border-action-critical-disabled disabled:text-text-action-critical-disabled"
324
+ );
325
+ const tertiaryCriticalVariantStyles = variant === "tertiary-critical" && (0, import_clsx3.default)(
326
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-action-critical-normal",
327
+ "bg-transparent border-transparent text-text-action-critical-normal",
328
+ "hover:bg-background-action-critical-secondary-hover hover:border-background-action-critical-secondary-hover hover:text-text-action-critical-hover",
329
+ "focus:bg-background-action-critical-secondary-hover focus:border-background-action-critical-secondary-hover focus:text-text-action-critical-hover focus:outline-0",
330
+ "active:bg-background-action-critical-secondary-active active:border-background-action-critical-secondary-active active:text-text-action-critical-active",
331
+ "disabled:bg-transparent disabled:border-transparent disabled:text-text-action-critical-disabled"
332
+ );
333
+ const navigationVarianStyles = variant === "navigation" && (0, import_clsx3.default)(
334
+ (colorClassName == null ? void 0 : colorClassName.trim()) ? colorClassName : "text-text-on-action-primary-normal",
335
+ "bg-transparent",
336
+ "hover:bg-background-on-action-secondary-hover hover:text-brand-text-action-primary-hover",
337
+ // "hover:bg-background-action-secondary-hover hover:text-text-action-primary-hover", // Will use this once colors are finalized
338
+ "focus:bg-background-on-action-secondary-hover focus:text-brand-text-action-primary-hover focus:outline-0",
339
+ // "focus:bg-background-action-secondary-hover focus:text-text-action-primary-hover", // Will use this once colors are finalized
340
+ "active:bg-background-on-action-secondary-active active:text-brand-text-action-primary-active",
341
+ // "active:bg-background-action-secondary-active active:text-text-action-primary-active", // Will use this once colors are finalized
342
+ "disabled:bg-transparent disabled:text-text-on-action-primary-disabled",
343
+ "flex-col",
344
+ paddingUsingComponentGap
345
+ );
346
+ const notNavigationVariantStyles = variant !== "navigation" && (0, import_clsx3.default)("border-2 flex-row", componentPaddingMinus2pxBorder, componentGap);
347
+ const buttonClasses = (0, import_clsx3.default)(
348
+ disabled ? "cursor-default" : "cursor-pointer",
349
+ block ? "w-full" : "w-fit",
350
+ baseTransition,
351
+ "rounded-sm whitespace-nowrap inline-flex items-center justify-center group/btn",
352
+ primaryVariantStyles,
353
+ secondaryVariantStyles,
354
+ tertiaryVariantStyles,
355
+ primaryCriticalVariantStyles,
356
+ secondaryCriticalVariantStyles,
357
+ tertiaryCriticalVariantStyles,
358
+ navigationVarianStyles,
359
+ notNavigationVariantStyles,
360
+ className
361
+ );
362
+ const labelClasses = (0, import_clsx3.default)(
363
+ "min-h-6 flex items-center justify-center",
364
+ classNameLabel,
365
+ componentPaddingXUsingComponentGap,
366
+ typography.buttonLabel
367
+ );
368
+ const Element = href ? "a" : as;
369
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
370
+ Element,
371
+ __spreadProps(__spreadValues({
372
+ id,
373
+ type: Element === "button" ? "button" : void 0,
374
+ className: buttonClasses
375
+ }, props), {
376
+ disabled,
377
+ href,
378
+ children: [
379
+ leftIcon && leftIcon,
380
+ !iconOnly && children && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { id: id ? `${id}-label` : void 0, className: labelClasses, children }),
381
+ rightIcon && rightIcon
382
+ ]
383
+ })
384
+ );
385
+ };
386
+ Button.displayName = "Button";
387
+
388
+ // src/components/Icon.tsx
389
+ var import_clsx4 = __toESM(require("clsx"), 1);
390
+ var import_jsx_runtime3 = require("react/jsx-runtime");
391
+ function Icon(_a) {
392
+ var _b = _a, {
393
+ name,
394
+ size = 24,
395
+ variant = "outline"
396
+ } = _b, props = __objRest(_b, [
397
+ "name",
398
+ "size",
399
+ "variant"
400
+ ]);
401
+ const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
402
+ const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
403
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
404
+ "span",
405
+ __spreadProps(__spreadValues({}, props), {
406
+ className: (0, import_clsx4.default)(
407
+ "icon",
408
+ `icon-${size}`,
409
+ // size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
410
+ props.className
411
+ ),
412
+ style: __spreadValues({
413
+ fontVariationSettings: variantStyle + `, ${weightStyle}`
414
+ }, props.style),
415
+ children: name
416
+ })
417
+ );
418
+ }
419
+
420
+ // src/components/ModalHeader.tsx
421
+ var import_clsx5 = __toESM(require("clsx"), 1);
422
+ var import_jsx_runtime4 = require("react/jsx-runtime");
423
+ var ModalHeader = ({
424
+ title,
425
+ hideCloseIcon,
426
+ headerIcon,
427
+ onClose,
428
+ id
429
+ }) => {
430
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
431
+ "div",
432
+ {
433
+ id,
434
+ className: (0, import_clsx5.default)(
435
+ "flex justify-between items-center",
436
+ layoutPaddding,
437
+ layoutGroupGap
438
+ ),
439
+ children: [
440
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_clsx5.default)("flex items-center", layoutGroupGap), children: [
441
+ headerIcon,
442
+ title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading2, { id: id ? `${id}-title` : void 0, as: "p", children: title })
443
+ ] }),
444
+ !hideCloseIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
445
+ Button,
446
+ {
447
+ id: id ? `${id}-close-button` : void 0,
448
+ iconOnly: true,
449
+ variant: "tertiary",
450
+ onClick: onClose,
451
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "close", size: 24 }) })
452
+ }
453
+ )
454
+ ]
455
+ }
456
+ );
457
+ };
458
+ ModalHeader.displayName = "ModalHeader";
459
+
460
+ // src/components/ModalContent.tsx
461
+ var import_clsx6 = __toESM(require("clsx"), 1);
462
+ var import_jsx_runtime5 = require("react/jsx-runtime");
463
+ function ModalContent({
464
+ fixedHeightScrolling,
465
+ children,
466
+ id
467
+ }) {
468
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
469
+ "div",
470
+ {
471
+ id,
472
+ className: (0, import_clsx6.default)(
473
+ "flex-grow desktop:flex-grow-0",
474
+ layoutPaddding,
475
+ fixedHeightScrolling && "overflow-auto"
476
+ ),
477
+ children
478
+ }
479
+ );
480
+ }
481
+ ModalContent.displayName = "ModalContent";
482
+
483
+ // src/components/ModalButtons.tsx
484
+ var import_clsx7 = __toESM(require("clsx"), 1);
485
+ var import_jsx_runtime6 = require("react/jsx-runtime");
486
+ var ModalButtons = ({
487
+ onClose,
488
+ onContinue,
489
+ customActions,
490
+ id
491
+ }) => {
492
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
493
+ "div",
494
+ {
495
+ id,
496
+ className: (0, import_clsx7.default)(
497
+ "border-t border-neutral-300 flex justify-end",
498
+ layoutPaddding,
499
+ layoutGroupGap
500
+ ),
501
+ children: customActions != null ? customActions : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
502
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
503
+ Button,
504
+ {
505
+ id: id ? `${id}-close-button` : void 0,
506
+ variant: "secondary",
507
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "close", size: 24 }),
508
+ onClick: onClose,
509
+ className: "max-sm:w-full",
510
+ children: "Close"
511
+ }
512
+ ),
513
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
514
+ Button,
515
+ {
516
+ id: id ? `${id}-continue-button` : void 0,
517
+ variant: "primary",
518
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "check", size: 24 }),
519
+ className: "max-sm:w-full",
520
+ onClick: onContinue,
521
+ children: "Continue"
522
+ }
523
+ )
524
+ ] })
525
+ }
526
+ );
527
+ };
528
+ ModalButtons.displayName = "ModalButtons";
529
+
530
+ // src/components/ModalScrim.tsx
531
+ var import_clsx8 = __toESM(require("clsx"), 1);
532
+ var import_jsx_runtime7 = require("react/jsx-runtime");
533
+ var ModalScrim = ({
534
+ show = false,
535
+ size = "small",
536
+ children,
537
+ onClick,
538
+ ref,
539
+ id
540
+ }) => {
541
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
542
+ "div",
543
+ {
544
+ id,
545
+ className: (0, import_clsx8.default)(
546
+ "overflow-y-auto h-screen transition-[visibility,opacity,background] ease-in-out duration-100 grid place-content-center desktop:p-4 group bg-neutral-600/50 fixed opacity-0",
547
+ !show && " pointer-events-none",
548
+ size === "small" && "p-4",
549
+ "inset-0 z-50"
550
+ ),
551
+ onMouseDown: onClick,
552
+ ref,
553
+ children
554
+ }
555
+ );
556
+ };
557
+ ModalScrim.displayName = "ModalScrim";
558
+
559
+ // src/components/Modal.tsx
560
+ var import_react_dom = require("react-dom");
561
+
562
+ // src/utils.ts
563
+ function findDocumentRoot(element) {
564
+ if (typeof window === "undefined" || typeof document === "undefined") {
565
+ throw new Error(
566
+ "findDocumentRoot can only be used in a browser environment."
567
+ );
568
+ }
569
+ if (!element || !(element instanceof Node)) {
570
+ return window.document.body;
571
+ }
572
+ var currentElement = element;
573
+ while (currentElement && currentElement.parentNode) {
574
+ if (currentElement.parentNode === document) {
575
+ return document.body;
576
+ } else if (currentElement.parentNode instanceof DocumentFragment) {
577
+ return currentElement.parentNode;
578
+ } else {
579
+ currentElement = currentElement.parentNode;
580
+ }
581
+ }
582
+ return window.document.body;
583
+ }
584
+
585
+ // src/components/Modal.tsx
586
+ var import_react_use = require("react-use");
587
+
588
+ // src/hooks/useKeydown.ts
589
+ var import_react = require("react");
590
+
591
+ // src/hooks/useMatchesMedia.ts
592
+ var import_react2 = require("react");
593
+ var useMatchesMedia = (query) => {
594
+ const [matches, setMatches] = (0, import_react2.useState)();
595
+ (0, import_react2.useLayoutEffect)(() => {
596
+ const mediaQueryList = window.matchMedia(query);
597
+ const listener = () => setMatches(mediaQueryList.matches);
598
+ listener();
599
+ mediaQueryList.addEventListener("change", listener);
600
+ return () => mediaQueryList.removeEventListener("change", listener);
601
+ }, [query]);
602
+ return matches;
603
+ };
604
+ var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
605
+
606
+ // src/components/useMounted.tsx
607
+ var import_react3 = require("react");
608
+ var useMounted = () => {
609
+ const [isMounted, setIsMounted] = (0, import_react3.useState)(false);
610
+ (0, import_react3.useEffect)(() => {
611
+ setIsMounted(true);
612
+ return () => setIsMounted(false);
613
+ }, []);
614
+ return isMounted;
615
+ };
616
+
617
+ // src/components/Modal.tsx
618
+ var import_jsx_runtime8 = require("react/jsx-runtime");
619
+ var fadeInScale = (element, duration = 300) => element.animate(
620
+ [
621
+ { opacity: 0, transform: "scale(0.95)" },
622
+ { opacity: 1, transform: "scale(1)" }
623
+ ],
624
+ {
625
+ duration,
626
+ easing: "cubic-bezier(0.4, 0, 0.2, 1)",
627
+ fill: "both"
628
+ }
629
+ );
630
+ var fadeOutScale = (element, duration = 200) => element.animate(
631
+ [
632
+ { opacity: 1, transform: "scale(1)" },
633
+ { opacity: 0, transform: "scale(0.95)" }
634
+ ],
635
+ {
636
+ duration,
637
+ easing: "ease-in-out",
638
+ fill: "both"
639
+ }
640
+ );
641
+ var bgFadeIn = (element, duration = 300) => element.animate([{ opacity: 0 }, { opacity: 1 }], {
642
+ duration,
643
+ easing: "cubic-bezier(0.4, 0, 0.2, 1)",
644
+ fill: "both"
645
+ });
646
+ var bgFadeOut = (element, duration = 200) => element.animate([{ opacity: 1 }, { opacity: 0 }], {
647
+ duration,
648
+ easing: "ease-in-out",
649
+ fill: "both"
650
+ });
651
+ var whenAllAnimationsFinish = (animations, callback) => {
652
+ let finishedCount = 0;
653
+ animations.forEach((animation) => {
654
+ animation.onfinish = () => {
655
+ finishedCount += 1;
656
+ if (finishedCount === animations.length) {
657
+ callback();
658
+ }
659
+ };
660
+ });
661
+ };
662
+ var sizes = {
663
+ small: {
664
+ sizeClass: "max-h-screen desktop:max-w-120 rounded-sm"
665
+ },
666
+ medium: {
667
+ sizeClass: "desktop:max-w-180 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
668
+ },
669
+ large: {
670
+ sizeClass: "desktop:max-w-240 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
671
+ },
672
+ "x-large": {
673
+ sizeClass: "desktop:max-w-300 w-screen desktop:h-fit h-screen desktop:w-full max-w-240"
674
+ }
675
+ };
676
+ var Modal = ({
677
+ id,
678
+ title,
679
+ open = false,
680
+ size = "small",
681
+ className,
682
+ children,
683
+ onClose,
684
+ onContinue,
685
+ closeOnBackdropClick = true,
686
+ showButtons = false,
687
+ hideCloseIcon = false,
688
+ headerIcon,
689
+ fixedHeightScrolling = false,
690
+ customActions
691
+ }) => {
692
+ var _a;
693
+ const mounted = useMounted();
694
+ const modalRef = (0, import_react4.useRef)(null);
695
+ const bgRef = (0, import_react4.useRef)(null);
696
+ const wasOpen = (0, import_react_use.usePrevious)(open);
697
+ const isMobile = useMatchesMobile();
698
+ const computedFixedHeightScrolling = isMobile || fixedHeightScrolling;
699
+ (0, import_react4.useEffect)(() => {
700
+ if (!mounted) return;
701
+ if (!modalRef.current || !bgRef.current) {
702
+ console.error("Modal or background reference is not set.");
703
+ return;
704
+ }
705
+ if (wasOpen === void 0) return;
706
+ if (wasOpen && !open) {
707
+ const modalAnimation = fadeOutScale(modalRef.current);
708
+ const bgAnimation = bgFadeOut(bgRef.current);
709
+ whenAllAnimationsFinish([modalAnimation, bgAnimation], () => {
710
+ if (onClose) {
711
+ onClose();
712
+ }
713
+ });
714
+ } else if (!wasOpen && open) {
715
+ fadeInScale(modalRef.current);
716
+ bgFadeIn(bgRef.current);
717
+ }
718
+ }, [mounted, open]);
719
+ const handleKeyDown = (0, import_react4.useCallback)(
720
+ (e) => {
721
+ if (e.key === "Escape") {
722
+ if (onClose) {
723
+ e.preventDefault();
724
+ onClose();
725
+ }
726
+ }
727
+ },
728
+ [onClose, bgRef, modalRef]
729
+ );
730
+ const handleClose = (0, import_react4.useCallback)(() => {
731
+ if (onClose) {
732
+ onClose();
733
+ }
734
+ }, [onClose]);
735
+ (0, import_react4.useEffect)(() => {
736
+ if (open) {
737
+ document.addEventListener("keyup", handleKeyDown);
738
+ }
739
+ return () => {
740
+ document.removeEventListener("keyup", handleKeyDown);
741
+ };
742
+ }, [open, handleKeyDown]);
743
+ (0, import_react4.useEffect)(() => {
744
+ if (!open) return;
745
+ const scrollY = window.scrollY;
746
+ const body = document.body;
747
+ body.style.position = "fixed";
748
+ body.style.top = `-${scrollY}px`;
749
+ body.style.left = "0";
750
+ body.style.right = "0";
751
+ body.style.overflow = "hidden";
752
+ body.style.width = "100%";
753
+ return () => {
754
+ body.style.position = "";
755
+ body.style.top = "";
756
+ body.style.left = "";
757
+ body.style.right = "";
758
+ body.style.overflow = "";
759
+ body.style.width = "";
760
+ window.scrollTo(0, scrollY);
761
+ };
762
+ }, [open]);
763
+ const { sizeClass } = (_a = sizes[size]) != null ? _a : sizes.small;
764
+ const backgroundClickHandler = (0, import_react4.useCallback)(
765
+ (e) => {
766
+ const target = e.target;
767
+ const currentTarget = e.currentTarget;
768
+ if (currentTarget.contains(target) && currentTarget !== target) {
769
+ e.stopPropagation();
770
+ return;
771
+ }
772
+ if (open && closeOnBackdropClick) {
773
+ handleClose();
774
+ }
775
+ },
776
+ [open, closeOnBackdropClick, handleClose]
777
+ );
778
+ if (!mounted) {
779
+ return null;
780
+ }
781
+ return (0, import_react_dom.createPortal)(
782
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
783
+ ModalScrim,
784
+ {
785
+ id: id ? `${id}-scrim` : void 0,
786
+ size,
787
+ ref: bgRef,
788
+ show: open,
789
+ onClick: backgroundClickHandler,
790
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
791
+ "div",
792
+ {
793
+ id,
794
+ ref: modalRef,
795
+ className: (0, import_clsx9.default)(
796
+ "bg-white shadow-md rounded-sm flex flex-col overflow-hidden w-full opacity-0 h-fit",
797
+ computedFixedHeightScrolling && "desktop:max-h-[calc(100vh-32px)] desktop:h-auto",
798
+ className,
799
+ sizeClass
800
+ ),
801
+ onClick: (e) => e.stopPropagation(),
802
+ children: [
803
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
804
+ ModalHeader,
805
+ {
806
+ id: id ? `${id}-header` : void 0,
807
+ title,
808
+ onClose: handleClose,
809
+ hideCloseIcon,
810
+ headerIcon
811
+ }
812
+ ),
813
+ children && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
814
+ ModalContent,
815
+ {
816
+ id: id ? `${id}-content` : void 0,
817
+ fixedHeightScrolling: computedFixedHeightScrolling,
818
+ children
819
+ }
820
+ ),
821
+ showButtons && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
822
+ ModalButtons,
823
+ {
824
+ id: id ? `${id}-buttons` : void 0,
825
+ onClose: handleClose,
826
+ onContinue,
827
+ customActions
828
+ }
829
+ )
830
+ ]
831
+ }
832
+ )
833
+ }
834
+ ),
835
+ findDocumentRoot(bgRef.current)
836
+ );
837
+ };
838
+ Modal.displayName = "Modal";
839
+
840
+ // src/components/PDFViewer.tsx
841
+ var import_jsx_runtime9 = require("react/jsx-runtime");
842
+ function PDFViewer(props) {
843
+ const { base64, isOpen, onClose, datab64 } = props;
844
+ const [page, setPage] = (0, import_react5.useState)(1);
845
+ const canvasRef = (0, import_react5.useRef)(null);
846
+ const { pdfDocument } = (0, import_react_pdf.usePdf)({
847
+ file: datab64 ? datab64 : `data:application/pdf;base64,${base64}`,
848
+ workerSrc: "/scripts/pdf.worker.min.mjs",
849
+ page,
850
+ canvasRef,
851
+ scale: 1
852
+ });
853
+ if (!base64 && !datab64) return null;
854
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Modal, { open: isOpen, onClose, hideCloseIcon: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col space-y-4", children: [
855
+ pdfDocument ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("canvas", { ref: canvasRef }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: "Loading PDF..." }),
856
+ Boolean(pdfDocument && pdfDocument.numPages) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("ul", { className: "flex flex-row justify-between items-center", children: [
857
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "previous", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
858
+ Button,
859
+ {
860
+ disabled: page === 1,
861
+ onClick: () => setPage(page - 1),
862
+ variant: "navigation",
863
+ children: "Previous"
864
+ }
865
+ ) }),
866
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { className: "text-label-desktop text-text-on-action-primary-normal", children: [
867
+ "Page ",
868
+ page,
869
+ " of ",
870
+ pdfDocument.numPages
871
+ ] }),
872
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "next", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
873
+ Button,
874
+ {
875
+ disabled: page === pdfDocument.numPages,
876
+ onClick: () => setPage(page + 1),
877
+ variant: "navigation",
878
+ children: "Next"
879
+ }
880
+ ) })
881
+ ] })
882
+ ] }) });
883
+ }
884
+ // Annotate the CommonJS export names for ESM import in node:
885
+ 0 && (module.exports = {
886
+ PDFViewer
887
+ });