@frontify/fondue-components 29.0.1 → 29.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/dist/fondue-components111.js +3 -15
- package/dist/fondue-components111.js.map +1 -1
- package/dist/fondue-components112.js +5 -127
- package/dist/fondue-components112.js.map +1 -1
- package/dist/fondue-components113.js +14 -11
- package/dist/fondue-components113.js.map +1 -1
- package/dist/fondue-components114.js +17 -36
- package/dist/fondue-components114.js.map +1 -1
- package/dist/fondue-components115.js +111 -14
- package/dist/fondue-components115.js.map +1 -1
- package/dist/fondue-components116.js +12 -14
- package/dist/fondue-components116.js.map +1 -1
- package/dist/fondue-components117.js +16 -110
- package/dist/fondue-components117.js.map +1 -1
- package/dist/fondue-components118.js +10 -10
- package/dist/fondue-components118.js.map +1 -1
- package/dist/fondue-components119.js +17 -17
- package/dist/fondue-components119.js.map +1 -1
- package/dist/fondue-components120.js +126 -12
- package/dist/fondue-components120.js.map +1 -1
- package/dist/fondue-components121.js +11 -217
- package/dist/fondue-components121.js.map +1 -1
- package/dist/fondue-components122.js +34 -17
- package/dist/fondue-components122.js.map +1 -1
- package/dist/fondue-components123.js +214 -14
- package/dist/fondue-components123.js.map +1 -1
- package/dist/fondue-components124.js +17 -149
- package/dist/fondue-components124.js.map +1 -1
- package/dist/fondue-components125.js +16 -44
- package/dist/fondue-components125.js.map +1 -1
- package/dist/fondue-components126.js +150 -4
- package/dist/fondue-components126.js.map +1 -1
- package/dist/fondue-components127.js +44 -4
- package/dist/fondue-components127.js.map +1 -1
- package/dist/fondue-components128.js +31 -18
- package/dist/fondue-components128.js.map +1 -1
- package/dist/fondue-components131.js +170 -6
- package/dist/fondue-components131.js.map +1 -1
- package/dist/fondue-components132.js +60 -12
- package/dist/fondue-components132.js.map +1 -1
- package/dist/fondue-components133.js +9 -71
- package/dist/fondue-components133.js.map +1 -1
- package/dist/fondue-components134.js +255 -14
- package/dist/fondue-components134.js.map +1 -1
- package/dist/fondue-components135.js +6 -7
- package/dist/fondue-components135.js.map +1 -1
- package/dist/fondue-components136.js +11 -88
- package/dist/fondue-components136.js.map +1 -1
- package/dist/fondue-components137.js +69 -79
- package/dist/fondue-components137.js.map +1 -1
- package/dist/fondue-components138.js +14 -30
- package/dist/fondue-components138.js.map +1 -1
- package/dist/fondue-components139.js +7 -170
- package/dist/fondue-components139.js.map +1 -1
- package/dist/fondue-components140.js +86 -57
- package/dist/fondue-components140.js.map +1 -1
- package/dist/fondue-components141.js +81 -9
- package/dist/fondue-components141.js.map +1 -1
- package/dist/fondue-components142.js +29 -254
- package/dist/fondue-components142.js.map +1 -1
- package/dist/fondue-components145.js +2 -2
- package/dist/fondue-components147.js +2 -2
- package/dist/fondue-components148.js +1 -1
- package/dist/fondue-components43.js +2 -2
- package/dist/fondue-components50.js +1 -1
- package/dist/fondue-components60.js +10 -10
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +3 -3
- package/dist/fondue-components62.js +2 -2
- package/dist/fondue-components74.js +2 -2
- package/dist/fondue-components77.js +1 -1
- package/dist/fondue-components78.js +1 -1
- package/dist/fondue-components79.js +1 -1
- package/dist/fondue-components82.js +1 -1
- package/dist/fondue-components84.js +2 -2
- package/dist/fondue-components90.js +2 -2
- package/dist/fondue-components91.js +2 -2
- package/dist/fondue-components92.js +2 -2
- package/dist/fondue-components93.js +2 -2
- package/dist/fondue-components94.js +1 -1
- package/dist/fondue-components95.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1,220 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { useFocusRing as Ie } from "./fondue-components132.js";
|
|
10
|
-
import { useSelectData as ve } from "./fondue-components133.js";
|
|
11
|
-
import { useSelectionDescription as Be } from "./fondue-components134.js";
|
|
12
|
-
import c from "./fondue-components125.js";
|
|
13
|
-
import { ClearButton as xe } from "./fondue-components135.js";
|
|
14
|
-
import { CollapsibleBadges as Se } from "./fondue-components136.js";
|
|
15
|
-
import { SelectMenu as we } from "./fondue-components137.js";
|
|
16
|
-
import { ForwardedRefSelectSlot as De } from "./fondue-components95.js";
|
|
17
|
-
import { StatusIcons as Re } from "./fondue-components138.js";
|
|
18
|
-
const z = ({
|
|
19
|
-
children: E,
|
|
20
|
-
selectedItemValues: i,
|
|
21
|
-
onItemSelect: m,
|
|
22
|
-
onClear: $,
|
|
23
|
-
placeholder: x = "",
|
|
24
|
-
status: p = "neutral",
|
|
25
|
-
disabled: b,
|
|
26
|
-
"data-test-id": d = "fondue-select-combobox",
|
|
27
|
-
alignMenu: _ = "start",
|
|
28
|
-
side: q = "bottom",
|
|
29
|
-
id: G,
|
|
30
|
-
viewportCollisionPadding: J = "compact",
|
|
31
|
-
getAsyncItems: C,
|
|
32
|
-
onEscapeKeyDown: Q,
|
|
33
|
-
multiple: o,
|
|
34
|
-
...a
|
|
35
|
-
}, U) => {
|
|
36
|
-
const h = he(null), W = fe((e) => {
|
|
37
|
-
h.current = e;
|
|
38
|
-
}, []), { t: X } = Ce(), { inputSlots: Y, menuSlots: Z, items: y, filterText: A, clearButton: S, getItemByValue: r, setFilterText: I, asyncItemStatus: w } = ve(E, C), { wasClickedRef: V, onMouseDown: D, onFocus: R, onBlur: ee } = Ie(), { selectionDescriptionId: L, selectionDescription: O } = Be(
|
|
39
|
-
o,
|
|
40
|
-
i,
|
|
41
|
-
r
|
|
42
|
-
), te = ye(i, r), [ae, k] = ge(!1), M = j(() => i.map((e) => r(e)).filter((e) => e !== void 0 && "value" in e && "label" in e), [i, r]), ne = K(
|
|
43
|
-
o ? {
|
|
44
|
-
selectedItems: M,
|
|
45
|
-
onStateChange({ selectedItems: e, type: l }) {
|
|
46
|
-
if (l === K.stateChangeTypes.SelectedItemKeyDownBackspace) {
|
|
47
|
-
const t = M.find((u) => !(e != null && e.includes(u)));
|
|
48
|
-
t && m(t.value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} : { selectedItems: [] }
|
|
52
|
-
), oe = o ? ne.removeSelectedItem : () => {
|
|
53
|
-
}, {
|
|
54
|
-
getInputProps: f,
|
|
55
|
-
getToggleButtonProps: ie,
|
|
56
|
-
getMenuProps: le,
|
|
57
|
-
getItemProps: re,
|
|
58
|
-
reset: N,
|
|
59
|
-
selectedItem: v,
|
|
60
|
-
isOpen: T,
|
|
61
|
-
highlightedIndex: se,
|
|
62
|
-
inputValue: B
|
|
63
|
-
} = s({
|
|
64
|
-
items: y,
|
|
65
|
-
selectedItem: o ? null : r(i[0]),
|
|
66
|
-
defaultHighlightedIndex: 0,
|
|
67
|
-
toggleButtonId: G,
|
|
68
|
-
// Only set labelId if aria-labelledby is explicitly provided, otherwise downshift generates an orphan ID
|
|
69
|
-
..."aria-labelledby" in a && a["aria-labelledby"] ? { labelId: a["aria-labelledby"] } : {},
|
|
70
|
-
onSelectedItemChange: ({ selectedItem: e }) => {
|
|
71
|
-
e && m(e.value), o && I("");
|
|
72
|
-
},
|
|
73
|
-
onInputValueChange: ({ inputValue: e }) => {
|
|
74
|
-
I(e);
|
|
75
|
-
},
|
|
76
|
-
onIsOpenChange: () => {
|
|
77
|
-
k(!1), I("");
|
|
78
|
-
},
|
|
79
|
-
onHighlightedIndexChange: () => {
|
|
80
|
-
k(!0);
|
|
81
|
-
},
|
|
82
|
-
itemToString: (e) => e ? e.label : "",
|
|
83
|
-
stateReducer: (e, l) => {
|
|
84
|
-
const { changes: t, type: u } = l;
|
|
85
|
-
if (o)
|
|
86
|
-
switch (u) {
|
|
87
|
-
case s.stateChangeTypes.InputKeyDownEnter:
|
|
88
|
-
case s.stateChangeTypes.ItemClick:
|
|
89
|
-
return {
|
|
90
|
-
...t,
|
|
91
|
-
isOpen: !0,
|
|
92
|
-
highlightedIndex: e.highlightedIndex,
|
|
93
|
-
inputValue: ""
|
|
94
|
-
};
|
|
95
|
-
case s.stateChangeTypes.InputBlur:
|
|
96
|
-
return {
|
|
97
|
-
...t,
|
|
98
|
-
inputValue: ""
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
else
|
|
102
|
-
switch (u) {
|
|
103
|
-
case s.stateChangeTypes.InputKeyDownEnter:
|
|
104
|
-
case s.stateChangeTypes.ItemClick:
|
|
105
|
-
t.selectedItem && e.selectedItem && t.selectedItem.value === e.selectedItem.value && m(t.selectedItem.value);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
return t;
|
|
109
|
-
}
|
|
110
|
-
}), F = j(() => o ? !1 : !C && !y.find((e) => e.label.toLowerCase().includes(B.toLowerCase())), [B, y, C, o]) || !!w.error || p === "error", ce = (e, l) => {
|
|
111
|
-
const t = r(e);
|
|
112
|
-
t && (oe(t), m(e), h.current && (h.current.focus(), l && (h.current.dataset.showFocusRing = "false")));
|
|
113
|
-
}, de = () => {
|
|
114
|
-
$(), N();
|
|
115
|
-
}, P = (e) => {
|
|
116
|
-
var l, t;
|
|
117
|
-
ee(e), o || ((v == null ? void 0 : v.label) ?? "").toLocaleLowerCase() !== B.toLocaleLowerCase() && N(), f().onBlur && ((t = (l = f()).onBlur) == null || t.call(l, e));
|
|
118
|
-
};
|
|
119
|
-
return /* @__PURE__ */ g(H.Root, { open: T, children: [
|
|
120
|
-
/* @__PURE__ */ n(H.Anchor, { asChild: !0, children: /* @__PURE__ */ g(
|
|
121
|
-
"div",
|
|
122
|
-
{
|
|
123
|
-
ref: U,
|
|
124
|
-
className: c.root,
|
|
125
|
-
"data-status": F ? "error" : p,
|
|
126
|
-
"data-disabled": b,
|
|
127
|
-
"data-empty": i.length === 0,
|
|
128
|
-
children: [
|
|
129
|
-
o ? /* @__PURE__ */ g(ue, { children: [
|
|
130
|
-
/* @__PURE__ */ n("span", { id: L, className: c.srOnly, children: O }),
|
|
131
|
-
/* @__PURE__ */ n(
|
|
132
|
-
Se,
|
|
133
|
-
{
|
|
134
|
-
items: te,
|
|
135
|
-
onDismiss: ce,
|
|
136
|
-
selectedCount: i.length,
|
|
137
|
-
children: /* @__PURE__ */ n(
|
|
138
|
-
"input",
|
|
139
|
-
{
|
|
140
|
-
...f({
|
|
141
|
-
ref: W,
|
|
142
|
-
"aria-label": "aria-label" in a ? a["aria-label"] : void 0,
|
|
143
|
-
// Remove auto-generated aria-labelledby if not explicitly provided
|
|
144
|
-
"aria-labelledby": "aria-labelledby" in a && a["aria-labelledby"] ? a["aria-labelledby"] : void 0,
|
|
145
|
-
"aria-describedby": O ? L : void 0
|
|
146
|
-
}),
|
|
147
|
-
"data-test-id": d,
|
|
148
|
-
placeholder: i.length === 0 ? x : "",
|
|
149
|
-
className: c.multiSelectInput,
|
|
150
|
-
disabled: b,
|
|
151
|
-
onMouseDown: D,
|
|
152
|
-
onFocus: R,
|
|
153
|
-
onBlur: P
|
|
154
|
-
}
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
] }) : /* @__PURE__ */ n(
|
|
159
|
-
"input",
|
|
160
|
-
{
|
|
161
|
-
...f({
|
|
162
|
-
"aria-label": "aria-label" in a ? a["aria-label"] : void 0,
|
|
163
|
-
// Remove auto-generated aria-labelledby if not explicitly provided
|
|
164
|
-
"aria-labelledby": "aria-labelledby" in a && a["aria-labelledby"] ? a["aria-labelledby"] : void 0
|
|
165
|
-
}),
|
|
166
|
-
"data-test-id": d,
|
|
167
|
-
placeholder: x,
|
|
168
|
-
className: c.input,
|
|
169
|
-
disabled: b,
|
|
170
|
-
onMouseDown: D,
|
|
171
|
-
onFocus: R,
|
|
172
|
-
onBlur: P
|
|
173
|
-
}
|
|
174
|
-
),
|
|
175
|
-
Y,
|
|
176
|
-
S ? /* @__PURE__ */ n(xe, { onClear: de, children: S }) : null,
|
|
177
|
-
w.isLoading && T ? /* @__PURE__ */ n(De, { name: "right", "data-test-id": `${d}-right-slot`, children: /* @__PURE__ */ n(pe, { size: "x-small", "data-test-id": `${d}-loading-circle` }) }) : null,
|
|
178
|
-
/* @__PURE__ */ g("div", { className: c.icons, children: [
|
|
179
|
-
/* @__PURE__ */ n(
|
|
180
|
-
"button",
|
|
181
|
-
{
|
|
182
|
-
"aria-label": X("Select_toggleMenu"),
|
|
183
|
-
...ie(),
|
|
184
|
-
type: "button",
|
|
185
|
-
disabled: b,
|
|
186
|
-
onMouseDown: () => {
|
|
187
|
-
V.current = !0;
|
|
188
|
-
},
|
|
189
|
-
children: /* @__PURE__ */ n(me, { size: 16, className: c.caret })
|
|
190
|
-
}
|
|
191
|
-
),
|
|
192
|
-
/* @__PURE__ */ n(Re, { status: p, hasError: F, dataTestId: d })
|
|
193
|
-
] })
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
) }),
|
|
197
|
-
/* @__PURE__ */ n(
|
|
198
|
-
we,
|
|
199
|
-
{
|
|
200
|
-
align: _,
|
|
201
|
-
side: q,
|
|
202
|
-
highlightedIndex: se,
|
|
203
|
-
filterText: A,
|
|
204
|
-
getMenuProps: le,
|
|
205
|
-
getItemProps: re,
|
|
206
|
-
selectedItemValues: i,
|
|
207
|
-
hasInteractedSinceOpening: ae,
|
|
208
|
-
viewportCollisionPadding: J,
|
|
209
|
-
onEscapeKeyDown: Q,
|
|
210
|
-
children: Z
|
|
211
|
-
}
|
|
212
|
-
)
|
|
213
|
-
] });
|
|
214
|
-
};
|
|
215
|
-
z.displayName = "Select.Combobox";
|
|
216
|
-
const Qe = be(z);
|
|
1
|
+
import { createContext as t, useContext as r } from "react";
|
|
2
|
+
const e = t({
|
|
3
|
+
itemId: "",
|
|
4
|
+
dragHandleRef: () => null,
|
|
5
|
+
hasHandle: !1
|
|
6
|
+
});
|
|
7
|
+
e.displayName = "OrderableItemContext";
|
|
8
|
+
const a = e.Provider, n = () => r(e);
|
|
217
9
|
export {
|
|
218
|
-
|
|
10
|
+
e as OrderableItemContext,
|
|
11
|
+
a as OrderableItemContextProvider,
|
|
12
|
+
n as useOrderableItemContext
|
|
219
13
|
};
|
|
220
14
|
//# sourceMappingURL=fondue-components121.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components121.js","sources":["../src/components/Select/components/ComboboxBase.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { useCombobox, useMultipleSelection } from 'downshift';\nimport {\n forwardRef,\n useCallback,\n useMemo,\n useRef,\n useState,\n type FocusEvent,\n type ForwardedRef,\n type ReactNode,\n} from 'react';\n\nimport { LoadingCircle } from '#/components/LoadingCircle/LoadingCircle.tsx';\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { useTranslation } from '#/hooks/useTranslation';\n\nimport { useBadgeItems } from '../hooks/useBadgeItems';\nimport { useFocusRing } from '../hooks/useFocusRing';\nimport { useSelectData, type AsyncItemsFetcher } from '../hooks/useSelectData';\nimport { useSelectionDescription } from '../hooks/useSelectionDescription';\nimport styles from '../styles/select.module.scss';\n\nimport { ClearButton } from './ClearButton';\nimport { CollapsibleBadges } from './CollapsibleBadges';\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } from './SelectMenu';\nimport { ForwardedRefSelectSlot } from './SelectSlot';\nimport { StatusIcons } from './StatusIcons';\n\ntype SelectItem = {\n value: string;\n label: string;\n children?: ReactNode;\n};\n\nexport type ComboboxSharedProps = {\n /**\n * Children of the Combobox component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu\n */\n children?: ReactNode;\n /**\n * The placeholder in the combobox component\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the combobox component\n */\n disabled?: boolean;\n /**\n * The alignment of the menu\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end';\n /**\n * Defines the preferred side of the combobox. It will not be respected if there are collisions with the viewport\n * @default \"bottom\"\n */\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * Id of the combobox component\n */\n id?: string;\n /**\n * The data test id of the combobox component\n */\n 'data-test-id'?: string;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n /**\n * Function to fetch items asynchronously\n */\n getAsyncItems?: AsyncItemsFetcher;\n /**\n * Event handler called when the escape key is pressed\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n} & CommonAriaProps;\n\ntype ComboboxBaseProps = ComboboxSharedProps & {\n /**\n * The currently selected item values\n */\n selectedItemValues: string[];\n /**\n * Callback fired when an item is selected or deselected\n */\n onItemSelect: (value?: string) => void;\n /**\n * Callback fired when the selection is cleared\n */\n onClear: () => void;\n /**\n * Whether the combobox allows multiple selections\n */\n multiple: boolean;\n};\n\nconst ComboboxBaseInput = (\n {\n children,\n selectedItemValues,\n onItemSelect,\n onClear,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n side = 'bottom',\n id,\n viewportCollisionPadding = 'compact',\n getAsyncItems,\n onEscapeKeyDown,\n multiple,\n ...props\n }: ComboboxBaseProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n): ReactNode => {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const inputCallbackRef = useCallback((node: HTMLInputElement | null): void => {\n inputRef.current = node;\n }, []);\n const { t } = useTranslation();\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText, asyncItemStatus } =\n useSelectData(children, getAsyncItems);\n const { wasClickedRef, onMouseDown, onFocus, onBlur } = useFocusRing();\n const { selectionDescriptionId, selectionDescription } = useSelectionDescription(\n multiple,\n selectedItemValues,\n getItemByValue,\n );\n const badgeItems = useBadgeItems(selectedItemValues, getItemByValue);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const selectedItems = useMemo((): SelectItem[] => {\n return selectedItemValues\n .map((value) => getItemByValue(value))\n .filter((item): item is SelectItem => item !== undefined && 'value' in item && 'label' in item);\n }, [selectedItemValues, getItemByValue]);\n\n const multipleSelectionResult = useMultipleSelection<SelectItem>(\n multiple\n ? {\n selectedItems,\n onStateChange({ selectedItems: newSelectedItems, type }) {\n if (type === useMultipleSelection.stateChangeTypes.SelectedItemKeyDownBackspace) {\n const removedItem = selectedItems.find((item) => !newSelectedItems?.includes(item));\n if (removedItem) {\n onItemSelect(removedItem.value);\n }\n }\n },\n }\n : { selectedItems: [] },\n );\n const removeSelectedItem = multiple ? multipleSelectionResult.removeSelectedItem : (): void => {};\n\n const {\n getInputProps,\n getToggleButtonProps,\n getMenuProps,\n getItemProps,\n reset,\n selectedItem,\n isOpen,\n highlightedIndex,\n inputValue,\n } = useCombobox<SelectItem>({\n items,\n selectedItem: multiple ? null : (getItemByValue(selectedItemValues[0]) as SelectItem | null | undefined),\n defaultHighlightedIndex: 0,\n toggleButtonId: id,\n // Only set labelId if aria-labelledby is explicitly provided, otherwise downshift generates an orphan ID\n ...('aria-labelledby' in props && props['aria-labelledby'] ? { labelId: props['aria-labelledby'] } : {}),\n onSelectedItemChange: ({ selectedItem }) => {\n if (selectedItem) {\n onItemSelect(selectedItem.value);\n }\n if (multiple) {\n setFilterText('');\n }\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n setFilterText('');\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n itemToString: (item) => (item ? item.label : ''),\n stateReducer: (state, actionAndChanges) => {\n const { changes, type } = actionAndChanges;\n if (multiple) {\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n return {\n ...changes,\n isOpen: true,\n highlightedIndex: state.highlightedIndex,\n inputValue: '',\n };\n case useCombobox.stateChangeTypes.InputBlur:\n // Select item on blur (Tab key) but clear the input\n return {\n ...changes,\n inputValue: '',\n };\n }\n } else {\n // For single select, handle re-selection of the same item\n // onSelectedItemChange doesn't fire when selecting the same item, so we call onItemSelect here\n switch (type) {\n case useCombobox.stateChangeTypes.InputKeyDownEnter:\n case useCombobox.stateChangeTypes.ItemClick:\n if (\n changes.selectedItem &&\n state.selectedItem &&\n changes.selectedItem.value === state.selectedItem.value\n ) {\n onItemSelect(changes.selectedItem.value);\n }\n break;\n }\n }\n return changes;\n },\n });\n\n const valueInvalid = useMemo(() => {\n if (multiple) {\n return false;\n }\n return !getAsyncItems && !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase()));\n }, [inputValue, items, getAsyncItems, multiple]);\n\n const hasError = valueInvalid || !!asyncItemStatus.error || status === 'error';\n\n const handleDismissBadge = (value: string, preventFocusRing: boolean): void => {\n const item = getItemByValue(value) as SelectItem | undefined;\n if (item) {\n removeSelectedItem(item);\n onItemSelect(value);\n if (inputRef.current) {\n inputRef.current.focus();\n if (preventFocusRing) {\n inputRef.current.dataset.showFocusRing = 'false';\n }\n }\n }\n };\n\n const handleClear = (): void => {\n onClear();\n reset();\n };\n\n const handleBlur = (blurEvent: FocusEvent<HTMLInputElement, Element>): void => {\n onBlur(blurEvent);\n\n if (!multiple) {\n const selectedItemLabel = selectedItem?.label ?? '';\n const isOutdated = selectedItemLabel.toLocaleLowerCase() !== inputValue.toLocaleLowerCase();\n\n if (isOutdated) {\n reset();\n }\n }\n\n if (getInputProps().onBlur) {\n getInputProps().onBlur?.(blurEvent);\n }\n };\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div\n ref={forwardedRef}\n className={styles.root}\n data-status={hasError ? 'error' : status}\n data-disabled={disabled}\n data-empty={selectedItemValues.length === 0}\n >\n {multiple ? (\n <>\n {/* Hidden description for screen readers - announced on focus */}\n <span id={selectionDescriptionId} className={styles.srOnly}>\n {selectionDescription}\n </span>\n <CollapsibleBadges\n items={badgeItems}\n onDismiss={handleDismissBadge}\n selectedCount={selectedItemValues.length}\n >\n <input\n // eslint-disable-next-line react-hooks/refs\n {...getInputProps({\n ref: inputCallbackRef,\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n // Remove auto-generated aria-labelledby if not explicitly provided\n 'aria-labelledby':\n 'aria-labelledby' in props && props['aria-labelledby']\n ? props['aria-labelledby']\n : undefined,\n 'aria-describedby': selectionDescription ? selectionDescriptionId : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={selectedItemValues.length === 0 ? placeholder : ''}\n className={styles.multiSelectInput}\n disabled={disabled}\n onMouseDown={onMouseDown}\n onFocus={onFocus}\n onBlur={handleBlur}\n />\n </CollapsibleBadges>\n </>\n ) : (\n <input\n {...getInputProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n // Remove auto-generated aria-labelledby if not explicitly provided\n 'aria-labelledby':\n 'aria-labelledby' in props && props['aria-labelledby']\n ? props['aria-labelledby']\n : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={onMouseDown}\n onFocus={onFocus}\n onBlur={handleBlur}\n />\n )}\n {inputSlots}\n {clearButton ? <ClearButton onClear={handleClear}>{clearButton}</ClearButton> : null}\n {asyncItemStatus.isLoading && isOpen ? (\n <ForwardedRefSelectSlot name=\"right\" data-test-id={`${dataTestId}-right-slot`}>\n <LoadingCircle size=\"x-small\" data-test-id={`${dataTestId}-loading-circle`} />\n </ForwardedRefSelectSlot>\n ) : null}\n <div className={styles.icons}>\n <button\n aria-label={t('Select_toggleMenu')}\n {...getToggleButtonProps()}\n type=\"button\"\n disabled={disabled}\n onMouseDown={() => {\n wasClickedRef.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n <StatusIcons status={status} hasError={hasError} dataTestId={dataTestId} />\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItemValues={selectedItemValues}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n onEscapeKeyDown={onEscapeKeyDown}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nComboboxBaseInput.displayName = 'Select.Combobox';\n\nexport const ComboboxBase = forwardRef<HTMLDivElement, ComboboxBaseProps>(ComboboxBaseInput);\n"],"names":["ComboboxBaseInput","children","selectedItemValues","onItemSelect","onClear","placeholder","status","disabled","dataTestId","alignMenu","side","id","viewportCollisionPadding","getAsyncItems","onEscapeKeyDown","multiple","props","forwardedRef","inputRef","useRef","inputCallbackRef","useCallback","node","t","useTranslation","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","asyncItemStatus","useSelectData","wasClickedRef","onMouseDown","onFocus","onBlur","useFocusRing","selectionDescriptionId","selectionDescription","useSelectionDescription","badgeItems","useBadgeItems","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","selectedItems","useMemo","value","item","multipleSelectionResult","useMultipleSelection","newSelectedItems","type","removedItem","removeSelectedItem","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","state","actionAndChanges","changes","hasError","handleDismissBadge","preventFocusRing","handleClear","handleBlur","blurEvent","_b","_a","jsxs","RadixPopover","jsx","styles","Fragment","CollapsibleBadges","ClearButton","ForwardedRefSelectSlot","LoadingCircle","IconCaretDown","StatusIcons","SelectMenu","ComboboxBase","forwardRef"],"mappings":";;;;;;;;;;;;;;;;;AA4GA,MAAMA,IAAoB,CACtB;AAAA,EACI,UAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,gBAAgBC,IAAa;AAAA,EAC7B,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;A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MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACA1B,EAAkB,cAAc;AAEzB,MAAM0F,KAAeC,GAA8C3F,CAAiB;"}
|
|
1
|
+
{"version":3,"file":"fondue-components121.js","sources":["../src/components/OrderableList/hooks/useOrderedListItemContext.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { createContext, useContext } from 'react';\n\ntype OrderableItemContextType = {\n itemId: string;\n dragHandleRef: (element: Element | null) => void;\n hasHandle: boolean;\n selected?: boolean;\n onSelect?: (isSelected: boolean) => void;\n};\n\nexport const OrderableItemContext = createContext<OrderableItemContextType>({\n itemId: '',\n dragHandleRef: () => null,\n hasHandle: false,\n});\nOrderableItemContext.displayName = 'OrderableItemContext';\n\nexport const OrderableItemContextProvider = OrderableItemContext.Provider;\n\nexport const useOrderableItemContext = (): OrderableItemContextType => useContext(OrderableItemContext);\n"],"names":["OrderableItemContext","createContext","OrderableItemContextProvider","useOrderableItemContext","useContext"],"mappings":";AAYO,MAAMA,IAAuBC,EAAwC;AAAA,EACxE,QAAQ;AAAA,EACR,eAAe,MAAM;AAAA,EACrB,WAAW;AACf,CAAC;AACDD,EAAqB,cAAc;AAE5B,MAAME,IAA+BF,EAAqB,UAEpDG,IAA0B,MAAgCC,EAAWJ,CAAoB;"}
|
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import { getItemTitle as p } from "./fondue-components80.js";
|
|
4
|
+
import { useOrderableListAnnounce as u } from "./fondue-components81.js";
|
|
5
|
+
import { useOrderableItemContext as b } from "./fondue-components121.js";
|
|
6
|
+
import l from "./fondue-components83.js";
|
|
7
|
+
const I = f(({ children: t }, o) => {
|
|
8
|
+
const { itemId: c, onSelect: n, selected: r, hasHandle: d } = b(), m = u();
|
|
9
|
+
if (!n)
|
|
10
|
+
return (
|
|
11
|
+
// eslint-disable-next-line jsx-a11y-x/no-noninteractive-tabindex
|
|
12
|
+
/* @__PURE__ */ s("div", { className: l.content, ref: o, tabIndex: d ? 0 : void 0, children: t })
|
|
13
|
+
);
|
|
14
|
+
const a = () => {
|
|
15
|
+
const e = !r;
|
|
16
|
+
n(e), m(`${p(c)} ${e ? "selected" : "unselected"}`);
|
|
17
|
+
}, i = (e) => {
|
|
18
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), a());
|
|
5
19
|
};
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
return /* @__PURE__ */ s(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: l.content,
|
|
24
|
+
ref: o,
|
|
25
|
+
role: "button",
|
|
26
|
+
tabIndex: 0,
|
|
27
|
+
"aria-pressed": !!r,
|
|
28
|
+
onClick: a,
|
|
29
|
+
onKeyDown: i,
|
|
30
|
+
"data-clickable": !0,
|
|
31
|
+
children: t
|
|
16
32
|
}
|
|
17
|
-
|
|
18
|
-
};
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
I.displayName = "OrderableListItemContent";
|
|
19
36
|
export {
|
|
20
|
-
I as
|
|
37
|
+
I as OrderableListItemContent
|
|
21
38
|
};
|
|
22
39
|
//# sourceMappingURL=fondue-components122.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components122.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components122.js","sources":["../src/components/OrderableList/OrderableListItemContent.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { forwardRef, type KeyboardEvent, type ReactNode } from 'react';\n\nimport { getItemTitle } from './helpers/getItemTitle';\nimport { useOrderableListAnnounce } from './hooks/useOrderableListAnnounce';\nimport { useOrderableItemContext } from './hooks/useOrderedListItemContext';\nimport styles from './styles/orderable-list.module.scss';\n\nexport const OrderableListItemContent = forwardRef<HTMLDivElement, { children: ReactNode }>(({ children }, ref) => {\n const { itemId, onSelect, selected, hasHandle } = useOrderableItemContext();\n const announce = useOrderableListAnnounce();\n\n if (!onSelect) {\n return (\n // eslint-disable-next-line jsx-a11y-x/no-noninteractive-tabindex\n <div className={styles.content} ref={ref} tabIndex={hasHandle ? 0 : undefined}>\n {children}\n </div>\n );\n }\n\n const handleSelect = () => {\n const newSelected = !selected;\n onSelect(newSelected);\n announce(`${getItemTitle(itemId)} ${newSelected ? 'selected' : 'unselected'}`);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleSelect();\n }\n };\n\n return (\n <div\n className={styles.content}\n ref={ref}\n role=\"button\"\n tabIndex={0}\n aria-pressed={Boolean(selected)}\n onClick={handleSelect}\n onKeyDown={handleKeyDown}\n data-clickable\n >\n {children}\n </div>\n );\n});\nOrderableListItemContent.displayName = 'OrderableListItemContent';\n"],"names":["OrderableListItemContent","forwardRef","children","ref","itemId","onSelect","selected","hasHandle","useOrderableItemContext","announce","useOrderableListAnnounce","jsx","styles","handleSelect","newSelected","getItemTitle","handleKeyDown","event"],"mappings":";;;;;;AASO,MAAMA,IAA2BC,EAAoD,CAAC,EAAE,UAAAC,EAAA,GAAYC,MAAQ;AAC/G,QAAM,EAAE,QAAAC,GAAQ,UAAAC,GAAU,UAAAC,GAAU,WAAAC,EAAA,IAAcC,EAAA,GAC5CC,IAAWC,EAAA;AAEjB,MAAI,CAACL;AACD;AAAA;AAAA,MAEI,gBAAAM,EAAC,OAAA,EAAI,WAAWC,EAAO,SAAS,KAAAT,GAAU,UAAUI,IAAY,IAAI,QAC/D,UAAAL,EAAA,CACL;AAAA;AAIR,QAAMW,IAAe,MAAM;AACvB,UAAMC,IAAc,CAACR;AACrB,IAAAD,EAASS,CAAW,GACpBL,EAAS,GAAGM,EAAaX,CAAM,CAAC,IAAIU,IAAc,aAAa,YAAY,EAAE;AAAA,EACjF,GAEME,IAAgB,CAACC,MAAyB;AAC5C,KAAIA,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SACvCA,EAAM,eAAA,GACNJ,EAAA;AAAA,EAER;AAEA,SACI,gBAAAF;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAWC,EAAO;AAAA,MAClB,KAAAT;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,gBAAc,EAAQG;AAAA,MACtB,SAASO;AAAA,MACT,WAAWG;AAAA,MACX,kBAAc;AAAA,MAEb,UAAAd;AAAA,IAAA;AAAA,EAAA;AAGb,CAAC;AACDF,EAAyB,cAAc;"}
|
|
@@ -1,20 +1,220 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsxs as g, jsx as n, Fragment as ue } from "react/jsx-runtime";
|
|
2
|
+
import { IconCaretDown as me } from "@frontify/fondue-icons";
|
|
3
|
+
import * as H from "@radix-ui/react-popover";
|
|
4
|
+
import { useMultipleSelection as K, useCombobox as s } from "downshift";
|
|
5
|
+
import { forwardRef as be, useRef as he, useCallback as fe, useState as ge, useMemo as j } from "react";
|
|
6
|
+
import { LoadingCircle as pe } from "./fondue-components21.js";
|
|
7
|
+
import { useTranslation as Ce } from "./fondue-components42.js";
|
|
8
|
+
import { useBadgeItems as ye } from "./fondue-components135.js";
|
|
9
|
+
import { useFocusRing as Ie } from "./fondue-components136.js";
|
|
10
|
+
import { useSelectData as ve } from "./fondue-components137.js";
|
|
11
|
+
import { useSelectionDescription as Be } from "./fondue-components138.js";
|
|
12
|
+
import c from "./fondue-components127.js";
|
|
13
|
+
import { ClearButton as xe } from "./fondue-components139.js";
|
|
14
|
+
import { CollapsibleBadges as Se } from "./fondue-components140.js";
|
|
15
|
+
import { SelectMenu as we } from "./fondue-components141.js";
|
|
16
|
+
import { ForwardedRefSelectSlot as De } from "./fondue-components95.js";
|
|
17
|
+
import { StatusIcons as Re } from "./fondue-components142.js";
|
|
18
|
+
const z = ({
|
|
19
|
+
children: E,
|
|
20
|
+
selectedItemValues: i,
|
|
21
|
+
onItemSelect: m,
|
|
22
|
+
onClear: $,
|
|
23
|
+
placeholder: x = "",
|
|
24
|
+
status: p = "neutral",
|
|
25
|
+
disabled: b,
|
|
26
|
+
"data-test-id": d = "fondue-select-combobox",
|
|
27
|
+
alignMenu: _ = "start",
|
|
28
|
+
side: q = "bottom",
|
|
29
|
+
id: G,
|
|
30
|
+
viewportCollisionPadding: J = "compact",
|
|
31
|
+
getAsyncItems: C,
|
|
32
|
+
onEscapeKeyDown: Q,
|
|
33
|
+
multiple: o,
|
|
34
|
+
...a
|
|
35
|
+
}, U) => {
|
|
36
|
+
const h = he(null), W = fe((e) => {
|
|
37
|
+
h.current = e;
|
|
38
|
+
}, []), { t: X } = Ce(), { inputSlots: Y, menuSlots: Z, items: y, filterText: A, clearButton: S, getItemByValue: r, setFilterText: I, asyncItemStatus: w } = ve(E, C), { wasClickedRef: V, onMouseDown: D, onFocus: R, onBlur: ee } = Ie(), { selectionDescriptionId: L, selectionDescription: O } = Be(
|
|
39
|
+
o,
|
|
40
|
+
i,
|
|
41
|
+
r
|
|
42
|
+
), te = ye(i, r), [ae, k] = ge(!1), M = j(() => i.map((e) => r(e)).filter((e) => e !== void 0 && "value" in e && "label" in e), [i, r]), ne = K(
|
|
43
|
+
o ? {
|
|
44
|
+
selectedItems: M,
|
|
45
|
+
onStateChange({ selectedItems: e, type: l }) {
|
|
46
|
+
if (l === K.stateChangeTypes.SelectedItemKeyDownBackspace) {
|
|
47
|
+
const t = M.find((u) => !(e != null && e.includes(u)));
|
|
48
|
+
t && m(t.value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} : { selectedItems: [] }
|
|
52
|
+
), oe = o ? ne.removeSelectedItem : () => {
|
|
53
|
+
}, {
|
|
54
|
+
getInputProps: f,
|
|
55
|
+
getToggleButtonProps: ie,
|
|
56
|
+
getMenuProps: le,
|
|
57
|
+
getItemProps: re,
|
|
58
|
+
reset: N,
|
|
59
|
+
selectedItem: v,
|
|
60
|
+
isOpen: T,
|
|
61
|
+
highlightedIndex: se,
|
|
62
|
+
inputValue: B
|
|
63
|
+
} = s({
|
|
64
|
+
items: y,
|
|
65
|
+
selectedItem: o ? null : r(i[0]),
|
|
66
|
+
defaultHighlightedIndex: 0,
|
|
67
|
+
toggleButtonId: G,
|
|
68
|
+
// Only set labelId if aria-labelledby is explicitly provided, otherwise downshift generates an orphan ID
|
|
69
|
+
..."aria-labelledby" in a && a["aria-labelledby"] ? { labelId: a["aria-labelledby"] } : {},
|
|
70
|
+
onSelectedItemChange: ({ selectedItem: e }) => {
|
|
71
|
+
e && m(e.value), o && I("");
|
|
6
72
|
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
73
|
+
onInputValueChange: ({ inputValue: e }) => {
|
|
74
|
+
I(e);
|
|
75
|
+
},
|
|
76
|
+
onIsOpenChange: () => {
|
|
77
|
+
k(!1), I("");
|
|
78
|
+
},
|
|
79
|
+
onHighlightedIndexChange: () => {
|
|
80
|
+
k(!0);
|
|
81
|
+
},
|
|
82
|
+
itemToString: (e) => e ? e.label : "",
|
|
83
|
+
stateReducer: (e, l) => {
|
|
84
|
+
const { changes: t, type: u } = l;
|
|
85
|
+
if (o)
|
|
86
|
+
switch (u) {
|
|
87
|
+
case s.stateChangeTypes.InputKeyDownEnter:
|
|
88
|
+
case s.stateChangeTypes.ItemClick:
|
|
89
|
+
return {
|
|
90
|
+
...t,
|
|
91
|
+
isOpen: !0,
|
|
92
|
+
highlightedIndex: e.highlightedIndex,
|
|
93
|
+
inputValue: ""
|
|
94
|
+
};
|
|
95
|
+
case s.stateChangeTypes.InputBlur:
|
|
96
|
+
return {
|
|
97
|
+
...t,
|
|
98
|
+
inputValue: ""
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
switch (u) {
|
|
103
|
+
case s.stateChangeTypes.InputKeyDownEnter:
|
|
104
|
+
case s.stateChangeTypes.ItemClick:
|
|
105
|
+
t.selectedItem && e.selectedItem && t.selectedItem.value === e.selectedItem.value && m(t.selectedItem.value);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
}), F = j(() => o ? !1 : !C && !y.find((e) => e.label.toLowerCase().includes(B.toLowerCase())), [B, y, C, o]) || !!w.error || p === "error", ce = (e, l) => {
|
|
111
|
+
const t = r(e);
|
|
112
|
+
t && (oe(t), m(e), h.current && (h.current.focus(), l && (h.current.dataset.showFocusRing = "false")));
|
|
113
|
+
}, de = () => {
|
|
114
|
+
$(), N();
|
|
115
|
+
}, P = (e) => {
|
|
116
|
+
var l, t;
|
|
117
|
+
ee(e), o || ((v == null ? void 0 : v.label) ?? "").toLocaleLowerCase() !== B.toLocaleLowerCase() && N(), f().onBlur && ((t = (l = f()).onBlur) == null || t.call(l, e));
|
|
15
118
|
};
|
|
119
|
+
return /* @__PURE__ */ g(H.Root, { open: T, children: [
|
|
120
|
+
/* @__PURE__ */ n(H.Anchor, { asChild: !0, children: /* @__PURE__ */ g(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
ref: U,
|
|
124
|
+
className: c.root,
|
|
125
|
+
"data-status": F ? "error" : p,
|
|
126
|
+
"data-disabled": b,
|
|
127
|
+
"data-empty": i.length === 0,
|
|
128
|
+
children: [
|
|
129
|
+
o ? /* @__PURE__ */ g(ue, { children: [
|
|
130
|
+
/* @__PURE__ */ n("span", { id: L, className: c.srOnly, children: O }),
|
|
131
|
+
/* @__PURE__ */ n(
|
|
132
|
+
Se,
|
|
133
|
+
{
|
|
134
|
+
items: te,
|
|
135
|
+
onDismiss: ce,
|
|
136
|
+
selectedCount: i.length,
|
|
137
|
+
children: /* @__PURE__ */ n(
|
|
138
|
+
"input",
|
|
139
|
+
{
|
|
140
|
+
...f({
|
|
141
|
+
ref: W,
|
|
142
|
+
"aria-label": "aria-label" in a ? a["aria-label"] : void 0,
|
|
143
|
+
// Remove auto-generated aria-labelledby if not explicitly provided
|
|
144
|
+
"aria-labelledby": "aria-labelledby" in a && a["aria-labelledby"] ? a["aria-labelledby"] : void 0,
|
|
145
|
+
"aria-describedby": O ? L : void 0
|
|
146
|
+
}),
|
|
147
|
+
"data-test-id": d,
|
|
148
|
+
placeholder: i.length === 0 ? x : "",
|
|
149
|
+
className: c.multiSelectInput,
|
|
150
|
+
disabled: b,
|
|
151
|
+
onMouseDown: D,
|
|
152
|
+
onFocus: R,
|
|
153
|
+
onBlur: P
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }) : /* @__PURE__ */ n(
|
|
159
|
+
"input",
|
|
160
|
+
{
|
|
161
|
+
...f({
|
|
162
|
+
"aria-label": "aria-label" in a ? a["aria-label"] : void 0,
|
|
163
|
+
// Remove auto-generated aria-labelledby if not explicitly provided
|
|
164
|
+
"aria-labelledby": "aria-labelledby" in a && a["aria-labelledby"] ? a["aria-labelledby"] : void 0
|
|
165
|
+
}),
|
|
166
|
+
"data-test-id": d,
|
|
167
|
+
placeholder: x,
|
|
168
|
+
className: c.input,
|
|
169
|
+
disabled: b,
|
|
170
|
+
onMouseDown: D,
|
|
171
|
+
onFocus: R,
|
|
172
|
+
onBlur: P
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
Y,
|
|
176
|
+
S ? /* @__PURE__ */ n(xe, { onClear: de, children: S }) : null,
|
|
177
|
+
w.isLoading && T ? /* @__PURE__ */ n(De, { name: "right", "data-test-id": `${d}-right-slot`, children: /* @__PURE__ */ n(pe, { size: "x-small", "data-test-id": `${d}-loading-circle` }) }) : null,
|
|
178
|
+
/* @__PURE__ */ g("div", { className: c.icons, children: [
|
|
179
|
+
/* @__PURE__ */ n(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
"aria-label": X("Select_toggleMenu"),
|
|
183
|
+
...ie(),
|
|
184
|
+
type: "button",
|
|
185
|
+
disabled: b,
|
|
186
|
+
onMouseDown: () => {
|
|
187
|
+
V.current = !0;
|
|
188
|
+
},
|
|
189
|
+
children: /* @__PURE__ */ n(me, { size: 16, className: c.caret })
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ n(Re, { status: p, hasError: F, dataTestId: d })
|
|
193
|
+
] })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
) }),
|
|
197
|
+
/* @__PURE__ */ n(
|
|
198
|
+
we,
|
|
199
|
+
{
|
|
200
|
+
align: _,
|
|
201
|
+
side: q,
|
|
202
|
+
highlightedIndex: se,
|
|
203
|
+
filterText: A,
|
|
204
|
+
getMenuProps: le,
|
|
205
|
+
getItemProps: re,
|
|
206
|
+
selectedItemValues: i,
|
|
207
|
+
hasInteractedSinceOpening: ae,
|
|
208
|
+
viewportCollisionPadding: J,
|
|
209
|
+
onEscapeKeyDown: Q,
|
|
210
|
+
children: Z
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] });
|
|
16
214
|
};
|
|
215
|
+
z.displayName = "Select.Combobox";
|
|
216
|
+
const Qe = be(z);
|
|
17
217
|
export {
|
|
18
|
-
|
|
218
|
+
Qe as ComboboxBase
|
|
19
219
|
};
|
|
20
220
|
//# sourceMappingURL=fondue-components123.js.map
|