@firecms/ui 3.0.0-canary.120 → 3.0.0-canary.121
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/MultiSelect.d.ts +33 -15
- package/dist/components/Select.d.ts +2 -6
- package/dist/components/Separator.d.ts +2 -1
- package/dist/components/_MultiSelect.d.ts +0 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/index.es.js +304 -447
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +304 -447
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/MultiSelect.tsx +336 -163
- package/src/components/Popover.tsx +1 -1
- package/src/components/Select.tsx +50 -57
- package/src/components/Separator.tsx +10 -4
- package/src/components/_MultiSelect.tsx +222 -0
- package/src/components/index.tsx +0 -1
- package/tailwind.config.js +3 -3
- package/dist/components/NewMultiSelect.d.ts +0 -60
- package/src/components/NewMultiSelect.tsx +0 -370
package/dist/index.es.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
import React__default, { useEffect, useState, useCallback, useRef, useMemo, forwardRef, useLayoutEffect, useDeferredValue } from "react";
|
3
|
+
import React__default, { useEffect, useState, useCallback, useRef, useMemo, Children, forwardRef, useLayoutEffect, useDeferredValue } from "react";
|
4
4
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
5
5
|
import { clsx } from "clsx";
|
6
6
|
import { twMerge } from "tailwind-merge";
|
@@ -15,8 +15,8 @@ import equal from "react-fast-compare";
|
|
15
15
|
import MarkdownIt from "markdown-it";
|
16
16
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
17
17
|
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
18
|
-
import { Command } from "cmdk";
|
19
18
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
19
|
+
import { Command } from "cmdk";
|
20
20
|
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
21
21
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
22
22
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
@@ -15501,485 +15501,279 @@ function MenubarShortcut({
|
|
15501
15501
|
function MenubarSubTriggerIndicator() {
|
15502
15502
|
return /* @__PURE__ */ jsx("div", { className: "ml-auto pl-5 ", children: /* @__PURE__ */ jsx(ChevronRightIcon, { size: "small" }) });
|
15503
15503
|
}
|
15504
|
-
function
|
15505
|
-
|
15506
|
-
|
15507
|
-
|
15508
|
-
), children });
|
15509
|
-
}
|
15510
|
-
const MultiSelectContext = React.createContext({});
|
15511
|
-
function MultiSelect({
|
15512
|
-
value,
|
15513
|
-
open,
|
15514
|
-
onMultiValueChange,
|
15515
|
-
size = "medium",
|
15516
|
-
label,
|
15517
|
-
disabled,
|
15518
|
-
renderValue,
|
15519
|
-
renderValues,
|
15520
|
-
containerClassName,
|
15521
|
-
className,
|
15522
|
-
children,
|
15523
|
-
error
|
15504
|
+
function Separator({
|
15505
|
+
orientation,
|
15506
|
+
decorative,
|
15507
|
+
className
|
15524
15508
|
}) {
|
15525
|
-
const containerRef = React.useRef(null);
|
15526
|
-
const inputRef = React.useRef(null);
|
15527
|
-
const listRef = React.useRef(null);
|
15528
|
-
useOutsideAlerter(listRef, () => setOpenInternal(false));
|
15529
|
-
const [openInternal, setOpenInternal] = React.useState(false);
|
15530
|
-
useEffect(() => {
|
15531
|
-
setOpenInternal(open ?? false);
|
15532
|
-
}, [open]);
|
15533
|
-
const onValueChangeInternal = React.useCallback((newValue) => {
|
15534
|
-
if (Array.isArray(value) && value.includes(newValue)) {
|
15535
|
-
onMultiValueChange?.(value.filter((v) => v !== newValue));
|
15536
|
-
} else {
|
15537
|
-
onMultiValueChange?.([...value ?? [], newValue]);
|
15538
|
-
}
|
15539
|
-
}, [value, onMultiValueChange]);
|
15540
|
-
const [inputValue, setInputValue] = React.useState("");
|
15541
|
-
const [boundingRect, setBoundingRect] = React.useState(null);
|
15542
|
-
const handleKeyDown = React.useCallback((e) => {
|
15543
|
-
const input = inputRef.current;
|
15544
|
-
if (input) {
|
15545
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
15546
|
-
if (input.value === "") {
|
15547
|
-
const newSelected = [...value ?? []];
|
15548
|
-
newSelected.pop();
|
15549
|
-
onMultiValueChange?.(newSelected);
|
15550
|
-
}
|
15551
|
-
}
|
15552
|
-
if (e.key === "Escape") {
|
15553
|
-
input.blur();
|
15554
|
-
setOpenInternal(false);
|
15555
|
-
e.stopPropagation();
|
15556
|
-
}
|
15557
|
-
}
|
15558
|
-
}, [onMultiValueChange, value]);
|
15559
|
-
const openDialog = React.useCallback(() => {
|
15560
|
-
setBoundingRect(containerRef.current?.getBoundingClientRect() ?? null);
|
15561
|
-
setOpenInternal(true);
|
15562
|
-
}, []);
|
15563
|
-
const usedBoundingRect = boundingRect ?? containerRef.current?.getBoundingClientRect();
|
15564
|
-
const maxHeight = window.innerHeight - (usedBoundingRect?.top ?? 0) - (usedBoundingRect?.height ?? 0) - 16;
|
15565
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
15566
|
-
typeof label === "string" ? /* @__PURE__ */ jsx(SelectInputLabel, { error, children: label }) : label,
|
15567
|
-
/* @__PURE__ */ jsxs(
|
15568
|
-
Command,
|
15569
|
-
{
|
15570
|
-
onKeyDown: handleKeyDown,
|
15571
|
-
onClick: () => {
|
15572
|
-
inputRef.current?.focus();
|
15573
|
-
openDialog();
|
15574
|
-
},
|
15575
|
-
className: cls("relative overflow-visible bg-transparent", containerClassName),
|
15576
|
-
children: [
|
15577
|
-
/* @__PURE__ */ jsxs(
|
15578
|
-
"div",
|
15579
|
-
{
|
15580
|
-
ref: containerRef,
|
15581
|
-
className: cls(
|
15582
|
-
"flex flex-row",
|
15583
|
-
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
15584
|
-
"select-none rounded-md text-sm",
|
15585
|
-
fieldBackgroundMixin,
|
15586
|
-
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
15587
|
-
"relative flex items-center",
|
15588
|
-
"p-4",
|
15589
|
-
error ? "text-red-500 dark:text-red-600" : "focus:text-text-primary dark:focus:text-text-primary-dark",
|
15590
|
-
error ? "border border-red-500 dark:border-red-600" : "",
|
15591
|
-
className
|
15592
|
-
),
|
15593
|
-
children: [
|
15594
|
-
/* @__PURE__ */ jsxs("div", { className: cls("flex-grow flex gap-1.5 flex-wrap items-center"), children: [
|
15595
|
-
renderValue && (value ?? []).map((v, i) => renderValue(v, i)),
|
15596
|
-
renderValues && renderValues(value ?? []),
|
15597
|
-
/* @__PURE__ */ jsx(
|
15598
|
-
Command.Input,
|
15599
|
-
{
|
15600
|
-
ref: inputRef,
|
15601
|
-
value: inputValue,
|
15602
|
-
onValueChange: setInputValue,
|
15603
|
-
onFocus: openDialog,
|
15604
|
-
className: cls("ml-2 bg-transparent outline-none flex-1 h-full w-full ", focusedDisabled)
|
15605
|
-
}
|
15606
|
-
)
|
15607
|
-
] }),
|
15608
|
-
/* @__PURE__ */ jsx("div", { className: "px-2 h-full flex items-center", children: /* @__PURE__ */ jsx(
|
15609
|
-
ExpandMoreIcon,
|
15610
|
-
{
|
15611
|
-
size: "small",
|
15612
|
-
className: cls("transition ", openInternal ? "rotate-180" : "")
|
15613
|
-
}
|
15614
|
-
) })
|
15615
|
-
]
|
15616
|
-
}
|
15617
|
-
),
|
15618
|
-
/* @__PURE__ */ jsx(
|
15619
|
-
DialogPrimitive.Root,
|
15620
|
-
{
|
15621
|
-
open: openInternal,
|
15622
|
-
modal: true,
|
15623
|
-
onOpenChange: setOpenInternal,
|
15624
|
-
children: /* @__PURE__ */ jsx(DialogPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
15625
|
-
MultiSelectContext.Provider,
|
15626
|
-
{
|
15627
|
-
value: {
|
15628
|
-
fieldValue: value,
|
15629
|
-
setInputValue,
|
15630
|
-
onValueChangeInternal
|
15631
|
-
},
|
15632
|
-
children: /* @__PURE__ */ jsx(
|
15633
|
-
"div",
|
15634
|
-
{
|
15635
|
-
ref: listRef,
|
15636
|
-
className: "z-50 absolute overflow-auto outline-none",
|
15637
|
-
style: {
|
15638
|
-
pointerEvents: openInternal ? "auto" : "none",
|
15639
|
-
top: (usedBoundingRect?.top ?? 0) + (usedBoundingRect?.height ?? 0),
|
15640
|
-
left: usedBoundingRect?.left,
|
15641
|
-
// right: boundingRect?.right,
|
15642
|
-
width: usedBoundingRect?.width,
|
15643
|
-
maxHeight
|
15644
|
-
},
|
15645
|
-
children: /* @__PURE__ */ jsx(
|
15646
|
-
Command.Group,
|
15647
|
-
{
|
15648
|
-
className: "mt-2 text-slate-900 dark:text-white animate-in z-50 border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-800 p-2 rounded-lg shadow-lg flex flex-col outline-none w-full",
|
15649
|
-
children
|
15650
|
-
}
|
15651
|
-
)
|
15652
|
-
}
|
15653
|
-
)
|
15654
|
-
}
|
15655
|
-
) })
|
15656
|
-
}
|
15657
|
-
)
|
15658
|
-
]
|
15659
|
-
}
|
15660
|
-
)
|
15661
|
-
] });
|
15662
|
-
}
|
15663
|
-
function MultiSelectItem({ children, value, className }) {
|
15664
|
-
const context = React.useContext(MultiSelectContext);
|
15665
|
-
if (!context) throw new Error("MultiSelectItem must be used inside a MultiSelect");
|
15666
|
-
const { fieldValue, setInputValue, onValueChangeInternal } = context;
|
15667
|
-
return /* @__PURE__ */ jsx(
|
15668
|
-
Command.Item,
|
15669
|
-
{
|
15670
|
-
onMouseDown: (e) => {
|
15671
|
-
e.preventDefault();
|
15672
|
-
e.stopPropagation();
|
15673
|
-
},
|
15674
|
-
onSelect: (_) => {
|
15675
|
-
setInputValue("");
|
15676
|
-
onValueChangeInternal(value);
|
15677
|
-
},
|
15678
|
-
className: cls(
|
15679
|
-
(fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
|
15680
|
-
"cursor-pointer",
|
15681
|
-
"m-1",
|
15682
|
-
"ring-offset-transparent",
|
15683
|
-
"p-2 rounded aria-[selected=true]:outline-none aria-[selected=true]:ring-2 aria-[selected=true]:ring-primary aria-[selected=true]:ring-opacity-75 aria-[selected=true]:ring-offset-2",
|
15684
|
-
"aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15685
|
-
"cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15686
|
-
className
|
15687
|
-
),
|
15688
|
-
children
|
15689
|
-
}
|
15690
|
-
);
|
15691
|
-
}
|
15692
|
-
function Separator({ orientation, decorative }) {
|
15693
15509
|
if (orientation === "horizontal")
|
15694
15510
|
return /* @__PURE__ */ jsx(
|
15695
15511
|
SeparatorPrimitive.Root,
|
15696
15512
|
{
|
15697
15513
|
decorative,
|
15698
15514
|
orientation: "horizontal",
|
15699
|
-
className: "dark:bg-opacity-
|
15515
|
+
className: cls("dark:bg-opacity-80 dark:bg-gray-800 bg-gray-100 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px my-4", className)
|
15700
15516
|
}
|
15701
15517
|
);
|
15702
15518
|
else
|
15703
15519
|
return /* @__PURE__ */ jsx(
|
15704
15520
|
SeparatorPrimitive.Root,
|
15705
15521
|
{
|
15706
|
-
className: "dark:bg-opacity-
|
15522
|
+
className: cls("dark:bg-opacity-80 dark:bg-gray-800 bg-gray-100 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px mx-4", className),
|
15707
15523
|
decorative,
|
15708
15524
|
orientation: "vertical"
|
15709
15525
|
}
|
15710
15526
|
);
|
15711
15527
|
}
|
15712
|
-
|
15528
|
+
function SelectInputLabel({ children, error }) {
|
15529
|
+
return /* @__PURE__ */ jsx("div", { className: cls(
|
15530
|
+
"text-sm font-medium ml-3.5 mb-1",
|
15531
|
+
error ? "text-red-500 dark:text-red-600" : "text-slate-500 dark:text-slate-300"
|
15532
|
+
), children });
|
15533
|
+
}
|
15534
|
+
const MultiSelectContext = React.createContext({});
|
15535
|
+
const MultiSelect = React.forwardRef(
|
15713
15536
|
({
|
15537
|
+
value,
|
15714
15538
|
size,
|
15715
|
-
|
15539
|
+
label,
|
15540
|
+
error,
|
15716
15541
|
onValueChange,
|
15717
15542
|
invisible,
|
15718
15543
|
disabled,
|
15719
|
-
|
15720
|
-
defaultValue = [],
|
15721
|
-
placeholder = "Select options",
|
15722
|
-
animation = 0,
|
15723
|
-
maxCount = 3,
|
15544
|
+
placeholder,
|
15724
15545
|
modalPopover = false,
|
15725
|
-
|
15546
|
+
includeClear = true,
|
15547
|
+
useChips = true,
|
15726
15548
|
className,
|
15727
|
-
|
15549
|
+
children,
|
15550
|
+
renderValues,
|
15551
|
+
open,
|
15552
|
+
onOpenChange
|
15728
15553
|
}, ref) => {
|
15729
|
-
const [
|
15730
|
-
const [
|
15554
|
+
const [isPopoverOpen, setIsPopoverOpen] = React.useState(open ?? false);
|
15555
|
+
const [selectedValues, setSelectedValues] = React.useState(value ?? []);
|
15556
|
+
console.log("selectedValues", selectedValues);
|
15557
|
+
const onPopoverOpenChange = (open2) => {
|
15558
|
+
setIsPopoverOpen(open2);
|
15559
|
+
onOpenChange?.(open2);
|
15560
|
+
};
|
15561
|
+
useEffect(() => {
|
15562
|
+
setIsPopoverOpen(open ?? false);
|
15563
|
+
}, [open]);
|
15564
|
+
const allValues = children ? (
|
15565
|
+
// @ts-ignore
|
15566
|
+
Children.map(children, (child) => {
|
15567
|
+
if (React.isValidElement(child)) {
|
15568
|
+
return child.props.value;
|
15569
|
+
}
|
15570
|
+
return null;
|
15571
|
+
}).filter(Boolean)
|
15572
|
+
) : [];
|
15731
15573
|
React.useEffect(() => {
|
15732
|
-
setSelectedValues(
|
15733
|
-
}, [
|
15574
|
+
setSelectedValues(value ?? []);
|
15575
|
+
}, [value]);
|
15576
|
+
function onItemClick(newValue) {
|
15577
|
+
let newSelectedValues;
|
15578
|
+
if (selectedValues.includes(newValue)) {
|
15579
|
+
newSelectedValues = selectedValues.filter((v) => v !== newValue);
|
15580
|
+
} else {
|
15581
|
+
newSelectedValues = [...selectedValues, newValue];
|
15582
|
+
}
|
15583
|
+
updateValues(newSelectedValues);
|
15584
|
+
}
|
15585
|
+
function updateValues(values) {
|
15586
|
+
setSelectedValues(values);
|
15587
|
+
onValueChange?.(values);
|
15588
|
+
}
|
15734
15589
|
const handleInputKeyDown = (event) => {
|
15735
15590
|
if (event.key === "Enter") {
|
15736
|
-
|
15591
|
+
onPopoverOpenChange(true);
|
15737
15592
|
} else if (event.key === "Backspace" && !event.currentTarget.value) {
|
15738
15593
|
const newSelectedValues = [...selectedValues];
|
15739
15594
|
newSelectedValues.pop();
|
15740
|
-
|
15741
|
-
onValueChange(newSelectedValues);
|
15595
|
+
updateValues(newSelectedValues);
|
15742
15596
|
}
|
15743
15597
|
};
|
15744
|
-
const toggleOption = (
|
15745
|
-
const newSelectedValues = selectedValues.includes(
|
15746
|
-
|
15747
|
-
onValueChange(newSelectedValues);
|
15598
|
+
const toggleOption = (value2) => {
|
15599
|
+
const newSelectedValues = selectedValues.includes(value2) ? selectedValues.filter((v) => v !== value2) : [...selectedValues, value2];
|
15600
|
+
updateValues(newSelectedValues);
|
15748
15601
|
};
|
15749
15602
|
const handleClear = () => {
|
15750
|
-
|
15751
|
-
onValueChange([]);
|
15603
|
+
updateValues([]);
|
15752
15604
|
};
|
15753
15605
|
const handleTogglePopover = () => {
|
15754
|
-
|
15755
|
-
};
|
15756
|
-
const clearExtraOptions = () => {
|
15757
|
-
const newSelectedValues = selectedValues.slice(0, maxCount);
|
15758
|
-
setSelectedValues(newSelectedValues);
|
15759
|
-
onValueChange(newSelectedValues);
|
15606
|
+
onPopoverOpenChange(!isPopoverOpen);
|
15760
15607
|
};
|
15761
15608
|
const toggleAll = () => {
|
15762
|
-
if (selectedValues.length ===
|
15609
|
+
if (selectedValues.length === allValues.length) {
|
15763
15610
|
handleClear();
|
15764
15611
|
} else {
|
15765
|
-
|
15766
|
-
setSelectedValues(allValues);
|
15767
|
-
onValueChange(allValues);
|
15612
|
+
updateValues(allValues);
|
15768
15613
|
}
|
15769
15614
|
};
|
15615
|
+
useInjectStyles("MultiSelect", `
|
15616
|
+
[cmdk-group] {
|
15617
|
+
max-height: 45vh;
|
15618
|
+
overflow-y: auto;
|
15619
|
+
// width: 400px;
|
15620
|
+
} `);
|
15770
15621
|
return /* @__PURE__ */ jsxs(
|
15771
|
-
|
15622
|
+
MultiSelectContext.Provider,
|
15772
15623
|
{
|
15773
|
-
|
15774
|
-
|
15775
|
-
|
15624
|
+
value: {
|
15625
|
+
fieldValue: selectedValues,
|
15626
|
+
onItemClick
|
15627
|
+
},
|
15776
15628
|
children: [
|
15777
|
-
/* @__PURE__ */ jsx(
|
15778
|
-
|
15629
|
+
typeof label === "string" ? /* @__PURE__ */ jsx(SelectInputLabel, { error, children: label }) : label,
|
15630
|
+
/* @__PURE__ */ jsxs(
|
15631
|
+
PopoverPrimitive.Root,
|
15779
15632
|
{
|
15780
|
-
|
15781
|
-
|
15782
|
-
|
15783
|
-
|
15784
|
-
|
15785
|
-
|
15786
|
-
|
15787
|
-
|
15788
|
-
|
15789
|
-
|
15790
|
-
|
15791
|
-
|
15792
|
-
|
15793
|
-
|
15794
|
-
|
15795
|
-
|
15796
|
-
|
15797
|
-
|
15798
|
-
|
15799
|
-
|
15800
|
-
|
15801
|
-
|
15802
|
-
|
15803
|
-
|
15633
|
+
open: isPopoverOpen,
|
15634
|
+
onOpenChange: onPopoverOpenChange,
|
15635
|
+
modal: modalPopover,
|
15636
|
+
children: [
|
15637
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
15638
|
+
"button",
|
15639
|
+
{
|
15640
|
+
ref,
|
15641
|
+
onClick: handleTogglePopover,
|
15642
|
+
className: cls(
|
15643
|
+
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
15644
|
+
"py-2",
|
15645
|
+
"px-4",
|
15646
|
+
"select-none rounded-md text-sm",
|
15647
|
+
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
15648
|
+
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
15649
|
+
"relative flex items-center",
|
15650
|
+
className
|
15651
|
+
),
|
15652
|
+
children: selectedValues.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center w-full", children: [
|
15653
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 text-start", children: [
|
15654
|
+
renderValues && renderValues(selectedValues),
|
15655
|
+
!renderValues && selectedValues.map((value2) => {
|
15656
|
+
const childrenProps = Children.map(children, (child) => {
|
15657
|
+
if (React.isValidElement(child)) {
|
15658
|
+
return child.props;
|
15659
|
+
}
|
15660
|
+
}).filter(Boolean);
|
15661
|
+
const option = childrenProps.find((o) => o.value === value2);
|
15662
|
+
if (!useChips) {
|
15663
|
+
return option?.children;
|
15804
15664
|
}
|
15805
|
-
|
15806
|
-
|
15807
|
-
children: [
|
15808
|
-
option?.label,
|
15809
|
-
/* @__PURE__ */ jsx(
|
15810
|
-
CloseIcon,
|
15665
|
+
return /* @__PURE__ */ jsxs(
|
15666
|
+
Chip,
|
15811
15667
|
{
|
15812
|
-
size: "
|
15813
|
-
|
15814
|
-
|
15815
|
-
|
15816
|
-
|
15817
|
-
|
15818
|
-
|
15819
|
-
|
15820
|
-
|
15821
|
-
|
15822
|
-
|
15823
|
-
|
15824
|
-
|
15825
|
-
|
15826
|
-
|
15827
|
-
|
15828
|
-
|
15829
|
-
|
15830
|
-
|
15831
|
-
|
15832
|
-
|
15833
|
-
|
15834
|
-
}
|
15835
|
-
),
|
15836
|
-
style: { animationDuration: `${animation}s` },
|
15837
|
-
children: [
|
15838
|
-
`+ ${selectedValues.length - maxCount} more`,
|
15839
|
-
/* @__PURE__ */ jsx(
|
15668
|
+
size: "small",
|
15669
|
+
className: cls("flex flex-row items-center p-1"),
|
15670
|
+
children: [
|
15671
|
+
option?.children,
|
15672
|
+
/* @__PURE__ */ jsx(
|
15673
|
+
CloseIcon,
|
15674
|
+
{
|
15675
|
+
size: "smallest",
|
15676
|
+
onClick: (event) => {
|
15677
|
+
event.stopPropagation();
|
15678
|
+
toggleOption(value2);
|
15679
|
+
}
|
15680
|
+
}
|
15681
|
+
)
|
15682
|
+
]
|
15683
|
+
},
|
15684
|
+
value2
|
15685
|
+
);
|
15686
|
+
})
|
15687
|
+
] }),
|
15688
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
15689
|
+
includeClear && /* @__PURE__ */ jsx(
|
15840
15690
|
CloseIcon,
|
15841
15691
|
{
|
15842
|
-
|
15692
|
+
className: "ml-4",
|
15693
|
+
size: "small",
|
15843
15694
|
onClick: (event) => {
|
15844
15695
|
event.stopPropagation();
|
15845
|
-
|
15696
|
+
handleClear();
|
15846
15697
|
}
|
15847
15698
|
}
|
15848
|
-
)
|
15849
|
-
|
15850
|
-
|
15851
|
-
|
15852
|
-
|
15853
|
-
|
15854
|
-
|
15855
|
-
|
15856
|
-
|
15857
|
-
|
15858
|
-
|
15859
|
-
|
15860
|
-
|
15861
|
-
|
15862
|
-
|
15863
|
-
|
15864
|
-
|
15865
|
-
|
15866
|
-
|
15867
|
-
orientation: "vertical"
|
15868
|
-
}
|
15869
|
-
),
|
15870
|
-
/* @__PURE__ */ jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsx(
|
15871
|
-
ExpandMoreIcon,
|
15872
|
-
{
|
15873
|
-
size: "small",
|
15874
|
-
className: cls("transition", isPopoverOpen ? "rotate-180" : "")
|
15875
|
-
}
|
15876
|
-
) })
|
15877
|
-
] })
|
15878
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full mx-auto", children: [
|
15879
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground mx-3", children: placeholder }),
|
15880
|
-
/* @__PURE__ */ jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsx(
|
15881
|
-
ExpandMoreIcon,
|
15882
|
-
{
|
15883
|
-
size: "small",
|
15884
|
-
className: cls("transition", isPopoverOpen ? "rotate-180" : "")
|
15699
|
+
),
|
15700
|
+
/* @__PURE__ */ jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsx(
|
15701
|
+
ExpandMoreIcon,
|
15702
|
+
{
|
15703
|
+
size: "small",
|
15704
|
+
className: cls("transition", isPopoverOpen ? "rotate-180" : "")
|
15705
|
+
}
|
15706
|
+
) })
|
15707
|
+
] })
|
15708
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full mx-auto", children: [
|
15709
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: placeholder }),
|
15710
|
+
/* @__PURE__ */ jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsx(
|
15711
|
+
ExpandMoreIcon,
|
15712
|
+
{
|
15713
|
+
size: "small",
|
15714
|
+
className: cls("transition", isPopoverOpen ? "rotate-180" : "")
|
15715
|
+
}
|
15716
|
+
) })
|
15717
|
+
] })
|
15885
15718
|
}
|
15886
|
-
) })
|
15887
|
-
] })
|
15888
|
-
}
|
15889
|
-
) }),
|
15890
|
-
/* @__PURE__ */ jsx(
|
15891
|
-
PopoverPrimitive.Content,
|
15892
|
-
{
|
15893
|
-
className: cls("z-50 relative overflow-hidden border bg-white dark:bg-gray-900 p-2 rounded-lg", defaultBorderMixin),
|
15894
|
-
align: "start",
|
15895
|
-
onEscapeKeyDown: () => setIsPopoverOpen(false),
|
15896
|
-
children: /* @__PURE__ */ jsxs(Command, { children: [
|
15719
|
+
) }),
|
15897
15720
|
/* @__PURE__ */ jsx(
|
15898
|
-
|
15721
|
+
PopoverPrimitive.Content,
|
15899
15722
|
{
|
15900
|
-
className: cls(
|
15901
|
-
|
15902
|
-
|
15903
|
-
|
15904
|
-
|
15905
|
-
|
15906
|
-
|
15907
|
-
|
15908
|
-
|
15909
|
-
|
15910
|
-
|
15911
|
-
|
15912
|
-
|
15913
|
-
// (fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
|
15914
|
-
"cursor-pointer",
|
15915
|
-
"flex flex-row items-center gap-2",
|
15916
|
-
"ring-offset-transparent",
|
15917
|
-
"p-1 rounded aria-[selected=true]:outline-none aria-[selected=true]:ring-2 aria-[selected=true]:ring-primary aria-[selected=true]:ring-opacity-75 aria-[selected=true]:ring-offset-2",
|
15918
|
-
"aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15919
|
-
"cursor-pointer p-1 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15920
|
-
className
|
15723
|
+
className: cls("z-50 relative overflow-hidden border bg-white dark:bg-gray-900 rounded-lg w-[400px]", defaultBorderMixin),
|
15724
|
+
align: "start",
|
15725
|
+
sideOffset: 8,
|
15726
|
+
onEscapeKeyDown: () => onPopoverOpenChange(false),
|
15727
|
+
children: /* @__PURE__ */ jsxs(Command, { children: [
|
15728
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
15729
|
+
/* @__PURE__ */ jsx(
|
15730
|
+
Command.Input,
|
15731
|
+
{
|
15732
|
+
className: cls(focusedDisabled, "bg-transparent outline-none flex-1 h-full w-full m-4 flex-grow"),
|
15733
|
+
placeholder: "Search...",
|
15734
|
+
onKeyDown: handleInputKeyDown
|
15735
|
+
}
|
15921
15736
|
),
|
15922
|
-
|
15923
|
-
|
15924
|
-
|
15925
|
-
|
15926
|
-
|
15927
|
-
|
15928
|
-
|
15929
|
-
|
15930
|
-
|
15931
|
-
|
15932
|
-
|
15933
|
-
{
|
15934
|
-
|
15935
|
-
|
15936
|
-
|
15937
|
-
|
15938
|
-
|
15939
|
-
|
15940
|
-
|
15941
|
-
|
15942
|
-
|
15943
|
-
|
15737
|
+
selectedValues.length > 0 && /* @__PURE__ */ jsx(
|
15738
|
+
"div",
|
15739
|
+
{
|
15740
|
+
onClick: handleClear,
|
15741
|
+
className: "text-sm justify-center cursor-pointer py-3 px-4 text-text-secondary dark:text-text-secondary-dark",
|
15742
|
+
children: "Clear"
|
15743
|
+
}
|
15744
|
+
)
|
15745
|
+
] }),
|
15746
|
+
/* @__PURE__ */ jsx(Separator, { orientation: "horizontal", className: "my-0" }),
|
15747
|
+
/* @__PURE__ */ jsxs(Command.List, { children: [
|
15748
|
+
/* @__PURE__ */ jsx(Command.Empty, { className: "px-4 py-2", children: "No results found." }),
|
15749
|
+
/* @__PURE__ */ jsxs(Command.Group, { children: [
|
15750
|
+
/* @__PURE__ */ jsxs(
|
15751
|
+
Command.Item,
|
15752
|
+
{
|
15753
|
+
onSelect: toggleAll,
|
15754
|
+
className: cls(
|
15755
|
+
"flex flex-row items-center gap-1.5",
|
15756
|
+
"cursor-pointer",
|
15757
|
+
"m-1",
|
15758
|
+
"ring-offset-transparent",
|
15759
|
+
"p-1 rounded aria-[selected=true]:outline-none aria-[selected=true]:ring-2 aria-[selected=true]:ring-primary aria-[selected=true]:ring-opacity-75 aria-[selected=true]:ring-offset-2",
|
15760
|
+
"aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15761
|
+
"cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900"
|
15762
|
+
),
|
15763
|
+
children: [
|
15764
|
+
/* @__PURE__ */ jsx(InnerCheckBox, { checked: selectedValues.length === allValues.length }),
|
15765
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-text-secondary dark:text-text-secondary-dark", children: "(Select All)" })
|
15766
|
+
]
|
15767
|
+
},
|
15768
|
+
"all"
|
15944
15769
|
),
|
15945
|
-
children
|
15946
|
-
|
15947
|
-
|
15948
|
-
|
15949
|
-
|
15950
|
-
|
15951
|
-
|
15952
|
-
})
|
15953
|
-
] }),
|
15954
|
-
/* @__PURE__ */ jsx(Command.Separator, {}),
|
15955
|
-
/* @__PURE__ */ jsx(Command.Group, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
15956
|
-
selectedValues.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
15957
|
-
/* @__PURE__ */ jsx(
|
15958
|
-
Command.Item,
|
15959
|
-
{
|
15960
|
-
onSelect: handleClear,
|
15961
|
-
className: "flex-1 justify-center cursor-pointer",
|
15962
|
-
children: "Clear"
|
15963
|
-
}
|
15964
|
-
),
|
15965
|
-
/* @__PURE__ */ jsx(
|
15966
|
-
Separator,
|
15967
|
-
{
|
15968
|
-
orientation: "vertical"
|
15969
|
-
}
|
15970
|
-
)
|
15971
|
-
] }),
|
15972
|
-
/* @__PURE__ */ jsx(
|
15973
|
-
Command.Item,
|
15974
|
-
{
|
15975
|
-
onSelect: () => setIsPopoverOpen(false),
|
15976
|
-
className: "flex-1 justify-center cursor-pointer max-w-full",
|
15977
|
-
children: "Close"
|
15978
|
-
}
|
15979
|
-
)
|
15980
|
-
] }) })
|
15981
|
-
] })
|
15982
|
-
] })
|
15770
|
+
children
|
15771
|
+
] })
|
15772
|
+
] })
|
15773
|
+
] })
|
15774
|
+
}
|
15775
|
+
)
|
15776
|
+
]
|
15983
15777
|
}
|
15984
15778
|
)
|
15985
15779
|
]
|
@@ -15987,7 +15781,66 @@ const NewMultiSelect = React.forwardRef(
|
|
15987
15781
|
);
|
15988
15782
|
}
|
15989
15783
|
);
|
15990
|
-
|
15784
|
+
MultiSelect.displayName = "MultiSelect";
|
15785
|
+
function MultiSelectItem({
|
15786
|
+
children,
|
15787
|
+
value,
|
15788
|
+
className
|
15789
|
+
}) {
|
15790
|
+
const context = React.useContext(MultiSelectContext);
|
15791
|
+
if (!context) throw new Error("MultiSelectItem must be used inside a MultiSelect");
|
15792
|
+
const {
|
15793
|
+
fieldValue,
|
15794
|
+
onItemClick
|
15795
|
+
} = context;
|
15796
|
+
const isSelected = (fieldValue ?? []).includes(value);
|
15797
|
+
return /* @__PURE__ */ jsxs(
|
15798
|
+
Command.Item,
|
15799
|
+
{
|
15800
|
+
onMouseDown: (e) => {
|
15801
|
+
e.preventDefault();
|
15802
|
+
e.stopPropagation();
|
15803
|
+
},
|
15804
|
+
onSelect: (_) => {
|
15805
|
+
onItemClick(value);
|
15806
|
+
},
|
15807
|
+
className: cls(
|
15808
|
+
"flex flex-row items-center gap-1.5",
|
15809
|
+
isSelected ? "bg-slate-200 dark:bg-slate-950" : "",
|
15810
|
+
"cursor-pointer",
|
15811
|
+
"m-1",
|
15812
|
+
"ring-offset-transparent",
|
15813
|
+
"p-1 rounded aria-[selected=true]:outline-none aria-[selected=true]:ring-2 aria-[selected=true]:ring-primary aria-[selected=true]:ring-opacity-75 aria-[selected=true]:ring-offset-2",
|
15814
|
+
"aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15815
|
+
"cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
|
15816
|
+
className
|
15817
|
+
),
|
15818
|
+
children: [
|
15819
|
+
/* @__PURE__ */ jsx(InnerCheckBox, { checked: isSelected }),
|
15820
|
+
children
|
15821
|
+
]
|
15822
|
+
}
|
15823
|
+
);
|
15824
|
+
}
|
15825
|
+
function InnerCheckBox({ checked }) {
|
15826
|
+
return /* @__PURE__ */ jsx("div", { className: cls(
|
15827
|
+
"p-2",
|
15828
|
+
"w-8 h-8",
|
15829
|
+
"inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150"
|
15830
|
+
), children: /* @__PURE__ */ jsx(
|
15831
|
+
"div",
|
15832
|
+
{
|
15833
|
+
className: cls(
|
15834
|
+
"border-2 relative transition-colors ease-in-out duration-150",
|
15835
|
+
"w-4 h-4 rounded flex items-center justify-center",
|
15836
|
+
checked ? "bg-primary" : "bg-white dark:bg-slate-900",
|
15837
|
+
checked ? "text-slate-100 dark:text-slate-900" : "",
|
15838
|
+
checked ? "border-transparent" : "border-slate-800 dark:border-slate-200"
|
15839
|
+
),
|
15840
|
+
children: checked && /* @__PURE__ */ jsx(Icon, { iconKey: "check", size: 16, className: "absolute" })
|
15841
|
+
}
|
15842
|
+
) });
|
15843
|
+
}
|
15991
15844
|
function Paper({
|
15992
15845
|
children,
|
15993
15846
|
style,
|
@@ -16127,40 +15980,28 @@ const Select = forwardRef(({
|
|
16127
15980
|
value,
|
16128
15981
|
onChange,
|
16129
15982
|
onValueChange,
|
16130
|
-
onMultiValueChange,
|
16131
15983
|
className,
|
16132
15984
|
inputClassName,
|
16133
15985
|
placeholder,
|
16134
15986
|
renderValue,
|
16135
|
-
renderValues,
|
16136
15987
|
label,
|
16137
15988
|
size = "medium",
|
16138
|
-
includeFocusOutline = true,
|
16139
15989
|
error,
|
16140
15990
|
disabled,
|
16141
15991
|
padding = true,
|
16142
15992
|
position = "item-aligned",
|
16143
15993
|
endAdornment,
|
16144
|
-
multiple,
|
16145
15994
|
invisible,
|
16146
15995
|
children,
|
16147
15996
|
...props
|
16148
15997
|
}, ref) => {
|
16149
|
-
const [openInternal, setOpenInternal] = useState(false);
|
15998
|
+
const [openInternal, setOpenInternal] = useState(open ?? false);
|
16150
15999
|
useEffect(() => {
|
16151
16000
|
setOpenInternal(open ?? false);
|
16152
16001
|
}, [open]);
|
16153
16002
|
const onValueChangeInternal = useCallback((newValue) => {
|
16154
|
-
|
16155
|
-
|
16156
|
-
onMultiValueChange?.(value.filter((v) => v !== newValue));
|
16157
|
-
} else {
|
16158
|
-
onMultiValueChange?.([...value ?? [], newValue]);
|
16159
|
-
}
|
16160
|
-
} else {
|
16161
|
-
onValueChange?.(newValue);
|
16162
|
-
}
|
16163
|
-
if (!multiple && onChange) {
|
16003
|
+
onValueChange?.(newValue);
|
16004
|
+
if (onChange) {
|
16164
16005
|
const event = {
|
16165
16006
|
target: {
|
16166
16007
|
name,
|
@@ -16169,14 +16010,13 @@ const Select = forwardRef(({
|
|
16169
16010
|
};
|
16170
16011
|
onChange(event);
|
16171
16012
|
}
|
16172
|
-
}, [
|
16013
|
+
}, [onChange, value, onValueChange]);
|
16173
16014
|
const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
|
16174
16015
|
return /* @__PURE__ */ jsxs(
|
16175
16016
|
SelectPrimitive.Root,
|
16176
16017
|
{
|
16177
16018
|
name,
|
16178
|
-
value
|
16179
|
-
defaultOpen: open,
|
16019
|
+
value,
|
16180
16020
|
open: openInternal,
|
16181
16021
|
disabled,
|
16182
16022
|
onValueChange: onValueChangeInternal,
|
@@ -16216,6 +16056,10 @@ const Select = forwardRef(({
|
|
16216
16056
|
"relative flex items-center",
|
16217
16057
|
inputClassName
|
16218
16058
|
),
|
16059
|
+
onClick: (e) => {
|
16060
|
+
e.preventDefault();
|
16061
|
+
e.stopPropagation();
|
16062
|
+
},
|
16219
16063
|
children: [
|
16220
16064
|
/* @__PURE__ */ jsx(
|
16221
16065
|
"div",
|
@@ -16226,11 +16070,22 @@ const Select = forwardRef(({
|
|
16226
16070
|
"overflow-visible",
|
16227
16071
|
size === "small" ? "h-[42px]" : "h-[64px]"
|
16228
16072
|
),
|
16229
|
-
children: /* @__PURE__ */ jsxs(
|
16230
|
-
|
16231
|
-
|
16232
|
-
|
16233
|
-
|
16073
|
+
children: /* @__PURE__ */ jsxs(
|
16074
|
+
SelectPrimitive.Value,
|
16075
|
+
{
|
16076
|
+
onClick: (e) => {
|
16077
|
+
e.preventDefault();
|
16078
|
+
e.stopPropagation();
|
16079
|
+
},
|
16080
|
+
placeholder,
|
16081
|
+
className: "w-full",
|
16082
|
+
children: [
|
16083
|
+
!hasValue && placeholder,
|
16084
|
+
hasValue && value && renderValue ? renderValue(value) : placeholder,
|
16085
|
+
hasValue && !renderValue && value
|
16086
|
+
]
|
16087
|
+
}
|
16088
|
+
)
|
16234
16089
|
}
|
16235
16090
|
),
|
16236
16091
|
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsx(ExpandMoreIcon, { size: "small", className: cls("transition", open ? "rotate-180" : "") }) })
|
@@ -16241,7 +16096,10 @@ const Select = forwardRef(({
|
|
16241
16096
|
"div",
|
16242
16097
|
{
|
16243
16098
|
className: cls("absolute h-full flex items-center", size === "small" ? "right-10" : "right-14"),
|
16244
|
-
onClick: (e) =>
|
16099
|
+
onClick: (e) => {
|
16100
|
+
e.preventDefault();
|
16101
|
+
e.stopPropagation();
|
16102
|
+
},
|
16245
16103
|
children: endAdornment
|
16246
16104
|
}
|
16247
16105
|
)
|
@@ -17059,7 +16917,7 @@ function Popover({
|
|
17059
16917
|
{
|
17060
16918
|
className: cls(
|
17061
16919
|
paperMixin,
|
17062
|
-
"PopoverContent
|
16920
|
+
"PopoverContent z-40",
|
17063
16921
|
className
|
17064
16922
|
),
|
17065
16923
|
side,
|
@@ -19288,7 +19146,6 @@ export {
|
|
19288
19146
|
NetworkWifiLockedIcon,
|
19289
19147
|
NeurologyIcon,
|
19290
19148
|
NewLabelIcon,
|
19291
|
-
NewMultiSelect,
|
19292
19149
|
NewReleasesIcon,
|
19293
19150
|
NewWindowIcon,
|
19294
19151
|
NewsIcon,
|