@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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { Slot as e } from "@radix-ui/react-slot";
|
|
3
|
-
import a from "./fondue-
|
|
3
|
+
import a from "./fondue-components96.js";
|
|
4
4
|
const m = ({ children: o, onClear: t }) => /* @__PURE__ */ r(e, { onClick: (l) => {
|
|
5
5
|
l.stopPropagation(), t();
|
|
6
6
|
}, className: a.clear, role: "button", "aria-label": "Clear selection", children: o });
|
|
@@ -2,7 +2,7 @@ import { jsxs as S, jsx as f } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef as m, useState as C, useEffect as _ } from "react";
|
|
3
3
|
import { Badge as w } from "./fondue-components4.js";
|
|
4
4
|
import { useTranslation as I } from "./fondue-components39.js";
|
|
5
|
-
import p from "./fondue-
|
|
5
|
+
import p from "./fondue-components96.js";
|
|
6
6
|
const W = 4, D = 40, E = 24, M = (r, h, u, o) => {
|
|
7
7
|
const g = r.offsetWidth;
|
|
8
8
|
let s = o ? E + W : 0, n = 0;
|
|
@@ -3,7 +3,7 @@ import * as p from "@radix-ui/react-popover";
|
|
|
3
3
|
import { Slot as M } from "@radix-ui/react-slot";
|
|
4
4
|
import { isValidElement as T } from "react";
|
|
5
5
|
import { useFondueTheme as E, ThemeProvider as F } from "./fondue-components36.js";
|
|
6
|
-
import a from "./fondue-
|
|
6
|
+
import a from "./fondue-components96.js";
|
|
7
7
|
import { recursiveMap as R, getSelectOptionValue as _ } from "./fondue-components109.js";
|
|
8
8
|
const j = ({
|
|
9
9
|
highlightedIndex: l,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as c, Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { IconCheckMark as i, IconExclamationMarkTriangle as l } from "@frontify/fondue-icons";
|
|
3
3
|
import { useTranslation as m } from "./fondue-components39.js";
|
|
4
|
-
import s from "./fondue-
|
|
4
|
+
import s from "./fondue-components96.js";
|
|
5
5
|
const f = ({ status: o, hasError: a, dataTestId: e }) => {
|
|
6
6
|
const { t } = m();
|
|
7
7
|
return /* @__PURE__ */ c(n, { children: [
|
|
@@ -2,7 +2,7 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { IconCross as s } from "@frontify/fondue-icons";
|
|
3
3
|
import { Button as t } from "./fondue-components6.js";
|
|
4
4
|
import { useTranslation as a } from "./fondue-components39.js";
|
|
5
|
-
import l from "./fondue-
|
|
5
|
+
import l from "./fondue-components96.js";
|
|
6
6
|
const f = ({ onClear: r }) => {
|
|
7
7
|
const { t: o } = a();
|
|
8
8
|
return /* @__PURE__ */ e(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import s from "./fondue-
|
|
3
|
-
import { colorToCss as e } from "./fondue-
|
|
2
|
+
import s from "./fondue-components98.js";
|
|
3
|
+
import { colorToCss as e } from "./fondue-components99.js";
|
|
4
4
|
const a = ["default", "positive", "highlight", "warning", "negative"], i = (t) => typeof t == "string" && a.includes(t), p = ({ status: t }) => {
|
|
5
5
|
const o = i(t) ? { "data-status": t } : { style: { backgroundColor: typeof t == "string" ? t : e(t) || "transparent" } };
|
|
6
6
|
return /* @__PURE__ */ r("div", { "data-test-id": "badge-status", className: s.root, ...o });
|
|
@@ -3,7 +3,7 @@ import { IconDroplet as I, IconCross as k, IconCaretDown as v } from "@frontify/
|
|
|
3
3
|
import { forwardRef as P } from "react";
|
|
4
4
|
import { useTranslation as w } from "./fondue-components39.js";
|
|
5
5
|
import { Button as y } from "./fondue-components6.js";
|
|
6
|
-
import a from "./fondue-
|
|
6
|
+
import a from "./fondue-components97.js";
|
|
7
7
|
import { getColorWithName as z, colorToCss as x } from "./fondue-components50.js";
|
|
8
8
|
const c = ({
|
|
9
9
|
id: m,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as u } from "react";
|
|
3
|
-
import { ComboboxBase as c } from "./fondue-
|
|
4
|
-
import { useMultiselect as b } from "./fondue-
|
|
3
|
+
import { ComboboxBase as c } from "./fondue-components92.js";
|
|
4
|
+
import { useMultiselect as b } from "./fondue-components93.js";
|
|
5
5
|
const a = ({ value: e, onSelect: o, defaultValue: t, ...l }, m) => {
|
|
6
6
|
const { selectedItemValues: r, toggleSelectedItem: p, clear: i } = b(o, e, t);
|
|
7
7
|
return /* @__PURE__ */ s(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as i } from "react";
|
|
3
|
-
import { ComboboxBase as a } from "./fondue-
|
|
4
|
-
import { useSingleSelect as b } from "./fondue-
|
|
3
|
+
import { ComboboxBase as a } from "./fondue-components92.js";
|
|
4
|
+
import { useSingleSelect as b } from "./fondue-components94.js";
|
|
5
5
|
const p = ({ value: e, onSelect: o, defaultValue: t, ...m }, l) => {
|
|
6
6
|
const { selectedItemValues: r, selectItem: s, clear: n } = b(o, e, t);
|
|
7
7
|
return /* @__PURE__ */ c(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as p } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as s } from "react";
|
|
3
|
-
import { SelectBase as u } from "./fondue-
|
|
4
|
-
import { useMultiselect as a } from "./fondue-
|
|
3
|
+
import { SelectBase as u } from "./fondue-components95.js";
|
|
4
|
+
import { useMultiselect as a } from "./fondue-components93.js";
|
|
5
5
|
const n = ({ value: e, onSelect: t, defaultValue: l, ...o }, r) => {
|
|
6
6
|
const { selectedItemValues: m, toggleSelectedItem: c, clear: i } = a(t, e, l);
|
|
7
7
|
return /* @__PURE__ */ p(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as i } from "react";
|
|
3
|
-
import { SelectBase as S } from "./fondue-
|
|
4
|
-
import { useSingleSelect as a } from "./fondue-
|
|
3
|
+
import { SelectBase as S } from "./fondue-components95.js";
|
|
4
|
+
import { useSingleSelect as a } from "./fondue-components94.js";
|
|
5
5
|
const p = ({ value: e, onSelect: t, defaultValue: l, ...o }, r) => {
|
|
6
6
|
const { selectedItemValues: m, selectItem: c, clear: s } = a(t, e, l);
|
|
7
7
|
return /* @__PURE__ */ n(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { IconCheckMark as n } from "@frontify/fondue-icons";
|
|
3
3
|
import { forwardRef as l } from "react";
|
|
4
|
-
import a from "./fondue-
|
|
4
|
+
import a from "./fondue-components96.js";
|
|
5
5
|
const o = ({ "data-test-id": c = "fondue-select-item", ...e }, t) => /* @__PURE__ */ d("li", { "data-test-id": c, ref: t, ...e, children: [
|
|
6
6
|
/* @__PURE__ */ r("div", { className: a.itemValue, children: e.children }),
|
|
7
7
|
/* @__PURE__ */ r(n, { className: a.checkmarkIcon })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as d } from "react";
|
|
3
|
-
import m from "./fondue-
|
|
3
|
+
import m from "./fondue-components96.js";
|
|
4
4
|
const t = ({ children: e, name: o, "data-test-id": r = "fondue-select-slot", ...a }, s) => /* @__PURE__ */ l("div", { "data-test-id": r, ref: s, className: m.slot, "data-name": o, ...a, children: e });
|
|
5
5
|
t.displayName = "Select.Slot";
|
|
6
6
|
const S = d(t);
|
|
@@ -1,8 +1,220 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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-components19.js";
|
|
7
|
+
import { useTranslation as Ce } from "./fondue-components39.js";
|
|
8
|
+
import { useBadgeItems as ye } from "./fondue-components100.js";
|
|
9
|
+
import { useFocusRing as Ie } from "./fondue-components101.js";
|
|
10
|
+
import { useSelectData as ve } from "./fondue-components102.js";
|
|
11
|
+
import { useSelectionDescription as Be } from "./fondue-components103.js";
|
|
12
|
+
import c from "./fondue-components96.js";
|
|
13
|
+
import { ClearButton as xe } from "./fondue-components104.js";
|
|
14
|
+
import { CollapsibleBadges as Se } from "./fondue-components105.js";
|
|
15
|
+
import { SelectMenu as we } from "./fondue-components106.js";
|
|
16
|
+
import { ForwardedRefSelectSlot as De } from "./fondue-components76.js";
|
|
17
|
+
import { StatusIcons as Re } from "./fondue-components107.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
|
+
] });
|
|
3
214
|
};
|
|
215
|
+
z.displayName = "Select.Combobox";
|
|
216
|
+
const Qe = be(z);
|
|
4
217
|
export {
|
|
5
|
-
|
|
6
|
-
o as root
|
|
218
|
+
Qe as ComboboxBase
|
|
7
219
|
};
|
|
8
220
|
//# sourceMappingURL=fondue-components92.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components92.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
1
|
+
{"version":3,"file":"fondue-components92.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;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;AAC1E,IAAAJ,EAAS,UAAUI;AAAA,EACvB,GAAG,CAAA,CAAE,GACC,EAAE,GAAAC,EAAA,IAAMC,GAAA,GACR,EAAE,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i(t);
|
|
5
|
+
};
|
|
6
|
+
return {
|
|
7
|
+
selectedItemValues: e,
|
|
8
|
+
toggleSelectedItem: (t) => {
|
|
9
|
+
if (t === void 0)
|
|
10
|
+
return;
|
|
11
|
+
const c = e.findIndex((o) => t === o);
|
|
12
|
+
c > 0 ? s([...e.slice(0, c), ...e.slice(c + 1)]) : s(c === 0 ? [...e.slice(1)] : [...e, t]);
|
|
13
|
+
},
|
|
14
|
+
clear: () => {
|
|
15
|
+
s([]);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
4
18
|
};
|
|
5
19
|
export {
|
|
6
|
-
|
|
20
|
+
I as useMultiselect
|
|
7
21
|
};
|
|
8
22
|
//# sourceMappingURL=fondue-components93.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components93.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components93.js","sources":["../src/components/Select/hooks/useMultiselect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useState } from 'react';\n\nexport const useMultiselect = (\n onSelect?: (value: string[] | null) => void,\n value?: string[] | null,\n defaultValue?: string[],\n) => {\n const [selectedItemsState, setSelectedItemsState] = useState<string[]>(defaultValue ?? []);\n\n const selectedItemValues = value ?? selectedItemsState;\n const setSelectedItems = (items: string[]) => {\n if (!value) {\n setSelectedItemsState(items);\n }\n onSelect?.(items);\n };\n\n const toggleSelectedItem = (toggledItem?: string) => {\n if (toggledItem === undefined) {\n return;\n }\n const index = selectedItemValues.findIndex((selectedItemValue) => toggledItem === selectedItemValue);\n if (index > 0) {\n setSelectedItems([...selectedItemValues.slice(0, index), ...selectedItemValues.slice(index + 1)]);\n } else if (index === 0) {\n setSelectedItems([...selectedItemValues.slice(1)]);\n } else {\n setSelectedItems([...selectedItemValues, toggledItem]);\n }\n };\n\n const clear = () => {\n setSelectedItems([]);\n };\n\n return {\n selectedItemValues,\n toggleSelectedItem,\n clear,\n };\n};\n"],"names":["useMultiselect","onSelect","value","defaultValue","selectedItemsState","setSelectedItemsState","useState","selectedItemValues","setSelectedItems","items","toggledItem","index","selectedItemValue"],"mappings":";AAIO,MAAMA,IAAiB,CAC1BC,GACAC,GACAC,MACC;AACD,QAAM,CAACC,GAAoBC,CAAqB,IAAIC,EAAmBH,KAAgB,CAAA,CAAE,GAEnFI,IAAqBL,KAASE,GAC9BI,IAAmB,CAACC,MAAoB;AAC1C,IAAKP,KACDG,EAAsBI,CAAK,GAE/BR,KAAA,QAAAA,EAAWQ;AAAA,EACf;AAoBA,SAAO;AAAA,IACH,oBAAAF;AAAA,IACA,oBApBuB,CAACG,MAAyB;AACjD,UAAIA,MAAgB;AAChB;AAEJ,YAAMC,IAAQJ,EAAmB,UAAU,CAACK,MAAsBF,MAAgBE,CAAiB;AACnG,MAAID,IAAQ,IACRH,EAAiB,CAAC,GAAGD,EAAmB,MAAM,GAAGI,CAAK,GAAG,GAAGJ,EAAmB,MAAMI,IAAQ,CAAC,CAAC,CAAC,IAEhGH,EADOG,MAAU,IACA,CAAC,GAAGJ,EAAmB,MAAM,CAAC,CAAC,IAE/B,CAAC,GAAGA,GAAoBG,CAAW,CAFH;AAAA,IAIzD;AAAA,IASI,OAPU,MAAM;AAChB,MAAAF,EAAiB,CAAA,CAAE;AAAA,IACvB;AAAA,EAKI;AAER;"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useState as a, useCallback as u } from "react";
|
|
2
|
+
const n = (s, t, e) => {
|
|
3
|
+
const [f, r] = a(e ?? null), i = t !== void 0 ? t : f, l = i !== null ? [i] : [], m = u(
|
|
4
|
+
(d) => {
|
|
5
|
+
d !== void 0 && (t === void 0 && r(d), s == null || s(d));
|
|
6
|
+
},
|
|
7
|
+
[t, s]
|
|
8
|
+
), I = u(() => {
|
|
9
|
+
t === void 0 && r(null), s == null || s(null);
|
|
10
|
+
}, [t, s]);
|
|
11
|
+
return {
|
|
12
|
+
selectedItemValues: l,
|
|
13
|
+
selectItem: m,
|
|
14
|
+
clear: I
|
|
15
|
+
};
|
|
9
16
|
};
|
|
10
17
|
export {
|
|
11
|
-
|
|
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
|
|
18
|
+
n as useSingleSelect
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=fondue-components94.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components94.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components94.js","sources":["../src/components/Select/hooks/useSingleSelect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useCallback, useState } from 'react';\n\nexport const useSingleSelect = (\n onSelect?: (value: string | null) => void,\n value?: string | null,\n defaultValue?: string,\n) => {\n const [selectedItemState, setSelectedItemState] = useState<string | null>(defaultValue ?? null);\n\n const selectedValue = value !== undefined ? value : selectedItemState;\n const selectedItemValues = selectedValue !== null ? [selectedValue] : [];\n\n const selectItem = useCallback(\n (item?: string) => {\n if (item === undefined) {\n return;\n }\n if (value === undefined) {\n setSelectedItemState(item);\n }\n onSelect?.(item);\n },\n [value, onSelect],\n );\n\n const clear = useCallback(() => {\n if (value === undefined) {\n setSelectedItemState(null);\n }\n onSelect?.(null);\n }, [value, onSelect]);\n\n return {\n selectedItemValues,\n selectItem,\n clear,\n };\n};\n"],"names":["useSingleSelect","onSelect","value","defaultValue","selectedItemState","setSelectedItemState","useState","selectedValue","selectedItemValues","selectItem","useCallback","item","clear"],"mappings":";AAIO,MAAMA,IAAkB,CAC3BC,GACAC,GACAC,MACC;AACD,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAAwBH,KAAgB,IAAI,GAExFI,IAAgBL,MAAU,SAAYA,IAAQE,GAC9CI,IAAqBD,MAAkB,OAAO,CAACA,CAAa,IAAI,CAAA,GAEhEE,IAAaC;AAAA,IACf,CAACC,MAAkB;AACf,MAAIA,MAAS,WAGTT,MAAU,UACVG,EAAqBM,CAAI,GAE7BV,KAAA,QAAAA,EAAWU;AAAA,IACf;AAAA,IACA,CAACT,GAAOD,CAAQ;AAAA,EAAA,GAGdW,IAAQF,EAAY,MAAM;AAC5B,IAAIR,MAAU,UACVG,EAAqB,IAAI,GAE7BJ,KAAA,QAAAA,EAAW;AAAA,EACf,GAAG,CAACC,GAAOD,CAAQ,CAAC;AAEpB,SAAO;AAAA,IACH,oBAAAO;AAAA,IACA,YAAAC;AAAA,IACA,OAAAG;AAAA,EAAA;AAER;"}
|