periplo-ui 4.3.0 → 4.4.0

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.
Files changed (42) hide show
  1. package/dist/components/Combobox/Combobox.d.ts +0 -42
  2. package/dist/components/Combobox/Combobox.js +22 -60
  3. package/dist/components/Combobox/Combobox.js.map +1 -1
  4. package/dist/components/Combobox/ComboboxTrigger.d.ts +14 -0
  5. package/dist/components/Combobox/ComboboxTrigger.js +74 -0
  6. package/dist/components/Combobox/ComboboxTrigger.js.map +1 -0
  7. package/dist/components/Combobox/StaticComboboxList.js +9 -2
  8. package/dist/components/Combobox/StaticComboboxList.js.map +1 -1
  9. package/dist/components/Combobox/VirtualizedComboboxList.d.ts +1 -1
  10. package/dist/components/Combobox/VirtualizedComboboxList.js +2 -16
  11. package/dist/components/Combobox/VirtualizedComboboxList.js.map +1 -1
  12. package/dist/components/Combobox/hooks/index.d.ts +6 -0
  13. package/dist/components/Combobox/hooks/index.js +7 -0
  14. package/dist/components/Combobox/hooks/index.js.map +1 -0
  15. package/dist/components/Combobox/hooks/useComboboxOpenState.d.ts +7 -0
  16. package/dist/components/Combobox/hooks/useComboboxOpenState.js +18 -0
  17. package/dist/components/Combobox/hooks/useComboboxOpenState.js.map +1 -0
  18. package/dist/components/Combobox/hooks/useComboboxSelection.d.ts +7 -0
  19. package/dist/components/Combobox/hooks/useComboboxSelection.js +49 -0
  20. package/dist/components/Combobox/hooks/useComboboxSelection.js.map +1 -0
  21. package/dist/components/Combobox/hooks/useDebouncedState.d.ts +5 -0
  22. package/dist/components/Combobox/hooks/useDebouncedState.js +19 -0
  23. package/dist/components/Combobox/hooks/useDebouncedState.js.map +1 -0
  24. package/dist/components/Combobox/hooks/useDisplayValue.d.ts +11 -0
  25. package/dist/components/Combobox/hooks/useDisplayValue.js +32 -0
  26. package/dist/components/Combobox/hooks/useDisplayValue.js.map +1 -0
  27. package/dist/components/Combobox/hooks/usePaginatedOptions.d.ts +24 -0
  28. package/dist/components/Combobox/hooks/usePaginatedOptions.js +54 -0
  29. package/dist/components/Combobox/hooks/usePaginatedOptions.js.map +1 -0
  30. package/dist/components/Combobox/hooks/useSelectedCache.d.ts +4 -0
  31. package/dist/components/Combobox/hooks/useSelectedCache.js +17 -0
  32. package/dist/components/Combobox/hooks/useSelectedCache.js.map +1 -0
  33. package/dist/components/Combobox/types.d.ts +0 -1
  34. package/dist/components/Combobox/useCombobox.d.ts +3 -3
  35. package/dist/components/Combobox/useCombobox.js +25 -159
  36. package/dist/components/Combobox/useCombobox.js.map +1 -1
  37. package/dist/components/Tooltip/Tooltip.d.ts +7 -1
  38. package/dist/components/Tooltip/Tooltip.js +31 -24
  39. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  40. package/dist/components/Tooltip/index.js +1 -1
  41. package/dist/index.js +1 -1
  42. package/package.json +1 -1
@@ -92,54 +92,12 @@ export type ComboboxProps<T> = ComboboxSingleProps<T> | ComboboxMultipleProps<T>
92
92
  *
93
93
  * @example Basic usage
94
94
  * ```tsx
95
- * interface User {
96
- * id: string
97
- * name: string
98
- * email: string
99
- * }
100
- *
101
- * <Combobox<User>
102
- * options={users}
103
- * value={selectedUserId}
104
- * onChange={setSelectedUserId}
105
- * getOptionValue={(user) => user.id}
106
- * getOptionLabel={(user) => user.name}
107
- * />
108
- * ```
109
- *
110
- * @example Custom filtering
111
- * ```tsx
112
95
  * <Combobox<User>
113
96
  * options={users}
114
97
  * value={selectedUserId}
115
98
  * onChange={setSelectedUserId}
116
99
  * getOptionValue={(user) => user.id}
117
100
  * getOptionLabel={(user) => user.name}
118
- * filterOptions={(options, searchTerm) =>
119
- * options.filter(user =>
120
- * user.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
121
- * user.email.toLowerCase().includes(searchTerm.toLowerCase())
122
- * )
123
- * }
124
- * />
125
- * ```
126
- *
127
- * @example Virtualized infinite scrolling with pagination
128
- * ```tsx
129
- * <Combobox<User>
130
- * options={[]} // Initial options can be empty
131
- * value={selectedUserId}
132
- * onChange={setSelectedUserId}
133
- * getOptionValue={(user) => user.id}
134
- * getOptionLabel={(user) => user.name}
135
- * fetchPage={async ({ page, search }) => {
136
- * const response = await api.getUsers({ page, search })
137
- * return {
138
- * items: response.users,
139
- * hasNextPage: response.page < response.totalPages,
140
- * nextPage: page + 1
141
- * }
142
- * }}
143
101
  * />
144
102
  * ```
145
103
  */
@@ -1,11 +1,9 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { CaretDown } from '@phosphor-icons/react/dist/ssr/CaretDown';
3
- import { X } from '@phosphor-icons/react/dist/ssr/X';
4
- import { useRef } from 'react';
2
+ import { useRef, useEffect } from 'react';
5
3
  import { cn } from '../../lib/utils.js';
6
- import { Button, buttonVariants } from '../Button/Button.js';
7
4
  import { Command, CommandInput } from '../Command/Command.js';
8
5
  import { PopoverRoot, PopoverTrigger, PopoverContent } from '../Popover/Popover.js';
6
+ import { ComboboxTrigger } from './ComboboxTrigger.js';
9
7
  import { StaticComboboxList } from './StaticComboboxList.js';
10
8
  import { useCombobox } from './useCombobox.js';
11
9
  import { VirtualizedComboboxList } from './VirtualizedComboboxList.js';
@@ -57,6 +55,12 @@ const Combobox = (props) => {
57
55
  handleClear,
58
56
  loadNextPage
59
57
  } = useCombobox(props);
58
+ useEffect(() => {
59
+ if (!open || !onOpenAutoFocus) return;
60
+ const timeoutId = globalThis.setTimeout(() => searchInputRef.current?.focus(), 0);
61
+ return () => globalThis.clearTimeout(timeoutId);
62
+ }, [open, onOpenAutoFocus]);
63
+ const hasMultipleRenderLabel = !!(multiple && "renderLabel" in props && props.renderLabel);
60
64
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-1", children: [
61
65
  /* @__PURE__ */ jsxs(PopoverRoot, { open, onOpenChange: setOpen, modal, children: [
62
66
  /* @__PURE__ */ jsx(
@@ -76,59 +80,21 @@ const Combobox = (props) => {
76
80
  event.preventDefault();
77
81
  event.stopPropagation();
78
82
  },
79
- children: /* @__PURE__ */ jsxs(
80
- Button,
83
+ children: /* @__PURE__ */ jsx(
84
+ ComboboxTrigger,
81
85
  {
82
86
  id,
83
- type: "button",
84
87
  disabled,
85
- variant: "text",
86
- className: cn(
87
- buttonVariants({ variant: "input", size: "lg" }),
88
- "relative flex justify-between rounded-lg",
89
- multiple && "renderLabel" in props && props.renderLabel ? "h-auto min-h-12" : "h-12",
90
- open && "border-neutral-950",
91
- disabled && "cursor-not-allowed",
92
- error && "border-error-400 focus-visible:border-error-700",
93
- className
94
- ),
95
- "aria-expanded": open,
96
- "aria-haspopup": "listbox",
97
- onMouseEnter: () => setIsHovered(true),
98
- onMouseLeave: () => setIsHovered(false),
99
- children: [
100
- /* @__PURE__ */ jsx(
101
- "span",
102
- {
103
- className: cn(
104
- "block",
105
- !hasValue && "text-neutral-300",
106
- !(multiple && "renderLabel" in props && props.renderLabel) && "truncate"
107
- ),
108
- children: displayValue
109
- }
110
- ),
111
- /* @__PURE__ */ jsx(
112
- CaretDown,
113
- {
114
- className: cn(
115
- "h-4 w-4 shrink-0 opacity-50 transition-opacity duration-150",
116
- showClearButton ? "opacity-0" : "opacity-50"
117
- )
118
- }
119
- ),
120
- onClear && hasValue && /* @__PURE__ */ jsx(
121
- X,
122
- {
123
- "data-testid": "clear-button",
124
- className: cn(
125
- "absolute right-4 z-10 h-4 w-4 shrink-0 cursor-pointer transition-opacity duration-150",
126
- showClearButton ? "opacity-100 hover:opacity-70" : "opacity-0"
127
- ),
128
- onClick: handleClear
129
- }
130
- )
131
- ]
88
+ open,
89
+ error,
90
+ hasValue,
91
+ showClearButton,
92
+ showClearIcon: !!onClear,
93
+ isMultilineLabel: hasMultipleRenderLabel,
94
+ displayValue,
95
+ className,
96
+ onHoverChange: setIsHovered,
97
+ onClear: handleClear
132
98
  }
133
99
  )
134
100
  }
@@ -140,10 +106,7 @@ const Combobox = (props) => {
140
106
  container,
141
107
  side: "bottom",
142
108
  align,
143
- onOpenAutoFocus: onOpenAutoFocus ? (event) => {
144
- event.preventDefault();
145
- searchInputRef.current?.focus();
146
- } : void 0,
109
+ onOpenAutoFocus: onOpenAutoFocus ? (event) => event.preventDefault() : void 0,
147
110
  children: /* @__PURE__ */ jsxs(Command, { shouldFilter: false, children: [
148
111
  /* @__PURE__ */ jsx(
149
112
  CommandInput,
@@ -170,8 +133,7 @@ const Combobox = (props) => {
170
133
  maxHeight: boundedListMaxHeight,
171
134
  hasNextPage,
172
135
  loadingMore,
173
- onLoadMore: loadNextPage,
174
- open
136
+ onLoadMore: loadNextPage
175
137
  }
176
138
  ) : /* @__PURE__ */ jsx(
177
139
  StaticComboboxList,
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { CaretDown } from '@phosphor-icons/react/dist/ssr/CaretDown'\nimport { X } from '@phosphor-icons/react/dist/ssr/X'\nimport { useRef } from 'react'\n\nimport { cn } from '../../lib/utils'\nimport { Button, buttonVariants } from '../Button'\nimport { Command, CommandInput } from '../Command'\nimport { PopoverContent, PopoverRoot, PopoverTrigger } from '../Popover'\n\nimport { StaticComboboxList } from './StaticComboboxList'\nimport { useCombobox } from './useCombobox'\nimport { VirtualizedComboboxList } from './VirtualizedComboboxList'\n\ntype ComboboxBaseProps<T> = {\n /** Unique identifier for the combobox */\n id?: string\n /** Array of options to display in the combobox */\n options: Array<T>\n /** Function to get the unique identifier from an option. */\n getOptionValue: (option: T) => string\n /** Function to get the display text from an option. */\n getOptionLabel: (option: T) => string\n /** Custom render function for options. If not provided, defaults to showing a checkmark and label */\n renderOption?: (option: T, isSelected: boolean) => React.ReactNode\n /** Placeholder text shown when no option is selected */\n placeholder?: string\n /** Placeholder text for the search input field */\n searchPlaceholder?: string\n /** Message shown when no options match the search query */\n emptyMessage?: string\n /** Additional CSS classes to apply to the combobox trigger */\n className?: string\n /** Additional CSS classes to apply to the popover content */\n contentClassName?: string\n /** Whether the combobox is disabled */\n disabled?: boolean\n /** Maximum height of the options list. Can be any valid CSS height value */\n maxHeight?: string | number\n /** Whether to close the dropdown when an option is selected. Defaults to `true` for single select and `false` for multi-select. */\n closeOnSelect?: boolean\n /** Whether the combobox is in a loading state */\n loading?: boolean\n /** Message to show when in loading state */\n loadingPlaceholder?: string\n /** Whether the combobox has an error */\n error?: boolean | string\n /** Custom function to filter options based on search term */\n filterOptions?: (options: Array<T>, searchTerm: string) => Array<T>\n /** Callback function executed when the clear button is clicked. When provided, an X button will appear on hover to clear the selection. */\n onClear?: boolean | (() => void)\n /** Whether the selection can be cleared */\n clearable?: boolean\n /** Whether the combobox is inside a modal */\n modal?: boolean\n /** Placeholder text for the selected multiple options */\n selectedMultiplePlaceholder?: string\n /** Placeholder text for the multiple options */\n multipleOptionsPlaceholder?: string\n /** Special options that appear at the top with their own title. When selected, the combobox switches to single-select mode. */\n specialOptions?: Array<T>\n /** Title for the special options group */\n specialOptionsTitle?: string\n /** Container element to position the combobox relative to. */\n container?: HTMLElement\n /** Alignment of the dropdown relative to the trigger. Defaults to 'center'. */\n align?: 'start' | 'center' | 'end'\n /** Auto-focus the search input when the dropdown opens. */\n onOpenAutoFocus?: boolean\n}\n\nexport type ComboboxSingleProps<T> = ComboboxBaseProps<T> & {\n multiple?: false\n value?: string\n onChange: (value: string) => void\n /** Custom render function for the selected value display. */\n renderLabel?: (selectedOption: T) => React.ReactNode\n /**\n * Async pagination function.\n * Note: Multiple selection is not supported with virtualization.\n */\n fetchPage?: (params: {\n page: number\n search?: string\n }) => Promise<{ items: Array<T>; hasNextPage: boolean; nextPage: number }>\n /** Prefetch the first page on mount (virtualized only), so data is ready before opening. */\n prefetch?: boolean\n}\n\nexport type ComboboxMultipleProps<T> = ComboboxBaseProps<T> & {\n multiple: true\n value?: Array<string>\n onChange: (value: Array<string>) => void\n /** Custom render function for the selected value(s) display. */\n renderLabel?: (selectedOptions: Array<T>, onRemove: (value: string) => void) => React.ReactNode\n /** fetchPage is not allowed with multiple selection */\n fetchPage?: never\n /** prefetch is not allowed with multiple selection */\n prefetch?: never\n}\n\nexport type ComboboxProps<T> = ComboboxSingleProps<T> | ComboboxMultipleProps<T>\n\n/**\n * A searchable combobox component with support for custom rendering, keyboard navigation, and search filtering.\n *\n * @example Basic usage\n * ```tsx\n * interface User {\n * id: string\n * name: string\n * email: string\n * }\n *\n * <Combobox<User>\n * options={users}\n * value={selectedUserId}\n * onChange={setSelectedUserId}\n * getOptionValue={(user) => user.id}\n * getOptionLabel={(user) => user.name}\n * />\n * ```\n *\n * @example Custom filtering\n * ```tsx\n * <Combobox<User>\n * options={users}\n * value={selectedUserId}\n * onChange={setSelectedUserId}\n * getOptionValue={(user) => user.id}\n * getOptionLabel={(user) => user.name}\n * filterOptions={(options, searchTerm) =>\n * options.filter(user =>\n * user.name.toLowerCase().includes(searchTerm.toLowerCase()) ||\n * user.email.toLowerCase().includes(searchTerm.toLowerCase())\n * )\n * }\n * />\n * ```\n *\n * @example Virtualized infinite scrolling with pagination\n * ```tsx\n * <Combobox<User>\n * options={[]} // Initial options can be empty\n * value={selectedUserId}\n * onChange={setSelectedUserId}\n * getOptionValue={(user) => user.id}\n * getOptionLabel={(user) => user.name}\n * fetchPage={async ({ page, search }) => {\n * const response = await api.getUsers({ page, search })\n * return {\n * items: response.users,\n * hasNextPage: response.page < response.totalPages,\n * nextPage: page + 1\n * }\n * }}\n * />\n * ```\n */\nexport const Combobox = <T extends object>(props: ComboboxProps<T>) => {\n const {\n id,\n options,\n getOptionValue,\n getOptionLabel,\n searchPlaceholder = 'Search...',\n emptyMessage = 'No results found.',\n className = 'w-60',\n contentClassName,\n disabled = false,\n maxHeight = '300px',\n renderOption,\n loading = false,\n loadingPlaceholder = 'Cargando...',\n error = false,\n multiple,\n onClear,\n modal = false,\n selectedMultiplePlaceholder = 'Selected',\n multipleOptionsPlaceholder = 'Options',\n specialOptions,\n specialOptionsTitle,\n container,\n align,\n onOpenAutoFocus = false,\n } = props\n\n const searchInputRef = useRef<HTMLInputElement>(null)\n\n const normalizedMaxHeight = typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight\n const boundedListMaxHeight = `min(${normalizedMaxHeight}, max(120px, calc(var(--radix-popover-content-available-height, 100dvh) - 68px)))`\n\n const {\n open,\n setOpen,\n searchTerm,\n setSearchTerm,\n setIsHovered,\n hasNextPage,\n loadingMore,\n isVirtualized,\n filteredOptions,\n displayValue,\n hasValue,\n showClearButton,\n handleSelect,\n handleClear,\n loadNextPage,\n } = useCombobox(props)\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <PopoverRoot open={open} onOpenChange={setOpen} modal={modal}>\n <PopoverTrigger\n asChild\n onPointerDown={(event) => {\n event.stopPropagation()\n if (open) {\n setOpen(false)\n event.preventDefault()\n } else {\n setOpen(true)\n }\n }}\n onClick={(event) => {\n event.preventDefault()\n event.stopPropagation()\n }}\n >\n <Button\n id={id}\n type=\"button\"\n disabled={disabled}\n variant=\"text\"\n className={cn(\n buttonVariants({ variant: 'input', size: 'lg' }),\n 'relative flex justify-between rounded-lg',\n multiple && 'renderLabel' in props && props.renderLabel ? 'h-auto min-h-12' : 'h-12',\n open && 'border-neutral-950',\n disabled && 'cursor-not-allowed',\n error && 'border-error-400 focus-visible:border-error-700',\n className,\n )}\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <span\n className={cn(\n 'block',\n !hasValue && 'text-neutral-300',\n !(multiple && 'renderLabel' in props && props.renderLabel) && 'truncate',\n )}\n >\n {displayValue}\n </span>\n <CaretDown\n className={cn(\n 'h-4 w-4 shrink-0 opacity-50 transition-opacity duration-150',\n showClearButton ? 'opacity-0' : 'opacity-50',\n )}\n />\n {onClear && hasValue && (\n <X\n data-testid=\"clear-button\"\n className={cn(\n 'absolute right-4 z-10 h-4 w-4 shrink-0 cursor-pointer transition-opacity duration-150',\n showClearButton ? 'opacity-100 hover:opacity-70' : 'opacity-0',\n )}\n onClick={handleClear}\n />\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n className={cn('overflow-hidden p-0', contentClassName)}\n container={container}\n side=\"bottom\"\n align={align}\n onOpenAutoFocus={\n onOpenAutoFocus\n ? (event) => {\n event.preventDefault()\n searchInputRef.current?.focus()\n }\n : undefined\n }\n >\n <Command shouldFilter={false}>\n <CommandInput\n ref={searchInputRef}\n placeholder={searchPlaceholder}\n disabled={loading}\n value={searchTerm}\n onValueChange={setSearchTerm}\n />\n {isVirtualized ? (\n <VirtualizedComboboxList\n localOptions={filteredOptions}\n loading={loading}\n loadingPlaceholder={loadingPlaceholder}\n emptyMessage={emptyMessage}\n value={props.value as string}\n getOptionValue={getOptionValue}\n getOptionLabel={getOptionLabel}\n handleSelect={handleSelect}\n renderOption={renderOption}\n maxHeight={boundedListMaxHeight}\n hasNextPage={hasNextPage}\n loadingMore={loadingMore}\n onLoadMore={loadNextPage}\n open={open}\n />\n ) : (\n <StaticComboboxList\n filteredOptions={filteredOptions}\n loading={loading}\n loadingPlaceholder={loadingPlaceholder}\n emptyMessage={emptyMessage}\n multiple={!!multiple}\n value={props.value}\n getOptionValue={getOptionValue}\n getOptionLabel={getOptionLabel}\n handleSelect={handleSelect}\n renderOption={renderOption}\n maxHeight={boundedListMaxHeight}\n selectedMultiplePlaceholder={selectedMultiplePlaceholder}\n multipleOptionsPlaceholder={multipleOptionsPlaceholder}\n options={options}\n specialOptions={specialOptions}\n specialOptionsTitle={specialOptionsTitle}\n />\n )}\n </Command>\n </PopoverContent>\n </PopoverRoot>\n {typeof error === 'string' && <span className=\"text-error-500 text-sm\">{error}</span>}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA8JO,MAAM,QAAA,GAAW,CAAmB,KAAA,KAA4B;AACrE,EAAA,MAAM;AAAA,IACJ,EAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA,GAAoB,WAAA;AAAA,IACpB,YAAA,GAAe,mBAAA;AAAA,IACf,SAAA,G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AA;AAAA,cAAA;AAAA,gBACC,YAAA,EAAc,eAAA;AAAA,gBACd,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,YAAA;AAAA,gBACA,OAAO,KAAA,CAAM,KAAA;AAAA,gBACb,cAAA;AAAA,gBACA,cAAA;AAAA,gBACA,YAAA;AAAA,gBACA,YAAA;AAAA,gBACA,SAAA,EAAW,oBAAA;AAAA,gBACX,WAAA;AAAA,gBACA,WAAA;AAAA,gBACA,UAAA,EAAY,YAAA;AAAA,gBACZ;AAAA;AAAA,aACF,mBAEA,GAAA;AAAA,cAAC,kBAAA;AAAA,cAAA;AAAA,gBACC,eAAA;AAAA,gBACA,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,YAAA;AAAA,gBACA,QAAA,EAAU,CAAC,CAAC,QAAA;AAAA,gBACZ,OAAO,KAAA,CAAM,KAAA;AAAA,gBACb,cAAA;AAAA,gBACA,cAAA;AAAA,gBACA,YAAA;AAAA,gBACA,YAAA;AAAA,gBACA,SAAA,EAAW,oBAAA;AAAA,gBACX,2BAAA;AAAA,gBACA,0BAAA;AAAA,gBACA,OAAA;AAAA,gBACA,cAAA;AAAA,gBACA;AAAA;AAAA;AACF,WAAA,EAEJ;AAAA;AAAA;AACF,KAAA,EACF,CAAA;AAAA,IACC,OAAO,KAAA,KAAU,QAAA,wBAAa,MAAA,EAAA,EAAK,SAAA,EAAU,0BAA0B,QAAA,EAAA,KAAA,EAAM;AAAA,GAAA,EAChF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"Combobox.js","sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nimport { cn } from '../../lib/utils'\nimport { Command, CommandInput } from '../Command'\nimport { PopoverContent, PopoverRoot, PopoverTrigger } from '../Popover'\n\nimport { ComboboxTrigger } from './ComboboxTrigger'\nimport { StaticComboboxList } from './StaticComboboxList'\nimport { useCombobox } from './useCombobox'\nimport { VirtualizedComboboxList } from './VirtualizedComboboxList'\n\ntype ComboboxBaseProps<T> = {\n /** Unique identifier for the combobox */\n id?: string\n /** Array of options to display in the combobox */\n options: Array<T>\n /** Function to get the unique identifier from an option. */\n getOptionValue: (option: T) => string\n /** Function to get the display text from an option. */\n getOptionLabel: (option: T) => string\n /** Custom render function for options. If not provided, defaults to showing a checkmark and label */\n renderOption?: (option: T, isSelected: boolean) => React.ReactNode\n /** Placeholder text shown when no option is selected */\n placeholder?: string\n /** Placeholder text for the search input field */\n searchPlaceholder?: string\n /** Message shown when no options match the search query */\n emptyMessage?: string\n /** Additional CSS classes to apply to the combobox trigger */\n className?: string\n /** Additional CSS classes to apply to the popover content */\n contentClassName?: string\n /** Whether the combobox is disabled */\n disabled?: boolean\n /** Maximum height of the options list. Can be any valid CSS height value */\n maxHeight?: string | number\n /** Whether to close the dropdown when an option is selected. Defaults to `true` for single select and `false` for multi-select. */\n closeOnSelect?: boolean\n /** Whether the combobox is in a loading state */\n loading?: boolean\n /** Message to show when in loading state */\n loadingPlaceholder?: string\n /** Whether the combobox has an error */\n error?: boolean | string\n /** Custom function to filter options based on search term */\n filterOptions?: (options: Array<T>, searchTerm: string) => Array<T>\n /** Callback function executed when the clear button is clicked. When provided, an X button will appear on hover to clear the selection. */\n onClear?: boolean | (() => void)\n /** Whether the selection can be cleared */\n clearable?: boolean\n /** Whether the combobox is inside a modal */\n modal?: boolean\n /** Placeholder text for the selected multiple options */\n selectedMultiplePlaceholder?: string\n /** Placeholder text for the multiple options */\n multipleOptionsPlaceholder?: string\n /** Special options that appear at the top with their own title. When selected, the combobox switches to single-select mode. */\n specialOptions?: Array<T>\n /** Title for the special options group */\n specialOptionsTitle?: string\n /** Container element to position the combobox relative to. */\n container?: HTMLElement\n /** Alignment of the dropdown relative to the trigger. Defaults to 'center'. */\n align?: 'start' | 'center' | 'end'\n /** Auto-focus the search input when the dropdown opens. */\n onOpenAutoFocus?: boolean\n}\n\nexport type ComboboxSingleProps<T> = ComboboxBaseProps<T> & {\n multiple?: false\n value?: string\n onChange: (value: string) => void\n /** Custom render function for the selected value display. */\n renderLabel?: (selectedOption: T) => React.ReactNode\n /**\n * Async pagination function.\n * Note: Multiple selection is not supported with virtualization.\n */\n fetchPage?: (params: {\n page: number\n search?: string\n }) => Promise<{ items: Array<T>; hasNextPage: boolean; nextPage: number }>\n /** Prefetch the first page on mount (virtualized only), so data is ready before opening. */\n prefetch?: boolean\n}\n\nexport type ComboboxMultipleProps<T> = ComboboxBaseProps<T> & {\n multiple: true\n value?: Array<string>\n onChange: (value: Array<string>) => void\n /** Custom render function for the selected value(s) display. */\n renderLabel?: (selectedOptions: Array<T>, onRemove: (value: string) => void) => React.ReactNode\n /** fetchPage is not allowed with multiple selection */\n fetchPage?: never\n /** prefetch is not allowed with multiple selection */\n prefetch?: never\n}\n\nexport type ComboboxProps<T> = ComboboxSingleProps<T> | ComboboxMultipleProps<T>\n\n/**\n * A searchable combobox component with support for custom rendering, keyboard navigation, and search filtering.\n *\n * @example Basic usage\n * ```tsx\n * <Combobox<User>\n * options={users}\n * value={selectedUserId}\n * onChange={setSelectedUserId}\n * getOptionValue={(user) => user.id}\n * getOptionLabel={(user) => user.name}\n * />\n * ```\n */\nexport const Combobox = <T extends object>(props: ComboboxProps<T>) => {\n const {\n id,\n options,\n getOptionValue,\n getOptionLabel,\n searchPlaceholder = 'Search...',\n emptyMessage = 'No results found.',\n className = 'w-60',\n contentClassName,\n disabled = false,\n maxHeight = '300px',\n renderOption,\n loading = false,\n loadingPlaceholder = 'Cargando...',\n error = false,\n multiple,\n onClear,\n modal = false,\n selectedMultiplePlaceholder = 'Selected',\n multipleOptionsPlaceholder = 'Options',\n specialOptions,\n specialOptionsTitle,\n container,\n align,\n onOpenAutoFocus = false,\n } = props\n\n const searchInputRef = useRef<HTMLInputElement>(null)\n\n const normalizedMaxHeight = typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight\n const boundedListMaxHeight = `min(${normalizedMaxHeight}, max(120px, calc(var(--radix-popover-content-available-height, 100dvh) - 68px)))`\n\n const {\n open,\n setOpen,\n searchTerm,\n setSearchTerm,\n setIsHovered,\n hasNextPage,\n loadingMore,\n isVirtualized,\n filteredOptions,\n displayValue,\n hasValue,\n showClearButton,\n handleSelect,\n handleClear,\n loadNextPage,\n } = useCombobox(props)\n\n useEffect(() => {\n if (!open || !onOpenAutoFocus) return\n const timeoutId = globalThis.setTimeout(() => searchInputRef.current?.focus(), 0)\n return () => globalThis.clearTimeout(timeoutId)\n }, [open, onOpenAutoFocus])\n\n const hasMultipleRenderLabel = !!(multiple && 'renderLabel' in props && props.renderLabel)\n\n return (\n <div className=\"flex w-full flex-col gap-1\">\n <PopoverRoot open={open} onOpenChange={setOpen} modal={modal}>\n <PopoverTrigger\n asChild\n onPointerDown={(event) => {\n event.stopPropagation()\n if (open) {\n setOpen(false)\n event.preventDefault()\n } else {\n setOpen(true)\n }\n }}\n onClick={(event) => {\n event.preventDefault()\n event.stopPropagation()\n }}\n >\n <ComboboxTrigger\n id={id}\n disabled={disabled}\n open={open}\n error={error}\n hasValue={hasValue}\n showClearButton={showClearButton}\n showClearIcon={!!onClear}\n isMultilineLabel={hasMultipleRenderLabel}\n displayValue={displayValue}\n className={className}\n onHoverChange={setIsHovered}\n onClear={handleClear}\n />\n </PopoverTrigger>\n <PopoverContent\n className={cn('overflow-hidden p-0', contentClassName)}\n container={container}\n side=\"bottom\"\n align={align}\n onOpenAutoFocus={onOpenAutoFocus ? (event) => event.preventDefault() : undefined}\n >\n <Command shouldFilter={false}>\n <CommandInput\n ref={searchInputRef}\n placeholder={searchPlaceholder}\n disabled={loading}\n value={searchTerm}\n onValueChange={setSearchTerm}\n />\n {isVirtualized ? (\n <VirtualizedComboboxList\n localOptions={filteredOptions}\n loading={loading}\n loadingPlaceholder={loadingPlaceholder}\n emptyMessage={emptyMessage}\n value={props.value as string}\n getOptionValue={getOptionValue}\n getOptionLabel={getOptionLabel}\n handleSelect={handleSelect}\n renderOption={renderOption}\n maxHeight={boundedListMaxHeight}\n hasNextPage={hasNextPage}\n loadingMore={loadingMore}\n onLoadMore={loadNextPage}\n />\n ) : (\n <StaticComboboxList\n filteredOptions={filteredOptions}\n loading={loading}\n loadingPlaceholder={loadingPlaceholder}\n emptyMessage={emptyMessage}\n multiple={!!multiple}\n value={props.value}\n getOptionValue={getOptionValue}\n getOptionLabel={getOptionLabel}\n handleSelect={handleSelect}\n renderOption={renderOption}\n maxHeight={boundedListMaxHeight}\n selectedMultiplePlaceholder={selectedMultiplePlaceholder}\n multipleOptionsPlaceholder={multipleOptionsPlaceholder}\n options={options}\n specialOptions={specialOptions}\n specialOptionsTitle={specialOptionsTitle}\n />\n )}\n </Command>\n </PopoverContent>\n </PopoverRoot>\n {typeof error === 'string' && <span className=\"text-error-500 text-sm\">{error}</span>}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;AAkHO,MAAM,QAAA,GAAW,CAAmB,KAAA,KAA4B;AACrE,EAAA,MAAM;AAAA,IACJ,EAAA;AAAA,IACA,OAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA,GAAoB,WAAA;AAAA,IACpB,YAAA,GAAe,mBAAA;AAAA,IACf,SAAA,GAAY,MAAA;AAAA,IACZ,gBAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,SAAA,GAAY,OAAA;AAAA,IACZ,YAAA;AAAA,IACA,OAAA,GAAU,KAAA;AAAA,IACV,kBAAA,GAAqB,aAAA;AAAA,IACrB,KAAA,GAAQ,KAAA;AAAA,IACR,QAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA,GAAQ,KAAA;AAAA,IACR,2BAAA,GAA8B,UAAA;AAAA,IAC9B,0BAAA,GAA6B,SAAA;AAAA,IAC7B,cAAA;AAAA,IACA,mBAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,eAAA,GAAkB;AAAA,GACpB,GAAI,KAAA;AAEJ,EAAA,MAAM,cAAA,GAAiB,OAAyB,IAAI,CAAA;AAE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aAAA,mBACC,GAAA;AAAA,cAAC,uBAAA;AAAA,cAAA;AAAA,gBACC,YAAA,EAAc,eAAA;AAAA,gBACd,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,YAAA;AAAA,gBACA,OAAO,KAAA,CAAM,KAAA;AAAA,gBACb,cAAA;AAAA,gBACA,cAAA;AAAA,gBACA,YAAA;AAAA,gBACA,YAAA;AAAA,gBACA,SAAA,EAAW,oBAAA;AAAA,gBACX,WAAA;AAAA,gBACA,WAAA;AAAA,gBACA,UAAA,EAAY;AAAA;AAAA,aACd,mBAEA,GAAA;AAAA,cAAC,kBAAA;AAAA,cAAA;AAAA,gBACC,eAAA;AAAA,gBACA,OAAA;AAAA,gBACA,kBAAA;AAAA,gBACA,YAAA;AAAA,gBACA,QAAA,EAAU,CAAC,CAAC,QAAA;AAAA,gBACZ,OAAO,KAAA,CAAM,KAAA;AAAA,gBACb,cAAA;AAAA,gBACA,cAAA;AAAA,gBACA,YAAA;AAAA,gBACA,YAAA;AAAA,gBACA,SAAA,EAAW,oBAAA;AAAA,gBACX,2BAAA;AAAA,gBACA,0BAAA;AAAA,gBACA,OAAA;AAAA,gBACA,cAAA;AAAA,gBACA;AAAA;AAAA;AACF,WAAA,EAEJ;AAAA;AAAA;AACF,KAAA,EACF,CAAA;AAAA,IACC,OAAO,KAAA,KAAU,QAAA,wBAAa,MAAA,EAAA,EAAK,SAAA,EAAU,0BAA0B,QAAA,EAAA,KAAA,EAAM;AAAA,GAAA,EAChF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,14 @@
1
+ export declare const ComboboxTrigger: import('react').ForwardRefExoticComponent<Readonly<{
2
+ id?: string;
3
+ disabled?: boolean;
4
+ open: boolean;
5
+ error?: boolean | string;
6
+ hasValue: boolean;
7
+ showClearButton: unknown;
8
+ showClearIcon: boolean;
9
+ isMultilineLabel: boolean;
10
+ displayValue: React.ReactNode;
11
+ className?: string;
12
+ onHoverChange: (hovered: boolean) => void;
13
+ onClear: (event: React.MouseEvent) => void;
14
+ }> & import('react').RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,74 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { CaretDown } from '@phosphor-icons/react/dist/ssr/CaretDown';
3
+ import { X } from '@phosphor-icons/react/dist/ssr/X';
4
+ import { forwardRef } from 'react';
5
+ import { cn } from '../../lib/utils.js';
6
+ import { Button, buttonVariants } from '../Button/Button.js';
7
+
8
+ const ComboboxTrigger = forwardRef(
9
+ ({
10
+ id,
11
+ disabled,
12
+ open,
13
+ error,
14
+ hasValue,
15
+ showClearButton,
16
+ showClearIcon,
17
+ isMultilineLabel,
18
+ displayValue,
19
+ className,
20
+ onHoverChange,
21
+ onClear,
22
+ ...rest
23
+ }, ref) => /* @__PURE__ */ jsxs(
24
+ Button,
25
+ {
26
+ ref,
27
+ id,
28
+ type: "button",
29
+ disabled,
30
+ variant: "text",
31
+ className: cn(
32
+ buttonVariants({ variant: "input", size: "lg" }),
33
+ "relative flex justify-between rounded-lg",
34
+ isMultilineLabel ? "h-auto min-h-12" : "h-12",
35
+ open && "border-neutral-950",
36
+ disabled && "cursor-not-allowed",
37
+ error && "border-error-400 focus-visible:border-error-700",
38
+ className
39
+ ),
40
+ "aria-expanded": open,
41
+ "aria-haspopup": "listbox",
42
+ onMouseEnter: () => onHoverChange(true),
43
+ onMouseLeave: () => onHoverChange(false),
44
+ ...rest,
45
+ children: [
46
+ /* @__PURE__ */ jsx("span", { className: cn("block", !hasValue && "text-neutral-300", !isMultilineLabel && "truncate"), children: displayValue }),
47
+ /* @__PURE__ */ jsx(
48
+ CaretDown,
49
+ {
50
+ className: cn(
51
+ "h-4 w-4 shrink-0 opacity-50 transition-opacity duration-150",
52
+ showClearButton ? "opacity-0" : "opacity-50"
53
+ )
54
+ }
55
+ ),
56
+ showClearIcon && hasValue && /* @__PURE__ */ jsx(
57
+ X,
58
+ {
59
+ "data-testid": "clear-button",
60
+ className: cn(
61
+ "absolute right-4 z-10 h-4 w-4 shrink-0 cursor-pointer transition-opacity duration-150",
62
+ showClearButton ? "opacity-100 hover:opacity-70" : "opacity-0"
63
+ ),
64
+ onClick: onClear
65
+ }
66
+ )
67
+ ]
68
+ }
69
+ )
70
+ );
71
+ ComboboxTrigger.displayName = "ComboboxTrigger";
72
+
73
+ export { ComboboxTrigger };
74
+ //# sourceMappingURL=ComboboxTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxTrigger.js","sources":["../../../src/components/Combobox/ComboboxTrigger.tsx"],"sourcesContent":["import { CaretDown } from '@phosphor-icons/react/dist/ssr/CaretDown'\nimport { X } from '@phosphor-icons/react/dist/ssr/X'\nimport { forwardRef } from 'react'\n\nimport { cn } from '../../lib/utils'\nimport { Button, buttonVariants } from '../Button'\n\ntype ComboboxTriggerProps = Readonly<{\n id?: string\n disabled?: boolean\n open: boolean\n error?: boolean | string\n hasValue: boolean\n showClearButton: unknown\n showClearIcon: boolean\n isMultilineLabel: boolean\n displayValue: React.ReactNode\n className?: string\n onHoverChange: (hovered: boolean) => void\n onClear: (event: React.MouseEvent) => void\n}>\n\nexport const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(\n (\n {\n id,\n disabled,\n open,\n error,\n hasValue,\n showClearButton,\n showClearIcon,\n isMultilineLabel,\n displayValue,\n className,\n onHoverChange,\n onClear,\n ...rest\n },\n ref,\n ) => (\n <Button\n ref={ref}\n id={id}\n type=\"button\"\n disabled={disabled}\n variant=\"text\"\n className={cn(\n buttonVariants({ variant: 'input', size: 'lg' }),\n 'relative flex justify-between rounded-lg',\n isMultilineLabel ? 'h-auto min-h-12' : 'h-12',\n open && 'border-neutral-950',\n disabled && 'cursor-not-allowed',\n error && 'border-error-400 focus-visible:border-error-700',\n className,\n )}\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n onMouseEnter={() => onHoverChange(true)}\n onMouseLeave={() => onHoverChange(false)}\n {...rest}\n >\n <span className={cn('block', !hasValue && 'text-neutral-300', !isMultilineLabel && 'truncate')}>\n {displayValue}\n </span>\n <CaretDown\n className={cn(\n 'h-4 w-4 shrink-0 opacity-50 transition-opacity duration-150',\n showClearButton ? 'opacity-0' : 'opacity-50',\n )}\n />\n {showClearIcon && hasValue && (\n <X\n data-testid=\"clear-button\"\n className={cn(\n 'absolute right-4 z-10 h-4 w-4 shrink-0 cursor-pointer transition-opacity duration-150',\n showClearButton ? 'opacity-100 hover:opacity-70' : 'opacity-0',\n )}\n onClick={onClear}\n />\n )}\n </Button>\n ),\n)\n\nComboboxTrigger.displayName = 'ComboboxTrigger'\n"],"names":[],"mappings":";;;;;;;AAsBO,MAAM,eAAA,GAAkB,UAAA;AAAA,EAC7B,CACE;AAAA,IACE,EAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,qBAEA,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,EAAA;AAAA,MACA,IAAA,EAAK,QAAA;AAAA,MACL,QAAA;AAAA,MACA,OAAA,EAAQ,MAAA;AAAA,MACR,SAAA,EAAW,EAAA;AAAA,QACT,eAAe,EAAE,OAAA,EAAS,OAAA,EAAS,IAAA,EAAM,MAAM,CAAA;AAAA,QAC/C,0CAAA;AAAA,QACA,mBAAmB,iBAAA,GAAoB,MAAA;AAAA,QACvC,IAAA,IAAQ,oBAAA;AAAA,QACR,QAAA,IAAY,oBAAA;AAAA,QACZ,KAAA,IAAS,iDAAA;AAAA,QACT;AAAA,OACF;AAAA,MACA,eAAA,EAAe,IAAA;AAAA,MACf,eAAA,EAAc,SAAA;AAAA,MACd,YAAA,EAAc,MAAM,aAAA,CAAc,IAAI,CAAA;AAAA,MACtC,YAAA,EAAc,MAAM,aAAA,CAAc,KAAK,CAAA;AAAA,MACtC,GAAG,IAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAW,EAAA,CAAG,OAAA,EAAS,CAAC,QAAA,IAAY,kBAAA,EAAoB,CAAC,gBAAA,IAAoB,UAAU,CAAA,EAC1F,QAAA,EAAA,YAAA,EACH,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,EAAA;AAAA,cACT,6DAAA;AAAA,cACA,kBAAkB,WAAA,GAAc;AAAA;AAClC;AAAA,SACF;AAAA,QACC,iBAAiB,QAAA,oBAChB,GAAA;AAAA,UAAC,CAAA;AAAA,UAAA;AAAA,YACC,aAAA,EAAY,cAAA;AAAA,YACZ,SAAA,EAAW,EAAA;AAAA,cACT,uFAAA;AAAA,cACA,kBAAkB,8BAAA,GAAiC;AAAA,aACrD;AAAA,YACA,OAAA,EAAS;AAAA;AAAA;AACX;AAAA;AAAA;AAIR;AAEA,eAAA,CAAgB,WAAA,GAAc,iBAAA;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { Check } from '@phosphor-icons/react/dist/ssr/Check';
2
3
  import { CheckSquare } from '@phosphor-icons/react/dist/ssr/CheckSquare';
3
4
  import { Square } from '@phosphor-icons/react/dist/ssr/Square';
4
5
  import { useMemo } from 'react';
@@ -46,8 +47,14 @@ const StaticComboboxList = ({
46
47
  const renderListOption = (option) => {
47
48
  const optionValue = getOptionValue(option);
48
49
  const selected = isOptionSelected(optionValue);
50
+ const renderSelectionIndicator = () => {
51
+ if (multiple) {
52
+ return selected ? /* @__PURE__ */ jsx(CheckSquare, { className: "mr-2 h-6! w-6!" }) : /* @__PURE__ */ jsx(Square, { className: "mr-2 h-6! w-6!" });
53
+ }
54
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "mr-1 flex h-6! w-6! shrink-0 items-center justify-end", children: selected && /* @__PURE__ */ jsx(Check, { weight: "bold", className: "h-4! w-4!" }) });
55
+ };
49
56
  return /* @__PURE__ */ jsx(CommandItem, { value: optionValue, onSelect: handleSelect, children: renderOption ? renderOption(option, selected) : /* @__PURE__ */ jsxs(Fragment, { children: [
50
- selected ? /* @__PURE__ */ jsx(CheckSquare, { className: "mr-2 !h-6 !w-6" }) : /* @__PURE__ */ jsx(Square, { className: "mr-2 !h-6 !w-6" }),
57
+ renderSelectionIndicator(),
51
58
  /* @__PURE__ */ jsx(ComboboxOptionWithTooltip, { label: getOptionLabel(option) })
52
59
  ] }) }, optionValue);
53
60
  };
@@ -61,7 +68,7 @@ const StaticComboboxList = ({
61
68
  filteredOptions.length === 0 && regularOptions.length === 0 && (!specialOptions || specialOptions.length === 0) && /* @__PURE__ */ jsx(CommandEmpty, { children: emptyMessage }),
62
69
  specialOptions?.length && specialOptionsTitle ? /* @__PURE__ */ jsxs(Fragment, { children: [
63
70
  /* @__PURE__ */ jsx(CommandGroup, { heading: specialOptionsTitle, children: specialOptions.map(renderListOption) }),
64
- /* @__PURE__ */ jsx(CommandSeparator, { className: "!mx-[10px]" })
71
+ /* @__PURE__ */ jsx(CommandSeparator, { className: "mx-[10px]!" })
65
72
  ] }) : null,
66
73
  !specialOptions && multiple && isArrayValue && regularSelectedOptions.length > 0 && /* @__PURE__ */ jsx(CommandGroup, { heading: selectedMultiplePlaceholder, children: regularSelectedOptions.map(renderListOption) }),
67
74
  optionsToShow.length > 0 && /* @__PURE__ */ jsx(CommandGroup, { heading: groupHeading, children: optionsToShow.map(renderListOption) })
@@ -1 +1 @@
1
- {"version":3,"file":"StaticComboboxList.js","sources":["../../../src/components/Combobox/StaticComboboxList.tsx"],"sourcesContent":["import { CheckSquare } from '@phosphor-icons/react/dist/ssr/CheckSquare'\nimport { Square } from '@phosphor-icons/react/dist/ssr/Square'\nimport { useMemo } from 'react'\n\nimport { CommandEmpty, CommandGroup, CommandItem, CommandList, CommandSeparator } from '../Command'\n\nimport { ComboboxOptionWithTooltip } from './ComboboxOptionWithTooltip'\nimport type { StaticComboboxListProps } from './types'\n\nexport const StaticComboboxList = <T extends object>({\n filteredOptions,\n loading,\n loadingPlaceholder,\n emptyMessage,\n multiple,\n value,\n getOptionValue,\n getOptionLabel,\n handleSelect,\n renderOption,\n maxHeight,\n selectedMultiplePlaceholder,\n multipleOptionsPlaceholder,\n options,\n specialOptions,\n specialOptionsTitle,\n}: StaticComboboxListProps<T>) => {\n const isArrayValue = Array.isArray(value)\n const selectedValues = useMemo(() => (multiple && isArrayValue ? value : []), [multiple, isArrayValue, value])\n\n const isOptionSelected = (optionValue: string) =>\n multiple ? selectedValues.includes(optionValue) : value === optionValue\n\n const regularOptions = useMemo(() => {\n return filteredOptions.filter(\n (option) => !specialOptions?.some((special) => getOptionValue(special) === getOptionValue(option)),\n )\n }, [filteredOptions, specialOptions, getOptionValue])\n\n const regularSelectedOptions = useMemo(() => {\n if (!multiple || !isArrayValue) return []\n\n return options.filter(\n (option) =>\n selectedValues.includes(getOptionValue(option)) &&\n !specialOptions?.some((special) => getOptionValue(special) === getOptionValue(option)),\n )\n }, [options, selectedValues, specialOptions, getOptionValue, multiple, isArrayValue])\n\n const optionsToShow = useMemo(() => {\n if (specialOptions) return regularOptions\n\n if (!multiple || !isArrayValue) return regularOptions\n\n return regularOptions.filter((option) => !selectedValues.includes(getOptionValue(option)))\n }, [regularOptions, specialOptions, selectedValues, getOptionValue, multiple, isArrayValue])\n\n const groupHeading = !specialOptions && multiple ? multipleOptionsPlaceholder : undefined\n\n const renderListOption = (option: T) => {\n const optionValue = getOptionValue(option)\n const selected = isOptionSelected(optionValue)\n\n return (\n <CommandItem key={optionValue} value={optionValue} onSelect={handleSelect}>\n {renderOption ? (\n renderOption(option, selected)\n ) : (\n <>\n {selected ? <CheckSquare className=\"mr-2 !h-6 !w-6\" /> : <Square className=\"mr-2 !h-6 !w-6\" />}\n <ComboboxOptionWithTooltip label={getOptionLabel(option)} />\n </>\n )}\n </CommandItem>\n )\n }\n\n return (\n <CommandList\n style={{ maxHeight }}\n className=\"overflow-auto overscroll-contain\"\n onWheel={(event) => event.stopPropagation()}\n >\n {loading ? (\n <div className=\"text-muted-foreground flex items-center justify-center py-6 text-sm\">{loadingPlaceholder}</div>\n ) : (\n <>\n {filteredOptions.length === 0 &&\n regularOptions.length === 0 &&\n (!specialOptions || specialOptions.length === 0) && <CommandEmpty>{emptyMessage}</CommandEmpty>}\n\n {specialOptions?.length && specialOptionsTitle ? (\n <>\n <CommandGroup heading={specialOptionsTitle}>{specialOptions.map(renderListOption)}</CommandGroup>\n\n <CommandSeparator className=\"!mx-[10px]\" />\n </>\n ) : null}\n\n {!specialOptions && multiple && isArrayValue && regularSelectedOptions.length > 0 && (\n <CommandGroup heading={selectedMultiplePlaceholder}>\n {regularSelectedOptions.map(renderListOption)}\n </CommandGroup>\n )}\n\n {optionsToShow.length > 0 && (\n <CommandGroup heading={groupHeading}>{optionsToShow.map(renderListOption)}</CommandGroup>\n )}\n </>\n )}\n </CommandList>\n )\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,qBAAqB,CAAmB;AAAA,EACnD,eAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,KAAkC;AAChC,EAAA,MAAM,YAAA,GAAe,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AACxC,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,MAAO,QAAA,IAAY,YAAA,GAAe,KAAA,GAAQ,EAAC,EAAI,CAAC,QAAA,EAAU,YAAA,EAAc,KAAK,CAAC,CAA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A,CAAC,YAAA,EAAA,EAAc,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,QAEjF,cAAA,EAAgB,MAAA,IAAU,mBAAA,mBACzB,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,gBAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAA,cAAA,CAAe,GAAA,CAAI,gBAAgB,CAAA,EAAE,CAAA;AAAA,0BAElF,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,YAAA,EAAa;AAAA,SAAA,EAC3C,CAAA,GACE,IAAA;AAAA,QAEH,CAAC,cAAA,IAAkB,QAAA,IAAY,YAAA,IAAgB,uBAAuB,MAAA,GAAS,CAAA,oBAC9E,GAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,2BAAA,EACpB,QAAA,EAAA,sBAAA,CAAuB,GAAA,CAAI,gBAAgB,CAAA,EAC9C,CAAA;AAAA,QAGD,aAAA,CAAc,MAAA,GAAS,CAAA,oBACtB,GAAA,CAAC,YAAA,EAAA,EAAa,SAAS,YAAA,EAAe,QAAA,EAAA,aAAA,CAAc,GAAA,CAAI,gBAAgB,CAAA,EAAE;AAAA,OAAA,EAE9E;AAAA;AAAA,GAEJ;AAEJ;;;;"}
1
+ {"version":3,"file":"StaticComboboxList.js","sources":["../../../src/components/Combobox/StaticComboboxList.tsx"],"sourcesContent":["import { Check } from '@phosphor-icons/react/dist/ssr/Check'\nimport { CheckSquare } from '@phosphor-icons/react/dist/ssr/CheckSquare'\nimport { Square } from '@phosphor-icons/react/dist/ssr/Square'\nimport { useMemo } from 'react'\n\nimport { CommandEmpty, CommandGroup, CommandItem, CommandList, CommandSeparator } from '../Command'\n\nimport { ComboboxOptionWithTooltip } from './ComboboxOptionWithTooltip'\nimport type { StaticComboboxListProps } from './types'\n\nexport const StaticComboboxList = <T extends object>({\n filteredOptions,\n loading,\n loadingPlaceholder,\n emptyMessage,\n multiple,\n value,\n getOptionValue,\n getOptionLabel,\n handleSelect,\n renderOption,\n maxHeight,\n selectedMultiplePlaceholder,\n multipleOptionsPlaceholder,\n options,\n specialOptions,\n specialOptionsTitle,\n}: StaticComboboxListProps<T>) => {\n const isArrayValue = Array.isArray(value)\n const selectedValues = useMemo(() => (multiple && isArrayValue ? value : []), [multiple, isArrayValue, value])\n\n const isOptionSelected = (optionValue: string) =>\n multiple ? selectedValues.includes(optionValue) : value === optionValue\n\n const regularOptions = useMemo(() => {\n return filteredOptions.filter(\n (option) => !specialOptions?.some((special) => getOptionValue(special) === getOptionValue(option)),\n )\n }, [filteredOptions, specialOptions, getOptionValue])\n\n const regularSelectedOptions = useMemo(() => {\n if (!multiple || !isArrayValue) return []\n\n return options.filter(\n (option) =>\n selectedValues.includes(getOptionValue(option)) &&\n !specialOptions?.some((special) => getOptionValue(special) === getOptionValue(option)),\n )\n }, [options, selectedValues, specialOptions, getOptionValue, multiple, isArrayValue])\n\n const optionsToShow = useMemo(() => {\n if (specialOptions) return regularOptions\n\n if (!multiple || !isArrayValue) return regularOptions\n\n return regularOptions.filter((option) => !selectedValues.includes(getOptionValue(option)))\n }, [regularOptions, specialOptions, selectedValues, getOptionValue, multiple, isArrayValue])\n\n const groupHeading = !specialOptions && multiple ? multipleOptionsPlaceholder : undefined\n\n const renderListOption = (option: T) => {\n const optionValue = getOptionValue(option)\n const selected = isOptionSelected(optionValue)\n\n const renderSelectionIndicator = () => {\n if (multiple) {\n return selected ? (\n <CheckSquare className=\"mr-2 h-6! w-6!\" />\n ) : (\n <Square className=\"mr-2 h-6! w-6!\" />\n )\n }\n\n return (\n <span aria-hidden className=\"mr-1 flex h-6! w-6! shrink-0 items-center justify-end\">\n {selected && <Check weight=\"bold\" className=\"h-4! w-4!\" />}\n </span>\n )\n }\n\n return (\n <CommandItem key={optionValue} value={optionValue} onSelect={handleSelect}>\n {renderOption ? (\n renderOption(option, selected)\n ) : (\n <>\n {renderSelectionIndicator()}\n <ComboboxOptionWithTooltip label={getOptionLabel(option)} />\n </>\n )}\n </CommandItem>\n )\n }\n\n return (\n <CommandList\n style={{ maxHeight }}\n className=\"overflow-auto overscroll-contain\"\n onWheel={(event) => event.stopPropagation()}\n >\n {loading ? (\n <div className=\"text-muted-foreground flex items-center justify-center py-6 text-sm\">{loadingPlaceholder}</div>\n ) : (\n <>\n {filteredOptions.length === 0 &&\n regularOptions.length === 0 &&\n (!specialOptions || specialOptions.length === 0) && <CommandEmpty>{emptyMessage}</CommandEmpty>}\n\n {specialOptions?.length && specialOptionsTitle ? (\n <>\n <CommandGroup heading={specialOptionsTitle}>{specialOptions.map(renderListOption)}</CommandGroup>\n\n <CommandSeparator className=\"mx-[10px]!\" />\n </>\n ) : null}\n\n {!specialOptions && multiple && isArrayValue && regularSelectedOptions.length > 0 && (\n <CommandGroup heading={selectedMultiplePlaceholder}>\n {regularSelectedOptions.map(renderListOption)}\n </CommandGroup>\n )}\n\n {optionsToShow.length > 0 && (\n <CommandGroup heading={groupHeading}>{optionsToShow.map(renderListOption)}</CommandGroup>\n )}\n </>\n )}\n </CommandList>\n )\n}\n"],"names":[],"mappings":";;;;;;;;AAUO,MAAM,qBAAqB,CAAmB;AAAA,EACnD,eAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,2BAAA;AAAA,EACA,0BAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,KAAkC;AAChC,EAAA,MAAM,YAAA,GAAe,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AACxC,EAAA,MAAM,cAAA,GAAiB,OAAA,CAAQ,MAAO,QAAA,IAAY,YAAA,GAAe,KAAA,GAAQ,EAAC,EAAI,CAAC,QAAA,EAAU,YAAA,EAAc,KAAK,CAAC,CAAA;AAE7G,E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,KAAA,KAAU,KAAA,CAAM,eAAA,EAAgB;AAAA,MAEzC,oCACC,GAAA,CAAC,KAAA,EAAA,EAAI,WAAU,qEAAA,EAAuE,QAAA,EAAA,kBAAA,EAAmB,oBAEzG,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,QAAA,eAAA,CAAgB,MAAA,KAAW,CAAA,IAC1B,cAAA,CAAe,MAAA,KAAW,CAAA,KACzB,CAAC,cAAA,IAAkB,cAAA,CAAe,MAAA,KAAW,CAAA,CAAA,oBAAM,GAAA,CAAC,YAAA,EAAA,EAAc,QAAA,EAAA,YAAA,EAAa,CAAA;AAAA,QAEjF,cAAA,EAAgB,MAAA,IAAU,mBAAA,mBACzB,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,gBAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAA,cAAA,CAAe,GAAA,CAAI,gBAAgB,CAAA,EAAE,CAAA;AAAA,0BAElF,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,YAAA,EAAa;AAAA,SAAA,EAC3C,CAAA,GACE,IAAA;AAAA,QAEH,CAAC,cAAA,IAAkB,QAAA,IAAY,YAAA,IAAgB,uBAAuB,MAAA,GAAS,CAAA,oBAC9E,GAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,2BAAA,EACpB,QAAA,EAAA,sBAAA,CAAuB,GAAA,CAAI,gBAAgB,CAAA,EAC9C,CAAA;AAAA,QAGD,aAAA,CAAc,MAAA,GAAS,CAAA,oBACtB,GAAA,CAAC,YAAA,EAAA,EAAa,SAAS,YAAA,EAAe,QAAA,EAAA,aAAA,CAAc,GAAA,CAAI,gBAAgB,CAAA,EAAE;AAAA,OAAA,EAE9E;AAAA;AAAA,GAEJ;AAEJ;;;;"}
@@ -1,2 +1,2 @@
1
1
  import { VirtualizedComboboxListProps } from './types';
2
- export declare const VirtualizedComboboxList: <T extends object>({ localOptions, loading, loadingPlaceholder, emptyMessage, value, getOptionValue, getOptionLabel, handleSelect, renderOption, maxHeight, hasNextPage, loadingMore, onLoadMore, open, }: VirtualizedComboboxListProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const VirtualizedComboboxList: <T extends object>({ localOptions, loading, loadingPlaceholder, emptyMessage, value, getOptionValue, getOptionLabel, handleSelect, renderOption, maxHeight, hasNextPage, loadingMore, onLoadMore, }: VirtualizedComboboxListProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -18,8 +18,7 @@ const VirtualizedComboboxList = ({
18
18
  maxHeight,
19
19
  hasNextPage,
20
20
  loadingMore,
21
- onLoadMore,
22
- open
21
+ onLoadMore
23
22
  }) => {
24
23
  const parentRef = useRef(null);
25
24
  const hasTriggeredRef = useRef(false);
@@ -33,20 +32,7 @@ const VirtualizedComboboxList = ({
33
32
  });
34
33
  useEffect(() => {
35
34
  hasTriggeredRef.current = false;
36
- }, [totalCount]);
37
- const hasScrolledToSelectedRef = useRef(false);
38
- useEffect(() => {
39
- if (!open) {
40
- hasScrolledToSelectedRef.current = false;
41
- return;
42
- }
43
- if (hasScrolledToSelectedRef.current || !value || totalCount === 0) return;
44
- const selectedIndex = localOptions.findIndex((option) => getOptionValue(option) === value);
45
- if (selectedIndex >= 0) {
46
- hasScrolledToSelectedRef.current = true;
47
- rowVirtualizer.scrollToIndex(selectedIndex, { align: "center" });
48
- }
49
- }, [open, value, totalCount, localOptions, getOptionValue, rowVirtualizer]);
35
+ }, [totalCount, loadingMore]);
50
36
  const virtualItems = rowVirtualizer.getVirtualItems();
51
37
  useEffect(() => {
52
38
  if (virtualItems.length === 0 || !hasNextPage || loadingMore || loading || hasTriggeredRef.current) {
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedComboboxList.js","sources":["../../../src/components/Combobox/VirtualizedComboboxList.tsx"],"sourcesContent":["import { Check } from '@phosphor-icons/react/dist/ssr/Check'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport { useRef, useEffect } from 'react'\n\nimport { CommandEmpty, CommandItem } from '../Command'\n\nimport { ComboboxOptionWithTooltip } from './ComboboxOptionWithTooltip'\nimport type { VirtualizedComboboxListProps } from './types'\n\nexport const VirtualizedComboboxList = <T extends object>({\n localOptions,\n loading,\n loadingPlaceholder,\n emptyMessage,\n value,\n getOptionValue,\n getOptionLabel,\n handleSelect,\n renderOption,\n maxHeight,\n hasNextPage,\n loadingMore,\n onLoadMore,\n open,\n}: VirtualizedComboboxListProps<T>) => {\n const parentRef = useRef<HTMLDivElement>(null)\n const hasTriggeredRef = useRef(false)\n\n const totalCount = localOptions.length\n const PREFETCH_THRESHOLD = 25\n\n const rowVirtualizer = useVirtualizer({\n count: totalCount,\n getScrollElement: () => parentRef.current,\n estimateSize: () => 40,\n overscan: 10,\n })\n\n useEffect(() => {\n hasTriggeredRef.current = false\n }, [totalCount])\n\n const hasScrolledToSelectedRef = useRef(false)\n\n useEffect(() => {\n if (!open) {\n hasScrolledToSelectedRef.current = false\n return\n }\n if (hasScrolledToSelectedRef.current || !value || totalCount === 0) return\n\n const selectedIndex = localOptions.findIndex((option) => getOptionValue(option) === value)\n if (selectedIndex >= 0) {\n hasScrolledToSelectedRef.current = true\n rowVirtualizer.scrollToIndex(selectedIndex, { align: 'center' })\n }\n }, [open, value, totalCount, localOptions, getOptionValue, rowVirtualizer])\n\n const virtualItems = rowVirtualizer.getVirtualItems()\n\n useEffect(() => {\n if (virtualItems.length === 0 || !hasNextPage || loadingMore || loading || hasTriggeredRef.current) {\n return\n }\n\n const lastVisibleItem = virtualItems.at(-1)\n const itemsFromEnd = totalCount - (lastVisibleItem?.index ?? 0)\n\n if (itemsFromEnd <= PREFETCH_THRESHOLD) {\n hasTriggeredRef.current = true\n onLoadMore()\n }\n }, [virtualItems, totalCount, hasNextPage, loadingMore, loading, onLoadMore])\n\n if (loading && localOptions.length === 0) {\n return (\n <div className=\"text-muted-foreground flex items-center justify-center py-6 text-sm\">{loadingPlaceholder}</div>\n )\n }\n\n if (localOptions.length === 0 && !loading && !loadingMore) {\n return <CommandEmpty>{emptyMessage}</CommandEmpty>\n }\n\n const getItemAtIndex = (index: number) => {\n const option = localOptions[index]\n const isSelected = value === getOptionValue(option)\n return { option, isSelected }\n }\n\n return (\n <div\n ref={parentRef}\n className=\"overflow-auto overscroll-contain\"\n style={{ maxHeight }}\n onWheel={(event) => event.stopPropagation()}\n >\n <div style={{ height: `${rowVirtualizer.getTotalSize()}px`, position: 'relative' }}>\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const { option, isSelected } = getItemAtIndex(virtualRow.index)\n const optionValue = getOptionValue(option)\n\n return (\n <div\n key={optionValue}\n data-index={virtualRow.index}\n ref={(el) => {\n if (el) rowVirtualizer.measureElement(el)\n }}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${virtualRow.start}px)`,\n }}\n >\n <CommandItem value={optionValue} onSelect={handleSelect}>\n {renderOption ? (\n renderOption(option, isSelected)\n ) : (\n <>\n <Check className={`mr-2 h-4 w-4 ${isSelected ? 'opacity-100' : 'opacity-0'}`} />\n <ComboboxOptionWithTooltip label={getOptionLabel(option)} />\n </>\n )}\n </CommandItem>\n </div>\n )\n })}\n </div>\n {loadingMore && (\n <div className=\"flex items-center justify-center py-2 text-sm text-neutral-500\">{loadingPlaceholder}</div>\n )}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,0BAA0B,CAAmB;AAAA,EACxD,YAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAAuC;AACrC,EAAA,MAAM,SAAA,GAAY,OAAuB,IAAI,CAAA;AAC7C,EAAA,MAAM,eAAA,GAAkB,OAAO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A,aAAA;AAAA,YAtBK;AAAA,WAuBP;AAAA,QAEJ,CAAC,CAAA,EACH,CAAA;AAAA,QACC,WAAA,oBACC,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kEAAkE,QAAA,EAAA,kBAAA,EAAmB;AAAA;AAAA;AAAA,GAExG;AAEJ;;;;"}
1
+ {"version":3,"file":"VirtualizedComboboxList.js","sources":["../../../src/components/Combobox/VirtualizedComboboxList.tsx"],"sourcesContent":["import { Check } from '@phosphor-icons/react/dist/ssr/Check'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport { useRef, useEffect } from 'react'\n\nimport { CommandEmpty, CommandItem } from '../Command'\n\nimport { ComboboxOptionWithTooltip } from './ComboboxOptionWithTooltip'\nimport type { VirtualizedComboboxListProps } from './types'\n\nexport const VirtualizedComboboxList = <T extends object>({\n localOptions,\n loading,\n loadingPlaceholder,\n emptyMessage,\n value,\n getOptionValue,\n getOptionLabel,\n handleSelect,\n renderOption,\n maxHeight,\n hasNextPage,\n loadingMore,\n onLoadMore,\n}: VirtualizedComboboxListProps<T>) => {\n const parentRef = useRef<HTMLDivElement>(null)\n const hasTriggeredRef = useRef(false)\n\n const totalCount = localOptions.length\n const PREFETCH_THRESHOLD = 25\n\n const rowVirtualizer = useVirtualizer({\n count: totalCount,\n getScrollElement: () => parentRef.current,\n estimateSize: () => 40,\n overscan: 10,\n })\n\n useEffect(() => {\n hasTriggeredRef.current = false\n }, [totalCount, loadingMore])\n\n const virtualItems = rowVirtualizer.getVirtualItems()\n\n useEffect(() => {\n if (virtualItems.length === 0 || !hasNextPage || loadingMore || loading || hasTriggeredRef.current) {\n return\n }\n\n const lastVisibleItem = virtualItems.at(-1)\n const itemsFromEnd = totalCount - (lastVisibleItem?.index ?? 0)\n\n if (itemsFromEnd <= PREFETCH_THRESHOLD) {\n hasTriggeredRef.current = true\n onLoadMore()\n }\n }, [virtualItems, totalCount, hasNextPage, loadingMore, loading, onLoadMore])\n\n if (loading && localOptions.length === 0) {\n return (\n <div className=\"text-muted-foreground flex items-center justify-center py-6 text-sm\">{loadingPlaceholder}</div>\n )\n }\n\n if (localOptions.length === 0 && !loading && !loadingMore) {\n return <CommandEmpty>{emptyMessage}</CommandEmpty>\n }\n\n const getItemAtIndex = (index: number) => {\n const option = localOptions[index]\n const isSelected = value === getOptionValue(option)\n return { option, isSelected }\n }\n\n return (\n <div\n ref={parentRef}\n className=\"overflow-auto overscroll-contain\"\n style={{ maxHeight }}\n onWheel={(event) => event.stopPropagation()}\n >\n <div style={{ height: `${rowVirtualizer.getTotalSize()}px`, position: 'relative' }}>\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const { option, isSelected } = getItemAtIndex(virtualRow.index)\n const optionValue = getOptionValue(option)\n\n return (\n <div\n key={optionValue}\n data-index={virtualRow.index}\n ref={(el) => {\n if (el) rowVirtualizer.measureElement(el)\n }}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${virtualRow.start}px)`,\n }}\n >\n <CommandItem value={optionValue} onSelect={handleSelect}>\n {renderOption ? (\n renderOption(option, isSelected)\n ) : (\n <>\n <Check className={`mr-2 h-4 w-4 ${isSelected ? 'opacity-100' : 'opacity-0'}`} />\n <ComboboxOptionWithTooltip label={getOptionLabel(option)} />\n </>\n )}\n </CommandItem>\n </div>\n )\n })}\n </div>\n {loadingMore && (\n <div className=\"flex items-center justify-center py-2 text-sm text-neutral-500\">{loadingPlaceholder}</div>\n )}\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;AASO,MAAM,0BAA0B,CAAmB;AAAA,EACxD,YAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA,KAAuC;AACrC,EAAA,MAAM,S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,KAAA,EAAO;AAAA,gBACL,QAAA,EAAU,UAAA;AAAA,gBACV,GAAA,EAAK,CAAA;AAAA,gBACL,IAAA,EAAM,CAAA;AAAA,gBACN,KAAA,EAAO,MAAA;AAAA,gBACP,SAAA,EAAW,CAAA,WAAA,EAAc,UAAA,CAAW,KAAK,CAAA,GAAA;AAAA,eAC3C;AAAA,cAEA,QAAA,kBAAA,GAAA,CAAC,WAAA,EAAA,EAAY,KAAA,EAAO,WAAA,EAAa,QAAA,EAAU,YAAA,EACxC,QAAA,EAAA,YAAA,GACC,YAAA,CAAa,MAAA,EAAQ,UAAU,CAAA,mBAE/B,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,gCAAA,GAAA,CAAC,SAAM,SAAA,EAAW,CAAA,aAAA,EAAgB,UAAA,GAAa,aAAA,GAAgB,WAAW,CAAA,CAAA,EAAI,CAAA;AAAA,gCAC9E,GAAA,CAAC,yBAAA,EAAA,EAA0B,KAAA,EAAO,cAAA,CAAe,MAAM,CAAA,EAAG;AAAA,eAAA,EAC5D,CAAA,EAEJ;AAAA,aAAA;AAAA,YAtBK;AAAA,WAuBP;AAAA,QAEJ,CAAC,CAAA,EACH,CAAA;AAAA,QACC,WAAA,oBACC,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,kEAAkE,QAAA,EAAA,kBAAA,EAAmB;AAAA;AAAA;AAAA,GAExG;AAEJ;;;;"}
@@ -0,0 +1,6 @@
1
+ export { useComboboxOpenState } from './useComboboxOpenState';
2
+ export { useComboboxSelection } from './useComboboxSelection';
3
+ export { useDebouncedState } from './useDebouncedState';
4
+ export { useDisplayValue } from './useDisplayValue';
5
+ export { usePaginatedOptions } from './usePaginatedOptions';
6
+ export { useSelectedCache } from './useSelectedCache';
@@ -0,0 +1,7 @@
1
+ export { useComboboxOpenState } from './useComboboxOpenState.js';
2
+ export { useComboboxSelection } from './useComboboxSelection.js';
3
+ export { useDebouncedState } from './useDebouncedState.js';
4
+ export { useDisplayValue } from './useDisplayValue.js';
5
+ export { usePaginatedOptions } from './usePaginatedOptions.js';
6
+ export { useSelectedCache } from './useSelectedCache.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,7 @@
1
+ export declare function useComboboxOpenState(): {
2
+ open: boolean;
3
+ setOpen: (next: boolean) => void;
4
+ searchTerm: string;
5
+ debouncedSearchTerm: string;
6
+ setSearchTerm: (next: string) => void;
7
+ };
@@ -0,0 +1,18 @@
1
+ import { useState, useCallback } from 'react';
2
+ import { useDebouncedState } from './useDebouncedState.js';
3
+
4
+ function useComboboxOpenState() {
5
+ const [open, setOpenRaw] = useState(false);
6
+ const { value: searchTerm, debouncedValue: debouncedSearchTerm, setValue: setSearchTerm } = useDebouncedState("");
7
+ const setOpen = useCallback(
8
+ (next) => {
9
+ setOpenRaw(next);
10
+ if (!next) setSearchTerm("");
11
+ },
12
+ [setSearchTerm]
13
+ );
14
+ return { open, setOpen, searchTerm, debouncedSearchTerm, setSearchTerm };
15
+ }
16
+
17
+ export { useComboboxOpenState };
18
+ //# sourceMappingURL=useComboboxOpenState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxOpenState.js","sources":["../../../../src/components/Combobox/hooks/useComboboxOpenState.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\nimport { useDebouncedState } from './useDebouncedState'\n\nexport function useComboboxOpenState() {\n const [open, setOpenRaw] = useState(false)\n const { value: searchTerm, debouncedValue: debouncedSearchTerm, setValue: setSearchTerm } = useDebouncedState('')\n\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenRaw(next)\n if (!next) setSearchTerm('')\n },\n [setSearchTerm],\n )\n\n return { open, setOpen, searchTerm, debouncedSearchTerm, setSearchTerm }\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,oBAAA,GAAuB;AACrC,EAAA,MAAM,CAAC,IAAA,EAAM,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AACzC,EAAA,MAAM,EAAE,OAAO,UAAA,EAAY,cAAA,EAAgB,qBAAqB,QAAA,EAAU,aAAA,EAAc,GAAI,iBAAA,CAAkB,EAAE,CAAA;AAEhH,EAAA,MAAM,OAAA,GAAU,WAAA;AAAA,IACd,CAAC,IAAA,KAAkB;AACjB,MAAA,UAAA,CAAW,IAAI,CAAA;AACf,MAAA,IAAI,CAAC,IAAA,EAAM,aAAA,CAAc,EAAE,CAAA;AAAA,IAC7B,CAAA;AAAA,IACA,CAAC,aAAa;AAAA,GAChB;AAEA,EAAA,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,UAAA,EAAY,qBAAqB,aAAA,EAAc;AACzE;;;;"}
@@ -0,0 +1,7 @@
1
+ import { ComboboxProps } from '../Combobox';
2
+ export declare function useComboboxSelection<T extends object>(props: ComboboxProps<T>, setOpen: (open: boolean) => void): {
3
+ handleSelect: (currentValue: string) => void;
4
+ handleRemove: (valueToRemove: string) => void;
5
+ handleClear: (event: React.MouseEvent) => void;
6
+ hasValue: boolean;
7
+ };
@@ -0,0 +1,49 @@
1
+ import { useMemo } from 'react';
2
+
3
+ function useComboboxSelection(props, setOpen) {
4
+ const { multiple, clearable = true, onClear, specialOptions } = props;
5
+ const closeOnSelect = props.closeOnSelect ?? !props.multiple;
6
+ const handleSelect = (currentValue) => {
7
+ if (multiple) {
8
+ const { onChange } = props;
9
+ const value = Array.isArray(props.value) ? props.value : [];
10
+ const isRemoving = value.includes(currentValue);
11
+ if (specialOptions && specialOptions.length > 0) {
12
+ onChange(isRemoving ? [] : [currentValue]);
13
+ } else {
14
+ if (isRemoving && !clearable && value.length === 1) return;
15
+ onChange(isRemoving ? value.filter((val) => val !== currentValue) : [...value, currentValue]);
16
+ }
17
+ } else {
18
+ const { value, onChange } = props;
19
+ onChange(clearable && currentValue === value ? "" : currentValue);
20
+ }
21
+ if (closeOnSelect) setOpen(false);
22
+ };
23
+ const handleRemove = (valueToRemove) => {
24
+ if (props.multiple) {
25
+ const { onChange } = props;
26
+ const value = Array.isArray(props.value) ? props.value : [];
27
+ if (!clearable && value.length === 1) return;
28
+ onChange(value.filter((val) => val !== valueToRemove));
29
+ }
30
+ };
31
+ const handleClear = (event) => {
32
+ event.preventDefault();
33
+ event.stopPropagation();
34
+ if (multiple) {
35
+ if (clearable) props.onChange([]);
36
+ } else {
37
+ props.onChange("");
38
+ }
39
+ if (typeof onClear === "function") onClear();
40
+ };
41
+ const hasValue = useMemo(() => {
42
+ if (multiple) return Array.isArray(props.value) && props.value.length > 0;
43
+ return !!props.value;
44
+ }, [props.value, multiple]);
45
+ return { handleSelect, handleRemove, handleClear, hasValue };
46
+ }
47
+
48
+ export { useComboboxSelection };
49
+ //# sourceMappingURL=useComboboxSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComboboxSelection.js","sources":["../../../../src/components/Combobox/hooks/useComboboxSelection.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport type { ComboboxProps } from '../Combobox'\n\nexport function useComboboxSelection<T extends object>(props: ComboboxProps<T>, setOpen: (open: boolean) => void) {\n const { multiple, clearable = true, onClear, specialOptions } = props\n const closeOnSelect = props.closeOnSelect ?? !props.multiple\n\n const handleSelect = (currentValue: string) => {\n if (multiple) {\n const { onChange } = props\n const value = Array.isArray(props.value) ? props.value : []\n const isRemoving = value.includes(currentValue)\n\n if (specialOptions && specialOptions.length > 0) {\n onChange(isRemoving ? [] : [currentValue])\n } else {\n if (isRemoving && !clearable && value.length === 1) return\n onChange(isRemoving ? value.filter((val) => val !== currentValue) : [...value, currentValue])\n }\n } else {\n const { value, onChange } = props\n onChange(clearable && currentValue === value ? '' : currentValue)\n }\n\n if (closeOnSelect) setOpen(false)\n }\n\n const handleRemove = (valueToRemove: string) => {\n if (props.multiple) {\n const { onChange } = props\n const value = Array.isArray(props.value) ? props.value : []\n if (!clearable && value.length === 1) return\n onChange(value.filter((val) => val !== valueToRemove))\n }\n }\n\n const handleClear = (event: React.MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (multiple) {\n if (clearable) props.onChange([])\n } else {\n props.onChange('')\n }\n\n if (typeof onClear === 'function') onClear()\n }\n\n const hasValue = useMemo(() => {\n if (multiple) return Array.isArray(props.value) && props.value.length > 0\n return !!props.value\n }, [props.value, multiple])\n\n return { handleSelect, handleRemove, handleClear, hasValue }\n}\n"],"names":[],"mappings":";;AAIO,SAAS,oBAAA,CAAuC,OAAyB,OAAA,EAAkC;AAChH,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,GAAY,IAAA,EAAM,OAAA,EAAS,gBAAe,GAAI,KAAA;AAChE,EAAA,MAAM,aAAA,GAAgB,KAAA,CAAM,aAAA,IAAiB,CAAC,KAAA,CAAM,QAAA;AAEpD,EAAA,MAAM,YAAA,GAAe,CAAC,YAAA,KAAyB;AAC7C,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,MAAM,EAAE,UAAS,GAAI,KAAA;AACrB,MAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA,GAAI,KAAA,CAAM,QAAQ,EAAC;AAC1D,MAAA,MAAM,UAAA,GAAa,KAAA,CAAM,QAAA,CAAS,YAAY,CAAA;AAE9C,MAAA,IAAI,cAAA,IAAkB,cAAA,CAAe,MAAA,GAAS,CAAA,EAAG;AAC/C,QAAA,QAAA,CAAS,UAAA,GAAa,EAAC,GAAI,CAAC,YAAY,CAAC,CAAA;AAAA,MAC3C,CAAA,MAAO;AACL,QAAA,IAAI,UAAA,IAAc,CAAC,SAAA,IAAa,KAAA,CAAM,WAAW,CAAA,EAAG;AACpD,QAAA,QAAA,CAAS,UAAA,GAAa,KAAA,CAAM,MAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,KAAQ,YAAY,CAAA,GAAI,CAAC,GAAG,KAAA,EAAO,YAAY,CAAC,CAAA;AAAA,MAC9F;AAAA,IACF,CAAA,MAAO;AACL,MAAA,M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