@frontify/fondue-components 26.0.2 → 26.0.3
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-components104.js +1 -1
- package/dist/fondue-components105.js +1 -1
- package/dist/fondue-components106.js +1 -1
- package/dist/fondue-components107.js +1 -1
- package/dist/fondue-components108.js +1 -1
- package/dist/fondue-components40.js +2 -2
- package/dist/fondue-components47.js +1 -1
- package/dist/fondue-components71.js +2 -2
- package/dist/fondue-components72.js +2 -2
- package/dist/fondue-components73.js +2 -2
- package/dist/fondue-components74.js +2 -2
- package/dist/fondue-components75.js +1 -1
- package/dist/fondue-components76.js +1 -1
- package/dist/fondue-components92.js +216 -4
- package/dist/fondue-components92.js.map +1 -1
- package/dist/fondue-components93.js +18 -4
- package/dist/fondue-components93.js.map +1 -1
- package/dist/fondue-components94.js +16 -16
- package/dist/fondue-components94.js.map +1 -1
- package/dist/fondue-components95.js +120 -180
- package/dist/fondue-components95.js.map +1 -1
- package/dist/fondue-components96.js +44 -18
- package/dist/fondue-components96.js.map +1 -1
- package/dist/fondue-components97.js +16 -19
- package/dist/fondue-components97.js.map +1 -1
- package/dist/fondue-components98.js +4 -150
- package/dist/fondue-components98.js.map +1 -1
- package/dist/fondue-components99.js +4 -44
- package/dist/fondue-components99.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,214 +1,154 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { IconCaretDown as
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { IconCaretDown as V } from "@frontify/fondue-icons";
|
|
3
|
+
import * as I from "@radix-ui/react-popover";
|
|
4
|
+
import { useSelect as s } from "downshift";
|
|
5
|
+
import { forwardRef as ee, useRef as te, useCallback as N, useState as ne, useMemo as oe } from "react";
|
|
6
|
+
import { useBadgeItems as re } from "./fondue-components100.js";
|
|
7
|
+
import { useFocusRing as ae } from "./fondue-components101.js";
|
|
8
|
+
import { useSelectData as se } from "./fondue-components102.js";
|
|
9
|
+
import { useSelectionDescription as ie } from "./fondue-components103.js";
|
|
10
|
+
import r from "./fondue-components96.js";
|
|
11
|
+
import { ClearButton as le } from "./fondue-components104.js";
|
|
12
|
+
import { CollapsibleBadges as ce } from "./fondue-components105.js";
|
|
13
|
+
import { SelectMenu as ue } from "./fondue-components106.js";
|
|
14
|
+
import { StatusIcons as ge } from "./fondue-components107.js";
|
|
15
|
+
const O = ({
|
|
16
|
+
children: M,
|
|
17
|
+
selectedItemValues: o,
|
|
18
|
+
onItemSelect: p,
|
|
19
|
+
onClear: P,
|
|
20
|
+
placeholder: c = "",
|
|
21
|
+
status: u = "neutral",
|
|
22
|
+
disabled: f,
|
|
23
|
+
alignMenu: R = "start",
|
|
24
|
+
side: j = "bottom",
|
|
25
|
+
id: k,
|
|
26
|
+
showStringValue: y = !0,
|
|
27
|
+
"data-test-id": b = "fondue-select",
|
|
28
|
+
viewportCollisionPadding: E = "compact",
|
|
29
|
+
onEscapeKeyDown: F,
|
|
30
|
+
multiple: g,
|
|
31
|
+
...i
|
|
32
|
+
}, a) => {
|
|
33
|
+
const C = te(null), B = N(
|
|
34
|
+
(e) => {
|
|
35
|
+
C.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
|
|
36
|
+
},
|
|
37
|
+
[a]
|
|
38
|
+
), { inputSlots: H, menuSlots: K, items: w, clearButton: S, getItemByValue: l } = se(M), { onMouseDown: z, onFocus: A, onBlur: q } = ae(), { selectionDescriptionId: D, selectionDescription: m } = ie(
|
|
39
|
+
g,
|
|
39
40
|
o,
|
|
40
|
-
i,
|
|
41
41
|
l
|
|
42
|
-
),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const a = N.find((b) => !(e != null && e.includes(b)));
|
|
48
|
-
a && h(a.value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} : { selectedItems: [] }
|
|
52
|
-
), oe = o ? ne.removeSelectedItem : () => {
|
|
53
|
-
}, {
|
|
54
|
-
getInputProps: m,
|
|
55
|
-
getToggleButtonProps: ie,
|
|
56
|
-
getMenuProps: re,
|
|
57
|
-
getItemProps: le,
|
|
58
|
-
reset: F,
|
|
59
|
-
selectedItem: v,
|
|
60
|
-
isOpen: k,
|
|
61
|
-
highlightedIndex: se,
|
|
62
|
-
inputValue: x
|
|
63
|
-
} = g({
|
|
64
|
-
items: y,
|
|
65
|
-
selectedItem: o ? null : l(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 t && t["aria-labelledby"] ? { labelId: t["aria-labelledby"] } : {},
|
|
70
|
-
onSelectedItemChange: ({ selectedItem: e }) => {
|
|
71
|
-
e && h(e.value), o && B("");
|
|
72
|
-
},
|
|
73
|
-
onInputValueChange: ({ inputValue: e }) => {
|
|
74
|
-
B(e);
|
|
42
|
+
), G = re(o, l), [J, v] = ne(!1), x = N(
|
|
43
|
+
(e) => {
|
|
44
|
+
const t = l(e);
|
|
45
|
+
if (t)
|
|
46
|
+
return !y && (t != null && t.children) ? t.children : t == null ? void 0 : t.label;
|
|
75
47
|
},
|
|
48
|
+
[l, y]
|
|
49
|
+
), { getToggleButtonProps: L, getMenuProps: Q, getItemProps: U, reset: W, isOpen: X, highlightedIndex: Y } = s({
|
|
50
|
+
items: w,
|
|
51
|
+
selectedItem: null,
|
|
52
|
+
toggleButtonId: k,
|
|
53
|
+
labelId: "aria-labelledby" in i ? i["aria-labelledby"] : void 0,
|
|
76
54
|
onIsOpenChange: () => {
|
|
77
|
-
|
|
55
|
+
v(!1);
|
|
78
56
|
},
|
|
79
57
|
onHighlightedIndexChange: () => {
|
|
80
|
-
|
|
58
|
+
v(!0);
|
|
59
|
+
},
|
|
60
|
+
onSelectedItemChange: ({ selectedItem: e }) => {
|
|
61
|
+
p(e == null ? void 0 : e.value);
|
|
81
62
|
},
|
|
82
63
|
itemToString: (e) => e ? e.label : "",
|
|
83
|
-
...
|
|
84
|
-
stateReducer: (e,
|
|
85
|
-
const { changes:
|
|
86
|
-
switch (
|
|
87
|
-
case
|
|
88
|
-
case
|
|
64
|
+
...g ? {
|
|
65
|
+
stateReducer: (e, t) => {
|
|
66
|
+
const { changes: h, type: $ } = t;
|
|
67
|
+
switch ($) {
|
|
68
|
+
case s.stateChangeTypes.ToggleButtonKeyDownEnter:
|
|
69
|
+
case s.stateChangeTypes.ToggleButtonKeyDownSpaceButton:
|
|
70
|
+
case s.stateChangeTypes.ItemClick:
|
|
89
71
|
return {
|
|
90
|
-
...
|
|
72
|
+
...h,
|
|
91
73
|
isOpen: !0,
|
|
92
|
-
highlightedIndex: e.highlightedIndex
|
|
93
|
-
inputValue: ""
|
|
74
|
+
highlightedIndex: e.highlightedIndex
|
|
94
75
|
};
|
|
95
|
-
case
|
|
76
|
+
case s.stateChangeTypes.ToggleButtonBlur:
|
|
96
77
|
return {
|
|
97
|
-
...
|
|
98
|
-
|
|
78
|
+
...h,
|
|
79
|
+
selectedItem: e.selectedItem
|
|
99
80
|
};
|
|
100
81
|
}
|
|
101
|
-
return
|
|
82
|
+
return h;
|
|
102
83
|
}
|
|
103
84
|
} : {}
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
return /* @__PURE__ */ f(H.Root, { open: k, children: [
|
|
114
|
-
/* @__PURE__ */ n(H.Anchor, { asChild: !0, children: /* @__PURE__ */ f(
|
|
85
|
+
}), T = u === "error", Z = () => {
|
|
86
|
+
P(), W();
|
|
87
|
+
}, _ = oe(
|
|
88
|
+
() => x(o[0]) || c,
|
|
89
|
+
[x, o, c]
|
|
90
|
+
);
|
|
91
|
+
return /* @__PURE__ */ d(I.Root, { open: X, children: [
|
|
92
|
+
/* @__PURE__ */ n(I.Anchor, { asChild: !0, onMouseDown: z, onFocus: A, onBlur: q, children: /* @__PURE__ */ d(
|
|
115
93
|
"div",
|
|
116
94
|
{
|
|
117
|
-
ref:
|
|
118
|
-
className:
|
|
119
|
-
"data-status":
|
|
120
|
-
"data-disabled":
|
|
121
|
-
"data-empty":
|
|
95
|
+
ref: B,
|
|
96
|
+
className: r.root,
|
|
97
|
+
"data-status": T ? "error" : u,
|
|
98
|
+
"data-disabled": f,
|
|
99
|
+
"data-empty": o.length === 0,
|
|
100
|
+
"data-test-id": b,
|
|
101
|
+
...f ? {} : (
|
|
102
|
+
// eslint-disable-next-line react-hooks/refs
|
|
103
|
+
L({
|
|
104
|
+
"aria-label": "aria-label" in i ? i["aria-label"] : void 0,
|
|
105
|
+
"aria-describedby": m ? D : void 0,
|
|
106
|
+
ref: B
|
|
107
|
+
})
|
|
108
|
+
),
|
|
122
109
|
children: [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Se,
|
|
127
|
-
{
|
|
128
|
-
items: te,
|
|
129
|
-
onDismiss: ce,
|
|
130
|
-
selectedCount: i.length,
|
|
131
|
-
children: /* @__PURE__ */ n(
|
|
132
|
-
"input",
|
|
133
|
-
{
|
|
134
|
-
...m({
|
|
135
|
-
ref: W,
|
|
136
|
-
"aria-label": "aria-label" in t ? t["aria-label"] : void 0,
|
|
137
|
-
// Remove auto-generated aria-labelledby if not explicitly provided
|
|
138
|
-
"aria-labelledby": "aria-labelledby" in t && t["aria-labelledby"] ? t["aria-labelledby"] : void 0,
|
|
139
|
-
"aria-describedby": O ? L : void 0
|
|
140
|
-
}),
|
|
141
|
-
"data-test-id": c,
|
|
142
|
-
placeholder: i.length === 0 ? I : "",
|
|
143
|
-
className: s.multiSelectInput,
|
|
144
|
-
disabled: d,
|
|
145
|
-
onMouseDown: D,
|
|
146
|
-
onFocus: w,
|
|
147
|
-
onBlur: T
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
] }) : /* @__PURE__ */ n(
|
|
153
|
-
"input",
|
|
110
|
+
m ? /* @__PURE__ */ n("span", { id: D, className: r.srOnly, children: m }) : null,
|
|
111
|
+
g ? /* @__PURE__ */ n("div", { className: r.selectedValue, children: /* @__PURE__ */ n(
|
|
112
|
+
ce,
|
|
154
113
|
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
className: s.input,
|
|
163
|
-
disabled: d,
|
|
164
|
-
onMouseDown: D,
|
|
165
|
-
onFocus: w,
|
|
166
|
-
onBlur: T
|
|
114
|
+
items: G,
|
|
115
|
+
placeholder: c,
|
|
116
|
+
onDismiss: (e) => {
|
|
117
|
+
var t;
|
|
118
|
+
p(e), (t = C.current) == null || t.focus();
|
|
119
|
+
},
|
|
120
|
+
selectedCount: o.length
|
|
167
121
|
}
|
|
168
|
-
),
|
|
169
|
-
|
|
170
|
-
S ? /* @__PURE__ */ n(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
/* @__PURE__ */ n(
|
|
174
|
-
"button",
|
|
175
|
-
{
|
|
176
|
-
"aria-label": X("Select_toggleMenu"),
|
|
177
|
-
...ie(),
|
|
178
|
-
type: "button",
|
|
179
|
-
disabled: d,
|
|
180
|
-
onMouseDown: () => {
|
|
181
|
-
V.current = !0;
|
|
182
|
-
},
|
|
183
|
-
children: /* @__PURE__ */ n(me, { size: 16, className: s.caret })
|
|
184
|
-
}
|
|
185
|
-
),
|
|
186
|
-
/* @__PURE__ */ n(we, { status: p, hasError: P, dataTestId: c })
|
|
122
|
+
) }) : /* @__PURE__ */ n("span", { className: r.selectedValue, children: _ }),
|
|
123
|
+
H,
|
|
124
|
+
S ? /* @__PURE__ */ n(le, { onClear: Z, children: S }) : null,
|
|
125
|
+
/* @__PURE__ */ d("div", { className: r.icons, children: [
|
|
126
|
+
/* @__PURE__ */ n(V, { size: 16, className: r.caret }),
|
|
127
|
+
/* @__PURE__ */ n(ge, { status: u, hasError: T, dataTestId: b })
|
|
187
128
|
] })
|
|
188
129
|
]
|
|
189
130
|
}
|
|
190
131
|
) }),
|
|
191
132
|
/* @__PURE__ */ n(
|
|
192
|
-
|
|
133
|
+
ue,
|
|
193
134
|
{
|
|
194
|
-
align:
|
|
195
|
-
side:
|
|
196
|
-
highlightedIndex:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
children: Z
|
|
135
|
+
align: R,
|
|
136
|
+
side: j,
|
|
137
|
+
highlightedIndex: Y,
|
|
138
|
+
getMenuProps: Q,
|
|
139
|
+
getItemProps: U,
|
|
140
|
+
selectedItemValues: o,
|
|
141
|
+
hasInteractedSinceOpening: J,
|
|
142
|
+
viewportCollisionPadding: E,
|
|
143
|
+
onEscapeKeyDown: F,
|
|
144
|
+
children: K
|
|
205
145
|
}
|
|
206
146
|
)
|
|
207
147
|
] });
|
|
208
148
|
};
|
|
209
|
-
|
|
210
|
-
const
|
|
149
|
+
O.displayName = "Select";
|
|
150
|
+
const Te = ee(O);
|
|
211
151
|
export {
|
|
212
|
-
|
|
152
|
+
Te as SelectBase
|
|
213
153
|
};
|
|
214
154
|
//# sourceMappingURL=fondue-components95.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components95.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 ...(multiple\n ? {\n stateReducer: (state, actionAndChanges) => {\n const { changes, type } = actionAndChanges;\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 return changes;\n },\n }\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;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACP,GACAC,MACY;AACZ,QAAMC,IAAWC,GAAgC,IAAI,GAC/CC,IAAmBC,GAAY,CAACC,MAAwC;AA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Ac,MAAK,WAAU,gBAAc,GAAG9E,CAAU,mBAAmB,GAChF,IACA;AAAA,UACJ,gBAAAsE,EAAC,OAAA,EAAI,WAAWG,EAAO,OACnB,UAAA;AAAA,YAAA,gBAAAD;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,cAAYzD,EAAE,mBAAmB;AAAA,gBAChC,GAAGmC,GAAA;AAAA,gBACJ,MAAK;AAAA,gBACL,UAAAnD;AAAA,gBACA,aAAa,MAAM;AACf,kBAAA2B,EAAc,UAAU;AAAA,gBAC5B;AAAA,gBAEA,4BAACqD,IAAA,EAAc,MAAM,IAAI,WAAWN,EAAO,MAAA,CAAO;AAAA,cAAA;AAAA,YAAA;AAAA,YAEtD,gBAAAD,EAACQ,IAAA,EAAY,QAAAlF,GAAgB,UAAAgE,GAAoB,YAAA9D,EAAA,CAAwB;AAAA,UAAA,EAAA,CAC7E;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAER;AAAA,IAEA,gBAAAwE;AAAA,MAACS;AAAA,MAAA;AAAA,QACG,OAAOhF;AAAA,QACP,MAAAC;AAAA,QACA,kBAAAsD;AAAA,QACA,YAAApC;AAAA,QACA,cAAA+B;AAAA,QACA,cAAAC;AAAA,QACA,oBAAA1D;AAAA,QACA,2BAAA0C;AAAA,QACA,0BAAAhC;AAAA,QACA,iBAAAE;AAAA,QAEC,UAAAY;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACA1B,EAAkB,cAAc;AAEzB,MAAM0F,KAAeC,GAA8C3F,CAAiB;"}
|
|
1
|
+
{"version":3,"file":"fondue-components95.js","sources":["../src/components/Select/components/SelectBase.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 { useSelect } from 'downshift';\nimport { forwardRef, useCallback, useMemo, useRef, useState, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { useBadgeItems } from '../hooks/useBadgeItems';\nimport { useFocusRing } from '../hooks/useFocusRing';\nimport { useSelectData } 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 { StatusIcons } from './StatusIcons';\n\nexport type SelectSharedProps = {\n /**\n * Children of the Select 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 select 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 select 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 select. It will not be respected if there are collisions with the viewport\n * @default \"bottom\"\n */\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * The data test id of the select component\n */\n 'data-test-id'?: string;\n /**\n * Id of the select component\n */\n id?: string;\n /**\n * The value of the select is shown as plain text (from the label prop) when set to true\n * Items child components are used if set to false\n * @default true\n */\n showStringValue?: boolean;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n /**\n * Event handler called when the escape key is pressed\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n} & CommonAriaProps;\n\ntype SelectBaseProps = SelectSharedProps & {\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 select allows multiple selections\n */\n multiple: boolean;\n};\n\nconst SelectBaseInput = (\n {\n children,\n selectedItemValues,\n onItemSelect,\n onClear,\n placeholder = '',\n status = 'neutral',\n disabled,\n alignMenu = 'start',\n side = 'bottom',\n id,\n showStringValue = true,\n 'data-test-id': dataTestId = 'fondue-select',\n viewportCollisionPadding = 'compact',\n onEscapeKeyDown,\n multiple,\n ...props\n }: SelectBaseProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n): ReactNode => {\n const internalRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useCallback(\n (node: HTMLDivElement | null): void => {\n internalRef.current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef) {\n forwardedRef.current = node;\n }\n },\n [forwardedRef],\n );\n const { inputSlots, menuSlots, items, clearButton, getItemByValue } = useSelectData(children);\n const { 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 getDisplayedValue = useCallback(\n (itemValue?: string): ReactNode => {\n const selectedItem = getItemByValue(itemValue);\n if (selectedItem) {\n return !showStringValue && selectedItem?.children ? selectedItem.children : selectedItem?.label;\n }\n return undefined;\n },\n [getItemByValue, showStringValue],\n );\n\n const { getToggleButtonProps, getMenuProps, getItemProps, reset, isOpen, highlightedIndex } = useSelect<{\n value: string;\n label: string;\n children?: ReactNode;\n }>({\n items,\n selectedItem: null,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n onSelectedItemChange: ({ selectedItem }) => {\n onItemSelect(selectedItem?.value);\n },\n itemToString: (item) => (item ? item.label : ''),\n ...(multiple\n ? {\n stateReducer: (state, actionAndChanges) => {\n const { changes, type } = actionAndChanges;\n switch (type) {\n case useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:\n case useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:\n case useSelect.stateChangeTypes.ItemClick:\n return {\n ...changes,\n isOpen: true,\n highlightedIndex: state.highlightedIndex,\n };\n case useSelect.stateChangeTypes.ToggleButtonBlur:\n return {\n ...changes,\n selectedItem: state.selectedItem,\n };\n }\n return changes;\n },\n }\n : {}),\n });\n\n const hasError = status === 'error';\n\n const handleClear = (): void => {\n onClear();\n reset();\n };\n\n const singleSelectValue = useMemo(\n (): ReactNode => getDisplayedValue(selectedItemValues[0]) || placeholder,\n [getDisplayedValue, selectedItemValues, placeholder],\n );\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild onMouseDown={onMouseDown} onFocus={onFocus} onBlur={onBlur}>\n <div\n ref={triggerRef}\n className={styles.root}\n data-status={hasError ? 'error' : status}\n data-disabled={disabled}\n data-empty={selectedItemValues.length === 0}\n data-test-id={dataTestId}\n {...(disabled\n ? {}\n : // eslint-disable-next-line react-hooks/refs\n getToggleButtonProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n 'aria-describedby': selectionDescription ? selectionDescriptionId : undefined,\n ref: triggerRef,\n }))}\n >\n {selectionDescription ? (\n <span id={selectionDescriptionId} className={styles.srOnly}>\n {selectionDescription}\n </span>\n ) : null}\n {multiple ? (\n <div className={styles.selectedValue}>\n <CollapsibleBadges\n items={badgeItems}\n placeholder={placeholder}\n onDismiss={(value) => {\n onItemSelect(value);\n internalRef.current?.focus();\n }}\n selectedCount={selectedItemValues.length}\n />\n </div>\n ) : (\n <span className={styles.selectedValue}>{singleSelectValue}</span>\n )}\n {inputSlots}\n {clearButton ? <ClearButton onClear={handleClear}>{clearButton}</ClearButton> : null}\n <div className={styles.icons}>\n <IconCaretDown size={16} className={styles.caret} />\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 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};\nSelectBaseInput.displayName = 'Select';\n\nexport const SelectBase = forwardRef<HTMLDivElement, SelectBaseProps>(SelectBaseInput);\n"],"names":["SelectBaseInput","children","selectedItemValues","onItemSelect","onClear","placeholder","status","disabled","alignMenu","side","id","showStringValue","dataTestId","viewportCollisionPadding","onEscapeKeyDown","multiple","props","forwardedRef","internalRef","useRef","triggerRef","useCallback","node","inputSlots","menuSlots","items","clearButton","getItemByValue","useSelectData","onMouseDown","onFocus","onBlur","useFocusRing","selectionDescriptionId","selectionDescription","useSelectionDescription","badgeItems","useBadgeItems","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getDisplayedValue","itemValue","selectedItem","getToggleButtonProps","getMenuProps","getItemProps","reset","isOpen","highlightedIndex","useSelect","item","state","actionAndChanges","changes","type","hasError","handleClear","singleSelectValue","useMemo","jsxs","RadixPopover","jsx","styles","CollapsibleBadges","value","_a","ClearButton","IconCaretDown","StatusIcons","SelectMenu","SelectBase","forwardRef"],"mappings":";;;;;;;;;;;;;;AA4FA,MAAMA,IAAkB,CACpB;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,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,gBAAgBC,IAAa;AAAA,EAC7B,0BAAAC,IAA2B;AAAA,EAC3B,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACP,GACAC,MACY;AACZ,Q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AU;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACAxB,EAAgB,cAAc;AAEvB,MAAMuE,KAAaC,GAA4CxE,CAAe;"}
|
|
@@ -1,22 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
const c = "_root_13ciu_7", e = "_selectedValue_13ciu_63", _ = "_input_13ciu_80", o = "_slot_13ciu_106", t = "_clear_13ciu_156", n = "_clearIcon_13ciu_163", u = "_icons_13ciu_167", i = "_caret_13ciu_173", r = "_iconSuccess_13ciu_201", s = "_iconError_13ciu_207", a = "_menu_13ciu_213", l = "_portal_13ciu_236", p = "_item_13ciu_252", g = "_checkmarkIcon_13ciu_281", m = "_itemValue_13ciu_287", d = "_group_13ciu_301", I = "_groupHeading_13ciu_312", b = "_badgesContainer_13ciu_324", k = "_badgeWrapper_13ciu_336", S = "_srOnly_13ciu_345", V = "_multiSelectInput_13ciu_357", y = {
|
|
2
|
+
root: c,
|
|
3
|
+
selectedValue: e,
|
|
4
|
+
input: _,
|
|
5
|
+
slot: o,
|
|
6
|
+
clear: t,
|
|
7
|
+
clearIcon: n,
|
|
8
|
+
icons: u,
|
|
9
|
+
caret: i,
|
|
10
|
+
iconSuccess: r,
|
|
11
|
+
iconError: s,
|
|
12
|
+
menu: a,
|
|
13
|
+
portal: l,
|
|
14
|
+
item: p,
|
|
15
|
+
checkmarkIcon: g,
|
|
16
|
+
itemValue: m,
|
|
17
|
+
group: d,
|
|
18
|
+
groupHeading: I,
|
|
19
|
+
badgesContainer: b,
|
|
20
|
+
badgeWrapper: k,
|
|
21
|
+
srOnly: S,
|
|
22
|
+
multiSelectInput: V
|
|
18
23
|
};
|
|
19
24
|
export {
|
|
20
|
-
|
|
25
|
+
k as badgeWrapper,
|
|
26
|
+
b as badgesContainer,
|
|
27
|
+
i as caret,
|
|
28
|
+
g as checkmarkIcon,
|
|
29
|
+
t as clear,
|
|
30
|
+
n as clearIcon,
|
|
31
|
+
y as default,
|
|
32
|
+
d as group,
|
|
33
|
+
I as groupHeading,
|
|
34
|
+
s as iconError,
|
|
35
|
+
r as iconSuccess,
|
|
36
|
+
u as icons,
|
|
37
|
+
_ as input,
|
|
38
|
+
p as item,
|
|
39
|
+
m as itemValue,
|
|
40
|
+
a as menu,
|
|
41
|
+
V as multiSelectInput,
|
|
42
|
+
l as portal,
|
|
43
|
+
c as root,
|
|
44
|
+
e as selectedValue,
|
|
45
|
+
o as slot,
|
|
46
|
+
S as srOnly
|
|
21
47
|
};
|
|
22
48
|
//# sourceMappingURL=fondue-components96.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components96.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components96.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
[d, t, s]
|
|
11
|
-
), f = i(() => {
|
|
12
|
-
t === void 0 && u(null), s == null || s(null);
|
|
13
|
-
}, [t, s]);
|
|
14
|
-
return {
|
|
15
|
-
selectedItemValues: a,
|
|
16
|
-
selectItem: c,
|
|
17
|
-
clear: f
|
|
18
|
-
};
|
|
1
|
+
const o = "_root_18649_5", c = "_caret_18649_43", t = "_colorName_18649_58", _ = "_colorIndicator_18649_61", n = "_button_18649_82", r = "_actions_18649_113", a = "_clearIcon_18649_122", s = {
|
|
2
|
+
root: o,
|
|
3
|
+
caret: c,
|
|
4
|
+
colorName: t,
|
|
5
|
+
colorIndicator: _,
|
|
6
|
+
button: n,
|
|
7
|
+
actions: r,
|
|
8
|
+
clearIcon: a
|
|
19
9
|
};
|
|
20
10
|
export {
|
|
21
|
-
|
|
11
|
+
r as actions,
|
|
12
|
+
n as button,
|
|
13
|
+
c as caret,
|
|
14
|
+
a as clearIcon,
|
|
15
|
+
_ as colorIndicator,
|
|
16
|
+
t as colorName,
|
|
17
|
+
s as default,
|
|
18
|
+
o as root
|
|
22
19
|
};
|
|
23
20
|
//# sourceMappingURL=fondue-components97.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components97.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components97.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|