@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/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("@radix-ui/react-collapsible"), require("clsx"), require("tailwind-merge"), require("date-fns/locale"), require("react-datepicker"), require("@radix-ui/react-checkbox"), require("material-icons/iconfont/filled.css"), require("@radix-ui/react-dialog"), require("react-dropzone"), require("@radix-ui/react-label"), require("react-fast-compare"), require("markdown-it"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-menubar"), require("cmdk"), require("@radix-ui/react-popover"), require("@radix-ui/react-separator"), require("@radix-ui/react-radio-group"), require("@radix-ui/react-select"), require("react-dom"), require("@radix-ui/react-tooltip"), require("@radix-ui/react-tabs")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "@radix-ui/react-collapsible", "clsx", "tailwind-merge", "date-fns/locale", "react-datepicker", "@radix-ui/react-checkbox", "material-icons/iconfont/filled.css", "@radix-ui/react-dialog", "react-dropzone", "@radix-ui/react-label", "react-fast-compare", "markdown-it", "@radix-ui/react-dropdown-menu", "@radix-ui/react-menubar", "cmdk", "@radix-ui/react-popover", "@radix-ui/react-separator", "@radix-ui/react-radio-group", "@radix-ui/react-select", "react-dom", "@radix-ui/react-tooltip", "@radix-ui/react-tabs"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS UI"] = {}, global.jsxRuntime, global.React, global.Collapsible, global.clsx, global.tailwindMerge, global.locales, global.DatePicker, global.CheckboxPrimitive, null, global.DialogPrimitive, global.reactDropzone, global.LabelPrimitive, global.equal, global.MarkdownIt, global.DropdownMenu, global.MenubarPrimitive, global.cmdk, global.PopoverPrimitive, global.SeparatorPrimitive, global.RadioGroupPrimitive, global.SelectPrimitive, global.ReactDOM, global.TooltipPrimitive, global.TabsPrimitive));
3
- })(this, function(exports2, jsxRuntime, React, Collapsible, clsx, tailwindMerge, locales, DatePicker, CheckboxPrimitive, filled_css, DialogPrimitive, reactDropzone, LabelPrimitive, equal, MarkdownIt, DropdownMenu, MenubarPrimitive, cmdk, PopoverPrimitive, SeparatorPrimitive, RadioGroupPrimitive, SelectPrimitive, ReactDOM, TooltipPrimitive, TabsPrimitive) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react"), require("@radix-ui/react-collapsible"), require("clsx"), require("tailwind-merge"), require("date-fns/locale"), require("react-datepicker"), require("@radix-ui/react-checkbox"), require("material-icons/iconfont/filled.css"), require("@radix-ui/react-dialog"), require("react-dropzone"), require("@radix-ui/react-label"), require("react-fast-compare"), require("markdown-it"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-menubar"), require("@radix-ui/react-popover"), require("cmdk"), require("@radix-ui/react-separator"), require("@radix-ui/react-radio-group"), require("@radix-ui/react-select"), require("react-dom"), require("@radix-ui/react-tooltip"), require("@radix-ui/react-tabs")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react", "@radix-ui/react-collapsible", "clsx", "tailwind-merge", "date-fns/locale", "react-datepicker", "@radix-ui/react-checkbox", "material-icons/iconfont/filled.css", "@radix-ui/react-dialog", "react-dropzone", "@radix-ui/react-label", "react-fast-compare", "markdown-it", "@radix-ui/react-dropdown-menu", "@radix-ui/react-menubar", "@radix-ui/react-popover", "cmdk", "@radix-ui/react-separator", "@radix-ui/react-radio-group", "@radix-ui/react-select", "react-dom", "@radix-ui/react-tooltip", "@radix-ui/react-tabs"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["FireCMS UI"] = {}, global.jsxRuntime, global.React, global.Collapsible, global.clsx, global.tailwindMerge, global.locales, global.DatePicker, global.CheckboxPrimitive, null, global.DialogPrimitive, global.reactDropzone, global.LabelPrimitive, global.equal, global.MarkdownIt, global.DropdownMenu, global.MenubarPrimitive, global.PopoverPrimitive, global.cmdk, global.SeparatorPrimitive, global.RadioGroupPrimitive, global.SelectPrimitive, global.ReactDOM, global.TooltipPrimitive, global.TabsPrimitive));
3
+ })(this, function(exports2, jsxRuntime, React, Collapsible, clsx, tailwindMerge, locales, DatePicker, CheckboxPrimitive, filled_css, DialogPrimitive, reactDropzone, LabelPrimitive, equal, MarkdownIt, DropdownMenu, MenubarPrimitive, PopoverPrimitive, cmdk, SeparatorPrimitive, RadioGroupPrimitive, SelectPrimitive, ReactDOM, TooltipPrimitive, TabsPrimitive) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -15511,485 +15511,279 @@
15511
15511
  function MenubarSubTriggerIndicator() {
15512
15512
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto pl-5 ", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, { size: "small" }) });
15513
15513
  }
15514
- function SelectInputLabel({ children, error }) {
15515
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls(
15516
- "text-sm font-medium ml-3.5 mb-1",
15517
- error ? "text-red-500 dark:text-red-600" : "text-slate-500 dark:text-slate-300"
15518
- ), children });
15519
- }
15520
- const MultiSelectContext = React__namespace.createContext({});
15521
- function MultiSelect({
15522
- value,
15523
- open,
15524
- onMultiValueChange,
15525
- size = "medium",
15526
- label,
15527
- disabled,
15528
- renderValue,
15529
- renderValues,
15530
- containerClassName,
15531
- className,
15532
- children,
15533
- error
15514
+ function Separator({
15515
+ orientation,
15516
+ decorative,
15517
+ className
15534
15518
  }) {
15535
- const containerRef = React__namespace.useRef(null);
15536
- const inputRef = React__namespace.useRef(null);
15537
- const listRef = React__namespace.useRef(null);
15538
- useOutsideAlerter(listRef, () => setOpenInternal(false));
15539
- const [openInternal, setOpenInternal] = React__namespace.useState(false);
15540
- React.useEffect(() => {
15541
- setOpenInternal(open ?? false);
15542
- }, [open]);
15543
- const onValueChangeInternal = React__namespace.useCallback((newValue) => {
15544
- if (Array.isArray(value) && value.includes(newValue)) {
15545
- onMultiValueChange?.(value.filter((v) => v !== newValue));
15546
- } else {
15547
- onMultiValueChange?.([...value ?? [], newValue]);
15548
- }
15549
- }, [value, onMultiValueChange]);
15550
- const [inputValue, setInputValue] = React__namespace.useState("");
15551
- const [boundingRect, setBoundingRect] = React__namespace.useState(null);
15552
- const handleKeyDown = React__namespace.useCallback((e) => {
15553
- const input = inputRef.current;
15554
- if (input) {
15555
- if (e.key === "Delete" || e.key === "Backspace") {
15556
- if (input.value === "") {
15557
- const newSelected = [...value ?? []];
15558
- newSelected.pop();
15559
- onMultiValueChange?.(newSelected);
15560
- }
15561
- }
15562
- if (e.key === "Escape") {
15563
- input.blur();
15564
- setOpenInternal(false);
15565
- e.stopPropagation();
15566
- }
15567
- }
15568
- }, [onMultiValueChange, value]);
15569
- const openDialog = React__namespace.useCallback(() => {
15570
- setBoundingRect(containerRef.current?.getBoundingClientRect() ?? null);
15571
- setOpenInternal(true);
15572
- }, []);
15573
- const usedBoundingRect = boundingRect ?? containerRef.current?.getBoundingClientRect();
15574
- const maxHeight = window.innerHeight - (usedBoundingRect?.top ?? 0) - (usedBoundingRect?.height ?? 0) - 16;
15575
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15576
- typeof label === "string" ? /* @__PURE__ */ jsxRuntime.jsx(SelectInputLabel, { error, children: label }) : label,
15577
- /* @__PURE__ */ jsxRuntime.jsxs(
15578
- cmdk.Command,
15579
- {
15580
- onKeyDown: handleKeyDown,
15581
- onClick: () => {
15582
- inputRef.current?.focus();
15583
- openDialog();
15584
- },
15585
- className: cls("relative overflow-visible bg-transparent", containerClassName),
15586
- children: [
15587
- /* @__PURE__ */ jsxRuntime.jsxs(
15588
- "div",
15589
- {
15590
- ref: containerRef,
15591
- className: cls(
15592
- "flex flex-row",
15593
- size === "small" ? "min-h-[42px]" : "min-h-[64px]",
15594
- "select-none rounded-md text-sm",
15595
- fieldBackgroundMixin,
15596
- disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
15597
- "relative flex items-center",
15598
- "p-4",
15599
- error ? "text-red-500 dark:text-red-600" : "focus:text-text-primary dark:focus:text-text-primary-dark",
15600
- error ? "border border-red-500 dark:border-red-600" : "",
15601
- className
15602
- ),
15603
- children: [
15604
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cls("flex-grow flex gap-1.5 flex-wrap items-center"), children: [
15605
- renderValue && (value ?? []).map((v, i) => renderValue(v, i)),
15606
- renderValues && renderValues(value ?? []),
15607
- /* @__PURE__ */ jsxRuntime.jsx(
15608
- cmdk.Command.Input,
15609
- {
15610
- ref: inputRef,
15611
- value: inputValue,
15612
- onValueChange: setInputValue,
15613
- onFocus: openDialog,
15614
- className: cls("ml-2 bg-transparent outline-none flex-1 h-full w-full ", focusedDisabled)
15615
- }
15616
- )
15617
- ] }),
15618
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 h-full flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
15619
- ExpandMoreIcon,
15620
- {
15621
- size: "small",
15622
- className: cls("transition ", openInternal ? "rotate-180" : "")
15623
- }
15624
- ) })
15625
- ]
15626
- }
15627
- ),
15628
- /* @__PURE__ */ jsxRuntime.jsx(
15629
- DialogPrimitive__namespace.Root,
15630
- {
15631
- open: openInternal,
15632
- modal: true,
15633
- onOpenChange: setOpenInternal,
15634
- children: /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
15635
- MultiSelectContext.Provider,
15636
- {
15637
- value: {
15638
- fieldValue: value,
15639
- setInputValue,
15640
- onValueChangeInternal
15641
- },
15642
- children: /* @__PURE__ */ jsxRuntime.jsx(
15643
- "div",
15644
- {
15645
- ref: listRef,
15646
- className: "z-50 absolute overflow-auto outline-none",
15647
- style: {
15648
- pointerEvents: openInternal ? "auto" : "none",
15649
- top: (usedBoundingRect?.top ?? 0) + (usedBoundingRect?.height ?? 0),
15650
- left: usedBoundingRect?.left,
15651
- // right: boundingRect?.right,
15652
- width: usedBoundingRect?.width,
15653
- maxHeight
15654
- },
15655
- children: /* @__PURE__ */ jsxRuntime.jsx(
15656
- cmdk.Command.Group,
15657
- {
15658
- 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",
15659
- children
15660
- }
15661
- )
15662
- }
15663
- )
15664
- }
15665
- ) })
15666
- }
15667
- )
15668
- ]
15669
- }
15670
- )
15671
- ] });
15672
- }
15673
- function MultiSelectItem({ children, value, className }) {
15674
- const context = React__namespace.useContext(MultiSelectContext);
15675
- if (!context) throw new Error("MultiSelectItem must be used inside a MultiSelect");
15676
- const { fieldValue, setInputValue, onValueChangeInternal } = context;
15677
- return /* @__PURE__ */ jsxRuntime.jsx(
15678
- cmdk.Command.Item,
15679
- {
15680
- onMouseDown: (e) => {
15681
- e.preventDefault();
15682
- e.stopPropagation();
15683
- },
15684
- onSelect: (_) => {
15685
- setInputValue("");
15686
- onValueChangeInternal(value);
15687
- },
15688
- className: cls(
15689
- (fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
15690
- "cursor-pointer",
15691
- "m-1",
15692
- "ring-offset-transparent",
15693
- "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",
15694
- "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15695
- "cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15696
- className
15697
- ),
15698
- children
15699
- }
15700
- );
15701
- }
15702
- function Separator({ orientation, decorative }) {
15703
15519
  if (orientation === "horizontal")
15704
15520
  return /* @__PURE__ */ jsxRuntime.jsx(
15705
15521
  SeparatorPrimitive__namespace.Root,
15706
15522
  {
15707
15523
  decorative,
15708
15524
  orientation: "horizontal",
15709
- className: "dark:bg-opacity-50 bg-opacity-50 dark:bg-gray-600 bg-gray-300 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px my-[8px]"
15525
+ 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)
15710
15526
  }
15711
15527
  );
15712
15528
  else
15713
15529
  return /* @__PURE__ */ jsxRuntime.jsx(
15714
15530
  SeparatorPrimitive__namespace.Root,
15715
15531
  {
15716
- className: "dark:bg-opacity-50 bg-opacity-50 dark:bg-gray-600 bg-gray-300 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px mx-[8px]",
15532
+ 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),
15717
15533
  decorative,
15718
15534
  orientation: "vertical"
15719
15535
  }
15720
15536
  );
15721
15537
  }
15722
- const NewMultiSelect = React__namespace.forwardRef(
15538
+ function SelectInputLabel({ children, error }) {
15539
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls(
15540
+ "text-sm font-medium ml-3.5 mb-1",
15541
+ error ? "text-red-500 dark:text-red-600" : "text-slate-500 dark:text-slate-300"
15542
+ ), children });
15543
+ }
15544
+ const MultiSelectContext = React__namespace.createContext({});
15545
+ const MultiSelect = React__namespace.forwardRef(
15723
15546
  ({
15547
+ value,
15724
15548
  size,
15725
- options,
15549
+ label,
15550
+ error,
15726
15551
  onValueChange,
15727
15552
  invisible,
15728
15553
  disabled,
15729
- variant,
15730
- defaultValue = [],
15731
- placeholder = "Select options",
15732
- animation = 0,
15733
- maxCount = 3,
15554
+ placeholder,
15734
15555
  modalPopover = false,
15735
- asChild = false,
15556
+ includeClear = true,
15557
+ useChips = true,
15736
15558
  className,
15737
- ...props
15559
+ children,
15560
+ renderValues,
15561
+ open,
15562
+ onOpenChange
15738
15563
  }, ref) => {
15739
- const [selectedValues, setSelectedValues] = React__namespace.useState(defaultValue);
15740
- const [isPopoverOpen, setIsPopoverOpen] = React__namespace.useState(false);
15564
+ const [isPopoverOpen, setIsPopoverOpen] = React__namespace.useState(open ?? false);
15565
+ const [selectedValues, setSelectedValues] = React__namespace.useState(value ?? []);
15566
+ console.log("selectedValues", selectedValues);
15567
+ const onPopoverOpenChange = (open2) => {
15568
+ setIsPopoverOpen(open2);
15569
+ onOpenChange?.(open2);
15570
+ };
15571
+ React.useEffect(() => {
15572
+ setIsPopoverOpen(open ?? false);
15573
+ }, [open]);
15574
+ const allValues = children ? (
15575
+ // @ts-ignore
15576
+ React.Children.map(children, (child) => {
15577
+ if (React__namespace.isValidElement(child)) {
15578
+ return child.props.value;
15579
+ }
15580
+ return null;
15581
+ }).filter(Boolean)
15582
+ ) : [];
15741
15583
  React__namespace.useEffect(() => {
15742
- setSelectedValues(defaultValue);
15743
- }, [defaultValue]);
15584
+ setSelectedValues(value ?? []);
15585
+ }, [value]);
15586
+ function onItemClick(newValue) {
15587
+ let newSelectedValues;
15588
+ if (selectedValues.includes(newValue)) {
15589
+ newSelectedValues = selectedValues.filter((v) => v !== newValue);
15590
+ } else {
15591
+ newSelectedValues = [...selectedValues, newValue];
15592
+ }
15593
+ updateValues(newSelectedValues);
15594
+ }
15595
+ function updateValues(values) {
15596
+ setSelectedValues(values);
15597
+ onValueChange?.(values);
15598
+ }
15744
15599
  const handleInputKeyDown = (event) => {
15745
15600
  if (event.key === "Enter") {
15746
- setIsPopoverOpen(true);
15601
+ onPopoverOpenChange(true);
15747
15602
  } else if (event.key === "Backspace" && !event.currentTarget.value) {
15748
15603
  const newSelectedValues = [...selectedValues];
15749
15604
  newSelectedValues.pop();
15750
- setSelectedValues(newSelectedValues);
15751
- onValueChange(newSelectedValues);
15605
+ updateValues(newSelectedValues);
15752
15606
  }
15753
15607
  };
15754
- const toggleOption = (value) => {
15755
- const newSelectedValues = selectedValues.includes(value) ? selectedValues.filter((v) => v !== value) : [...selectedValues, value];
15756
- setSelectedValues(newSelectedValues);
15757
- onValueChange(newSelectedValues);
15608
+ const toggleOption = (value2) => {
15609
+ const newSelectedValues = selectedValues.includes(value2) ? selectedValues.filter((v) => v !== value2) : [...selectedValues, value2];
15610
+ updateValues(newSelectedValues);
15758
15611
  };
15759
15612
  const handleClear = () => {
15760
- setSelectedValues([]);
15761
- onValueChange([]);
15613
+ updateValues([]);
15762
15614
  };
15763
15615
  const handleTogglePopover = () => {
15764
- setIsPopoverOpen((prev) => !prev);
15765
- };
15766
- const clearExtraOptions = () => {
15767
- const newSelectedValues = selectedValues.slice(0, maxCount);
15768
- setSelectedValues(newSelectedValues);
15769
- onValueChange(newSelectedValues);
15616
+ onPopoverOpenChange(!isPopoverOpen);
15770
15617
  };
15771
15618
  const toggleAll = () => {
15772
- if (selectedValues.length === options.length) {
15619
+ if (selectedValues.length === allValues.length) {
15773
15620
  handleClear();
15774
15621
  } else {
15775
- const allValues = options.map((option) => option.value);
15776
- setSelectedValues(allValues);
15777
- onValueChange(allValues);
15622
+ updateValues(allValues);
15778
15623
  }
15779
15624
  };
15625
+ useInjectStyles("MultiSelect", `
15626
+ [cmdk-group] {
15627
+ max-height: 45vh;
15628
+ overflow-y: auto;
15629
+ // width: 400px;
15630
+ } `);
15780
15631
  return /* @__PURE__ */ jsxRuntime.jsxs(
15781
- PopoverPrimitive__namespace.Root,
15632
+ MultiSelectContext.Provider,
15782
15633
  {
15783
- open: isPopoverOpen,
15784
- onOpenChange: setIsPopoverOpen,
15785
- modal: modalPopover,
15634
+ value: {
15635
+ fieldValue: selectedValues,
15636
+ onItemClick
15637
+ },
15786
15638
  children: [
15787
- /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
15788
- "button",
15639
+ typeof label === "string" ? /* @__PURE__ */ jsxRuntime.jsx(SelectInputLabel, { error, children: label }) : label,
15640
+ /* @__PURE__ */ jsxRuntime.jsxs(
15641
+ PopoverPrimitive__namespace.Root,
15789
15642
  {
15790
- ref,
15791
- ...props,
15792
- onClick: handleTogglePopover,
15793
- className: cls(
15794
- size === "small" ? "min-h-[42px]" : "min-h-[64px]",
15795
- "select-none rounded-md text-sm",
15796
- invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
15797
- disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
15798
- "relative flex items-center",
15799
- className
15800
- ),
15801
- children: selectedValues.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center w-full", children: [
15802
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center", children: [
15803
- selectedValues.slice(0, maxCount).map((value) => {
15804
- const option = options.find((o) => o.value === value);
15805
- return /* @__PURE__ */ jsxRuntime.jsxs(
15806
- Chip,
15807
- {
15808
- className: cls(
15809
- "m-1 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300",
15810
- {
15811
- "border-foreground/10 text-foreground bg-card hover:bg-card/80": variant === "default",
15812
- "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80": variant === "secondary",
15813
- "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80": variant === "destructive"
15643
+ open: isPopoverOpen,
15644
+ onOpenChange: onPopoverOpenChange,
15645
+ modal: modalPopover,
15646
+ children: [
15647
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
15648
+ "button",
15649
+ {
15650
+ ref,
15651
+ onClick: handleTogglePopover,
15652
+ className: cls(
15653
+ size === "small" ? "min-h-[42px]" : "min-h-[64px]",
15654
+ "py-2",
15655
+ "px-4",
15656
+ "select-none rounded-md text-sm",
15657
+ invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
15658
+ disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
15659
+ "relative flex items-center",
15660
+ className
15661
+ ),
15662
+ children: selectedValues.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center w-full", children: [
15663
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5 text-start", children: [
15664
+ renderValues && renderValues(selectedValues),
15665
+ !renderValues && selectedValues.map((value2) => {
15666
+ const childrenProps = React.Children.map(children, (child) => {
15667
+ if (React__namespace.isValidElement(child)) {
15668
+ return child.props;
15669
+ }
15670
+ }).filter(Boolean);
15671
+ const option = childrenProps.find((o) => o.value === value2);
15672
+ if (!useChips) {
15673
+ return option?.children;
15814
15674
  }
15815
- ),
15816
- style: { animationDuration: `${animation}s` },
15817
- children: [
15818
- option?.label,
15819
- /* @__PURE__ */ jsxRuntime.jsx(
15820
- CloseIcon,
15675
+ return /* @__PURE__ */ jsxRuntime.jsxs(
15676
+ Chip,
15821
15677
  {
15822
- size: "smallest",
15823
- onClick: (event) => {
15824
- event.stopPropagation();
15825
- toggleOption(value);
15826
- }
15827
- }
15828
- )
15829
- ]
15830
- },
15831
- value
15832
- );
15833
- }),
15834
- selectedValues.length > maxCount && /* @__PURE__ */ jsxRuntime.jsxs(
15835
- Chip,
15836
- {
15837
- className: cls(
15838
- "bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
15839
- "m-1 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300",
15840
- {
15841
- "border-foreground/10 text-foreground bg-card hover:bg-card/80": variant === "default",
15842
- "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80": variant === "secondary",
15843
- "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80": variant === "destructive"
15844
- }
15845
- ),
15846
- style: { animationDuration: `${animation}s` },
15847
- children: [
15848
- `+ ${selectedValues.length - maxCount} more`,
15849
- /* @__PURE__ */ jsxRuntime.jsx(
15678
+ size: "small",
15679
+ className: cls("flex flex-row items-center p-1"),
15680
+ children: [
15681
+ option?.children,
15682
+ /* @__PURE__ */ jsxRuntime.jsx(
15683
+ CloseIcon,
15684
+ {
15685
+ size: "smallest",
15686
+ onClick: (event) => {
15687
+ event.stopPropagation();
15688
+ toggleOption(value2);
15689
+ }
15690
+ }
15691
+ )
15692
+ ]
15693
+ },
15694
+ value2
15695
+ );
15696
+ })
15697
+ ] }),
15698
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
15699
+ includeClear && /* @__PURE__ */ jsxRuntime.jsx(
15850
15700
  CloseIcon,
15851
15701
  {
15852
- size: "smallest",
15702
+ className: "ml-4",
15703
+ size: "small",
15853
15704
  onClick: (event) => {
15854
15705
  event.stopPropagation();
15855
- clearExtraOptions();
15706
+ handleClear();
15856
15707
  }
15857
15708
  }
15858
- )
15859
- ]
15860
- }
15861
- )
15862
- ] }),
15863
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
15864
- /* @__PURE__ */ jsxRuntime.jsx(
15865
- CloseIcon,
15866
- {
15867
- size: "small",
15868
- onClick: (event) => {
15869
- event.stopPropagation();
15870
- handleClear();
15871
- }
15872
- }
15873
- ),
15874
- /* @__PURE__ */ jsxRuntime.jsx(
15875
- Separator,
15876
- {
15877
- orientation: "vertical"
15878
- }
15879
- ),
15880
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsxRuntime.jsx(
15881
- ExpandMoreIcon,
15882
- {
15883
- size: "small",
15884
- className: cls("transition", isPopoverOpen ? "rotate-180" : "")
15885
- }
15886
- ) })
15887
- ] })
15888
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full mx-auto", children: [
15889
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground mx-3", children: placeholder }),
15890
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsxRuntime.jsx(
15891
- ExpandMoreIcon,
15892
- {
15893
- size: "small",
15894
- className: cls("transition", isPopoverOpen ? "rotate-180" : "")
15709
+ ),
15710
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsxRuntime.jsx(
15711
+ ExpandMoreIcon,
15712
+ {
15713
+ size: "small",
15714
+ className: cls("transition", isPopoverOpen ? "rotate-180" : "")
15715
+ }
15716
+ ) })
15717
+ ] })
15718
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full mx-auto", children: [
15719
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: placeholder }),
15720
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsxRuntime.jsx(
15721
+ ExpandMoreIcon,
15722
+ {
15723
+ size: "small",
15724
+ className: cls("transition", isPopoverOpen ? "rotate-180" : "")
15725
+ }
15726
+ ) })
15727
+ ] })
15895
15728
  }
15896
- ) })
15897
- ] })
15898
- }
15899
- ) }),
15900
- /* @__PURE__ */ jsxRuntime.jsx(
15901
- PopoverPrimitive__namespace.Content,
15902
- {
15903
- className: cls("z-50 relative overflow-hidden border bg-white dark:bg-gray-900 p-2 rounded-lg", defaultBorderMixin),
15904
- align: "start",
15905
- onEscapeKeyDown: () => setIsPopoverOpen(false),
15906
- children: /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command, { children: [
15729
+ ) }),
15907
15730
  /* @__PURE__ */ jsxRuntime.jsx(
15908
- cmdk.Command.Input,
15731
+ PopoverPrimitive__namespace.Content,
15909
15732
  {
15910
- className: cls(focusedDisabled, "bg-transparent outline-none flex-1 h-full w-full m-4"),
15911
- placeholder: "Search...",
15912
- onKeyDown: handleInputKeyDown
15913
- }
15914
- ),
15915
- /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.List, { children: [
15916
- /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { children: "No results found." }),
15917
- /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.Group, { children: [
15918
- /* @__PURE__ */ jsxRuntime.jsxs(
15919
- cmdk.Command.Item,
15920
- {
15921
- onSelect: toggleAll,
15922
- className: cls(
15923
- // (fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
15924
- "cursor-pointer",
15925
- "flex flex-row items-center gap-2",
15926
- "ring-offset-transparent",
15927
- "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",
15928
- "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15929
- "cursor-pointer p-1 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15930
- className
15733
+ className: cls("z-50 relative overflow-hidden border bg-white dark:bg-gray-900 rounded-lg w-[400px]", defaultBorderMixin),
15734
+ align: "start",
15735
+ sideOffset: 8,
15736
+ onEscapeKeyDown: () => onPopoverOpenChange(false),
15737
+ children: /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command, { children: [
15738
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center", children: [
15739
+ /* @__PURE__ */ jsxRuntime.jsx(
15740
+ cmdk.Command.Input,
15741
+ {
15742
+ className: cls(focusedDisabled, "bg-transparent outline-none flex-1 h-full w-full m-4 flex-grow"),
15743
+ placeholder: "Search...",
15744
+ onKeyDown: handleInputKeyDown
15745
+ }
15931
15746
  ),
15932
- children: [
15933
- /* @__PURE__ */ jsxRuntime.jsx(Checkbox, { checked: selectedValues.length === options.length, size: "small" }),
15934
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "(Select All)" })
15935
- ]
15936
- },
15937
- "all"
15938
- ),
15939
- options.map((option) => {
15940
- const isSelected = selectedValues.includes(option.value);
15941
- return /* @__PURE__ */ jsxRuntime.jsxs(
15942
- cmdk.Command.Item,
15943
- {
15944
- onSelect: () => toggleOption(option.value),
15945
- className: cls(
15946
- // (fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
15947
- "cursor-pointer",
15948
- "flex flex-row items-center gap-2",
15949
- "ring-offset-transparent",
15950
- "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",
15951
- "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15952
- "cursor-pointer p-1 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15953
- className
15747
+ selectedValues.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
15748
+ "div",
15749
+ {
15750
+ onClick: handleClear,
15751
+ className: "text-sm justify-center cursor-pointer py-3 px-4 text-text-secondary dark:text-text-secondary-dark",
15752
+ children: "Clear"
15753
+ }
15754
+ )
15755
+ ] }),
15756
+ /* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "horizontal", className: "my-0" }),
15757
+ /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.List, { children: [
15758
+ /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { className: "px-4 py-2", children: "No results found." }),
15759
+ /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.Group, { children: [
15760
+ /* @__PURE__ */ jsxRuntime.jsxs(
15761
+ cmdk.Command.Item,
15762
+ {
15763
+ onSelect: toggleAll,
15764
+ className: cls(
15765
+ "flex flex-row items-center gap-1.5",
15766
+ "cursor-pointer",
15767
+ "m-1",
15768
+ "ring-offset-transparent",
15769
+ "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",
15770
+ "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15771
+ "cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900"
15772
+ ),
15773
+ children: [
15774
+ /* @__PURE__ */ jsxRuntime.jsx(InnerCheckBox, { checked: selectedValues.length === allValues.length }),
15775
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-text-secondary dark:text-text-secondary-dark", children: "(Select All)" })
15776
+ ]
15777
+ },
15778
+ "all"
15954
15779
  ),
15955
- children: [
15956
- /* @__PURE__ */ jsxRuntime.jsx(Checkbox, { checked: isSelected, size: "small" }),
15957
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
15958
- ]
15959
- },
15960
- option.value
15961
- );
15962
- })
15963
- ] }),
15964
- /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Separator, {}),
15965
- /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Group, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
15966
- selectedValues.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15967
- /* @__PURE__ */ jsxRuntime.jsx(
15968
- cmdk.Command.Item,
15969
- {
15970
- onSelect: handleClear,
15971
- className: "flex-1 justify-center cursor-pointer",
15972
- children: "Clear"
15973
- }
15974
- ),
15975
- /* @__PURE__ */ jsxRuntime.jsx(
15976
- Separator,
15977
- {
15978
- orientation: "vertical"
15979
- }
15980
- )
15981
- ] }),
15982
- /* @__PURE__ */ jsxRuntime.jsx(
15983
- cmdk.Command.Item,
15984
- {
15985
- onSelect: () => setIsPopoverOpen(false),
15986
- className: "flex-1 justify-center cursor-pointer max-w-full",
15987
- children: "Close"
15988
- }
15989
- )
15990
- ] }) })
15991
- ] })
15992
- ] })
15780
+ children
15781
+ ] })
15782
+ ] })
15783
+ ] })
15784
+ }
15785
+ )
15786
+ ]
15993
15787
  }
15994
15788
  )
15995
15789
  ]
@@ -15997,7 +15791,66 @@
15997
15791
  );
15998
15792
  }
15999
15793
  );
16000
- NewMultiSelect.displayName = "MultiSelect";
15794
+ MultiSelect.displayName = "MultiSelect";
15795
+ function MultiSelectItem({
15796
+ children,
15797
+ value,
15798
+ className
15799
+ }) {
15800
+ const context = React__namespace.useContext(MultiSelectContext);
15801
+ if (!context) throw new Error("MultiSelectItem must be used inside a MultiSelect");
15802
+ const {
15803
+ fieldValue,
15804
+ onItemClick
15805
+ } = context;
15806
+ const isSelected = (fieldValue ?? []).includes(value);
15807
+ return /* @__PURE__ */ jsxRuntime.jsxs(
15808
+ cmdk.Command.Item,
15809
+ {
15810
+ onMouseDown: (e) => {
15811
+ e.preventDefault();
15812
+ e.stopPropagation();
15813
+ },
15814
+ onSelect: (_) => {
15815
+ onItemClick(value);
15816
+ },
15817
+ className: cls(
15818
+ "flex flex-row items-center gap-1.5",
15819
+ isSelected ? "bg-slate-200 dark:bg-slate-950" : "",
15820
+ "cursor-pointer",
15821
+ "m-1",
15822
+ "ring-offset-transparent",
15823
+ "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",
15824
+ "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15825
+ "cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
15826
+ className
15827
+ ),
15828
+ children: [
15829
+ /* @__PURE__ */ jsxRuntime.jsx(InnerCheckBox, { checked: isSelected }),
15830
+ children
15831
+ ]
15832
+ }
15833
+ );
15834
+ }
15835
+ function InnerCheckBox({ checked }) {
15836
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls(
15837
+ "p-2",
15838
+ "w-8 h-8",
15839
+ "inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150"
15840
+ ), children: /* @__PURE__ */ jsxRuntime.jsx(
15841
+ "div",
15842
+ {
15843
+ className: cls(
15844
+ "border-2 relative transition-colors ease-in-out duration-150",
15845
+ "w-4 h-4 rounded flex items-center justify-center",
15846
+ checked ? "bg-primary" : "bg-white dark:bg-slate-900",
15847
+ checked ? "text-slate-100 dark:text-slate-900" : "",
15848
+ checked ? "border-transparent" : "border-slate-800 dark:border-slate-200"
15849
+ ),
15850
+ children: checked && /* @__PURE__ */ jsxRuntime.jsx(Icon, { iconKey: "check", size: 16, className: "absolute" })
15851
+ }
15852
+ ) });
15853
+ }
16001
15854
  function Paper({
16002
15855
  children,
16003
15856
  style,
@@ -16137,40 +15990,28 @@
16137
15990
  value,
16138
15991
  onChange,
16139
15992
  onValueChange,
16140
- onMultiValueChange,
16141
15993
  className,
16142
15994
  inputClassName,
16143
15995
  placeholder,
16144
15996
  renderValue,
16145
- renderValues,
16146
15997
  label,
16147
15998
  size = "medium",
16148
- includeFocusOutline = true,
16149
15999
  error,
16150
16000
  disabled,
16151
16001
  padding = true,
16152
16002
  position = "item-aligned",
16153
16003
  endAdornment,
16154
- multiple,
16155
16004
  invisible,
16156
16005
  children,
16157
16006
  ...props
16158
16007
  }, ref) => {
16159
- const [openInternal, setOpenInternal] = React.useState(false);
16008
+ const [openInternal, setOpenInternal] = React.useState(open ?? false);
16160
16009
  React.useEffect(() => {
16161
16010
  setOpenInternal(open ?? false);
16162
16011
  }, [open]);
16163
16012
  const onValueChangeInternal = React.useCallback((newValue) => {
16164
- if (multiple) {
16165
- if (Array.isArray(value) && value.includes(newValue)) {
16166
- onMultiValueChange?.(value.filter((v) => v !== newValue));
16167
- } else {
16168
- onMultiValueChange?.([...value ?? [], newValue]);
16169
- }
16170
- } else {
16171
- onValueChange?.(newValue);
16172
- }
16173
- if (!multiple && onChange) {
16013
+ onValueChange?.(newValue);
16014
+ if (onChange) {
16174
16015
  const event = {
16175
16016
  target: {
16176
16017
  name,
@@ -16179,14 +16020,13 @@
16179
16020
  };
16180
16021
  onChange(event);
16181
16022
  }
16182
- }, [multiple, onChange, value, onMultiValueChange, onValueChange]);
16023
+ }, [onChange, value, onValueChange]);
16183
16024
  const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
16184
16025
  return /* @__PURE__ */ jsxRuntime.jsxs(
16185
16026
  SelectPrimitive__namespace.Root,
16186
16027
  {
16187
16028
  name,
16188
- value: Array.isArray(value) ? void 0 : value,
16189
- defaultOpen: open,
16029
+ value,
16190
16030
  open: openInternal,
16191
16031
  disabled,
16192
16032
  onValueChange: onValueChangeInternal,
@@ -16226,6 +16066,10 @@
16226
16066
  "relative flex items-center",
16227
16067
  inputClassName
16228
16068
  ),
16069
+ onClick: (e) => {
16070
+ e.preventDefault();
16071
+ e.stopPropagation();
16072
+ },
16229
16073
  children: [
16230
16074
  /* @__PURE__ */ jsxRuntime.jsx(
16231
16075
  "div",
@@ -16236,11 +16080,22 @@
16236
16080
  "overflow-visible",
16237
16081
  size === "small" ? "h-[42px]" : "h-[64px]"
16238
16082
  ),
16239
- children: /* @__PURE__ */ jsxRuntime.jsxs(SelectPrimitive__namespace.Value, { placeholder, className: "w-full", children: [
16240
- renderValue && (hasValue && Array.isArray(value) ? value.map((v, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1 max-w-full", children: renderValue ? renderValue(v, i) : v }, v)) : typeof value === "string" ? renderValue ? renderValue(value, 0) : value : placeholder),
16241
- renderValues && (!hasValue || Array.isArray(value)) ? renderValues(value ?? []) : null,
16242
- !renderValue && !renderValues && hasValue
16243
- ] })
16083
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
16084
+ SelectPrimitive__namespace.Value,
16085
+ {
16086
+ onClick: (e) => {
16087
+ e.preventDefault();
16088
+ e.stopPropagation();
16089
+ },
16090
+ placeholder,
16091
+ className: "w-full",
16092
+ children: [
16093
+ !hasValue && placeholder,
16094
+ hasValue && value && renderValue ? renderValue(value) : placeholder,
16095
+ hasValue && !renderValue && value
16096
+ ]
16097
+ }
16098
+ )
16244
16099
  }
16245
16100
  ),
16246
16101
  /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { className: cls("px-2 h-full flex items-center"), children: /* @__PURE__ */ jsxRuntime.jsx(ExpandMoreIcon, { size: "small", className: cls("transition", open ? "rotate-180" : "") }) })
@@ -16251,7 +16106,10 @@
16251
16106
  "div",
16252
16107
  {
16253
16108
  className: cls("absolute h-full flex items-center", size === "small" ? "right-10" : "right-14"),
16254
- onClick: (e) => e.stopPropagation(),
16109
+ onClick: (e) => {
16110
+ e.preventDefault();
16111
+ e.stopPropagation();
16112
+ },
16255
16113
  children: endAdornment
16256
16114
  }
16257
16115
  )
@@ -17069,7 +16927,7 @@
17069
16927
  {
17070
16928
  className: cls(
17071
16929
  paperMixin,
17072
- "PopoverContent shadow z-40",
16930
+ "PopoverContent z-40",
17073
16931
  className
17074
16932
  ),
17075
16933
  side,
@@ -19297,7 +19155,6 @@
19297
19155
  exports2.NetworkWifiLockedIcon = NetworkWifiLockedIcon;
19298
19156
  exports2.NeurologyIcon = NeurologyIcon;
19299
19157
  exports2.NewLabelIcon = NewLabelIcon;
19300
- exports2.NewMultiSelect = NewMultiSelect;
19301
19158
  exports2.NewReleasesIcon = NewReleasesIcon;
19302
19159
  exports2.NewWindowIcon = NewWindowIcon;
19303
19160
  exports2.NewsIcon = NewsIcon;