lecom-ui 5.4.32 → 5.4.33
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/components/Combobox/Combobox.js +178 -42
- package/dist/components/CustomTagInput/CustomTagInput.js +27 -18
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/DataTable/DataTable.utils.js +1 -1
- package/dist/components/DataTable/Table.js +1 -1
- package/dist/components/Header/SearchInput.js +4 -1
- package/dist/components/Input/Input.js +2 -2
- package/dist/components/Layout/Layout.js +3 -0
- package/dist/components/MultiSelect/MultiSelect.js +238 -124
- package/dist/components/Pagination/Pagination.js +20 -5
- package/dist/components/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/TagInput/TagInput.js +44 -17
- package/dist/i18n/locales/en_us.js +4 -2
- package/dist/i18n/locales/es_es.js +4 -2
- package/dist/i18n/locales/pt_br.js +4 -2
- package/dist/index.d.ts +24 -14
- package/dist/style.min.css +1 -1
- package/package.json +1 -1
|
@@ -56,13 +56,17 @@ const MultiSelect = React.forwardRef(
|
|
|
56
56
|
allowTypoDistance = 0,
|
|
57
57
|
groupedOptions,
|
|
58
58
|
classNameContent,
|
|
59
|
-
size = "medium"
|
|
59
|
+
size = "medium",
|
|
60
|
+
disabled = false,
|
|
61
|
+
readOnly = false
|
|
60
62
|
}, ref) => {
|
|
61
63
|
const { t } = useTranslation();
|
|
62
64
|
const [selectedValues, setSelectedValues] = React.useState(value);
|
|
63
65
|
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
|
|
64
66
|
const [query, setQuery] = React.useState("");
|
|
65
|
-
const [dynamicMaxCount, setDynamicMaxCount] = React.useState(
|
|
67
|
+
const [dynamicMaxCount, setDynamicMaxCount] = React.useState(
|
|
68
|
+
selectedValues.length || 1
|
|
69
|
+
);
|
|
66
70
|
const buttonRef = React.useRef(null);
|
|
67
71
|
React.useEffect(() => {
|
|
68
72
|
const shallowEqual = (a, b) => {
|
|
@@ -166,11 +170,13 @@ const MultiSelect = React.forwardRef(
|
|
|
166
170
|
}
|
|
167
171
|
};
|
|
168
172
|
const toggleOption = (option) => {
|
|
173
|
+
if (readOnly) return;
|
|
169
174
|
const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter((value2) => value2 !== option) : [...selectedValues, option];
|
|
170
175
|
setSelectedValues(newSelectedValues);
|
|
171
176
|
onValueChange(newSelectedValues);
|
|
172
177
|
};
|
|
173
178
|
const handleClear = () => {
|
|
179
|
+
if (readOnly) return;
|
|
174
180
|
setSelectedValues([]);
|
|
175
181
|
onValueChange([]);
|
|
176
182
|
};
|
|
@@ -178,6 +184,7 @@ const MultiSelect = React.forwardRef(
|
|
|
178
184
|
setIsPopoverOpen((prev) => !prev);
|
|
179
185
|
};
|
|
180
186
|
const toggleAll = () => {
|
|
187
|
+
if (readOnly) return;
|
|
181
188
|
if (treeOptions && treeOptions.length) {
|
|
182
189
|
const gather = (acc, nodes) => {
|
|
183
190
|
for (const n of nodes) {
|
|
@@ -340,7 +347,10 @@ const MultiSelect = React.forwardRef(
|
|
|
340
347
|
if (!node.children || node.children.length === 0) {
|
|
341
348
|
return [node.value];
|
|
342
349
|
}
|
|
343
|
-
return [
|
|
350
|
+
return [
|
|
351
|
+
node.value,
|
|
352
|
+
...node.children.flatMap((c) => collectAllValues(c))
|
|
353
|
+
];
|
|
344
354
|
}
|
|
345
355
|
};
|
|
346
356
|
const isNodeFullySelected = (node) => {
|
|
@@ -371,6 +381,7 @@ const MultiSelect = React.forwardRef(
|
|
|
371
381
|
}
|
|
372
382
|
};
|
|
373
383
|
const toggleTreeNode = (node) => {
|
|
384
|
+
if (readOnly) return;
|
|
374
385
|
if (treeSelectionStrategy === "all") {
|
|
375
386
|
const isSelected = selectedValues.includes(node.value);
|
|
376
387
|
const next = isSelected ? selectedValues.filter((v) => v !== node.value) : [...selectedValues, node.value];
|
|
@@ -454,7 +465,8 @@ const MultiSelect = React.forwardRef(
|
|
|
454
465
|
{
|
|
455
466
|
className: cn(
|
|
456
467
|
"flex items-center gap-2 px-2 py-1 cursor-pointer rounded-sm text-grey-800 hover:bg-grey-100",
|
|
457
|
-
(fully || isSelectedLeaf) && "bg-blue-50"
|
|
468
|
+
(fully || isSelectedLeaf) && "bg-blue-50",
|
|
469
|
+
readOnly && "cursor-default hover:bg-transparent"
|
|
458
470
|
),
|
|
459
471
|
style: { paddingLeft: depth * 14 + 8 }
|
|
460
472
|
},
|
|
@@ -467,7 +479,9 @@ const MultiSelect = React.forwardRef(
|
|
|
467
479
|
),
|
|
468
480
|
onClick: (e) => {
|
|
469
481
|
e.stopPropagation();
|
|
470
|
-
|
|
482
|
+
if (!readOnly) {
|
|
483
|
+
toggleTreeNode(n);
|
|
484
|
+
}
|
|
471
485
|
}
|
|
472
486
|
},
|
|
473
487
|
fully && /* @__PURE__ */ React.createElement(Check, { className: "!h-3 !w-3 !text-white", strokeWidth: 3 }),
|
|
@@ -480,7 +494,9 @@ const MultiSelect = React.forwardRef(
|
|
|
480
494
|
className: "flex-1 truncate cursor-pointer overflow-hidden",
|
|
481
495
|
onClick: (e) => {
|
|
482
496
|
e.stopPropagation();
|
|
483
|
-
|
|
497
|
+
if (!readOnly) {
|
|
498
|
+
toggleTreeNode(n);
|
|
499
|
+
}
|
|
484
500
|
},
|
|
485
501
|
title: n.label
|
|
486
502
|
},
|
|
@@ -514,40 +530,62 @@ const MultiSelect = React.forwardRef(
|
|
|
514
530
|
transition-all duration-300 outline-none
|
|
515
531
|
[&_svg]:pointer-events-auto`,
|
|
516
532
|
maxCount === void 0 && TRIGGER_HEIGHT_CLASSES[size],
|
|
533
|
+
disabled && "opacity-50 cursor-not-allowed pointer-events-none",
|
|
534
|
+
readOnly && !disabled && "opacity-50 hover:border-grey-400",
|
|
517
535
|
className
|
|
518
536
|
),
|
|
519
|
-
"aria-expanded": isPopoverOpen
|
|
537
|
+
"aria-expanded": isPopoverOpen,
|
|
538
|
+
"aria-readonly": readOnly,
|
|
539
|
+
disabled
|
|
520
540
|
},
|
|
521
541
|
selectedValues.length > 0 ? /* @__PURE__ */ React.createElement("div", { className: "flex justify-between items-center w-full" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap items-center gap-1" }, selectedValues.slice(0, dynamicMaxCount).map((value2) => {
|
|
522
|
-
const selectedOption = options.find(
|
|
542
|
+
const selectedOption = options.find(
|
|
543
|
+
(option) => option.value === value2
|
|
544
|
+
);
|
|
523
545
|
const label = findTreeLabel(value2) || selectedOption?.label || value2;
|
|
524
546
|
const prefix = selectedOption?.prefix;
|
|
525
|
-
return /* @__PURE__ */ React.createElement(
|
|
526
|
-
|
|
527
|
-
{
|
|
528
|
-
className: "flex items-center flex-shrink-0 [&_svg]:text-blue-600",
|
|
529
|
-
textColor: "text-blue-600"
|
|
530
|
-
},
|
|
531
|
-
prefix
|
|
532
|
-
), /* @__PURE__ */ React.createElement(
|
|
533
|
-
Typography,
|
|
547
|
+
return /* @__PURE__ */ React.createElement(
|
|
548
|
+
Tag,
|
|
534
549
|
{
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
className: "
|
|
550
|
+
key: value2,
|
|
551
|
+
color: "blue",
|
|
552
|
+
className: "focus:ring-0 flex items-center gap-2 max-w-[15.625rem]"
|
|
538
553
|
},
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
554
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 truncate min-w-0" }, prefix && /* @__PURE__ */ React.createElement(
|
|
555
|
+
Typography,
|
|
556
|
+
{
|
|
557
|
+
className: "flex items-center flex-shrink-0 [&_svg]:text-blue-600",
|
|
558
|
+
textColor: "text-blue-600"
|
|
559
|
+
},
|
|
560
|
+
prefix
|
|
561
|
+
), /* @__PURE__ */ React.createElement(
|
|
562
|
+
Typography,
|
|
563
|
+
{
|
|
564
|
+
variant: getFontVariant(size),
|
|
565
|
+
textColor: "text-blue-600",
|
|
566
|
+
className: "truncate"
|
|
567
|
+
},
|
|
568
|
+
label
|
|
569
|
+
)),
|
|
570
|
+
!disabled && !readOnly && /* @__PURE__ */ React.createElement(
|
|
571
|
+
X,
|
|
572
|
+
{
|
|
573
|
+
className: "h-4 w-4 cursor-pointer flex-shrink-0",
|
|
574
|
+
onClick: (event) => {
|
|
575
|
+
event.stopPropagation();
|
|
576
|
+
toggleOption(value2);
|
|
577
|
+
}
|
|
547
578
|
}
|
|
548
|
-
|
|
549
|
-
)
|
|
550
|
-
}), selectedValues.length > dynamicMaxCount && /* @__PURE__ */ React.createElement(Tag, { color: "blue", className: "focus:ring-0" }, /* @__PURE__ */ React.createElement(
|
|
579
|
+
)
|
|
580
|
+
);
|
|
581
|
+
}), selectedValues.length > dynamicMaxCount && /* @__PURE__ */ React.createElement(Tag, { color: "blue", className: "focus:ring-0" }, /* @__PURE__ */ React.createElement(
|
|
582
|
+
Typography,
|
|
583
|
+
{
|
|
584
|
+
variant: getFontVariant(size),
|
|
585
|
+
className: "text-blue-600"
|
|
586
|
+
},
|
|
587
|
+
`+ ${selectedValues.length - dynamicMaxCount}`
|
|
588
|
+
))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between" }, !disabled && !readOnly && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
551
589
|
X,
|
|
552
590
|
{
|
|
553
591
|
className: "h-4 w-4 cursor-pointer text-grey-800",
|
|
@@ -562,11 +600,11 @@ const MultiSelect = React.forwardRef(
|
|
|
562
600
|
orientation: "vertical",
|
|
563
601
|
className: "flex min-h-4 mx-1 h-full"
|
|
564
602
|
}
|
|
565
|
-
), isPopoverOpen ? /* @__PURE__ */ React.createElement(ChevronUp, { className: "h-4 w-4 cursor-pointer text-grey-800" }) : /* @__PURE__ */ React.createElement(ChevronDown, { className: "h-4 w-4 cursor-pointer text-grey-800" }))) : /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between w-full mx-auto" }, /* @__PURE__ */ React.createElement(
|
|
603
|
+
)), isPopoverOpen ? /* @__PURE__ */ React.createElement(ChevronUp, { className: "h-4 w-4 cursor-pointer text-grey-800" }) : /* @__PURE__ */ React.createElement(ChevronDown, { className: "h-4 w-4 cursor-pointer text-grey-800" }))) : /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between w-full mx-auto" }, /* @__PURE__ */ React.createElement(
|
|
566
604
|
Typography,
|
|
567
605
|
{
|
|
568
606
|
variant: getFontVariant(size),
|
|
569
|
-
className: "text-grey-
|
|
607
|
+
className: "text-grey-500 mx-3"
|
|
570
608
|
},
|
|
571
609
|
placeholder
|
|
572
610
|
), isPopoverOpen ? /* @__PURE__ */ React.createElement(ChevronUp, { className: "h-4 cursor-pointer text-grey-800 mx-2" }) : /* @__PURE__ */ React.createElement(ChevronDown, { className: "h-4 cursor-pointer text-grey-800 mx-2" }))
|
|
@@ -583,114 +621,165 @@ const MultiSelect = React.forwardRef(
|
|
|
583
621
|
align: "start",
|
|
584
622
|
onEscapeKeyDown: () => setIsPopoverOpen(false)
|
|
585
623
|
},
|
|
586
|
-
!isTree && /* @__PURE__ */ React.createElement(
|
|
587
|
-
|
|
624
|
+
!isTree && /* @__PURE__ */ React.createElement(
|
|
625
|
+
Command,
|
|
588
626
|
{
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
value: query,
|
|
592
|
-
onValueChange: (v) => setQuery(v)
|
|
593
|
-
}
|
|
594
|
-
), /* @__PURE__ */ React.createElement(CommandList, null, /* @__PURE__ */ React.createElement(CommandGroup, null, (effectiveOptions.length === 0 || query && filteredOptions.length === 0) && /* @__PURE__ */ React.createElement(CommandEmpty, { className: cn("p-4 text-center text-grey-800", getFontVariant(size)) }, t("multiSelect.empty")), !query && effectiveOptions.length > 0 && /* @__PURE__ */ React.createElement(
|
|
595
|
-
CommandItem,
|
|
596
|
-
{
|
|
597
|
-
key: "all",
|
|
598
|
-
onSelect: toggleAll,
|
|
599
|
-
className: "cursor-pointer"
|
|
627
|
+
shouldFilter: false,
|
|
628
|
+
className: SEARCH_INPUT_CLASSES[size]
|
|
600
629
|
},
|
|
601
630
|
/* @__PURE__ */ React.createElement(
|
|
602
|
-
|
|
631
|
+
CommandInput,
|
|
603
632
|
{
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
)
|
|
608
|
-
|
|
609
|
-
|
|
633
|
+
placeholder: treeSearchPlaceholder || t("multiSelect.search"),
|
|
634
|
+
onKeyDown: handleInputKeyDown,
|
|
635
|
+
value: query,
|
|
636
|
+
onValueChange: (v) => setQuery(v),
|
|
637
|
+
disabled: readOnly
|
|
638
|
+
}
|
|
610
639
|
),
|
|
611
|
-
/* @__PURE__ */ React.createElement(
|
|
612
|
-
|
|
640
|
+
/* @__PURE__ */ React.createElement(CommandList, null, /* @__PURE__ */ React.createElement(CommandGroup, null, (effectiveOptions.length === 0 || query && filteredOptions.length === 0) && /* @__PURE__ */ React.createElement(
|
|
641
|
+
CommandEmpty,
|
|
613
642
|
{
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
selectAllLabel ?? t("multiSelect.selectAll")
|
|
618
|
-
)
|
|
619
|
-
), isGrouped ? Object.entries(groupedOptions).map(
|
|
620
|
-
([categoryName, categoryOptions]) => {
|
|
621
|
-
const filtered = categoryOptions.filter(
|
|
622
|
-
(opt) => !query || effectiveOptions.some(
|
|
623
|
-
(eff) => eff.value === opt.value && filteredOptions.some(
|
|
624
|
-
(filt) => filt.value === opt.value
|
|
625
|
-
)
|
|
643
|
+
className: cn(
|
|
644
|
+
"p-4 text-center text-grey-800",
|
|
645
|
+
getFontVariant(size)
|
|
626
646
|
)
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
const isSelected = selectedValues.includes(
|
|
631
|
-
option.value
|
|
632
|
-
);
|
|
633
|
-
return /* @__PURE__ */ React.createElement(
|
|
634
|
-
CommandItem,
|
|
635
|
-
{
|
|
636
|
-
key: option.value,
|
|
637
|
-
onSelect: () => toggleOption(option.value),
|
|
638
|
-
className: "cursor-pointer"
|
|
639
|
-
},
|
|
640
|
-
/* @__PURE__ */ React.createElement(
|
|
641
|
-
"div",
|
|
642
|
-
{
|
|
643
|
-
className: cn(
|
|
644
|
-
"flex h-4 w-4 items-center justify-center rounded-sm border-2 border-grey-400 flex-shrink-0",
|
|
645
|
-
isSelected ? "bg-blue-600 border-blue-600 text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
646
|
-
)
|
|
647
|
-
},
|
|
648
|
-
/* @__PURE__ */ React.createElement(Check, { className: "!h-3 !w-3 !text-white", strokeWidth: 3 })
|
|
649
|
-
),
|
|
650
|
-
/* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 truncate min-w-0" }, option.prefix && /* @__PURE__ */ React.createElement(Typography, { className: "flex items-center flex-shrink-0" }, option.prefix), /* @__PURE__ */ React.createElement(
|
|
651
|
-
Typography,
|
|
652
|
-
{
|
|
653
|
-
variant: getFontVariant(size),
|
|
654
|
-
className: "text-grey-800 truncate overflow-hidden",
|
|
655
|
-
title: option.label
|
|
656
|
-
},
|
|
657
|
-
highlight(option.label, query)
|
|
658
|
-
))
|
|
659
|
-
);
|
|
660
|
-
}));
|
|
661
|
-
}
|
|
662
|
-
) : filteredOptions.map((option) => {
|
|
663
|
-
const isSelected = selectedValues.includes(
|
|
664
|
-
option.value
|
|
665
|
-
);
|
|
666
|
-
return /* @__PURE__ */ React.createElement(
|
|
647
|
+
},
|
|
648
|
+
t("multiSelect.empty")
|
|
649
|
+
), !query && effectiveOptions.length > 0 && /* @__PURE__ */ React.createElement(
|
|
667
650
|
CommandItem,
|
|
668
651
|
{
|
|
669
|
-
key:
|
|
670
|
-
onSelect:
|
|
671
|
-
className:
|
|
652
|
+
key: "all",
|
|
653
|
+
onSelect: readOnly ? void 0 : toggleAll,
|
|
654
|
+
className: cn(
|
|
655
|
+
"cursor-pointer",
|
|
656
|
+
readOnly && "cursor-default pointer-events-none hover:bg-transparent"
|
|
657
|
+
)
|
|
672
658
|
},
|
|
673
659
|
/* @__PURE__ */ React.createElement(
|
|
674
660
|
"div",
|
|
675
661
|
{
|
|
676
662
|
className: cn(
|
|
677
|
-
"flex h-4 w-4 items-center justify-center rounded-sm border border-grey-800
|
|
678
|
-
|
|
663
|
+
"flex h-4 w-4 items-center justify-center rounded-sm border border-grey-800",
|
|
664
|
+
selectedValues.length > 0 ? "bg-blue-600 border-blue-600 text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
679
665
|
)
|
|
680
666
|
},
|
|
681
|
-
/* @__PURE__ */ React.createElement(
|
|
667
|
+
selectedValues.length === effectiveOptions.length ? /* @__PURE__ */ React.createElement(
|
|
668
|
+
Check,
|
|
669
|
+
{
|
|
670
|
+
className: "!h-3 !w-3 !text-white",
|
|
671
|
+
strokeWidth: 3
|
|
672
|
+
}
|
|
673
|
+
) : /* @__PURE__ */ React.createElement(
|
|
674
|
+
Minus,
|
|
675
|
+
{
|
|
676
|
+
className: "!h-3 !w-3 !text-white",
|
|
677
|
+
strokeWidth: 3
|
|
678
|
+
}
|
|
679
|
+
)
|
|
682
680
|
),
|
|
683
|
-
/* @__PURE__ */ React.createElement(
|
|
681
|
+
/* @__PURE__ */ React.createElement(
|
|
684
682
|
Typography,
|
|
685
683
|
{
|
|
686
684
|
variant: getFontVariant(size),
|
|
687
|
-
className: "text-grey-800
|
|
688
|
-
title: option.label
|
|
685
|
+
className: "text-grey-800"
|
|
689
686
|
},
|
|
690
|
-
|
|
691
|
-
)
|
|
692
|
-
)
|
|
693
|
-
|
|
687
|
+
selectAllLabel ?? t("multiSelect.selectAll")
|
|
688
|
+
)
|
|
689
|
+
), isGrouped ? Object.entries(groupedOptions).map(
|
|
690
|
+
([categoryName, categoryOptions]) => {
|
|
691
|
+
const filtered = categoryOptions.filter(
|
|
692
|
+
(opt) => !query || effectiveOptions.some(
|
|
693
|
+
(eff) => eff.value === opt.value && filteredOptions.some(
|
|
694
|
+
(filt) => filt.value === opt.value
|
|
695
|
+
)
|
|
696
|
+
)
|
|
697
|
+
);
|
|
698
|
+
if (!filtered.length) return null;
|
|
699
|
+
return /* @__PURE__ */ React.createElement("div", { key: categoryName }, /* @__PURE__ */ React.createElement("div", { className: "px-2 py-2 text-xs font-medium text-muted-foreground" }, categoryName), filtered.map((option) => {
|
|
700
|
+
const isSelected = selectedValues.includes(
|
|
701
|
+
option.value
|
|
702
|
+
);
|
|
703
|
+
return /* @__PURE__ */ React.createElement(
|
|
704
|
+
CommandItem,
|
|
705
|
+
{
|
|
706
|
+
key: option.value,
|
|
707
|
+
onSelect: readOnly ? void 0 : () => toggleOption(option.value),
|
|
708
|
+
className: cn(
|
|
709
|
+
"cursor-pointer",
|
|
710
|
+
readOnly && "cursor-default pointer-events-none hover:bg-transparent"
|
|
711
|
+
)
|
|
712
|
+
},
|
|
713
|
+
/* @__PURE__ */ React.createElement(
|
|
714
|
+
"div",
|
|
715
|
+
{
|
|
716
|
+
className: cn(
|
|
717
|
+
"flex h-4 w-4 items-center justify-center rounded-sm border-2 border-grey-400 flex-shrink-0",
|
|
718
|
+
isSelected ? "bg-blue-600 border-blue-600 text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
719
|
+
)
|
|
720
|
+
},
|
|
721
|
+
/* @__PURE__ */ React.createElement(
|
|
722
|
+
Check,
|
|
723
|
+
{
|
|
724
|
+
className: "!h-3 !w-3 !text-white",
|
|
725
|
+
strokeWidth: 3
|
|
726
|
+
}
|
|
727
|
+
)
|
|
728
|
+
),
|
|
729
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 truncate min-w-0" }, option.prefix && /* @__PURE__ */ React.createElement(Typography, { className: "flex items-center flex-shrink-0" }, option.prefix), /* @__PURE__ */ React.createElement(
|
|
730
|
+
Typography,
|
|
731
|
+
{
|
|
732
|
+
variant: getFontVariant(size),
|
|
733
|
+
className: "text-grey-800 truncate overflow-hidden",
|
|
734
|
+
title: option.label
|
|
735
|
+
},
|
|
736
|
+
highlight(option.label, query)
|
|
737
|
+
))
|
|
738
|
+
);
|
|
739
|
+
}));
|
|
740
|
+
}
|
|
741
|
+
) : filteredOptions.map((option) => {
|
|
742
|
+
const isSelected = selectedValues.includes(
|
|
743
|
+
option.value
|
|
744
|
+
);
|
|
745
|
+
return /* @__PURE__ */ React.createElement(
|
|
746
|
+
CommandItem,
|
|
747
|
+
{
|
|
748
|
+
key: option.value,
|
|
749
|
+
onSelect: readOnly ? void 0 : () => toggleOption(option.value),
|
|
750
|
+
className: cn(
|
|
751
|
+
"cursor-pointer",
|
|
752
|
+
readOnly && "cursor-default pointer-events-none hover:bg-transparent"
|
|
753
|
+
)
|
|
754
|
+
},
|
|
755
|
+
/* @__PURE__ */ React.createElement(
|
|
756
|
+
"div",
|
|
757
|
+
{
|
|
758
|
+
className: cn(
|
|
759
|
+
"flex h-4 w-4 items-center justify-center rounded-sm border border-grey-800 flex-shrink-0",
|
|
760
|
+
isSelected ? "bg-blue-600 border-blue-600 text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
761
|
+
)
|
|
762
|
+
},
|
|
763
|
+
/* @__PURE__ */ React.createElement(
|
|
764
|
+
Check,
|
|
765
|
+
{
|
|
766
|
+
className: "!h-3 !w-3 !text-white",
|
|
767
|
+
strokeWidth: 3
|
|
768
|
+
}
|
|
769
|
+
)
|
|
770
|
+
),
|
|
771
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 truncate min-w-0" }, option.prefix && /* @__PURE__ */ React.createElement(Typography, { className: "flex items-center flex-shrink-0" }, option.prefix), /* @__PURE__ */ React.createElement(
|
|
772
|
+
Typography,
|
|
773
|
+
{
|
|
774
|
+
variant: getFontVariant(size),
|
|
775
|
+
className: "text-grey-800 truncate overflow-hidden",
|
|
776
|
+
title: option.label
|
|
777
|
+
},
|
|
778
|
+
highlight(option.label, query)
|
|
779
|
+
))
|
|
780
|
+
);
|
|
781
|
+
})))
|
|
782
|
+
),
|
|
694
783
|
isTree && /* @__PURE__ */ React.createElement("div", { className: "min-w-[260px] max-h-80 overflow-hidden flex flex-col" }, treeSearch && /* @__PURE__ */ React.createElement("div", { className: "px-1 pt-2 pb-0 border-b border-grey-300 flex-shrink-0" }, /* @__PURE__ */ React.createElement("div", { className: "relative" }, /* @__PURE__ */ React.createElement(
|
|
695
784
|
"svg",
|
|
696
785
|
{
|
|
@@ -715,6 +804,7 @@ const MultiSelect = React.forwardRef(
|
|
|
715
804
|
value: treeQuery,
|
|
716
805
|
onChange: (e) => setTreeQuery(e.target.value),
|
|
717
806
|
placeholder: treeSearchPlaceholder || t("multiSelect.search"),
|
|
807
|
+
disabled: readOnly,
|
|
718
808
|
className: cn(
|
|
719
809
|
"w-full pl-9 pr-3 border-0 focus:outline-none focus:ring-0 bg-transparent placeholder:text-muted-foreground",
|
|
720
810
|
getFontVariant(size),
|
|
@@ -724,8 +814,11 @@ const MultiSelect = React.forwardRef(
|
|
|
724
814
|
))), /* @__PURE__ */ React.createElement("div", { className: "px-2 pb-1 overflow-y-auto overflow-x-hidden [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb:hover]:bg-grey-400" }, !treeQuery && treeOptions && treeOptions.length > 0 && /* @__PURE__ */ React.createElement(
|
|
725
815
|
"div",
|
|
726
816
|
{
|
|
727
|
-
className:
|
|
728
|
-
|
|
817
|
+
className: cn(
|
|
818
|
+
"flex items-center gap-2 px-2 py-1 cursor-pointer rounded-sm hover:bg-accent",
|
|
819
|
+
readOnly && "cursor-default hover:bg-transparent pointer-events-none"
|
|
820
|
+
),
|
|
821
|
+
onClick: readOnly ? void 0 : toggleAll
|
|
729
822
|
},
|
|
730
823
|
/* @__PURE__ */ React.createElement(
|
|
731
824
|
"div",
|
|
@@ -745,7 +838,19 @@ const MultiSelect = React.forwardRef(
|
|
|
745
838
|
acc += treeSelectionStrategy === "all" ? 1 + countAll(n.children) : countAll(n.children);
|
|
746
839
|
}
|
|
747
840
|
return acc;
|
|
748
|
-
}(treeOptions) ? /* @__PURE__ */ React.createElement(
|
|
841
|
+
}(treeOptions) ? /* @__PURE__ */ React.createElement(
|
|
842
|
+
Check,
|
|
843
|
+
{
|
|
844
|
+
className: "!h-3 !w-3 !text-white",
|
|
845
|
+
strokeWidth: 3
|
|
846
|
+
}
|
|
847
|
+
) : /* @__PURE__ */ React.createElement(
|
|
848
|
+
Minus,
|
|
849
|
+
{
|
|
850
|
+
className: "!h-3 !w-3 !text-white",
|
|
851
|
+
strokeWidth: 3
|
|
852
|
+
}
|
|
853
|
+
)
|
|
749
854
|
),
|
|
750
855
|
/* @__PURE__ */ React.createElement(
|
|
751
856
|
Typography,
|
|
@@ -755,7 +860,16 @@ const MultiSelect = React.forwardRef(
|
|
|
755
860
|
},
|
|
756
861
|
selectAllLabel ?? t("multiSelect.selectAll")
|
|
757
862
|
)
|
|
758
|
-
), !treeOptions || treeOptions.length === 0 || treeQuery && displayedTree.length === 0 ? /* @__PURE__ */ React.createElement(
|
|
863
|
+
), !treeOptions || treeOptions.length === 0 || treeQuery && displayedTree.length === 0 ? /* @__PURE__ */ React.createElement(
|
|
864
|
+
"div",
|
|
865
|
+
{
|
|
866
|
+
className: cn(
|
|
867
|
+
"p-4 text-center text-grey-800",
|
|
868
|
+
getFontVariant(size)
|
|
869
|
+
)
|
|
870
|
+
},
|
|
871
|
+
t("multiSelect.empty")
|
|
872
|
+
) : renderTree(displayedTree)))
|
|
759
873
|
)
|
|
760
874
|
);
|
|
761
875
|
}
|
|
@@ -145,7 +145,8 @@ const PaginationPerPage = ({
|
|
|
145
145
|
className,
|
|
146
146
|
onChangePerPage,
|
|
147
147
|
perPage,
|
|
148
|
-
totalRowsSelected = 0
|
|
148
|
+
totalRowsSelected = 0,
|
|
149
|
+
maxSelection
|
|
149
150
|
}) => {
|
|
150
151
|
const { t } = useTranslation();
|
|
151
152
|
const perPageOptions = [
|
|
@@ -165,6 +166,12 @@ const PaginationPerPage = ({
|
|
|
165
166
|
if (!onChangePerPage) {
|
|
166
167
|
return null;
|
|
167
168
|
}
|
|
169
|
+
const getSelectedText = () => {
|
|
170
|
+
if (maxSelection === 1 && totalRowsSelected === 1) {
|
|
171
|
+
return `${totalRowsSelected} ${t("pagination.selectedItemSingular")}`;
|
|
172
|
+
}
|
|
173
|
+
return `${totalRowsSelected} ${t("pagination.selectedProcess")}`;
|
|
174
|
+
};
|
|
168
175
|
return /* @__PURE__ */ React.createElement("div", { className: cn("flex items-center gap-4", className) }, /* @__PURE__ */ React.createElement(DropdownMenu, null, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(Button, { size: "small", color: "grey", variant: "outlined" }, /* @__PURE__ */ React.createElement("span", { className: "max-md:hidden" }, t("pagination.show")), " ", perPage, /* @__PURE__ */ React.createElement(ChevronDown, { size: 20 }))), /* @__PURE__ */ React.createElement(DropdownMenuContent, { side: "top", align: "center" }, perPageOptions.map((option) => /* @__PURE__ */ React.createElement(
|
|
169
176
|
DropdownMenuItem,
|
|
170
177
|
{
|
|
@@ -174,7 +181,7 @@ const PaginationPerPage = ({
|
|
|
174
181
|
}
|
|
175
182
|
},
|
|
176
183
|
option.value.toString()
|
|
177
|
-
)))), totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" },
|
|
184
|
+
)))), totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, getSelectedText()));
|
|
178
185
|
};
|
|
179
186
|
PaginationPerPage.displayName = "PaginationPerPage";
|
|
180
187
|
const Pagination = ({
|
|
@@ -185,7 +192,8 @@ const Pagination = ({
|
|
|
185
192
|
onChangePerPage,
|
|
186
193
|
className,
|
|
187
194
|
activeColor,
|
|
188
|
-
showPerPageSelector = true
|
|
195
|
+
showPerPageSelector = true,
|
|
196
|
+
maxSelection
|
|
189
197
|
}) => {
|
|
190
198
|
const { t } = useTranslation();
|
|
191
199
|
const mapPaginationItem = (item) => {
|
|
@@ -215,6 +223,12 @@ const Pagination = ({
|
|
|
215
223
|
};
|
|
216
224
|
return React.createElement(mappedComponents[item.type], componentProps);
|
|
217
225
|
};
|
|
226
|
+
const getSelectedText = () => {
|
|
227
|
+
if (maxSelection === 1 && totalRowsSelected === 1) {
|
|
228
|
+
return `${totalRowsSelected} ${t("pagination.selectedItemSingular")}`;
|
|
229
|
+
}
|
|
230
|
+
return `${totalRowsSelected} ${t("pagination.selectedProcess")}`;
|
|
231
|
+
};
|
|
218
232
|
return /* @__PURE__ */ React.createElement(
|
|
219
233
|
"div",
|
|
220
234
|
{
|
|
@@ -225,10 +239,11 @@ const Pagination = ({
|
|
|
225
239
|
{
|
|
226
240
|
onChangePerPage,
|
|
227
241
|
perPage,
|
|
228
|
-
totalRowsSelected
|
|
242
|
+
totalRowsSelected,
|
|
243
|
+
maxSelection
|
|
229
244
|
}
|
|
230
245
|
),
|
|
231
|
-
!showPerPageSelector && totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" },
|
|
246
|
+
!showPerPageSelector && totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, getSelectedText()),
|
|
232
247
|
/* @__PURE__ */ React.createElement("nav", { role: "navigation", "aria-label": "pagination" }, /* @__PURE__ */ React.createElement(PaginationContent, null, itemsPage.map((item) => /* @__PURE__ */ React.createElement(PaginationItem, { key: item.id }, mapPaginationItem(item)))))
|
|
233
248
|
);
|
|
234
249
|
};
|
|
@@ -27,7 +27,7 @@ const ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...pr
|
|
|
27
27
|
),
|
|
28
28
|
...props
|
|
29
29
|
},
|
|
30
|
-
/* @__PURE__ */ React.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
|
|
30
|
+
/* @__PURE__ */ React.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border bg-grey-400 hover:bg-gray-500" })
|
|
31
31
|
));
|
|
32
32
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
33
33
|
|