@sustaina/shared-ui 1.32.0 → 1.33.1

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.mjs CHANGED
@@ -4,7 +4,7 @@ import { twMerge } from 'tailwind-merge';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import * as React4 from 'react';
6
6
  import React4__default, { forwardRef, useRef, useMemo, useCallback, useState, isValidElement, useEffect, useLayoutEffect, createElement } from 'react';
7
- import { CircleX, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image as Image$1, AlignLeft, AlignCenter, AlignRight, CircleHelp, XIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, X, Search, ChevronUp, ChevronDown, PanelLeftIcon, Minimize2, Maximize2, Plus, ChevronLeft, CircleUserRound, MoreVertical, Bug, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
7
+ import { CircleX, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image as Image$1, AlignLeft, AlignCenter, AlignRight, CircleHelp, ChevronDown, X, Check, XIcon, SearchIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, Search, ChevronUp, PanelLeftIcon, Minimize2, Maximize2, Plus, ChevronLeft, CircleUserRound, MoreVertical, Bug, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
8
8
  import { createPortal } from 'react-dom';
9
9
  import * as SelectPrimitive from '@radix-ui/react-select';
10
10
  import { useForm, FormProvider, Controller, useFormContext, useFormState, useFieldArray, useWatch } from 'react-hook-form';
@@ -58,6 +58,8 @@ import { restrictToParentElement, restrictToVerticalAxis } from '@dnd-kit/modifi
58
58
  import { z } from 'zod';
59
59
  import Cropper from 'react-easy-crop';
60
60
  import { NumericFormat } from 'react-number-format';
61
+ import { Command as Command$1 } from 'cmdk';
62
+ import { useVirtualizer } from '@tanstack/react-virtual';
61
63
 
62
64
  var __defProp = Object.defineProperty;
63
65
  var __export = (target, all) => {
@@ -4211,6 +4213,25 @@ var useTruncated = ({
4211
4213
  return isTruncated;
4212
4214
  };
4213
4215
  var useTruncated_default = useTruncated;
4216
+ var useControllableState = ({
4217
+ defaultValue,
4218
+ value
4219
+ }) => {
4220
+ const [internalValue, setInternalValue] = React4.useState(value ?? defaultValue);
4221
+ React4.useEffect(() => {
4222
+ if (value !== internalValue) {
4223
+ setInternalValue(value);
4224
+ }
4225
+ }, [value]);
4226
+ const updateState = React4.useCallback((nextValue) => {
4227
+ setInternalValue(nextValue);
4228
+ }, []);
4229
+ return {
4230
+ value: internalValue,
4231
+ updateState
4232
+ };
4233
+ };
4234
+ var useControllableState_default = useControllableState;
4214
4235
  var HeaderCell = ({
4215
4236
  rootClassName,
4216
4237
  labelClassName,
@@ -9734,8 +9755,9 @@ var Navbar = ({
9734
9755
  mainButtonText && /* @__PURE__ */ jsx(
9735
9756
  Button,
9736
9757
  {
9758
+ variant: "cottonYellowDark",
9737
9759
  disabled: mainButtonDisable,
9738
- className: cn("bg-sus-secondary-1 hover:bg-sus-secondary-hover", mainButtonClassName),
9760
+ className: mainButtonClassName,
9739
9761
  size: "lg",
9740
9762
  onClick: onMainButtonClick,
9741
9763
  children: mainButtonText
@@ -10111,7 +10133,7 @@ var Truncated = ({
10111
10133
  Tooltip,
10112
10134
  {
10113
10135
  ...tooltipProps,
10114
- open,
10136
+ open: tooltipProps?.disabled ? false : open,
10115
10137
  onOpenChange: (open2) => {
10116
10138
  setOpen(isTruncated && open2);
10117
10139
  },
@@ -10395,7 +10417,552 @@ var ActionMenu = ({
10395
10417
  )
10396
10418
  ] });
10397
10419
  };
10420
+ function Dialog3({ ...props }) {
10421
+ return /* @__PURE__ */ jsx(SheetPrimitive.Root, { "data-slot": "dialog", ...props });
10422
+ }
10423
+ function DialogPortal3({ ...props }) {
10424
+ return /* @__PURE__ */ jsx(SheetPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
10425
+ }
10426
+ function DialogOverlay3({ className, ...props }) {
10427
+ return /* @__PURE__ */ jsx(
10428
+ SheetPrimitive.Overlay,
10429
+ {
10430
+ "data-slot": "dialog-overlay",
10431
+ className: cn(
10432
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
10433
+ className
10434
+ ),
10435
+ ...props
10436
+ }
10437
+ );
10438
+ }
10439
+ function DialogContent3({
10440
+ className,
10441
+ children,
10442
+ showCloseButton = true,
10443
+ ...props
10444
+ }) {
10445
+ return /* @__PURE__ */ jsxs(DialogPortal3, { "data-slot": "dialog-portal", children: [
10446
+ /* @__PURE__ */ jsx(DialogOverlay3, {}),
10447
+ /* @__PURE__ */ jsxs(
10448
+ SheetPrimitive.Content,
10449
+ {
10450
+ "data-slot": "dialog-content",
10451
+ className: cn(
10452
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
10453
+ className
10454
+ ),
10455
+ ...props,
10456
+ children: [
10457
+ children,
10458
+ showCloseButton && /* @__PURE__ */ jsxs(
10459
+ SheetPrimitive.Close,
10460
+ {
10461
+ "data-slot": "dialog-close",
10462
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
10463
+ children: [
10464
+ /* @__PURE__ */ jsx(XIcon, {}),
10465
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
10466
+ ]
10467
+ }
10468
+ )
10469
+ ]
10470
+ }
10471
+ )
10472
+ ] });
10473
+ }
10474
+ function DialogHeader3({ className, ...props }) {
10475
+ return /* @__PURE__ */ jsx(
10476
+ "div",
10477
+ {
10478
+ "data-slot": "dialog-header",
10479
+ className: cn("flex flex-col gap-2 text-center sm:text-left", className),
10480
+ ...props
10481
+ }
10482
+ );
10483
+ }
10484
+ function DialogTitle3({ className, ...props }) {
10485
+ return /* @__PURE__ */ jsx(
10486
+ SheetPrimitive.Title,
10487
+ {
10488
+ "data-slot": "dialog-title",
10489
+ className: cn("text-lg leading-none font-semibold", className),
10490
+ ...props
10491
+ }
10492
+ );
10493
+ }
10494
+ function DialogDescription3({
10495
+ className,
10496
+ ...props
10497
+ }) {
10498
+ return /* @__PURE__ */ jsx(
10499
+ SheetPrimitive.Description,
10500
+ {
10501
+ "data-slot": "dialog-description",
10502
+ className: cn("text-muted-foreground text-sm", className),
10503
+ ...props
10504
+ }
10505
+ );
10506
+ }
10507
+ function Command({ className, ...props }) {
10508
+ return /* @__PURE__ */ jsx(
10509
+ Command$1,
10510
+ {
10511
+ "data-slot": "command",
10512
+ className: cn(
10513
+ "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
10514
+ className
10515
+ ),
10516
+ ...props
10517
+ }
10518
+ );
10519
+ }
10520
+ function CommandDialog({
10521
+ title = "Command Palette",
10522
+ description = "Search for a command to run...",
10523
+ children,
10524
+ className,
10525
+ showCloseButton = true,
10526
+ ...props
10527
+ }) {
10528
+ return /* @__PURE__ */ jsxs(Dialog3, { ...props, children: [
10529
+ /* @__PURE__ */ jsxs(DialogHeader3, { className: "sr-only", children: [
10530
+ /* @__PURE__ */ jsx(DialogTitle3, { children: title }),
10531
+ /* @__PURE__ */ jsx(DialogDescription3, { children: description })
10532
+ ] }),
10533
+ /* @__PURE__ */ jsx(DialogContent3, { className: cn("overflow-hidden p-0", className), showCloseButton, children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) })
10534
+ ] });
10535
+ }
10536
+ function CommandInput({ className, ...props }) {
10537
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "command-input-wrapper", className: "flex h-9 items-center gap-2 border-b px-3", children: [
10538
+ /* @__PURE__ */ jsx(SearchIcon, { className: "size-4 shrink-0 opacity-50" }),
10539
+ /* @__PURE__ */ jsx(
10540
+ Command$1.Input,
10541
+ {
10542
+ "data-slot": "command-input",
10543
+ className: cn(
10544
+ "placeholder:text-sus-gray-1 flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
10545
+ className
10546
+ ),
10547
+ ...props
10548
+ }
10549
+ )
10550
+ ] });
10551
+ }
10552
+ function CommandList({ className, ...props }) {
10553
+ return /* @__PURE__ */ jsx(
10554
+ Command$1.List,
10555
+ {
10556
+ "data-slot": "command-list",
10557
+ className: cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className),
10558
+ ...props
10559
+ }
10560
+ );
10561
+ }
10562
+ function CommandEmpty({ className, ...props }) {
10563
+ return /* @__PURE__ */ jsx(
10564
+ Command$1.Empty,
10565
+ {
10566
+ "data-slot": "command-empty",
10567
+ className: cn("py-6 text-center text-sm", className),
10568
+ ...props
10569
+ }
10570
+ );
10571
+ }
10572
+ function CommandGroup({ className, ...props }) {
10573
+ return /* @__PURE__ */ jsx(
10574
+ Command$1.Group,
10575
+ {
10576
+ "data-slot": "command-group",
10577
+ className: cn(
10578
+ "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
10579
+ className
10580
+ ),
10581
+ ...props
10582
+ }
10583
+ );
10584
+ }
10585
+ function CommandSeparator({
10586
+ className,
10587
+ ...props
10588
+ }) {
10589
+ return /* @__PURE__ */ jsx(
10590
+ Command$1.Separator,
10591
+ {
10592
+ "data-slot": "command-separator",
10593
+ className: cn("bg-border -mx-1 h-px", className),
10594
+ ...props
10595
+ }
10596
+ );
10597
+ }
10598
+ function CommandItem({ className, ...props }) {
10599
+ return /* @__PURE__ */ jsx(
10600
+ Command$1.Item,
10601
+ {
10602
+ "data-slot": "command-item",
10603
+ className: cn(
10604
+ "hover:bg-[#EAF5EE] hover:text-sus-green-2 bg-white text-black relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
10605
+ "[&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
10606
+ className
10607
+ ),
10608
+ ...props
10609
+ }
10610
+ );
10611
+ }
10612
+ function CommandShortcut({ className, ...props }) {
10613
+ return /* @__PURE__ */ jsx(
10614
+ "span",
10615
+ {
10616
+ "data-slot": "command-shortcut",
10617
+ className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className),
10618
+ ...props
10619
+ }
10620
+ );
10621
+ }
10622
+ var useFieldNames = ({
10623
+ fieldNames
10624
+ }) => {
10625
+ const { label: labelFieldKey = "label", value: valueFieldKey = "value" } = fieldNames || {};
10626
+ const getLabelField = React4__default.useCallback(
10627
+ (option) => {
10628
+ return option?.[labelFieldKey];
10629
+ },
10630
+ [labelFieldKey]
10631
+ );
10632
+ const getValueField = React4__default.useCallback(
10633
+ (option) => {
10634
+ return option?.[valueFieldKey];
10635
+ },
10636
+ [valueFieldKey]
10637
+ );
10638
+ return {
10639
+ getLabelField,
10640
+ getValueField
10641
+ };
10642
+ };
10643
+ var useFieldNames_default = useFieldNames;
10644
+ var ROW_HEIGHT = 32;
10645
+ var MIN_HEIGHT_EMPTY = 76;
10646
+ var VirtualizedCommand = ({
10647
+ name,
10648
+ height = 292,
10649
+ options,
10650
+ emptyContent = "No data.",
10651
+ searchPlaceholder,
10652
+ value,
10653
+ notFoundContent = "Not item found.",
10654
+ showSearch = true,
10655
+ fieldNames,
10656
+ disabledOption,
10657
+ filterOption,
10658
+ onSelect,
10659
+ labelRender,
10660
+ onBlur,
10661
+ onFocus
10662
+ }) => {
10663
+ const { getLabelField, getValueField } = useFieldNames_default({ fieldNames });
10664
+ const internalOptions = React4.useMemo(() => options ?? [], [options]);
10665
+ const [filteredOptions, setFilteredOptions] = React4.useState(internalOptions);
10666
+ const [focusedIndex, setFocusedIndex] = React4.useState(0);
10667
+ const [isKeyboardNavActive, setIsKeyboardNavActive] = React4.useState(false);
10668
+ const parentRef = React4.useRef(null);
10669
+ const virtualizer = useVirtualizer({
10670
+ count: filteredOptions.length,
10671
+ getScrollElement: () => parentRef.current,
10672
+ estimateSize: () => ROW_HEIGHT,
10673
+ overscan: 2
10674
+ });
10675
+ const virtualOptions = virtualizer.getVirtualItems();
10676
+ const dynamicHeight = React4.useMemo(() => {
10677
+ const contentHeight = filteredOptions.length * ROW_HEIGHT;
10678
+ if (contentHeight <= 0) {
10679
+ return MIN_HEIGHT_EMPTY;
10680
+ }
10681
+ return Math.max(ROW_HEIGHT, Math.min(height, contentHeight));
10682
+ }, [filteredOptions.length, height]);
10683
+ const scrollToIndex = React4.useCallback(
10684
+ (index) => {
10685
+ virtualizer.scrollToIndex(index, {
10686
+ align: "center"
10687
+ });
10688
+ },
10689
+ [virtualizer]
10690
+ );
10691
+ const handleSearch = React4.useCallback(
10692
+ (search) => {
10693
+ setIsKeyboardNavActive(false);
10694
+ setFilteredOptions(
10695
+ internalOptions.filter((option) => {
10696
+ if (typeof filterOption === "function") {
10697
+ return filterOption(search, option);
10698
+ }
10699
+ const labelValue = getLabelField(option);
10700
+ return labelValue?.toString()?.toLowerCase()?.includes?.(search.toLowerCase());
10701
+ })
10702
+ );
10703
+ },
10704
+ [filterOption, getLabelField, internalOptions]
10705
+ );
10706
+ const handleKeyDown = React4.useCallback(
10707
+ (event) => {
10708
+ switch (event.key) {
10709
+ case "ArrowDown": {
10710
+ event.preventDefault();
10711
+ setIsKeyboardNavActive(true);
10712
+ setFocusedIndex((prev) => {
10713
+ const newIndex = prev === -1 ? 0 : Math.min(prev + 1, filteredOptions.length - 1);
10714
+ scrollToIndex(newIndex);
10715
+ return newIndex;
10716
+ });
10717
+ break;
10718
+ }
10719
+ case "ArrowUp": {
10720
+ event.preventDefault();
10721
+ setIsKeyboardNavActive(true);
10722
+ setFocusedIndex((prev) => {
10723
+ const newIndex = prev === -1 ? filteredOptions.length - 1 : Math.max(prev - 1, 0);
10724
+ scrollToIndex(newIndex);
10725
+ return newIndex;
10726
+ });
10727
+ break;
10728
+ }
10729
+ case "Enter": {
10730
+ event.preventDefault();
10731
+ const option = filteredOptions?.[focusedIndex];
10732
+ if (option) {
10733
+ onSelect?.(getValueField(option), option);
10734
+ }
10735
+ break;
10736
+ }
10737
+ }
10738
+ },
10739
+ [filteredOptions, focusedIndex, getValueField, onSelect, scrollToIndex]
10740
+ );
10741
+ React4.useEffect(() => {
10742
+ if (value) {
10743
+ const option = filteredOptions.find((option2) => {
10744
+ const optionValue = getValueField(option2);
10745
+ return optionValue === value;
10746
+ });
10747
+ if (option) {
10748
+ const index = filteredOptions.indexOf(option);
10749
+ setFocusedIndex(index);
10750
+ virtualizer.scrollToIndex(index, { align: "center" });
10751
+ }
10752
+ }
10753
+ }, [value, filteredOptions, virtualizer, getValueField]);
10754
+ return /* @__PURE__ */ jsxs(Command, { shouldFilter: false, onKeyDown: handleKeyDown, onFocus, onBlur, children: [
10755
+ showSearch && /* @__PURE__ */ jsx(
10756
+ CommandInput,
10757
+ {
10758
+ onValueChange: handleSearch,
10759
+ placeholder: searchPlaceholder,
10760
+ "data-testid": `command-input-${name}`
10761
+ }
10762
+ ),
10763
+ /* @__PURE__ */ jsxs(
10764
+ CommandList,
10765
+ {
10766
+ ref: parentRef,
10767
+ className: "max-h-none",
10768
+ style: {
10769
+ height: dynamicHeight,
10770
+ width: "100%",
10771
+ overflow: "auto"
10772
+ },
10773
+ onMouseDown: () => setIsKeyboardNavActive(false),
10774
+ onMouseMove: () => setIsKeyboardNavActive(false),
10775
+ children: [
10776
+ /* @__PURE__ */ jsx(CommandEmpty, { "data-testid": `command-item-empty-${name}`, children: internalOptions.length === 0 ? emptyContent : notFoundContent }),
10777
+ /* @__PURE__ */ jsx(
10778
+ CommandGroup,
10779
+ {
10780
+ style: {
10781
+ height: `${virtualizer.getTotalSize()}px`,
10782
+ width: "100%",
10783
+ position: "relative"
10784
+ },
10785
+ children: virtualOptions.map((virtualOption, index) => {
10786
+ const option = filteredOptions[virtualOption.index];
10787
+ const optionLabel = getLabelField(option);
10788
+ const optionValue = getValueField(option);
10789
+ const labelRendered = labelRender ? labelRender(filteredOptions[virtualOption.index]) : optionLabel;
10790
+ return /* @__PURE__ */ jsxs(
10791
+ CommandItem,
10792
+ {
10793
+ className: cn("absolute left-0 top-0 w-full flex items-center justify-between", {
10794
+ "bg-sus-secondary-green-3 text-sus-green-2": focusedIndex === virtualOption.index,
10795
+ "aria-selected:bg-white aria-selected:text-black pointer-events-none": isKeyboardNavActive && focusedIndex !== virtualOption.index
10796
+ }),
10797
+ style: {
10798
+ height: `${virtualOption.size}px`,
10799
+ transform: `translateY(${virtualOption.start}px)`
10800
+ },
10801
+ value: optionValue,
10802
+ onMouseEnter: () => !isKeyboardNavActive && setFocusedIndex(virtualOption.index),
10803
+ onMouseLeave: () => !isKeyboardNavActive && setFocusedIndex(-1),
10804
+ onSelect: (selectedValue) => onSelect?.(selectedValue, option),
10805
+ disabled: disabledOption?.(option),
10806
+ "data-testid": `command-item-${index}-${optionValue}`,
10807
+ children: [
10808
+ typeof labelRendered === "string" ? /* @__PURE__ */ jsx(truncated_default, { tooltipProps: { disabled: true }, children: labelRendered }) : labelRendered,
10809
+ /* @__PURE__ */ jsx(
10810
+ Check,
10811
+ {
10812
+ className: cn(
10813
+ "mr-2 size-2 hover:text-sus-green-2",
10814
+ value === optionValue ? "opacity-100" : "opacity-0"
10815
+ )
10816
+ }
10817
+ )
10818
+ ]
10819
+ },
10820
+ optionValue
10821
+ );
10822
+ })
10823
+ }
10824
+ )
10825
+ ]
10826
+ }
10827
+ )
10828
+ ] });
10829
+ };
10830
+ var VirtualizedCommand_default = VirtualizedCommand;
10831
+ var ComboboxInner = ({
10832
+ name,
10833
+ dropdownName,
10834
+ defaultValue,
10835
+ className,
10836
+ options,
10837
+ value,
10838
+ disabled,
10839
+ placeholder: placeholder2,
10840
+ fieldNames,
10841
+ showClear = false,
10842
+ onSelect,
10843
+ onFocus,
10844
+ onBlur,
10845
+ disabledOption,
10846
+ emptyContent,
10847
+ filterOption,
10848
+ height,
10849
+ labelRender,
10850
+ notFoundContent,
10851
+ searchPlaceholder,
10852
+ showSearch,
10853
+ ...props
10854
+ }, ref) => {
10855
+ const { getValueField } = useFieldNames_default({ fieldNames });
10856
+ const [open, setOpen] = React4.useState(false);
10857
+ const { value: selectedValue, updateState: setSelectedValue } = useControllableState_default({
10858
+ defaultValue,
10859
+ value
10860
+ });
10861
+ const renderValue = React4.useMemo(() => {
10862
+ if (!selectedValue) return placeholder2;
10863
+ const selectedOptionFound = options?.find((option) => {
10864
+ const optionValue = getValueField(option);
10865
+ return optionValue === selectedValue;
10866
+ });
10867
+ return selectedOptionFound ? getValueField(selectedOptionFound) : null;
10868
+ }, [getValueField, options, placeholder2, selectedValue]);
10869
+ const handleSelect = React4.useCallback(
10870
+ (selected, option) => {
10871
+ setSelectedValue(selected);
10872
+ setOpen(false);
10873
+ if (typeof onSelect === "function") {
10874
+ onSelect(selected, option);
10875
+ }
10876
+ },
10877
+ [onSelect, setSelectedValue]
10878
+ );
10879
+ const handleClear = React4.useCallback(
10880
+ (event) => {
10881
+ event.stopPropagation();
10882
+ setSelectedValue(void 0);
10883
+ },
10884
+ [setSelectedValue]
10885
+ );
10886
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: (next) => !disabled && setOpen(next), children: [
10887
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
10888
+ "button",
10889
+ {
10890
+ ref,
10891
+ name,
10892
+ type: "button",
10893
+ role: "combobox",
10894
+ "aria-expanded": open,
10895
+ className: cn(
10896
+ "flex w-full items-center justify-between gap-2 rounded-md border bg-white px-3 h-9 text-sm whitespace-nowrap shadow-xs outline-none border-input",
10897
+ "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50",
10898
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
10899
+ "transition-all",
10900
+ className
10901
+ ),
10902
+ "data-state": open ? "open" : "closed",
10903
+ disabled,
10904
+ onFocus,
10905
+ onBlur,
10906
+ "data-testid": `combobox-trigger-${name}`,
10907
+ ...props,
10908
+ children: [
10909
+ /* @__PURE__ */ jsx(
10910
+ truncated_default,
10911
+ {
10912
+ className: cn(!selectedValue && "text-sus-gray-1"),
10913
+ tooltipProps: { disabled: true },
10914
+ children: renderValue
10915
+ }
10916
+ ),
10917
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
10918
+ /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 opacity-50" }),
10919
+ showClear && selectedValue && /* @__PURE__ */ jsx(
10920
+ "span",
10921
+ {
10922
+ role: "button",
10923
+ className: cn(
10924
+ "inline-flex items-center justify-center p-0 cursor-pointer transition-all size-[15px]"
10925
+ ),
10926
+ onClick: handleClear,
10927
+ "data-testid": `combobox-clear-button-${name}`,
10928
+ children: /* @__PURE__ */ jsx(X, { className: "size-[15px] bg-black text-white border border-black hover:bg-[#333] rounded-full" })
10929
+ }
10930
+ )
10931
+ ] })
10932
+ ]
10933
+ }
10934
+ ) }),
10935
+ /* @__PURE__ */ jsx(
10936
+ PopoverContent,
10937
+ {
10938
+ className: "p-0 w-(--radix-popper-anchor-width) min-w-(--radix-popper-anchor-width) max-w-(--radix-popper-available-width)",
10939
+ align: "start",
10940
+ sideOffset: 4,
10941
+ children: /* @__PURE__ */ jsx(
10942
+ VirtualizedCommand_default,
10943
+ {
10944
+ name: dropdownName,
10945
+ emptyContent,
10946
+ height,
10947
+ notFoundContent,
10948
+ searchPlaceholder,
10949
+ showSearch,
10950
+ fieldNames,
10951
+ options,
10952
+ value: selectedValue,
10953
+ disabledOption,
10954
+ filterOption,
10955
+ labelRender,
10956
+ onSelect: handleSelect
10957
+ }
10958
+ )
10959
+ }
10960
+ )
10961
+ ] });
10962
+ };
10963
+ var Combobox = React4.forwardRef(ComboboxInner);
10964
+ var Combobox_default = Combobox;
10398
10965
 
10399
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionMenu, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, CropperModalError, DIALOG_ALERT_I18N_SUBNAMESPACE, DIALOG_ALERT_TEMPLATES, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, filters_default as FiltersIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, Input, InputNumber_default as InputNumber, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, calendar_default as SuiCalendarIcon, calendar2_default as SuiCalendarIcon2, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip2 as Tooltip, TooltipArrow, TooltipContent2 as TooltipContent, TooltipProvider2 as TooltipProvider, TooltipTrigger2 as TooltipTrigger, truncated_default as Truncated, ui_exports as UI, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated, validateTokenPrefixes };
10966
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionMenu, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Combobox_default as Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CropperModal, CropperModalError, DIALOG_ALERT_I18N_SUBNAMESPACE, DIALOG_ALERT_TEMPLATES, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, filters_default as FiltersIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, Input, InputNumber_default as InputNumber, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, calendar_default as SuiCalendarIcon, calendar2_default as SuiCalendarIcon2, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip2 as Tooltip, TooltipArrow, TooltipContent2 as TooltipContent, TooltipProvider2 as TooltipProvider, TooltipTrigger2 as TooltipTrigger, truncated_default as Truncated, ui_exports as UI, VirtualizedCommand_default as VirtualizedCommand, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useControllableState_default as useControllableState, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated, validateTokenPrefixes };
10400
10967
  //# sourceMappingURL=index.mjs.map
10401
10968
  //# sourceMappingURL=index.mjs.map