@frontify/fondue-components 3.3.6 → 4.0.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.
Files changed (113) hide show
  1. package/dist/fondue-components.js +32 -30
  2. package/dist/fondue-components.js.map +1 -1
  3. package/dist/fondue-components10.js +2 -2
  4. package/dist/fondue-components11.js +31 -31
  5. package/dist/fondue-components11.js.map +1 -1
  6. package/dist/fondue-components12.js +2 -2
  7. package/dist/fondue-components13.js +1 -1
  8. package/dist/fondue-components14.js +1 -1
  9. package/dist/fondue-components15.js +1 -1
  10. package/dist/fondue-components16.js +2 -2
  11. package/dist/fondue-components17.js +2 -2
  12. package/dist/fondue-components18.js +39 -37
  13. package/dist/fondue-components18.js.map +1 -1
  14. package/dist/fondue-components19.js +1 -1
  15. package/dist/fondue-components20.js +2 -2
  16. package/dist/fondue-components21.js +116 -65
  17. package/dist/fondue-components21.js.map +1 -1
  18. package/dist/fondue-components22.js +64 -41
  19. package/dist/fondue-components22.js.map +1 -1
  20. package/dist/fondue-components23.js +43 -32
  21. package/dist/fondue-components23.js.map +1 -1
  22. package/dist/fondue-components24.js +32 -5
  23. package/dist/fondue-components24.js.map +1 -1
  24. package/dist/fondue-components25.js +5 -12
  25. package/dist/fondue-components25.js.map +1 -1
  26. package/dist/fondue-components26.js +10 -153
  27. package/dist/fondue-components26.js.map +1 -1
  28. package/dist/fondue-components27.js +59 -22
  29. package/dist/fondue-components27.js.map +1 -1
  30. package/dist/fondue-components28.js +17 -17
  31. package/dist/fondue-components28.js.map +1 -1
  32. package/dist/fondue-components29.js +112 -15
  33. package/dist/fondue-components29.js.map +1 -1
  34. package/dist/fondue-components3.js +2 -2
  35. package/dist/fondue-components30.js +19 -30
  36. package/dist/fondue-components30.js.map +1 -1
  37. package/dist/fondue-components31.js +32 -28
  38. package/dist/fondue-components31.js.map +1 -1
  39. package/dist/fondue-components32.js +23 -125
  40. package/dist/fondue-components32.js.map +1 -1
  41. package/dist/fondue-components33.js +129 -20
  42. package/dist/fondue-components33.js.map +1 -1
  43. package/dist/fondue-components34.js +21 -45
  44. package/dist/fondue-components34.js.map +1 -1
  45. package/dist/fondue-components35.js +45 -28
  46. package/dist/fondue-components35.js.map +1 -1
  47. package/dist/fondue-components36.js +28 -15
  48. package/dist/fondue-components36.js.map +1 -1
  49. package/dist/fondue-components37.js +15 -60
  50. package/dist/fondue-components37.js.map +1 -1
  51. package/dist/fondue-components38.js +60 -15
  52. package/dist/fondue-components38.js.map +1 -1
  53. package/dist/fondue-components39.js +15 -17
  54. package/dist/fondue-components39.js.map +1 -1
  55. package/dist/fondue-components4.js +4 -4
  56. package/dist/fondue-components40.js +18 -4
  57. package/dist/fondue-components40.js.map +1 -1
  58. package/dist/fondue-components41.js +3 -11
  59. package/dist/fondue-components41.js.map +1 -1
  60. package/dist/fondue-components42.js +11 -3
  61. package/dist/fondue-components42.js.map +1 -1
  62. package/dist/fondue-components43.js +5 -35
  63. package/dist/fondue-components43.js.map +1 -1
  64. package/dist/fondue-components44.js +35 -13
  65. package/dist/fondue-components44.js.map +1 -1
  66. package/dist/fondue-components45.js +12 -4
  67. package/dist/fondue-components45.js.map +1 -1
  68. package/dist/fondue-components46.js +4 -24
  69. package/dist/fondue-components46.js.map +1 -1
  70. package/dist/fondue-components47.js +24 -16
  71. package/dist/fondue-components47.js.map +1 -1
  72. package/dist/fondue-components48.js +16 -137
  73. package/dist/fondue-components48.js.map +1 -1
  74. package/dist/fondue-components49.js +140 -16
  75. package/dist/fondue-components49.js.map +1 -1
  76. package/dist/fondue-components5.js +2 -2
  77. package/dist/fondue-components50.js +16 -62
  78. package/dist/fondue-components50.js.map +1 -1
  79. package/dist/fondue-components51.js +72 -8
  80. package/dist/fondue-components51.js.map +1 -1
  81. package/dist/fondue-components52.js +8 -29
  82. package/dist/fondue-components52.js.map +1 -1
  83. package/dist/fondue-components53.js +32 -48
  84. package/dist/fondue-components53.js.map +1 -1
  85. package/dist/fondue-components54.js +48 -10
  86. package/dist/fondue-components54.js.map +1 -1
  87. package/dist/fondue-components55.js +8 -10
  88. package/dist/fondue-components55.js.map +1 -1
  89. package/dist/fondue-components56.js +12 -17
  90. package/dist/fondue-components56.js.map +1 -1
  91. package/dist/fondue-components57.js +52 -6
  92. package/dist/fondue-components57.js.map +1 -1
  93. package/dist/fondue-components58.js +13 -9
  94. package/dist/fondue-components58.js.map +1 -1
  95. package/dist/fondue-components59.js +18 -2
  96. package/dist/fondue-components59.js.map +1 -1
  97. package/dist/fondue-components6.js +5 -5
  98. package/dist/fondue-components60.js +6 -38
  99. package/dist/fondue-components60.js.map +1 -1
  100. package/dist/fondue-components61.js +5 -0
  101. package/dist/fondue-components61.js.map +1 -0
  102. package/dist/fondue-components62.js +42 -0
  103. package/dist/fondue-components62.js.map +1 -0
  104. package/dist/fondue-components63.js +14 -0
  105. package/dist/fondue-components63.js.map +1 -0
  106. package/dist/fondue-components7.js +93 -68
  107. package/dist/fondue-components7.js.map +1 -1
  108. package/dist/fondue-components8.js +2 -2
  109. package/dist/fondue-components9.js +65 -62
  110. package/dist/fondue-components9.js.map +1 -1
  111. package/dist/index.d.ts +96 -1
  112. package/dist/style.css +1 -1
  113. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components48.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 { SelectMenu } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } 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) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string;\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 aria label of the combobox component.\n */\n 'aria-label'?: string;\n /**\n * The data test id of the select component.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'aria-label': ariaLabel,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText } =\n useSelectData(children);\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 onSelectedItemChange: ({ selectedItem }) => {\n onSelect && onSelect(selectedItem.value);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\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 () => !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items],\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\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={valueInvalid ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': ariaLabel,\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 )}\n <div className={styles.icons}>\n <button\n {...getToggleButtonProps()}\n type=\"button\"\n aria-label=\"toggle menu\"\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 {valueInvalid || status === 'error' ? (\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 highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\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","ariaLabel","dataTestId","forwardedRef","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":";;;;;;;;;AAoDO,MAAMA,IAAiB,CAC1B;AAAA,EACI,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,cAAcC;AAAA,EACd,gBAAgBC,IAAa;AACjC,GACAC,MACC;AACK,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,YAAAC,GAAY,aAAAC,GAAa,gBAAAC,GAAgB,eAAAC,EAAA,IAC3EC,EAAcjB,CAAQ,GAEpB,CAACkB,GAA2BC,CAA4B,IAAIC,EAAS,EAAK,GAE1E;AAAA,IACF,eAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,YAAAC;AAAA,MACAC,EAAY;AAAA,IACZ,OAAAlB;AAAA,IACA,cAAcG,EAAeb,CAAK;AAAA,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,CACJ,EACJ,CAAA;AAAA,IAEA,gBAAAkC;AAAA,MAACS;AAAA,MAAA;AAAA,QACG,kBAAAvB;AAAA,QACA,YAAAf;AAAA,QACA,cAAAU;AAAA,QACA,cAAAC;AAAA,QACA,cAAAE;AAAA,QACA,2BAAAR;AAAA,QAEC,UAAAP;AAAA,MAAA;AAAA,IACL;AAAA,EACJ,EAAA,CAAA;AAER;AACAZ,EAAe,cAAc;AAEhB,MAAAqD,KAAuBC,EAA0CtD,CAAc;"}
1
+ {"version":3,"file":"fondue-components48.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -1,19 +1,143 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { IconCheckMark as l } from "@frontify/fondue-icons";
3
- import { forwardRef as a } from "react";
4
- import c from "./fondue-components52.js";
5
- const d = ({ "data-test-id": t = "fondue-select-item", ...e }, r) => /* @__PURE__ */ i("li", { "data-test-id": t, ref: r, ...e, children: [
6
- e.children,
7
- /* @__PURE__ */ o(l, { className: c.checkmarkIcon })
8
- ] });
9
- d.displayName = "Select.Item";
10
- const I = a(d), m = ({ children: t, groupId: e, "data-test-id": r = "fondue-select-item-group" }, s) => /* @__PURE__ */ o("div", { "data-test-id": r, className: c.group, ref: s, children: t }, e);
11
- m.displayName = "Select.Group";
12
- const S = a(m);
1
+ import { jsxs as u, jsx as t } from "react/jsx-runtime";
2
+ import { IconCaretDown as $, IconCheckMark as A, IconExclamationMarkTriangle as E } from "@frontify/fondue-icons";
3
+ import * as x from "@radix-ui/react-popover";
4
+ import { Slot as q } from "@radix-ui/react-slot";
5
+ import { useCombobox as G } from "downshift";
6
+ import { forwardRef as J, useState as K, useRef as Q, useMemo as U } from "react";
7
+ import { SelectMenu as W } from "./fondue-components51.js";
8
+ import o from "./fondue-components53.js";
9
+ import { useSelectData as X } from "./fondue-components54.js";
10
+ const w = ({
11
+ children: S,
12
+ onSelect: d,
13
+ value: N,
14
+ defaultValue: O,
15
+ placeholder: R = "",
16
+ status: n = "neutral",
17
+ disabled: m,
18
+ "aria-label": B,
19
+ "data-test-id": s = "fondue-select-combobox",
20
+ alignMenu: M = "start"
21
+ }, F) => {
22
+ const { inputSlots: L, menuSlots: P, items: l, filterText: k, clearButton: g, getItemByValue: p, setFilterText: v } = X(S), [y, f] = K(!1), {
23
+ getInputProps: c,
24
+ getToggleButtonProps: D,
25
+ getMenuProps: H,
26
+ getItemProps: T,
27
+ reset: h,
28
+ selectedItem: r,
29
+ isOpen: V,
30
+ highlightedIndex: z,
31
+ inputValue: i
32
+ } = G({
33
+ items: l,
34
+ selectedItem: p(N),
35
+ defaultSelectedItem: p(O),
36
+ defaultHighlightedIndex: 0,
37
+ onSelectedItemChange: ({ selectedItem: e }) => {
38
+ d && d(e.value);
39
+ },
40
+ onInputValueChange: ({ inputValue: e }) => {
41
+ v(e);
42
+ },
43
+ onIsOpenChange: () => {
44
+ f(!1);
45
+ },
46
+ onHighlightedIndexChange: () => {
47
+ f(!0);
48
+ },
49
+ itemToString: (e) => e ? e.label : ""
50
+ }), a = Q(!1), b = U(
51
+ () => !l.find((e) => e.label.toLowerCase().includes(i.toLowerCase())),
52
+ [i, l]
53
+ ), j = (e) => {
54
+ var C, I;
55
+ e.target.dataset.showFocusRing = "false", a.current = !1, (r == null ? void 0 : r.label.toLocaleLowerCase()) !== i.toLocaleLowerCase() && h(), c().onBlur && ((I = (C = c()).onBlur) == null || I.call(C, e));
56
+ };
57
+ return /* @__PURE__ */ u(x.Root, { open: V, children: [
58
+ /* @__PURE__ */ t(x.Anchor, { asChild: !0, children: /* @__PURE__ */ u("div", { ref: F, className: o.root, "data-status": b ? "error" : n, children: [
59
+ /* @__PURE__ */ t(
60
+ "input",
61
+ {
62
+ ...c({
63
+ "aria-label": B
64
+ }),
65
+ "data-test-id": s,
66
+ placeholder: R,
67
+ className: o.input,
68
+ disabled: m,
69
+ onMouseDown: (e) => {
70
+ a.current = !0, e.currentTarget.dataset.showFocusRing = "false";
71
+ },
72
+ onFocus: (e) => {
73
+ a.current || (e.target.dataset.showFocusRing = "true");
74
+ },
75
+ onBlur: j
76
+ }
77
+ ),
78
+ L,
79
+ g && /* @__PURE__ */ t(
80
+ q,
81
+ {
82
+ onClick: (e) => {
83
+ e.stopPropagation(), h();
84
+ },
85
+ className: o.clear,
86
+ role: "button",
87
+ children: g
88
+ }
89
+ ),
90
+ /* @__PURE__ */ u("div", { className: o.icons, children: [
91
+ /* @__PURE__ */ t(
92
+ "button",
93
+ {
94
+ ...D(),
95
+ type: "button",
96
+ "aria-label": "toggle menu",
97
+ disabled: m,
98
+ onMouseDown: () => {
99
+ a.current = !0;
100
+ },
101
+ children: /* @__PURE__ */ t($, { size: 16, className: o.caret })
102
+ }
103
+ ),
104
+ n === "success" ? /* @__PURE__ */ t(
105
+ A,
106
+ {
107
+ size: 16,
108
+ className: o.iconSuccess,
109
+ "data-test-id": `${s}-success-icon`
110
+ }
111
+ ) : null,
112
+ b || n === "error" ? /* @__PURE__ */ t(
113
+ E,
114
+ {
115
+ size: 16,
116
+ className: o.iconError,
117
+ "data-test-id": `${s}-error-icon`
118
+ }
119
+ ) : null
120
+ ] })
121
+ ] }) }),
122
+ /* @__PURE__ */ t(
123
+ W,
124
+ {
125
+ align: M,
126
+ highlightedIndex: z,
127
+ filterText: k,
128
+ getMenuProps: H,
129
+ getItemProps: T,
130
+ selectedItem: r,
131
+ hasInteractedSinceOpening: y,
132
+ children: P
133
+ }
134
+ )
135
+ ] });
136
+ };
137
+ w.displayName = "Select.Combobox";
138
+ const se = J(w);
13
139
  export {
14
- I as ForwardedRefSelectItem,
15
- S as ForwardedRefSelectItemGroup,
16
- d as SelectItem,
17
- m as SelectItemGroup
140
+ se as ForwardedRefCombobox,
141
+ w as SelectCombobox
18
142
  };
19
143
  //# sourceMappingURL=fondue-components49.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components49.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 {props.children}\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 data test id of the select item group.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectItemGroup = (\n { children, groupId, '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 {children}\n </div>\n );\n};\nSelectItemGroup.displayName = 'Select.Group';\n\nexport const ForwardedRefSelectItemGroup = forwardRef<HTMLDivElement, SelectItemGroupProps>(SelectItemGroup);\n"],"names":["SelectItem","dataTestId","props","forwardedRef","jsx","IconCheckMark","styles","ForwardedRefSelectItem","forwardRef","SelectItemGroup","children","groupId","ForwardedRefSelectItemGroup"],"mappings":";;;;AAiCa,MAAAA,IAAa,CACtB,EAAE,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAM,GAC9DC,wBAGK,MAAG,EAAA,gBAAcF,GAAY,KAAKE,GAAe,GAAGD,GAChD,UAAA;AAAA,EAAMA,EAAA;AAAA,EACN,gBAAAE,EAAAC,GAAA,EAAc,WAAWC,EAAO,cAAe,CAAA;AACpD,EAAA,CAAA;AAGRN,EAAW,cAAc;AAEZ,MAAAO,IAAyBC,EAA2CR,CAAU,GAiB9ES,IAAkB,CAC3B,EAAE,UAAAC,GAAU,SAAAC,GAAS,gBAAgBV,IAAa,2BAA2B,GAC7EE,MAGI,gBAAAC,EAAC,OAAI,EAAA,gBAAcH,GAAY,WAAWK,EAAO,OAAO,KAAKH,GACxD,UAAAO,EAAA,GAD2EC,CAEhF;AAGRF,EAAgB,cAAc;AAEjB,MAAAG,IAA8BJ,EAAiDC,CAAe;"}
1
+ {"version":3,"file":"fondue-components49.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 { SelectMenu } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } 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) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string;\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 /**\n * The aria label of the combobox component.\n */\n 'aria-label'?: string;\n /**\n * The data test id of the select component.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'aria-label': ariaLabel,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText } =\n useSelectData(children);\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 onSelectedItemChange: ({ selectedItem }) => {\n onSelect && onSelect(selectedItem.value);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\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 () => !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items],\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\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={valueInvalid ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': ariaLabel,\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 )}\n <div className={styles.icons}>\n <button\n {...getToggleButtonProps()}\n type=\"button\"\n aria-label=\"toggle menu\"\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 {valueInvalid || status === 'error' ? (\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 highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\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","ariaLabel","dataTestId","alignMenu","forwardedRef","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":";;;;;;;;;AAyDO,MAAMA,IAAiB,CAC1B;AAAA,EACI,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,cAAcC;AAAA,EACd,gBAAgBC,IAAa;AAAA,EAC7B,WAAAC,IAAY;AAChB,GACAC,MACC;AACK,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,YAAAC,GAAY,aAAAC,GAAa,gBAAAC,GAAgB,eAAAC,EAAA,IAC3EC,EAAclB,CAAQ,GAEpB,CAACmB,GAA2BC,CAA4B,IAAIC,EAAS,EAAK,GAE1E;AAAA,IACF,eAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,YAAAC;AAAA,MACAC,EAAY;AAAA,IACZ,OAAAlB;AAAA,IACA,cAAcG,EAAed,CAAK;AAAA,IAClC,qBAAqBc,EAAeb,CAAY;AAAA,IAChD,yBAAyB;AAAA,IACzB,sBAAsB,CAAC,EAAE,cAAAwB,QAAmB;AAC5B,MAAA1B,KAAAA,EAAS0B,EAAa,K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AAAU;AAAA,QACA,cAAAC;AAAA,QACA,cAAAE;AAAA,QACA,2BAAAR;AAAA,QAEC,UAAAP;AAAA,MAAA;AAAA,IACL;AAAA,EACJ,EAAA,CAAA;AAER;AACAb,EAAe,cAAc;AAEhB,MAAAsD,KAAuBC,EAA0CvD,CAAc;"}
@@ -2,8 +2,8 @@ import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
2
  import { IconMinus as m, IconCheckMark as h } from "@frontify/fondue-icons";
3
3
  import * as o from "@radix-ui/react-checkbox";
4
4
  import { forwardRef as k } from "react";
5
- import { cn as p } from "./fondue-components25.js";
6
- import { checkboxStyles as l, checkboxIndicatorStyles as w } from "./fondue-components29.js";
5
+ import { cn as p } from "./fondue-components26.js";
6
+ import { checkboxStyles as l, checkboxIndicatorStyles as w } from "./fondue-components30.js";
7
7
  const f = ({
8
8
  className: a,
9
9
  value: c,
@@ -1,65 +1,19 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import * as l from "@radix-ui/react-popover";
3
- import { Slot as S } from "@radix-ui/react-slot";
4
- import { useRef as g, isValidElement as C } from "react";
5
- import { usePreventDropdownOverflow as M } from "./fondue-components38.js";
6
- import n from "./fondue-components52.js";
7
- import { recursiveMap as N, getSelectOptionValue as P } from "./fondue-components60.js";
8
- const V = ({
9
- highlightedIndex: p,
10
- getMenuProps: u,
11
- getItemProps: m,
12
- children: f,
13
- filterText: c,
14
- selectedItem: r,
15
- hasInteractedSinceOpening: d
16
- }) => {
17
- const s = g(null), { setMaxHeight: v } = M(s), h = (e) => {
18
- e.preventDefault(), v();
19
- };
20
- return /* @__PURE__ */ t(l.Portal, { children: /* @__PURE__ */ t(l.Content, { onOpenAutoFocus: h, className: n.portal, children: /* @__PURE__ */ t(
21
- "ul",
22
- {
23
- className: n.menu,
24
- ...u(),
25
- ref: s,
26
- "data-has-interacted": d ? "true" : "false",
27
- "data-test-id": "fondue-select-menu",
28
- children: N(
29
- f,
30
- (e, i) => {
31
- if (((o) => (
32
- // @ts-expect-error - We are explicitly checking for ref
33
- C(o) && o.ref !== void 0
34
- ))(e)) {
35
- const o = P(e.props), a = m({
36
- item: o,
37
- index: i,
38
- ...e.ref ? { ref: e.ref } : {}
39
- });
40
- return /* @__PURE__ */ t(
41
- S,
42
- {
43
- className: n.item,
44
- "data-highlighted": p === i,
45
- "data-selected": (r == null ? void 0 : r.value) === o.value,
46
- onTouchStart: (O) => {
47
- a.onClick && a.onClick(O);
48
- },
49
- ...a,
50
- children: e
51
- },
52
- e.props.value
53
- );
54
- }
55
- },
56
- c
57
- ).parsedChildren
58
- }
59
- ) }) });
60
- };
61
- V.displayName = "Select.Menu";
1
+ import { jsxs as i, jsx as a } from "react/jsx-runtime";
2
+ import { IconCheckMark as l } from "@frontify/fondue-icons";
3
+ import { forwardRef as c } from "react";
4
+ import o from "./fondue-components53.js";
5
+ const d = ({ "data-test-id": t = "fondue-select-item", ...e }, r) => /* @__PURE__ */ i("li", { "data-test-id": t, ref: r, ...e, children: [
6
+ /* @__PURE__ */ a("div", { className: o.itemValue, children: e.children }),
7
+ /* @__PURE__ */ a(l, { className: o.checkmarkIcon })
8
+ ] });
9
+ d.displayName = "Select.Item";
10
+ const I = c(d), m = ({ children: t, groupId: e, "data-test-id": r = "fondue-select-item-group" }, s) => /* @__PURE__ */ a("div", { "data-test-id": r, className: o.group, ref: s, children: t }, e);
11
+ m.displayName = "Select.Group";
12
+ const S = c(m);
62
13
  export {
63
- V as SelectMenu
14
+ I as ForwardedRefSelectItem,
15
+ S as ForwardedRefSelectItemGroup,
16
+ d as SelectItem,
17
+ m as SelectItemGroup
64
18
  };
65
19
  //# sourceMappingURL=fondue-components50.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components50.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, useRef, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\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 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\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n selectedItem,\n hasInteractedSinceOpening,\n}: SelectMenuProps) => {\n const ref = useRef<HTMLUListElement | null>(null);\n\n const { setMaxHeight } = usePreventDropdownOverflow(ref);\n\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n setMaxHeight();\n };\n\n return (\n <RadixPopover.Portal>\n <RadixPopover.Content onOpenAutoFocus={handleOnOpenAutoFocus} className={styles.portal}>\n <ul\n className={styles.menu}\n {...getMenuProps()}\n ref={ref}\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 </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","selectedItem","hasInteractedSinceOpening","ref","useRef","setMaxHeight","usePreventDropdownOverflow","handleOnOpenAutoFocus","event","jsx","RadixPopover","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AAsDO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,2BAAAC;AACJ,MAAuB;AACb,QAAAC,IAAMC,EAAgC,IAAI,GAE1C,EAAE,cAAAC,EAAA,IAAiBC,EAA2BH,CAAG,GAEjDI,IAAwB,CAACC,MAAiB;AAC5C,IAAAA,EAAM,eAAe,GACRH;EAAA;AAGjB,SACK,gBAAAI,EAAAC,EAAa,QAAb,EACG,UAAC,gBAAAD,EAAAC,EAAa,SAAb,EAAqB,iBAAiBH,GAAuB,WAAWI,EAAO,QAC5E,UAAA,gBAAAF;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAWE,EAAO;AAAA,MACjB,GAAGd,EAAa;AAAA,MACjB,KAAAM;AAAA,MACA,uBAAqBD,IAA4B,SAAS;AAAA,MAC1D,gBAAa;AAAA,MAGT,UAAAU;AAAA,QACIb;AAAA,QACA,CAACc,GAAOC,MAAU;AAOV,eANY,CACZD;AAAAA;AAAAA,YAGAE,EAAuBF,CAAK,KAAKA,EAAM,QAAQ;AAAA,aAEtBA,CAAK,GAAG;AAC3B,kBAAAG,IAAaC,EAAqBJ,EAAM,KAAK,GAC7CK,IAAYpB,EAAa;AAAA,cAC3B,MAAMkB;AAAA,cACN,OAAAF;AAAA,cACA,GAAID,EAAM,MAAM,EAAE,KAAKA,EAAM,IAAA,IAAQ,CAAC;AAAA,YAAA,CACzC;AAGG,mBAAA,gBAAAJ;AAAA,cAACU;AAAAA,cAAA;AAAA,gBACG,WAAWR,EAAO;AAAA,gBAClB,oBAAkBf,MAAqBkB;AAAA,gBACvC,kBAAeb,KAAA,gBAAAA,EAAc,WAAUe,EAAW;AAAA,gBAGlD,cAAc,CAACR,MAAU;AACrB,kBAAIU,EAAU,WACVA,EAAU,QAAQV,CAA2C;AAAA,gBAErE;AAAA,gBACC,GAAGU;AAAA,gBAEH,UAAAL;AAAA,cAAA;AAAA,cATIA,EAAM,MAAM;AAAA,YAAA;AAAA,UAY7B;AAAA,QACJ;AAAA,QACAb;AAAA,MAAA,EACF;AAAA,IAAA;AAAA,EAAA,EAGd,CAAA,EACJ,CAAA;AAER;AACAL,EAAW,cAAc;"}
1
+ {"version":3,"file":"fondue-components50.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 data test id of the select item group.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectItemGroup = (\n { children, groupId, '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 {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","ForwardedRefSelectItemGroup"],"mappings":";;;;AAiCa,MAAAA,IAAa,CACtB,EAAE,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAM,GAC9DC,wBAGK,MAAG,EAAA,gBAAcF,GAAY,KAAKE,GAAe,GAAGD,GACjD,UAAA;AAAA,EAAA,gBAAAE,EAAC,OAAI,EAAA,WAAWC,EAAO,WAAY,YAAM,UAAS;AAAA,EACjD,gBAAAD,EAAAE,GAAA,EAAc,WAAWD,EAAO,cAAe,CAAA;AACpD,EAAA,CAAA;AAGRL,EAAW,cAAc;AAEZ,MAAAO,IAAyBC,EAA2CR,CAAU,GAiB9ES,IAAkB,CAC3B,EAAE,UAAAC,GAAU,SAAAC,GAAS,gBAAgBV,IAAa,2BAA2B,GAC7EE,MAGI,gBAAAC,EAAC,OAAI,EAAA,gBAAcH,GAAY,WAAWI,EAAO,OAAO,KAAKF,GACxD,UAAAO,EAAA,GAD2EC,CAEhF;AAGRF,EAAgB,cAAc;AAEjB,MAAAG,IAA8BJ,EAAiDC,CAAe;"}
@@ -1,11 +1,75 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { forwardRef as d } from "react";
3
- import m from "./fondue-components52.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);
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import * as l from "@radix-ui/react-popover";
3
+ import { Slot as P } from "@radix-ui/react-slot";
4
+ import { useRef as S, isValidElement as C } from "react";
5
+ import { usePreventDropdownOverflow as M } from "./fondue-components39.js";
6
+ import n from "./fondue-components53.js";
7
+ import { recursiveMap as N, getSelectOptionValue as V } from "./fondue-components62.js";
8
+ const x = ({
9
+ highlightedIndex: p,
10
+ getMenuProps: u,
11
+ getItemProps: m,
12
+ children: f,
13
+ filterText: c,
14
+ align: d,
15
+ selectedItem: r,
16
+ hasInteractedSinceOpening: v
17
+ }) => {
18
+ const s = S(null), { setMaxHeight: h } = M(s), g = (e) => {
19
+ e.preventDefault(), h();
20
+ };
21
+ return /* @__PURE__ */ t(l.Portal, { children: /* @__PURE__ */ t(
22
+ l.Content,
23
+ {
24
+ align: d,
25
+ collisionPadding: 16,
26
+ onOpenAutoFocus: g,
27
+ className: n.portal,
28
+ children: /* @__PURE__ */ t(
29
+ "ul",
30
+ {
31
+ className: n.menu,
32
+ ...u(),
33
+ ref: s,
34
+ "data-has-interacted": v ? "true" : "false",
35
+ "data-test-id": "fondue-select-menu",
36
+ children: N(
37
+ f,
38
+ (e, i) => {
39
+ if (((o) => (
40
+ // @ts-expect-error - We are explicitly checking for ref
41
+ C(o) && o.ref !== void 0
42
+ ))(e)) {
43
+ const o = V(e.props), a = m({
44
+ item: o,
45
+ index: i,
46
+ ...e.ref ? { ref: e.ref } : {}
47
+ });
48
+ return /* @__PURE__ */ t(
49
+ P,
50
+ {
51
+ className: n.item,
52
+ "data-highlighted": p === i,
53
+ "data-selected": (r == null ? void 0 : r.value) === o.value,
54
+ onTouchStart: (O) => {
55
+ a.onClick && a.onClick(O);
56
+ },
57
+ ...a,
58
+ children: e
59
+ },
60
+ e.props.value
61
+ );
62
+ }
63
+ },
64
+ c
65
+ ).parsedChildren
66
+ }
67
+ )
68
+ }
69
+ ) });
70
+ };
71
+ x.displayName = "Select.Menu";
7
72
  export {
8
- S as ForwardedRefSelectSlot,
9
- t as SelectSlot
73
+ x as SelectMenu
10
74
  };
11
75
  //# sourceMappingURL=fondue-components51.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components51.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":";;;AAqBa,MAAAA,IAAa,CACtB,EAAE,UAAAC,GAAU,MAAAC,GAAM,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAM,GAC9EC,MAGK,gBAAAC,EAAA,OAAA,EAAI,gBAAcH,GAAY,KAAKE,GAAc,WAAWE,EAAO,MAAM,aAAWL,GAAO,GAAGE,GAC1F,UAAAH,EACL,CAAA;AAGRD,EAAW,cAAc;AAEZ,MAAAQ,IAAyBC,EAA4CT,CAAU;"}
1
+ {"version":3,"file":"fondue-components51.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, useRef, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\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 * 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\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n selectedItem,\n hasInteractedSinceOpening,\n}: SelectMenuProps) => {\n const ref = useRef<HTMLUListElement | null>(null);\n\n const { setMaxHeight } = usePreventDropdownOverflow(ref);\n\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n setMaxHeight();\n };\n\n return (\n <RadixPopover.Portal>\n <RadixPopover.Content\n align={align}\n collisionPadding={16}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n className={styles.portal}\n >\n <ul\n className={styles.menu}\n {...getMenuProps()}\n ref={ref}\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 </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","align","selectedItem","hasInteractedSinceOpening","ref","useRef","setMaxHeight","usePreventDropdownOverflow","handleOnOpenAutoFocus","event","jsx","RadixPopover","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AA2DO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,2BAAAC;AACJ,MAAuB;AACb,QAAAC,IAAMC,EAAgC,IAAI,GAE1C,EAAE,cAAAC,EAAA,IAAiBC,EAA2BH,CAAG,GAEjDI,IAAwB,CAACC,MAAiB;AAC5C,IAAAA,EAAM,eAAe,GACRH;EAAA;AAIb,SAAA,gBAAAI,EAACC,EAAa,QAAb,EACG,UAAA,gBAAAD;AAAA,IAACC,EAAa;AAAA,IAAb;AAAA,MACG,OAAAV;AAAA,MACA,kBAAkB;AAAA,MAClB,iBAAiBO;AAAA,MACjB,WAAWI,EAAO;AAAA,MAElB,UAAA,gBAAAF;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,WAAWE,EAAO;AAAA,UACjB,GAAGf,EAAa;AAAA,UACjB,KAAAO;AAAA,UACA,uBAAqBD,IAA4B,SAAS;AAAA,UAC1D,gBAAa;AAAA,UAGT,UAAAU;AAAA,YACId;AAAA,YACA,CAACe,GAAOC,MAAU;AAOV,mBANY,CACZD;AAAAA;AAAAA,gBAGAE,EAAuBF,CAAK,KAAKA,EAAM,QAAQ;AAAA,iBAEtBA,CAAK,GAAG;AAC3B,sBAAAG,IAAaC,EAAqBJ,EAAM,KAAK,GAC7CK,IAAYrB,EAAa;AAAA,kBAC3B,MAAMmB;AAAA,kBACN,OAAAF;AAAA,kBACA,GAAID,EAAM,MAAM,EAAE,KAAKA,EAAM,IAAA,IAAQ,CAAC;AAAA,gBAAA,CACzC;AAGG,uBAAA,gBAAAJ;AAAA,kBAACU;AAAAA,kBAAA;AAAA,oBACG,WAAWR,EAAO;AAAA,oBAClB,oBAAkBhB,MAAqBmB;AAAA,oBACvC,kBAAeb,KAAA,gBAAAA,EAAc,WAAUe,EAAW;AAAA,oBAGlD,cAAc,CAACR,MAAU;AACrB,sBAAIU,EAAU,WACVA,EAAU,QAAQV,CAA2C;AAAA,oBAErE;AAAA,oBACC,GAAGU;AAAA,oBAEH,UAAAL;AAAA,kBAAA;AAAA,kBATIA,EAAM,MAAM;AAAA,gBAAA;AAAA,cAY7B;AAAA,YACJ;AAAA,YACAd;AAAA,UAAA,EACF;AAAA,QAAA;AAAA,MAEV;AAAA,IAAA;AAAA,EAER,EAAA,CAAA;AAER;AACAL,EAAW,cAAc;"}
@@ -1,32 +1,11 @@
1
- const n = "_root_1nim9_5", o = "_input_1nim9_59", c = "_slot_1nim9_78", _ = "_clear_1nim9_127", t = "_icons_1nim9_140", s = "_caret_1nim9_146", i = "_iconSuccess_1nim9_168", r = "_iconError_1nim9_174", m = "_menu_1nim9_180", e = "_portal_1nim9_194", a = "_item_1nim9_198", u = "_checkmarkIcon_1nim9_217", l = "_group_1nim9_231", p = {
2
- root: n,
3
- input: o,
4
- slot: c,
5
- clear: _,
6
- icons: t,
7
- caret: s,
8
- iconSuccess: i,
9
- iconError: r,
10
- menu: m,
11
- portal: e,
12
- item: a,
13
- checkmarkIcon: u,
14
- group: l
15
- };
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as d } from "react";
3
+ import m from "./fondue-components53.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);
16
7
  export {
17
- s as caret,
18
- u as checkmarkIcon,
19
- _ as clear,
20
- p as default,
21
- l as group,
22
- r as iconError,
23
- i as iconSuccess,
24
- t as icons,
25
- o as input,
26
- a as item,
27
- m as menu,
28
- e as portal,
29
- n as root,
30
- c as slot
8
+ S as ForwardedRefSelectSlot,
9
+ t as SelectSlot
31
10
  };
32
11
  //# sourceMappingURL=fondue-components52.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components52.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"fondue-components52.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":";;;AAqBa,MAAAA,IAAa,CACtB,EAAE,UAAAC,GAAU,MAAAC,GAAM,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAM,GAC9EC,MAGK,gBAAAC,EAAA,OAAA,EAAI,gBAAcH,GAAY,KAAKE,GAAc,WAAWE,EAAO,MAAM,aAAWL,GAAO,GAAGE,GAC1F,UAAAH,EACL,CAAA;AAGRD,EAAW,cAAc;AAEZ,MAAAQ,IAAyBC,EAA4CT,CAAU;"}
@@ -1,52 +1,36 @@
1
- import { jsx as w } from "react/jsx-runtime";
2
- import { IconCross as x } from "@frontify/fondue-icons";
3
- import { useState as B, useMemo as i, Children as f, isValidElement as a, cloneElement as E, useCallback as v } from "react";
4
- import { ForwardedRefSelectItem as F } from "./fondue-components49.js";
5
- import { ForwardedRefSelectSlot as c } from "./fondue-components51.js";
6
- import { getSelectOptionValue as I } from "./fondue-components60.js";
7
- const S = (r) => {
8
- const t = [];
9
- return f.forEach(r, (o) => {
10
- if (a(o) && o.type === F)
11
- t.push(I(o.props));
12
- else if (a(o) && o.props.children) {
13
- const u = S(o.props.children);
14
- for (const l of u)
15
- t.push(l);
16
- }
17
- }), t;
18
- }, z = (r) => {
19
- const [t, o] = B(""), { inputSlots: u, menuSlots: l, itemValues: p, clearButton: V } = i(() => {
20
- const s = [], n = [];
21
- let m;
22
- f.toArray(r).some(
23
- (e) => a(e) && e.type === c
24
- ) ? f.forEach(r, (e) => {
25
- a(e) && e.type === c && (e.props.name === "menu" ? n.push(e.props.children) : e.props.name === "left" || e.props.name === "right" ? s.push(e) : e.props.name === "clear" && (e.props.children ? m = e : m = E(e, { children: /* @__PURE__ */ w(x, { size: 16 }) })));
26
- }) : n.push(r);
27
- const g = S(n);
28
- return { inputSlots: s, menuSlots: n, itemValues: g, clearButton: m };
29
- }, [r]), y = i(
30
- () => p.filter(
31
- (s) => t === "" || s.label.toLowerCase().includes(t.toLowerCase())
32
- ),
33
- [p, t]
34
- ), C = v(
35
- (s) => s ? p.find((n) => n.value === s) : void 0,
36
- [p]
37
- );
38
- return {
39
- items: y,
40
- menuSlots: l,
41
- filterText: t,
42
- inputSlots: u,
43
- clearButton: V,
44
- setFilterText: o,
45
- getItemByValue: C
46
- };
1
+ const c = "_root_1pv0q_6", o = "_selectedValue_1pv0q_68", _ = "_input_1pv0q_80", t = "_slot_1pv0q_106", e = "_clear_1pv0q_158", n = "_icons_1pv0q_171", s = "_caret_1pv0q_177", r = "_iconSuccess_1pv0q_205", p = "_iconError_1pv0q_211", a = "_menu_1pv0q_217", l = "_portal_1pv0q_237", u = "_item_1pv0q_241", i = "_checkmarkIcon_1pv0q_266", q = "_itemValue_1pv0q_273", v = "_group_1pv0q_287", m = {
2
+ root: c,
3
+ selectedValue: o,
4
+ input: _,
5
+ slot: t,
6
+ clear: e,
7
+ icons: n,
8
+ caret: s,
9
+ iconSuccess: r,
10
+ iconError: p,
11
+ menu: a,
12
+ portal: l,
13
+ item: u,
14
+ checkmarkIcon: i,
15
+ itemValue: q,
16
+ group: v
47
17
  };
48
18
  export {
49
- S as getRecursiveOptionValues,
50
- z as useSelectData
19
+ s as caret,
20
+ i as checkmarkIcon,
21
+ e as clear,
22
+ m as default,
23
+ v as group,
24
+ p as iconError,
25
+ r as iconSuccess,
26
+ n as icons,
27
+ _ as input,
28
+ u as item,
29
+ q as itemValue,
30
+ a as menu,
31
+ l as portal,
32
+ c as root,
33
+ o as selectedValue,
34
+ t as slot
51
35
  };
52
36
  //# sourceMappingURL=fondue-components53.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components53.js","sources":["../src/components/Select/useSelectData.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport { Children, cloneElement, isValidElement, useCallback, useMemo, useState, type ReactNode } 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\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 = (children: ReactNode): { value: string; label: string }[] => {\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 * @returns {Object} An object containing the processed data.\n */\nexport const useSelectData = (children: ReactNode) => {\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) => (value ? itemValues.find((item) => item.value === value) : undefined),\n [itemValues],\n );\n\n return {\n items,\n menuSlots,\n filterText,\n inputSlots,\n clearButton,\n setFilterText,\n getItemByValue,\n };\n};\n"],"names":["getRecursiveOptionValues","children","values","Children","child","isValidElement","ForwardedRefSelectItem","getSelectOptionValue","optionValues","optionValue","useSelectData","filterText","setFilterText","useState","inputSlots","menuSlots","itemValues","clearButton","useMemo","ForwardedRefSelectSlot","cloneElement","IconCross","items","item","getItemByValue","useCallback","value"],"mappings":";;;;;;AA6Ba,MAAAA,IAA2B,CAACC,MAA4D;AACjG,QAAMC,IAA6C,CAAA;AAC1C,SAAAC,EAAA,QAAQF,GAAU,CAACG,MAAU;AAClC,QAAIC,EAAgCD,CAAK,KAAKA,EAAM,SAASE;AACzD,MAAAJ,EAAO,KAAKK,EAAqBH,EAAM,KAAK,CAAC;AAAA,aACtCC,EAAwCD,CAAK,KAAKA,EAAM,MAAM,UAAU;AAC/E,YAAMI,IAAeR,EAAyBI,EAAM,MAAM,QAAQ;AAClE,iBAAWK,KAAeD;AACtB,QAAAN,EAAO,KAAKO,CAAW;AAAA,IAE/B;AAAA,EAAA,CACH,GACMP;AACX,GAQaQ,IAAgB,CAACT,MAAwB;AAClD,QAAM,CAACU,GAAYC,CAAa,IAAIC,EAAS,EAAE,GACzC,EAAE,YAAAC,GAAY,WAAAC,GAAW,YAAAC,GAAY,aAAAC,EAAY,IAAIC,EAAQ,MAAM;AACrE,UAAMJ,IAA0B,CAAA,GAC1BC,IAAyB,CAAA;AAC3BE,QAAAA;AAMJ,IAJiBd,EAAS,QAAQF,CAAQ,EAAE;AAAA,MACxC,CAACG,MAAUC,EAAgCD,CAAK,KAAKA,EAAM,SAASe;AAAA,IAAA,IAI3DhB,EAAA,QAAQF,GAAU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