@dmsi/wedgekit-react 0.0.208 → 0.0.210
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-2WRRRPEB.js → chunk-BHFIS4ZV.js} +1 -1
- package/dist/{chunk-33W2KSCB.js → chunk-HKSYYK4K.js} +1 -1
- package/dist/{chunk-EFX3RPW4.js → chunk-LQW4LMNB.js} +18 -27
- package/dist/components/DataGridCell.cjs +826 -839
- package/dist/components/DataGridCell.js +6 -6
- package/dist/components/DateInput.js +7 -7
- package/dist/components/DateRangeInput.js +7 -7
- package/dist/components/FilterGroup.js +7 -7
- package/dist/components/Input.js +2 -2
- package/dist/components/MenuOption.js +2 -2
- package/dist/components/MobileDataGrid.js +3 -3
- package/dist/components/Modal.js +1 -1
- package/dist/components/NestedMenu.js +2 -2
- package/dist/components/Notification.js +3 -3
- package/dist/components/PDFViewer.js +3 -3
- package/dist/components/Password.js +2 -2
- package/dist/components/Search.js +3 -3
- package/dist/components/Select.js +3 -3
- package/dist/components/Stepper.js +2 -2
- package/dist/components/Time.js +4 -4
- package/dist/components/Toast.js +3 -3
- package/dist/components/Upload.js +3 -3
- package/dist/components/index.cjs +901 -909
- package/dist/components/index.js +33 -28
- package/package.json +1 -1
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -4
- package/src/components/DataGrid/TableBody/index.tsx +14 -3
- package/src/components/DataGrid/index.tsx +1 -4
- package/src/components/DataGridCell.tsx +11 -17
- package/dist/{chunk-7W4I2NK3.js → chunk-GW7OVMMC.js} +3 -3
- package/dist/{chunk-ERW3AMED.js → chunk-TPZ6752P.js} +3 -3
|
@@ -262,66 +262,78 @@ var gapUsingContainerPadding = (0, import_clsx.default)(
|
|
|
262
262
|
"gap-mobile-container-padding desktop:gap-desktop-container-padding compact:gap-desktop-compact-container-padding"
|
|
263
263
|
);
|
|
264
264
|
|
|
265
|
-
// src/components/
|
|
265
|
+
// src/components/MenuOption.tsx
|
|
266
|
+
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
267
|
+
var import_react6 = require("react");
|
|
268
|
+
|
|
269
|
+
// src/components/Label.tsx
|
|
266
270
|
var import_clsx2 = __toESM(require("clsx"), 1);
|
|
267
271
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
268
|
-
|
|
272
|
+
var Label = (_a) => {
|
|
269
273
|
var _b = _a, {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
as = "span",
|
|
275
|
+
padded,
|
|
276
|
+
className,
|
|
277
|
+
color,
|
|
278
|
+
align,
|
|
279
|
+
id,
|
|
273
280
|
testid
|
|
274
281
|
} = _b, props = __objRest(_b, [
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"
|
|
282
|
+
"as",
|
|
283
|
+
"padded",
|
|
284
|
+
"className",
|
|
285
|
+
"color",
|
|
286
|
+
"align",
|
|
287
|
+
"id",
|
|
278
288
|
"testid"
|
|
279
289
|
]);
|
|
280
|
-
const
|
|
281
|
-
const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
|
|
290
|
+
const Element = as;
|
|
282
291
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
283
|
-
|
|
284
|
-
__spreadProps(__spreadValues({
|
|
292
|
+
Element,
|
|
293
|
+
__spreadProps(__spreadValues({
|
|
294
|
+
id,
|
|
285
295
|
"data-testid": testid,
|
|
286
296
|
className: (0, import_clsx2.default)(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
297
|
+
typography.label,
|
|
298
|
+
align === "left" && "text-left",
|
|
299
|
+
align === "center" && "text-center",
|
|
300
|
+
align === "right" && "text-right",
|
|
301
|
+
className,
|
|
302
|
+
padded && componentPaddingXUsingComponentGap
|
|
303
|
+
)
|
|
304
|
+
}, props), {
|
|
305
|
+
style: __spreadProps(__spreadValues({}, props.style), {
|
|
306
|
+
color: color ? `var(--color-${color})` : void 0
|
|
307
|
+
})
|
|
296
308
|
})
|
|
297
309
|
);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/components/Search.tsx
|
|
301
|
-
var import_react3 = require("react");
|
|
302
|
-
|
|
303
|
-
// src/components/Input.tsx
|
|
304
|
-
var import_react2 = require("react");
|
|
305
|
-
var import_clsx4 = __toESM(require("clsx"), 1);
|
|
310
|
+
};
|
|
311
|
+
Label.displayName = "Label";
|
|
306
312
|
|
|
307
|
-
// src/components/
|
|
313
|
+
// src/components/Paragraph.tsx
|
|
308
314
|
var import_clsx3 = __toESM(require("clsx"), 1);
|
|
309
315
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
310
|
-
var
|
|
316
|
+
var Paragraph = (_a) => {
|
|
311
317
|
var _b = _a, {
|
|
312
|
-
as = "span",
|
|
313
|
-
padded,
|
|
314
318
|
className,
|
|
315
319
|
color,
|
|
316
|
-
|
|
320
|
+
padded,
|
|
321
|
+
align = "left",
|
|
322
|
+
tall,
|
|
323
|
+
addOverflow,
|
|
324
|
+
children,
|
|
325
|
+
as = "p",
|
|
317
326
|
id,
|
|
318
327
|
testid
|
|
319
328
|
} = _b, props = __objRest(_b, [
|
|
320
|
-
"as",
|
|
321
|
-
"padded",
|
|
322
329
|
"className",
|
|
323
330
|
"color",
|
|
331
|
+
"padded",
|
|
324
332
|
"align",
|
|
333
|
+
"tall",
|
|
334
|
+
"addOverflow",
|
|
335
|
+
"children",
|
|
336
|
+
"as",
|
|
325
337
|
"id",
|
|
326
338
|
"testid"
|
|
327
339
|
]);
|
|
@@ -330,23 +342,108 @@ var Label = (_a) => {
|
|
|
330
342
|
Element,
|
|
331
343
|
__spreadProps(__spreadValues({
|
|
332
344
|
id,
|
|
333
|
-
"data-testid": testid
|
|
345
|
+
"data-testid": testid
|
|
346
|
+
}, props), {
|
|
334
347
|
className: (0, import_clsx3.default)(
|
|
335
|
-
typography.
|
|
348
|
+
typography.paragraph,
|
|
349
|
+
className,
|
|
350
|
+
padded && componentPaddingXUsingComponentGap,
|
|
336
351
|
align === "left" && "text-left",
|
|
337
352
|
align === "center" && "text-center",
|
|
338
353
|
align === "right" && "text-right",
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
)
|
|
342
|
-
}, props), {
|
|
354
|
+
tall && "!leading-6",
|
|
355
|
+
addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
|
|
356
|
+
),
|
|
343
357
|
style: __spreadProps(__spreadValues({}, props.style), {
|
|
344
358
|
color: color ? `var(--color-${color})` : void 0
|
|
345
|
-
})
|
|
359
|
+
}),
|
|
360
|
+
children
|
|
346
361
|
})
|
|
347
362
|
);
|
|
348
363
|
};
|
|
349
|
-
|
|
364
|
+
Paragraph.displayName = "Paragraph";
|
|
365
|
+
|
|
366
|
+
// src/components/Icon.tsx
|
|
367
|
+
var import_clsx4 = __toESM(require("clsx"), 1);
|
|
368
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
369
|
+
function Icon(_a) {
|
|
370
|
+
var _b = _a, {
|
|
371
|
+
name,
|
|
372
|
+
size = 24,
|
|
373
|
+
variant = "outline",
|
|
374
|
+
testid
|
|
375
|
+
} = _b, props = __objRest(_b, [
|
|
376
|
+
"name",
|
|
377
|
+
"size",
|
|
378
|
+
"variant",
|
|
379
|
+
"testid"
|
|
380
|
+
]);
|
|
381
|
+
const variantStyle = variant === "filled" ? '"FILL" 1' : '"FILL" 0';
|
|
382
|
+
const weightStyle = size === 16 ? '"wght" 400' : '"wght" 300';
|
|
383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
384
|
+
"span",
|
|
385
|
+
__spreadProps(__spreadValues({}, props), {
|
|
386
|
+
"data-testid": testid,
|
|
387
|
+
className: (0, import_clsx4.default)(
|
|
388
|
+
"icon",
|
|
389
|
+
`icon-${size}`,
|
|
390
|
+
// size === 16 ? "font-normal" : "font-light", // size 16 font weight is not working as normal from before
|
|
391
|
+
props.className
|
|
392
|
+
),
|
|
393
|
+
style: __spreadValues({
|
|
394
|
+
fontVariationSettings: variantStyle + `, ${weightStyle}`
|
|
395
|
+
}, props.style),
|
|
396
|
+
children: name
|
|
397
|
+
})
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// src/hooks/useKeydown.ts
|
|
402
|
+
var import_react2 = require("react");
|
|
403
|
+
|
|
404
|
+
// src/hooks/useInfiniteScroll.tsx
|
|
405
|
+
var import_react3 = require("react");
|
|
406
|
+
function useInfiniteScroll({
|
|
407
|
+
containerRef,
|
|
408
|
+
onLoadMore,
|
|
409
|
+
isLoading,
|
|
410
|
+
offset = 50,
|
|
411
|
+
enabled = true
|
|
412
|
+
// ✅ Add this
|
|
413
|
+
}) {
|
|
414
|
+
(0, import_react3.useEffect)(() => {
|
|
415
|
+
if (!enabled) return;
|
|
416
|
+
const handleScroll = () => {
|
|
417
|
+
const el2 = containerRef.current;
|
|
418
|
+
if (!el2 || isLoading) return;
|
|
419
|
+
const { scrollTop, scrollHeight, clientHeight } = el2;
|
|
420
|
+
const isNearBottom = scrollTop + clientHeight >= scrollHeight - offset;
|
|
421
|
+
if (isNearBottom) {
|
|
422
|
+
onLoadMore();
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const el = containerRef.current;
|
|
426
|
+
if (el) el.addEventListener("scroll", handleScroll);
|
|
427
|
+
return () => {
|
|
428
|
+
if (el) el.removeEventListener("scroll", handleScroll);
|
|
429
|
+
};
|
|
430
|
+
}, [containerRef, onLoadMore, isLoading, offset, enabled]);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/hooks/useMatchesMedia.ts
|
|
434
|
+
var import_react4 = require("react");
|
|
435
|
+
var useMatchesMedia = (query) => {
|
|
436
|
+
const [matches, setMatches] = (0, import_react4.useState)();
|
|
437
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
438
|
+
const mediaQueryList = window.matchMedia(query);
|
|
439
|
+
const listener = () => setMatches(mediaQueryList.matches);
|
|
440
|
+
listener();
|
|
441
|
+
mediaQueryList.addEventListener("change", listener);
|
|
442
|
+
return () => mediaQueryList.removeEventListener("change", listener);
|
|
443
|
+
}, [query]);
|
|
444
|
+
return matches;
|
|
445
|
+
};
|
|
446
|
+
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
350
447
|
|
|
351
448
|
// src/utils/formatting.tsx
|
|
352
449
|
function getDecimalPlaceholder(decimals) {
|
|
@@ -381,561 +478,6 @@ function formatCurrencyDisplay(value) {
|
|
|
381
478
|
return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
|
|
382
479
|
}
|
|
383
480
|
|
|
384
|
-
// src/components/Input.tsx
|
|
385
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
386
|
-
var InputBase = (_a) => {
|
|
387
|
-
var _b = _a, {
|
|
388
|
-
id,
|
|
389
|
-
testid,
|
|
390
|
-
before,
|
|
391
|
-
after,
|
|
392
|
-
type,
|
|
393
|
-
label,
|
|
394
|
-
error,
|
|
395
|
-
className,
|
|
396
|
-
align = "left",
|
|
397
|
-
caption,
|
|
398
|
-
required,
|
|
399
|
-
selectOnFocus,
|
|
400
|
-
removeRoundness,
|
|
401
|
-
inputContainerRef,
|
|
402
|
-
removeBorder,
|
|
403
|
-
wrapperClassName,
|
|
404
|
-
focus,
|
|
405
|
-
fullWidth = true
|
|
406
|
-
} = _b, props = __objRest(_b, [
|
|
407
|
-
"id",
|
|
408
|
-
"testid",
|
|
409
|
-
"before",
|
|
410
|
-
"after",
|
|
411
|
-
"type",
|
|
412
|
-
"label",
|
|
413
|
-
"error",
|
|
414
|
-
"className",
|
|
415
|
-
"align",
|
|
416
|
-
"caption",
|
|
417
|
-
"required",
|
|
418
|
-
"selectOnFocus",
|
|
419
|
-
"removeRoundness",
|
|
420
|
-
"inputContainerRef",
|
|
421
|
-
"removeBorder",
|
|
422
|
-
"wrapperClassName",
|
|
423
|
-
"focus",
|
|
424
|
-
"fullWidth"
|
|
425
|
-
]);
|
|
426
|
-
const attributes = {
|
|
427
|
-
"data-error": error && !focus || null,
|
|
428
|
-
"data-focus": focus || null
|
|
429
|
-
};
|
|
430
|
-
const inputRef = (0, import_react2.useRef)(null);
|
|
431
|
-
const inputId = id ? `${id}-input` : void 0;
|
|
432
|
-
(0, import_react2.useEffect)(() => {
|
|
433
|
-
var _a2;
|
|
434
|
-
const input = inputRef.current;
|
|
435
|
-
const focusHandler = () => {
|
|
436
|
-
input == null ? void 0 : input.select();
|
|
437
|
-
};
|
|
438
|
-
if (selectOnFocus) {
|
|
439
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
|
|
440
|
-
return () => {
|
|
441
|
-
input == null ? void 0 : input.removeEventListener("focus", focusHandler);
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
}, [selectOnFocus]);
|
|
445
|
-
const inputBaseClass = (0, import_clsx4.default)(
|
|
446
|
-
fullWidth ? "w-full" : "w-fit",
|
|
447
|
-
"flex flex-row items-center",
|
|
448
|
-
"bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
|
|
449
|
-
componentGap,
|
|
450
|
-
baseTransition,
|
|
451
|
-
"outline-transparent outline-2 -outline-offset-2",
|
|
452
|
-
componentPaddingMinusBorder,
|
|
453
|
-
!removeRoundness && "rounded-base",
|
|
454
|
-
!removeBorder && "border border-border-primary-normal",
|
|
455
|
-
"relative"
|
|
456
|
-
);
|
|
457
|
-
const inputFocusClass = (0, import_clsx4.default)(
|
|
458
|
-
"has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
|
|
459
|
-
);
|
|
460
|
-
const inputDisabledClass = (0, import_clsx4.default)(
|
|
461
|
-
"has-disabled:bg-background-action-secondary-disabled"
|
|
462
|
-
);
|
|
463
|
-
const inputReadOnlyClass = (0, import_clsx4.default)(
|
|
464
|
-
"has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
|
|
465
|
-
);
|
|
466
|
-
const inputInvalidClass = (0, import_clsx4.default)(
|
|
467
|
-
"has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
|
|
468
|
-
);
|
|
469
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
470
|
-
"label",
|
|
471
|
-
{
|
|
472
|
-
id,
|
|
473
|
-
"data-testid": testid,
|
|
474
|
-
htmlFor: inputId,
|
|
475
|
-
ref: inputContainerRef,
|
|
476
|
-
className: (0, import_clsx4.default)(
|
|
477
|
-
"w-full flex flex-col",
|
|
478
|
-
"block",
|
|
479
|
-
"text-text-primary-normal has-disabled:text-text-primary-disabled",
|
|
480
|
-
componentGap
|
|
481
|
-
),
|
|
482
|
-
style: __spreadValues({}, props.style),
|
|
483
|
-
children: [
|
|
484
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: (0, import_clsx4.default)("flex items-center", componentGap), children: [
|
|
485
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
486
|
-
Label,
|
|
487
|
-
{
|
|
488
|
-
id: id ? `${id}-label` : void 0,
|
|
489
|
-
className: (0, import_clsx4.default)(
|
|
490
|
-
props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
|
|
491
|
-
),
|
|
492
|
-
children: label
|
|
493
|
-
}
|
|
494
|
-
),
|
|
495
|
-
required && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
496
|
-
"span",
|
|
497
|
-
{
|
|
498
|
-
className: (0, import_clsx4.default)(typography.label, "text-text-critical-normal"),
|
|
499
|
-
children: "*"
|
|
500
|
-
}
|
|
501
|
-
)
|
|
502
|
-
] }),
|
|
503
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
504
|
-
"div",
|
|
505
|
-
{
|
|
506
|
-
className: (0, import_clsx4.default)(
|
|
507
|
-
inputBaseClass,
|
|
508
|
-
!props.disabled && inputInvalidClass,
|
|
509
|
-
inputFocusClass,
|
|
510
|
-
inputDisabledClass,
|
|
511
|
-
inputReadOnlyClass,
|
|
512
|
-
wrapperClassName
|
|
513
|
-
),
|
|
514
|
-
children: [
|
|
515
|
-
before,
|
|
516
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
517
|
-
"input",
|
|
518
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
519
|
-
ref: (el) => {
|
|
520
|
-
inputRef.current = el;
|
|
521
|
-
},
|
|
522
|
-
type,
|
|
523
|
-
required
|
|
524
|
-
}, props), attributes), {
|
|
525
|
-
id: inputId,
|
|
526
|
-
"data-testid": testid ? `${testid}-input` : void 0,
|
|
527
|
-
className: (0, import_clsx4.default)(
|
|
528
|
-
"flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
|
|
529
|
-
"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
530
|
-
"placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
|
|
531
|
-
align === "right" && "text-right",
|
|
532
|
-
align === "center" && "text-center",
|
|
533
|
-
componentPaddingXUsingComponentGap,
|
|
534
|
-
typography.paragraph,
|
|
535
|
-
className,
|
|
536
|
-
props.readOnly && !props.disabled && "!px-0"
|
|
537
|
-
)
|
|
538
|
-
})
|
|
539
|
-
),
|
|
540
|
-
after
|
|
541
|
-
]
|
|
542
|
-
}
|
|
543
|
-
),
|
|
544
|
-
caption && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { id: id ? `${id}-caption` : void 0, "data-testid": testid ? `${testid}-caption` : void 0, children: caption })
|
|
545
|
-
]
|
|
546
|
-
}
|
|
547
|
-
);
|
|
548
|
-
};
|
|
549
|
-
var Input = (_a) => {
|
|
550
|
-
var _b = _a, {
|
|
551
|
-
variant = "default",
|
|
552
|
-
decimals,
|
|
553
|
-
uom,
|
|
554
|
-
removeSearchIcon,
|
|
555
|
-
value: propValue,
|
|
556
|
-
onChange,
|
|
557
|
-
onBlur,
|
|
558
|
-
onClear,
|
|
559
|
-
id,
|
|
560
|
-
testid
|
|
561
|
-
} = _b, props = __objRest(_b, [
|
|
562
|
-
"variant",
|
|
563
|
-
"decimals",
|
|
564
|
-
"uom",
|
|
565
|
-
"removeSearchIcon",
|
|
566
|
-
"value",
|
|
567
|
-
"onChange",
|
|
568
|
-
"onBlur",
|
|
569
|
-
"onClear",
|
|
570
|
-
"id",
|
|
571
|
-
"testid"
|
|
572
|
-
]);
|
|
573
|
-
const [internalValue, setInternalValue] = (0, import_react2.useState)("");
|
|
574
|
-
const [displayValue, setDisplayValue] = (0, import_react2.useState)("");
|
|
575
|
-
(0, import_react2.useEffect)(() => {
|
|
576
|
-
var _a2;
|
|
577
|
-
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
578
|
-
setInternalValue(stringValue);
|
|
579
|
-
setDisplayValue(stringValue);
|
|
580
|
-
}, [propValue]);
|
|
581
|
-
(0, import_react2.useEffect)(() => {
|
|
582
|
-
var _a2;
|
|
583
|
-
if (variant !== "currency") {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
587
|
-
if (!stringValue) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
591
|
-
setInternalValue(formatted);
|
|
592
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
593
|
-
}, []);
|
|
594
|
-
const getInputProps = () => {
|
|
595
|
-
var _a2;
|
|
596
|
-
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
597
|
-
id
|
|
598
|
-
}), getDecimalPlaceholder(decimals)), {
|
|
599
|
-
value: propValue
|
|
600
|
-
});
|
|
601
|
-
switch (variant) {
|
|
602
|
-
case "search":
|
|
603
|
-
return __spreadProps(__spreadValues({}, baseProps), {
|
|
604
|
-
placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
|
|
605
|
-
className: "!mr-6",
|
|
606
|
-
value: displayValue
|
|
607
|
-
});
|
|
608
|
-
case "finder":
|
|
609
|
-
return baseProps;
|
|
610
|
-
case "currency":
|
|
611
|
-
return __spreadProps(__spreadValues({}, baseProps), {
|
|
612
|
-
align: "right",
|
|
613
|
-
type: "text",
|
|
614
|
-
value: displayValue
|
|
615
|
-
});
|
|
616
|
-
case "percentage":
|
|
617
|
-
case "uom":
|
|
618
|
-
return __spreadProps(__spreadValues({}, baseProps), {
|
|
619
|
-
type: "number",
|
|
620
|
-
align: "right"
|
|
621
|
-
});
|
|
622
|
-
default:
|
|
623
|
-
return baseProps;
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
const getBeforeElement = () => {
|
|
627
|
-
if (props.before) return props.before;
|
|
628
|
-
switch (variant) {
|
|
629
|
-
case "search":
|
|
630
|
-
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "search" }) }) : null;
|
|
631
|
-
case "currency":
|
|
632
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "attach_money" }) });
|
|
633
|
-
default:
|
|
634
|
-
return null;
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
const getAfterElement = () => {
|
|
638
|
-
if (props.after) return props.after;
|
|
639
|
-
switch (variant) {
|
|
640
|
-
case "search": {
|
|
641
|
-
const hasValue = displayValue.length > 0;
|
|
642
|
-
return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
643
|
-
Icon,
|
|
644
|
-
{
|
|
645
|
-
id: id ? `${id}-clear-button` : void 0,
|
|
646
|
-
testid: testid ? `${testid}-clear-button` : void 0,
|
|
647
|
-
name: "close",
|
|
648
|
-
onClick: handleSearchReset,
|
|
649
|
-
className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
|
|
650
|
-
}
|
|
651
|
-
) : null;
|
|
652
|
-
}
|
|
653
|
-
case "finder":
|
|
654
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "search" });
|
|
655
|
-
case "uom":
|
|
656
|
-
return uom ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
|
|
657
|
-
case "percentage":
|
|
658
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "percent" }) });
|
|
659
|
-
default:
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
const handleSearchReset = () => {
|
|
664
|
-
setInternalValue("");
|
|
665
|
-
setDisplayValue("");
|
|
666
|
-
if (onChange) {
|
|
667
|
-
const syntheticEvent = {
|
|
668
|
-
target: { value: "" }
|
|
669
|
-
};
|
|
670
|
-
if (typeof onChange === "function") {
|
|
671
|
-
onChange(syntheticEvent);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
onClear == null ? void 0 : onClear();
|
|
675
|
-
};
|
|
676
|
-
const handleChange = (e) => {
|
|
677
|
-
const rawValue = e.target.value;
|
|
678
|
-
if (variant === "currency") {
|
|
679
|
-
const raw = rawValue.replace(/,/g, "");
|
|
680
|
-
if (raw === "") {
|
|
681
|
-
setInternalValue("");
|
|
682
|
-
setDisplayValue("");
|
|
683
|
-
if (onChange) {
|
|
684
|
-
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
685
|
-
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
686
|
-
});
|
|
687
|
-
onChange(syntheticEvent);
|
|
688
|
-
}
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
const regex = /^\d*\.?\d*$/;
|
|
692
|
-
if (!regex.test(raw)) return;
|
|
693
|
-
const parts = raw.split(".");
|
|
694
|
-
const currentDecimals = decimals != null ? decimals : 2;
|
|
695
|
-
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
696
|
-
setInternalValue(raw);
|
|
697
|
-
setDisplayValue(formatCurrencyDisplay(raw));
|
|
698
|
-
const asNumber = Number(raw);
|
|
699
|
-
if (!isNaN(asNumber) && onChange) {
|
|
700
|
-
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
701
|
-
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
702
|
-
});
|
|
703
|
-
onChange(syntheticEvent);
|
|
704
|
-
}
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
setInternalValue(rawValue);
|
|
708
|
-
setDisplayValue(rawValue);
|
|
709
|
-
if (typeof onChange === "function") {
|
|
710
|
-
onChange(e);
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
const handleBlur = (e) => {
|
|
714
|
-
if (!internalValue) {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (variant === "currency") {
|
|
718
|
-
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
719
|
-
setInternalValue(formatted);
|
|
720
|
-
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
721
|
-
const asNumber = Number(formatted);
|
|
722
|
-
if (!isNaN(asNumber) && onChange) {
|
|
723
|
-
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
724
|
-
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
725
|
-
});
|
|
726
|
-
onChange(syntheticEvent);
|
|
727
|
-
}
|
|
728
|
-
} else if (variant === "uom" || variant === "percentage") {
|
|
729
|
-
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
730
|
-
e.target.value = formattedValue;
|
|
731
|
-
}
|
|
732
|
-
onBlur == null ? void 0 : onBlur(e);
|
|
733
|
-
};
|
|
734
|
-
const inputProps = getInputProps();
|
|
735
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
736
|
-
InputBase,
|
|
737
|
-
__spreadProps(__spreadValues({}, inputProps), {
|
|
738
|
-
before: getBeforeElement(),
|
|
739
|
-
after: getAfterElement(),
|
|
740
|
-
onChange: handleChange,
|
|
741
|
-
onBlur: handleBlur,
|
|
742
|
-
testid
|
|
743
|
-
})
|
|
744
|
-
);
|
|
745
|
-
};
|
|
746
|
-
Input.displayName = "Input";
|
|
747
|
-
var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
|
|
748
|
-
var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
|
|
749
|
-
var Currency = (props) => {
|
|
750
|
-
var _a;
|
|
751
|
-
const handleCurrencyChange = (e) => {
|
|
752
|
-
var _a2;
|
|
753
|
-
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
|
|
754
|
-
};
|
|
755
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
756
|
-
Input,
|
|
757
|
-
__spreadProps(__spreadValues({}, props), {
|
|
758
|
-
variant: "currency",
|
|
759
|
-
decimals: (_a = props.decimals) != null ? _a : 2,
|
|
760
|
-
onChange: handleCurrencyChange
|
|
761
|
-
})
|
|
762
|
-
);
|
|
763
|
-
};
|
|
764
|
-
var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
|
|
765
|
-
Finder.displayName = "Finder";
|
|
766
|
-
UOM.displayName = "UOM";
|
|
767
|
-
Currency.displayName = "Currency";
|
|
768
|
-
Percentage.displayName = "Percentage";
|
|
769
|
-
|
|
770
|
-
// src/components/Search.tsx
|
|
771
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
772
|
-
var Search = (_a) => {
|
|
773
|
-
var _b = _a, {
|
|
774
|
-
id,
|
|
775
|
-
testid,
|
|
776
|
-
label,
|
|
777
|
-
error,
|
|
778
|
-
children,
|
|
779
|
-
readOnly,
|
|
780
|
-
renderMenu,
|
|
781
|
-
onClick,
|
|
782
|
-
wrapperClassName,
|
|
783
|
-
removeRoundness
|
|
784
|
-
} = _b, props = __objRest(_b, [
|
|
785
|
-
"id",
|
|
786
|
-
"testid",
|
|
787
|
-
"label",
|
|
788
|
-
"error",
|
|
789
|
-
"children",
|
|
790
|
-
"readOnly",
|
|
791
|
-
"renderMenu",
|
|
792
|
-
"onClick",
|
|
793
|
-
"wrapperClassName",
|
|
794
|
-
"removeRoundness"
|
|
795
|
-
]);
|
|
796
|
-
const inputRef = (0, import_react3.useRef)(null);
|
|
797
|
-
const inputContainerRef = (0, import_react3.useRef)(null);
|
|
798
|
-
const preventFocusOnInitialRender = (0, import_react3.useRef)(true);
|
|
799
|
-
const [show, setShow] = (0, import_react3.useState)(false);
|
|
800
|
-
const [clearing, setClearing] = (0, import_react3.useState)(false);
|
|
801
|
-
const uniqueId = (0, import_react3.useId)();
|
|
802
|
-
const searchMenuName = `search-menu-${uniqueId}`;
|
|
803
|
-
(0, import_react3.useEffect)(() => {
|
|
804
|
-
var _a2;
|
|
805
|
-
if (preventFocusOnInitialRender.current) {
|
|
806
|
-
preventFocusOnInitialRender.current = false;
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
810
|
-
}, [props.value]);
|
|
811
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
812
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
813
|
-
Input,
|
|
814
|
-
__spreadValues({
|
|
815
|
-
id,
|
|
816
|
-
testid,
|
|
817
|
-
variant: "search",
|
|
818
|
-
inputContainerRef,
|
|
819
|
-
ref: inputRef,
|
|
820
|
-
label,
|
|
821
|
-
wrapperClassName,
|
|
822
|
-
onClick: (e) => {
|
|
823
|
-
if (props.disabled || readOnly) {
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
if (clearing) {
|
|
827
|
-
setClearing(false);
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
onClick == null ? void 0 : onClick(e);
|
|
831
|
-
setShow(!show);
|
|
832
|
-
},
|
|
833
|
-
onClear: () => {
|
|
834
|
-
setClearing(true);
|
|
835
|
-
},
|
|
836
|
-
onKeyDown: (e) => {
|
|
837
|
-
setShow(true);
|
|
838
|
-
if (["ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
839
|
-
e.preventDefault();
|
|
840
|
-
const menu = document.querySelector(
|
|
841
|
-
`[data-menu="${searchMenuName}"]`
|
|
842
|
-
);
|
|
843
|
-
const selectedMenuOption = menu == null ? void 0 : menu.querySelector("[data-selected]");
|
|
844
|
-
if (selectedMenuOption) {
|
|
845
|
-
const allMenuOptions = Array.from(
|
|
846
|
-
(menu == null ? void 0 : menu.querySelectorAll('[role="menuitem"]')) || []
|
|
847
|
-
);
|
|
848
|
-
const currentIndex = allMenuOptions.indexOf(selectedMenuOption);
|
|
849
|
-
let targetOption;
|
|
850
|
-
if (e.key === "ArrowDown") {
|
|
851
|
-
targetOption = allMenuOptions[currentIndex + 1] || allMenuOptions[0];
|
|
852
|
-
} else {
|
|
853
|
-
targetOption = allMenuOptions[currentIndex - 1] || allMenuOptions[allMenuOptions.length - 1];
|
|
854
|
-
}
|
|
855
|
-
targetOption == null ? void 0 : targetOption.focus();
|
|
856
|
-
} else {
|
|
857
|
-
const toFocusMenuOption = e.key === "ArrowDown" ? menu == null ? void 0 : menu.querySelector('[role="menuitem"]') : menu == null ? void 0 : menu.querySelector(
|
|
858
|
-
'[role="menuitem"]:last-child'
|
|
859
|
-
);
|
|
860
|
-
toFocusMenuOption == null ? void 0 : toFocusMenuOption.focus();
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
},
|
|
864
|
-
error,
|
|
865
|
-
readOnly,
|
|
866
|
-
removeRoundness,
|
|
867
|
-
focus: renderMenu && show
|
|
868
|
-
}, props)
|
|
869
|
-
),
|
|
870
|
-
renderMenu ? renderMenu({
|
|
871
|
-
id: id ? `${id}-menu` : void 0,
|
|
872
|
-
testid: testid ? `${testid}-menu` : void 0,
|
|
873
|
-
positionTo: inputContainerRef,
|
|
874
|
-
show,
|
|
875
|
-
setShow,
|
|
876
|
-
topOffset: props.caption ? -16 : null,
|
|
877
|
-
autoFocusOff: true,
|
|
878
|
-
menuName: searchMenuName
|
|
879
|
-
}) : children
|
|
880
|
-
] });
|
|
881
|
-
};
|
|
882
|
-
Search.displayName = "Search";
|
|
883
|
-
|
|
884
|
-
// src/components/Menu.tsx
|
|
885
|
-
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
886
|
-
var import_react9 = require("react");
|
|
887
|
-
var import_react_dom = require("react-dom");
|
|
888
|
-
|
|
889
|
-
// src/components/useMenuSystem.tsx
|
|
890
|
-
var import_react8 = require("react");
|
|
891
|
-
|
|
892
|
-
// src/hooks/useKeydown.ts
|
|
893
|
-
var import_react4 = require("react");
|
|
894
|
-
|
|
895
|
-
// src/hooks/useInfiniteScroll.tsx
|
|
896
|
-
var import_react5 = require("react");
|
|
897
|
-
function useInfiniteScroll({
|
|
898
|
-
containerRef,
|
|
899
|
-
onLoadMore,
|
|
900
|
-
isLoading,
|
|
901
|
-
offset = 50,
|
|
902
|
-
enabled = true
|
|
903
|
-
// ✅ Add this
|
|
904
|
-
}) {
|
|
905
|
-
(0, import_react5.useEffect)(() => {
|
|
906
|
-
if (!enabled) return;
|
|
907
|
-
const handleScroll = () => {
|
|
908
|
-
const el2 = containerRef.current;
|
|
909
|
-
if (!el2 || isLoading) return;
|
|
910
|
-
const { scrollTop, scrollHeight, clientHeight } = el2;
|
|
911
|
-
const isNearBottom = scrollTop + clientHeight >= scrollHeight - offset;
|
|
912
|
-
if (isNearBottom) {
|
|
913
|
-
onLoadMore();
|
|
914
|
-
}
|
|
915
|
-
};
|
|
916
|
-
const el = containerRef.current;
|
|
917
|
-
if (el) el.addEventListener("scroll", handleScroll);
|
|
918
|
-
return () => {
|
|
919
|
-
if (el) el.removeEventListener("scroll", handleScroll);
|
|
920
|
-
};
|
|
921
|
-
}, [containerRef, onLoadMore, isLoading, offset, enabled]);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// src/hooks/useMatchesMedia.ts
|
|
925
|
-
var import_react6 = require("react");
|
|
926
|
-
var useMatchesMedia = (query) => {
|
|
927
|
-
const [matches, setMatches] = (0, import_react6.useState)();
|
|
928
|
-
(0, import_react6.useLayoutEffect)(() => {
|
|
929
|
-
const mediaQueryList = window.matchMedia(query);
|
|
930
|
-
const listener = () => setMatches(mediaQueryList.matches);
|
|
931
|
-
listener();
|
|
932
|
-
mediaQueryList.addEventListener("change", listener);
|
|
933
|
-
return () => mediaQueryList.removeEventListener("change", listener);
|
|
934
|
-
}, [query]);
|
|
935
|
-
return matches;
|
|
936
|
-
};
|
|
937
|
-
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
938
|
-
|
|
939
481
|
// src/utils/mergeObjectArrays.ts
|
|
940
482
|
function mergeObjectArrays(arr1, arr2) {
|
|
941
483
|
const maxLength = Math.max(arr1.length, arr2.length);
|
|
@@ -965,65 +507,251 @@ function findDocumentRoot(element) {
|
|
|
965
507
|
currentElement = currentElement.parentNode;
|
|
966
508
|
}
|
|
967
509
|
}
|
|
968
|
-
return window.document.body;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// src/hooks/useTableLayout.ts
|
|
972
|
-
var
|
|
973
|
-
function useTableLayout(initialColumns, key) {
|
|
974
|
-
const [columns, setColumns] = (0,
|
|
975
|
-
const [isReady, setIsReady] = (0,
|
|
976
|
-
const [layoutSignal, setLayoutSignal] = (0,
|
|
977
|
-
(0,
|
|
978
|
-
if (!key) return setIsReady(true);
|
|
979
|
-
const savedLayout = localStorage.getItem(`${key}-tableLayout`);
|
|
980
|
-
if (savedLayout) {
|
|
981
|
-
setColumns(
|
|
982
|
-
mergeObjectArrays(
|
|
983
|
-
initialColumns,
|
|
984
|
-
JSON.parse(savedLayout)
|
|
985
|
-
)
|
|
986
|
-
);
|
|
510
|
+
return window.document.body;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/hooks/useTableLayout.ts
|
|
514
|
+
var import_react5 = require("react");
|
|
515
|
+
function useTableLayout(initialColumns, key) {
|
|
516
|
+
const [columns, setColumns] = (0, import_react5.useState)(initialColumns);
|
|
517
|
+
const [isReady, setIsReady] = (0, import_react5.useState)(false);
|
|
518
|
+
const [layoutSignal, setLayoutSignal] = (0, import_react5.useState)(0);
|
|
519
|
+
(0, import_react5.useEffect)(() => {
|
|
520
|
+
if (!key) return setIsReady(true);
|
|
521
|
+
const savedLayout = localStorage.getItem(`${key}-tableLayout`);
|
|
522
|
+
if (savedLayout) {
|
|
523
|
+
setColumns(
|
|
524
|
+
mergeObjectArrays(
|
|
525
|
+
initialColumns,
|
|
526
|
+
JSON.parse(savedLayout)
|
|
527
|
+
)
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
if (!savedLayout) handleSaveLayout(initialColumns, true);
|
|
531
|
+
setLayoutSignal((prev) => prev + 1);
|
|
532
|
+
setIsReady(true);
|
|
533
|
+
}, []);
|
|
534
|
+
const handleSaveLayout = (0, import_react5.useCallback)(
|
|
535
|
+
(setter, _internal) => {
|
|
536
|
+
if (!isReady && !_internal) return null;
|
|
537
|
+
const newColumns = typeof setter === "function" ? setter(columns) : setter;
|
|
538
|
+
if (JSON.stringify(newColumns) === JSON.stringify(columns) && !_internal)
|
|
539
|
+
return null;
|
|
540
|
+
if (key) {
|
|
541
|
+
localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
|
|
542
|
+
}
|
|
543
|
+
setColumns(newColumns);
|
|
544
|
+
setLayoutSignal((prev) => prev + 1);
|
|
545
|
+
return newColumns;
|
|
546
|
+
},
|
|
547
|
+
[columns, isReady, key]
|
|
548
|
+
);
|
|
549
|
+
return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/components/MenuOption.tsx
|
|
553
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
554
|
+
var MenuOption = ({
|
|
555
|
+
id,
|
|
556
|
+
testid,
|
|
557
|
+
children,
|
|
558
|
+
disabled = false,
|
|
559
|
+
variant = "normal",
|
|
560
|
+
value,
|
|
561
|
+
before,
|
|
562
|
+
after,
|
|
563
|
+
subMenu,
|
|
564
|
+
onClick,
|
|
565
|
+
selected,
|
|
566
|
+
ref,
|
|
567
|
+
onSubMenuHover,
|
|
568
|
+
onSubMenuLeave,
|
|
569
|
+
onSubMenuEnter,
|
|
570
|
+
toggleMenu,
|
|
571
|
+
subMenuLevel = 1,
|
|
572
|
+
currentSubMenuLevel,
|
|
573
|
+
closeSubMenuLevel,
|
|
574
|
+
activeMenu,
|
|
575
|
+
mobilePositionTo,
|
|
576
|
+
highlightMatchingText = false,
|
|
577
|
+
menuValue,
|
|
578
|
+
onMouseMove
|
|
579
|
+
}) => {
|
|
580
|
+
const uniqueId = (0, import_react6.useId)();
|
|
581
|
+
const internalRef = (0, import_react6.useRef)(null);
|
|
582
|
+
const actualRef = ref || internalRef;
|
|
583
|
+
const menuId = (0, import_react6.useRef)(`menu-${uniqueId}`);
|
|
584
|
+
const isMobile = useMatchesMobile();
|
|
585
|
+
const handleMouseEnter = () => {
|
|
586
|
+
if (subMenu && onSubMenuHover && !disabled) {
|
|
587
|
+
onSubMenuHover(menuId.current, subMenuLevel);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
const handleMouseLeave = () => {
|
|
591
|
+
if (subMenu && onSubMenuLeave && !disabled) {
|
|
592
|
+
onSubMenuLeave(subMenuLevel);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const handleMouseMove = () => {
|
|
596
|
+
if (subMenu && onMouseMove && !disabled) {
|
|
597
|
+
onMouseMove();
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const handleSubMenuEnter = () => {
|
|
601
|
+
if (onSubMenuEnter) {
|
|
602
|
+
onSubMenuEnter();
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
const additionalAttributes = {
|
|
606
|
+
"data-selected": selected || null
|
|
607
|
+
};
|
|
608
|
+
const svgStyles = (0, import_clsx5.default)(
|
|
609
|
+
"[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
|
|
610
|
+
);
|
|
611
|
+
const textLabelStyles = (0, import_clsx5.default)("w-full whitespace-nowrap !leading-6");
|
|
612
|
+
const normalStyles = variant === "normal" && !disabled && (0, import_clsx5.default)(
|
|
613
|
+
"bg-transparent text-text-primary-normal",
|
|
614
|
+
"hover:bg-background-action-secondary-hover",
|
|
615
|
+
"focus:bg-background-action-secondary-hover",
|
|
616
|
+
"data-selected:bg-background-action-secondary-hover",
|
|
617
|
+
"active:bg-background-action-secondary-active"
|
|
618
|
+
);
|
|
619
|
+
const normalDisabledStyles = variant === "normal" && disabled && (0, import_clsx5.default)("text-text-primary-disabled");
|
|
620
|
+
const actionStyles = variant === "action" && !disabled && (0, import_clsx5.default)(
|
|
621
|
+
"text-action-400 bg-transparent",
|
|
622
|
+
"hover:bg-background-action-secondary-hover hover:text-text-action-hover",
|
|
623
|
+
"focus:bg-background-action-secondary-hover focus:text-text-action-hover",
|
|
624
|
+
"data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
|
|
625
|
+
"active:bg-background-action-secondary-active active:text-text-action-active"
|
|
626
|
+
);
|
|
627
|
+
const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx5.default)("text-text-action-disabled");
|
|
628
|
+
const disabledStyles = disabled && (0, import_clsx5.default)("bg-transparent cursor-default pointer-events-none");
|
|
629
|
+
const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
|
|
630
|
+
const renderChildren = typeof children === "object" ? children : variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { padded: true, className: textLabelStyles, children: processChildren }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: processChildren });
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
633
|
+
"div",
|
|
634
|
+
__spreadProps(__spreadValues({
|
|
635
|
+
id,
|
|
636
|
+
"data-testid": testid,
|
|
637
|
+
ref: actualRef,
|
|
638
|
+
className: (0, import_clsx5.default)(
|
|
639
|
+
"flex items-center cursor-pointer w-full text-left relative outline-none",
|
|
640
|
+
svgStyles,
|
|
641
|
+
componentGap,
|
|
642
|
+
componentPadding,
|
|
643
|
+
baseTransition,
|
|
644
|
+
normalStyles,
|
|
645
|
+
normalDisabledStyles,
|
|
646
|
+
actionStyles,
|
|
647
|
+
actionDisabledStyles,
|
|
648
|
+
disabledStyles
|
|
649
|
+
),
|
|
650
|
+
"data-value": value || children,
|
|
651
|
+
onClick: () => {
|
|
652
|
+
onClick == null ? void 0 : onClick(menuId.current, value || children);
|
|
653
|
+
if (subMenu) {
|
|
654
|
+
toggleMenu(menuId.current, subMenuLevel);
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
onMouseEnter: handleMouseEnter,
|
|
658
|
+
onMouseLeave: handleMouseLeave,
|
|
659
|
+
onMouseMove: handleMouseMove
|
|
660
|
+
}, additionalAttributes), {
|
|
661
|
+
tabIndex: -1,
|
|
662
|
+
role: "menuitem",
|
|
663
|
+
"aria-haspopup": subMenu ? "menu" : void 0,
|
|
664
|
+
children: [
|
|
665
|
+
before && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
|
|
666
|
+
renderChildren,
|
|
667
|
+
renderAfterProp()
|
|
668
|
+
]
|
|
669
|
+
})
|
|
670
|
+
),
|
|
671
|
+
subMenu && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
672
|
+
"div",
|
|
673
|
+
{
|
|
674
|
+
onMouseEnter: handleSubMenuEnter,
|
|
675
|
+
onMouseLeave: handleMouseLeave,
|
|
676
|
+
"data-submenu-parent": menuId.current,
|
|
677
|
+
"data-menu-level": subMenuLevel + 1,
|
|
678
|
+
children: subMenu({
|
|
679
|
+
menuId: menuId.current,
|
|
680
|
+
positionTo: actualRef,
|
|
681
|
+
mobilePositionTo,
|
|
682
|
+
position: "right",
|
|
683
|
+
subMenuLevel,
|
|
684
|
+
mobileBackMenuOption,
|
|
685
|
+
mobileHide: isMobile && activeMenu !== menuId.current
|
|
686
|
+
})
|
|
687
|
+
}
|
|
688
|
+
)
|
|
689
|
+
] });
|
|
690
|
+
function renderAfterProp() {
|
|
691
|
+
if (after) {
|
|
692
|
+
return after;
|
|
693
|
+
}
|
|
694
|
+
if (subMenu && after !== null) {
|
|
695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chevron_right" });
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function mobileBackMenuOption() {
|
|
699
|
+
if (!isMobile) {
|
|
700
|
+
return;
|
|
987
701
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
|
|
702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
703
|
+
MenuOption,
|
|
704
|
+
{
|
|
705
|
+
id: id ? `${id}-back` : void 0,
|
|
706
|
+
testid: testid ? `${testid}-back` : void 0,
|
|
707
|
+
onClick: () => {
|
|
708
|
+
closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
|
|
709
|
+
},
|
|
710
|
+
variant: "action",
|
|
711
|
+
before: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chevron_left" }),
|
|
712
|
+
children: "Back"
|
|
1000
713
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
MenuOption.displayName = "MenuOption";
|
|
718
|
+
function highlightMatch(text, searchValue) {
|
|
719
|
+
if (!searchValue || !searchValue.trim()) {
|
|
720
|
+
return text;
|
|
721
|
+
}
|
|
722
|
+
const regex = new RegExp(
|
|
723
|
+
`(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
724
|
+
"gi"
|
|
725
|
+
);
|
|
726
|
+
const parts = text.split(regex);
|
|
727
|
+
return parts.map(
|
|
728
|
+
(part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "font-bold", children: part }, index) : part
|
|
1006
729
|
);
|
|
1007
|
-
return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
|
|
1008
730
|
}
|
|
1009
731
|
|
|
732
|
+
// src/components/Menu.tsx
|
|
733
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
734
|
+
var import_react8 = require("react");
|
|
735
|
+
var import_react_dom = require("react-dom");
|
|
736
|
+
|
|
1010
737
|
// src/components/useMenuSystem.tsx
|
|
738
|
+
var import_react7 = require("react");
|
|
1011
739
|
function useSubMenuSystem(mobilePositionTo) {
|
|
1012
|
-
const [activeMenus, setActiveMenus] = (0,
|
|
740
|
+
const [activeMenus, setActiveMenus] = (0, import_react7.useState)(
|
|
1013
741
|
{}
|
|
1014
742
|
);
|
|
1015
|
-
const [activeMenu, setActiveMenu] = (0,
|
|
1016
|
-
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0,
|
|
743
|
+
const [activeMenu, setActiveMenu] = (0, import_react7.useState)("");
|
|
744
|
+
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react7.useState)(
|
|
1017
745
|
null
|
|
1018
746
|
);
|
|
1019
|
-
const menuRootRef = (0,
|
|
1020
|
-
const subMenuRefs = (0,
|
|
1021
|
-
const hoverTimeoutRef = (0,
|
|
1022
|
-
const closeTimeoutRef = (0,
|
|
1023
|
-
const mouseStopTimeoutRef = (0,
|
|
1024
|
-
const isMouseMovingRef = (0,
|
|
1025
|
-
const pendingOpenActionRef = (0,
|
|
1026
|
-
const pendingCloseActionRef = (0,
|
|
747
|
+
const menuRootRef = (0, import_react7.useRef)(null);
|
|
748
|
+
const subMenuRefs = (0, import_react7.useRef)({});
|
|
749
|
+
const hoverTimeoutRef = (0, import_react7.useRef)(null);
|
|
750
|
+
const closeTimeoutRef = (0, import_react7.useRef)(null);
|
|
751
|
+
const mouseStopTimeoutRef = (0, import_react7.useRef)(null);
|
|
752
|
+
const isMouseMovingRef = (0, import_react7.useRef)(false);
|
|
753
|
+
const pendingOpenActionRef = (0, import_react7.useRef)(null);
|
|
754
|
+
const pendingCloseActionRef = (0, import_react7.useRef)(null);
|
|
1027
755
|
const isMobile = useMatchesMobile();
|
|
1028
756
|
const toggleMenu = (menuId, level) => {
|
|
1029
757
|
if (closeTimeoutRef.current) {
|
|
@@ -1063,7 +791,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1063
791
|
return newActiveMenus;
|
|
1064
792
|
});
|
|
1065
793
|
};
|
|
1066
|
-
const executePendingActions = (0,
|
|
794
|
+
const executePendingActions = (0, import_react7.useCallback)(() => {
|
|
1067
795
|
if (pendingCloseActionRef.current) {
|
|
1068
796
|
pendingCloseActionRef.current();
|
|
1069
797
|
pendingCloseActionRef.current = null;
|
|
@@ -1152,7 +880,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1152
880
|
const isMenuActive = (menuId, level) => {
|
|
1153
881
|
return activeMenus[level] === menuId;
|
|
1154
882
|
};
|
|
1155
|
-
(0,
|
|
883
|
+
(0, import_react7.useEffect)(() => {
|
|
1156
884
|
const handleClickOutside = (event) => {
|
|
1157
885
|
var _a;
|
|
1158
886
|
if (Object.keys(activeMenus).length === 0) return;
|
|
@@ -1171,7 +899,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1171
899
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1172
900
|
};
|
|
1173
901
|
}, [activeMenus]);
|
|
1174
|
-
(0,
|
|
902
|
+
(0, import_react7.useEffect)(() => {
|
|
1175
903
|
return () => {
|
|
1176
904
|
if (hoverTimeoutRef.current) {
|
|
1177
905
|
clearTimeout(hoverTimeoutRef.current);
|
|
@@ -1249,13 +977,13 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1249
977
|
};
|
|
1250
978
|
}
|
|
1251
979
|
function useMenuPosition(elementRef, position = "bottom", options) {
|
|
1252
|
-
const [menuPosition, setMenuPosition] = (0,
|
|
980
|
+
const [menuPosition, setMenuPosition] = (0, import_react7.useState)({
|
|
1253
981
|
top: 0,
|
|
1254
982
|
left: 0,
|
|
1255
983
|
minWidth: 0
|
|
1256
984
|
});
|
|
1257
985
|
const isMobile = options == null ? void 0 : options.isMobile;
|
|
1258
|
-
const updatePosition = (0,
|
|
986
|
+
const updatePosition = (0, import_react7.useCallback)(() => {
|
|
1259
987
|
var _a, _b, _c;
|
|
1260
988
|
if (!(elementRef == null ? void 0 : elementRef.current)) return;
|
|
1261
989
|
const triggerRect = elementRef.current.getBoundingClientRect();
|
|
@@ -1303,7 +1031,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1303
1031
|
minWidth: triggerRect.width
|
|
1304
1032
|
});
|
|
1305
1033
|
}, [elementRef, position, options == null ? void 0 : options.menuRef, options == null ? void 0 : options.topOffset, isMobile]);
|
|
1306
|
-
(0,
|
|
1034
|
+
(0, import_react7.useEffect)(() => {
|
|
1307
1035
|
if (!(options == null ? void 0 : options.isOpen) || !(options == null ? void 0 : options.setIsOpen)) return;
|
|
1308
1036
|
const handleClickOutside = (event) => {
|
|
1309
1037
|
var _a, _b, _c, _d, _e;
|
|
@@ -1329,7 +1057,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1329
1057
|
options == null ? void 0 : options.menuRef,
|
|
1330
1058
|
options == null ? void 0 : options.additionalRefs
|
|
1331
1059
|
]);
|
|
1332
|
-
(0,
|
|
1060
|
+
(0, import_react7.useEffect)(() => {
|
|
1333
1061
|
updatePosition();
|
|
1334
1062
|
const resizeObserver = new ResizeObserver(updatePosition);
|
|
1335
1063
|
if (elementRef == null ? void 0 : elementRef.current) {
|
|
@@ -1388,9 +1116,9 @@ var Menu = (_a) => {
|
|
|
1388
1116
|
"menuName",
|
|
1389
1117
|
"calculateMinMaxHeight"
|
|
1390
1118
|
]);
|
|
1391
|
-
const internalRef = (0,
|
|
1119
|
+
const internalRef = (0, import_react8.useRef)(null);
|
|
1392
1120
|
const actualRef = ref || internalRef;
|
|
1393
|
-
const [maxHeight, setMaxHeight] = (0,
|
|
1121
|
+
const [maxHeight, setMaxHeight] = (0, import_react8.useState)("180px");
|
|
1394
1122
|
const isMobile = useMatchesMobile();
|
|
1395
1123
|
const { menuPosition, updatePosition } = useMenuPosition(
|
|
1396
1124
|
isMobile && mobilePositionTo ? mobilePositionTo : positionTo,
|
|
@@ -1403,7 +1131,7 @@ var Menu = (_a) => {
|
|
|
1403
1131
|
isMobile: !!(isMobile && mobilePositionTo)
|
|
1404
1132
|
}
|
|
1405
1133
|
);
|
|
1406
|
-
(0,
|
|
1134
|
+
(0, import_react8.useEffect)(() => {
|
|
1407
1135
|
if (calculateMinMaxHeight) {
|
|
1408
1136
|
return;
|
|
1409
1137
|
}
|
|
@@ -1427,7 +1155,7 @@ var Menu = (_a) => {
|
|
|
1427
1155
|
cancelAnimationFrame(raf);
|
|
1428
1156
|
};
|
|
1429
1157
|
}, [actualRef.current, customMaxHeight, calculateMinMaxHeight]);
|
|
1430
|
-
(0,
|
|
1158
|
+
(0, import_react8.useEffect)(() => {
|
|
1431
1159
|
if (!calculateMinMaxHeight) {
|
|
1432
1160
|
return;
|
|
1433
1161
|
}
|
|
@@ -1438,14 +1166,14 @@ var Menu = (_a) => {
|
|
|
1438
1166
|
setMaxHeight(`${calculatedMaxHeight}px`);
|
|
1439
1167
|
}
|
|
1440
1168
|
}, [actualRef.current, positionTo == null ? void 0 : positionTo.current, calculateMinMaxHeight]);
|
|
1441
|
-
(0,
|
|
1169
|
+
(0, import_react8.useEffect)(() => {
|
|
1442
1170
|
if (!show) {
|
|
1443
1171
|
return;
|
|
1444
1172
|
}
|
|
1445
1173
|
initializeMenuFocus();
|
|
1446
1174
|
updatePosition();
|
|
1447
1175
|
}, [show, updatePosition]);
|
|
1448
|
-
(0,
|
|
1176
|
+
(0, import_react8.useEffect)(() => {
|
|
1449
1177
|
if (!show || !setShow) {
|
|
1450
1178
|
return;
|
|
1451
1179
|
}
|
|
@@ -1469,7 +1197,7 @@ var Menu = (_a) => {
|
|
|
1469
1197
|
id,
|
|
1470
1198
|
"data-testid": testid,
|
|
1471
1199
|
ref: setRefs,
|
|
1472
|
-
className: (0,
|
|
1200
|
+
className: (0, import_clsx6.default)(
|
|
1473
1201
|
"shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
|
|
1474
1202
|
"fixed",
|
|
1475
1203
|
"z-50",
|
|
@@ -1591,249 +1319,517 @@ var Menu = (_a) => {
|
|
|
1591
1319
|
ref.current = node;
|
|
1592
1320
|
}
|
|
1593
1321
|
}
|
|
1594
|
-
}
|
|
1595
|
-
function stopPropagation(e) {
|
|
1596
|
-
e.stopPropagation();
|
|
1597
|
-
}
|
|
1322
|
+
}
|
|
1323
|
+
function stopPropagation(e) {
|
|
1324
|
+
e.stopPropagation();
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
Menu.displayName = "Menu";
|
|
1328
|
+
|
|
1329
|
+
// src/components/Search.tsx
|
|
1330
|
+
var import_react10 = require("react");
|
|
1331
|
+
|
|
1332
|
+
// src/components/Input.tsx
|
|
1333
|
+
var import_react9 = require("react");
|
|
1334
|
+
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
1335
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1336
|
+
var InputBase = (_a) => {
|
|
1337
|
+
var _b = _a, {
|
|
1338
|
+
id,
|
|
1339
|
+
testid,
|
|
1340
|
+
before,
|
|
1341
|
+
after,
|
|
1342
|
+
type,
|
|
1343
|
+
label,
|
|
1344
|
+
error,
|
|
1345
|
+
className,
|
|
1346
|
+
align = "left",
|
|
1347
|
+
caption,
|
|
1348
|
+
required,
|
|
1349
|
+
selectOnFocus,
|
|
1350
|
+
removeRoundness,
|
|
1351
|
+
inputContainerRef,
|
|
1352
|
+
removeBorder,
|
|
1353
|
+
wrapperClassName,
|
|
1354
|
+
focus,
|
|
1355
|
+
fullWidth = true
|
|
1356
|
+
} = _b, props = __objRest(_b, [
|
|
1357
|
+
"id",
|
|
1358
|
+
"testid",
|
|
1359
|
+
"before",
|
|
1360
|
+
"after",
|
|
1361
|
+
"type",
|
|
1362
|
+
"label",
|
|
1363
|
+
"error",
|
|
1364
|
+
"className",
|
|
1365
|
+
"align",
|
|
1366
|
+
"caption",
|
|
1367
|
+
"required",
|
|
1368
|
+
"selectOnFocus",
|
|
1369
|
+
"removeRoundness",
|
|
1370
|
+
"inputContainerRef",
|
|
1371
|
+
"removeBorder",
|
|
1372
|
+
"wrapperClassName",
|
|
1373
|
+
"focus",
|
|
1374
|
+
"fullWidth"
|
|
1375
|
+
]);
|
|
1376
|
+
const attributes = {
|
|
1377
|
+
"data-error": error && !focus || null,
|
|
1378
|
+
"data-focus": focus || null
|
|
1379
|
+
};
|
|
1380
|
+
const inputRef = (0, import_react9.useRef)(null);
|
|
1381
|
+
const inputId = id ? `${id}-input` : void 0;
|
|
1382
|
+
(0, import_react9.useEffect)(() => {
|
|
1383
|
+
var _a2;
|
|
1384
|
+
const input = inputRef.current;
|
|
1385
|
+
const focusHandler = () => {
|
|
1386
|
+
input == null ? void 0 : input.select();
|
|
1387
|
+
};
|
|
1388
|
+
if (selectOnFocus) {
|
|
1389
|
+
(_a2 = inputRef.current) == null ? void 0 : _a2.addEventListener("focus", focusHandler);
|
|
1390
|
+
return () => {
|
|
1391
|
+
input == null ? void 0 : input.removeEventListener("focus", focusHandler);
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
}, [selectOnFocus]);
|
|
1395
|
+
const inputBaseClass = (0, import_clsx7.default)(
|
|
1396
|
+
fullWidth ? "w-full" : "w-fit",
|
|
1397
|
+
"flex flex-row items-center",
|
|
1398
|
+
"bg-background-action-secondary-normal caret-icon-on-action-secondary-normal",
|
|
1399
|
+
componentGap,
|
|
1400
|
+
baseTransition,
|
|
1401
|
+
"outline-transparent outline-2 -outline-offset-2",
|
|
1402
|
+
componentPaddingMinusBorder,
|
|
1403
|
+
!removeRoundness && "rounded-base",
|
|
1404
|
+
!removeBorder && "border border-border-primary-normal",
|
|
1405
|
+
"relative"
|
|
1406
|
+
);
|
|
1407
|
+
const inputFocusClass = (0, import_clsx7.default)(
|
|
1408
|
+
"has-[[data-focus]]:border-transparent has-[[data-focus]]:outline-border-primary-focus focus-within:border-transparent focus-within:outline-border-primary-focus"
|
|
1409
|
+
);
|
|
1410
|
+
const inputDisabledClass = (0, import_clsx7.default)(
|
|
1411
|
+
"has-disabled:bg-background-action-secondary-disabled"
|
|
1412
|
+
);
|
|
1413
|
+
const inputReadOnlyClass = (0, import_clsx7.default)(
|
|
1414
|
+
"has-[input:not(:disabled):read-only]:outline-none has-[input:not(:disabled):read-only]:bg-transparent has-[input:not(:disabled):read-only]:border-transparent has-[input:not(:disabled):read-only]:pl-0"
|
|
1415
|
+
);
|
|
1416
|
+
const inputInvalidClass = (0, import_clsx7.default)(
|
|
1417
|
+
"has-[[data-error]]:border-transparent has-[[data-error]]:not-focus-within:outline-border-primary-error has-[[data-error]]:not-focus-within:outline-1"
|
|
1418
|
+
);
|
|
1419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1420
|
+
"label",
|
|
1421
|
+
{
|
|
1422
|
+
id,
|
|
1423
|
+
"data-testid": testid,
|
|
1424
|
+
htmlFor: inputId,
|
|
1425
|
+
ref: inputContainerRef,
|
|
1426
|
+
className: (0, import_clsx7.default)(
|
|
1427
|
+
"w-full flex flex-col",
|
|
1428
|
+
"block",
|
|
1429
|
+
"text-text-primary-normal has-disabled:text-text-primary-disabled",
|
|
1430
|
+
componentGap
|
|
1431
|
+
),
|
|
1432
|
+
style: __spreadValues({}, props.style),
|
|
1433
|
+
children: [
|
|
1434
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_clsx7.default)("flex items-center", componentGap), children: [
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1436
|
+
Label,
|
|
1437
|
+
{
|
|
1438
|
+
id: id ? `${id}-label` : void 0,
|
|
1439
|
+
className: (0, import_clsx7.default)(
|
|
1440
|
+
props.disabled || props.readOnly ? "cursor-default" : "cursor-pointer"
|
|
1441
|
+
),
|
|
1442
|
+
children: label
|
|
1443
|
+
}
|
|
1444
|
+
),
|
|
1445
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1446
|
+
"span",
|
|
1447
|
+
{
|
|
1448
|
+
className: (0, import_clsx7.default)(typography.label, "text-text-critical-normal"),
|
|
1449
|
+
children: "*"
|
|
1450
|
+
}
|
|
1451
|
+
)
|
|
1452
|
+
] }),
|
|
1453
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1454
|
+
"div",
|
|
1455
|
+
{
|
|
1456
|
+
className: (0, import_clsx7.default)(
|
|
1457
|
+
inputBaseClass,
|
|
1458
|
+
!props.disabled && inputInvalidClass,
|
|
1459
|
+
inputFocusClass,
|
|
1460
|
+
inputDisabledClass,
|
|
1461
|
+
inputReadOnlyClass,
|
|
1462
|
+
wrapperClassName
|
|
1463
|
+
),
|
|
1464
|
+
children: [
|
|
1465
|
+
before,
|
|
1466
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1467
|
+
"input",
|
|
1468
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
1469
|
+
ref: (el) => {
|
|
1470
|
+
inputRef.current = el;
|
|
1471
|
+
},
|
|
1472
|
+
type,
|
|
1473
|
+
required
|
|
1474
|
+
}, props), attributes), {
|
|
1475
|
+
id: inputId,
|
|
1476
|
+
"data-testid": testid ? `${testid}-input` : void 0,
|
|
1477
|
+
className: (0, import_clsx7.default)(
|
|
1478
|
+
"flex-1 outline-none w-full max-w-full min-h-6 min-w-0",
|
|
1479
|
+
"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
|
|
1480
|
+
"placeholder:text-text-secondary-normal disabled:text-text-secondary-disabled",
|
|
1481
|
+
align === "right" && "text-right",
|
|
1482
|
+
align === "center" && "text-center",
|
|
1483
|
+
componentPaddingXUsingComponentGap,
|
|
1484
|
+
typography.paragraph,
|
|
1485
|
+
className,
|
|
1486
|
+
props.readOnly && !props.disabled && "!px-0"
|
|
1487
|
+
)
|
|
1488
|
+
})
|
|
1489
|
+
),
|
|
1490
|
+
after
|
|
1491
|
+
]
|
|
1492
|
+
}
|
|
1493
|
+
),
|
|
1494
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: id ? `${id}-caption` : void 0, "data-testid": testid ? `${testid}-caption` : void 0, children: caption })
|
|
1495
|
+
]
|
|
1496
|
+
}
|
|
1497
|
+
);
|
|
1598
1498
|
};
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
// src/components/MenuOption.tsx
|
|
1602
|
-
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
1603
|
-
var import_react10 = require("react");
|
|
1604
|
-
|
|
1605
|
-
// src/components/Paragraph.tsx
|
|
1606
|
-
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
1607
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1608
|
-
var Paragraph = (_a) => {
|
|
1499
|
+
var Input = (_a) => {
|
|
1609
1500
|
var _b = _a, {
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1501
|
+
variant = "default",
|
|
1502
|
+
decimals,
|
|
1503
|
+
uom,
|
|
1504
|
+
removeSearchIcon,
|
|
1505
|
+
value: propValue,
|
|
1506
|
+
onChange,
|
|
1507
|
+
onBlur,
|
|
1508
|
+
onClear,
|
|
1618
1509
|
id,
|
|
1619
1510
|
testid
|
|
1620
1511
|
} = _b, props = __objRest(_b, [
|
|
1621
|
-
"
|
|
1622
|
-
"
|
|
1623
|
-
"
|
|
1624
|
-
"
|
|
1625
|
-
"
|
|
1626
|
-
"
|
|
1627
|
-
"
|
|
1628
|
-
"
|
|
1512
|
+
"variant",
|
|
1513
|
+
"decimals",
|
|
1514
|
+
"uom",
|
|
1515
|
+
"removeSearchIcon",
|
|
1516
|
+
"value",
|
|
1517
|
+
"onChange",
|
|
1518
|
+
"onBlur",
|
|
1519
|
+
"onClear",
|
|
1629
1520
|
"id",
|
|
1630
1521
|
"testid"
|
|
1631
1522
|
]);
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
menuValue,
|
|
1684
|
-
onMouseMove
|
|
1685
|
-
}) => {
|
|
1686
|
-
const uniqueId = (0, import_react10.useId)();
|
|
1687
|
-
const internalRef = (0, import_react10.useRef)(null);
|
|
1688
|
-
const actualRef = ref || internalRef;
|
|
1689
|
-
const menuId = (0, import_react10.useRef)(`menu-${uniqueId}`);
|
|
1690
|
-
const isMobile = useMatchesMobile();
|
|
1691
|
-
const handleMouseEnter = () => {
|
|
1692
|
-
if (subMenu && onSubMenuHover && !disabled) {
|
|
1693
|
-
onSubMenuHover(menuId.current, subMenuLevel);
|
|
1523
|
+
const [internalValue, setInternalValue] = (0, import_react9.useState)("");
|
|
1524
|
+
const [displayValue, setDisplayValue] = (0, import_react9.useState)("");
|
|
1525
|
+
(0, import_react9.useEffect)(() => {
|
|
1526
|
+
var _a2;
|
|
1527
|
+
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
1528
|
+
setInternalValue(stringValue);
|
|
1529
|
+
setDisplayValue(stringValue);
|
|
1530
|
+
}, [propValue]);
|
|
1531
|
+
(0, import_react9.useEffect)(() => {
|
|
1532
|
+
var _a2;
|
|
1533
|
+
if (variant !== "currency") {
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
const stringValue = (_a2 = propValue == null ? void 0 : propValue.toString()) != null ? _a2 : "";
|
|
1537
|
+
if (!stringValue) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
const formatted = formatDecimalValue(stringValue, decimals != null ? decimals : 2);
|
|
1541
|
+
setInternalValue(formatted);
|
|
1542
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
1543
|
+
}, []);
|
|
1544
|
+
const getInputProps = () => {
|
|
1545
|
+
var _a2;
|
|
1546
|
+
const baseProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
1547
|
+
id
|
|
1548
|
+
}), getDecimalPlaceholder(decimals)), {
|
|
1549
|
+
value: propValue
|
|
1550
|
+
});
|
|
1551
|
+
switch (variant) {
|
|
1552
|
+
case "search":
|
|
1553
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
1554
|
+
placeholder: (_a2 = props.placeholder) != null ? _a2 : "Search",
|
|
1555
|
+
className: "!mr-6",
|
|
1556
|
+
value: displayValue
|
|
1557
|
+
});
|
|
1558
|
+
case "finder":
|
|
1559
|
+
return baseProps;
|
|
1560
|
+
case "currency":
|
|
1561
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
1562
|
+
align: "right",
|
|
1563
|
+
type: "text",
|
|
1564
|
+
value: displayValue
|
|
1565
|
+
});
|
|
1566
|
+
case "percentage":
|
|
1567
|
+
case "uom":
|
|
1568
|
+
return __spreadProps(__spreadValues({}, baseProps), {
|
|
1569
|
+
type: "number",
|
|
1570
|
+
align: "right"
|
|
1571
|
+
});
|
|
1572
|
+
default:
|
|
1573
|
+
return baseProps;
|
|
1694
1574
|
}
|
|
1695
1575
|
};
|
|
1696
|
-
const
|
|
1697
|
-
if (
|
|
1698
|
-
|
|
1576
|
+
const getBeforeElement = () => {
|
|
1577
|
+
if (props.before) return props.before;
|
|
1578
|
+
switch (variant) {
|
|
1579
|
+
case "search":
|
|
1580
|
+
return !removeSearchIcon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" }) }) : null;
|
|
1581
|
+
case "currency":
|
|
1582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "attach_money" }) });
|
|
1583
|
+
default:
|
|
1584
|
+
return null;
|
|
1699
1585
|
}
|
|
1700
1586
|
};
|
|
1701
|
-
const
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1587
|
+
const getAfterElement = () => {
|
|
1588
|
+
if (props.after) return props.after;
|
|
1589
|
+
switch (variant) {
|
|
1590
|
+
case "search": {
|
|
1591
|
+
const hasValue = displayValue.length > 0;
|
|
1592
|
+
return hasValue && !props.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1593
|
+
Icon,
|
|
1594
|
+
{
|
|
1595
|
+
id: id ? `${id}-clear-button` : void 0,
|
|
1596
|
+
testid: testid ? `${testid}-clear-button` : void 0,
|
|
1597
|
+
name: "close",
|
|
1598
|
+
onClick: handleSearchReset,
|
|
1599
|
+
className: "cursor-pointer absolute right-2 bottom-2/4 translate-y-2/4"
|
|
1600
|
+
}
|
|
1601
|
+
) : null;
|
|
1602
|
+
}
|
|
1603
|
+
case "finder":
|
|
1604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "search" });
|
|
1605
|
+
case "uom":
|
|
1606
|
+
return uom ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-text-secondary-normal uppercase", children: uom.slice(0, 4) }) : null;
|
|
1607
|
+
case "percentage":
|
|
1608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-icon-primary-normal contents", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "percent" }) });
|
|
1609
|
+
default:
|
|
1610
|
+
return null;
|
|
1704
1611
|
}
|
|
1705
1612
|
};
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1708
|
-
|
|
1613
|
+
const handleSearchReset = () => {
|
|
1614
|
+
setInternalValue("");
|
|
1615
|
+
setDisplayValue("");
|
|
1616
|
+
if (onChange) {
|
|
1617
|
+
const syntheticEvent = {
|
|
1618
|
+
target: { value: "" }
|
|
1619
|
+
};
|
|
1620
|
+
if (typeof onChange === "function") {
|
|
1621
|
+
onChange(syntheticEvent);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
onClear == null ? void 0 : onClear();
|
|
1625
|
+
};
|
|
1626
|
+
const handleChange = (e) => {
|
|
1627
|
+
const rawValue = e.target.value;
|
|
1628
|
+
if (variant === "currency") {
|
|
1629
|
+
const raw = rawValue.replace(/,/g, "");
|
|
1630
|
+
if (raw === "") {
|
|
1631
|
+
setInternalValue("");
|
|
1632
|
+
setDisplayValue("");
|
|
1633
|
+
if (onChange) {
|
|
1634
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
1635
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: "" })
|
|
1636
|
+
});
|
|
1637
|
+
onChange(syntheticEvent);
|
|
1638
|
+
}
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
const regex = /^\d*\.?\d*$/;
|
|
1642
|
+
if (!regex.test(raw)) return;
|
|
1643
|
+
const parts = raw.split(".");
|
|
1644
|
+
const currentDecimals = decimals != null ? decimals : 2;
|
|
1645
|
+
if (parts.length === 2 && parts[1].length > currentDecimals) return;
|
|
1646
|
+
setInternalValue(raw);
|
|
1647
|
+
setDisplayValue(formatCurrencyDisplay(raw));
|
|
1648
|
+
const asNumber = Number(raw);
|
|
1649
|
+
if (!isNaN(asNumber) && onChange) {
|
|
1650
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
1651
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
1652
|
+
});
|
|
1653
|
+
onChange(syntheticEvent);
|
|
1654
|
+
}
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
setInternalValue(rawValue);
|
|
1658
|
+
setDisplayValue(rawValue);
|
|
1659
|
+
if (typeof onChange === "function") {
|
|
1660
|
+
onChange(e);
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
const handleBlur = (e) => {
|
|
1664
|
+
if (!internalValue) {
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
if (variant === "currency") {
|
|
1668
|
+
const formatted = formatDecimalValue(internalValue, decimals != null ? decimals : 2);
|
|
1669
|
+
setInternalValue(formatted);
|
|
1670
|
+
setDisplayValue(formatCurrencyDisplay(formatted));
|
|
1671
|
+
const asNumber = Number(formatted);
|
|
1672
|
+
if (!isNaN(asNumber) && onChange) {
|
|
1673
|
+
const syntheticEvent = __spreadProps(__spreadValues({}, e), {
|
|
1674
|
+
target: __spreadProps(__spreadValues({}, e.target), { value: asNumber.toString() })
|
|
1675
|
+
});
|
|
1676
|
+
onChange(syntheticEvent);
|
|
1677
|
+
}
|
|
1678
|
+
} else if (variant === "uom" || variant === "percentage") {
|
|
1679
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
1680
|
+
e.target.value = formattedValue;
|
|
1709
1681
|
}
|
|
1682
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
1710
1683
|
};
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
"focus:bg-background-action-secondary-hover",
|
|
1722
|
-
"data-selected:bg-background-action-secondary-hover",
|
|
1723
|
-
"active:bg-background-action-secondary-active"
|
|
1684
|
+
const inputProps = getInputProps();
|
|
1685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1686
|
+
InputBase,
|
|
1687
|
+
__spreadProps(__spreadValues({}, inputProps), {
|
|
1688
|
+
before: getBeforeElement(),
|
|
1689
|
+
after: getAfterElement(),
|
|
1690
|
+
onChange: handleChange,
|
|
1691
|
+
onBlur: handleBlur,
|
|
1692
|
+
testid
|
|
1693
|
+
})
|
|
1724
1694
|
);
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1695
|
+
};
|
|
1696
|
+
Input.displayName = "Input";
|
|
1697
|
+
var Finder = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "finder" }));
|
|
1698
|
+
var UOM = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "uom" }));
|
|
1699
|
+
var Currency = (props) => {
|
|
1700
|
+
var _a;
|
|
1701
|
+
const handleCurrencyChange = (e) => {
|
|
1702
|
+
var _a2;
|
|
1703
|
+
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, e);
|
|
1704
|
+
};
|
|
1705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1706
|
+
Input,
|
|
1707
|
+
__spreadProps(__spreadValues({}, props), {
|
|
1708
|
+
variant: "currency",
|
|
1709
|
+
decimals: (_a = props.decimals) != null ? _a : 2,
|
|
1710
|
+
onChange: handleCurrencyChange
|
|
1711
|
+
})
|
|
1732
1712
|
);
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1713
|
+
};
|
|
1714
|
+
var Percentage = (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Input, __spreadProps(__spreadValues({}, props), { variant: "percentage" }));
|
|
1715
|
+
Finder.displayName = "Finder";
|
|
1716
|
+
UOM.displayName = "UOM";
|
|
1717
|
+
Currency.displayName = "Currency";
|
|
1718
|
+
Percentage.displayName = "Percentage";
|
|
1719
|
+
|
|
1720
|
+
// src/components/Search.tsx
|
|
1721
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1722
|
+
var Search = (_a) => {
|
|
1723
|
+
var _b = _a, {
|
|
1724
|
+
id,
|
|
1725
|
+
testid,
|
|
1726
|
+
label,
|
|
1727
|
+
error,
|
|
1728
|
+
children,
|
|
1729
|
+
readOnly,
|
|
1730
|
+
renderMenu,
|
|
1731
|
+
onClick,
|
|
1732
|
+
wrapperClassName,
|
|
1733
|
+
removeRoundness
|
|
1734
|
+
} = _b, props = __objRest(_b, [
|
|
1735
|
+
"id",
|
|
1736
|
+
"testid",
|
|
1737
|
+
"label",
|
|
1738
|
+
"error",
|
|
1739
|
+
"children",
|
|
1740
|
+
"readOnly",
|
|
1741
|
+
"renderMenu",
|
|
1742
|
+
"onClick",
|
|
1743
|
+
"wrapperClassName",
|
|
1744
|
+
"removeRoundness"
|
|
1745
|
+
]);
|
|
1746
|
+
const inputRef = (0, import_react10.useRef)(null);
|
|
1747
|
+
const inputContainerRef = (0, import_react10.useRef)(null);
|
|
1748
|
+
const preventFocusOnInitialRender = (0, import_react10.useRef)(true);
|
|
1749
|
+
const [show, setShow] = (0, import_react10.useState)(false);
|
|
1750
|
+
const [clearing, setClearing] = (0, import_react10.useState)(false);
|
|
1751
|
+
const uniqueId = (0, import_react10.useId)();
|
|
1752
|
+
const searchMenuName = `search-menu-${uniqueId}`;
|
|
1753
|
+
(0, import_react10.useEffect)(() => {
|
|
1754
|
+
var _a2;
|
|
1755
|
+
if (preventFocusOnInitialRender.current) {
|
|
1756
|
+
preventFocusOnInitialRender.current = false;
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
1760
|
+
}, [props.value]);
|
|
1737
1761
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1738
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
1739
|
-
|
|
1740
|
-
|
|
1762
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1763
|
+
Input,
|
|
1764
|
+
__spreadValues({
|
|
1741
1765
|
id,
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1766
|
+
testid,
|
|
1767
|
+
variant: "search",
|
|
1768
|
+
inputContainerRef,
|
|
1769
|
+
ref: inputRef,
|
|
1770
|
+
label,
|
|
1771
|
+
wrapperClassName,
|
|
1772
|
+
onClick: (e) => {
|
|
1773
|
+
if (props.disabled || readOnly) {
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
if (clearing) {
|
|
1777
|
+
setClearing(false);
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
onClick == null ? void 0 : onClick(e);
|
|
1781
|
+
setShow(!show);
|
|
1782
|
+
},
|
|
1783
|
+
onClear: () => {
|
|
1784
|
+
setClearing(true);
|
|
1785
|
+
},
|
|
1786
|
+
onKeyDown: (e) => {
|
|
1787
|
+
setShow(true);
|
|
1788
|
+
if (["ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
1789
|
+
e.preventDefault();
|
|
1790
|
+
const menu = document.querySelector(
|
|
1791
|
+
`[data-menu="${searchMenuName}"]`
|
|
1792
|
+
);
|
|
1793
|
+
const selectedMenuOption = menu == null ? void 0 : menu.querySelector("[data-selected]");
|
|
1794
|
+
if (selectedMenuOption) {
|
|
1795
|
+
const allMenuOptions = Array.from(
|
|
1796
|
+
(menu == null ? void 0 : menu.querySelectorAll('[role="menuitem"]')) || []
|
|
1797
|
+
);
|
|
1798
|
+
const currentIndex = allMenuOptions.indexOf(selectedMenuOption);
|
|
1799
|
+
let targetOption;
|
|
1800
|
+
if (e.key === "ArrowDown") {
|
|
1801
|
+
targetOption = allMenuOptions[currentIndex + 1] || allMenuOptions[0];
|
|
1802
|
+
} else {
|
|
1803
|
+
targetOption = allMenuOptions[currentIndex - 1] || allMenuOptions[allMenuOptions.length - 1];
|
|
1804
|
+
}
|
|
1805
|
+
targetOption == null ? void 0 : targetOption.focus();
|
|
1806
|
+
} else {
|
|
1807
|
+
const toFocusMenuOption = e.key === "ArrowDown" ? menu == null ? void 0 : menu.querySelector('[role="menuitem"]') : menu == null ? void 0 : menu.querySelector(
|
|
1808
|
+
'[role="menuitem"]:last-child'
|
|
1809
|
+
);
|
|
1810
|
+
toFocusMenuOption == null ? void 0 : toFocusMenuOption.focus();
|
|
1811
|
+
}
|
|
1761
1812
|
}
|
|
1762
1813
|
},
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
role: "menuitem",
|
|
1769
|
-
"aria-haspopup": subMenu ? "menu" : void 0,
|
|
1770
|
-
children: [
|
|
1771
|
-
before && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
|
|
1772
|
-
renderChildren,
|
|
1773
|
-
renderAfterProp()
|
|
1774
|
-
]
|
|
1775
|
-
})
|
|
1814
|
+
error,
|
|
1815
|
+
readOnly,
|
|
1816
|
+
removeRoundness,
|
|
1817
|
+
focus: renderMenu && show
|
|
1818
|
+
}, props)
|
|
1776
1819
|
),
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
{
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
mobilePositionTo,
|
|
1788
|
-
position: "right",
|
|
1789
|
-
subMenuLevel,
|
|
1790
|
-
mobileBackMenuOption,
|
|
1791
|
-
mobileHide: isMobile && activeMenu !== menuId.current
|
|
1792
|
-
})
|
|
1793
|
-
}
|
|
1794
|
-
)
|
|
1820
|
+
renderMenu ? renderMenu({
|
|
1821
|
+
id: id ? `${id}-menu` : void 0,
|
|
1822
|
+
testid: testid ? `${testid}-menu` : void 0,
|
|
1823
|
+
positionTo: inputContainerRef,
|
|
1824
|
+
show,
|
|
1825
|
+
setShow,
|
|
1826
|
+
topOffset: props.caption ? -16 : null,
|
|
1827
|
+
autoFocusOff: true,
|
|
1828
|
+
menuName: searchMenuName
|
|
1829
|
+
}) : children
|
|
1795
1830
|
] });
|
|
1796
|
-
function renderAfterProp() {
|
|
1797
|
-
if (after) {
|
|
1798
|
-
return after;
|
|
1799
|
-
}
|
|
1800
|
-
if (subMenu && after !== null) {
|
|
1801
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_right" });
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
function mobileBackMenuOption() {
|
|
1805
|
-
if (!isMobile) {
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1809
|
-
MenuOption,
|
|
1810
|
-
{
|
|
1811
|
-
id: id ? `${id}-back` : void 0,
|
|
1812
|
-
testid: testid ? `${testid}-back` : void 0,
|
|
1813
|
-
onClick: () => {
|
|
1814
|
-
closeSubMenuLevel == null ? void 0 : closeSubMenuLevel(currentSubMenuLevel != null ? currentSubMenuLevel : 0);
|
|
1815
|
-
},
|
|
1816
|
-
variant: "action",
|
|
1817
|
-
before: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron_left" }),
|
|
1818
|
-
children: "Back"
|
|
1819
|
-
}
|
|
1820
|
-
);
|
|
1821
|
-
}
|
|
1822
1831
|
};
|
|
1823
|
-
|
|
1824
|
-
function highlightMatch(text, searchValue) {
|
|
1825
|
-
if (!searchValue || !searchValue.trim()) {
|
|
1826
|
-
return text;
|
|
1827
|
-
}
|
|
1828
|
-
const regex = new RegExp(
|
|
1829
|
-
`(${searchValue.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
1830
|
-
"gi"
|
|
1831
|
-
);
|
|
1832
|
-
const parts = text.split(regex);
|
|
1833
|
-
return parts.map(
|
|
1834
|
-
(part, index) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-bold", children: part }, index) : part
|
|
1835
|
-
);
|
|
1836
|
-
}
|
|
1832
|
+
Search.displayName = "Search";
|
|
1837
1833
|
|
|
1838
1834
|
// src/components/DataGridCell.tsx
|
|
1839
1835
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
@@ -1855,6 +1851,7 @@ var DataGridCell = (0, import_react11.memo)(
|
|
|
1855
1851
|
warning,
|
|
1856
1852
|
center,
|
|
1857
1853
|
width,
|
|
1854
|
+
minWidth,
|
|
1858
1855
|
testid
|
|
1859
1856
|
} = _b, props = __objRest(_b, [
|
|
1860
1857
|
"id",
|
|
@@ -1872,6 +1869,7 @@ var DataGridCell = (0, import_react11.memo)(
|
|
|
1872
1869
|
"warning",
|
|
1873
1870
|
"center",
|
|
1874
1871
|
"width",
|
|
1872
|
+
"minWidth",
|
|
1875
1873
|
"testid"
|
|
1876
1874
|
]);
|
|
1877
1875
|
const Element = type === "header" ? "th" : "td";
|
|
@@ -1945,7 +1943,7 @@ var DataGridCell = (0, import_react11.memo)(
|
|
|
1945
1943
|
id,
|
|
1946
1944
|
"data-testid": testid,
|
|
1947
1945
|
className: (0, import_clsx8.default)("flex h-10", !width && "flex-1"),
|
|
1948
|
-
style: { width }
|
|
1946
|
+
style: { width, minWidth }
|
|
1949
1947
|
}, props), {
|
|
1950
1948
|
"data-theme": type === "header" && !locked ? "brand" : void 0,
|
|
1951
1949
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -1986,7 +1984,7 @@ function DataCellHeader(_a) {
|
|
|
1986
1984
|
"testid",
|
|
1987
1985
|
"useMenuDefaultMinWidth"
|
|
1988
1986
|
]);
|
|
1989
|
-
var _a2
|
|
1987
|
+
var _a2;
|
|
1990
1988
|
const [showMenu, setShowMenu] = (0, import_react11.useState)(false);
|
|
1991
1989
|
const [filter, setFilter] = (0, import_react11.useState)(
|
|
1992
1990
|
(_a2 = header.column.getFilterValue()) != null ? _a2 : ""
|
|
@@ -2020,7 +2018,7 @@ function DataCellHeader(_a) {
|
|
|
2020
2018
|
const style = __spreadValues({
|
|
2021
2019
|
position: "relative",
|
|
2022
2020
|
whiteSpace: "nowrap",
|
|
2023
|
-
|
|
2021
|
+
minWidth: header.column.getSize(),
|
|
2024
2022
|
"--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
|
|
2025
2023
|
"--color-icon-on-action-primary-normal": "var(--color-text-brand-primary-normal)",
|
|
2026
2024
|
"--background-action-secondary-normal": "var(--color-text-brand-primary-normal)"
|
|
@@ -2034,6 +2032,7 @@ function DataCellHeader(_a) {
|
|
|
2034
2032
|
type: "header",
|
|
2035
2033
|
component: "header",
|
|
2036
2034
|
style,
|
|
2035
|
+
minWidth: `${header.column.getSize()}px`,
|
|
2037
2036
|
onClick: header.column.getToggleSortingHandler(),
|
|
2038
2037
|
onRightClick: () => setShowMenu(!showMenu)
|
|
2039
2038
|
}, props), {
|
|
@@ -2057,8 +2056,8 @@ function DataCellHeader(_a) {
|
|
|
2057
2056
|
id: id ? `${id}-filter-option` : void 0,
|
|
2058
2057
|
testid: testid ? `${testid}-filter-option` : void 0
|
|
2059
2058
|
}, subMenuListeners), {
|
|
2060
|
-
subMenu: (
|
|
2061
|
-
var
|
|
2059
|
+
subMenu: (_b2) => {
|
|
2060
|
+
var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
|
|
2062
2061
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2063
2062
|
Menu,
|
|
2064
2063
|
__spreadProps(__spreadValues({
|
|
@@ -2131,8 +2130,8 @@ function DataCellHeader(_a) {
|
|
|
2131
2130
|
setShowMenu(!showMenu);
|
|
2132
2131
|
}
|
|
2133
2132
|
}, subMenuListeners), {
|
|
2134
|
-
subMenu: (
|
|
2135
|
-
var
|
|
2133
|
+
subMenu: (_d) => {
|
|
2134
|
+
var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
|
|
2136
2135
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2137
2136
|
Menu,
|
|
2138
2137
|
__spreadProps(__spreadValues({}, props2), {
|
|
@@ -2220,7 +2219,6 @@ function DraggableCellHeader(_a) {
|
|
|
2220
2219
|
"header",
|
|
2221
2220
|
"children"
|
|
2222
2221
|
]);
|
|
2223
|
-
var _a2, _b2;
|
|
2224
2222
|
const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
|
|
2225
2223
|
id: header.column.id
|
|
2226
2224
|
});
|
|
@@ -2231,7 +2229,6 @@ function DraggableCellHeader(_a) {
|
|
|
2231
2229
|
transition: "width transform 0.2s ease-in-out",
|
|
2232
2230
|
whiteSpace: "nowrap",
|
|
2233
2231
|
zIndex: isDragging ? 1 : 0,
|
|
2234
|
-
width: (_b2 = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : header.column.getSize(),
|
|
2235
2232
|
"--color-text-primary-normal": "var(--color-action-000)",
|
|
2236
2233
|
"--color-icon-on-action-primary-normal": "var(--color-action-000)",
|
|
2237
2234
|
userSelect: "none"
|
|
@@ -2257,7 +2254,6 @@ function DragAlongCell(_a) {
|
|
|
2257
2254
|
"cell",
|
|
2258
2255
|
"children"
|
|
2259
2256
|
]);
|
|
2260
|
-
var _a2, _b2, _c, _d;
|
|
2261
2257
|
const { isDragging, setNodeRef, transform } = (0, import_sortable.useSortable)({
|
|
2262
2258
|
id: cell.column.id
|
|
2263
2259
|
});
|
|
@@ -2266,19 +2262,10 @@ function DragAlongCell(_a) {
|
|
|
2266
2262
|
position: "relative",
|
|
2267
2263
|
transform: CSS.Translate.toString(transform),
|
|
2268
2264
|
transition: "width transform 0.2s ease-in-out",
|
|
2269
|
-
|
|
2265
|
+
minWidth: cell.column.getSize(),
|
|
2270
2266
|
zIndex: isDragging ? 1 : 0
|
|
2271
2267
|
};
|
|
2272
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2273
|
-
DataGridCell,
|
|
2274
|
-
__spreadProps(__spreadValues({
|
|
2275
|
-
style,
|
|
2276
|
-
ref: setNodeRef,
|
|
2277
|
-
width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`
|
|
2278
|
-
}, props), {
|
|
2279
|
-
children
|
|
2280
|
-
})
|
|
2281
|
-
);
|
|
2268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
|
|
2282
2269
|
}
|
|
2283
2270
|
DragAlongCell.displayName = "DragAlongCell";
|
|
2284
2271
|
|
|
@@ -2370,7 +2357,7 @@ function TableBodyRow({
|
|
|
2370
2357
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { style: { display: "flex", width: virtualPaddingLeft } })
|
|
2371
2358
|
) : null,
|
|
2372
2359
|
columns.map((column) => {
|
|
2373
|
-
var _a2
|
|
2360
|
+
var _a2;
|
|
2374
2361
|
const cell = locked ? column : visibleCells[column.index];
|
|
2375
2362
|
if (!cell) {
|
|
2376
2363
|
return;
|
|
@@ -2385,7 +2372,6 @@ function TableBodyRow({
|
|
|
2385
2372
|
className: (0, import_clsx10.default)({
|
|
2386
2373
|
"justify-end": typeof cellValue === "number"
|
|
2387
2374
|
}),
|
|
2388
|
-
width: (_c = (_b = cell.column.columnDef.meta) == null ? void 0 : _b.headerWidth) != null ? _c : `${cell.column.getSize()}px`,
|
|
2389
2375
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2390
2376
|
Tooltip,
|
|
2391
2377
|
{
|
|
@@ -2571,7 +2557,15 @@ function TableBody({
|
|
|
2571
2557
|
transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
|
|
2572
2558
|
},
|
|
2573
2559
|
className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
|
|
2574
|
-
children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2560
|
+
children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2561
|
+
LoadingCell,
|
|
2562
|
+
{
|
|
2563
|
+
id,
|
|
2564
|
+
testid,
|
|
2565
|
+
column: column.columnDef
|
|
2566
|
+
},
|
|
2567
|
+
column.id
|
|
2568
|
+
))
|
|
2575
2569
|
}
|
|
2576
2570
|
)
|
|
2577
2571
|
]
|
|
@@ -3101,23 +3095,21 @@ function DataGrid({
|
|
|
3101
3095
|
)
|
|
3102
3096
|
) : null,
|
|
3103
3097
|
virtualColumns.map((virtualColumn) => {
|
|
3104
|
-
var _a2, _b2, _c2
|
|
3098
|
+
var _a2, _b2, _c2;
|
|
3105
3099
|
const header = headerGroup.headers[virtualColumn.index];
|
|
3106
3100
|
if (!header) {
|
|
3107
3101
|
return;
|
|
3108
3102
|
}
|
|
3109
3103
|
if (typeof header.column.columnDef.header === "string") {
|
|
3110
|
-
const
|
|
3111
|
-
const cellValue = (_b2 = table.getRowModel().rows[0]) == null ? void 0 : _b2.getValue(header.column.id);
|
|
3104
|
+
const cellValue = (_a2 = table.getRowModel().rows[0]) == null ? void 0 : _a2.getValue(header.column.id);
|
|
3112
3105
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3113
3106
|
DraggableCellHeader,
|
|
3114
3107
|
{
|
|
3115
3108
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
3116
3109
|
testid: testid ? `${testid}-header-${header.id}` : void 0,
|
|
3117
3110
|
header,
|
|
3118
|
-
locked: (
|
|
3111
|
+
locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
|
|
3119
3112
|
center: centerHeader,
|
|
3120
|
-
width: customHeaderWidth,
|
|
3121
3113
|
className: (0, import_clsx13.default)(
|
|
3122
3114
|
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
3123
3115
|
"group",
|
|
@@ -3158,7 +3150,7 @@ function DataGrid({
|
|
|
3158
3150
|
header.id
|
|
3159
3151
|
);
|
|
3160
3152
|
}
|
|
3161
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: ((
|
|
3153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: ((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3162
3154
|
DataGridCell,
|
|
3163
3155
|
{
|
|
3164
3156
|
id: id ? `${id}-header-${header.id}` : void 0,
|