@frontify/fondue-components 23.0.0 → 24.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components.js +50 -46
- package/dist/fondue-components.js.map +1 -1
- package/dist/fondue-components10.js +3 -3
- package/dist/fondue-components10.js.map +1 -1
- package/dist/fondue-components11.js +104 -86
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +2 -2
- package/dist/fondue-components13.js +58 -57
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components14.js +2 -2
- package/dist/fondue-components15.js +2 -2
- package/dist/fondue-components16.js +2 -2
- package/dist/fondue-components17.js +56 -36
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js +34 -16
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js +18 -73
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js +18 -36
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +71 -50
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +36 -138
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +50 -50
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +138 -33
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +52 -193
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +30 -134
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +191 -126
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +134 -30
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +130 -63
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components3.js +1 -1
- package/dist/fondue-components30.js +31 -101
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +64 -30
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +98 -52
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +30 -20
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +56 -23
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +20 -7
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +23 -6
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +8 -32
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +5 -3
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +32 -12
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js +3 -3
- package/dist/fondue-components40.js +5 -155
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +18 -116
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +59 -22
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +111 -14
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +116 -30
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +21 -54
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +31 -130
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +53 -20
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +131 -53
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +20 -7
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components5.js +2 -2
- package/dist/fondue-components50.js +53 -13
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +7 -14
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +13 -5
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +15 -60
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +5 -18
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +60 -19
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +18 -5
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +18 -14
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +1 -1
- package/dist/fondue-components59.js +10 -16
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components6.js +4 -4
- package/dist/fondue-components60.js +4 -10
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +18 -35
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +10 -4
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +34 -10
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +35 -5
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +4 -24
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +12 -16
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +4 -151
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +25 -19
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components69.js +16 -77
- package/dist/fondue-components69.js.map +1 -1
- package/dist/fondue-components7.js +2 -2
- package/dist/fondue-components70.js +152 -8
- package/dist/fondue-components70.js.map +1 -1
- package/dist/fondue-components71.js +19 -37
- package/dist/fondue-components71.js.map +1 -1
- package/dist/fondue-components72.js +76 -69
- package/dist/fondue-components72.js.map +1 -1
- package/dist/fondue-components73.js +8 -11
- package/dist/fondue-components73.js.map +1 -1
- package/dist/fondue-components74.js +36 -12
- package/dist/fondue-components74.js.map +1 -1
- package/dist/fondue-components75.js +70 -12
- package/dist/fondue-components75.js.map +1 -1
- package/dist/fondue-components76.js +10 -22
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +13 -34
- package/dist/fondue-components77.js.map +1 -1
- package/dist/fondue-components78.js +12 -10
- package/dist/fondue-components78.js.map +1 -1
- package/dist/fondue-components79.js +22 -67
- package/dist/fondue-components79.js.map +1 -1
- package/dist/fondue-components8.js +5 -5
- package/dist/fondue-components80.js +34 -15
- package/dist/fondue-components80.js.map +1 -1
- package/dist/fondue-components81.js +9 -24
- package/dist/fondue-components81.js.map +1 -1
- package/dist/fondue-components82.js +67 -18
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +14 -22
- package/dist/fondue-components83.js.map +1 -1
- package/dist/fondue-components84.js +24 -6
- package/dist/fondue-components84.js.map +1 -1
- package/dist/fondue-components85.js +18 -19
- package/dist/fondue-components85.js.map +1 -1
- package/dist/fondue-components86.js +21 -5
- package/dist/fondue-components86.js.map +1 -1
- package/dist/fondue-components87.js +8 -4
- package/dist/fondue-components87.js.map +1 -1
- package/dist/fondue-components88.js +19 -4
- package/dist/fondue-components88.js.map +1 -1
- package/dist/fondue-components89.js +4 -14
- package/dist/fondue-components89.js.map +1 -1
- package/dist/fondue-components9.js +5 -5
- package/dist/fondue-components90.js +5 -2
- package/dist/fondue-components90.js.map +1 -1
- package/dist/fondue-components91.js +4 -39
- package/dist/fondue-components91.js.map +1 -1
- package/dist/fondue-components92.js +39 -20
- package/dist/fondue-components92.js.map +1 -1
- package/dist/fondue-components93.js +24 -0
- package/dist/fondue-components93.js.map +1 -0
- package/dist/fondue-components94.js +5 -0
- package/dist/fondue-components94.js.map +1 -0
- package/dist/fondue-components95.js +20 -0
- package/dist/fondue-components95.js.map +1 -0
- package/dist/index.d.ts +116 -3
- package/dist/style.css +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components68.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"fondue-components68.js","sources":["../src/hooks/useControllableState.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type Dispatch, type SetStateAction, useCallback, useMemo, useState, useRef, useEffect } from 'react';\n\n// Radix UI handy hook for handling controlled and uncontrolled state\n// Source: https://github.com/radix-ui/primitives/blob/main/packages/react/use-controllable-state/src/useControllableState.tsx\n\ntype UseControllableStateParams<TValue> = {\n prop?: TValue;\n defaultProp?: TValue;\n onChange?: (state: TValue) => void;\n};\n\ntype SetStateFn<T> = (prevState?: T) => T;\n\nexport const useControllableState = <TValue>({\n prop,\n defaultProp,\n onChange = () => {},\n}: UseControllableStateParams<TValue>) => {\n const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });\n const isControlled = prop !== undefined;\n const value = isControlled ? prop : uncontrolledProp;\n const handleChange = useMemo(() => onChange, [onChange]);\n\n const setValue: Dispatch<SetStateAction<TValue | undefined>> = useCallback(\n (nextValue) => {\n if (isControlled) {\n const setter = nextValue as SetStateFn<TValue>;\n const value = typeof nextValue === 'function' ? setter(prop) : nextValue;\n if (value !== prop) {\n handleChange(value as TValue);\n }\n } else {\n setUncontrolledProp(nextValue);\n }\n },\n [isControlled, prop, setUncontrolledProp, handleChange],\n );\n\n return [value, setValue] as const;\n};\n\nconst useUncontrolledState = <TValue>({ defaultProp, onChange }: Omit<UseControllableStateParams<TValue>, 'prop'>) => {\n const [value, setValue] = useState<TValue | undefined>(defaultProp);\n const prevValueRef = useRef(value);\n const handleChange = useMemo(() => onChange, [onChange]);\n\n useEffect(() => {\n if (prevValueRef.current !== value) {\n handleChange?.(value as TValue);\n prevValueRef.current = value;\n }\n }, [value, prevValueRef, handleChange]);\n\n return [value, setValue] as const;\n};\n"],"names":["useControllableState","prop","defaultProp","onChange","uncontrolledProp","setUncontrolledProp","useUncontrolledState","isControlled","value","handleChange","useMemo","setValue","useCallback","nextValue","useState","prevValueRef","useRef","useEffect"],"mappings":";AAeO,MAAMA,IAAuB,CAAS;AAAA,EACzC,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC,IAAW,MAAM;AAAA,EAAC;AACtB,MAA0C;AACtC,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAqB,EAAE,aAAAJ,GAAa,UAAAC,GAAU,GACxFI,IAAeN,MAAS,QACxBO,IAAQD,IAAeN,IAAOG,GAC9BK,IAAeC,EAAQ,MAAMP,GAAU,CAACA,CAAQ,CAAC,GAEjDQ,IAAyDC;AAAA,IAC3D,CAACC,MAAc;AACX,UAAIN,GAAc;AAEd,cAAMC,IAAQ,OAAOK,KAAc,aADpBA,EACwCZ,CAAI,IAAIY;AAC/D,QAAIL,MAAUP,KACVQ,EAAaD,CAAe;AAAA,MAEpC;AACI,QAAAH,EAAoBQ,CAAS;AAAA,IAErC;AAAA,IACA,CAACN,GAAcN,GAAMI,GAAqBI,CAAY;AAAA,EAAA;AAG1D,SAAO,CAACD,GAAOG,CAAQ;AAC3B,GAEML,IAAuB,CAAS,EAAE,aAAAJ,GAAa,UAAAC,QAAiE;AAClH,QAAM,CAACK,GAAOG,CAAQ,IAAIG,EAA6BZ,CAAW,GAC5Da,IAAeC,EAAOR,CAAK,GAC3BC,IAAeC,EAAQ,MAAMP,GAAU,CAACA,CAAQ,CAAC;AAEvD,SAAAc,EAAU,MAAM;AACZ,IAAIF,EAAa,YAAYP,MACzBC,KAAA,QAAAA,EAAeD,IACfO,EAAa,UAAUP;AAAA,EAE/B,GAAG,CAACA,GAAOO,GAAcN,CAAY,CAAC,GAE/B,CAACD,GAAOG,CAAQ;AAC3B;"}
|
|
@@ -1,81 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
highlightedIndex: p,
|
|
10
|
-
getMenuProps: c,
|
|
11
|
-
getItemProps: m,
|
|
12
|
-
children: f,
|
|
13
|
-
filterText: d,
|
|
14
|
-
align: h,
|
|
15
|
-
side: v,
|
|
16
|
-
selectedItem: o,
|
|
17
|
-
hasInteractedSinceOpening: P,
|
|
18
|
-
viewportCollisionPadding: S = "compact"
|
|
19
|
-
}) => {
|
|
20
|
-
const g = (e) => {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
}, O = {
|
|
23
|
-
compact: 8,
|
|
24
|
-
spacious: 24
|
|
25
|
-
}, { theme: N, dir: i } = M(), A = (e) => i === "ltr" ? e : e === "left" ? "right" : e === "right" ? "left" : e;
|
|
26
|
-
return /* @__PURE__ */ r(u.Portal, { children: /* @__PURE__ */ r(T, { theme: N, dir: i, children: /* @__PURE__ */ r(
|
|
27
|
-
u.Content,
|
|
28
|
-
{
|
|
29
|
-
align: h,
|
|
30
|
-
side: A(v),
|
|
31
|
-
collisionPadding: O[S] + 8,
|
|
32
|
-
onOpenAutoFocus: g,
|
|
33
|
-
className: n.portal,
|
|
34
|
-
children: /* @__PURE__ */ r(
|
|
35
|
-
"ul",
|
|
36
|
-
{
|
|
37
|
-
className: n.menu,
|
|
38
|
-
...c({}, { suppressRefError: !0 }),
|
|
39
|
-
"data-has-interacted": P ? "true" : "false",
|
|
40
|
-
"data-test-id": "fondue-select-menu",
|
|
41
|
-
children: E(
|
|
42
|
-
f,
|
|
43
|
-
(e, s) => {
|
|
44
|
-
if (((t) => (
|
|
45
|
-
// @ts-expect-error - We are explicitly checking for ref
|
|
46
|
-
D(t) && t.ref !== void 0
|
|
47
|
-
))(e)) {
|
|
48
|
-
const t = F(e.props), a = m({
|
|
49
|
-
item: t,
|
|
50
|
-
index: s,
|
|
51
|
-
...e.ref ? { ref: e.ref } : {}
|
|
52
|
-
}), l = (o == null ? void 0 : o.value) === t.value;
|
|
53
|
-
return /* @__PURE__ */ r(
|
|
54
|
-
V,
|
|
55
|
-
{
|
|
56
|
-
className: n.item,
|
|
57
|
-
"data-highlighted": p === s,
|
|
58
|
-
"data-selected": l,
|
|
59
|
-
onTouchStart: (C) => {
|
|
60
|
-
a.onClick && a.onClick(C);
|
|
61
|
-
},
|
|
62
|
-
...a,
|
|
63
|
-
"aria-selected": l,
|
|
64
|
-
children: e
|
|
65
|
-
},
|
|
66
|
-
e.props.value
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
d
|
|
71
|
-
).parsedChildren
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
) }) });
|
|
1
|
+
const t = "_root_zjamu_5", e = "_item_zjamu_34", a = "_itemLabel_zjamu_59", i = "_itemLabelActive_zjamu_80", o = "_itemLabelInactive_zjamu_111", _ = "_activeIndicator_zjamu_141", c = "_separator_zjamu_267", m = {
|
|
2
|
+
root: t,
|
|
3
|
+
item: e,
|
|
4
|
+
itemLabel: a,
|
|
5
|
+
itemLabelActive: i,
|
|
6
|
+
itemLabelInactive: o,
|
|
7
|
+
activeIndicator: _,
|
|
8
|
+
separator: c
|
|
76
9
|
};
|
|
77
|
-
R.displayName = "Select.Menu";
|
|
78
10
|
export {
|
|
79
|
-
|
|
11
|
+
_ as activeIndicator,
|
|
12
|
+
m as default,
|
|
13
|
+
e as item,
|
|
14
|
+
a as itemLabel,
|
|
15
|
+
i as itemLabelActive,
|
|
16
|
+
o as itemLabelInactive,
|
|
17
|
+
t as root,
|
|
18
|
+
c as separator
|
|
80
19
|
};
|
|
81
20
|
//# sourceMappingURL=fondue-components69.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components69.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components69.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -2,8 +2,8 @@ import { jsx as i, jsxs as l } from "react/jsx-runtime";
|
|
|
2
2
|
import { IconMinus as f, IconCheckMark as u } from "@frontify/fondue-icons";
|
|
3
3
|
import * as r from "@radix-ui/react-checkbox";
|
|
4
4
|
import { forwardRef as h } from "react";
|
|
5
|
-
import { cn as w } from "./fondue-
|
|
6
|
-
import { checkboxIndicatorStyles as b, checkboxStyles as x } from "./fondue-
|
|
5
|
+
import { cn as w } from "./fondue-components41.js";
|
|
6
|
+
import { checkboxIndicatorStyles as b, checkboxStyles as x } from "./fondue-components45.js";
|
|
7
7
|
const p = ({
|
|
8
8
|
className: d,
|
|
9
9
|
value: s,
|
|
@@ -1,11 +1,155 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsxs as g, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { IconCaretDown as Q, IconCheckMark as U, IconExclamationMarkTriangle as W } from "@frontify/fondue-icons";
|
|
3
|
+
import * as B from "@radix-ui/react-popover";
|
|
4
|
+
import { Slot as X } from "@radix-ui/react-slot";
|
|
5
|
+
import { useCombobox as Y } from "downshift";
|
|
6
|
+
import { forwardRef as Z, useState as A, useRef as ee, useMemo as te } from "react";
|
|
7
|
+
import { LoadingCircle as oe } from "./fondue-components19.js";
|
|
8
|
+
import { ForwardedRefSelectSlot as re } from "./fondue-components73.js";
|
|
9
|
+
import { useTranslation as ae } from "./fondue-components36.js";
|
|
10
|
+
import { SelectMenu as le } from "./fondue-components72.js";
|
|
11
|
+
import o from "./fondue-components74.js";
|
|
12
|
+
import { useSelectData as ne } from "./fondue-components75.js";
|
|
13
|
+
const L = ({
|
|
14
|
+
children: M,
|
|
15
|
+
onSelect: i,
|
|
16
|
+
value: O,
|
|
17
|
+
defaultValue: v,
|
|
18
|
+
placeholder: F = "",
|
|
19
|
+
status: s = "neutral",
|
|
20
|
+
disabled: f,
|
|
21
|
+
"data-test-id": r = "fondue-select-combobox",
|
|
22
|
+
alignMenu: P = "start",
|
|
23
|
+
side: k = "bottom",
|
|
24
|
+
id: y,
|
|
25
|
+
viewportCollisionPadding: z = "compact",
|
|
26
|
+
getAsyncItems: c,
|
|
27
|
+
...a
|
|
28
|
+
}, D) => {
|
|
29
|
+
const { t: H } = ae(), { inputSlots: V, menuSlots: $, items: u, filterText: T, clearButton: h, getItemByValue: p, setFilterText: b, asyncItemStatus: C } = ne(M, c), [j, x] = A(!1), {
|
|
30
|
+
getInputProps: d,
|
|
31
|
+
getToggleButtonProps: E,
|
|
32
|
+
getMenuProps: _,
|
|
33
|
+
getItemProps: q,
|
|
34
|
+
reset: w,
|
|
35
|
+
selectedItem: l,
|
|
36
|
+
isOpen: S,
|
|
37
|
+
highlightedIndex: G,
|
|
38
|
+
inputValue: m
|
|
39
|
+
} = Y({
|
|
40
|
+
items: u,
|
|
41
|
+
selectedItem: p(O),
|
|
42
|
+
defaultSelectedItem: p(v),
|
|
43
|
+
defaultHighlightedIndex: 0,
|
|
44
|
+
toggleButtonId: y,
|
|
45
|
+
labelId: "aria-labelledby" in a ? a["aria-labelledby"] : void 0,
|
|
46
|
+
onSelectedItemChange: ({ selectedItem: e }) => {
|
|
47
|
+
i == null || i((e == null ? void 0 : e.value) ?? null);
|
|
48
|
+
},
|
|
49
|
+
onInputValueChange: ({ inputValue: e }) => {
|
|
50
|
+
b(e);
|
|
51
|
+
},
|
|
52
|
+
onIsOpenChange: () => {
|
|
53
|
+
x(!1), b("");
|
|
54
|
+
},
|
|
55
|
+
onHighlightedIndexChange: () => {
|
|
56
|
+
x(!0);
|
|
57
|
+
},
|
|
58
|
+
itemToString: (e) => e ? e.label : ""
|
|
59
|
+
}), n = ee(!1), J = te(
|
|
60
|
+
() => !c && !u.find((e) => e.label.toLowerCase().includes(m.toLowerCase())),
|
|
61
|
+
[m, u, c]
|
|
62
|
+
), K = (e) => {
|
|
63
|
+
var N, R;
|
|
64
|
+
e.target.dataset.showFocusRing = "false", n.current = !1, (l == null ? void 0 : l.label.toLocaleLowerCase()) !== m.toLocaleLowerCase() && w(), d().onBlur && ((R = (N = d()).onBlur) == null || R.call(N, e));
|
|
65
|
+
}, I = J || !!C.error || s === "error";
|
|
66
|
+
return /* @__PURE__ */ g(B.Root, { open: S, children: [
|
|
67
|
+
/* @__PURE__ */ t(B.Anchor, { asChild: !0, children: /* @__PURE__ */ g("div", { ref: D, className: o.root, "data-status": I ? "error" : s, children: [
|
|
68
|
+
/* @__PURE__ */ t(
|
|
69
|
+
"input",
|
|
70
|
+
{
|
|
71
|
+
...d({
|
|
72
|
+
"aria-label": "aria-label" in a ? a["aria-label"] : void 0
|
|
73
|
+
}),
|
|
74
|
+
"data-test-id": r,
|
|
75
|
+
placeholder: F,
|
|
76
|
+
className: o.input,
|
|
77
|
+
disabled: f,
|
|
78
|
+
onMouseDown: (e) => {
|
|
79
|
+
n.current = !0, e.currentTarget.dataset.showFocusRing = "false";
|
|
80
|
+
},
|
|
81
|
+
onFocus: (e) => {
|
|
82
|
+
n.current || (e.target.dataset.showFocusRing = "true");
|
|
83
|
+
},
|
|
84
|
+
onBlur: K
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
V,
|
|
88
|
+
h ? /* @__PURE__ */ t(
|
|
89
|
+
X,
|
|
90
|
+
{
|
|
91
|
+
onClick: (e) => {
|
|
92
|
+
e.stopPropagation(), w();
|
|
93
|
+
},
|
|
94
|
+
className: o.clear,
|
|
95
|
+
role: "button",
|
|
96
|
+
children: h
|
|
97
|
+
}
|
|
98
|
+
) : null,
|
|
99
|
+
C.isLoading && S ? /* @__PURE__ */ t(re, { name: "right", "data-test-id": `${r}-right-slot`, children: /* @__PURE__ */ t(oe, { size: "x-small", "data-test-id": `${r}-loading-circle` }) }) : null,
|
|
100
|
+
/* @__PURE__ */ g("div", { className: o.icons, children: [
|
|
101
|
+
/* @__PURE__ */ t(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
"aria-label": H("Select_toggleMenu"),
|
|
105
|
+
...E(),
|
|
106
|
+
type: "button",
|
|
107
|
+
disabled: f,
|
|
108
|
+
onMouseDown: () => {
|
|
109
|
+
n.current = !0;
|
|
110
|
+
},
|
|
111
|
+
children: /* @__PURE__ */ t(Q, { size: 16, className: o.caret })
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
s === "success" ? /* @__PURE__ */ t(
|
|
115
|
+
U,
|
|
116
|
+
{
|
|
117
|
+
size: 16,
|
|
118
|
+
className: o.iconSuccess,
|
|
119
|
+
"data-test-id": `${r}-success-icon`
|
|
120
|
+
}
|
|
121
|
+
) : null,
|
|
122
|
+
I ? /* @__PURE__ */ t(
|
|
123
|
+
W,
|
|
124
|
+
{
|
|
125
|
+
size: 16,
|
|
126
|
+
className: o.iconError,
|
|
127
|
+
"data-test-id": `${r}-error-icon`
|
|
128
|
+
}
|
|
129
|
+
) : null
|
|
130
|
+
] })
|
|
131
|
+
] }) }),
|
|
132
|
+
/* @__PURE__ */ t(
|
|
133
|
+
le,
|
|
134
|
+
{
|
|
135
|
+
align: P,
|
|
136
|
+
side: k,
|
|
137
|
+
highlightedIndex: G,
|
|
138
|
+
filterText: T,
|
|
139
|
+
getMenuProps: _,
|
|
140
|
+
getItemProps: q,
|
|
141
|
+
selectedItem: l,
|
|
142
|
+
hasInteractedSinceOpening: j,
|
|
143
|
+
viewportCollisionPadding: z,
|
|
144
|
+
children: $
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] });
|
|
148
|
+
};
|
|
149
|
+
L.displayName = "Select.Combobox";
|
|
150
|
+
const xe = Z(L);
|
|
7
151
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
152
|
+
xe as ForwardedRefCombobox,
|
|
153
|
+
L as SelectCombobox
|
|
10
154
|
};
|
|
11
155
|
//# sourceMappingURL=fondue-components70.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components70.js","sources":["../src/components/Select/SelectSlot.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { forwardRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport styles from './styles/select.module.scss';\n\nexport type SelectSlotProps = {\n /**\n * The children of the select slot. This can be a custom component.\n */\n children?: ReactNode;\n /**\n * The slot name that is used to determine the placement.\n */\n name: 'menu' | 'left' | 'right' | 'clear';\n /**\n * The data test id of the select slot.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectSlot = (\n { children, name, 'data-test-id': dataTestId = 'fondue-select-slot', ...props }: SelectSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={forwardedRef} className={styles.slot} data-name={name} {...props}>\n {children}\n </div>\n );\n};\nSelectSlot.displayName = 'Select.Slot';\n\nexport const ForwardedRefSelectSlot = forwardRef<HTMLDivElement, SelectSlotProps>(SelectSlot);\n"],"names":["SelectSlot","children","name","dataTestId","props","forwardedRef","jsx","styles","ForwardedRefSelectSlot","forwardRef"],"mappings":";;;AAqBO,MAAMA,IAAa,CACtB,EAAE,UAAAC,GAAU,MAAAC,GAAM,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAA,GACxEC,MAGI,gBAAAC,EAAC,OAAA,EAAI,gBAAcH,GAAY,KAAKE,GAAc,WAAWE,EAAO,MAAM,aAAWL,GAAO,GAAGE,GAC1F,UAAAH,GACL;AAGRD,EAAW,cAAc;AAElB,MAAMQ,IAAyBC,EAA4CT,CAAU;"}
|
|
1
|
+
{"version":3,"file":"fondue-components70.js","sources":["../src/components/Select/Combobox.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useCombobox } from 'downshift';\nimport { forwardRef, useMemo, useRef, useState, type FocusEvent, type ForwardedRef, type ReactNode } from 'react';\n\nimport { LoadingCircle } from '#/components/LoadingCircle/LoadingCircle.tsx';\nimport { ForwardedRefSelectSlot } from '#/components/Select/SelectSlot.tsx';\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { useTranslation } from '#/hooks/useTranslation';\n\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { useSelectData, type AsyncItemsFetcher } from './useSelectData';\n\nexport type ComboboxProps = {\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 * Callback function that is called when an item is selected.\n */\n onSelect?: (selectedValue: string | null) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string | null;\n /**\n * The default value of the combobox component. Used for uncontrolled usages.\n */\n defaultValue?: string;\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 * 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} & CommonAriaProps;\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\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 ...props\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { t } = useTranslation();\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText, asyncItemStatus } =\n useSelectData(children, getAsyncItems);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const {\n getInputProps,\n getToggleButtonProps,\n getMenuProps,\n getItemProps,\n reset,\n selectedItem,\n isOpen,\n highlightedIndex,\n inputValue,\n } = useCombobox({\n items,\n selectedItem: getItemByValue(value),\n defaultSelectedItem: getItemByValue(defaultValue),\n defaultHighlightedIndex: 0,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\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 });\n\n const wasClicked = useRef(false);\n\n const valueInvalid = useMemo(\n () => !getAsyncItems && !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items, getAsyncItems],\n );\n\n const onBlurHandler = (blurEvent: FocusEvent<HTMLInputElement, Element>) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n\n const selectedItemNullOrOutdated = selectedItem?.label.toLocaleLowerCase() !== inputValue.toLocaleLowerCase();\n\n if (selectedItemNullOrOutdated) {\n // if there is no selection or\n // the existing selected value is not the same as the input value (old),\n // reset the input\n reset();\n }\n\n if (getInputProps().onBlur) {\n getInputProps().onBlur?.(blurEvent);\n }\n };\n const hasError = valueInvalid || !!asyncItemStatus.error || status === 'error';\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={hasError ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={onBlurHandler}\n />\n {inputSlots}\n {clearButton ? (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n role=\"button\"\n >\n {clearButton}\n </RadixSlot>\n ) : 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 wasClicked.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {hasError ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\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 selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectCombobox.displayName = 'Select.Combobox';\n\nexport const ForwardedRefCombobox = forwardRef<HTMLDivElement, ComboboxProps>(SelectCombobox);\n"],"names":["SelectCombobox","children","onSelect","value","defaultValue","placeholder","status","disabled","dataTestId","alignMenu","side","id","viewportCollisionPadding","getAsyncItems","props","forwardedRef","t","useTranslation","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","asyncItemStatus","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","hasError","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","ForwardedRefSelectSlot","LoadingCircle","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":"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"}
|
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
itemValue: g,
|
|
17
|
-
group: d,
|
|
18
|
-
groupHeading: k
|
|
19
|
-
};
|
|
1
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { IconCheckMark as n } from "@frontify/fondue-icons";
|
|
3
|
+
import { forwardRef as l } from "react";
|
|
4
|
+
import a from "./fondue-components74.js";
|
|
5
|
+
const o = ({ "data-test-id": c = "fondue-select-item", ...e }, t) => /* @__PURE__ */ d("li", { "data-test-id": c, ref: t, ...e, children: [
|
|
6
|
+
/* @__PURE__ */ r("div", { className: a.itemValue, children: e.children }),
|
|
7
|
+
/* @__PURE__ */ r(n, { className: a.checkmarkIcon })
|
|
8
|
+
] });
|
|
9
|
+
o.displayName = "Select.Item";
|
|
10
|
+
const I = l(o), s = ({ children: c, groupId: e, heading: t, "data-test-id": i = "fondue-select-item-group" }, m) => /* @__PURE__ */ d("div", { "data-test-id": i, className: a.group, ref: m, children: [
|
|
11
|
+
t ? /* @__PURE__ */ r("div", { className: a.groupHeading, children: /* @__PURE__ */ r("span", { children: t }) }) : null,
|
|
12
|
+
c
|
|
13
|
+
] }, e);
|
|
14
|
+
s.displayName = "Select.Group";
|
|
15
|
+
const N = l(s);
|
|
20
16
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
I as default,
|
|
26
|
-
d as group,
|
|
27
|
-
k as groupHeading,
|
|
28
|
-
l as iconError,
|
|
29
|
-
r as iconSuccess,
|
|
30
|
-
a as icons,
|
|
31
|
-
o as input,
|
|
32
|
-
p as item,
|
|
33
|
-
g as itemValue,
|
|
34
|
-
u as menu,
|
|
35
|
-
i as portal,
|
|
36
|
-
n as root,
|
|
37
|
-
c as selectedValue,
|
|
38
|
-
_ as slot
|
|
17
|
+
I as ForwardedRefSelectItem,
|
|
18
|
+
N as ForwardedRefSelectItemGroup,
|
|
19
|
+
o as SelectItem,
|
|
20
|
+
s as SelectItemGroup
|
|
39
21
|
};
|
|
40
22
|
//# sourceMappingURL=fondue-components71.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components71.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components71.js","sources":["../src/components/Select/SelectItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark } from '@frontify/fondue-icons';\nimport { forwardRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport styles from './styles/select.module.scss';\n\nexport type SelectItemProps = {\n /**\n * The value of the select item.\n */\n value: string;\n /**\n * The data test id of the select item.\n */\n 'data-test-id'?: string;\n} & (\n | {\n /**\n * The label of the select item. Required when the child is not a string.\n */\n label: string;\n /**\n * The children of the select item. This can be a custom component or a string.\n */\n children?: ReactNode;\n }\n | {\n label?: string;\n children: string;\n }\n);\n\nexport const SelectItem = (\n { 'data-test-id': dataTestId = 'fondue-select-item', ...props }: SelectItemProps,\n forwardedRef?: ForwardedRef<HTMLLIElement>,\n) => {\n return (\n <li data-test-id={dataTestId} ref={forwardedRef} {...props}>\n <div className={styles.itemValue}>{props.children}</div>\n <IconCheckMark className={styles.checkmarkIcon} />\n </li>\n );\n};\nSelectItem.displayName = 'Select.Item';\n\nexport const ForwardedRefSelectItem = forwardRef<HTMLLIElement, SelectItemProps>(SelectItem);\n\nexport type SelectItemGroupProps = {\n /**\n * The children of the select item group. This can contain multiple `Select.Item` components.\n */\n children: ReactNode;\n /**\n * The internal group ID of the select item group.\n */\n groupId: string;\n /**\n * The groups heading\n */\n heading?: string;\n /**\n * The data test id of the select item group.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectItemGroup = (\n { children, groupId, heading, 'data-test-id': dataTestId = 'fondue-select-item-group' }: SelectItemGroupProps,\n forwardedRef?: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} className={styles.group} ref={forwardedRef} key={groupId}>\n {heading ? (\n <div className={styles.groupHeading}>\n <span>{heading}</span>\n </div>\n ) : null}\n {children}\n </div>\n );\n};\nSelectItemGroup.displayName = 'Select.Group';\n\nexport const ForwardedRefSelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>(SelectItemGroup);\n"],"names":["SelectItem","dataTestId","props","forwardedRef","jsx","styles","IconCheckMark","ForwardedRefSelectItem","forwardRef","SelectItemGroup","children","groupId","heading","jsxs","ForwardedRefSelectItemGroup"],"mappings":";;;;AAiCO,MAAMA,IAAa,CACtB,EAAE,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAA,GACxDC,wBAGK,MAAA,EAAG,gBAAcF,GAAY,KAAKE,GAAe,GAAGD,GACjD,UAAA;AAAA,EAAA,gBAAAE,EAAC,OAAA,EAAI,WAAWC,EAAO,WAAY,YAAM,UAAS;AAAA,EAClD,gBAAAD,EAACE,GAAA,EAAc,WAAWD,EAAO,cAAA,CAAe;AAAA,GACpD;AAGRL,EAAW,cAAc;AAElB,MAAMO,IAAyBC,EAA2CR,CAAU,GAqB9ES,IAAkB,CAC3B,EAAE,UAAAC,GAAU,SAAAC,GAAS,SAAAC,GAAS,gBAAgBX,IAAa,2BAAA,GAC3DE,MAGI,gBAAAU,EAAC,SAAI,gBAAcZ,GAAY,WAAWI,EAAO,OAAO,KAAKF,GACxD,UAAA;AAAA,EAAAS,IACG,gBAAAR,EAAC,SAAI,WAAWC,EAAO,cACnB,UAAA,gBAAAD,EAAC,QAAA,EAAM,UAAAQ,EAAA,CAAQ,EAAA,CACnB,IACA;AAAA,EACHF;AAAA,EAAA,GAN2EC,CAOhF;AAGRF,EAAgB,cAAc;AAEvB,MAAMK,IAA8BN,EAAiDC,CAAe;"}
|
|
@@ -1,74 +1,81 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as u from "@radix-ui/react-popover";
|
|
3
|
+
import { Slot as V } from "@radix-ui/react-slot";
|
|
4
|
+
import { isValidElement as D } from "react";
|
|
5
|
+
import { useFondueTheme as M, ThemeProvider as T } from "./fondue-components33.js";
|
|
6
|
+
import n from "./fondue-components74.js";
|
|
7
|
+
import { recursiveMap as E, getSelectOptionValue as F } from "./fondue-components92.js";
|
|
8
|
+
const R = ({
|
|
9
|
+
highlightedIndex: p,
|
|
10
|
+
getMenuProps: c,
|
|
11
|
+
getItemProps: m,
|
|
12
|
+
children: f,
|
|
13
|
+
filterText: d,
|
|
14
|
+
align: h,
|
|
15
|
+
side: v,
|
|
16
|
+
selectedItem: o,
|
|
17
|
+
hasInteractedSinceOpening: P,
|
|
18
|
+
viewportCollisionPadding: S = "compact"
|
|
19
|
+
}) => {
|
|
20
|
+
const g = (e) => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}, O = {
|
|
23
|
+
compact: 8,
|
|
24
|
+
spacious: 24
|
|
25
|
+
}, { theme: N, dir: i } = M(), A = (e) => i === "ltr" ? e : e === "left" ? "right" : e === "right" ? "left" : e;
|
|
26
|
+
return /* @__PURE__ */ r(u.Portal, { children: /* @__PURE__ */ r(T, { theme: N, dir: i, children: /* @__PURE__ */ r(
|
|
27
|
+
u.Content,
|
|
28
|
+
{
|
|
29
|
+
align: h,
|
|
30
|
+
side: A(v),
|
|
31
|
+
collisionPadding: O[S] + 8,
|
|
32
|
+
onOpenAutoFocus: g,
|
|
33
|
+
className: n.portal,
|
|
34
|
+
children: /* @__PURE__ */ r(
|
|
35
|
+
"ul",
|
|
36
|
+
{
|
|
37
|
+
className: n.menu,
|
|
38
|
+
...c({}, { suppressRefError: !0 }),
|
|
39
|
+
"data-has-interacted": P ? "true" : "false",
|
|
40
|
+
"data-test-id": "fondue-select-menu",
|
|
41
|
+
children: E(
|
|
42
|
+
f,
|
|
43
|
+
(e, s) => {
|
|
44
|
+
if (((t) => (
|
|
45
|
+
// @ts-expect-error - We are explicitly checking for ref
|
|
46
|
+
D(t) && t.ref !== void 0
|
|
47
|
+
))(e)) {
|
|
48
|
+
const t = F(e.props), a = m({
|
|
49
|
+
item: t,
|
|
50
|
+
index: s,
|
|
51
|
+
...e.ref ? { ref: e.ref } : {}
|
|
52
|
+
}), l = (o == null ? void 0 : o.value) === t.value;
|
|
53
|
+
return /* @__PURE__ */ r(
|
|
54
|
+
V,
|
|
55
|
+
{
|
|
56
|
+
className: n.item,
|
|
57
|
+
"data-highlighted": p === s,
|
|
58
|
+
"data-selected": l,
|
|
59
|
+
onTouchStart: (C) => {
|
|
60
|
+
a.onClick && a.onClick(C);
|
|
61
|
+
},
|
|
62
|
+
...a,
|
|
63
|
+
"aria-selected": l,
|
|
64
|
+
children: e
|
|
65
|
+
},
|
|
66
|
+
e.props.value
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
d
|
|
71
|
+
).parsedChildren
|
|
72
|
+
}
|
|
73
|
+
)
|
|
34
74
|
}
|
|
35
|
-
})
|
|
36
|
-
}, q = (n, s) => {
|
|
37
|
-
const [e, r] = S(""), { inputSlots: m, menuSlots: i, itemValues: l, clearButton: f } = b(() => {
|
|
38
|
-
const a = [], p = [];
|
|
39
|
-
let V;
|
|
40
|
-
v.toArray(n).some(
|
|
41
|
-
(t) => C(t) && t.type === y
|
|
42
|
-
) ? v.forEach(n, (t) => {
|
|
43
|
-
C(t) && t.type === y && (t.props.name === "menu" ? p.push(t.props.children) : t.props.name === "left" || t.props.name === "right" ? a.push(t) : t.props.name === "clear" && (t.props.children ? V = t : V = w(t, { children: /* @__PURE__ */ E(F, {}) })));
|
|
44
|
-
}) : p.push(n);
|
|
45
|
-
const R = g(p);
|
|
46
|
-
return { inputSlots: a, menuSlots: p, itemValues: R, clearButton: V };
|
|
47
|
-
}, [n]), u = b(
|
|
48
|
-
() => l.filter(
|
|
49
|
-
(a) => e === "" || a.label.toLowerCase().includes(e.toLowerCase())
|
|
50
|
-
),
|
|
51
|
-
[l, e]
|
|
52
|
-
), o = B(
|
|
53
|
-
(a) => a ? l.find((p) => p.value === a) : void 0,
|
|
54
|
-
[l]
|
|
55
|
-
), c = O(e, s);
|
|
56
|
-
return {
|
|
57
|
-
items: [...u, ...c.items],
|
|
58
|
-
menuSlots: [...i, ...c.menuComponents],
|
|
59
|
-
filterText: e,
|
|
60
|
-
inputSlots: m,
|
|
61
|
-
clearButton: f,
|
|
62
|
-
setFilterText: r,
|
|
63
|
-
getItemByValue: o,
|
|
64
|
-
asyncItemStatus: {
|
|
65
|
-
isLoading: c.isLoading,
|
|
66
|
-
error: c.error
|
|
67
|
-
}
|
|
68
|
-
};
|
|
75
|
+
) }) });
|
|
69
76
|
};
|
|
77
|
+
R.displayName = "Select.Menu";
|
|
70
78
|
export {
|
|
71
|
-
|
|
72
|
-
q as useSelectData
|
|
79
|
+
R as SelectMenu
|
|
73
80
|
};
|
|
74
81
|
//# sourceMappingURL=fondue-components72.js.map
|