@frontify/fondue-components 19.1.0 → 19.2.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.
Files changed (98) hide show
  1. package/dist/fondue-components10.js +23 -19
  2. package/dist/fondue-components10.js.map +1 -1
  3. package/dist/fondue-components11.js +2 -2
  4. package/dist/fondue-components12.js +1 -1
  5. package/dist/fondue-components13.js +34 -24
  6. package/dist/fondue-components13.js.map +1 -1
  7. package/dist/fondue-components14.js +1 -1
  8. package/dist/fondue-components15.js +1 -1
  9. package/dist/fondue-components17.js +1 -1
  10. package/dist/fondue-components18.js +1 -1
  11. package/dist/fondue-components19.js +1 -1
  12. package/dist/fondue-components20.js +1 -1
  13. package/dist/fondue-components21.js +2 -2
  14. package/dist/fondue-components22.js +6 -6
  15. package/dist/fondue-components23.js +1 -1
  16. package/dist/fondue-components24.js +1 -1
  17. package/dist/fondue-components25.js +3 -3
  18. package/dist/fondue-components26.js +3 -3
  19. package/dist/fondue-components27.js +1 -1
  20. package/dist/fondue-components28.js +31 -29
  21. package/dist/fondue-components28.js.map +1 -1
  22. package/dist/fondue-components29.js +1 -1
  23. package/dist/fondue-components30.js +1 -1
  24. package/dist/fondue-components37.js +1 -1
  25. package/dist/fondue-components40.js +1 -1
  26. package/dist/fondue-components42.js +1 -1
  27. package/dist/fondue-components49.js +5 -60
  28. package/dist/fondue-components49.js.map +1 -1
  29. package/dist/fondue-components50.js +59 -17
  30. package/dist/fondue-components50.js.map +1 -1
  31. package/dist/fondue-components51.js +18 -19
  32. package/dist/fondue-components51.js.map +1 -1
  33. package/dist/fondue-components52.js +18 -4
  34. package/dist/fondue-components52.js.map +1 -1
  35. package/dist/fondue-components53.js +3 -13
  36. package/dist/fondue-components53.js.map +1 -1
  37. package/dist/fondue-components54.js +13 -3
  38. package/dist/fondue-components54.js.map +1 -1
  39. package/dist/fondue-components55.js +3 -17
  40. package/dist/fondue-components55.js.map +1 -1
  41. package/dist/fondue-components56.js +19 -35
  42. package/dist/fondue-components56.js.map +1 -1
  43. package/dist/fondue-components57.js +35 -5
  44. package/dist/fondue-components57.js.map +1 -1
  45. package/dist/fondue-components58.js +4 -12
  46. package/dist/fondue-components58.js.map +1 -1
  47. package/dist/fondue-components59.js +12 -4
  48. package/dist/fondue-components59.js.map +1 -1
  49. package/dist/fondue-components60.js +4 -24
  50. package/dist/fondue-components60.js.map +1 -1
  51. package/dist/fondue-components61.js +24 -16
  52. package/dist/fondue-components61.js.map +1 -1
  53. package/dist/fondue-components62.js +16 -146
  54. package/dist/fondue-components62.js.map +1 -1
  55. package/dist/fondue-components63.js +151 -19
  56. package/dist/fondue-components63.js.map +1 -1
  57. package/dist/fondue-components64.js +19 -77
  58. package/dist/fondue-components64.js.map +1 -1
  59. package/dist/fondue-components65.js +77 -8
  60. package/dist/fondue-components65.js.map +1 -1
  61. package/dist/fondue-components66.js +8 -35
  62. package/dist/fondue-components66.js.map +1 -1
  63. package/dist/fondue-components67.js +34 -48
  64. package/dist/fondue-components67.js.map +1 -1
  65. package/dist/fondue-components68.js +70 -10
  66. package/dist/fondue-components68.js.map +1 -1
  67. package/dist/fondue-components69.js +8 -10
  68. package/dist/fondue-components69.js.map +1 -1
  69. package/dist/fondue-components70.js +12 -12
  70. package/dist/fondue-components70.js.map +1 -1
  71. package/dist/fondue-components71.js +12 -20
  72. package/dist/fondue-components71.js.map +1 -1
  73. package/dist/fondue-components72.js +21 -29
  74. package/dist/fondue-components72.js.map +1 -1
  75. package/dist/fondue-components73.js +28 -55
  76. package/dist/fondue-components73.js.map +1 -1
  77. package/dist/fondue-components74.js +55 -14
  78. package/dist/fondue-components74.js.map +1 -1
  79. package/dist/fondue-components75.js +14 -25
  80. package/dist/fondue-components75.js.map +1 -1
  81. package/dist/fondue-components76.js +24 -13
  82. package/dist/fondue-components76.js.map +1 -1
  83. package/dist/fondue-components77.js +14 -6
  84. package/dist/fondue-components77.js.map +1 -1
  85. package/dist/fondue-components78.js +6 -6
  86. package/dist/fondue-components79.js +7 -2
  87. package/dist/fondue-components79.js.map +1 -1
  88. package/dist/fondue-components82.js +2 -17
  89. package/dist/fondue-components82.js.map +1 -1
  90. package/dist/fondue-components83.js +16 -39
  91. package/dist/fondue-components83.js.map +1 -1
  92. package/dist/fondue-components84.js +43 -0
  93. package/dist/fondue-components84.js.map +1 -0
  94. package/dist/fondue-components9.js +77 -66
  95. package/dist/fondue-components9.js.map +1 -1
  96. package/dist/index.d.ts +16 -1
  97. package/dist/style.css +1 -1
  98. package/package.json +3 -3
@@ -1,150 +1,20 @@
1
- import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
- import { IconCaretDown as q, IconCheckMark as G, IconExclamationMarkTriangle as J } from "@frontify/fondue-icons";
3
- import * as N from "@radix-ui/react-popover";
4
- import { Slot as K } from "@radix-ui/react-slot";
5
- import { useCombobox as Q } from "downshift";
6
- import { forwardRef as U, useState as W, useRef as X, useMemo as Y } from "react";
7
- import { SelectMenu as Z } from "./fondue-components64.js";
8
- import o from "./fondue-components66.js";
9
- import { useSelectData as _ } from "./fondue-components67.js";
10
- const S = ({
11
- children: B,
12
- onSelect: l,
13
- value: O,
14
- defaultValue: R,
15
- placeholder: v = "",
16
- status: s = "neutral",
17
- disabled: g,
18
- "data-test-id": i = "fondue-select-combobox",
19
- alignMenu: M = "start",
20
- side: y = "bottom",
21
- id: F,
22
- viewportCollisionPadding: L = "compact",
23
- ...a
24
- }, P) => {
25
- const { inputSlots: k, menuSlots: D, items: c, filterText: H, clearButton: f, getItemByValue: p, setFilterText: h } = _(B), [T, b] = W(!1), {
26
- getInputProps: u,
27
- getToggleButtonProps: V,
28
- getMenuProps: z,
29
- getItemProps: j,
30
- reset: C,
31
- selectedItem: r,
32
- isOpen: $,
33
- highlightedIndex: A,
34
- inputValue: d
35
- } = Q({
36
- items: c,
37
- selectedItem: p(O),
38
- defaultSelectedItem: p(R),
39
- defaultHighlightedIndex: 0,
40
- toggleButtonId: F,
41
- labelId: "aria-labelledby" in a ? a["aria-labelledby"] : void 0,
42
- onSelectedItemChange: ({ selectedItem: e }) => {
43
- l == null || l((e == null ? void 0 : e.value) ?? null);
44
- },
45
- onInputValueChange: ({ inputValue: e }) => {
46
- h(e);
47
- },
48
- onIsOpenChange: () => {
49
- b(!1), h("");
50
- },
51
- onHighlightedIndexChange: () => {
52
- b(!0);
53
- },
54
- itemToString: (e) => e ? e.label : ""
55
- }), n = X(!1), x = Y(
56
- () => !c.find((e) => e.label.toLowerCase().includes(d.toLowerCase())),
57
- [d, c]
58
- ), E = (e) => {
59
- var I, w;
60
- e.target.dataset.showFocusRing = "false", n.current = !1, (r == null ? void 0 : r.label.toLocaleLowerCase()) !== d.toLocaleLowerCase() && C(), u().onBlur && ((w = (I = u()).onBlur) == null || w.call(I, e));
61
- };
62
- return /* @__PURE__ */ m(N.Root, { open: $, children: [
63
- /* @__PURE__ */ t(N.Anchor, { asChild: !0, children: /* @__PURE__ */ m("div", { ref: P, className: o.root, "data-status": x ? "error" : s, children: [
64
- /* @__PURE__ */ t(
65
- "input",
66
- {
67
- ...u({
68
- "aria-label": "aria-label" in a ? a["aria-label"] : void 0
69
- }),
70
- "data-test-id": i,
71
- placeholder: v,
72
- className: o.input,
73
- disabled: g,
74
- onMouseDown: (e) => {
75
- n.current = !0, e.currentTarget.dataset.showFocusRing = "false";
76
- },
77
- onFocus: (e) => {
78
- n.current || (e.target.dataset.showFocusRing = "true");
79
- },
80
- onBlur: E
81
- }
82
- ),
83
- k,
84
- f && /* @__PURE__ */ t(
85
- K,
86
- {
87
- onClick: (e) => {
88
- e.stopPropagation(), C();
89
- },
90
- className: o.clear,
91
- role: "button",
92
- children: f
93
- }
94
- ),
95
- /* @__PURE__ */ m("div", { className: o.icons, children: [
96
- /* @__PURE__ */ t(
97
- "button",
98
- {
99
- "aria-label": "toggle menu",
100
- ...V(),
101
- type: "button",
102
- disabled: g,
103
- onMouseDown: () => {
104
- n.current = !0;
105
- },
106
- children: /* @__PURE__ */ t(q, { size: 16, className: o.caret })
107
- }
108
- ),
109
- s === "success" ? /* @__PURE__ */ t(
110
- G,
111
- {
112
- size: 16,
113
- className: o.iconSuccess,
114
- "data-test-id": `${i}-success-icon`
115
- }
116
- ) : null,
117
- x || s === "error" ? /* @__PURE__ */ t(
118
- J,
119
- {
120
- size: 16,
121
- className: o.iconError,
122
- "data-test-id": `${i}-error-icon`
123
- }
124
- ) : null
125
- ] })
126
- ] }) }),
127
- /* @__PURE__ */ t(
128
- Z,
129
- {
130
- align: M,
131
- side: y,
132
- highlightedIndex: A,
133
- filterText: H,
134
- getMenuProps: z,
135
- getItemProps: j,
136
- selectedItem: r,
137
- hasInteractedSinceOpening: T,
138
- viewportCollisionPadding: L,
139
- children: D
140
- }
141
- )
142
- ] });
1
+ const t = "_root_1yzu4_5", e = "_item_1yzu4_30", a = "_itemLabel_1yzu4_50", i = "_itemLabelActive_1yzu4_70", o = "_itemLabelInactive_1yzu4_100", _ = "_activeIndicator_1yzu4_130", c = "_separator_1yzu4_227", n = {
2
+ root: t,
3
+ item: e,
4
+ itemLabel: a,
5
+ itemLabelActive: i,
6
+ itemLabelInactive: o,
7
+ activeIndicator: _,
8
+ separator: c
143
9
  };
144
- S.displayName = "Select.Combobox";
145
- const ce = U(S);
146
10
  export {
147
- ce as ForwardedRefCombobox,
148
- S as SelectCombobox
11
+ _ as activeIndicator,
12
+ n as default,
13
+ e as item,
14
+ a as itemLabel,
15
+ i as itemLabelActive,
16
+ o as itemLabelInactive,
17
+ t as root,
18
+ c as separator
149
19
  };
150
20
  //# sourceMappingURL=fondue-components62.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components62.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 { type CommonAriaProps } from '#/helpers/aria';\n\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } 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 | null) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string | null;\n /**\n * The default value of the combobox component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the combobox component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the combobox component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end' /**\n * Defines the preferred side of the combobox. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */;\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * Id of the combobox component\n */\n id?: string;\n /**\n * The data test id of the combobox component.\n */\n 'data-test-id'?: string;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n} & CommonAriaProps;\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n side = 'bottom',\n id,\n viewportCollisionPadding = 'compact',\n ...props\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 toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n setFilterText('');\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const wasClicked = useRef(false);\n\n const valueInvalid = useMemo(\n () => !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': 'aria-label' in props ? props['aria-label'] : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={onBlurHandler}\n />\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n role=\"button\"\n >\n {clearButton}\n </RadixSlot>\n )}\n <div className={styles.icons}>\n <button\n aria-label=\"toggle menu\"\n {...getToggleButtonProps()}\n type=\"button\"\n disabled={disabled}\n onMouseDown={() => {\n wasClicked.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {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 side={side}\n highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectCombobox.displayName = 'Select.Combobox';\n\nexport const ForwardedRefCombobox = forwardRef<HTMLDivElement, ComboboxProps>(SelectCombobox);\n"],"names":["SelectCombobox","children","onSelect","value","defaultValue","placeholder","status","disabled","dataTestId","alignMenu","side","id","viewportCollisionPadding","props","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","I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ACA,0BAAAX;AAAA,QAEC,UAAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACAhB,EAAe,cAAc;AAEhB,MAAAyD,KAAuBC,EAA0C1D,CAAc;"}
1
+ {"version":3,"file":"fondue-components62.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -1,22 +1,154 @@
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-components66.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);
1
+ import { jsxs as g, jsx as o } from "react/jsx-runtime";
2
+ import { IconCaretDown as Q, IconCheckMark as U, IconExclamationMarkTriangle as W } from "@frontify/fondue-icons";
3
+ import * as B from "@radix-ui/react-popover";
4
+ import { Slot as X } from "@radix-ui/react-slot";
5
+ import { useCombobox as Y } from "downshift";
6
+ import { forwardRef as Z, useState as _, useRef as A, useMemo as ee } from "react";
7
+ import { LoadingCircle as oe } from "./fondue-components18.js";
8
+ import { ForwardedRefSelectSlot as te } from "./fondue-components66.js";
9
+ import { SelectMenu as re } from "./fondue-components65.js";
10
+ import t from "./fondue-components67.js";
11
+ import { useSelectData as ae } from "./fondue-components68.js";
12
+ const L = ({
13
+ children: O,
14
+ onSelect: i,
15
+ value: v,
16
+ defaultValue: F,
17
+ placeholder: M = "",
18
+ status: s = "neutral",
19
+ disabled: f,
20
+ "data-test-id": r = "fondue-select-combobox",
21
+ alignMenu: P = "start",
22
+ side: k = "bottom",
23
+ id: y,
24
+ viewportCollisionPadding: z = "compact",
25
+ getAsyncItems: c,
26
+ ...a
27
+ }, D) => {
28
+ const { inputSlots: H, menuSlots: V, items: u, filterText: $, clearButton: h, getItemByValue: p, setFilterText: b, asyncItemStatus: C } = ae(O, c), [j, x] = _(!1), {
29
+ getInputProps: d,
30
+ getToggleButtonProps: E,
31
+ getMenuProps: T,
32
+ getItemProps: q,
33
+ reset: w,
34
+ selectedItem: l,
35
+ isOpen: S,
36
+ highlightedIndex: G,
37
+ inputValue: m
38
+ } = Y({
39
+ items: u,
40
+ selectedItem: p(v),
41
+ defaultSelectedItem: p(F),
42
+ defaultHighlightedIndex: 0,
43
+ toggleButtonId: y,
44
+ labelId: "aria-labelledby" in a ? a["aria-labelledby"] : void 0,
45
+ onSelectedItemChange: ({ selectedItem: e }) => {
46
+ i == null || i((e == null ? void 0 : e.value) ?? null);
47
+ },
48
+ onInputValueChange: ({ inputValue: e }) => {
49
+ b(e);
50
+ },
51
+ onIsOpenChange: () => {
52
+ x(!1), b("");
53
+ },
54
+ onHighlightedIndexChange: () => {
55
+ x(!0);
56
+ },
57
+ itemToString: (e) => e ? e.label : ""
58
+ }), n = A(!1), J = ee(
59
+ () => !c && !u.find((e) => e.label.toLowerCase().includes(m.toLowerCase())),
60
+ [m, u, c]
61
+ ), K = (e) => {
62
+ var N, R;
63
+ e.target.dataset.showFocusRing = "false", n.current = !1, (l == null ? void 0 : l.label.toLocaleLowerCase()) !== m.toLocaleLowerCase() && w(), d().onBlur && ((R = (N = d()).onBlur) == null || R.call(N, e));
64
+ }, I = J || !!C.error || s === "error";
65
+ return /* @__PURE__ */ g(B.Root, { open: S, children: [
66
+ /* @__PURE__ */ o(B.Anchor, { asChild: !0, children: /* @__PURE__ */ g("div", { ref: D, className: t.root, "data-status": I ? "error" : s, children: [
67
+ /* @__PURE__ */ o(
68
+ "input",
69
+ {
70
+ ...d({
71
+ "aria-label": "aria-label" in a ? a["aria-label"] : void 0
72
+ }),
73
+ "data-test-id": r,
74
+ placeholder: M,
75
+ className: t.input,
76
+ disabled: f,
77
+ onMouseDown: (e) => {
78
+ n.current = !0, e.currentTarget.dataset.showFocusRing = "false";
79
+ },
80
+ onFocus: (e) => {
81
+ n.current || (e.target.dataset.showFocusRing = "true");
82
+ },
83
+ onBlur: K
84
+ }
85
+ ),
86
+ H,
87
+ h && /* @__PURE__ */ o(
88
+ X,
89
+ {
90
+ onClick: (e) => {
91
+ e.stopPropagation(), w();
92
+ },
93
+ className: t.clear,
94
+ role: "button",
95
+ children: h
96
+ }
97
+ ),
98
+ C.isLoading && S ? /* @__PURE__ */ o(te, { name: "right", "data-test-id": `${r}-right-slot`, children: /* @__PURE__ */ o(oe, { size: "x-small", "data-test-id": `${r}-loading-circle` }) }) : null,
99
+ /* @__PURE__ */ g("div", { className: t.icons, children: [
100
+ /* @__PURE__ */ o(
101
+ "button",
102
+ {
103
+ "aria-label": "toggle menu",
104
+ ...E(),
105
+ type: "button",
106
+ disabled: f,
107
+ onMouseDown: () => {
108
+ n.current = !0;
109
+ },
110
+ children: /* @__PURE__ */ o(Q, { size: 16, className: t.caret })
111
+ }
112
+ ),
113
+ s === "success" ? /* @__PURE__ */ o(
114
+ U,
115
+ {
116
+ size: 16,
117
+ className: t.iconSuccess,
118
+ "data-test-id": `${r}-success-icon`
119
+ }
120
+ ) : null,
121
+ I ? /* @__PURE__ */ o(
122
+ W,
123
+ {
124
+ size: 16,
125
+ className: t.iconError,
126
+ "data-test-id": `${r}-error-icon`
127
+ }
128
+ ) : null
129
+ ] })
130
+ ] }) }),
131
+ /* @__PURE__ */ o(
132
+ re,
133
+ {
134
+ align: P,
135
+ side: k,
136
+ highlightedIndex: G,
137
+ filterText: $,
138
+ getMenuProps: T,
139
+ getItemProps: q,
140
+ selectedItem: l,
141
+ hasInteractedSinceOpening: j,
142
+ viewportCollisionPadding: z,
143
+ children: V
144
+ }
145
+ )
146
+ ] });
147
+ };
148
+ L.displayName = "Select.Combobox";
149
+ const pe = Z(L);
16
150
  export {
17
- I as ForwardedRefSelectItem,
18
- N as ForwardedRefSelectItemGroup,
19
- o as SelectItem,
20
- s as SelectItemGroup
151
+ pe as ForwardedRefCombobox,
152
+ L as SelectCombobox
21
153
  };
22
154
  //# sourceMappingURL=fondue-components63.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components63.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":";;;;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;AAAA,GACpD;AAGRL,EAAW,cAAc;AAEZ,MAAAO,IAAyBC,EAA2CR,CAAU,GAqB9ES,IAAkB,CAC3B,EAAE,UAAAC,GAAU,SAAAC,GAAS,SAAAC,GAAS,gBAAgBX,IAAa,2BAA2B,GACtFE,MAGI,gBAAAU,EAAC,SAAI,gBAAcZ,GAAY,WAAWI,EAAO,OAAO,KAAKF,GACxD,UAAA;AAAA,EACGS,IAAA,gBAAAR,EAAC,SAAI,WAAWC,EAAO,cACnB,UAAC,gBAAAD,EAAA,QAAA,EAAM,UAAQQ,EAAA,CAAA,EAAA,CACnB,IACA;AAAA,EACHF;AAAA,EAAA,GAN2EC,CAOhF;AAGRF,EAAgB,cAAc;AAEjB,MAAAK,IAA8BN,EAAiDC,CAAe;"}
1
+ {"version":3,"file":"fondue-components63.js","sources":["../src/components/Select/Combobox.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useCombobox } from 'downshift';\nimport { forwardRef, useMemo, useRef, useState, type FocusEvent, type ForwardedRef, type ReactNode } from 'react';\n\nimport { LoadingCircle } from '#/components/LoadingCircle/LoadingCircle.tsx';\nimport { ForwardedRefSelectSlot } from '#/components/Select/SelectSlot.tsx';\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { type AsyncItemsFetcher, 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 | null) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string | null;\n /**\n * The default value of the combobox component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the combobox component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the combobox component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end' /**\n * Defines the preferred side of the combobox. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */;\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * Id of the combobox component\n */\n id?: string;\n /**\n * The data test id of the combobox component.\n */\n 'data-test-id'?: string;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n /**\n * Function to fetch items asynchronously.\n */\n getAsyncItems?: AsyncItemsFetcher;\n} & CommonAriaProps;\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n side = 'bottom',\n id,\n viewportCollisionPadding = 'compact',\n getAsyncItems,\n ...props\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText, asyncItemStatus } =\n useSelectData(children, getAsyncItems);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const {\n getInputProps,\n getToggleButtonProps,\n getMenuProps,\n getItemProps,\n reset,\n selectedItem,\n isOpen,\n highlightedIndex,\n inputValue,\n } = useCombobox({\n items,\n selectedItem: getItemByValue(value),\n defaultSelectedItem: getItemByValue(defaultValue),\n defaultHighlightedIndex: 0,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n setFilterText('');\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const wasClicked = useRef(false);\n\n const valueInvalid = useMemo(\n () => !getAsyncItems && !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items, getAsyncItems],\n );\n\n const onBlurHandler = (blurEvent: FocusEvent<HTMLInputElement, Element>) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n\n const selectedItemNullOrOutdated = selectedItem?.label.toLocaleLowerCase() !== inputValue.toLocaleLowerCase();\n\n if (selectedItemNullOrOutdated) {\n // if there is no selection or\n // the existing selected value is not the same as the input value (old),\n // reset the input\n reset();\n }\n\n if (getInputProps().onBlur) {\n getInputProps().onBlur?.(blurEvent);\n }\n };\n const hasError = valueInvalid || !!asyncItemStatus.error || status === 'error';\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={hasError ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={onBlurHandler}\n />\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n role=\"button\"\n >\n {clearButton}\n </RadixSlot>\n )}\n {asyncItemStatus.isLoading && isOpen ? (\n <ForwardedRefSelectSlot name=\"right\" data-test-id={`${dataTestId}-right-slot`}>\n <LoadingCircle size=\"x-small\" data-test-id={`${dataTestId}-loading-circle`} />\n </ForwardedRefSelectSlot>\n ) : null}\n <div className={styles.icons}>\n <button\n aria-label=\"toggle menu\"\n {...getToggleButtonProps()}\n type=\"button\"\n disabled={disabled}\n onMouseDown={() => {\n wasClicked.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {hasError ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectCombobox.displayName = 'Select.Combobox';\n\nexport const ForwardedRefCombobox = forwardRef<HTMLDivElement, ComboboxProps>(SelectCombobox);\n"],"names":["SelectCombobox","children","onSelect","value","defaultValue","placeholder","status","disabled","dataTestId","alignMenu","side","id","viewportCollisionPadding","getAsyncItems","props","forwardedRef","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","asyncItemStatus","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","hasError","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","ForwardedRefSelectSlot","LoadingCircle","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":";;;;;;;;;;;AA0EO,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,gBAAgBC,IAAa;AAAA,EAC7B,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,eAAAC;AAAA,EACA,GAAGC;AACP,GACAC,MACC;AACD,QAAM,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,YAAAC,GAAY,aAAAC,GAAa,gBAAAC,GAAgB,eAAAC,GAA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C,EAAAO,IAAA,EAAc,MAAK,WAAU,gBAAc,GAAGjD,CAAU,mBAAmB,GAChF,IACA;AAAA,MACH,gBAAAwC,EAAA,OAAA,EAAI,WAAWG,EAAO,OACnB,UAAA;AAAA,QAAA,gBAAAD;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,cAAW;AAAA,YACV,GAAGrB,EAAqB;AAAA,YACzB,MAAK;AAAA,YACL,UAAAtB;AAAA,YACA,aAAa,MAAM;AACf,cAAAgC,EAAW,UAAU;AAAA,YACzB;AAAA,YAEA,4BAACmB,GAAc,EAAA,MAAM,IAAI,WAAWP,EAAO,MAAO,CAAA;AAAA,UAAA;AAAA,QACtD;AAAA,QACC7C,MAAW,YACR,gBAAA4C;AAAA,UAACS;AAAA,UAAA;AAAA,YACG,MAAM;AAAA,YACN,WAAWR,EAAO;AAAA,YAClB,gBAAc,GAAG3C,CAAU;AAAA,UAAA;AAAA,QAAA,IAE/B;AAAA,QACHuC,IACG,gBAAAG;AAAA,UAACU;AAAA,UAAA;AAAA,YACG,MAAM;AAAA,YACN,WAAWT,EAAO;AAAA,YAClB,gBAAc,GAAG3C,CAAU;AAAA,UAAA;AAAA,QAAA,IAE/B;AAAA,MAAA,EACR,CAAA;AAAA,IAAA,EAAA,CACJ,EACJ,CAAA;AAAA,IAEA,gBAAA0C;AAAA,MAACW;AAAA,MAAA;AAAA,QACG,OAAOpD;AAAA,QACP,MAAAC;AAAA,QACA,kBAAAyB;AAAA,QACA,YAAAhB;AAAA,QACA,cAAAW;AAAA,QACA,cAAAC;AAAA,QACA,cAAAE;AAAA,QACA,2BAAAR;AAAA,QACA,0BAAAb;AAAA,QAEC,UAAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACAjB,EAAe,cAAc;AAEhB,MAAA8D,KAAuBC,EAA0C/D,CAAc;"}
@@ -1,80 +1,22 @@
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-components29.js";
6
- import n from "./fondue-components66.js";
7
- import { recursiveMap as D, getSelectOptionValue as M } from "./fondue-components83.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";
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-components67.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
- T as SelectMenu
17
+ I as ForwardedRefSelectItem,
18
+ N as ForwardedRefSelectItemGroup,
19
+ o as SelectItem,
20
+ s as SelectItemGroup
79
21
  };
80
22
  //# sourceMappingURL=fondue-components64.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components64.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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E;AAAA,oBACC,GAAGc;AAAA,oBAEH,UAAAL;AAAA,kBAAA;AAAA,kBATIA,EAAM,MAAM;AAAA,gBAUrB;AAAA,cAAA;AAAA,YAGZ;AAAA,YACAhB;AAAA,UAAA,EACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAEV;AAAA,KAER,EACJ,CAAA;AAER;AACAL,EAAW,cAAc;"}
1
+ {"version":3,"file":"fondue-components64.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":";;;;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;AAAA,GACpD;AAGRL,EAAW,cAAc;AAEZ,MAAAO,IAAyBC,EAA2CR,CAAU,GAqB9ES,IAAkB,CAC3B,EAAE,UAAAC,GAAU,SAAAC,GAAS,SAAAC,GAAS,gBAAgBX,IAAa,2BAA2B,GACtFE,MAGI,gBAAAU,EAAC,SAAI,gBAAcZ,GAAY,WAAWI,EAAO,OAAO,KAAKF,GACxD,UAAA;AAAA,EACGS,IAAA,gBAAAR,EAAC,SAAI,WAAWC,EAAO,cACnB,UAAC,gBAAAD,EAAA,QAAA,EAAM,UAAQQ,EAAA,CAAA,EAAA,CACnB,IACA;AAAA,EACHF;AAAA,EAAA,GAN2EC,CAOhF;AAGRF,EAAgB,cAAc;AAEjB,MAAAK,IAA8BN,EAAiDC,CAAe;"}