@dmsi/wedgekit-react 0.0.207 → 0.0.209
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-WNQ53SVY.js → chunk-E6Y7ZHQX.js} +45 -1
- package/dist/{chunk-WXHRJSDG.js → chunk-ERW3AMED.js} +1 -1
- package/dist/{chunk-2JRZCC2K.js → chunk-JITZWSPR.js} +3 -3
- package/dist/{chunk-WE55TGZZ.js → chunk-NIHZMIOL.js} +1 -1
- package/dist/{chunk-RXPS5GVE.js → chunk-Q3TNALWH.js} +17 -26
- package/dist/{chunk-M3433XEJ.js → chunk-T3F37S6Z.js} +15 -1
- package/dist/{chunk-2B5T4NCT.js → chunk-UKSJPFN2.js} +2 -2
- package/dist/components/DataGridCell.cjs +814 -824
- package/dist/components/DataGridCell.js +7 -6
- package/dist/components/DateInput.cjs +23 -23
- package/dist/components/DateInput.js +4 -4
- package/dist/components/DateRangeInput.cjs +23 -23
- package/dist/components/DateRangeInput.js +4 -4
- package/dist/components/Menu.cjs +38 -35
- package/dist/components/Menu.js +6 -4
- package/dist/components/MenuOption.cjs +7 -4
- package/dist/components/MenuOption.js +5 -2
- package/dist/components/Modal.cjs +15 -12
- package/dist/components/Modal.js +5 -3
- package/dist/components/NestedMenu.cjs +9 -6
- package/dist/components/NestedMenu.js +5 -2
- package/dist/components/PDFViewer.cjs +22 -19
- package/dist/components/PDFViewer.js +5 -3
- package/dist/components/ProjectBar.cjs +3 -0
- package/dist/components/ProjectBar.js +4 -1
- package/dist/components/Time.js +2 -1
- package/dist/components/index.cjs +963 -905
- package/dist/components/index.js +70 -45
- package/dist/components/useMenuSystem.cjs +22 -19
- package/dist/components/useMenuSystem.js +5 -2
- package/dist/hooks/index.cjs +66 -2
- package/dist/hooks/index.js +8 -3
- package/dist/utils/index.cjs +25 -0
- package/dist/utils/index.js +3 -1
- 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 +58 -35
- package/src/components/DataGridCell.tsx +11 -17
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useTableLayout.ts +68 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/mergeObjectArrays.ts +18 -0
- package/src/utils.ts +1 -0
- /package/dist/{chunk-6LN6QT6M.js → chunk-VXWSAIB5.js} +0 -0
|
@@ -134,7 +134,7 @@ var CSS = /* @__PURE__ */ Object.freeze({
|
|
|
134
134
|
|
|
135
135
|
// src/components/DataGridCell.tsx
|
|
136
136
|
var import_clsx8 = __toESM(require("clsx"), 1);
|
|
137
|
-
var
|
|
137
|
+
var import_react11 = require("react");
|
|
138
138
|
|
|
139
139
|
// src/classNames.ts
|
|
140
140
|
var import_clsx = __toESM(require("clsx"), 1);
|
|
@@ -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,562 +478,264 @@ function formatCurrencyDisplay(value) {
|
|
|
381
478
|
return decimalPart !== void 0 ? `${formattedInteger}.${decimalPart}` : formattedInteger;
|
|
382
479
|
}
|
|
383
480
|
|
|
384
|
-
// src/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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"
|
|
481
|
+
// src/utils/mergeObjectArrays.ts
|
|
482
|
+
function mergeObjectArrays(arr1, arr2) {
|
|
483
|
+
const maxLength = Math.max(arr1.length, arr2.length);
|
|
484
|
+
return Array.from(
|
|
485
|
+
{ length: maxLength },
|
|
486
|
+
(_, i) => __spreadValues(__spreadValues({}, arr1[i] || {}), arr2[i] || {})
|
|
459
487
|
);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// src/utils.ts
|
|
491
|
+
function findDocumentRoot(element) {
|
|
492
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
493
|
+
throw new Error(
|
|
494
|
+
"findDocumentRoot can only be used in a browser environment."
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (!element || !(element instanceof Node)) {
|
|
498
|
+
return window.document.body;
|
|
499
|
+
}
|
|
500
|
+
let currentElement = element;
|
|
501
|
+
while (currentElement && currentElement.parentNode) {
|
|
502
|
+
if (currentElement.parentNode === document) {
|
|
503
|
+
return document.body;
|
|
504
|
+
} else if (currentElement.parentNode instanceof DocumentFragment) {
|
|
505
|
+
return currentElement.parentNode;
|
|
506
|
+
} else {
|
|
507
|
+
currentElement = currentElement.parentNode;
|
|
585
508
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
509
|
+
}
|
|
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
|
+
);
|
|
589
529
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
530
|
+
if (!savedLayout) handleSaveLayout(initialColumns, true);
|
|
531
|
+
setLayoutSignal((prev) => prev + 1);
|
|
532
|
+
setIsReady(true);
|
|
593
533
|
}, []);
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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:
|
|
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)
|
|
634
539
|
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;
|
|
540
|
+
if (key) {
|
|
541
|
+
localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
|
|
690
542
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
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);
|
|
706
588
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
if (
|
|
710
|
-
|
|
589
|
+
};
|
|
590
|
+
const handleMouseLeave = () => {
|
|
591
|
+
if (subMenu && onSubMenuLeave && !disabled) {
|
|
592
|
+
onSubMenuLeave(subMenuLevel);
|
|
711
593
|
}
|
|
712
594
|
};
|
|
713
|
-
const
|
|
714
|
-
if (!
|
|
715
|
-
|
|
595
|
+
const handleMouseMove = () => {
|
|
596
|
+
if (subMenu && onMouseMove && !disabled) {
|
|
597
|
+
onMouseMove();
|
|
716
598
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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;
|
|
599
|
+
};
|
|
600
|
+
const handleSubMenuEnter = () => {
|
|
601
|
+
if (onSubMenuEnter) {
|
|
602
|
+
onSubMenuEnter();
|
|
731
603
|
}
|
|
732
|
-
onBlur == null ? void 0 : onBlur(e);
|
|
733
604
|
};
|
|
734
|
-
const
|
|
735
|
-
|
|
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);
|
|
605
|
+
const additionalAttributes = {
|
|
606
|
+
"data-selected": selected || null
|
|
754
607
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
__spreadProps(__spreadValues({}, props), {
|
|
758
|
-
variant: "currency",
|
|
759
|
-
decimals: (_a = props.decimals) != null ? _a : 2,
|
|
760
|
-
onChange: handleCurrencyChange
|
|
761
|
-
})
|
|
608
|
+
const svgStyles = (0, import_clsx5.default)(
|
|
609
|
+
"[&>svg]:shrink-0 [&>svg]:fill-icon-action-primary-normal"
|
|
762
610
|
);
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
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]);
|
|
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 });
|
|
811
631
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
812
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
813
|
-
|
|
814
|
-
__spreadValues({
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
633
|
+
"div",
|
|
634
|
+
__spreadProps(__spreadValues({
|
|
815
635
|
id,
|
|
816
|
-
testid,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
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
|
-
}
|
|
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);
|
|
862
655
|
}
|
|
863
656
|
},
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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
|
+
})
|
|
869
670
|
),
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
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
|
+
)
|
|
880
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;
|
|
701
|
+
}
|
|
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"
|
|
713
|
+
}
|
|
714
|
+
);
|
|
715
|
+
}
|
|
881
716
|
};
|
|
882
|
-
|
|
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
|
|
729
|
+
);
|
|
730
|
+
}
|
|
883
731
|
|
|
884
732
|
// src/components/Menu.tsx
|
|
885
|
-
var
|
|
733
|
+
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
886
734
|
var import_react8 = require("react");
|
|
887
735
|
var import_react_dom = require("react-dom");
|
|
888
736
|
|
|
889
737
|
// src/components/useMenuSystem.tsx
|
|
890
738
|
var import_react7 = 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
|
-
// src/components/useMenuSystem.tsx
|
|
940
739
|
function useSubMenuSystem(mobilePositionTo) {
|
|
941
740
|
const [activeMenus, setActiveMenus] = (0, import_react7.useState)(
|
|
942
741
|
{}
|
|
@@ -1275,29 +1074,6 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1275
1074
|
return { menuPosition, updatePosition };
|
|
1276
1075
|
}
|
|
1277
1076
|
|
|
1278
|
-
// src/utils.ts
|
|
1279
|
-
function findDocumentRoot(element) {
|
|
1280
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1281
|
-
throw new Error(
|
|
1282
|
-
"findDocumentRoot can only be used in a browser environment."
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
if (!element || !(element instanceof Node)) {
|
|
1286
|
-
return window.document.body;
|
|
1287
|
-
}
|
|
1288
|
-
let currentElement = element;
|
|
1289
|
-
while (currentElement && currentElement.parentNode) {
|
|
1290
|
-
if (currentElement.parentNode === document) {
|
|
1291
|
-
return document.body;
|
|
1292
|
-
} else if (currentElement.parentNode instanceof DocumentFragment) {
|
|
1293
|
-
return currentElement.parentNode;
|
|
1294
|
-
} else {
|
|
1295
|
-
currentElement = currentElement.parentNode;
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
return window.document.body;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1077
|
// src/components/Menu.tsx
|
|
1302
1078
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1303
1079
|
var Menu = (_a) => {
|
|
@@ -1421,7 +1197,7 @@ var Menu = (_a) => {
|
|
|
1421
1197
|
id,
|
|
1422
1198
|
"data-testid": testid,
|
|
1423
1199
|
ref: setRefs,
|
|
1424
|
-
className: (0,
|
|
1200
|
+
className: (0, import_clsx6.default)(
|
|
1425
1201
|
"shadow-4 rounded-base bg-background-grouped-primary-normal overflow-x-hidden overflow-y-auto flex flex-col outline-0",
|
|
1426
1202
|
"fixed",
|
|
1427
1203
|
"z-50",
|
|
@@ -1550,246 +1326,514 @@ var Menu = (_a) => {
|
|
|
1550
1326
|
};
|
|
1551
1327
|
Menu.displayName = "Menu";
|
|
1552
1328
|
|
|
1553
|
-
// src/components/
|
|
1554
|
-
var
|
|
1555
|
-
var import_react9 = require("react");
|
|
1329
|
+
// src/components/Search.tsx
|
|
1330
|
+
var import_react10 = require("react");
|
|
1556
1331
|
|
|
1557
|
-
// src/components/
|
|
1558
|
-
var
|
|
1332
|
+
// src/components/Input.tsx
|
|
1333
|
+
var import_react9 = require("react");
|
|
1334
|
+
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
1559
1335
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1560
|
-
var
|
|
1336
|
+
var InputBase = (_a) => {
|
|
1561
1337
|
var _b = _a, {
|
|
1338
|
+
id,
|
|
1339
|
+
testid,
|
|
1340
|
+
before,
|
|
1341
|
+
after,
|
|
1342
|
+
type,
|
|
1343
|
+
label,
|
|
1344
|
+
error,
|
|
1562
1345
|
className,
|
|
1563
|
-
color,
|
|
1564
|
-
padded,
|
|
1565
1346
|
align = "left",
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
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
|
+
);
|
|
1498
|
+
};
|
|
1499
|
+
var Input = (_a) => {
|
|
1500
|
+
var _b = _a, {
|
|
1501
|
+
variant = "default",
|
|
1502
|
+
decimals,
|
|
1503
|
+
uom,
|
|
1504
|
+
removeSearchIcon,
|
|
1505
|
+
value: propValue,
|
|
1506
|
+
onChange,
|
|
1507
|
+
onBlur,
|
|
1508
|
+
onClear,
|
|
1570
1509
|
id,
|
|
1571
1510
|
testid
|
|
1572
1511
|
} = _b, props = __objRest(_b, [
|
|
1573
|
-
"
|
|
1574
|
-
"
|
|
1575
|
-
"
|
|
1576
|
-
"
|
|
1577
|
-
"
|
|
1578
|
-
"
|
|
1579
|
-
"
|
|
1580
|
-
"
|
|
1512
|
+
"variant",
|
|
1513
|
+
"decimals",
|
|
1514
|
+
"uom",
|
|
1515
|
+
"removeSearchIcon",
|
|
1516
|
+
"value",
|
|
1517
|
+
"onChange",
|
|
1518
|
+
"onBlur",
|
|
1519
|
+
"onClear",
|
|
1581
1520
|
"id",
|
|
1582
1521
|
"testid"
|
|
1583
1522
|
]);
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
align === "center" && "text-center",
|
|
1597
|
-
align === "right" && "text-right",
|
|
1598
|
-
tall && "!leading-6",
|
|
1599
|
-
addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
|
|
1600
|
-
),
|
|
1601
|
-
style: __spreadProps(__spreadValues({}, props.style), {
|
|
1602
|
-
color: color ? `var(--color-${color})` : void 0
|
|
1603
|
-
}),
|
|
1604
|
-
children
|
|
1605
|
-
})
|
|
1606
|
-
);
|
|
1607
|
-
};
|
|
1608
|
-
Paragraph.displayName = "Paragraph";
|
|
1609
|
-
|
|
1610
|
-
// src/components/MenuOption.tsx
|
|
1611
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1612
|
-
var MenuOption = ({
|
|
1613
|
-
id,
|
|
1614
|
-
testid,
|
|
1615
|
-
children,
|
|
1616
|
-
disabled = false,
|
|
1617
|
-
variant = "normal",
|
|
1618
|
-
value,
|
|
1619
|
-
before,
|
|
1620
|
-
after,
|
|
1621
|
-
subMenu,
|
|
1622
|
-
onClick,
|
|
1623
|
-
selected,
|
|
1624
|
-
ref,
|
|
1625
|
-
onSubMenuHover,
|
|
1626
|
-
onSubMenuLeave,
|
|
1627
|
-
onSubMenuEnter,
|
|
1628
|
-
toggleMenu,
|
|
1629
|
-
subMenuLevel = 1,
|
|
1630
|
-
currentSubMenuLevel,
|
|
1631
|
-
closeSubMenuLevel,
|
|
1632
|
-
activeMenu,
|
|
1633
|
-
mobilePositionTo,
|
|
1634
|
-
highlightMatchingText = false,
|
|
1635
|
-
menuValue,
|
|
1636
|
-
onMouseMove
|
|
1637
|
-
}) => {
|
|
1638
|
-
const uniqueId = (0, import_react9.useId)();
|
|
1639
|
-
const internalRef = (0, import_react9.useRef)(null);
|
|
1640
|
-
const actualRef = ref || internalRef;
|
|
1641
|
-
const menuId = (0, import_react9.useRef)(`menu-${uniqueId}`);
|
|
1642
|
-
const isMobile = useMatchesMobile();
|
|
1643
|
-
const handleMouseEnter = () => {
|
|
1644
|
-
if (subMenu && onSubMenuHover && !disabled) {
|
|
1645
|
-
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;
|
|
1646
1535
|
}
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
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;
|
|
1651
1574
|
}
|
|
1652
1575
|
};
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1655
|
-
|
|
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;
|
|
1656
1585
|
}
|
|
1657
1586
|
};
|
|
1658
|
-
const
|
|
1659
|
-
if (
|
|
1660
|
-
|
|
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;
|
|
1661
1611
|
}
|
|
1662
1612
|
};
|
|
1663
|
-
const
|
|
1664
|
-
"
|
|
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();
|
|
1665
1625
|
};
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
"hover:bg-background-action-secondary-hover hover:text-text-action-hover",
|
|
1681
|
-
"focus:bg-background-action-secondary-hover focus:text-text-action-hover",
|
|
1682
|
-
"data-selected:bg-background-action-secondary-active data-selected:text-text-action-active",
|
|
1683
|
-
"active:bg-background-action-secondary-active active:text-text-action-active"
|
|
1684
|
-
);
|
|
1685
|
-
const actionDisabledStyles = variant === "action" && disabled && (0, import_clsx7.default)("text-text-action-disabled");
|
|
1686
|
-
const disabledStyles = disabled && (0, import_clsx7.default)("bg-transparent cursor-default pointer-events-none");
|
|
1687
|
-
const processChildren = typeof children === "string" && highlightMatchingText ? highlightMatch(children, menuValue) : children;
|
|
1688
|
-
const renderChildren = typeof children === "object" ? children : variant === "action" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { padded: true, className: textLabelStyles, children: processChildren }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Paragraph, { padded: true, className: textLabelStyles, children: processChildren });
|
|
1689
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1690
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1691
|
-
"div",
|
|
1692
|
-
__spreadProps(__spreadValues({
|
|
1693
|
-
id,
|
|
1694
|
-
"data-testid": testid,
|
|
1695
|
-
ref: actualRef,
|
|
1696
|
-
className: (0, import_clsx7.default)(
|
|
1697
|
-
"flex items-center cursor-pointer w-full text-left relative outline-none",
|
|
1698
|
-
svgStyles,
|
|
1699
|
-
componentGap,
|
|
1700
|
-
componentPadding,
|
|
1701
|
-
baseTransition,
|
|
1702
|
-
normalStyles,
|
|
1703
|
-
normalDisabledStyles,
|
|
1704
|
-
actionStyles,
|
|
1705
|
-
actionDisabledStyles,
|
|
1706
|
-
disabledStyles
|
|
1707
|
-
),
|
|
1708
|
-
"data-value": value || children,
|
|
1709
|
-
onClick: () => {
|
|
1710
|
-
onClick == null ? void 0 : onClick(menuId.current, value || children);
|
|
1711
|
-
if (subMenu) {
|
|
1712
|
-
toggleMenu(menuId.current, subMenuLevel);
|
|
1713
|
-
}
|
|
1714
|
-
},
|
|
1715
|
-
onMouseEnter: handleMouseEnter,
|
|
1716
|
-
onMouseLeave: handleMouseLeave,
|
|
1717
|
-
onMouseMove: handleMouseMove
|
|
1718
|
-
}, additionalAttributes), {
|
|
1719
|
-
tabIndex: -1,
|
|
1720
|
-
role: "menuitem",
|
|
1721
|
-
"aria-haspopup": subMenu ? "menu" : void 0,
|
|
1722
|
-
children: [
|
|
1723
|
-
before && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "shrink-0 flex items-center", children: before }),
|
|
1724
|
-
renderChildren,
|
|
1725
|
-
renderAfterProp()
|
|
1726
|
-
]
|
|
1727
|
-
})
|
|
1728
|
-
),
|
|
1729
|
-
subMenu && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1730
|
-
"div",
|
|
1731
|
-
{
|
|
1732
|
-
onMouseEnter: handleSubMenuEnter,
|
|
1733
|
-
onMouseLeave: handleMouseLeave,
|
|
1734
|
-
"data-submenu-parent": menuId.current,
|
|
1735
|
-
"data-menu-level": subMenuLevel + 1,
|
|
1736
|
-
children: subMenu({
|
|
1737
|
-
menuId: menuId.current,
|
|
1738
|
-
positionTo: actualRef,
|
|
1739
|
-
mobilePositionTo,
|
|
1740
|
-
position: "right",
|
|
1741
|
-
subMenuLevel,
|
|
1742
|
-
mobileBackMenuOption,
|
|
1743
|
-
mobileHide: isMobile && activeMenu !== menuId.current
|
|
1744
|
-
})
|
|
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;
|
|
1745
1640
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
return
|
|
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;
|
|
1751
1656
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1657
|
+
setInternalValue(rawValue);
|
|
1658
|
+
setDisplayValue(rawValue);
|
|
1659
|
+
if (typeof onChange === "function") {
|
|
1660
|
+
onChange(e);
|
|
1754
1661
|
}
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
if (!
|
|
1662
|
+
};
|
|
1663
|
+
const handleBlur = (e) => {
|
|
1664
|
+
if (!internalValue) {
|
|
1758
1665
|
return;
|
|
1759
1666
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
children: "Back"
|
|
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);
|
|
1771
1677
|
}
|
|
1772
|
-
)
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1678
|
+
} else if (variant === "uom" || variant === "percentage") {
|
|
1679
|
+
const formattedValue = formatDecimalValue(e.target.value, decimals);
|
|
1680
|
+
e.target.value = formattedValue;
|
|
1681
|
+
}
|
|
1682
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
1683
|
+
};
|
|
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
|
+
})
|
|
1783
1694
|
);
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
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
|
+
})
|
|
1787
1712
|
);
|
|
1788
|
-
}
|
|
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]);
|
|
1761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1762
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1763
|
+
Input,
|
|
1764
|
+
__spreadValues({
|
|
1765
|
+
id,
|
|
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
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
},
|
|
1814
|
+
error,
|
|
1815
|
+
readOnly,
|
|
1816
|
+
removeRoundness,
|
|
1817
|
+
focus: renderMenu && show
|
|
1818
|
+
}, props)
|
|
1819
|
+
),
|
|
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
|
|
1830
|
+
] });
|
|
1831
|
+
};
|
|
1832
|
+
Search.displayName = "Search";
|
|
1789
1833
|
|
|
1790
1834
|
// src/components/DataGridCell.tsx
|
|
1791
1835
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1792
|
-
var DataGridCell = (0,
|
|
1836
|
+
var DataGridCell = (0, import_react11.memo)(
|
|
1793
1837
|
(_a) => {
|
|
1794
1838
|
var _b = _a, {
|
|
1795
1839
|
id,
|
|
@@ -1807,6 +1851,7 @@ var DataGridCell = (0, import_react10.memo)(
|
|
|
1807
1851
|
warning,
|
|
1808
1852
|
center,
|
|
1809
1853
|
width,
|
|
1854
|
+
minWidth,
|
|
1810
1855
|
testid
|
|
1811
1856
|
} = _b, props = __objRest(_b, [
|
|
1812
1857
|
"id",
|
|
@@ -1824,13 +1869,14 @@ var DataGridCell = (0, import_react10.memo)(
|
|
|
1824
1869
|
"warning",
|
|
1825
1870
|
"center",
|
|
1826
1871
|
"width",
|
|
1872
|
+
"minWidth",
|
|
1827
1873
|
"testid"
|
|
1828
1874
|
]);
|
|
1829
1875
|
const Element = type === "header" ? "th" : "td";
|
|
1830
|
-
const timerRef = (0,
|
|
1831
|
-
const [isGrabbing, setIsGrabbing] = (0,
|
|
1832
|
-
const [isPointerPressed, setIsPointerPressed] = (0,
|
|
1833
|
-
(0,
|
|
1876
|
+
const timerRef = (0, import_react11.useRef)(null);
|
|
1877
|
+
const [isGrabbing, setIsGrabbing] = (0, import_react11.useState)(false);
|
|
1878
|
+
const [isPointerPressed, setIsPointerPressed] = (0, import_react11.useState)(false);
|
|
1879
|
+
(0, import_react11.useEffect)(() => {
|
|
1834
1880
|
return () => {
|
|
1835
1881
|
if (timerRef.current) {
|
|
1836
1882
|
clearTimeout(timerRef.current);
|
|
@@ -1897,7 +1943,7 @@ var DataGridCell = (0, import_react10.memo)(
|
|
|
1897
1943
|
id,
|
|
1898
1944
|
"data-testid": testid,
|
|
1899
1945
|
className: (0, import_clsx8.default)("flex h-10", !width && "flex-1"),
|
|
1900
|
-
style: { width }
|
|
1946
|
+
style: { width, minWidth }
|
|
1901
1947
|
}, props), {
|
|
1902
1948
|
"data-theme": type === "header" && !locked ? "brand" : void 0,
|
|
1903
1949
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -1938,13 +1984,13 @@ function DataCellHeader(_a) {
|
|
|
1938
1984
|
"testid",
|
|
1939
1985
|
"useMenuDefaultMinWidth"
|
|
1940
1986
|
]);
|
|
1941
|
-
var _a2
|
|
1942
|
-
const [showMenu, setShowMenu] = (0,
|
|
1943
|
-
const [filter, setFilter] = (0,
|
|
1987
|
+
var _a2;
|
|
1988
|
+
const [showMenu, setShowMenu] = (0, import_react11.useState)(false);
|
|
1989
|
+
const [filter, setFilter] = (0, import_react11.useState)(
|
|
1944
1990
|
(_a2 = header.column.getFilterValue()) != null ? _a2 : ""
|
|
1945
1991
|
);
|
|
1946
|
-
const ref = (0,
|
|
1947
|
-
const predeterminedPinned = (0,
|
|
1992
|
+
const ref = (0, import_react11.useRef)(null);
|
|
1993
|
+
const predeterminedPinned = (0, import_react11.useRef)(false);
|
|
1948
1994
|
const {
|
|
1949
1995
|
menuRootRef,
|
|
1950
1996
|
isMenuActive,
|
|
@@ -1952,7 +1998,7 @@ function DataCellHeader(_a) {
|
|
|
1952
1998
|
listeners: subMenuListeners,
|
|
1953
1999
|
mobileHide
|
|
1954
2000
|
} = useSubMenuSystem(node ? node : ref);
|
|
1955
|
-
(0,
|
|
2001
|
+
(0, import_react11.useEffect)(() => {
|
|
1956
2002
|
var _a3;
|
|
1957
2003
|
const columnPinning = (_a3 = header.getContext().table.options.initialState) == null ? void 0 : _a3.columnPinning;
|
|
1958
2004
|
const left = (columnPinning == null ? void 0 : columnPinning.left) ? columnPinning.left : [];
|
|
@@ -1961,7 +2007,7 @@ function DataCellHeader(_a) {
|
|
|
1961
2007
|
header.column.id
|
|
1962
2008
|
);
|
|
1963
2009
|
}, []);
|
|
1964
|
-
(0,
|
|
2010
|
+
(0, import_react11.useEffect)(() => {
|
|
1965
2011
|
const handler = setTimeout(() => {
|
|
1966
2012
|
header.column.setFilterValue(filter);
|
|
1967
2013
|
}, 500);
|
|
@@ -1972,7 +2018,7 @@ function DataCellHeader(_a) {
|
|
|
1972
2018
|
const style = __spreadValues({
|
|
1973
2019
|
position: "relative",
|
|
1974
2020
|
whiteSpace: "nowrap",
|
|
1975
|
-
|
|
2021
|
+
minWidth: header.column.getSize(),
|
|
1976
2022
|
"--color-text-primary-normal": "var(--color-text-brand-primary-normal)",
|
|
1977
2023
|
"--color-icon-on-action-primary-normal": "var(--color-text-brand-primary-normal)",
|
|
1978
2024
|
"--background-action-secondary-normal": "var(--color-text-brand-primary-normal)"
|
|
@@ -1986,6 +2032,7 @@ function DataCellHeader(_a) {
|
|
|
1986
2032
|
type: "header",
|
|
1987
2033
|
component: "header",
|
|
1988
2034
|
style,
|
|
2035
|
+
minWidth: `${header.column.getSize()}px`,
|
|
1989
2036
|
onClick: header.column.getToggleSortingHandler(),
|
|
1990
2037
|
onRightClick: () => setShowMenu(!showMenu)
|
|
1991
2038
|
}, props), {
|
|
@@ -2009,8 +2056,8 @@ function DataCellHeader(_a) {
|
|
|
2009
2056
|
id: id ? `${id}-filter-option` : void 0,
|
|
2010
2057
|
testid: testid ? `${testid}-filter-option` : void 0
|
|
2011
2058
|
}, subMenuListeners), {
|
|
2012
|
-
subMenu: (
|
|
2013
|
-
var
|
|
2059
|
+
subMenu: (_b2) => {
|
|
2060
|
+
var _c = _b2, { menuId, subMenuLevel } = _c, props2 = __objRest(_c, ["menuId", "subMenuLevel"]);
|
|
2014
2061
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2015
2062
|
Menu,
|
|
2016
2063
|
__spreadProps(__spreadValues({
|
|
@@ -2083,8 +2130,8 @@ function DataCellHeader(_a) {
|
|
|
2083
2130
|
setShowMenu(!showMenu);
|
|
2084
2131
|
}
|
|
2085
2132
|
}, subMenuListeners), {
|
|
2086
|
-
subMenu: (
|
|
2087
|
-
var
|
|
2133
|
+
subMenu: (_d) => {
|
|
2134
|
+
var _e = _d, { menuId, subMenuLevel } = _e, props2 = __objRest(_e, ["menuId", "subMenuLevel"]);
|
|
2088
2135
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2089
2136
|
Menu,
|
|
2090
2137
|
__spreadProps(__spreadValues({}, props2), {
|
|
@@ -2172,7 +2219,6 @@ function DraggableCellHeader(_a) {
|
|
|
2172
2219
|
"header",
|
|
2173
2220
|
"children"
|
|
2174
2221
|
]);
|
|
2175
|
-
var _a2, _b2;
|
|
2176
2222
|
const { attributes, isDragging, listeners, setNodeRef, transform, node } = (0, import_sortable.useSortable)({
|
|
2177
2223
|
id: header.column.id
|
|
2178
2224
|
});
|
|
@@ -2183,7 +2229,6 @@ function DraggableCellHeader(_a) {
|
|
|
2183
2229
|
transition: "width transform 0.2s ease-in-out",
|
|
2184
2230
|
whiteSpace: "nowrap",
|
|
2185
2231
|
zIndex: isDragging ? 1 : 0,
|
|
2186
|
-
width: (_b2 = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth) != null ? _b2 : header.column.getSize(),
|
|
2187
2232
|
"--color-text-primary-normal": "var(--color-action-000)",
|
|
2188
2233
|
"--color-icon-on-action-primary-normal": "var(--color-action-000)",
|
|
2189
2234
|
userSelect: "none"
|
|
@@ -2209,7 +2254,6 @@ function DragAlongCell(_a) {
|
|
|
2209
2254
|
"cell",
|
|
2210
2255
|
"children"
|
|
2211
2256
|
]);
|
|
2212
|
-
var _a2, _b2, _c, _d;
|
|
2213
2257
|
const { isDragging, setNodeRef, transform } = (0, import_sortable.useSortable)({
|
|
2214
2258
|
id: cell.column.id
|
|
2215
2259
|
});
|
|
@@ -2218,24 +2262,15 @@ function DragAlongCell(_a) {
|
|
|
2218
2262
|
position: "relative",
|
|
2219
2263
|
transform: CSS.Translate.toString(transform),
|
|
2220
2264
|
transition: "width transform 0.2s ease-in-out",
|
|
2221
|
-
|
|
2265
|
+
minWidth: cell.column.getSize(),
|
|
2222
2266
|
zIndex: isDragging ? 1 : 0
|
|
2223
2267
|
};
|
|
2224
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2225
|
-
DataGridCell,
|
|
2226
|
-
__spreadProps(__spreadValues({
|
|
2227
|
-
style,
|
|
2228
|
-
ref: setNodeRef,
|
|
2229
|
-
width: (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.headerWidth) != null ? _d : `${cell.column.getSize()}px`
|
|
2230
|
-
}, props), {
|
|
2231
|
-
children
|
|
2232
|
-
})
|
|
2233
|
-
);
|
|
2268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataGridCell, __spreadProps(__spreadValues({ style, ref: setNodeRef }, props), { children }));
|
|
2234
2269
|
}
|
|
2235
2270
|
DragAlongCell.displayName = "DragAlongCell";
|
|
2236
2271
|
|
|
2237
2272
|
// src/components/DataGrid/index.tsx
|
|
2238
|
-
var
|
|
2273
|
+
var import_react16 = __toESM(require("react"), 1);
|
|
2239
2274
|
var import_react_table3 = require("@tanstack/react-table");
|
|
2240
2275
|
var import_core = require("@dnd-kit/core");
|
|
2241
2276
|
var import_sortable2 = require("@dnd-kit/sortable");
|
|
@@ -2263,7 +2298,7 @@ function getSortIcon(sort, nextSort = false) {
|
|
|
2263
2298
|
}
|
|
2264
2299
|
|
|
2265
2300
|
// src/components/DataGrid/PinnedColumns.tsx
|
|
2266
|
-
var
|
|
2301
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
2267
2302
|
|
|
2268
2303
|
// src/components/DataGrid/TableBody/index.tsx
|
|
2269
2304
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
@@ -2272,7 +2307,7 @@ var import_clsx11 = __toESM(require("clsx"), 1);
|
|
|
2272
2307
|
// src/components/DataGrid/TableBody/TableBodyRow.tsx
|
|
2273
2308
|
var import_clsx10 = __toESM(require("clsx"), 1);
|
|
2274
2309
|
var import_react_table = require("@tanstack/react-table");
|
|
2275
|
-
var
|
|
2310
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
2276
2311
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2277
2312
|
function TableBodyRow({
|
|
2278
2313
|
id,
|
|
@@ -2322,13 +2357,13 @@ function TableBodyRow({
|
|
|
2322
2357
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { style: { display: "flex", width: virtualPaddingLeft } })
|
|
2323
2358
|
) : null,
|
|
2324
2359
|
columns.map((column) => {
|
|
2325
|
-
var _a2
|
|
2360
|
+
var _a2;
|
|
2326
2361
|
const cell = locked ? column : visibleCells[column.index];
|
|
2327
2362
|
if (!cell) {
|
|
2328
2363
|
return;
|
|
2329
2364
|
}
|
|
2330
2365
|
const cellValue = cell.getValue();
|
|
2331
|
-
return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2366
|
+
return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.default.Fragment, { children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2332
2367
|
CellElement,
|
|
2333
2368
|
{
|
|
2334
2369
|
id: id ? `${id}-row-${row.id}-cell-${cell.id}` : void 0,
|
|
@@ -2337,7 +2372,6 @@ function TableBodyRow({
|
|
|
2337
2372
|
className: (0, import_clsx10.default)({
|
|
2338
2373
|
"justify-end": typeof cellValue === "number"
|
|
2339
2374
|
}),
|
|
2340
|
-
width: (_c = (_b = cell.column.columnDef.meta) == null ? void 0 : _b.headerWidth) != null ? _c : `${cell.column.getSize()}px`,
|
|
2341
2375
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2342
2376
|
Tooltip,
|
|
2343
2377
|
{
|
|
@@ -2523,7 +2557,15 @@ function TableBody({
|
|
|
2523
2557
|
transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
|
|
2524
2558
|
},
|
|
2525
2559
|
className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
|
|
2526
|
-
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
|
+
))
|
|
2527
2569
|
}
|
|
2528
2570
|
)
|
|
2529
2571
|
]
|
|
@@ -2532,10 +2574,10 @@ function TableBody({
|
|
|
2532
2574
|
}
|
|
2533
2575
|
|
|
2534
2576
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
2535
|
-
var
|
|
2577
|
+
var import_react14 = require("react");
|
|
2536
2578
|
|
|
2537
2579
|
// src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx
|
|
2538
|
-
var
|
|
2580
|
+
var import_react13 = require("react");
|
|
2539
2581
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2540
2582
|
function ColumnSelectorMenuOption({
|
|
2541
2583
|
id,
|
|
@@ -2543,7 +2585,7 @@ function ColumnSelectorMenuOption({
|
|
|
2543
2585
|
column,
|
|
2544
2586
|
toggleColumnVisibility
|
|
2545
2587
|
}) {
|
|
2546
|
-
const [isVisible, setIsVisible] = (0,
|
|
2588
|
+
const [isVisible, setIsVisible] = (0, import_react13.useState)(column.getIsVisible());
|
|
2547
2589
|
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
2548
2590
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MenuOption, { id, testid, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2549
2591
|
Checkbox,
|
|
@@ -2569,8 +2611,8 @@ function ColumnSelectorHeaderCell({
|
|
|
2569
2611
|
toggleColumnVisibility,
|
|
2570
2612
|
resetColumnVisibility
|
|
2571
2613
|
}) {
|
|
2572
|
-
const ref = (0,
|
|
2573
|
-
const [show, setShow] = (0,
|
|
2614
|
+
const ref = (0, import_react14.useRef)(null);
|
|
2615
|
+
const [show, setShow] = (0, import_react14.useState)(false);
|
|
2574
2616
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2575
2617
|
DataGridCell,
|
|
2576
2618
|
{
|
|
@@ -2733,7 +2775,7 @@ function PinnedColumns(_a) {
|
|
|
2733
2775
|
header.id
|
|
2734
2776
|
);
|
|
2735
2777
|
}
|
|
2736
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react15.default.Fragment, { children: ((_c = header.column.columnDef.meta) == null ? void 0 : _c.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2737
2779
|
Checkbox,
|
|
2738
2780
|
{
|
|
2739
2781
|
checked: allSelectedAcrossPages,
|
|
@@ -2811,12 +2853,29 @@ function DataGrid({
|
|
|
2811
2853
|
useMenuDefaultMinWidth
|
|
2812
2854
|
}) {
|
|
2813
2855
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2814
|
-
const [
|
|
2815
|
-
|
|
2856
|
+
const [localSorting, setLocalSorting] = (0, import_react16.useState)([]);
|
|
2857
|
+
const [localColumnFilters, setLocalColumnFilters] = (0, import_react16.useState)([]);
|
|
2858
|
+
const [localRowSelection, setLocalRowSelection] = (0, import_react16.useState)({});
|
|
2859
|
+
const {
|
|
2860
|
+
columns: tableColumns,
|
|
2861
|
+
setColumns: setTableColumns,
|
|
2862
|
+
layoutSignal
|
|
2863
|
+
} = useTableLayout(columns, id != null ? id : testid);
|
|
2864
|
+
const [columnOrder, setColumnOrder] = (0, import_react16.useState)(
|
|
2865
|
+
tableColumns.map((c) => c.id)
|
|
2816
2866
|
);
|
|
2817
|
-
const [
|
|
2818
|
-
|
|
2819
|
-
|
|
2867
|
+
const [columnVisibility, setColumnVisibility] = (0, import_react16.useState)(
|
|
2868
|
+
Object.fromEntries(
|
|
2869
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
2870
|
+
var _a2, _b2;
|
|
2871
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
2872
|
+
})
|
|
2873
|
+
)
|
|
2874
|
+
);
|
|
2875
|
+
(0, import_react16.useEffect)(() => {
|
|
2876
|
+
setColumnOrder(tableColumns.map((c) => c.id));
|
|
2877
|
+
resetColumnVisibility();
|
|
2878
|
+
}, [layoutSignal]);
|
|
2820
2879
|
const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
|
|
2821
2880
|
const setSortingState = pagination ? (updaterOrValue) => {
|
|
2822
2881
|
const value = typeof updaterOrValue === "function" ? updaterOrValue(
|
|
@@ -2834,38 +2893,34 @@ function DataGrid({
|
|
|
2834
2893
|
const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
|
|
2835
2894
|
(onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
|
|
2836
2895
|
} : setLocalRowSelection;
|
|
2837
|
-
const dndId = (0,
|
|
2838
|
-
const containerRef =
|
|
2839
|
-
const
|
|
2840
|
-
const initialVisibility = {};
|
|
2841
|
-
columns.forEach((column) => {
|
|
2842
|
-
var _a2, _b2;
|
|
2843
|
-
if (column.id) {
|
|
2844
|
-
initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
|
|
2845
|
-
}
|
|
2846
|
-
});
|
|
2847
|
-
return initialVisibility;
|
|
2848
|
-
});
|
|
2849
|
-
const toggleColumnVisibility = (0, import_react15.useCallback)(
|
|
2896
|
+
const dndId = (0, import_react16.useId)();
|
|
2897
|
+
const containerRef = import_react16.default.useRef(null);
|
|
2898
|
+
const toggleColumnVisibility = (0, import_react16.useCallback)(
|
|
2850
2899
|
(columnId, isVisible) => {
|
|
2851
|
-
|
|
2900
|
+
setTableColumns((prev) => {
|
|
2901
|
+
const persistedIndex = prev.findIndex((col) => col.id === columnId);
|
|
2902
|
+
if (persistedIndex !== -1) {
|
|
2903
|
+
prev[persistedIndex].meta = __spreadProps(__spreadValues({}, prev[persistedIndex].meta), {
|
|
2904
|
+
visible: isVisible
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
return [...prev];
|
|
2908
|
+
}, true);
|
|
2852
2909
|
},
|
|
2853
|
-
[
|
|
2910
|
+
[setTableColumns]
|
|
2854
2911
|
);
|
|
2855
|
-
const resetColumnVisibility = (0,
|
|
2856
|
-
setColumnVisibility(
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
});
|
|
2866
|
-
}, [columns]);
|
|
2912
|
+
const resetColumnVisibility = (0, import_react16.useCallback)(() => {
|
|
2913
|
+
setColumnVisibility(
|
|
2914
|
+
Object.fromEntries(
|
|
2915
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
2916
|
+
var _a2, _b2;
|
|
2917
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
2918
|
+
})
|
|
2919
|
+
)
|
|
2920
|
+
);
|
|
2921
|
+
}, [tableColumns]);
|
|
2867
2922
|
const table = (0, import_react_table3.useReactTable)({
|
|
2868
|
-
columns,
|
|
2923
|
+
columns: tableColumns,
|
|
2869
2924
|
data,
|
|
2870
2925
|
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
2871
2926
|
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
@@ -2949,7 +3004,12 @@ function DataGrid({
|
|
|
2949
3004
|
setColumnOrder((prev) => {
|
|
2950
3005
|
const oldIndex = prev.indexOf(active.id);
|
|
2951
3006
|
const newIndex = prev.indexOf(over.id);
|
|
2952
|
-
|
|
3007
|
+
const newOrder = (0, import_sortable2.arrayMove)(prev, oldIndex, newIndex);
|
|
3008
|
+
setTableColumns((prev2) => {
|
|
3009
|
+
const res = newOrder.map((id2) => prev2.find((col) => col.id === id2)).filter(Boolean);
|
|
3010
|
+
return res;
|
|
3011
|
+
});
|
|
3012
|
+
return newOrder;
|
|
2953
3013
|
});
|
|
2954
3014
|
}
|
|
2955
3015
|
};
|
|
@@ -3035,23 +3095,21 @@ function DataGrid({
|
|
|
3035
3095
|
)
|
|
3036
3096
|
) : null,
|
|
3037
3097
|
virtualColumns.map((virtualColumn) => {
|
|
3038
|
-
var _a2, _b2, _c2
|
|
3098
|
+
var _a2, _b2, _c2;
|
|
3039
3099
|
const header = headerGroup.headers[virtualColumn.index];
|
|
3040
3100
|
if (!header) {
|
|
3041
3101
|
return;
|
|
3042
3102
|
}
|
|
3043
3103
|
if (typeof header.column.columnDef.header === "string") {
|
|
3044
|
-
const
|
|
3045
|
-
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);
|
|
3046
3105
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3047
3106
|
DraggableCellHeader,
|
|
3048
3107
|
{
|
|
3049
3108
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
3050
3109
|
testid: testid ? `${testid}-header-${header.id}` : void 0,
|
|
3051
3110
|
header,
|
|
3052
|
-
locked: (
|
|
3111
|
+
locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
|
|
3053
3112
|
center: centerHeader,
|
|
3054
|
-
width: customHeaderWidth,
|
|
3055
3113
|
className: (0, import_clsx13.default)(
|
|
3056
3114
|
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
3057
3115
|
"group",
|
|
@@ -3092,7 +3150,7 @@ function DataGrid({
|
|
|
3092
3150
|
header.id
|
|
3093
3151
|
);
|
|
3094
3152
|
}
|
|
3095
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
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)(
|
|
3096
3154
|
DataGridCell,
|
|
3097
3155
|
{
|
|
3098
3156
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
@@ -3296,7 +3354,7 @@ function adaptTableStateSetter(setter) {
|
|
|
3296
3354
|
}
|
|
3297
3355
|
|
|
3298
3356
|
// src/components/Select.tsx
|
|
3299
|
-
var
|
|
3357
|
+
var import_react17 = require("react");
|
|
3300
3358
|
var import_clsx14 = __toESM(require("clsx"), 1);
|
|
3301
3359
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3302
3360
|
var Select = (_a) => {
|
|
@@ -3329,11 +3387,11 @@ var Select = (_a) => {
|
|
|
3329
3387
|
"displayValue",
|
|
3330
3388
|
"value"
|
|
3331
3389
|
]);
|
|
3332
|
-
const inputRef = (0,
|
|
3333
|
-
const inputContainerRef = (0,
|
|
3334
|
-
const preventFocusOnInitialRender = (0,
|
|
3335
|
-
const [show, setShow] = (0,
|
|
3336
|
-
(0,
|
|
3390
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
3391
|
+
const inputContainerRef = (0, import_react17.useRef)(null);
|
|
3392
|
+
const preventFocusOnInitialRender = (0, import_react17.useRef)(true);
|
|
3393
|
+
const [show, setShow] = (0, import_react17.useState)(false);
|
|
3394
|
+
(0, import_react17.useEffect)(() => {
|
|
3337
3395
|
var _a2;
|
|
3338
3396
|
if (preventFocusOnInitialRender.current) {
|
|
3339
3397
|
preventFocusOnInitialRender.current = false;
|
|
@@ -3712,7 +3770,7 @@ Button.displayName = "Button";
|
|
|
3712
3770
|
|
|
3713
3771
|
// src/components/Tooltip.tsx
|
|
3714
3772
|
var import_clsx18 = __toESM(require("clsx"), 1);
|
|
3715
|
-
var
|
|
3773
|
+
var import_react18 = require("react");
|
|
3716
3774
|
var import_react_dom2 = require("react-dom");
|
|
3717
3775
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3718
3776
|
var Tooltip = ({
|
|
@@ -3725,11 +3783,11 @@ var Tooltip = ({
|
|
|
3725
3783
|
offset = 8,
|
|
3726
3784
|
keepHidden = false
|
|
3727
3785
|
}) => {
|
|
3728
|
-
const ref = (0,
|
|
3729
|
-
const tooltipRef = (0,
|
|
3730
|
-
const [tooltipPosition, setTooltipPosition] = (0,
|
|
3731
|
-
const [isVisible, setIsVisible] = (0,
|
|
3732
|
-
const [removeOpacity, setRemoveOpacity] = (0,
|
|
3786
|
+
const ref = (0, import_react18.useRef)(null);
|
|
3787
|
+
const tooltipRef = (0, import_react18.useRef)(null);
|
|
3788
|
+
const [tooltipPosition, setTooltipPosition] = (0, import_react18.useState)({ top: 0, left: 0 });
|
|
3789
|
+
const [isVisible, setIsVisible] = (0, import_react18.useState)(false);
|
|
3790
|
+
const [removeOpacity, setRemoveOpacity] = (0, import_react18.useState)(false);
|
|
3733
3791
|
const updatePosition = () => {
|
|
3734
3792
|
if (!ref.current || !tooltipRef.current) return;
|
|
3735
3793
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -3768,14 +3826,14 @@ var Tooltip = ({
|
|
|
3768
3826
|
setIsVisible(false);
|
|
3769
3827
|
setRemoveOpacity(false);
|
|
3770
3828
|
};
|
|
3771
|
-
(0,
|
|
3829
|
+
(0, import_react18.useEffect)(() => {
|
|
3772
3830
|
if (isVisible && tooltipRef.current) {
|
|
3773
3831
|
requestAnimationFrame(() => {
|
|
3774
3832
|
updatePosition();
|
|
3775
3833
|
});
|
|
3776
3834
|
}
|
|
3777
3835
|
}, [isVisible]);
|
|
3778
|
-
(0,
|
|
3836
|
+
(0, import_react18.useEffect)(() => {
|
|
3779
3837
|
if (isVisible) {
|
|
3780
3838
|
window.addEventListener("resize", updatePosition);
|
|
3781
3839
|
return () => window.removeEventListener("resize", updatePosition);
|