@bioturing/components 0.26.2 → 0.28.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/components/checkbox/component.js.map +1 -1
- package/dist/components/choice-list/component.js +24 -21
- package/dist/components/choice-list/component.js.map +1 -1
- package/dist/components/cmdk/index.js.map +1 -1
- package/dist/components/combobox/component.js +202 -0
- package/dist/components/combobox/component.js.map +1 -0
- package/dist/components/combobox/style.css +1 -0
- package/dist/components/combobox/trigger.js +89 -0
- package/dist/components/combobox/trigger.js.map +1 -0
- package/dist/components/dropdown-menu/component.js +176 -162
- package/dist/components/dropdown-menu/component.js.map +1 -1
- package/dist/components/dropdown-menu/divider.js +16 -0
- package/dist/components/dropdown-menu/divider.js.map +1 -0
- package/dist/components/dropdown-menu/item.css +1 -0
- package/dist/components/dropdown-menu/item.js +131 -0
- package/dist/components/dropdown-menu/item.js.map +1 -0
- package/dist/components/dropdown-menu/style.css +1 -1
- package/dist/components/hooks/useDraggable.js +77 -0
- package/dist/components/hooks/useDraggable.js.map +1 -0
- package/dist/components/hooks/useHover.js +26 -0
- package/dist/components/hooks/useHover.js.map +1 -0
- package/dist/components/hooks/useTransitionStatus.js +52 -0
- package/dist/components/hooks/useTransitionStatus.js.map +1 -0
- package/dist/components/nav/item.js +2 -2
- package/dist/components/popup-panel/component.js +136 -169
- package/dist/components/popup-panel/component.js.map +1 -1
- package/dist/components/popup-panel/style.css +1 -1
- package/dist/components/resizable/component.js +239 -0
- package/dist/components/resizable/component.js.map +1 -0
- package/dist/components/resizable/style.css +1 -0
- package/dist/components/segmented/component.js +3 -3
- package/dist/components/segmented/component.js.map +1 -1
- package/dist/components/select/component.js +160 -91
- package/dist/components/select/component.js.map +1 -1
- package/dist/components/select/item.js +54 -0
- package/dist/components/select/item.js.map +1 -0
- package/dist/components/select/style.css +1 -1
- package/dist/components/spin/component.js +9 -8
- package/dist/components/spin/component.js.map +1 -1
- package/dist/components/splitter/splitter-panel.js +26 -43
- package/dist/components/splitter/splitter-panel.js.map +1 -1
- package/dist/components/splitter/splitter.js +99 -98
- package/dist/components/splitter/splitter.js.map +1 -1
- package/dist/components/splitter/useSizes.js +86 -0
- package/dist/components/splitter/useSizes.js.map +1 -0
- package/dist/components/stack/StackChild.js +9 -9
- package/dist/components/transition/component.js +1 -1
- package/dist/components/transition/component.js.map +1 -1
- package/dist/components/upload/dragger.js +19 -10
- package/dist/components/upload/dragger.js.map +1 -1
- package/dist/components/upload/item.js +21 -18
- package/dist/components/upload/item.js.map +1 -1
- package/dist/components/utils/antdUtils.js +18 -56
- package/dist/components/utils/antdUtils.js.map +1 -1
- package/dist/components/utils/placement.js +58 -0
- package/dist/components/utils/placement.js.map +1 -0
- package/dist/components/utils/reactElement.js +5 -0
- package/dist/components/utils/reactElement.js.map +1 -0
- package/dist/index.d.ts +478 -20
- package/dist/index.js +205 -189
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +39 -5
- package/dist/metadata.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/combobox/component.tsx"],"sourcesContent":["\"use client\";\nimport React, { forwardRef, useCallback, useMemo, useState } from \"react\";\nimport { useControlled } from \"@base-ui-components/utils/useControlled\";\nimport { clsx, useCls } from \"../utils\";\nimport {\n DropdownMenu,\n DropdownMenuProps,\n DropdownMenuItem,\n type DropdownMenuItemType,\n} from \"../dropdown-menu\";\nimport type { PopoverProps } from \"antd/es/popover\";\nimport { ComboboxTrigger, ComboboxTriggerProps } from \"./trigger\";\n\n// Import component-specific styles\nimport \"./style.css\";\nimport { useControlledState } from \"../hooks\";\nimport { DropdownMenuDivider } from \"../dropdown-menu/divider\";\n\nexport interface ComboboxOption {\n value: string | number;\n label: React.ReactNode;\n disabled?: boolean;\n icon?: React.ReactNode;\n}\n\nexport interface ComboboxProps {\n /** Array of options to be displayed in the combobox */\n options?: ComboboxOption[];\n /** Current value of the combobox */\n value?: string | number | Array<string | number>;\n /** Default value when uncontrolled */\n defaultValue?: string | number | Array<string | number>;\n /** Callback when value changes */\n onChange?: (value: string | number | Array<string | number>) => void;\n /** Placeholder text for the input */\n placeholder?: string;\n /** Whether the combobox is disabled */\n disabled?: boolean;\n /** Whether to allow clearing the selection */\n allowClear?: boolean;\n /** Whether to allow multiple selections */\n multiple?: boolean;\n /** Maximum number of tags to show */\n maxTagCount?: number;\n /** Whether to show search functionality */\n showSearch?: boolean;\n /** Controlled open state */\n open?: boolean;\n /** Callback when open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Placement of the dropdown */\n placement?: PopoverProps[\"placement\"];\n /** Custom className for the component */\n className?: string;\n /** Custom class names for different parts */\n classNames?: {\n trigger?: string;\n input?: string;\n option?: string;\n optionIcon?: string;\n optionText?: string;\n };\n /** Size of the combobox */\n size?: \"small\" | \"middle\" | \"large\";\n /** Loading state */\n loading?: boolean;\n /** Custom render for options */\n optionRender?: (\n option: ComboboxOption,\n props: React.HTMLAttributes<HTMLElement>\n ) => React.ReactElement;\n /** Filter function for search */\n filterOption?: boolean | ((input: string, option: ComboboxOption) => boolean);\n /** Callback when search input changes */\n onSearch?: (value: string) => void;\n /** Custom dropdown render */\n dropdownRender?: (menu: React.ReactElement) => React.ReactElement;\n /** Custom clear icon */\n clearIcon?: React.ReactNode;\n /** Custom suffix icon */\n suffixIcon?: React.ReactNode;\n /**\n * Props to pass to the dropdown menu\n */\n dropdownMenuProps?: DropdownMenuProps;\n /**\n * Props to pass to the combobox trigger\n */\n triggerProps?: ComboboxTriggerProps;\n searchProps?: {\n placeholder?: string;\n onValueChange?: (value: string) => void;\n value?: string;\n };\n /**\n * Show selection summary instead of individual tags when multiple\n * @default false\n */\n showSelectionSummary?: boolean;\n /**\n * Render function for the selection summary in multiple case\n * @default (selectedValues) => `${selectedValues.length} items selected`\n */\n selectionSummaryRender?: (\n selectedValues: Array<string | number>\n ) => React.ReactNode;\n /**\n * Show select all option when in multiple mode\n * @default false\n */\n showSelectAll?: boolean;\n /**\n * Render function for the select all option\n */\n selectAllRender?: (props: {\n onSelectAll: () => void;\n onDeselectAll: () => void;\n checked: boolean;\n indeterminate: boolean;\n }) => React.ReactNode;\n}\n\nconst ComboboxInner = (\n {\n options = [],\n value: controlledValue,\n defaultValue,\n onChange,\n placeholder = \"Select...\",\n disabled = false,\n allowClear = false,\n multiple = false,\n maxTagCount,\n showSearch = true,\n open: controlledOpen,\n onOpenChange,\n placement = \"bottomLeft\",\n className,\n classNames,\n size = \"middle\",\n loading: _loading = false,\n optionRender,\n filterOption = true,\n onSearch,\n dropdownRender,\n clearIcon,\n suffixIcon,\n dropdownMenuProps,\n triggerProps,\n searchProps,\n showSelectionSummary = false,\n selectionSummaryRender,\n showSelectAll = false,\n selectAllRender,\n ...rest\n }: ComboboxProps,\n ref: React.ForwardedRef<HTMLDivElement>\n) => {\n const [initialDefaultValue] = useState(\n defaultValue !== undefined ? defaultValue : multiple ? [] : undefined\n );\n const [value, setValue] = useControlled({\n controlled: controlledValue,\n default: initialDefaultValue,\n name: \"value\",\n });\n\n const [open, setOpen] = useControlledState(\n controlledOpen,\n onOpenChange,\n false\n );\n const [searchValue, setSearchValue] = useState(\"\");\n const cls = useCls();\n\n const handleValueChange = useCallback(\n (newValue: string | number | Array<string | number>) => {\n setValue(newValue);\n onChange?.(newValue);\n },\n [setValue, onChange]\n );\n\n const handleOptionSelect = useCallback(\n (optionValue: string | number) => {\n if (multiple) {\n const currentValues = Array.isArray(value) ? value : [];\n const newValues = currentValues.includes(optionValue)\n ? currentValues.filter((v) => v !== optionValue)\n : [...currentValues, optionValue];\n handleValueChange(newValues);\n } else {\n handleValueChange(optionValue);\n // onOpenChange?.(false);\n }\n },\n [multiple, value, handleValueChange]\n );\n\n const handleSearchChange = useCallback(\n (newValue: string) => {\n setSearchValue(newValue);\n onSearch?.(newValue);\n },\n [onSearch]\n );\n\n // Check if option is selected\n const isSelected = useCallback(\n (optionValue: string | number) => {\n if (multiple) {\n return Array.isArray(value) && value.includes(optionValue);\n }\n return value === optionValue;\n },\n [multiple, value]\n );\n\n // Filter options based on search\n const filteredOptions = useMemo(() => {\n if (!showSearch || !searchValue) return options;\n\n return options.filter((option) => {\n if (typeof filterOption === \"function\") {\n return filterOption(searchValue, option);\n }\n if (filterOption === false) return true;\n\n const label =\n typeof option.label === \"string\" ? option.label : String(option.value);\n return label.toLowerCase().includes(searchValue.toLowerCase());\n });\n }, [options, showSearch, searchValue, filterOption]);\n\n const handleSelectAll = useCallback(() => {\n if (multiple) {\n const allValues = filteredOptions.map((option) => option.value);\n handleValueChange(allValues);\n }\n }, [multiple, filteredOptions, handleValueChange]);\n\n const handleDeselectAll = useCallback(() => {\n if (multiple) {\n handleValueChange([]);\n }\n }, [multiple, handleValueChange]);\n\n // Convert options to DropdownMenu items\n const dropdownItems: DropdownMenuItemType[] = useMemo(() => {\n return filteredOptions.map((option) => {\n return {\n type: \"item\",\n key: option.value,\n icon: option.icon,\n label: option.label,\n disabled: option.disabled,\n onClick: () => !option.disabled && handleOptionSelect(option.value),\n };\n });\n }, [filteredOptions, handleOptionSelect]);\n\n // Select all component for beforeList\n const selectAllComponent = useMemo(() => {\n if (!showSelectAll || !multiple || filteredOptions.length === 0) {\n return null;\n }\n\n const selectedValues = Array.isArray(value) ? value : [];\n const filteredOptionValues = filteredOptions.map((opt) => opt.value);\n const selectedFromFiltered = selectedValues.filter((val) =>\n filteredOptionValues.includes(val)\n );\n const checked =\n selectedFromFiltered.length === filteredOptions.length &&\n filteredOptions.length > 0;\n const indeterminate =\n selectedFromFiltered.length > 0 &&\n selectedFromFiltered.length < filteredOptions.length;\n\n const selectAllItem: DropdownMenuItemType & { type: \"item\" } = {\n type: \"item\",\n key: \"select_all\",\n label: \"Select All\",\n onClick: () => {\n if (indeterminate || checked) {\n handleDeselectAll();\n } else {\n handleSelectAll();\n }\n },\n };\n\n return (\n <>\n <DropdownMenuItem\n key=\"select_all\"\n item={selectAllItem}\n inCombobox={showSearch}\n selected={checked}\n showCheckbox\n indeterminate={indeterminate}\n renderAsNativeElement\n onSelect={() => {\n if (indeterminate || checked) {\n handleDeselectAll();\n } else {\n handleSelectAll();\n }\n }}\n />\n <DropdownMenuDivider />\n </>\n );\n }, [\n showSelectAll,\n multiple,\n filteredOptions,\n value,\n showSearch,\n handleDeselectAll,\n handleSelectAll,\n ]);\n\n // Prepare trigger data\n const selectedValues = Array.isArray(value) ? value : value ? [value] : [];\n const selectedOptions = selectedValues\n .map((val) => options.find((opt) => opt.value === val))\n .filter(Boolean);\n\n return (\n <div\n ref={ref}\n className={clsx(\n cls(\"combobox\"),\n className,\n disabled && \"pointer-events-none opacity-50\"\n )}\n {...rest}\n >\n <DropdownMenu\n items={dropdownItems}\n open={open}\n onOpenChange={setOpen}\n placement={placement}\n showSearch={showSearch}\n searchProps={{\n placeholder: \"Search options...\",\n onValueChange: handleSearchChange,\n value: searchValue,\n ...searchProps,\n }}\n className={clsx(cls(\"combobox-dropdown\"))}\n classNames={{\n trigger: clsx(cls(\"combobox-trigger-wrapper\")),\n popup: clsx(cls(\"combobox-popup\")),\n item: clsx(cls(\"combobox-option\"), classNames?.option),\n ...classNames,\n }}\n popupMatchTriggerWidth\n keepOpenOnSelect={multiple}\n highlightedItemKey={multiple ? undefined : selectedValues[0]}\n showCheckbox={multiple}\n beforeList={selectAllComponent}\n selectedItemKeys={selectedValues}\n {...dropdownMenuProps}\n >\n <ComboboxTrigger\n selectedOptions={selectedOptions}\n placeholder={placeholder}\n multiple={multiple}\n disabled={disabled}\n open={open}\n size={size}\n allowClear={allowClear}\n suffixIcon={suffixIcon}\n clearIcon={clearIcon}\n classNames={classNames}\n onClear={() => handleValueChange(multiple ? [] : undefined)}\n showSelectionSummary={showSelectionSummary}\n selectionSummaryRender={selectionSummaryRender}\n {...triggerProps}\n />\n </DropdownMenu>\n </div>\n );\n};\n\nconst MainCombobox = forwardRef(ComboboxInner);\n\nexport const Combobox = Object.assign(MainCombobox, {\n // Add any sub components here if needed\n});\n\nexport default Combobox;\n"],"names":["ComboboxInner","options","controlledValue","defaultValue","onChange","placeholder","disabled","allowClear","multiple","maxTagCount","showSearch","controlledOpen","onOpenChange","placement","className","classNames","size","_loading","optionRender","filterOption","onSearch","dropdownRender","clearIcon","suffixIcon","dropdownMenuProps","triggerProps","searchProps","showSelectionSummary","selectionSummaryRender","showSelectAll","selectAllRender","rest","ref","initialDefaultValue","useState","value","setValue","useControlled","open","setOpen","useControlledState","searchValue","setSearchValue","cls","useCls","handleValueChange","useCallback","newValue","handleOptionSelect","optionValue","currentValues","newValues","v","handleSearchChange","filteredOptions","useMemo","option","handleSelectAll","allValues","handleDeselectAll","dropdownItems","selectAllComponent","selectedValues","filteredOptionValues","opt","selectedFromFiltered","val","checked","indeterminate","jsxs","Fragment","jsx","DropdownMenuItem","DropdownMenuDivider","selectedOptions","clsx","DropdownMenu","ComboboxTrigger","MainCombobox","forwardRef","Combobox"],"mappings":";;;;;;;;;;;;AA0HA,MAAMA,KAAgB,CACpB;AAAA,EACE,SAAAC,IAAU,CAAC;AAAA,EACX,OAAOC;AAAA,EACP,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AAAA,EACX,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,aAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,MAAMC;AAAA,EACN,cAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAASC,KAAW;AAAA,EACpB,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,wBAAAC;AAAA,EACA,eAAAC,IAAgB;A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AAA,UACA,cAAcC;AAAA,UACd,WAAA1B;AAAA,UACA,YAAAH;AAAA,UACA,aAAa;AAAA,YACX,aAAa;AAAA,YACb,eAAe2C;AAAA,YACf,OAAOZ;AAAA,YACP,GAAGf;AAAA,UACL;AAAA,UACA,WAAWiD,EAAKhC,EAAI,mBAAmB,CAAC;AAAA,UACxC,YAAY;AAAA,YACV,SAASgC,EAAKhC,EAAI,0BAA0B,CAAC;AAAA,YAC7C,OAAOgC,EAAKhC,EAAI,gBAAgB,CAAC;AAAA,YACjC,MAAMgC,EAAKhC,EAAI,iBAAiB,GAAG5B,KAAA,gBAAAA,EAAY,MAAM;AAAA,YACrD,GAAGA;AAAA,UACL;AAAA,UACA,wBAAsB;AAAA,UACtB,kBAAkBP;AAAA,UAClB,oBAAoBA,IAAW,SAAYsD,EAAe,CAAC;AAAA,UAC3D,cAActD;AAAA,UACd,YAAYqD;AAAA,UACZ,kBAAkBC;AAAA,UACjB,GAAGtC;AAAA,UAEJ,UAAA,gBAAA+C;AAAA,YAACM;AAAA,YAAA;AAAA,cACC,iBAAAH;AAAA,cACA,aAAArE;AAAA,cACA,UAAAG;AAAA,cACA,UAAAF;AAAA,cACA,MAAAgC;AAAA,cACA,MAAAtB;AAAA,cACA,YAAAT;AAAA,cACA,YAAAgB;AAAA,cACA,WAAAD;AAAA,cACA,YAAAP;AAAA,cACA,SAAS,MAAM8B,EAAkBrC,IAAW,CAAA,IAAK,MAAS;AAAA,cAC1D,sBAAAmB;AAAA,cACA,wBAAAC;AAAA,cACC,GAAGH;AAAA,YAAA;AAAA,UAAA;AAAA,QACN;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ,GAEMqD,KAAeC,GAAW/E,EAAa,GAEhCgF,KAAW,OAAO,OAAOF,IAAc;AAAA;AAEpD,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer components{.ds-combobox{position:relative;display:inline-block;cursor:pointer;width:100%}.ds-combobox:focus,.ds-combobox:focus-visible{outline:none}.ds-combobox-selector{position:relative;background-color:var( --ds-select-selector-bg, var(--ds-color-bg-container) );border:1px solid var(--ds-color-border);border-radius:6px;transition:all .2s;width:100%;height:auto;padding:var(--ds-select-option-padding, 6px 12px);display:flex;flex-wrap:wrap;align-items:center;gap:4}.ds-combobox:hover .ds-combobox-selector{border-color:var( --ds-select-hover-border-color, var(--ds-color-primary-hover) )}.ds-combobox:focus-visible .ds-combobox-selector{outline:var(--ds-line-width-focus) solid var(--ds-color-primary-border);outline-offset:1px;transition:outline-offset 0s,outline 0s}.ds-combobox-open .ds-combobox-selector{border-color:var(--ds-select-active-border-color, var(--ds-color-primary));box-shadow:0 0 0 2px var(--ds-select-active-outline-color, var(--ds-color-primary-bg))}.ds-combobox-disabled .ds-combobox-selector{background-color:var( --ds-select-multiple-selector-bg-disabled, var(--ds-color-bg-container-disabled) );border-color:var(--ds-color-border);cursor:not-allowed;color:var(--ds-color-text-disabled)}.ds-combobox-selection-wrap{display:flex;flex-wrap:wrap;align-items:center;flex:1;width:100%;position:relative}.ds-combobox-selection-search{position:relative;flex:1;min-width:0}.ds-combobox-selection-search-input{position:absolute;top:0;left:0;height:100%;width:100%;opacity:0;background:transparent;border:none;outline:none;cursor:pointer}.ds-combobox-selection-placeholder{flex:1;color:var(--ds-color-text-placeholder);pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:left}.ds-combobox-selection-text{flex:1;color:var(--ds-color-text);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:left}.ds-combobox-arrow{display:flex;align-items:center;color:var(--ds-color-text-quaternary);font-size:12px;width:12px;height:12px;pointer-events:none}.ds-combobox-arrow-icon{display:flex;align-items:center;justify-content:center}.ds-combobox-selection-suffix{height:12px;width:12px;position:relative;font-size:12px}.ds-combobox-selection-suffix .ds-combobox-arrow{position:absolute;top:0;left:0}.ds-combobox-selection-suffix .ds-combobox-clear{position:absolute;top:0;right:0;color:var(--ds-color-text-tertiary);transition:opacity .3s ease}:is(.ds-combobox-selection-suffix .ds-combobox-clear):hover{color:var(--ds-color-icon-hover)}.ds-combobox:hover .ds-combobox-clear{opacity:1}.ds-combobox-clear:hover{color:var(--ds-color-text-secondary)}.ds-combobox-small .ds-combobox-selector{padding:1px 8px;min-height:24px;line-height:20px}.ds-combobox-small .ds-combobox-arrow,.ds-combobox-small .ds-combobox-clear{right:7px}.ds-combobox-middle .ds-combobox-selector{padding:5px 12px;min-height:32px;line-height:20px}.ds-combobox-large .ds-combobox-selector{padding:9px 12px;min-height:40px;line-height:20px}.ds-combobox-open .ds-combobox-arrow-icon{transform:rotate(180deg)}.ds-combobox-option-wrapper{display:flex;align-items:center;gap:8px}.ds-combobox-option-wrapper .ds-checkbox{pointer-events:none}-selected.ds-combobox-option-wrapper{font-weight:700;background-color:var(--ds-select-option-active-bg)}.ds-combobox-option-wrapper .ds-combobox-option-text{flex:1}.ds-combobox-option-wrapper .ds-combobox-option-icon{flex-shrink:0;flex-grow:0}}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as $ } from "react";
|
|
4
|
+
import { XCircleIcon as j, CaretDownIcon as k } from "@bioturing/assets";
|
|
5
|
+
import { useCls as I } from "../utils/antdUtils.js";
|
|
6
|
+
import { clsx as v } from "../utils/cn.js";
|
|
7
|
+
const y = $(
|
|
8
|
+
({
|
|
9
|
+
selectedOptions: c,
|
|
10
|
+
placeholder: x = "Select...",
|
|
11
|
+
multiple: n = !1,
|
|
12
|
+
disabled: b = !1,
|
|
13
|
+
open: s = !1,
|
|
14
|
+
size: h = "middle",
|
|
15
|
+
allowClear: m = !1,
|
|
16
|
+
suffixIcon: d,
|
|
17
|
+
clearIcon: g,
|
|
18
|
+
classNames: r,
|
|
19
|
+
className: f,
|
|
20
|
+
onClear: l,
|
|
21
|
+
showSelectionSummary: p = !1,
|
|
22
|
+
selectionSummaryRender: i,
|
|
23
|
+
...u
|
|
24
|
+
}, N) => {
|
|
25
|
+
const o = I(), w = () => {
|
|
26
|
+
if (c.length === 0)
|
|
27
|
+
return /* @__PURE__ */ e("span", { className: o("combobox-selection-placeholder"), children: x });
|
|
28
|
+
if (n) {
|
|
29
|
+
if (p) {
|
|
30
|
+
const a = c.map((T) => T.value);
|
|
31
|
+
return /* @__PURE__ */ e("span", { className: o("combobox-selection-summary"), children: i ? i(a) : `${c.length} items selected` });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ e("span", { className: o("combobox-selection-text"), children: c.length === 1 ? c[0].label : `${c.length} items selected` });
|
|
34
|
+
} else
|
|
35
|
+
return /* @__PURE__ */ e("span", { className: o("combobox-selection-text"), children: c[0].label });
|
|
36
|
+
}, C = (a) => {
|
|
37
|
+
a.stopPropagation(), l == null || l();
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ e(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
ref: N,
|
|
43
|
+
className: v(
|
|
44
|
+
o("combobox"),
|
|
45
|
+
o(`combobox-${h}`),
|
|
46
|
+
n && o("combobox-multiple"),
|
|
47
|
+
b && o("combobox-disabled"),
|
|
48
|
+
s && o("combobox-open"),
|
|
49
|
+
o("combobox-trigger"),
|
|
50
|
+
r == null ? void 0 : r.trigger,
|
|
51
|
+
f
|
|
52
|
+
),
|
|
53
|
+
disabled: b,
|
|
54
|
+
role: "combobox",
|
|
55
|
+
"aria-expanded": s,
|
|
56
|
+
...u,
|
|
57
|
+
children: /* @__PURE__ */ t("span", { className: o("combobox-selector"), children: [
|
|
58
|
+
/* @__PURE__ */ e("span", { className: o("combobox-selection-wrap"), children: w() }),
|
|
59
|
+
/* @__PURE__ */ t("span", { className: o("combobox-selection-suffix"), children: [
|
|
60
|
+
m && c.length > 0 && /* @__PURE__ */ e(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
className: o("combobox-clear"),
|
|
64
|
+
unselectable: "on",
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
onClick: C,
|
|
67
|
+
children: g || /* @__PURE__ */ e("span", { className: o("combobox-clear-icon"), children: /* @__PURE__ */ e(j, { weight: "fill" }) })
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
(!m || c.length === 0) && /* @__PURE__ */ e(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
className: o("combobox-arrow"),
|
|
74
|
+
unselectable: "on",
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
children: d || /* @__PURE__ */ e("span", { className: o("combobox-arrow-icon"), children: /* @__PURE__ */ e(k, { weight: "bold" }) })
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] })
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
y.displayName = "ComboboxTrigger";
|
|
86
|
+
export {
|
|
87
|
+
y as ComboboxTrigger
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.js","sources":["../../../src/components/combobox/trigger.tsx"],"sourcesContent":["\"use client\";\nimport React, { forwardRef } from \"react\";\nimport { CaretDownIcon, XCircleIcon, XIcon } from \"@bioturing/assets\";\nimport { clsx, useCls } from \"../utils\";\nimport type { ComboboxOption } from \"./component\";\n\nexport interface ComboboxTriggerProps\n extends React.ComponentPropsWithoutRef<\"button\"> {\n /** Selected options */\n selectedOptions: ComboboxOption[];\n /** Placeholder text */\n placeholder?: string;\n /** Whether multiple selection is enabled */\n multiple?: boolean;\n /** Whether the component is disabled */\n disabled?: boolean;\n /** Whether the dropdown is open */\n open?: boolean;\n /** Size variant */\n size?: \"small\" | \"middle\" | \"large\";\n /** Whether to show clear button */\n allowClear?: boolean;\n /** Custom suffix icon */\n suffixIcon?: React.ReactNode;\n /** Custom clear icon */\n clearIcon?: React.ReactNode;\n /** Custom class names */\n classNames?: {\n trigger?: string;\n };\n /** Clear handler */\n onClear?: () => void;\n /** Show selection summary instead of individual tags when multiple */\n showSelectionSummary?: boolean;\n /** Render function for the selection summary in multiple case */\n selectionSummaryRender?: (selectedValues: Array<string | number>) => React.ReactNode;\n}\n\nexport const ComboboxTrigger = forwardRef<\n HTMLButtonElement,\n ComboboxTriggerProps\n>(\n (\n {\n selectedOptions,\n placeholder = \"Select...\",\n multiple = false,\n disabled = false,\n open = false,\n size = \"middle\",\n allowClear = false,\n suffixIcon,\n clearIcon,\n classNames,\n className,\n onClear,\n showSelectionSummary = false,\n selectionSummaryRender,\n ...rest\n },\n ref\n ) => {\n const cls = useCls();\n\n const renderTriggerContent = () => {\n if (selectedOptions.length === 0) {\n return (\n <span className={cls(\"combobox-selection-placeholder\")}>\n {placeholder}\n </span>\n );\n }\n\n if (multiple) {\n // Show selection summary if enabled\n if (showSelectionSummary) {\n const selectedValues = selectedOptions.map(opt => opt.value);\n return (\n <span className={cls(\"combobox-selection-summary\")}>\n {selectionSummaryRender\n ? selectionSummaryRender(selectedValues)\n : `${selectedOptions.length} items selected`}\n </span>\n );\n }\n \n // Default: Simple text display for multiple selections - no tags\n return (\n <span className={cls(\"combobox-selection-text\")}>\n {selectedOptions.length === 1\n ? selectedOptions[0].label\n : `${selectedOptions.length} items selected`}\n </span>\n );\n } else {\n return (\n <span className={cls(\"combobox-selection-text\")}>\n {selectedOptions[0].label}\n </span>\n );\n }\n };\n\n const handleClearClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n onClear?.();\n };\n\n return (\n <button\n ref={ref}\n className={clsx(\n cls(\"combobox\"),\n cls(`combobox-${size}`),\n multiple && cls(\"combobox-multiple\"),\n disabled && cls(\"combobox-disabled\"),\n open && cls(\"combobox-open\"),\n cls(\"combobox-trigger\"),\n classNames?.trigger,\n className\n )}\n disabled={disabled}\n role=\"combobox\"\n aria-expanded={open}\n {...rest}\n >\n <span className={cls(\"combobox-selector\")}>\n <span className={cls(\"combobox-selection-wrap\")}>\n {renderTriggerContent()}\n </span>\n <span className={cls(\"combobox-selection-suffix\")}>\n {allowClear && selectedOptions.length > 0 && (\n <span\n className={cls(\"combobox-clear\")}\n unselectable=\"on\"\n aria-hidden=\"true\"\n onClick={handleClearClick}\n >\n {clearIcon || (\n <span className={cls(\"combobox-clear-icon\")}>\n <XCircleIcon weight=\"fill\" />\n </span>\n )}\n </span>\n )}\n {(!allowClear || selectedOptions.length === 0) && (\n <span\n className={cls(\"combobox-arrow\")}\n unselectable=\"on\"\n aria-hidden=\"true\"\n >\n {suffixIcon || (\n <span className={cls(\"combobox-arrow-icon\")}>\n <CaretDownIcon weight=\"bold\" />\n </span>\n )}\n </span>\n )}\n </span>\n </span>\n </button>\n );\n }\n);\n\nComboboxTrigger.displayName = \"ComboboxTrigger\";\n"],"names":["ComboboxTrigger","forwardRef","selectedOptions","placeholder","multiple","disabled","open","size","allowClear","suffixIcon","clearIcon","classNames","className","onClear","showSelectionSummary","selectionSummaryRender","rest","ref","cls","useCls","renderTriggerContent","selectedValues","opt","jsx","handleClearClick","e","clsx","jsxs","XCircleIcon","CaretDownIcon"],"mappings":";;;;;;AAsCO,MAAMA,IAAkBC;AAAA,EAI7B,CACE;AAAA,IACE,iBAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,UAAAC,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,MAAAC,IAAO;AAAA,IACP,MAAAC,IAAO;AAAA,IACP,YAAAC,IAAa;AAAA,IACb,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,sBAAAC,IAAuB;AAAA,IACvB,wBAAAC;AAAA,IACA,GAAGC;AAAA,KAELC,MACG;AACH,UAAMC,IAAMC,EAAO,GAEbC,IAAuB,MAAM;AAC7B,UAAAlB,EAAgB,WAAW;AAC7B,iCACG,QAAK,EAAA,WAAWgB,EAAI,gCAAgC,GAClD,UACHf,GAAA;AAIJ,UAAIC,GA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AgB,SAAS,KACtC,gBAAAqB;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAWL,EAAI,gBAAgB;AAAA,gBAC/B,cAAa;AAAA,gBACb,eAAY;AAAA,gBACZ,SAASM;AAAA,gBAER,UAAAd,KACE,gBAAAa,EAAA,QAAA,EAAK,WAAWL,EAAI,qBAAqB,GACxC,UAAC,gBAAAK,EAAAK,GAAA,EAAY,QAAO,OAAO,CAAA,EAC7B,CAAA;AAAA,cAAA;AAAA,YAEJ;AAAA,aAEA,CAACpB,KAAcN,EAAgB,WAAW,MAC1C,gBAAAqB;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAWL,EAAI,gBAAgB;AAAA,gBAC/B,cAAa;AAAA,gBACb,eAAY;AAAA,gBAEX,UAAAT,KACE,gBAAAc,EAAA,QAAA,EAAK,WAAWL,EAAI,qBAAqB,GACxC,UAAC,gBAAAK,EAAAM,GAAA,EAAc,QAAO,OAAO,CAAA,EAC/B,CAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAEJ,EAEJ,CAAA;AAAA,QAAA,EACF,CAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;AAEA7B,EAAgB,cAAc;"}
|
|
@@ -1,206 +1,220 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { Menu as
|
|
5
|
-
import { useControlled as
|
|
6
|
-
import { Popover as
|
|
7
|
-
import { Command as
|
|
8
|
-
import { PopupPanelSize as
|
|
2
|
+
import { jsx as p, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback as w, useRef as X, createElement as Y } from "react";
|
|
4
|
+
import { Menu as h } from "@base-ui-components/react/menu";
|
|
5
|
+
import { useControlled as Z } from "@base-ui-components/utils/useControlled";
|
|
6
|
+
import { Popover as $ } from "@base-ui-components/react/popover";
|
|
7
|
+
import { Command as g } from "../cmdk/index.js";
|
|
8
|
+
import { PopupPanelSize as j } from "../popup-panel/constants.js";
|
|
9
|
+
import { DropdownMenuItem as c } from "./item.js";
|
|
9
10
|
import './style.css';/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
import { DropdownMenuDivider as O } from "./divider.js";
|
|
12
|
+
import { parseAntdPlacement as K } from "../utils/placement.js";
|
|
13
|
+
import { Input as a } from "../input/component.js";
|
|
14
|
+
import { ScrollArea as z } from "../scroll-area/component.js";
|
|
15
|
+
import { DROPDOWN_COLLISION_AVOIDANCE as N } from "../utils/constants.js";
|
|
16
|
+
import { useCls as s, useAntdCssVarClassname as oo } from "../utils/antdUtils.js";
|
|
17
|
+
import { clsx as u } from "../utils/cn.js";
|
|
18
|
+
const Co = ({
|
|
19
|
+
children: B,
|
|
20
|
+
items: S,
|
|
21
|
+
placement: T,
|
|
22
|
+
openOnHover: U,
|
|
23
|
+
open: W,
|
|
21
24
|
onOpenChange: v,
|
|
22
|
-
className:
|
|
23
|
-
itemRender:
|
|
24
|
-
classNames:
|
|
25
|
-
size:
|
|
26
|
-
showSearch:
|
|
27
|
-
searchProps:
|
|
25
|
+
className: q,
|
|
26
|
+
itemRender: k,
|
|
27
|
+
classNames: o,
|
|
28
|
+
size: y = "auto",
|
|
29
|
+
showSearch: d,
|
|
30
|
+
searchProps: E = {
|
|
28
31
|
placeholder: "Search..."
|
|
29
|
-
}
|
|
32
|
+
},
|
|
33
|
+
popupMatchTriggerWidth: F,
|
|
34
|
+
beforeList: C,
|
|
35
|
+
afterList: D,
|
|
36
|
+
keepOpenOnSelect: L,
|
|
37
|
+
highlightedItemKey: G,
|
|
38
|
+
selectedItemKeys: P,
|
|
39
|
+
showCheckbox: M
|
|
30
40
|
}) => {
|
|
31
|
-
const [
|
|
32
|
-
controlled:
|
|
41
|
+
const [H, R] = Z({
|
|
42
|
+
controlled: W,
|
|
33
43
|
default: !1,
|
|
34
44
|
name: "open"
|
|
35
|
-
}),
|
|
36
|
-
(
|
|
37
|
-
|
|
45
|
+
}), l = w(
|
|
46
|
+
(r) => {
|
|
47
|
+
R(r), v == null || v(r);
|
|
38
48
|
},
|
|
39
|
-
[
|
|
40
|
-
),
|
|
49
|
+
[R, v]
|
|
50
|
+
), e = s(), V = oo(), x = K(T), J = X(null), A = S.reduce((r, n) => (r.length === 0 && n.type !== "header" && r.push({
|
|
41
51
|
label: null,
|
|
42
52
|
items: []
|
|
43
|
-
}),
|
|
44
|
-
label:
|
|
53
|
+
}), n.type === "header" ? r.push({
|
|
54
|
+
label: n.title,
|
|
45
55
|
items: []
|
|
46
|
-
}) : (
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} else if (o.type === "divider")
|
|
85
|
-
return /* @__PURE__ */ e(
|
|
86
|
-
G,
|
|
87
|
-
{
|
|
88
|
-
className: d(
|
|
89
|
-
n("dropdown-menu-divider"),
|
|
90
|
-
r == null ? void 0 : r.separator
|
|
91
|
-
)
|
|
92
|
-
},
|
|
93
|
-
t + "-" + p
|
|
94
|
-
);
|
|
95
|
-
return null;
|
|
96
|
-
},
|
|
97
|
-
[n, r, I, m, i, G]
|
|
98
|
-
), A = M(
|
|
99
|
-
(o, t) => /* @__PURE__ */ g(
|
|
100
|
-
f.Group,
|
|
56
|
+
}) : (n.type === "item" || n.type === "divider") && r.length > 0 && r[r.length - 1].items.push(n), r), []), m = w(
|
|
57
|
+
(r, n, t) => r.type === "item" ? /* @__PURE__ */ p(
|
|
58
|
+
c,
|
|
59
|
+
{
|
|
60
|
+
item: r,
|
|
61
|
+
inCombobox: d,
|
|
62
|
+
selected: P == null ? void 0 : P.includes(r.key),
|
|
63
|
+
onSelect: d ? () => {
|
|
64
|
+
const i = new MouseEvent("click", {
|
|
65
|
+
bubbles: !0,
|
|
66
|
+
cancelable: !0
|
|
67
|
+
});
|
|
68
|
+
r.onClick(i), L || l == null || l(!1);
|
|
69
|
+
} : void 0,
|
|
70
|
+
itemRender: k,
|
|
71
|
+
showCheckbox: M
|
|
72
|
+
},
|
|
73
|
+
n + "-" + t
|
|
74
|
+
) : r.type === "divider" ? /* @__PURE__ */ p(
|
|
75
|
+
O,
|
|
76
|
+
{
|
|
77
|
+
inCombobox: d,
|
|
78
|
+
className: o == null ? void 0 : o.separator
|
|
79
|
+
},
|
|
80
|
+
n + "-" + t
|
|
81
|
+
) : null,
|
|
82
|
+
[
|
|
83
|
+
o,
|
|
84
|
+
k,
|
|
85
|
+
l,
|
|
86
|
+
d,
|
|
87
|
+
L,
|
|
88
|
+
P,
|
|
89
|
+
M
|
|
90
|
+
]
|
|
91
|
+
), I = w(
|
|
92
|
+
(r, n) => /* @__PURE__ */ b(
|
|
93
|
+
h.Group,
|
|
101
94
|
{
|
|
102
|
-
className:
|
|
95
|
+
className: u(e("dropdown-menu-group"), o == null ? void 0 : o.group),
|
|
103
96
|
children: [
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
r.label && /* @__PURE__ */ p(
|
|
98
|
+
h.GroupLabel,
|
|
106
99
|
{
|
|
107
|
-
className:
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
className: u(
|
|
101
|
+
e("dropdown-menu-header"),
|
|
102
|
+
o == null ? void 0 : o.groupLabel
|
|
110
103
|
),
|
|
111
|
-
children: /* @__PURE__ */
|
|
104
|
+
children: /* @__PURE__ */ p("span", { children: r.label })
|
|
112
105
|
}
|
|
113
106
|
),
|
|
114
|
-
|
|
107
|
+
r.items.map((t, i) => m(t, n, i))
|
|
115
108
|
]
|
|
116
109
|
},
|
|
117
|
-
"group" +
|
|
110
|
+
"group" + n
|
|
118
111
|
),
|
|
119
|
-
[
|
|
120
|
-
),
|
|
121
|
-
(
|
|
122
|
-
|
|
112
|
+
[e, o, m]
|
|
113
|
+
), _ = w(
|
|
114
|
+
(r, n) => r.label ? /* @__PURE__ */ p(
|
|
115
|
+
g.Group,
|
|
123
116
|
{
|
|
124
|
-
className:
|
|
125
|
-
heading: /* @__PURE__ */
|
|
126
|
-
|
|
117
|
+
className: u(e("dropdown-menu-group"), o == null ? void 0 : o.group),
|
|
118
|
+
heading: /* @__PURE__ */ p(
|
|
119
|
+
h.GroupLabel,
|
|
127
120
|
{
|
|
128
|
-
className:
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
className: u(
|
|
122
|
+
e("dropdown-menu-header"),
|
|
123
|
+
o == null ? void 0 : o.groupLabel
|
|
131
124
|
),
|
|
132
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ p("span", { children: r.label })
|
|
133
126
|
}
|
|
134
127
|
),
|
|
135
|
-
children:
|
|
128
|
+
children: r.items.map((t, i) => m(t, n, i))
|
|
136
129
|
},
|
|
137
|
-
"group" +
|
|
138
|
-
) :
|
|
139
|
-
[
|
|
140
|
-
),
|
|
141
|
-
() =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
130
|
+
"group" + n
|
|
131
|
+
) : r.items.map((t, i) => m(t, n, i)),
|
|
132
|
+
[e, o, m]
|
|
133
|
+
), Q = w(
|
|
134
|
+
() => d ? /* @__PURE__ */ b(
|
|
135
|
+
g,
|
|
136
|
+
{
|
|
137
|
+
className: e("dropdown-menu-container"),
|
|
138
|
+
disablePointerSelection: d,
|
|
139
|
+
defaultValue: G ? String(G) : void 0,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ Y(
|
|
142
|
+
g.Input,
|
|
143
|
+
{
|
|
144
|
+
...E,
|
|
145
|
+
key: "search",
|
|
146
|
+
render: /* @__PURE__ */ p(a, { allowClear: !0, className: e("dropdown-menu-search") })
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
C,
|
|
150
|
+
/* @__PURE__ */ p(z, { children: /* @__PURE__ */ b(g.List, { className: e("dropdown-menu-list"), children: [
|
|
151
|
+
/* @__PURE__ */ p(g.Empty, { className: e("dropdown-menu-empty"), children: "No results found." }),
|
|
152
|
+
A.map(_)
|
|
153
|
+
] }) }),
|
|
154
|
+
D
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
) : /* @__PURE__ */ b("div", { className: e("dropdown-menu-container"), children: [
|
|
158
|
+
C,
|
|
159
|
+
/* @__PURE__ */ p(z, { children: A.map(I) }),
|
|
160
|
+
D
|
|
161
|
+
] }),
|
|
155
162
|
[
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
d,
|
|
164
|
+
e,
|
|
165
|
+
G,
|
|
158
166
|
E,
|
|
167
|
+
C,
|
|
159
168
|
A,
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
_,
|
|
170
|
+
D,
|
|
171
|
+
I
|
|
162
172
|
]
|
|
163
|
-
),
|
|
164
|
-
return /* @__PURE__ */
|
|
165
|
-
|
|
173
|
+
), f = d ? $ : h;
|
|
174
|
+
return /* @__PURE__ */ b(
|
|
175
|
+
f.Root,
|
|
166
176
|
{
|
|
167
|
-
openOnHover:
|
|
168
|
-
open:
|
|
169
|
-
onOpenChange:
|
|
177
|
+
openOnHover: U,
|
|
178
|
+
open: H,
|
|
179
|
+
onOpenChange: l,
|
|
170
180
|
children: [
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
|
|
181
|
+
/* @__PURE__ */ p(
|
|
182
|
+
f.Trigger,
|
|
173
183
|
{
|
|
174
|
-
render:
|
|
175
|
-
ref:
|
|
176
|
-
className:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
render: B,
|
|
185
|
+
ref: J,
|
|
186
|
+
className: u(
|
|
187
|
+
e("dropdown-menu-trigger"),
|
|
188
|
+
o == null ? void 0 : o.trigger,
|
|
189
|
+
V
|
|
180
190
|
)
|
|
181
191
|
}
|
|
182
192
|
),
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
193
|
+
/* @__PURE__ */ p(f.Portal, { children: /* @__PURE__ */ p(
|
|
194
|
+
f.Positioner,
|
|
185
195
|
{
|
|
186
|
-
side:
|
|
187
|
-
align:
|
|
196
|
+
side: x.side,
|
|
197
|
+
align: x.align,
|
|
188
198
|
sideOffset: 4,
|
|
189
|
-
className:
|
|
190
|
-
collisionAvoidance:
|
|
191
|
-
children: /* @__PURE__ */
|
|
192
|
-
|
|
199
|
+
className: u(e("dropdown-menu-root"), o == null ? void 0 : o.root),
|
|
200
|
+
collisionAvoidance: N,
|
|
201
|
+
children: /* @__PURE__ */ p(
|
|
202
|
+
f.Popup,
|
|
193
203
|
{
|
|
194
|
-
className:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
className: u(
|
|
205
|
+
e(
|
|
206
|
+
"dropdown-menu",
|
|
207
|
+
M && "dropdown-menu-show-checkbox",
|
|
208
|
+
F && "dropdown-menu-match-trigger-width"
|
|
209
|
+
),
|
|
210
|
+
q,
|
|
211
|
+
o == null ? void 0 : o.popup,
|
|
212
|
+
V
|
|
199
213
|
),
|
|
200
214
|
style: {
|
|
201
|
-
"--size-width":
|
|
215
|
+
"--size-width": y in j ? j[y] : void 0
|
|
202
216
|
},
|
|
203
|
-
children:
|
|
217
|
+
children: Q()
|
|
204
218
|
}
|
|
205
219
|
)
|
|
206
220
|
}
|
|
@@ -210,6 +224,6 @@ const lo = ({
|
|
|
210
224
|
);
|
|
211
225
|
};
|
|
212
226
|
export {
|
|
213
|
-
|
|
227
|
+
Co as DropdownMenu
|
|
214
228
|
};
|
|
215
229
|
//# sourceMappingURL=component.js.map
|