@frontify/fondue-components 19.2.0 → 19.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components.js +10 -8
- 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 +3 -3
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +2 -2
- package/dist/fondue-components12.js.map +1 -1
- package/dist/fondue-components13.js +3 -3
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components14.js +2 -2
- package/dist/fondue-components14.js.map +1 -1
- package/dist/fondue-components15.js +2 -2
- package/dist/fondue-components15.js.map +1 -1
- package/dist/fondue-components16.js +1 -1
- package/dist/fondue-components16.js.map +1 -1
- package/dist/fondue-components17.js +1 -1
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js +1 -1
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js +1 -1
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js +2 -2
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +2 -2
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +8 -8
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +1 -1
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +2 -2
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +63 -62
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +77 -70
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +2 -2
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +3 -12
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +101 -10
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components3.js +93 -73
- package/dist/fondue-components3.js.map +1 -1
- package/dist/fondue-components30.js +12 -55
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +55 -14
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +20 -7
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +7 -6
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +7 -32
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +32 -5
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +5 -12
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +10 -153
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +59 -22
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +17 -17
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js +33 -32
- package/dist/fondue-components4.js.map +1 -1
- package/dist/fondue-components40.js +112 -15
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +19 -30
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +32 -62
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +53 -121
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +129 -20
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +21 -45
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +45 -8
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +8 -13
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +13 -15
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +14 -4
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components5.js +2 -2
- package/dist/fondue-components5.js.map +1 -1
- package/dist/fondue-components50.js +5 -60
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +59 -17
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +18 -19
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +18 -4
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +3 -13
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +13 -3
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +3 -17
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +19 -35
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +35 -5
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +4 -12
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components6.js +4 -4
- package/dist/fondue-components6.js.map +1 -1
- package/dist/fondue-components60.js +12 -4
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +4 -24
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +24 -16
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +16 -150
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +151 -19
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +19 -77
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +77 -8
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +8 -35
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +34 -70
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components69.js +70 -10
- package/dist/fondue-components69.js.map +1 -1
- package/dist/fondue-components7.js +36 -30
- package/dist/fondue-components7.js.map +1 -1
- package/dist/fondue-components70.js +8 -10
- package/dist/fondue-components70.js.map +1 -1
- package/dist/fondue-components71.js +12 -12
- package/dist/fondue-components71.js.map +1 -1
- package/dist/fondue-components72.js +12 -20
- package/dist/fondue-components72.js.map +1 -1
- package/dist/fondue-components73.js +21 -29
- package/dist/fondue-components73.js.map +1 -1
- package/dist/fondue-components74.js +33 -55
- package/dist/fondue-components74.js.map +1 -1
- package/dist/fondue-components75.js +55 -14
- package/dist/fondue-components75.js.map +1 -1
- package/dist/fondue-components76.js +14 -25
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +24 -13
- package/dist/fondue-components77.js.map +1 -1
- package/dist/fondue-components78.js +14 -6
- package/dist/fondue-components78.js.map +1 -1
- package/dist/fondue-components79.js +21 -5
- package/dist/fondue-components79.js.map +1 -1
- package/dist/fondue-components8.js +5 -5
- package/dist/fondue-components8.js.map +1 -1
- package/dist/fondue-components80.js +6 -4
- package/dist/fondue-components80.js.map +1 -1
- package/dist/fondue-components81.js +6 -4
- package/dist/fondue-components81.js.map +1 -1
- package/dist/fondue-components82.js +5 -2
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +4 -16
- package/dist/fondue-components83.js.map +1 -1
- package/dist/fondue-components84.js +2 -40
- package/dist/fondue-components84.js.map +1 -1
- package/dist/fondue-components85.js +43 -0
- package/dist/fondue-components85.js.map +1 -0
- package/dist/fondue-components86.js +20 -0
- package/dist/fondue-components86.js.map +1 -0
- package/dist/fondue-components9.js +37 -32
- package/dist/fondue-components9.js.map +1 -1
- package/dist/index.d.ts +125 -50
- package/dist/style.css +1 -1
- package/package.json +60 -60
|
@@ -1,80 +1,22 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
selectedItem: t,
|
|
17
|
-
hasInteractedSinceOpening: h,
|
|
18
|
-
viewportCollisionPadding: v = "compact"
|
|
19
|
-
}) => {
|
|
20
|
-
const P = (e) => {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
}, O = {
|
|
23
|
-
compact: 8,
|
|
24
|
-
spacious: 24
|
|
25
|
-
}, N = g();
|
|
26
|
-
return /* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ r(A, { theme: N, children: /* @__PURE__ */ r(
|
|
27
|
-
i.Content,
|
|
28
|
-
{
|
|
29
|
-
align: f,
|
|
30
|
-
side: d,
|
|
31
|
-
collisionPadding: O[v] + 8,
|
|
32
|
-
onOpenAutoFocus: P,
|
|
33
|
-
className: n.portal,
|
|
34
|
-
children: /* @__PURE__ */ r(
|
|
35
|
-
"ul",
|
|
36
|
-
{
|
|
37
|
-
className: n.menu,
|
|
38
|
-
...l({}, { suppressRefError: !0 }),
|
|
39
|
-
"data-has-interacted": h ? "true" : "false",
|
|
40
|
-
"data-test-id": "fondue-select-menu",
|
|
41
|
-
children: D(
|
|
42
|
-
u,
|
|
43
|
-
(e, s) => {
|
|
44
|
-
if (((o) => (
|
|
45
|
-
// @ts-expect-error - We are explicitly checking for ref
|
|
46
|
-
V(o) && o.ref !== void 0
|
|
47
|
-
))(e)) {
|
|
48
|
-
const o = M(e.props), a = m({
|
|
49
|
-
item: o,
|
|
50
|
-
index: s,
|
|
51
|
-
...e.ref ? { ref: e.ref } : {}
|
|
52
|
-
});
|
|
53
|
-
return /* @__PURE__ */ r(
|
|
54
|
-
C,
|
|
55
|
-
{
|
|
56
|
-
className: n.item,
|
|
57
|
-
"data-highlighted": p === s,
|
|
58
|
-
"data-selected": (t == null ? void 0 : t.value) === o.value,
|
|
59
|
-
onTouchStart: (S) => {
|
|
60
|
-
a.onClick && a.onClick(S);
|
|
61
|
-
},
|
|
62
|
-
...a,
|
|
63
|
-
children: e
|
|
64
|
-
},
|
|
65
|
-
e.props.value
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
c
|
|
70
|
-
).parsedChildren
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
) }) });
|
|
75
|
-
};
|
|
76
|
-
T.displayName = "Select.Menu";
|
|
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-components68.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);
|
|
77
16
|
export {
|
|
78
|
-
|
|
17
|
+
I as ForwardedRefSelectItem,
|
|
18
|
+
N as ForwardedRefSelectItemGroup,
|
|
19
|
+
o as SelectItem,
|
|
20
|
+
s as SelectItemGroup
|
|
79
21
|
};
|
|
80
22
|
//# sourceMappingURL=fondue-components65.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components65.js","sources":["../src/components/Select/
|
|
1
|
+
{"version":3,"file":"fondue-components65.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,11 +1,80 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as i from "@radix-ui/react-popover";
|
|
3
|
+
import { Slot as C } from "@radix-ui/react-slot";
|
|
4
|
+
import { isValidElement as V } from "react";
|
|
5
|
+
import { useFondueTheme as g, ThemeProvider as A } from "./fondue-components30.js";
|
|
6
|
+
import n from "./fondue-components68.js";
|
|
7
|
+
import { recursiveMap as D, getSelectOptionValue as M } from "./fondue-components85.js";
|
|
8
|
+
const T = ({
|
|
9
|
+
highlightedIndex: p,
|
|
10
|
+
getMenuProps: l,
|
|
11
|
+
getItemProps: m,
|
|
12
|
+
children: u,
|
|
13
|
+
filterText: c,
|
|
14
|
+
align: f,
|
|
15
|
+
side: d,
|
|
16
|
+
selectedItem: t,
|
|
17
|
+
hasInteractedSinceOpening: h,
|
|
18
|
+
viewportCollisionPadding: v = "compact"
|
|
19
|
+
}) => {
|
|
20
|
+
const P = (e) => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}, O = {
|
|
23
|
+
compact: 8,
|
|
24
|
+
spacious: 24
|
|
25
|
+
}, N = g();
|
|
26
|
+
return /* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ r(A, { theme: N, children: /* @__PURE__ */ r(
|
|
27
|
+
i.Content,
|
|
28
|
+
{
|
|
29
|
+
align: f,
|
|
30
|
+
side: d,
|
|
31
|
+
collisionPadding: O[v] + 8,
|
|
32
|
+
onOpenAutoFocus: P,
|
|
33
|
+
className: n.portal,
|
|
34
|
+
children: /* @__PURE__ */ r(
|
|
35
|
+
"ul",
|
|
36
|
+
{
|
|
37
|
+
className: n.menu,
|
|
38
|
+
...l({}, { suppressRefError: !0 }),
|
|
39
|
+
"data-has-interacted": h ? "true" : "false",
|
|
40
|
+
"data-test-id": "fondue-select-menu",
|
|
41
|
+
children: D(
|
|
42
|
+
u,
|
|
43
|
+
(e, s) => {
|
|
44
|
+
if (((o) => (
|
|
45
|
+
// @ts-expect-error - We are explicitly checking for ref
|
|
46
|
+
V(o) && o.ref !== void 0
|
|
47
|
+
))(e)) {
|
|
48
|
+
const o = M(e.props), a = m({
|
|
49
|
+
item: o,
|
|
50
|
+
index: s,
|
|
51
|
+
...e.ref ? { ref: e.ref } : {}
|
|
52
|
+
});
|
|
53
|
+
return /* @__PURE__ */ r(
|
|
54
|
+
C,
|
|
55
|
+
{
|
|
56
|
+
className: n.item,
|
|
57
|
+
"data-highlighted": p === s,
|
|
58
|
+
"data-selected": (t == null ? void 0 : t.value) === o.value,
|
|
59
|
+
onTouchStart: (S) => {
|
|
60
|
+
a.onClick && a.onClick(S);
|
|
61
|
+
},
|
|
62
|
+
...a,
|
|
63
|
+
children: e
|
|
64
|
+
},
|
|
65
|
+
e.props.value
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
c
|
|
70
|
+
).parsedChildren
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
) }) });
|
|
75
|
+
};
|
|
76
|
+
T.displayName = "Select.Menu";
|
|
7
77
|
export {
|
|
8
|
-
|
|
9
|
-
t as SelectSlot
|
|
78
|
+
T as SelectMenu
|
|
10
79
|
};
|
|
11
80
|
//# sourceMappingURL=fondue-components66.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components66.js","sources":["../src/components/Select/
|
|
1
|
+
{"version":3,"file":"fondue-components66.js","sources":["../src/components/Select/SelectMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { type UseComboboxPropGetters, type UseSelectPropGetters } from 'downshift';\nimport { isValidElement, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\n\nexport type SelectMenuViewportCollisionPadding = 'compact' | 'spacious';\n\nexport type SelectMenuProps = {\n /**\n * @internal\n * The index of the highlighted item in the menu.\n */\n highlightedIndex: number;\n /**\n * @internal\n * Callback function to retrieve the props for a menu element.\n */\n getMenuProps: UseSelectPropGetters<unknown>['getMenuProps'] | UseComboboxPropGetters<unknown>['getMenuProps'];\n /**\n * @internal\n * Callback function to retrieve the props for a item element.\n */\n getItemProps: UseSelectPropGetters<unknown>['getItemProps'] | UseComboboxPropGetters<unknown>['getItemProps'];\n /**\n * @internal\n * The children of the menu component. This can contain multiple `Select.Item` or `Select.Group` components.\n */\n children: ReactNode;\n /**\n * @internal\n * The filter text shown in the combobox input element.\n */\n filterText?: string;\n /**\n * @internal\n * The alignment of the menu.\n */\n align: 'start' | 'center' | 'end';\n /**\n * @internal\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 * @internal\n * The type of the menu.\n */\n selectedItem?: {\n value: string;\n } | null;\n /**\n * @internal\n * A boolean to indicate if highlighted item was changed since opening the menu.\n * This is used to determine the style of the selected/highlighted item.\n */\n hasInteractedSinceOpening?: boolean;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n};\n\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n side,\n selectedItem,\n hasInteractedSinceOpening,\n viewportCollisionPadding = 'compact',\n}: SelectMenuProps) => {\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n };\n\n const VIEWPORT_COLLISION_PADDING_MAP: Record<SelectMenuViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n };\n\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <RadixPopover.Content\n align={align}\n side={side}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding] + 8}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n className={styles.portal}\n >\n <ul\n className={styles.menu}\n // TODO: fix this accessibility issue\n // We are mounting/unmounting the menu on open/close\n // We should instead toggle its visibility for accessibility reasons\n // https://github.com/downshift-js/downshift?tab=readme-ov-file#getmenuprops\n {...getMenuProps({}, { suppressRefError: true })}\n data-has-interacted={hasInteractedSinceOpening ? 'true' : 'false'}\n data-test-id=\"fondue-select-menu\"\n >\n {\n recursiveMap(\n children,\n (child, index) => {\n const isValid = <TProps,>(\n child: ReactNode,\n ): child is ReactElement<TProps> & { ref: ForwardedRef<HTMLElement> } =>\n // @ts-expect-error - We are explicitly checking for ref\n isValidElement<TProps>(child) && child.ref !== undefined;\n\n if (isValid<SelectItemProps>(child)) {\n const optionData = getSelectOptionValue(child.props);\n const itemProps = getItemProps({\n item: optionData,\n index,\n ...(child.ref ? { ref: child.ref } : {}),\n });\n\n return (\n <RadixSlot\n className={styles.item}\n data-highlighted={highlightedIndex === index}\n data-selected={selectedItem?.value === optionData.value}\n key={child.props.value}\n // Workaround for the issue where the onClick event is not fired on touch devices because of portal usage\n onTouchStart={(event) => {\n if (itemProps.onClick) {\n itemProps.onClick(event as unknown as MouseEvent<HTMLElement>);\n }\n }}\n {...itemProps}\n >\n {child}\n </RadixSlot>\n );\n }\n },\n filterText,\n ).parsedChildren\n }\n </ul>\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","align","side","selectedItem","hasInteractedSinceOpening","viewportCollisionPadding","handleOnOpenAutoFocus","event","VIEWPORT_COLLISION_PADDING_MAP","theme","useFondueTheme","RadixPopover","jsx","ThemeProvider","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AAwEO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,0BAAAC,IAA2B;AAC/B,MAAuB;AACnB,QAAMC,IAAwB,CAACC,MAAiB;AAC5C,IAAAA,EAAM,eAAA;AAAA,EACV,GAEMC,IAAqF;AAAA,IACvF,SAAS;AAAA,IACT,UAAU;AAAA,EAAA,GAGRC,IAAQC,EAAA;AACd,2BACKC,EAAa,QAAb,EACG,UAAA,gBAAAC,EAACC,KAAc,OAAAJ,GACX,UAAA,gBAAAG;AAAA,IAACD,EAAa;AAAA,IAAb;AAAA,MACG,OAAAV;AAAA,MACA,MAAAC;AAAA,MACA,kBAAkBM,EAA+BH,C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|
8
|
-
caret: s,
|
|
9
|
-
iconSuccess: r,
|
|
10
|
-
iconError: m,
|
|
11
|
-
menu: a,
|
|
12
|
-
portal: d,
|
|
13
|
-
item: u,
|
|
14
|
-
checkmarkIcon: i,
|
|
15
|
-
itemValue: l,
|
|
16
|
-
group: p,
|
|
17
|
-
groupHeading: g
|
|
18
|
-
};
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d } from "react";
|
|
3
|
+
import m from "./fondue-components68.js";
|
|
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
|
+
t.displayName = "Select.Slot";
|
|
6
|
+
const S = d(t);
|
|
19
7
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
e as clear,
|
|
23
|
-
k as default,
|
|
24
|
-
p as group,
|
|
25
|
-
g as groupHeading,
|
|
26
|
-
m as iconError,
|
|
27
|
-
r as iconSuccess,
|
|
28
|
-
n as icons,
|
|
29
|
-
_ as input,
|
|
30
|
-
u as item,
|
|
31
|
-
l as itemValue,
|
|
32
|
-
a as menu,
|
|
33
|
-
d as portal,
|
|
34
|
-
o as root,
|
|
35
|
-
c as selectedValue,
|
|
36
|
-
t as slot
|
|
8
|
+
S as ForwardedRefSelectSlot,
|
|
9
|
+
t as SelectSlot
|
|
37
10
|
};
|
|
38
11
|
//# sourceMappingURL=fondue-components67.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components67.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components67.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,74 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
menuComponents: u.map((o) => /* @__PURE__ */ E(L, { label: o.label, value: o.value, children: o.content ? o.content : o.label }, o.value)),
|
|
19
|
-
items: u.map((o) => ({ value: o.value, label: o.label, children: o.content }))
|
|
20
|
-
}), r(!1);
|
|
21
|
-
}).catch((u) => {
|
|
22
|
-
i(u), r(!1);
|
|
23
|
-
}));
|
|
24
|
-
}, [n, s]), { isLoading: e, error: m, menuComponents: l.menuComponents, items: l.items };
|
|
25
|
-
}, g = (n) => {
|
|
26
|
-
const s = [];
|
|
27
|
-
return v.forEach(n, (e) => {
|
|
28
|
-
if (C(e) && e.type === L)
|
|
29
|
-
s.push(F(e.props));
|
|
30
|
-
else if (C(e) && e.props.children) {
|
|
31
|
-
const r = g(e.props.children);
|
|
32
|
-
for (const m of r)
|
|
33
|
-
s.push(m);
|
|
34
|
-
}
|
|
35
|
-
}), s;
|
|
36
|
-
}, T = (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 = B(t, { children: /* @__PURE__ */ E(w, { size: 16 }) })));
|
|
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 = I(
|
|
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
|
-
};
|
|
1
|
+
const o = "_root_174md_7", c = "_selectedValue_174md_69", _ = "_input_174md_87", t = "_slot_174md_113", e = "_clear_174md_165", n = "_icons_174md_178", s = "_caret_174md_184", r = "_iconSuccess_174md_212", m = "_iconError_174md_218", a = "_menu_174md_224", d = "_portal_174md_247", u = "_item_174md_263", i = "_checkmarkIcon_174md_304", l = "_itemValue_174md_311", p = "_group_174md_325", g = "_groupHeading_174md_336", k = {
|
|
2
|
+
root: o,
|
|
3
|
+
selectedValue: c,
|
|
4
|
+
input: _,
|
|
5
|
+
slot: t,
|
|
6
|
+
clear: e,
|
|
7
|
+
icons: n,
|
|
8
|
+
caret: s,
|
|
9
|
+
iconSuccess: r,
|
|
10
|
+
iconError: m,
|
|
11
|
+
menu: a,
|
|
12
|
+
portal: d,
|
|
13
|
+
item: u,
|
|
14
|
+
checkmarkIcon: i,
|
|
15
|
+
itemValue: l,
|
|
16
|
+
group: p,
|
|
17
|
+
groupHeading: g
|
|
69
18
|
};
|
|
70
19
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
20
|
+
s as caret,
|
|
21
|
+
i as checkmarkIcon,
|
|
22
|
+
e as clear,
|
|
23
|
+
k as default,
|
|
24
|
+
p as group,
|
|
25
|
+
g as groupHeading,
|
|
26
|
+
m as iconError,
|
|
27
|
+
r as iconSuccess,
|
|
28
|
+
n as icons,
|
|
29
|
+
_ as input,
|
|
30
|
+
u as item,
|
|
31
|
+
l as itemValue,
|
|
32
|
+
a as menu,
|
|
33
|
+
d as portal,
|
|
34
|
+
o as root,
|
|
35
|
+
c as selectedValue,
|
|
36
|
+
t as slot
|
|
73
37
|
};
|
|
74
38
|
//# sourceMappingURL=fondue-components68.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components68.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components68.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { IconCross as w } from "@frontify/fondue-icons";
|
|
3
|
+
import { useState as S, useMemo as b, Children as v, isValidElement as C, cloneElement as B, useCallback as I, useEffect as x } from "react";
|
|
4
|
+
import { ForwardedRefSelectItem as L } from "./fondue-components65.js";
|
|
5
|
+
import { ForwardedRefSelectSlot as y } from "./fondue-components67.js";
|
|
6
|
+
import { getSelectOptionValue as F } from "./fondue-components85.js";
|
|
7
|
+
const O = (n, s) => {
|
|
8
|
+
const [e, r] = S(!1), [m, i] = S(null), [l, f] = S({
|
|
9
|
+
menuComponents: [],
|
|
10
|
+
items: []
|
|
11
|
+
});
|
|
12
|
+
return x(() => {
|
|
13
|
+
i(null), s || f({
|
|
14
|
+
menuComponents: [],
|
|
15
|
+
items: []
|
|
16
|
+
}), s && (r(!0), s(n).then((u) => {
|
|
17
|
+
f({
|
|
18
|
+
menuComponents: u.map((o) => /* @__PURE__ */ E(L, { label: o.label, value: o.value, children: o.content ? o.content : o.label }, o.value)),
|
|
19
|
+
items: u.map((o) => ({ value: o.value, label: o.label, children: o.content }))
|
|
20
|
+
}), r(!1);
|
|
21
|
+
}).catch((u) => {
|
|
22
|
+
i(u), r(!1);
|
|
23
|
+
}));
|
|
24
|
+
}, [n, s]), { isLoading: e, error: m, menuComponents: l.menuComponents, items: l.items };
|
|
25
|
+
}, g = (n) => {
|
|
26
|
+
const s = [];
|
|
27
|
+
return v.forEach(n, (e) => {
|
|
28
|
+
if (C(e) && e.type === L)
|
|
29
|
+
s.push(F(e.props));
|
|
30
|
+
else if (C(e) && e.props.children) {
|
|
31
|
+
const r = g(e.props.children);
|
|
32
|
+
for (const m of r)
|
|
33
|
+
s.push(m);
|
|
34
|
+
}
|
|
35
|
+
}), s;
|
|
36
|
+
}, T = (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 = B(t, { children: /* @__PURE__ */ E(w, { size: 16 }) })));
|
|
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 = I(
|
|
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
|
+
};
|
|
6
69
|
};
|
|
7
70
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t as root,
|
|
11
|
-
o as thumb,
|
|
12
|
-
s as track
|
|
71
|
+
g as getRecursiveOptionValues,
|
|
72
|
+
T as useSelectData
|
|
13
73
|
};
|
|
14
74
|
//# sourceMappingURL=fondue-components69.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components69.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
1
|
+
{"version":3,"file":"fondue-components69.js","sources":["../src/components/Select/useSelectData.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport {\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n type ReactNode,\n useEffect,\n} from 'react';\n\nimport { ForwardedRefSelectItem, type SelectItemProps } from './SelectItem';\nimport { ForwardedRefSelectSlot, type SelectSlotProps } from './SelectSlot';\nimport { getSelectOptionValue } from './utils';\n\nexport type SelectItemType = {\n value: string;\n label: string;\n};\n\nexport type AsyncItem = { label: string; value: string; content?: ReactNode };\n\nexport type AsyncItemsFetcher = (filterText: string) => Promise<AsyncItem[]>;\n\nconst useAsyncItems = (filterText: string, getAsyncItems?: AsyncItemsFetcher) => {\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [asyncResult, setAsyncResult] = useState<{\n menuComponents: ReactNode[];\n items: { value: string; label: string; children?: ReactNode }[];\n }>({\n menuComponents: [],\n items: [],\n });\n\n useEffect(() => {\n setError(null);\n if (!getAsyncItems) {\n setAsyncResult({\n menuComponents: [],\n items: [],\n });\n }\n\n if (getAsyncItems) {\n setIsLoading(true);\n getAsyncItems(filterText)\n .then((items) => {\n setAsyncResult({\n menuComponents: items.map((item) => (\n <ForwardedRefSelectItem key={item.value} label={item.label} value={item.value}>\n {item.content ? item.content : item.label}\n </ForwardedRefSelectItem>\n )),\n items: items.map((item) => ({ value: item.value, label: item.label, children: item.content })),\n });\n setIsLoading(false);\n })\n .catch((error: Error) => {\n setError(error);\n setIsLoading(false);\n });\n }\n }, [filterText, getAsyncItems]);\n\n return { isLoading, error, menuComponents: asyncResult.menuComponents, items: asyncResult.items };\n};\n\n/**\n * Recursively extracts option values from children.\n * This function traverses through the React component tree and collects all SelectItem values.\n *\n * @param {ReactNode} children - The React children to extract values from.\n * @returns {SelectItemType[]} An array of SelectItemType objects.\n *\n * @example\n * const options = (\n * <SelectItem value=\"1\">Option 1</SelectItem>\n * <SelectItem value=\"2\">Option 2</SelectItem>\n * );\n * const values = getRecursiveOptionValues(options);\n * // Returns: [{ value: '1', label: 'Option 1' }, { value: '2', label: 'Option 2' }]\n */\nexport const getRecursiveOptionValues = (\n children: ReactNode,\n): { value: string; label: string; children?: ReactNode }[] => {\n const values: { value: string; label: string }[] = [];\n Children.forEach(children, (child) => {\n if (isValidElement<SelectItemProps>(child) && child.type === ForwardedRefSelectItem) {\n values.push(getSelectOptionValue(child.props));\n } else if (isValidElement<{ children: ReactNode }>(child) && child.props.children) {\n const optionValues = getRecursiveOptionValues(child.props.children);\n for (const optionValue of optionValues) {\n values.push(optionValue);\n }\n }\n });\n return values;\n};\n\n/**\n * Custom hook for managing select data and filtering.\n *\n * @param {ReactNode} children - The React children to process, typically SelectItem components.\n * @param {AsyncItemsFetcher} [getAsyncItems] - Optional function to fetch items asynchronously based on filter text.\n * @returns {Object} An object containing the processed data.\n */\nexport const useSelectData = (children: ReactNode, getAsyncItems?: AsyncItemsFetcher) => {\n const [filterText, setFilterText] = useState('');\n const { inputSlots, menuSlots, itemValues, clearButton } = useMemo(() => {\n const inputSlots: ReactNode[] = [];\n const menuSlots: ReactNode[] = [];\n let clearButton: ReactNode;\n\n const hasSlots = Children.toArray(children).some(\n (child) => isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot,\n );\n\n if (hasSlots) {\n Children.forEach(children, (child) => {\n if (isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot) {\n if (child.props.name === 'menu') {\n menuSlots.push(child.props.children);\n } else if (child.props.name === 'left' || child.props.name === 'right') {\n inputSlots.push(child);\n } else if (child.props.name === 'clear') {\n if (child.props.children) {\n clearButton = child;\n } else {\n clearButton = cloneElement(child, { children: <IconCross size={16} /> });\n }\n }\n }\n });\n } else {\n menuSlots.push(children);\n }\n\n const itemValues = getRecursiveOptionValues(menuSlots);\n\n return { inputSlots, menuSlots, itemValues, clearButton };\n }, [children]);\n\n const items = useMemo(\n () =>\n itemValues.filter(\n (item) => filterText === '' || item.label.toLowerCase().includes(filterText.toLowerCase()),\n ),\n [itemValues, filterText],\n );\n\n const getItemByValue = useCallback(\n (value?: string | null) => (value ? itemValues.find((item) => item.value === value) : undefined),\n [itemValues],\n );\n\n const asyncItems = useAsyncItems(filterText, getAsyncItems);\n\n return {\n items: [...items, ...asyncItems.items],\n menuSlots: [...menuSlots, ...asyncItems.menuComponents],\n filterText,\n inputSlots,\n clearButton,\n setFilterText,\n getItemByValue,\n asyncItemStatus: {\n isLoading: asyncItems.isLoading,\n error: asyncItems.error,\n },\n };\n};\n"],"names":["useAsyncItems","filterText","getAsyncItems","isLoading","setIsLoading","useState","error","setError","asyncResult","setAsyncResult","useEffect","items","item","jsx","ForwardedRefSelectItem","getRecursiveOptionValues","children","values","Children","child","isValidElement","getSelectOptionValue","optionValues","optionValue","useSelectData","setFilterText","inputSlots","menuSlots","itemValues","clearButton","useMemo","ForwardedRefSelectSlot","cloneElement","IconCross","getItemByValue","useCallback","value","asyncItems"],"mappings":";;;;;;AA2BA,MAAMA,IAAgB,CAACC,GAAoBC,MAAsC;AAC7E,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAC/C,CAACG,GAAaC,CAAc,IAAIJ,EAGnC;AAAA,IACC,gBAAgB,CAAA;AAAA,IAChB,OAAO,CAAA;AAAA,EAAC,CACX;AAED,SAAAK,EAAU,MAAM;AACZ,IAAAH,EAAS,IAAI,GACRL,KACDO,EAAe;AAAA,MACX,gBAAgB,CAAA;AAAA,MAChB,OAAO,CAAA;AAAA,IAAC,CACX,GAGDP,MACAE,EAAa,EAAI,GACjBF,EAAcD,CAA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