jenosize-ui 0.1.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.
- package/LICENSE +28 -0
- package/README.md +100 -0
- package/THIRD-PARTY-NOTICES.md +163 -0
- package/dist/Button-Bt7pzM4R.d.ts +82 -0
- package/dist/PaymentInput-CKPIPNWH.d.ts +141 -0
- package/dist/Select-CVbEQ2Ep.d.ts +118 -0
- package/dist/TagInput-CTJYOB4J.d.ts +90 -0
- package/dist/avatar.d.ts +161 -0
- package/dist/avatar.js +11 -0
- package/dist/badge.d.ts +109 -0
- package/dist/badge.js +10 -0
- package/dist/breadcrumb.d.ts +58 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/button.d.ts +54 -0
- package/dist/button.js +14 -0
- package/dist/calendar.d.ts +368 -0
- package/dist/calendar.js +21 -0
- package/dist/callout.d.ts +70 -0
- package/dist/callout.js +16 -0
- package/dist/card-nWicloNi.d.ts +80 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +7 -0
- package/dist/checkbox.d.ts +133 -0
- package/dist/checkbox.js +11 -0
- package/dist/chunk-24TO7E32.js +42 -0
- package/dist/chunk-3Y5X7B5C.js +146 -0
- package/dist/chunk-4OLULPQG.js +202 -0
- package/dist/chunk-4P2NBLBW.js +103 -0
- package/dist/chunk-52IFGFTL.js +11 -0
- package/dist/chunk-5FATN5YD.js +115 -0
- package/dist/chunk-5NOBSXJN.js +297 -0
- package/dist/chunk-5RAPA22E.js +106 -0
- package/dist/chunk-7EUAMHMU.js +16 -0
- package/dist/chunk-7EWQKTNQ.js +1336 -0
- package/dist/chunk-7HOIZ3UO.js +110 -0
- package/dist/chunk-7IU5TMFL.js +452 -0
- package/dist/chunk-7JBNLEJ7.js +29 -0
- package/dist/chunk-7S2TBALK.js +23 -0
- package/dist/chunk-BJUZVYQC.js +188 -0
- package/dist/chunk-BVJWBYIG.js +66 -0
- package/dist/chunk-CME4DIML.js +65 -0
- package/dist/chunk-CYPPEUX5.js +73 -0
- package/dist/chunk-D5BTFSL7.js +71 -0
- package/dist/chunk-D6TPWNRK.js +387 -0
- package/dist/chunk-DJSXIAFH.js +66 -0
- package/dist/chunk-DRZCJCBO.js +46 -0
- package/dist/chunk-DWKILXHE.js +17 -0
- package/dist/chunk-E7ZSWBAK.js +70 -0
- package/dist/chunk-EDSK6FEH.js +8 -0
- package/dist/chunk-F2K7VJUV.js +114 -0
- package/dist/chunk-F6NLE6XJ.js +40 -0
- package/dist/chunk-FHHAPGCR.js +32 -0
- package/dist/chunk-FXIBGTS5.js +14 -0
- package/dist/chunk-GCVA3OIV.js +72 -0
- package/dist/chunk-GFOAJVW5.js +336 -0
- package/dist/chunk-GRLSUQQE.js +136 -0
- package/dist/chunk-GTHJWR3Q.js +77 -0
- package/dist/chunk-HMUZE6EK.js +67 -0
- package/dist/chunk-I7WU4GTY.js +503 -0
- package/dist/chunk-J2BCKBHC.js +151 -0
- package/dist/chunk-J36M3KRX.js +1315 -0
- package/dist/chunk-J7ZQQFPT.js +113 -0
- package/dist/chunk-JP26LPCY.js +234 -0
- package/dist/chunk-JTNFJLIY.js +1046 -0
- package/dist/chunk-JVJRHBTD.js +50 -0
- package/dist/chunk-JYGR44ZC.js +133 -0
- package/dist/chunk-KDLPXXD2.js +173 -0
- package/dist/chunk-KMSYEE23.js +224 -0
- package/dist/chunk-KNYKWUYX.js +52 -0
- package/dist/chunk-LME57Z6J.js +138 -0
- package/dist/chunk-MFJP5FA7.js +20 -0
- package/dist/chunk-MKC5HNA7.js +1692 -0
- package/dist/chunk-MQGD2OUF.js +39 -0
- package/dist/chunk-MUFHLP4S.js +566 -0
- package/dist/chunk-O2LG3PNI.js +74 -0
- package/dist/chunk-O4GRKO3I.js +66 -0
- package/dist/chunk-OHUFNYGN.js +791 -0
- package/dist/chunk-PWKWNDBS.js +243 -0
- package/dist/chunk-QA74ITR4.js +103 -0
- package/dist/chunk-R6RGJF4L.js +170 -0
- package/dist/chunk-S7NNXWIN.js +7 -0
- package/dist/chunk-SV56BSUQ.js +162 -0
- package/dist/chunk-T7FCG7XV.js +435 -0
- package/dist/chunk-THC2ISYP.js +57 -0
- package/dist/chunk-VWC72TR3.js +115 -0
- package/dist/chunk-W46K56XU.js +216 -0
- package/dist/chunk-W5GGOUUI.js +75 -0
- package/dist/chunk-WEUJYDCV.js +269 -0
- package/dist/chunk-WFY7DKQD.js +279 -0
- package/dist/chunk-WZQFC7ZN.js +448 -0
- package/dist/chunk-Z3ETJN5G.js +136 -0
- package/dist/chunk-ZOOX3TUB.js +192 -0
- package/dist/chunk-ZSNJ6UA3.js +42 -0
- package/dist/chunk-ZZA2LUTL.js +130 -0
- package/dist/chunk-ZZT2E5VT.js +24 -0
- package/dist/color-CtSxc1Rh.d.ts +6 -0
- package/dist/combobox.d.ts +184 -0
- package/dist/combobox.js +21 -0
- package/dist/date-input.d.ts +83 -0
- package/dist/date-input.js +16 -0
- package/dist/date-picker.d.ts +249 -0
- package/dist/date-picker.js +29 -0
- package/dist/date-utils-7hTFTXNK.d.ts +34 -0
- package/dist/date-vMJBKAFK.d.ts +22 -0
- package/dist/dialog.d.ts +86 -0
- package/dist/dialog.js +15 -0
- package/dist/drawer.d.ts +77 -0
- package/dist/drawer.js +14 -0
- package/dist/dropdown-menu.d.ts +218 -0
- package/dist/dropdown-menu.js +10 -0
- package/dist/file-trigger.d.ts +42 -0
- package/dist/file-trigger.js +3 -0
- package/dist/form.d.ts +487 -0
- package/dist/form.js +1179 -0
- package/dist/header-navigation.d.ts +74 -0
- package/dist/header-navigation.js +23 -0
- package/dist/icons/app.d.ts +48 -0
- package/dist/icons/app.js +282 -0
- package/dist/icons/flag.d.ts +817 -0
- package/dist/icons/flag.js +58336 -0
- package/dist/icons/integration.d.ts +36 -0
- package/dist/icons/integration.js +531 -0
- package/dist/icons/payment.d.ts +116 -0
- package/dist/icons/payment.js +2418 -0
- package/dist/icons.d.ts +2013 -0
- package/dist/icons.js +2012 -0
- package/dist/illustration.d.ts +48 -0
- package/dist/illustration.js +4 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +73 -0
- package/dist/indicator.d.ts +51 -0
- package/dist/indicator.js +7 -0
- package/dist/input.d.ts +66 -0
- package/dist/input.js +15 -0
- package/dist/multi-value-CJb_tnvi.d.ts +8 -0
- package/dist/nav-Bla0o_-1.d.ts +98 -0
- package/dist/number-input.d.ts +80 -0
- package/dist/number-input.js +15 -0
- package/dist/options-CPEIgjtd.d.ts +68 -0
- package/dist/overflow-Df0h42Oi.d.ts +29 -0
- package/dist/pagination.d.ts +77 -0
- package/dist/pagination.js +17 -0
- package/dist/payment-input.d.ts +7 -0
- package/dist/payment-input.js +15 -0
- package/dist/popover.d.ts +60 -0
- package/dist/popover.js +14 -0
- package/dist/progress.d.ts +87 -0
- package/dist/progress.js +5 -0
- package/dist/radio.d.ts +77 -0
- package/dist/radio.js +12 -0
- package/dist/select.d.ts +68 -0
- package/dist/select.js +24 -0
- package/dist/shared-BNXAdgh2.d.ts +9 -0
- package/dist/shared-BYXJPnsN.d.ts +11 -0
- package/dist/shared-Dc-GgA16.d.ts +42 -0
- package/dist/sidebar-navigation.d.ts +129 -0
- package/dist/sidebar-navigation.js +15 -0
- package/dist/styles.css +2 -0
- package/dist/switch.d.ts +23 -0
- package/dist/switch.js +7 -0
- package/dist/table.d.ts +692 -0
- package/dist/table.js +44 -0
- package/dist/tabs.d.ts +111 -0
- package/dist/tabs.js +8 -0
- package/dist/tag-input.d.ts +12 -0
- package/dist/tag-input.js +19 -0
- package/dist/tag.d.ts +98 -0
- package/dist/tag.js +9 -0
- package/dist/textarea.d.ts +40 -0
- package/dist/textarea.js +12 -0
- package/dist/theme-script.d.ts +29 -0
- package/dist/theme-script.js +15 -0
- package/dist/theme.css +929 -0
- package/dist/theme.d.ts +71 -0
- package/dist/theme.js +15 -0
- package/dist/toast.d.ts +242 -0
- package/dist/toast.js +15 -0
- package/dist/tooltip.d.ts +70 -0
- package/dist/tooltip.js +6 -0
- package/dist/tree.d.ts +308 -0
- package/dist/tree.js +11 -0
- package/package.json +352 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { XIcon } from './chunk-24TO7E32.js';
|
|
2
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
3
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import 'react';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var BASE = "flex cursor-pointer items-center justify-center rounded-lg p-2 outline-focus-ring transition duration-100 ease-linear focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:shrink-0 [&_svg]:transition-colors [&_svg]:duration-100 [&_svg]:ease-linear";
|
|
9
|
+
var SIZE = {
|
|
10
|
+
xs: "size-7 [&_svg]:size-4",
|
|
11
|
+
sm: "size-9 [&_svg]:size-5",
|
|
12
|
+
md: "size-10 [&_svg]:size-5",
|
|
13
|
+
lg: "size-11 [&_svg]:size-6"
|
|
14
|
+
};
|
|
15
|
+
var THEME = {
|
|
16
|
+
light: "text-fg-quaternary hover:bg-secondary hover:text-fg-quaternary_hover",
|
|
17
|
+
dark: "text-white/70 hover:bg-white/20 hover:text-white"
|
|
18
|
+
};
|
|
19
|
+
function CloseButton(props) {
|
|
20
|
+
const { render, size = "sm", theme = "light", label = "Close", disabled = false, type = "button", className, ...rest } = props;
|
|
21
|
+
return useRender({
|
|
22
|
+
defaultTagName: "button",
|
|
23
|
+
render,
|
|
24
|
+
props: mergeProps(
|
|
25
|
+
{
|
|
26
|
+
type,
|
|
27
|
+
className: cn(BASE, SIZE[size], THEME[theme], className),
|
|
28
|
+
children: /* @__PURE__ */ jsx(XIcon, {}),
|
|
29
|
+
disabled,
|
|
30
|
+
"aria-label": label
|
|
31
|
+
},
|
|
32
|
+
rest
|
|
33
|
+
)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { CloseButton };
|
|
38
|
+
//# sourceMappingURL=chunk-MQGD2OUF.js.map
|
|
39
|
+
//# sourceMappingURL=chunk-MQGD2OUF.js.map
|
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import { useDebouncedCallback } from './chunk-F6NLE6XJ.js';
|
|
2
|
+
import { useControlScrollFade } from './chunk-7EUAMHMU.js';
|
|
3
|
+
import { ListboxFooter, MultiValueCount } from './chunk-FHHAPGCR.js';
|
|
4
|
+
import { mapOptions, isOptionGroup, buildOptionMap } from './chunk-7JBNLEJ7.js';
|
|
5
|
+
import { useTagRow } from './chunk-W5GGOUUI.js';
|
|
6
|
+
import { tagSlotClass, tagContentClass, tagCloseClass, tagRootClass } from './chunk-4P2NBLBW.js';
|
|
7
|
+
import { FieldShell } from './chunk-QA74ITR4.js';
|
|
8
|
+
import { Slot } from './chunk-52IFGFTL.js';
|
|
9
|
+
import { useScrollFade } from './chunk-O2LG3PNI.js';
|
|
10
|
+
import { useFieldValidity, FieldFrame, LISTBOX_PX_SM, CONTROL_ICON, SLOT_ICON } from './chunk-J2BCKBHC.js';
|
|
11
|
+
import { PlusIcon, XIcon, ChevronDownIcon, LoaderCircleIcon, CheckIcon } from './chunk-24TO7E32.js';
|
|
12
|
+
import { POPUP_MOTION } from './chunk-O4GRKO3I.js';
|
|
13
|
+
import { warnNonNegativeInt } from './chunk-GCVA3OIV.js';
|
|
14
|
+
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
15
|
+
import { Combobox as Combobox$1 } from '@base-ui/react/combobox';
|
|
16
|
+
import * as React from 'react';
|
|
17
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
18
|
+
|
|
19
|
+
var ComboboxContext = React.createContext({
|
|
20
|
+
size: "md",
|
|
21
|
+
multiple: false,
|
|
22
|
+
clearable: false,
|
|
23
|
+
indicator: "checkmark",
|
|
24
|
+
indicatorAlign: "left",
|
|
25
|
+
optionMap: /* @__PURE__ */ new Map(),
|
|
26
|
+
query: "",
|
|
27
|
+
anchorRef: { current: null }
|
|
28
|
+
});
|
|
29
|
+
var useComboboxContext = () => React.useContext(ComboboxContext);
|
|
30
|
+
function ComboboxRoot(props) {
|
|
31
|
+
const {
|
|
32
|
+
size = "md",
|
|
33
|
+
options,
|
|
34
|
+
selectionIndicator,
|
|
35
|
+
selectionIndicatorAlign = "left",
|
|
36
|
+
label,
|
|
37
|
+
tooltip,
|
|
38
|
+
tooltipDescription,
|
|
39
|
+
hint,
|
|
40
|
+
hideRequiredIndicator = false,
|
|
41
|
+
invalid = false,
|
|
42
|
+
error,
|
|
43
|
+
clearable = false,
|
|
44
|
+
fullWidth = true,
|
|
45
|
+
onInputChange,
|
|
46
|
+
disabled = false,
|
|
47
|
+
multiple,
|
|
48
|
+
itemToStringLabel: itemToStringLabelProp,
|
|
49
|
+
// Pulled out so the multi-select "stay open while picking" mirror below owns them —
|
|
50
|
+
// `{...rest}` is spread LAST, so leaving them in it would re-override our handler.
|
|
51
|
+
open: openProp,
|
|
52
|
+
onOpenChange,
|
|
53
|
+
// Pulled OUT of `rest`: Base UI's `Combobox.Root` renders no DOM node, so a `className` left
|
|
54
|
+
// in `rest` would be silently dropped. It belongs on the Field column like every other Field
|
|
55
|
+
// control (AGENTS §4/§6).
|
|
56
|
+
className,
|
|
57
|
+
...rest
|
|
58
|
+
} = props;
|
|
59
|
+
const { isInvalid, showError } = useFieldValidity(invalid, error);
|
|
60
|
+
const reactId = React.useId();
|
|
61
|
+
const labelId = label != null ? `${reactId}-label` : void 0;
|
|
62
|
+
const isMulti = multiple === true;
|
|
63
|
+
const indicator = selectionIndicator ?? (isMulti ? "checkbox" : "checkmark");
|
|
64
|
+
const optionMap = React.useMemo(() => buildOptionMap(options), [options]);
|
|
65
|
+
const autoItemToStringLabel = React.useMemo(
|
|
66
|
+
() => optionMap.size > 0 ? (value) => {
|
|
67
|
+
const opt = optionMap.get(value);
|
|
68
|
+
return opt && typeof opt.label === "string" ? opt.label : value;
|
|
69
|
+
} : void 0,
|
|
70
|
+
[optionMap]
|
|
71
|
+
);
|
|
72
|
+
const itemToStringLabel = itemToStringLabelProp ?? autoItemToStringLabel;
|
|
73
|
+
const inputValueProp = typeof props.inputValue === "string" ? props.inputValue : void 0;
|
|
74
|
+
const [query, setQuery] = React.useState(() => inputValueProp ?? (typeof props.defaultInputValue === "string" ? props.defaultInputValue : ""));
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (inputValueProp !== void 0) setQuery(inputValueProp);
|
|
77
|
+
}, [inputValueProp]);
|
|
78
|
+
const handleInputValueChange = (value, details) => {
|
|
79
|
+
setQuery(value);
|
|
80
|
+
onInputChange?.(value, details);
|
|
81
|
+
};
|
|
82
|
+
const ownsOpen = isMulti && openProp === void 0;
|
|
83
|
+
const [openSelf, setOpenSelf] = React.useState(props.defaultOpen ?? false);
|
|
84
|
+
const handleOpenChange = (nextOpen, details) => {
|
|
85
|
+
onOpenChange?.(nextOpen, details);
|
|
86
|
+
if (details.isCanceled) return;
|
|
87
|
+
if (!nextOpen && details.reason === "item-press") return;
|
|
88
|
+
setOpenSelf(nextOpen);
|
|
89
|
+
};
|
|
90
|
+
const anchorRef = React.useRef(null);
|
|
91
|
+
const ctx = React.useMemo(
|
|
92
|
+
() => ({ size, multiple: isMulti, clearable, indicator, indicatorAlign: selectionIndicatorAlign, labelId, optionMap, query, anchorRef }),
|
|
93
|
+
[size, isMulti, clearable, indicator, selectionIndicatorAlign, labelId, optionMap, query]
|
|
94
|
+
);
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
FieldFrame,
|
|
97
|
+
{
|
|
98
|
+
label,
|
|
99
|
+
tooltip,
|
|
100
|
+
tooltipDescription,
|
|
101
|
+
labelId,
|
|
102
|
+
required: props.required,
|
|
103
|
+
hideRequiredIndicator,
|
|
104
|
+
hint,
|
|
105
|
+
error,
|
|
106
|
+
isInvalid,
|
|
107
|
+
showError,
|
|
108
|
+
size,
|
|
109
|
+
disabled,
|
|
110
|
+
fullWidth,
|
|
111
|
+
className,
|
|
112
|
+
children: /* @__PURE__ */ jsx(ComboboxContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
113
|
+
Combobox$1.Root,
|
|
114
|
+
{
|
|
115
|
+
disabled,
|
|
116
|
+
multiple,
|
|
117
|
+
itemToStringLabel,
|
|
118
|
+
onInputValueChange: handleInputValueChange,
|
|
119
|
+
...rest,
|
|
120
|
+
open: ownsOpen ? openSelf : openProp,
|
|
121
|
+
onOpenChange: ownsOpen ? handleOpenChange : onOpenChange
|
|
122
|
+
}
|
|
123
|
+
) })
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
var INNER_INPUT = "min-w-0 flex-1 bg-transparent text-primary outline-none placeholder:text-quaternary disabled:cursor-not-allowed read-only:cursor-default";
|
|
128
|
+
var CHIP_SIZE = { sm: "sm", md: "md", lg: "md" };
|
|
129
|
+
function ghostRemainder(optionMap, query) {
|
|
130
|
+
if (query === "") return "";
|
|
131
|
+
const q = query.toLowerCase();
|
|
132
|
+
let completion = "";
|
|
133
|
+
for (const opt of optionMap.values()) {
|
|
134
|
+
if (typeof opt.label !== "string") continue;
|
|
135
|
+
const label = opt.label.toLowerCase();
|
|
136
|
+
if (label === q) return "";
|
|
137
|
+
if (completion === "" && label.startsWith(q) && opt.label.length > query.length) {
|
|
138
|
+
completion = opt.label.slice(query.length);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return completion;
|
|
142
|
+
}
|
|
143
|
+
function ComboboxInput({
|
|
144
|
+
placeholder = "Search\u2026",
|
|
145
|
+
leading,
|
|
146
|
+
trailing,
|
|
147
|
+
leadingAddon,
|
|
148
|
+
trailingAddon,
|
|
149
|
+
renderChip,
|
|
150
|
+
display = "tags",
|
|
151
|
+
supportingText,
|
|
152
|
+
maxRows,
|
|
153
|
+
selectedCount = 0,
|
|
154
|
+
scrollFade = false,
|
|
155
|
+
children,
|
|
156
|
+
className
|
|
157
|
+
}) {
|
|
158
|
+
const { size, multiple, labelId, optionMap, query, anchorRef } = useComboboxContext();
|
|
159
|
+
const chips = multiple && display === "tags";
|
|
160
|
+
const { ref: fadeRef, style: fadeStyle } = useControlScrollFade(scrollFade && !multiple);
|
|
161
|
+
const ghost = !multiple && optionMap.size > 0;
|
|
162
|
+
const remainder = ghost ? ghostRemainder(optionMap, query) : "";
|
|
163
|
+
const chipRow = useTagRow({ size, maxRows, count: selectedCount, hasPills: chips && selectedCount > 0, scrollbar: "none" });
|
|
164
|
+
const showCount = multiple && !chips && selectedCount > 0;
|
|
165
|
+
const inputPlaceholder = showCount ? void 0 : placeholder;
|
|
166
|
+
return /* @__PURE__ */ jsxs(
|
|
167
|
+
FieldShell,
|
|
168
|
+
{
|
|
169
|
+
render: /* @__PURE__ */ jsx(Combobox$1.InputGroup, {}),
|
|
170
|
+
boxRef: anchorRef,
|
|
171
|
+
size,
|
|
172
|
+
fluid: true,
|
|
173
|
+
leading,
|
|
174
|
+
trailing,
|
|
175
|
+
leadingAddon,
|
|
176
|
+
trailingAddon,
|
|
177
|
+
glyphTrailing: children,
|
|
178
|
+
className: cn(
|
|
179
|
+
// `group` is the hook the inner adornments' `group-data-*` styles read — it belongs to
|
|
180
|
+
// Combobox, not to the shared shell.
|
|
181
|
+
"group",
|
|
182
|
+
size === "sm" && LISTBOX_PX_SM,
|
|
183
|
+
// Once the chip row is capped and overflowing, top-align the shell's own children so the
|
|
184
|
+
// affixes and trailing controls sit level with the FIRST row, not the block's middle.
|
|
185
|
+
chipRow.capped && chipRow.scrollable && "items-start",
|
|
186
|
+
className
|
|
187
|
+
),
|
|
188
|
+
children: [
|
|
189
|
+
showCount ? /* @__PURE__ */ jsx("span", { className: "flex min-w-0 shrink-0 items-center", children: /* @__PURE__ */ jsx(MultiValueCount, { count: selectedCount, supportingText }) }) : null,
|
|
190
|
+
chips ? /* @__PURE__ */ jsxs(Combobox$1.Chips, { ref: chipRow.ref, className: cn(chipRow.className, "min-w-0 flex-1"), style: chipRow.style, children: [
|
|
191
|
+
/* @__PURE__ */ jsx(Combobox$1.Value, { children: (selected) => {
|
|
192
|
+
const values = Array.isArray(selected) ? selected : [];
|
|
193
|
+
return values.map((value, index) => {
|
|
194
|
+
const opt = optionMap.get(String(value));
|
|
195
|
+
const chip = renderChip?.(String(value)) ?? {
|
|
196
|
+
label: opt?.label ?? String(value),
|
|
197
|
+
leading: opt?.leading
|
|
198
|
+
};
|
|
199
|
+
return /* @__PURE__ */ jsxs(
|
|
200
|
+
Combobox$1.Chip,
|
|
201
|
+
{
|
|
202
|
+
className: cn(
|
|
203
|
+
tagRootClass(CHIP_SIZE[size], { withLeading: !!chip.leading, withClose: true }),
|
|
204
|
+
// Disabled = the shell's uniform opacity-50 fade (LOCKED); no per-chip color swap.
|
|
205
|
+
// One-line chip at its natural width (`shrink-0`) — the ROW absorbs the
|
|
206
|
+
// overflow (wrapping, or scrolling under `maxRows`), so a long label is
|
|
207
|
+
// reached by wrapping/scrolling instead of squeezing the chip, breaking its
|
|
208
|
+
// label, or spilling past the field's ring.
|
|
209
|
+
"shrink-0"
|
|
210
|
+
),
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsxs("span", { className: tagContentClass(CHIP_SIZE[size]), children: [
|
|
213
|
+
chip.leading ? /* @__PURE__ */ jsx(Slot, { className: tagSlotClass(CHIP_SIZE[size]), children: chip.leading }) : null,
|
|
214
|
+
chip.label
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
Combobox$1.ChipRemove,
|
|
218
|
+
{
|
|
219
|
+
"aria-label": `Remove ${typeof chip.label === "string" ? chip.label : String(value)}`,
|
|
220
|
+
className: tagCloseClass(CHIP_SIZE[size]),
|
|
221
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
`${String(value)}-${index}`
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
} }),
|
|
230
|
+
/* @__PURE__ */ jsx(Combobox$1.Input, { "aria-labelledby": labelId, placeholder, className: cn(INNER_INPUT, "min-w-[4rem]") })
|
|
231
|
+
] }) : (
|
|
232
|
+
// ONE structure for the ghost-text and plain inputs — the input's position and element type
|
|
233
|
+
// are identical whether or not there is a ghost remainder.
|
|
234
|
+
//
|
|
235
|
+
// They used to be two sibling branches, and `ghost` is derived from `optionMap.size > 0`. So
|
|
236
|
+
// the moment an async search returned no matches, the element AT THIS JSX POSITION changed
|
|
237
|
+
// type from `<span>` to `<BaseCombobox.Input>`; React cannot reconcile across a type change,
|
|
238
|
+
// so it unmounted the subtree and mounted a fresh one. The focused `<input>` DOM node was
|
|
239
|
+
// destroyed: focus fell to `<body>`, the popup closed, and the keystroke that caused it was
|
|
240
|
+
// lost. Every empty↔non-empty transition, i.e. every time a query stops matching and every
|
|
241
|
+
// time it starts again — and `docs/components/combobox.md` prescribes exactly this async
|
|
242
|
+
// shape, so the documented pattern was the broken one.
|
|
243
|
+
//
|
|
244
|
+
// Ghost-text (inline autocomplete): the real input stays OPAQUE — it is the source
|
|
245
|
+
// of truth, so it always shows the live value (including a preselected value that
|
|
246
|
+
// never fired an input event) and scrolls its own overflow natively. The overlay adds
|
|
247
|
+
// ONLY the muted autocomplete remainder, pushed into place by an invisible copy of the
|
|
248
|
+
// query (no scroll-sync or width measurement needed; it clips off-screen on overflow).
|
|
249
|
+
//
|
|
250
|
+
// The wrapper is layout-neutral for the plain case: it carries the same `min-w-0 flex-1`
|
|
251
|
+
// the input already had from `INNER_INPUT`, so the input still fills the same box.
|
|
252
|
+
/* @__PURE__ */ jsxs("span", { className: "relative flex min-w-0 flex-1 items-center", children: [
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
Combobox$1.Input,
|
|
255
|
+
{
|
|
256
|
+
ref: fadeRef,
|
|
257
|
+
style: fadeStyle,
|
|
258
|
+
"aria-labelledby": labelId,
|
|
259
|
+
placeholder: inputPlaceholder,
|
|
260
|
+
className: cn(INNER_INPUT, "font-medium placeholder:font-normal")
|
|
261
|
+
}
|
|
262
|
+
),
|
|
263
|
+
ghost && remainder ? /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 flex items-center overflow-hidden font-medium", children: [
|
|
264
|
+
/* @__PURE__ */ jsx("span", { className: "invisible whitespace-pre", children: query }),
|
|
265
|
+
/* @__PURE__ */ jsx("span", { className: "whitespace-pre text-tertiary", children: remainder })
|
|
266
|
+
] }) : null
|
|
267
|
+
] })
|
|
268
|
+
)
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
var TRAILING_BTN = "inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md text-fg-quaternary outline-none transition-colors hover:text-fg-quaternary_hover focus-visible:text-fg-quaternary_hover data-[disabled]:cursor-not-allowed";
|
|
274
|
+
function ComboboxTrigger({ className }) {
|
|
275
|
+
const { size } = useComboboxContext();
|
|
276
|
+
return /* @__PURE__ */ jsx(Combobox$1.Trigger, { "aria-label": "Show options", className: cn(TRAILING_BTN, CONTROL_ICON[size], className), children: /* @__PURE__ */ jsx(Combobox$1.Icon, { className: "inline-flex transition-transform duration-200 group-data-[popup-open]:rotate-180", children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) }) });
|
|
277
|
+
}
|
|
278
|
+
function ComboboxClear({ className }) {
|
|
279
|
+
const { clearable, size } = useComboboxContext();
|
|
280
|
+
if (!clearable) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return /* @__PURE__ */ jsx(Combobox$1.Clear, { "aria-label": "Clear", className: cn(TRAILING_BTN, CONTROL_ICON[size], className), children: /* @__PURE__ */ jsx(XIcon, {}) });
|
|
284
|
+
}
|
|
285
|
+
var POPUP = cn("w-full rounded-lg bg-primary p-1 text-primary shadow-lg ring-1 ring-secondary_alt outline-none ring-inset", POPUP_MOTION);
|
|
286
|
+
var LIST_BASE = "overflow-y-auto overscroll-contain outline-none";
|
|
287
|
+
var LIST_MAX_H = {
|
|
288
|
+
sm: "max-h-[min(var(--available-height),14rem)]",
|
|
289
|
+
md: "max-h-[min(var(--available-height),16rem)]",
|
|
290
|
+
lg: "max-h-[min(var(--available-height),20rem)]"
|
|
291
|
+
};
|
|
292
|
+
function ComboboxContent({ children, footer, className }) {
|
|
293
|
+
const { size, anchorRef } = useComboboxContext();
|
|
294
|
+
const listRef = React.useRef(null);
|
|
295
|
+
const { maskImage } = useScrollFade(listRef, { axis: "vertical" });
|
|
296
|
+
return /* @__PURE__ */ jsx(Combobox$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
297
|
+
Combobox$1.Positioner,
|
|
298
|
+
{
|
|
299
|
+
anchor: anchorRef,
|
|
300
|
+
side: "bottom",
|
|
301
|
+
align: "start",
|
|
302
|
+
sideOffset: 4,
|
|
303
|
+
className: "z-50 w-fit max-w-[var(--available-width)] min-w-[var(--anchor-width)] outline-none",
|
|
304
|
+
children: /* @__PURE__ */ jsxs(Combobox$1.Popup, { className: cn(POPUP, className), children: [
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
|
+
Combobox$1.List,
|
|
307
|
+
{
|
|
308
|
+
ref: listRef,
|
|
309
|
+
className: cn(LIST_BASE, LIST_MAX_H[size]),
|
|
310
|
+
style: maskImage ? { maskImage, WebkitMaskImage: maskImage } : void 0,
|
|
311
|
+
children
|
|
312
|
+
}
|
|
313
|
+
),
|
|
314
|
+
footer
|
|
315
|
+
] })
|
|
316
|
+
}
|
|
317
|
+
) });
|
|
318
|
+
}
|
|
319
|
+
var ITEM_BASE = "group relative flex w-full cursor-pointer select-none items-center rounded-md font-medium text-primary outline-none transition-colors scroll-my-1 data-[highlighted]:bg-secondary data-[disabled]:opacity-50 data-[disabled]:pointer-events-none";
|
|
320
|
+
var ITEM_SIZE = {
|
|
321
|
+
sm: "min-h-9 gap-1.5 px-2 py-1.5 text-sm",
|
|
322
|
+
md: "min-h-9 gap-2 px-2.5 py-2 text-sm",
|
|
323
|
+
lg: "min-h-10 gap-2 px-3 py-2 text-md"
|
|
324
|
+
};
|
|
325
|
+
var ITEM_TEXT_GAP = { sm: "gap-x-1.5", md: "gap-x-2", lg: "gap-x-2" };
|
|
326
|
+
function Slot2({ node, size, className }) {
|
|
327
|
+
return /* @__PURE__ */ jsx(Slot, { className: cn("items-center text-tertiary", SLOT_ICON[size], className), children: node });
|
|
328
|
+
}
|
|
329
|
+
var CB_BOX = { sm: "size-4 rounded-sm", md: "size-4 rounded-sm", lg: "size-5 rounded-md" };
|
|
330
|
+
var CB_ICON = { sm: "size-3", md: "size-3", lg: "size-3.5" };
|
|
331
|
+
function ComboboxItemCheckbox({ size, className }) {
|
|
332
|
+
return /* @__PURE__ */ jsx(
|
|
333
|
+
"span",
|
|
334
|
+
{
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
className: cn(
|
|
337
|
+
"relative inline-flex shrink-0 items-center justify-center bg-primary ring-1 ring-primary transition-colors duration-100 ease-linear ring-inset",
|
|
338
|
+
CB_BOX[size],
|
|
339
|
+
"group-data-[selected]:bg-brand-solid group-data-[selected]:ring-brand-solid",
|
|
340
|
+
className
|
|
341
|
+
),
|
|
342
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: cn("text-fg-white opacity-0 transition-opacity group-data-[selected]:opacity-100", CB_ICON[size]) })
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
function ComboboxItem({ value, leading, supporting, trailing, disabled = false, hideIndicator = false, children, className }) {
|
|
347
|
+
const { size, indicator, indicatorAlign, optionMap } = useComboboxContext();
|
|
348
|
+
const opt = optionMap.get(value);
|
|
349
|
+
const rLeading = leading ?? opt?.leading;
|
|
350
|
+
const rSupporting = supporting ?? opt?.supporting;
|
|
351
|
+
const rTrailing = trailing ?? opt?.trailing;
|
|
352
|
+
const isCheckbox = indicator === "checkbox" && !hideIndicator;
|
|
353
|
+
const checkboxLeft = isCheckbox && indicatorAlign === "left";
|
|
354
|
+
const checkboxRight = isCheckbox && indicatorAlign === "right";
|
|
355
|
+
return /* @__PURE__ */ jsxs(
|
|
356
|
+
Combobox$1.Item,
|
|
357
|
+
{
|
|
358
|
+
value,
|
|
359
|
+
disabled,
|
|
360
|
+
className: cn(
|
|
361
|
+
ITEM_BASE,
|
|
362
|
+
// Selected-row tint only in checkmark mode (UUI gates the fill on the indicator);
|
|
363
|
+
// checkbox mode leaves the row un-tinted, the box carries the selected state.
|
|
364
|
+
!isCheckbox && "data-[selected]:bg-secondary",
|
|
365
|
+
ITEM_SIZE[size],
|
|
366
|
+
className
|
|
367
|
+
),
|
|
368
|
+
children: [
|
|
369
|
+
checkboxLeft ? /* @__PURE__ */ jsx(ComboboxItemCheckbox, { size }) : null,
|
|
370
|
+
rLeading ? /* @__PURE__ */ jsx(Slot2, { node: rLeading, size }) : null,
|
|
371
|
+
/* @__PURE__ */ jsxs("span", { className: cn("flex min-w-0 flex-1 flex-wrap items-baseline", ITEM_TEXT_GAP[size]), children: [
|
|
372
|
+
/* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: children ?? opt?.label }),
|
|
373
|
+
rSupporting ? /* @__PURE__ */ jsx("span", { className: "truncate font-normal whitespace-nowrap text-tertiary", children: rSupporting }) : null
|
|
374
|
+
] }),
|
|
375
|
+
rTrailing ? /* @__PURE__ */ jsx(Slot2, { node: rTrailing, size, className: "ml-auto" }) : null,
|
|
376
|
+
checkboxRight ? /* @__PURE__ */ jsx(ComboboxItemCheckbox, { size, className: !rTrailing ? "ml-auto" : void 0 }) : null,
|
|
377
|
+
!isCheckbox && !hideIndicator ? /* @__PURE__ */ jsx(Combobox$1.ItemIndicator, { className: cn("inline-flex shrink-0 text-brand-secondary", !rTrailing && "ml-auto", CONTROL_ICON[size]), children: /* @__PURE__ */ jsx(CheckIcon, {}) }) : null
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function ComboboxGroup({ children, className }) {
|
|
383
|
+
return /* @__PURE__ */ jsx(Combobox$1.Group, { className: cn("py-1", className), children });
|
|
384
|
+
}
|
|
385
|
+
function ComboboxGroupLabel({ children, className }) {
|
|
386
|
+
return /* @__PURE__ */ jsx(Combobox$1.GroupLabel, { className: cn("px-2 py-1.5 text-sm font-medium text-tertiary", className), children });
|
|
387
|
+
}
|
|
388
|
+
function ComboboxEmpty({ children, className }) {
|
|
389
|
+
return /* @__PURE__ */ jsx(Combobox$1.Empty, { className: cn("px-3 py-6 text-center text-sm text-tertiary", className), children });
|
|
390
|
+
}
|
|
391
|
+
function ComboboxLoading({ children = "Loading\u2026", className }) {
|
|
392
|
+
return /* @__PURE__ */ jsxs(Combobox$1.Status, { className: cn("flex items-center justify-center gap-2 px-3 py-6 text-sm text-tertiary [&_svg]:size-4", className), children: [
|
|
393
|
+
/* @__PURE__ */ jsx(LoaderCircleIcon, { className: "animate-spin" }),
|
|
394
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
395
|
+
] });
|
|
396
|
+
}
|
|
397
|
+
function optionLabelText(option) {
|
|
398
|
+
return typeof option.label === "string" ? option.label : option.value;
|
|
399
|
+
}
|
|
400
|
+
function asString(v) {
|
|
401
|
+
return typeof v === "string" ? v : null;
|
|
402
|
+
}
|
|
403
|
+
function asStringList(v) {
|
|
404
|
+
if (Array.isArray(v)) return v.filter((entry) => typeof entry === "string");
|
|
405
|
+
return typeof v === "string" ? [v] : [];
|
|
406
|
+
}
|
|
407
|
+
function defaultCreateLabel(query) {
|
|
408
|
+
return `Create \u201C${query}\u201D`;
|
|
409
|
+
}
|
|
410
|
+
function defaultContains(option, query) {
|
|
411
|
+
return optionLabelText(option).toLowerCase().includes(query.trim().toLowerCase());
|
|
412
|
+
}
|
|
413
|
+
function flattenOptions(options) {
|
|
414
|
+
const flat = [];
|
|
415
|
+
for (const entry of options) {
|
|
416
|
+
if (isOptionGroup(entry)) flat.push(...entry.options);
|
|
417
|
+
else flat.push(entry);
|
|
418
|
+
}
|
|
419
|
+
return flat;
|
|
420
|
+
}
|
|
421
|
+
function filterOptions(options, query, predicate) {
|
|
422
|
+
const out = [];
|
|
423
|
+
for (const entry of options) {
|
|
424
|
+
if (isOptionGroup(entry)) {
|
|
425
|
+
const opts = entry.options.filter((o) => predicate(o, query));
|
|
426
|
+
if (opts.length > 0) out.push({ label: entry.label, options: opts });
|
|
427
|
+
} else if (predicate(entry, query)) {
|
|
428
|
+
out.push(entry);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
function ComboboxFlat(props) {
|
|
434
|
+
const {
|
|
435
|
+
options,
|
|
436
|
+
filter,
|
|
437
|
+
loading = false,
|
|
438
|
+
loadingMessage,
|
|
439
|
+
emptyMessage = "No results found.",
|
|
440
|
+
placeholder,
|
|
441
|
+
leading,
|
|
442
|
+
trailing,
|
|
443
|
+
leadingAddon,
|
|
444
|
+
trailingAddon,
|
|
445
|
+
scrollFade,
|
|
446
|
+
renderChip,
|
|
447
|
+
display,
|
|
448
|
+
supportingText,
|
|
449
|
+
maxRows,
|
|
450
|
+
actions,
|
|
451
|
+
meta,
|
|
452
|
+
creatable = false,
|
|
453
|
+
onCreate,
|
|
454
|
+
createLabel = defaultCreateLabel,
|
|
455
|
+
validateCreate,
|
|
456
|
+
multiple,
|
|
457
|
+
autoHighlight,
|
|
458
|
+
onInputChange,
|
|
459
|
+
searchDebounce = 0,
|
|
460
|
+
onValueChange,
|
|
461
|
+
...rootProps
|
|
462
|
+
} = props;
|
|
463
|
+
const size = props.size ?? "md";
|
|
464
|
+
const [query, setQuery] = React.useState("");
|
|
465
|
+
const [selectedSingle, setSelectedSingle] = React.useState(() => asString(props.value ?? props.defaultValue));
|
|
466
|
+
React.useEffect(() => {
|
|
467
|
+
if (multiple !== true && props.value !== void 0) setSelectedSingle(asString(props.value));
|
|
468
|
+
}, [props.value, multiple]);
|
|
469
|
+
const [selectedValues, setSelectedValues] = React.useState(() => asStringList(props.value ?? props.defaultValue));
|
|
470
|
+
React.useEffect(() => {
|
|
471
|
+
if (props.value !== void 0) setSelectedValues(asStringList(props.value));
|
|
472
|
+
}, [props.value]);
|
|
473
|
+
React.useEffect(() => {
|
|
474
|
+
warnNonNegativeInt("Combobox", "searchDebounce", searchDebounce);
|
|
475
|
+
}, [searchDebounce]);
|
|
476
|
+
const emitInputChange = useDebouncedCallback(onInputChange, searchDebounce);
|
|
477
|
+
const handleInputChange = (value, details) => {
|
|
478
|
+
setQuery(value);
|
|
479
|
+
if (value === "") emitInputChange.flush(value, details);
|
|
480
|
+
else emitInputChange.call(value, details);
|
|
481
|
+
};
|
|
482
|
+
const handleValueChange = ((v, details) => {
|
|
483
|
+
const next = asStringList(v);
|
|
484
|
+
if (creatable && onCreate) {
|
|
485
|
+
const known = new Set(flattenOptions(options).map((o) => o.value));
|
|
486
|
+
for (const value of next) {
|
|
487
|
+
if (!known.has(value) && !selectedValues.includes(value)) onCreate(value);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (multiple !== true) setSelectedSingle(asString(v));
|
|
491
|
+
setSelectedValues(next);
|
|
492
|
+
onValueChange?.(v, details);
|
|
493
|
+
});
|
|
494
|
+
const predicate = typeof filter === "function" ? filter : defaultContains;
|
|
495
|
+
const trimmed = query.trim().toLowerCase();
|
|
496
|
+
const selectedLabel = selectedSingle != null ? optionLabelText(flattenOptions(options).find((o) => o.value === selectedSingle) ?? { value: selectedSingle }).toLowerCase() : "";
|
|
497
|
+
const isReselect = multiple !== true && selectedLabel !== "" && trimmed === selectedLabel;
|
|
498
|
+
const showAll = trimmed === "" || isReselect;
|
|
499
|
+
const rows = filter === null || showAll ? options : filterOptions(options, query, predicate);
|
|
500
|
+
const createQuery = query.trim();
|
|
501
|
+
const knownAlready = createQuery === "" || flattenOptions(options).some((o) => o.value.toLowerCase() === trimmed || optionLabelText(o).toLowerCase() === trimmed) || selectedValues.some((v) => v.toLowerCase() === trimmed);
|
|
502
|
+
const showCreate = creatable && !loading && !knownAlready && (validateCreate?.(createQuery) ?? true);
|
|
503
|
+
const isEmpty = !loading && !showCreate && flattenOptions(rows).length === 0;
|
|
504
|
+
return /* @__PURE__ */ jsxs(
|
|
505
|
+
ComboboxRoot,
|
|
506
|
+
{
|
|
507
|
+
options,
|
|
508
|
+
multiple,
|
|
509
|
+
filter: null,
|
|
510
|
+
autoHighlight: autoHighlight ?? (creatable ? true : void 0),
|
|
511
|
+
onValueChange: handleValueChange,
|
|
512
|
+
onInputChange: handleInputChange,
|
|
513
|
+
...rootProps,
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ jsxs(
|
|
516
|
+
ComboboxInput,
|
|
517
|
+
{
|
|
518
|
+
placeholder,
|
|
519
|
+
leading,
|
|
520
|
+
trailing,
|
|
521
|
+
leadingAddon,
|
|
522
|
+
trailingAddon,
|
|
523
|
+
scrollFade,
|
|
524
|
+
renderChip,
|
|
525
|
+
display,
|
|
526
|
+
supportingText,
|
|
527
|
+
maxRows,
|
|
528
|
+
selectedCount: selectedValues.length,
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ jsx(ComboboxClear, {}),
|
|
531
|
+
/* @__PURE__ */ jsx(ComboboxTrigger, {})
|
|
532
|
+
]
|
|
533
|
+
}
|
|
534
|
+
),
|
|
535
|
+
/* @__PURE__ */ jsxs(ComboboxContent, { footer: /* @__PURE__ */ jsx(ListboxFooter, { meta, actions, size }), children: [
|
|
536
|
+
loading ? /* @__PURE__ */ jsx(ComboboxLoading, { children: loadingMessage }) : null,
|
|
537
|
+
isEmpty ? /* @__PURE__ */ jsx(ComboboxEmpty, { children: emptyMessage }) : null,
|
|
538
|
+
loading ? null : mapOptions(rows, {
|
|
539
|
+
item: (opt) => /* @__PURE__ */ jsx(ComboboxItem, { value: opt.value, disabled: opt.disabled, children: opt.label ?? opt.value }, opt.value),
|
|
540
|
+
group: (label, groupChildren) => /* @__PURE__ */ jsxs(ComboboxGroup, { children: [
|
|
541
|
+
/* @__PURE__ */ jsx(ComboboxGroupLabel, { children: label }),
|
|
542
|
+
groupChildren
|
|
543
|
+
] }, label)
|
|
544
|
+
}),
|
|
545
|
+
showCreate ? /* @__PURE__ */ jsx(ComboboxItem, { value: createQuery, leading: /* @__PURE__ */ jsx(PlusIcon, {}), hideIndicator: true, children: createLabel(createQuery) }) : null
|
|
546
|
+
] })
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
ComboboxFlat.displayName = "Combobox";
|
|
552
|
+
ComboboxRoot.displayName = "ComboboxRoot";
|
|
553
|
+
ComboboxInput.displayName = "ComboboxInput";
|
|
554
|
+
ComboboxTrigger.displayName = "ComboboxTrigger";
|
|
555
|
+
ComboboxClear.displayName = "ComboboxClear";
|
|
556
|
+
ComboboxContent.displayName = "ComboboxContent";
|
|
557
|
+
ComboboxItem.displayName = "ComboboxItem";
|
|
558
|
+
ComboboxGroup.displayName = "ComboboxGroup";
|
|
559
|
+
ComboboxGroupLabel.displayName = "ComboboxGroupLabel";
|
|
560
|
+
ComboboxEmpty.displayName = "ComboboxEmpty";
|
|
561
|
+
ComboboxLoading.displayName = "ComboboxLoading";
|
|
562
|
+
var Combobox = ComboboxFlat;
|
|
563
|
+
|
|
564
|
+
export { Combobox };
|
|
565
|
+
//# sourceMappingURL=chunk-MUFHLP4S.js.map
|
|
566
|
+
//# sourceMappingURL=chunk-MUFHLP4S.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect } from './chunk-EDSK6FEH.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
var DEFAULT_FADE = 16;
|
|
5
|
+
function fadeMask(axis, atStart, atEnd, size, padStart = 0, padEnd = 0) {
|
|
6
|
+
const dir = axis === "vertical" ? "to bottom" : "to right";
|
|
7
|
+
const start = atStart ? "#000 0" : padStart > 0 ? `transparent ${padStart}px, #000 ${padStart + size}px` : `transparent 0, #000 ${size}px`;
|
|
8
|
+
const end = atEnd ? "#000 100%" : padEnd > 0 ? `#000 calc(100% - ${padEnd + size}px), transparent calc(100% - ${padEnd}px)` : `#000 calc(100% - ${size}px), transparent 100%`;
|
|
9
|
+
return `linear-gradient(${dir}, ${start}, ${end})`;
|
|
10
|
+
}
|
|
11
|
+
var cssPx = (value) => Number.parseFloat(value) || 0;
|
|
12
|
+
function inkPadding(el, vertical) {
|
|
13
|
+
if (!(el instanceof HTMLInputElement)) return { padStart: 0, padEnd: 0 };
|
|
14
|
+
const cs = getComputedStyle(el);
|
|
15
|
+
return {
|
|
16
|
+
padStart: cssPx(vertical ? cs.paddingTop : cs.paddingLeft),
|
|
17
|
+
padEnd: cssPx(vertical ? cs.paddingBottom : cs.paddingRight)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function useScrollFade(ref, options) {
|
|
21
|
+
const axis = options?.axis ?? "vertical";
|
|
22
|
+
const enabled = options?.enabled ?? true;
|
|
23
|
+
const size = options?.size ?? DEFAULT_FADE;
|
|
24
|
+
const [st, setSt] = React.useState({ scrollable: false, atStart: true, atEnd: true, padStart: 0, padEnd: 0 });
|
|
25
|
+
useIsomorphicLayoutEffect(() => {
|
|
26
|
+
const el = ref.current;
|
|
27
|
+
if (el == null || !enabled) {
|
|
28
|
+
setSt((p) => !p.scrollable && p.atStart && p.atEnd ? p : { ...p, scrollable: false, atStart: true, atEnd: true });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const measure = () => {
|
|
32
|
+
const vertical = axis === "vertical";
|
|
33
|
+
const scrollLen = vertical ? el.scrollHeight : el.scrollWidth;
|
|
34
|
+
const clientLen = vertical ? el.clientHeight : el.clientWidth;
|
|
35
|
+
const pos = vertical ? el.scrollTop : el.scrollLeft;
|
|
36
|
+
const scrollable = scrollLen > clientLen + 1;
|
|
37
|
+
const atStart = pos <= 1;
|
|
38
|
+
const atEnd = pos + clientLen >= scrollLen - 1;
|
|
39
|
+
const { padStart, padEnd } = scrollable ? inkPadding(el, vertical) : { padStart: 0, padEnd: 0 };
|
|
40
|
+
setSt(
|
|
41
|
+
(p) => p.scrollable === scrollable && p.atStart === atStart && p.atEnd === atEnd && p.padStart === padStart && p.padEnd === padEnd ? p : { scrollable, atStart, atEnd, padStart, padEnd }
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
measure();
|
|
45
|
+
let raf1 = 0;
|
|
46
|
+
let raf2 = 0;
|
|
47
|
+
raf1 = requestAnimationFrame(() => {
|
|
48
|
+
raf2 = requestAnimationFrame(measure);
|
|
49
|
+
});
|
|
50
|
+
const ro = new ResizeObserver(measure);
|
|
51
|
+
ro.observe(el);
|
|
52
|
+
const mo = new MutationObserver(measure);
|
|
53
|
+
mo.observe(el, { childList: true, subtree: true });
|
|
54
|
+
el.addEventListener("scroll", measure, { passive: true });
|
|
55
|
+
el.addEventListener("input", measure);
|
|
56
|
+
void document.fonts?.ready.then(measure);
|
|
57
|
+
return () => {
|
|
58
|
+
cancelAnimationFrame(raf1);
|
|
59
|
+
cancelAnimationFrame(raf2);
|
|
60
|
+
ro.disconnect();
|
|
61
|
+
mo.disconnect();
|
|
62
|
+
el.removeEventListener("scroll", measure);
|
|
63
|
+
el.removeEventListener("input", measure);
|
|
64
|
+
};
|
|
65
|
+
}, [ref, axis, enabled]);
|
|
66
|
+
return {
|
|
67
|
+
scrollable: st.scrollable,
|
|
68
|
+
maskImage: enabled && st.scrollable ? fadeMask(axis, st.atStart, st.atEnd, size, st.padStart, st.padEnd) : void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { useScrollFade };
|
|
73
|
+
//# sourceMappingURL=chunk-O2LG3PNI.js.map
|
|
74
|
+
//# sourceMappingURL=chunk-O2LG3PNI.js.map
|