@frontify/fondue-components 29.0.0 → 29.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 (87) hide show
  1. package/dist/fondue-components111.js +15 -3
  2. package/dist/fondue-components111.js.map +1 -1
  3. package/dist/fondue-components112.js +127 -5
  4. package/dist/fondue-components112.js.map +1 -1
  5. package/dist/fondue-components113.js +11 -17
  6. package/dist/fondue-components113.js.map +1 -1
  7. package/dist/fondue-components114.js +36 -14
  8. package/dist/fondue-components114.js.map +1 -1
  9. package/dist/fondue-components115.js +14 -15
  10. package/dist/fondue-components115.js.map +1 -1
  11. package/dist/fondue-components116.js +15 -111
  12. package/dist/fondue-components116.js.map +1 -1
  13. package/dist/fondue-components117.js +110 -12
  14. package/dist/fondue-components117.js.map +1 -1
  15. package/dist/fondue-components118.js +13 -17
  16. package/dist/fondue-components118.js.map +1 -1
  17. package/dist/fondue-components119.js +17 -13
  18. package/dist/fondue-components119.js.map +1 -1
  19. package/dist/fondue-components120.js +12 -126
  20. package/dist/fondue-components120.js.map +1 -1
  21. package/dist/fondue-components121.js +217 -11
  22. package/dist/fondue-components121.js.map +1 -1
  23. package/dist/fondue-components122.js +17 -34
  24. package/dist/fondue-components122.js.map +1 -1
  25. package/dist/fondue-components123.js +14 -214
  26. package/dist/fondue-components123.js.map +1 -1
  27. package/dist/fondue-components124.js +149 -17
  28. package/dist/fondue-components124.js.map +1 -1
  29. package/dist/fondue-components125.js +44 -16
  30. package/dist/fondue-components125.js.map +1 -1
  31. package/dist/fondue-components126.js +4 -150
  32. package/dist/fondue-components126.js.map +1 -1
  33. package/dist/fondue-components127.js +4 -44
  34. package/dist/fondue-components127.js.map +1 -1
  35. package/dist/fondue-components128.js +28 -169
  36. package/dist/fondue-components128.js.map +1 -1
  37. package/dist/fondue-components130.js +41 -9
  38. package/dist/fondue-components130.js.map +1 -1
  39. package/dist/fondue-components131.js +6 -256
  40. package/dist/fondue-components131.js.map +1 -1
  41. package/dist/fondue-components132.js +11 -28
  42. package/dist/fondue-components132.js.map +1 -1
  43. package/dist/fondue-components133.js +74 -0
  44. package/dist/fondue-components133.js.map +1 -0
  45. package/dist/fondue-components134.js +14 -40
  46. package/dist/fondue-components134.js.map +1 -1
  47. package/dist/fondue-components135.js +7 -6
  48. package/dist/fondue-components135.js.map +1 -1
  49. package/dist/fondue-components136.js +88 -11
  50. package/dist/fondue-components136.js.map +1 -1
  51. package/dist/fondue-components137.js +79 -69
  52. package/dist/fondue-components137.js.map +1 -1
  53. package/dist/fondue-components138.js +30 -14
  54. package/dist/fondue-components138.js.map +1 -1
  55. package/dist/fondue-components139.js +170 -7
  56. package/dist/fondue-components139.js.map +1 -1
  57. package/dist/fondue-components140.js +57 -86
  58. package/dist/fondue-components140.js.map +1 -1
  59. package/dist/fondue-components141.js +9 -81
  60. package/dist/fondue-components141.js.map +1 -1
  61. package/dist/fondue-components142.js +254 -29
  62. package/dist/fondue-components142.js.map +1 -1
  63. package/dist/fondue-components145.js +2 -2
  64. package/dist/fondue-components147.js +2 -2
  65. package/dist/fondue-components148.js +1 -1
  66. package/dist/fondue-components43.js +2 -2
  67. package/dist/fondue-components50.js +1 -1
  68. package/dist/fondue-components60.js +2 -2
  69. package/dist/fondue-components61.js +3 -3
  70. package/dist/fondue-components62.js +2 -2
  71. package/dist/fondue-components74.js +2 -2
  72. package/dist/fondue-components77.js +1 -1
  73. package/dist/fondue-components78.js +1 -1
  74. package/dist/fondue-components79.js +1 -1
  75. package/dist/fondue-components82.js +1 -1
  76. package/dist/fondue-components84.js +2 -2
  77. package/dist/fondue-components90.js +2 -2
  78. package/dist/fondue-components91.js +2 -2
  79. package/dist/fondue-components92.js +2 -2
  80. package/dist/fondue-components93.js +2 -2
  81. package/dist/fondue-components94.js +1 -1
  82. package/dist/fondue-components95.js +1 -1
  83. package/dist/index.d.ts +2 -2
  84. package/dist/style.css +1 -1
  85. package/package.json +1 -1
  86. package/dist/fondue-components129.js +0 -63
  87. package/dist/fondue-components129.js.map +0 -1
@@ -1,15 +1,92 @@
1
- import { useRef as u, useCallback as t } from "react";
2
- const c = () => {
3
- const s = u(!1), o = t((e) => {
4
- s.current = !0, e.currentTarget.dataset.showFocusRing = "false";
5
- }, []), r = t((e) => {
6
- s.current || (e.target.dataset.showFocusRing = "true");
7
- }, []), n = t((e) => {
8
- e.target.dataset.showFocusRing = "false", s.current = !1;
9
- }, []);
10
- return { wasClickedRef: s, onMouseDown: o, onFocus: r, onBlur: n };
1
+ import { jsxs as S, jsx as f } from "react/jsx-runtime";
2
+ import { useRef as m, useState as C, useEffect as _ } from "react";
3
+ import { Badge as w } from "./fondue-components4.js";
4
+ import { useTranslation as I } from "./fondue-components42.js";
5
+ import p from "./fondue-components125.js";
6
+ const W = 4, D = 40, E = 24, M = (r, h, u, o) => {
7
+ const g = r.offsetWidth;
8
+ let s = o ? E + W : 0, n = 0;
9
+ for (const d of u) {
10
+ const a = h.get(d.value);
11
+ if (!a)
12
+ continue;
13
+ const l = a.offsetWidth, i = n > 0 ? l + W : l, c = u.length - n - 1 > 0 ? D + W : 0;
14
+ if (s + i + c > g)
15
+ break;
16
+ s += i, n++;
17
+ }
18
+ return Math.max(1, n);
19
+ }, x = ({
20
+ items: r,
21
+ placeholder: h,
22
+ onDismiss: u,
23
+ children: o,
24
+ selectedCount: g = 0
25
+ }) => {
26
+ const { t: s } = I(), n = m(!1), d = m(null), a = m(/* @__PURE__ */ new Map()), [l, i] = C(r.length), b = o !== void 0;
27
+ if (_(() => {
28
+ const e = d.current;
29
+ if (!e)
30
+ return;
31
+ const v = () => {
32
+ if (r.length === 0) {
33
+ i(0);
34
+ return;
35
+ }
36
+ i(M(e, a.current, r, b));
37
+ }, t = new ResizeObserver(v);
38
+ return t.observe(e), () => {
39
+ t.disconnect();
40
+ };
41
+ }, [r, b]), r.length === 0 && !o)
42
+ return h;
43
+ const c = r.length - l, y = (e) => e === 1 ? s("Select_singleItemSelected") : e > 1 ? s("Select_multipleItemsSelected", { count: e.toString() }) : "";
44
+ return /* @__PURE__ */ S("div", { ref: d, className: p.badgesContainer, children: [
45
+ /* @__PURE__ */ f("span", { className: p.srOnly, "aria-live": "polite", "aria-atomic": "true", children: y(g) }),
46
+ o,
47
+ r.map((e, v) => /* @__PURE__ */ f(
48
+ "div",
49
+ {
50
+ ref: (t) => {
51
+ t ? a.current.set(e.value, t) : a.current.delete(e.value);
52
+ },
53
+ role: "presentation",
54
+ className: p.badgeWrapper,
55
+ "data-visible": v < l,
56
+ onKeyDown: (t) => {
57
+ (t.key === "Enter" || t.key === " ") && t.stopPropagation();
58
+ },
59
+ onMouseDown: () => {
60
+ n.current = !0;
61
+ },
62
+ children: /* @__PURE__ */ f(
63
+ w,
64
+ {
65
+ emphasis: "weak",
66
+ "aria-label": typeof e.displayValue == "string" ? e.displayValue : e.value,
67
+ onDismiss: (t) => {
68
+ t.stopPropagation(), u(e.value, n.current), n.current = !1;
69
+ },
70
+ children: e.displayValue
71
+ }
72
+ )
73
+ },
74
+ e.value
75
+ )),
76
+ c > 0 && /* @__PURE__ */ f(
77
+ "div",
78
+ {
79
+ className: p.badgeWrapper,
80
+ "aria-label": s("Select_additionalItemsSelected", { count: c.toString() }),
81
+ children: /* @__PURE__ */ S(w, { emphasis: "weak", "aria-hidden": "true", children: [
82
+ "+",
83
+ c
84
+ ] })
85
+ }
86
+ )
87
+ ] });
11
88
  };
12
89
  export {
13
- c as useFocusRing
90
+ x as CollapsibleBadges
14
91
  };
15
92
  //# sourceMappingURL=fondue-components136.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components136.js","sources":["../src/components/Select/hooks/useFocusRing.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useCallback, useRef, type FocusEvent, type MouseEvent, type MutableRefObject } from 'react';\n\ntype FocusRingHandlers = {\n /** Ref tracking whether the element was activated via mouse click. */\n wasClickedRef: MutableRefObject<boolean>;\n /** Handler for mousedown events marks the interaction as click-based. */\n onMouseDown: (event: MouseEvent<HTMLElement>) => void;\n /** Handler for focus events shows the focus ring only for keyboard navigation. */\n onFocus: (event: FocusEvent<HTMLElement>) => void;\n /** Handler for blur events hides the focus ring and resets click tracking. */\n onBlur: (event: FocusEvent<HTMLElement>) => void;\n};\n\nexport const useFocusRing = (): FocusRingHandlers => {\n const wasClickedRef = useRef(false);\n\n const onMouseDown = useCallback((event: MouseEvent<HTMLElement>): void => {\n wasClickedRef.current = true;\n event.currentTarget.dataset.showFocusRing = 'false';\n }, []);\n\n const onFocus = useCallback((event: FocusEvent<HTMLElement>): void => {\n if (!wasClickedRef.current) {\n event.target.dataset.showFocusRing = 'true';\n }\n }, []);\n\n const onBlur = useCallback((event: FocusEvent<HTMLElement>): void => {\n event.target.dataset.showFocusRing = 'false';\n wasClickedRef.current = false;\n }, []);\n\n return { wasClickedRef, onMouseDown, onFocus, onBlur };\n};\n"],"names":["useFocusRing","wasClickedRef","useRef","onMouseDown","useCallback","event","onFocus","onBlur"],"mappings":";AAeO,MAAMA,IAAe,MAAyB;AACjD,QAAMC,IAAgBC,EAAO,EAAK,GAE5BC,IAAcC,EAAY,CAACC,MAAyC;AACtE,IAAAJ,EAAc,UAAU,IACxBI,EAAM,cAAc,QAAQ,gBAAgB;AAAA,EAChD,GAAG,CAAA,CAAE,GAECC,IAAUF,EAAY,CAACC,MAAyC;AAClE,IAAKJ,EAAc,YACfI,EAAM,OAAO,QAAQ,gBAAgB;AAAA,EAE7C,GAAG,CAAA,CAAE,GAECE,IAASH,EAAY,CAACC,MAAyC;AACjE,IAAAA,EAAM,OAAO,QAAQ,gBAAgB,SACrCJ,EAAc,UAAU;AAAA,EAC5B,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,eAAAA,GAAe,aAAAE,GAAa,SAAAG,GAAS,QAAAC,EAAA;AAClD;"}
1
+ {"version":3,"file":"fondue-components136.js","sources":["../src/components/Select/components/CollapsibleBadges.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';\n\nimport { Badge } from '#/components/Badge/Badge';\nimport { useTranslation } from '#/hooks/useTranslation';\n\nimport styles from '../styles/select.module.scss';\n\nconst BADGE_GAP = 4;\nconst OVERFLOW_BADGE_MIN_WIDTH = 40;\nconst INPUT_MIN_WIDTH = 24;\n\ntype BadgeItem = {\n value: string;\n displayValue: ReactNode;\n};\n\ntype CollapsibleBadgesProps = {\n items: BadgeItem[];\n placeholder?: string;\n onDismiss: (value: string, preventFocusRing: boolean) => void;\n /** Optional children to render at the end (e.g., an input field). Space is reserved in the layout calculation. */\n children?: ReactNode;\n /** Total number of selected items (for screen reader announcements). */\n selectedCount?: number;\n};\n\nconst calculateVisibleCount = (\n container: HTMLDivElement,\n badgeElements: Map<string, HTMLDivElement>,\n items: BadgeItem[],\n hasInputSlot: boolean,\n): number => {\n const containerWidth = container.offsetWidth;\n let usedWidth = hasInputSlot ? INPUT_MIN_WIDTH + BADGE_GAP : 0;\n let count = 0;\n\n for (const item of items) {\n const badgeElement = badgeElements.get(item.value);\n if (!badgeElement) {\n continue;\n }\n\n const badgeWidth = badgeElement.offsetWidth;\n const widthWithGap = count > 0 ? badgeWidth + BADGE_GAP : badgeWidth;\n const hasMoreAfterThis = items.length - count - 1 > 0;\n const reservedWidth = hasMoreAfterThis ? OVERFLOW_BADGE_MIN_WIDTH + BADGE_GAP : 0;\n\n if (usedWidth + widthWithGap + reservedWidth > containerWidth) {\n break;\n }\n\n usedWidth += widthWithGap;\n count++;\n }\n\n return Math.max(1, count);\n};\n\nexport const CollapsibleBadges = ({\n items,\n placeholder,\n onDismiss,\n children,\n selectedCount = 0,\n}: CollapsibleBadgesProps): ReactNode => {\n const { t } = useTranslation();\n const wasClickedRef = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const badgeElementsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n const [visibleCount, setVisibleCount] = useState(items.length);\n const hasChildren = children !== undefined;\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const recalculate = (): void => {\n if (items.length === 0) {\n setVisibleCount(0);\n return;\n }\n setVisibleCount(calculateVisibleCount(container, badgeElementsRef.current, items, hasChildren));\n };\n\n const observer = new ResizeObserver(recalculate);\n observer.observe(container);\n return (): void => {\n observer.disconnect();\n };\n }, [items, hasChildren]);\n\n if (items.length === 0 && !children) {\n return placeholder;\n }\n\n const overflowCount = items.length - visibleCount;\n\n const getSelectedCountText = (count: number): string => {\n if (count === 1) {\n return t('Select_singleItemSelected');\n }\n if (count > 1) {\n return t('Select_multipleItemsSelected', { count: count.toString() });\n }\n return '';\n };\n\n return (\n <div ref={containerRef} className={styles.badgesContainer}>\n <span className={styles.srOnly} aria-live=\"polite\" aria-atomic=\"true\">\n {getSelectedCountText(selectedCount)}\n </span>\n {children}\n {items.map((item, index) => (\n <div\n key={item.value}\n ref={(element): void => {\n if (element) {\n badgeElementsRef.current.set(item.value, element);\n } else {\n badgeElementsRef.current.delete(item.value);\n }\n }}\n role=\"presentation\"\n className={styles.badgeWrapper}\n data-visible={index < visibleCount}\n onKeyDown={(event: KeyboardEvent<HTMLDivElement>): void => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.stopPropagation();\n }\n }}\n onMouseDown={(): void => {\n wasClickedRef.current = true;\n }}\n >\n <Badge\n emphasis=\"weak\"\n aria-label={typeof item.displayValue === 'string' ? item.displayValue : item.value}\n onDismiss={(event) => {\n event.stopPropagation();\n onDismiss(item.value, wasClickedRef.current);\n wasClickedRef.current = false;\n }}\n >\n {item.displayValue}\n </Badge>\n </div>\n ))}\n {overflowCount > 0 && (\n <div\n className={styles.badgeWrapper}\n aria-label={t('Select_additionalItemsSelected', { count: overflowCount.toString() })}\n >\n <Badge emphasis=\"weak\" aria-hidden=\"true\">\n +{overflowCount}\n </Badge>\n </div>\n )}\n </div>\n );\n};\n"],"names":["BADGE_GAP","OVERFLOW_BADGE_MIN_WIDTH","INPUT_MIN_WIDTH","calculateVisibleCount","container","badgeElements","items","hasInputSlot","containerWidth","usedWidth","count","item","badgeElement","badgeWidth","widthWithGap","reservedWidth","CollapsibleBadges","placeholder","onDismiss","children","selectedCount","t","useTranslation","wasClickedRef","useRef","containerRef","badgeElementsRef","visibleCount","setVisibleCount","useState","hasChildren","useEffect","recalculate","observer","overflowCount","getSelectedCountText","styles","jsx","index","element","event","Badge","jsxs"],"mappings":";;;;;AASA,MAAMA,IAAY,GACZC,IAA2B,IAC3BC,IAAkB,IAiBlBC,IAAwB,CAC1BC,GACAC,GACAC,GACAC,MACS;AACT,QAAMC,IAAiBJ,EAAU;AACjC,MAAIK,IAAYF,IAAeL,IAAkBF,IAAY,GACzDU,IAAQ;AAEZ,aAAWC,KAAQL,GAAO;AACtB,UAAMM,IAAeP,EAAc,IAAIM,EAAK,KAAK;AACjD,QAAI,CAACC;AACD;AAGJ,UAAMC,IAAaD,EAAa,aAC1BE,IAAeJ,IAAQ,IAAIG,IAAab,IAAYa,GAEpDE,IADmBT,EAAM,SAASI,IAAQ,IAAI,IACXT,IAA2BD,IAAY;AAEhF,QAAIS,IAAYK,IAAeC,IAAgBP;AAC3C;AAGJ,IAAAC,KAAaK,GACbJ;AAAA,EACJ;AAEA,SAAO,KAAK,IAAI,GAAGA,CAAK;AAC5B,GAEaM,IAAoB,CAAC;AAAA,EAC9B,OAAAV;AAAA,EACA,aAAAW;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC,IAAgB;AACpB,MAAyC;AACrC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IAAgBC,EAAO,EAAK,GAC5BC,IAAeD,EAAuB,IAAI,GAC1CE,IAAmBF,EAAoC,oBAAI,KAAK,GAChE,CAACG,GAAcC,CAAe,IAAIC,EAASvB,EAAM,MAAM,GACvDwB,IAAcX,MAAa;AAuBjC,MArBAY,EAAU,MAAM;AACZ,UAAM3B,IAAYqB,EAAa;AAC/B,QAAI,CAACrB;AACD;A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AAA,QAEA,UAAA,gBAAAc;AAAA,UAACI;AAAA,UAAA;AAAA,YACG,UAAS;AAAA,YACT,cAAY,OAAO9B,EAAK,gBAAiB,WAAWA,EAAK,eAAeA,EAAK;AAAA,YAC7E,WAAW,CAAC6B,MAAU;AAClB,cAAAA,EAAM,gBAAA,GACNtB,EAAUP,EAAK,OAAOY,EAAc,OAAO,GAC3CA,EAAc,UAAU;AAAA,YAC5B;AAAA,YAEC,UAAAZ,EAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MACV;AAAA,MA9BKA,EAAK;AAAA,IAAA,CAgCjB;AAAA,IACAuB,IAAgB,KACb,gBAAAG;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,WAAWD,EAAO;AAAA,QAClB,cAAYf,EAAE,kCAAkC,EAAE,OAAOa,EAAc,SAAA,GAAY;AAAA,QAEnF,UAAA,gBAAAQ,EAACD,GAAA,EAAM,UAAS,QAAO,eAAY,QAAO,UAAA;AAAA,UAAA;AAAA,UACpCP;AAAA,QAAA,EAAA,CACN;AAAA,MAAA;AAAA,IAAA;AAAA,EACJ,GAER;AAER;"}
@@ -1,74 +1,84 @@
1
- import { jsx as E } from "react/jsx-runtime";
2
- import { useState as S, useMemo as b, Children as V, isValidElement as C, cloneElement as w, useCallback as B, useEffect as x } from "react";
3
- import { SelectClear as F } from "./fondue-components148.js";
4
- import { ForwardedRefSelectItem as L } from "./fondue-components94.js";
5
- import { ForwardedRefSelectSlot as y } from "./fondue-components95.js";
6
- import { getSelectOptionValue as I } from "./fondue-components149.js";
7
- const d = (n, s) => {
8
- const [e, r] = S(!1), [m, i] = S(null), [l, f] = S({
9
- menuComponents: [],
10
- items: []
11
- });
12
- return x(() => {
13
- i(null), s || f({
14
- menuComponents: [],
15
- items: []
16
- }), s && (r(!0), s(n).then((u) => {
17
- f({
18
- menuComponents: u.map((o) => /* @__PURE__ */ E(L, { label: o.label, value: o.value, children: o.content ? o.content : o.label }, o.value)),
19
- items: u.map((o) => ({ value: o.value, label: o.label, children: o.content }))
20
- }), r(!1);
21
- }).catch((u) => {
22
- i(u), r(!1);
23
- }));
24
- }, [n, s]), { isLoading: e, error: m, menuComponents: l.menuComponents, items: l.items };
25
- }, g = (n) => {
26
- const s = [];
27
- return V.forEach(n, (e) => {
28
- if (C(e) && e.type === L)
29
- s.push(I(e.props));
30
- else if (C(e) && e.props.children) {
31
- const r = g(e.props.children);
32
- for (const m of r)
33
- s.push(m);
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import * as p from "@radix-ui/react-popover";
3
+ import { Slot as M } from "@radix-ui/react-slot";
4
+ import { isValidElement as T } from "react";
5
+ import { useFondueTheme as E, ThemeProvider as F } from "./fondue-components39.js";
6
+ import a from "./fondue-components125.js";
7
+ import { recursiveMap as R, getSelectOptionValue as _ } from "./fondue-components149.js";
8
+ const j = ({
9
+ highlightedIndex: l,
10
+ getMenuProps: u,
11
+ getItemProps: m,
12
+ children: f,
13
+ filterText: d,
14
+ align: h,
15
+ side: P,
16
+ selectedItemValues: o,
17
+ hasInteractedSinceOpening: S,
18
+ viewportCollisionPadding: g = "compact",
19
+ onEscapeKeyDown: v
20
+ }) => {
21
+ const O = (e) => {
22
+ e.preventDefault();
23
+ }, N = {
24
+ compact: 8,
25
+ spacious: 24
26
+ }, { theme: A, dir: n } = E(), C = (e) => n === "ltr" ? e : e === "left" ? "right" : e === "right" ? "left" : e;
27
+ return /* @__PURE__ */ r(p.Portal, { children: /* @__PURE__ */ r(F, { theme: A, dir: n, children: /* @__PURE__ */ r(
28
+ p.Content,
29
+ {
30
+ dir: n,
31
+ align: h,
32
+ side: C(P),
33
+ collisionPadding: N[g] + 8,
34
+ onOpenAutoFocus: O,
35
+ onEscapeKeyDown: v,
36
+ className: a.portal,
37
+ children: /* @__PURE__ */ r(
38
+ "ul",
39
+ {
40
+ className: a.menu,
41
+ ...u({}, { suppressRefError: !0 }),
42
+ "data-has-interacted": S ? "true" : "false",
43
+ "data-test-id": "fondue-select-menu",
44
+ children: R(
45
+ f,
46
+ (e, s) => {
47
+ if (((t) => (
48
+ // @ts-expect-error - We are explicitly checking for ref
49
+ T(t) && t.ref !== void 0
50
+ ))(e)) {
51
+ const t = _(e.props), i = m({
52
+ item: t,
53
+ index: s,
54
+ ...e.ref ? { ref: e.ref } : {}
55
+ }), c = o == null ? void 0 : o.includes(t.value);
56
+ return /* @__PURE__ */ r(
57
+ M,
58
+ {
59
+ className: a.item,
60
+ "data-highlighted": l === s,
61
+ "data-selected": c,
62
+ onTouchStart: (D) => {
63
+ i.onClick && i.onClick(D);
64
+ },
65
+ ...i,
66
+ "aria-selected": c,
67
+ children: e
68
+ },
69
+ e.props.value
70
+ );
71
+ }
72
+ },
73
+ d
74
+ ).parsedChildren
75
+ }
76
+ )
34
77
  }
35
- }), s;
36
- }, q = (n, s) => {
37
- const [e, r] = S(""), { inputSlots: m, menuSlots: i, itemValues: l, clearButton: f } = b(() => {
38
- const a = [], p = [];
39
- let v;
40
- V.toArray(n).some(
41
- (t) => C(t) && t.type === y
42
- ) ? V.forEach(n, (t) => {
43
- C(t) && t.type === y && (t.props.name === "menu" ? p.push(t.props.children) : t.props.name === "left" || t.props.name === "right" ? a.push(t) : t.props.name === "clear" && (t.props.children ? v = t : v = w(t, { children: /* @__PURE__ */ E(F, {}) })));
44
- }) : p.push(n);
45
- const R = g(p);
46
- return { inputSlots: a, menuSlots: p, itemValues: R, clearButton: v };
47
- }, [n]), u = b(
48
- () => l.filter(
49
- (a) => e === "" || a.label.toLowerCase().includes(e.toLowerCase())
50
- ),
51
- [l, e]
52
- ), o = B(
53
- (a) => a !== void 0 ? l.find((p) => p.value === a) : void 0,
54
- [l]
55
- ), c = d(e, s);
56
- return {
57
- items: [...u, ...c.items],
58
- menuSlots: [...i, ...c.menuComponents],
59
- filterText: e,
60
- inputSlots: m,
61
- clearButton: f,
62
- setFilterText: r,
63
- getItemByValue: o,
64
- asyncItemStatus: {
65
- isLoading: c.isLoading,
66
- error: c.error
67
- }
68
- };
78
+ ) }) });
69
79
  };
80
+ j.displayName = "Select.Menu";
70
81
  export {
71
- g as getRecursiveOptionValues,
72
- q as useSelectData
82
+ j as SelectMenu
73
83
  };
74
84
  //# sourceMappingURL=fondue-components137.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components137.js","sources":["../src/components/Select/hooks/useSelectData.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { SelectClear } from '../components/SelectClear';\nimport { ForwardedRefSelectItem, type SelectItemProps } from '../components/SelectItem';\nimport { ForwardedRefSelectSlot, type SelectSlotProps } from '../components/SelectSlot';\nimport { getSelectOptionValue } from '../utils';\n\nexport type SelectItemType = {\n value: string;\n label: string;\n};\n\nexport type AsyncItem = { label: string; value: string; content?: ReactNode };\n\nexport type AsyncItemsFetcher = (filterText: string) => Promise<AsyncItem[]>;\n\nconst useAsyncItems = (filterText: string, getAsyncItems?: AsyncItemsFetcher) => {\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [asyncResult, setAsyncResult] = useState<{\n menuComponents: ReactNode[];\n items: { value: string; label: string; children?: ReactNode }[];\n }>({\n menuComponents: [],\n items: [],\n });\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setError(null);\n if (!getAsyncItems) {\n setAsyncResult({\n menuComponents: [],\n items: [],\n });\n }\n\n if (getAsyncItems) {\n setIsLoading(true);\n getAsyncItems(filterText)\n .then((items) => {\n setAsyncResult({\n menuComponents: items.map((item) => (\n <ForwardedRefSelectItem key={item.value} label={item.label} value={item.value}>\n {item.content ? item.content : item.label}\n </ForwardedRefSelectItem>\n )),\n items: items.map((item) => ({ value: item.value, label: item.label, children: item.content })),\n });\n setIsLoading(false);\n })\n .catch((error: Error) => {\n setError(error);\n setIsLoading(false);\n });\n }\n }, [filterText, getAsyncItems]);\n\n return { isLoading, error, menuComponents: asyncResult.menuComponents, items: asyncResult.items };\n};\n\n/**\n * Recursively extracts option values from children.\n * This function traverses through the React component tree and collects all SelectItem values.\n *\n * @param {ReactNode} children - The React children to extract values from.\n * @returns {SelectItemType[]} An array of SelectItemType objects.\n *\n * @example\n * const options = (\n * <SelectItem value=\"1\">Option 1</SelectItem>\n * <SelectItem value=\"2\">Option 2</SelectItem>\n * );\n * const values = getRecursiveOptionValues(options);\n * // Returns: [{ value: '1', label: 'Option 1' }, { value: '2', label: 'Option 2' }]\n */\nexport const getRecursiveOptionValues = (\n children: ReactNode,\n): { value: string; label: string; children?: ReactNode }[] => {\n const values: { value: string; label: string }[] = [];\n Children.forEach(children, (child) => {\n if (isValidElement<SelectItemProps>(child) && child.type === ForwardedRefSelectItem) {\n values.push(getSelectOptionValue(child.props));\n } else if (isValidElement<{ children: ReactNode }>(child) && child.props.children) {\n const optionValues = getRecursiveOptionValues(child.props.children);\n for (const optionValue of optionValues) {\n values.push(optionValue);\n }\n }\n });\n return values;\n};\n\n/**\n * Custom hook for managing select data and filtering.\n *\n * @param {ReactNode} children - The React children to process, typically SelectItem components.\n * @param {AsyncItemsFetcher} [getAsyncItems] - Optional function to fetch items asynchronously based on filter text.\n * @returns {Object} An object containing the processed data.\n */\nexport const useSelectData = (children: ReactNode, getAsyncItems?: AsyncItemsFetcher) => {\n const [filterText, setFilterText] = useState('');\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\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: <SelectClear /> });\n }\n }\n }\n });\n } else {\n menuSlots.push(children);\n }\n\n const itemValues = getRecursiveOptionValues(menuSlots);\n\n return { inputSlots, menuSlots, itemValues, clearButton };\n }, [children]);\n\n const items = useMemo(\n () =>\n itemValues.filter(\n (item) => filterText === '' || item.label.toLowerCase().includes(filterText.toLowerCase()),\n ),\n [itemValues, filterText],\n );\n\n const getItemByValue = useCallback(\n (value?: string | null) => (value !== undefined ? itemValues.find((item) => item.value === value) : undefined),\n [itemValues],\n );\n\n const asyncItems = useAsyncItems(filterText, getAsyncItems);\n\n return {\n items: [...items, ...asyncItems.items],\n menuSlots: [...menuSlots, ...asyncItems.menuComponents],\n filterText,\n inputSlots,\n clearButton,\n setFilterText,\n getItemByValue,\n asyncItemStatus: {\n isLoading: asyncItems.isLoading,\n error: asyncItems.error,\n },\n };\n};\n"],"names":["useAsyncItems","filterText","getAsyncItems","isLoading","setIsLoading","useState","error","setError","asyncResult","setAsyncResult","useEffect","items","item","jsx","ForwardedRefSelectItem","getRecursiveOptionValues","children","values","Children","child","isValidElement","getSelectOptionValue","optionValues","optionValue","useSelectData","setFilterText","inputSlots","menuSlots","itemValues","clearButton","useMemo","ForwardedRefSelectSlot","cloneElement","SelectClear","getItemByValue","useCallback","value","asyncItems"],"mappings":";;;;;;AA2BA,MAAMA,IAAgB,CAACC,GAAoBC,MAAsC;AAC7E,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAC/C,CAACG,GAAaC,CAAc,IAAIJ,EAGnC;AAAA,IACC,gBAAgB,CAAA;AAAA,IAChB,OAAO,CAAA;AAAA,EAAC,CACX;AAED,SAAAK,EAAU,MAAM;AAEZ,IAAAH,EAAS,IAAI,GACRL,KACDO,EAAe;AAAA,MACX,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AGV,GAAW,GAAGU,EAAW,cAAc;AAAA,IACtD,YAAApC;AAAA,IACA,YAAAyB;AAAA,IACA,aAAAG;AAAA,IACA,eAAAJ;AAAA,IACA,gBAAAS;AAAA,IACA,iBAAiB;AAAA,MACb,WAAWG,EAAW;AAAA,MACtB,OAAOA,EAAW;AAAA,IAAA;AAAA,EACtB;AAER;"}
1
+ {"version":3,"file":"fondue-components137.js","sources":["../src/components/Select/components/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 '#/components/ThemeProvider/ThemeProvider';\n\nimport styles from '../styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from '../utils';\n\nimport { type SelectItemProps } from './SelectItem';\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 selectedItemValues?: string[];\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 * @internal\n * Event handler called when the escape key is pressed.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n};\n\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n side,\n selectedItemValues,\n hasInteractedSinceOpening,\n viewportCollisionPadding = 'compact',\n onEscapeKeyDown,\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, dir } = useFondueTheme();\n\n const getAdjustedSide = (side: 'left' | 'right' | 'bottom' | 'top') => {\n if (dir === 'ltr') {\n return side;\n }\n\n if (side === 'left') {\n return 'right';\n }\n if (side === 'right') {\n return 'left';\n }\n\n return side;\n };\n\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme} dir={dir}>\n <RadixPopover.Content\n dir={dir}\n align={align}\n side={getAdjustedSide(side)}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding] + 8}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n onEscapeKeyDown={onEscapeKeyDown}\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 const isSelected = selectedItemValues?.includes(optionData.value);\n\n return (\n <RadixSlot\n className={styles.item}\n data-highlighted={highlightedIndex === index}\n data-selected={isSelected}\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 aria-selected={isSelected}\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","selectedItemValues","hasInteractedSinceOpening","viewportCollisionPadding","onEscapeKeyDown","handleOnOpenAutoFocus","event","VIEWPORT_COLLISION_PADDING_MAP","theme","dir","useFondueTheme","getAdjustedSide","RadixPopover","jsx","ThemeProvider","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","isSelected","RadixSlot"],"mappings":";;;;;;;AA4EO,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,oBAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,iBAAAC;AACJ,MAAuB;AACnB,QAAMC,I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ACG,WAAWT,EAAO;AAAA,oBAClB,oBAAkBrB,MAAqBwB;AAAA,oBACvC,iBAAeK;AAAA,oBAGf,cAAc,CAACjB,MAAU;AACrB,sBAAIgB,EAAU,WACVA,EAAU,QAAQhB,CAA2C;AAAA,oBAErE;AAAA,oBACC,GAAGgB;AAAA,oBACJ,iBAAeC;AAAA,oBAEd,UAAAN;AAAA,kBAAA;AAAA,kBAVIA,EAAM,MAAM;AAAA,gBAAA;AAAA,cAa7B;AAAA,YACJ;AAAA,YACAnB;AAAA,UAAA,EACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAEV;AAAA,EAAA,GAER,EAAA,CACJ;AAER;AACAL,EAAW,cAAc;"}
@@ -1,18 +1,34 @@
1
- import { useId as u, useMemo as f } from "react";
2
- import { useTranslation as D } from "./fondue-components42.js";
3
- const g = (t, n, r) => {
4
- const { t: i } = D(), s = u(), e = f(() => {
5
- if (!t || n.length === 0)
6
- return "";
7
- const p = n.map((c) => {
8
- const o = r(c);
9
- return (o == null ? void 0 : o.label) ?? c;
10
- }).join(", ");
11
- return i("Select_selectedCount", { count: n.length.toString(), items: p });
12
- }, [t, n, r, i]);
13
- return { selectionDescriptionId: s, selectionDescription: e };
1
+ import { jsxs as c, Fragment as n, jsx as r } from "react/jsx-runtime";
2
+ import { IconCheckMark as i, IconExclamationMarkTriangle as l } from "@frontify/fondue-icons";
3
+ import { useTranslation as m } from "./fondue-components42.js";
4
+ import s from "./fondue-components125.js";
5
+ const f = ({ status: o, hasError: a, dataTestId: e }) => {
6
+ const { t } = m();
7
+ return /* @__PURE__ */ c(n, { children: [
8
+ o === "success" ? /* @__PURE__ */ r(
9
+ i,
10
+ {
11
+ size: 16,
12
+ className: s.iconSuccess,
13
+ "data-test-id": `${e}-success-icon`,
14
+ "aria-hidden": "true"
15
+ }
16
+ ) : null,
17
+ a ? /* @__PURE__ */ c(n, { children: [
18
+ /* @__PURE__ */ r(
19
+ l,
20
+ {
21
+ size: 16,
22
+ className: s.iconError,
23
+ "data-test-id": `${e}-error-icon`,
24
+ "aria-hidden": "true"
25
+ }
26
+ ),
27
+ /* @__PURE__ */ r("span", { className: s.srOnly, role: "alert", children: t("Select_error") })
28
+ ] }) : null
29
+ ] });
14
30
  };
15
31
  export {
16
- g as useSelectionDescription
32
+ f as StatusIcons
17
33
  };
18
34
  //# sourceMappingURL=fondue-components138.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components138.js","sources":["../src/components/Select/hooks/useSelectionDescription.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useId, useMemo } from 'react';\n\nimport { useTranslation } from '#/hooks/useTranslation';\n\ntype SelectItemLike = {\n value: string;\n label: string;\n};\n\ntype SelectionDescription = {\n /** The unique ID for the SR description element. */\n selectionDescriptionId: string;\n /** The description text for screen readers (empty string when not applicable). */\n selectionDescription: string;\n};\n\nexport const useSelectionDescription = (\n isMultiple: boolean,\n selectedItemValues: string[],\n getItemByValue: (value?: string) => SelectItemLike | undefined,\n): SelectionDescription => {\n const { t } = useTranslation();\n const selectionDescriptionId = useId();\n\n const selectionDescription = useMemo((): string => {\n if (!isMultiple || selectedItemValues.length === 0) {\n return '';\n }\n const labels = selectedItemValues\n .map((value) => {\n const item = getItemByValue(value);\n return item?.label ?? value;\n })\n .join(', ');\n return t('Select_selectedCount', { count: selectedItemValues.length.toString(), items: labels });\n }, [isMultiple, selectedItemValues, getItemByValue, t]);\n\n return { selectionDescriptionId, selectionDescription };\n};\n"],"names":["useSelectionDescription","isMultiple","selectedItemValues","getItemByValue","t","useTranslation","selectionDescriptionId","useId","selectionDescription","useMemo","labels","value","item"],"mappings":";;AAkBO,MAAMA,IAA0B,CACnCC,GACAC,GACAC,MACuB;AACvB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IAAyBC,EAAA,GAEzBC,IAAuBC,EAAQ,MAAc;AAC/C,QAAI,CAACR,KAAcC,EAAmB,WAAW;AAC7C,aAAO;AAEX,UAAMQ,IAASR,EACV,IAAI,CAACS,MAAU;AACZ,YAAMC,IAAOT,EAAeQ,CAAK;AACjC,cAAOC,KAAA,gBAAAA,EAAM,UAASD;AAAA,IAC1B,CAAC,EACA,KAAK,IAAI;AACd,WAAOP,EAAE,wBAAwB,EAAE,OAAOF,EAAmB,OAAO,SAAA,GAAY,OAAOQ,GAAQ;AAAA,EACnG,GAAG,CAACT,GAAYC,GAAoBC,GAAgBC,CAAC,CAAC;AAEtD,SAAO,EAAE,wBAAAE,GAAwB,sBAAAE,EAAA;AACrC;"}
1
+ {"version":3,"file":"fondue-components138.js","sources":["../src/components/Select/components/StatusIcons.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport { type ReactNode } from 'react';\n\nimport { useTranslation } from '#/hooks/useTranslation';\n\nimport styles from '../styles/select.module.scss';\n\ntype StatusIconsProps = {\n /** The current status of the component. */\n status: 'neutral' | 'success' | 'error';\n /** Whether the component is in an error state (may differ from status when validation is involved). */\n hasError: boolean;\n /** The data-test-id prefix for the icons. */\n dataTestId: string;\n};\n\nexport const StatusIcons = ({ status, hasError, dataTestId }: StatusIconsProps): ReactNode => {\n const { t } = useTranslation();\n return (\n <>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n aria-hidden=\"true\"\n />\n ) : null}\n {hasError ? (\n <>\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n aria-hidden=\"true\"\n />\n <span className={styles.srOnly} role=\"alert\">\n {t('Select_error')}\n </span>\n </>\n ) : null}\n </>\n );\n};\n"],"names":["StatusIcons","status","hasError","dataTestId","useTranslation","jsxs","Fragment","jsx","IconCheckMark","styles","IconExclamationMarkTriangle"],"mappings":";;;;AAkBO,MAAMA,IAAc,CAAC,EAAE,QAAAC,GAAQ,UAAAC,GAAU,YAAAC,QAA8C;AAC1F,QAAM,EAAE,EAAA,IAAMC,EAAA;AACd,SACI,gBAAAC,EAAAC,GAAA,EACK,UAAA;AAAA,IAAAL,MAAW,YACR,gBAAAM;AAAA,MAACC;AAAA,MAAA;AAAA,QACG,MAAM;AAAA,QACN,WAAWC,EAAO;AAAA,QAClB,gBAAc,GAAGN,CAAU;AAAA,QAC3B,eAAY;AAAA,MAAA;AAAA,IAAA,IAEhB;AAAA,IACHD,IACG,gBAAAG,EAAAC,GAAA,EACI,UAAA;AAAA,MAAA,gBAAAC;AAAA,QAACG;AAAA,QAAA;AAAA,UACG,MAAM;AAAA,UACN,WAAWD,EAAO;AAAA,UAClB,gBAAc,GAAGN,CAAU;AAAA,UAC3B,eAAY;AAAA,QAAA;AAAA,MAAA;AAAA,MAEhB,gBAAAI,EAAC,UAAK,WAAWE,EAAO,QAAQ,MAAK,SAChC,UAAA,EAAE,cAAc,EAAA,CACrB;AAAA,IAAA,EAAA,CACJ,IACA;AAAA,EAAA,GACR;AAER;"}
@@ -1,10 +1,173 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { Slot as e } from "@radix-ui/react-slot";
3
- import a from "./fondue-components127.js";
4
- const m = ({ children: o, onClear: t }) => /* @__PURE__ */ r(e, { onClick: (l) => {
5
- l.stopPropagation(), t();
6
- }, className: a.clear, role: "button", "aria-label": "Clear selection", children: o });
1
+ import { computed as U, untracked as ue, batch as X, effect as le, signal as fe } from "./fondue-components142.js";
2
+ import { Signal as Ee } from "./fondue-components142.js";
3
+ var _e = Object.create, G = Object.defineProperty, he = Object.defineProperties, pe = Object.getOwnPropertyDescriptor, ve = Object.getOwnPropertyDescriptors, Y = Object.getOwnPropertySymbols, de = Object.prototype.hasOwnProperty, ge = Object.prototype.propertyIsEnumerable, Oe = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), O = (e) => {
4
+ throw TypeError(e);
5
+ }, A = (e, t, r) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ye = (e, t) => {
6
+ for (var r in t || (t = {}))
7
+ de.call(t, r) && A(e, r, t[r]);
8
+ if (Y)
9
+ for (var r of Y(t))
10
+ ge.call(t, r) && A(e, r, t[r]);
11
+ return e;
12
+ }, we = (e, t) => he(e, ve(t)), Z = (e, t) => G(e, "name", { value: t, configurable: !0 }), Pe = (e) => {
13
+ var t;
14
+ return [, , , _e((t = void 0) != null ? t : null)];
15
+ }, x = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], P = (e) => e !== void 0 && typeof e != "function" ? O("Function expected") : e, Se = (e, t, r, i, n) => ({ kind: x[e], name: t, metadata: i, addInitializer: (a) => r._ ? O("Already initialized") : n.push(P(a || null)) }), ee = (e, t) => A(t, Oe("metadata"), e[3]), d = (e, t, r, i) => {
16
+ for (var n = 0, a = e[t >> 1], p = a && a.length; n < p; n++) t & 1 ? a[n].call(r) : i = a[n].call(r, i);
17
+ return i;
18
+ }, y = (e, t, r, i, n, a) => {
19
+ var p, l, L, w, m, s = t & 7, j = !!(t & 8), h = !!(t & 16), D = s > 3 ? e.length + 1 : s ? j ? 1 : 2 : 0, Q = x[s + 5], R = s > 3 && (e[D - 1] = []), ce = e[D] || (e[D] = []), _ = s && (!h && !j && (n = n.prototype), s < 5 && (s > 3 || !h) && pe(s < 4 ? n : { get [r]() {
20
+ return f(this, a);
21
+ }, set [r](u) {
22
+ return v(this, a, u);
23
+ } }, r));
24
+ s ? h && s < 4 && Z(a, (s > 2 ? "set " : s > 1 ? "get " : "") + r) : Z(n, r);
25
+ for (var M = i.length - 1; M >= 0; M--)
26
+ w = Se(s, r, L = {}, e[3], ce), s && (w.static = j, w.private = h, m = w.access = { has: h ? (u) => ke(n, u) : (u) => r in u }, s ^ 3 && (m.get = h ? (u) => (s ^ 1 ? f : me)(u, n, s ^ 4 ? a : _.get) : (u) => u[r]), s > 2 && (m.set = h ? (u, V) => v(u, n, V, s ^ 4 ? a : _.set) : (u, V) => u[r] = V)), l = (0, i[M])(s ? s < 4 ? h ? a : _[Q] : s > 4 ? void 0 : { get: _.get, set: _.set } : n, w), L._ = 1, s ^ 4 || l === void 0 ? P(l) && (s > 4 ? R.unshift(l) : s ? h ? a = l : _[Q] = l : n = l) : typeof l != "object" || l === null ? O("Object expected") : (P(p = l.get) && (_.get = p), P(p = l.set) && (_.set = p), P(p = l.init) && R.unshift(p));
27
+ return s || ee(e, n), _ && G(n, r, _), h ? s ^ 4 ? a : _ : n;
28
+ }, N = (e, t, r) => t.has(e) || O("Cannot " + r), ke = (e, t) => Object(t) !== t ? O('Cannot use the "in" operator on this value') : e.has(t), f = (e, t, r) => (N(e, t, "read from private field"), r ? r.call(e) : t.get(e)), S = (e, t, r) => t.has(e) ? O("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), v = (e, t, r, i) => (N(e, t, "write to private field"), i ? i.call(e, r) : t.set(e, r), r), me = (e, t, r) => (N(e, t, "access private method"), r);
29
+ function je(e, t) {
30
+ if (t) {
31
+ let r;
32
+ return U(() => {
33
+ const i = e();
34
+ return i && r && t(r, i) ? r : (r = i, i);
35
+ });
36
+ }
37
+ return U(e);
38
+ }
39
+ function $(e, t) {
40
+ if (Object.is(e, t))
41
+ return !0;
42
+ if (e === null || t === null) return !1;
43
+ if (typeof e == "function" && typeof t == "function")
44
+ return e === t;
45
+ if (e instanceof Set && t instanceof Set) {
46
+ if (e.size !== t.size)
47
+ return !1;
48
+ for (const r of e)
49
+ if (!t.has(r))
50
+ return !1;
51
+ return !0;
52
+ }
53
+ if (Array.isArray(e))
54
+ return !Array.isArray(t) || e.length !== t.length ? !1 : !e.some(
55
+ (i, n) => !$(i, t[n])
56
+ );
57
+ if (typeof e == "object" && typeof t == "object") {
58
+ const r = Object.keys(e), i = Object.keys(t);
59
+ return r.length !== i.length ? !1 : !r.some(
60
+ (a) => !$(e[a], t[a])
61
+ );
62
+ }
63
+ return !1;
64
+ }
65
+ function W({ get: e }, t) {
66
+ return {
67
+ init(r) {
68
+ return fe(r);
69
+ },
70
+ get() {
71
+ return e.call(this).value;
72
+ },
73
+ set(r) {
74
+ const i = e.call(this);
75
+ i.peek() !== r && (i.value = r);
76
+ }
77
+ };
78
+ }
79
+ function Me(e, t) {
80
+ const r = /* @__PURE__ */ new WeakMap();
81
+ return function() {
82
+ let i = r.get(this);
83
+ return i || (i = je(e.bind(this)), r.set(this, i)), i.value;
84
+ };
85
+ }
86
+ function b(e = !0) {
87
+ return function(t, r) {
88
+ r.addInitializer(function() {
89
+ const i = r.kind === "field" ? this : r.static ? this : Object.getPrototypeOf(this), n = Object.getOwnPropertyDescriptor(i, r.name);
90
+ n && Object.defineProperty(i, r.name, we(ye({}, n), { enumerable: e }));
91
+ });
92
+ };
93
+ }
94
+ function Ve(...e) {
95
+ const t = e.map((r) => le(r));
96
+ return () => t.forEach((r) => r());
97
+ }
98
+ var te, re, ie, se, ne, ae, c, T, z, C, q, o, B, E, oe, F, J, I, H, K;
99
+ ae = [W], ne = [W], se = [W], ie = [b()], re = [b()], te = [b()];
100
+ var k = class {
101
+ constructor(e, t = Object.is) {
102
+ this.defaultValue = e, this.equals = t, d(c, 5, this), S(this, o), S(this, T, d(c, 8, this)), d(c, 11, this), S(this, B, d(c, 12, this)), d(c, 15, this), S(this, J, d(c, 16, this)), d(c, 19, this), this.reset = this.reset.bind(this), this.reset();
103
+ }
104
+ get current() {
105
+ return f(this, o, H);
106
+ }
107
+ get initial() {
108
+ return f(this, o, C);
109
+ }
110
+ get previous() {
111
+ return f(this, o, oe);
112
+ }
113
+ /** Set the current value */
114
+ set current(e) {
115
+ const t = ue(() => f(this, o, H));
116
+ e && t && this.equals(t, e) || X(() => {
117
+ f(this, o, C) || v(this, o, e, q), v(this, o, t, F), v(this, o, e, K);
118
+ });
119
+ }
120
+ /** Reset the state to the initial value */
121
+ reset(e = this.defaultValue) {
122
+ X(() => {
123
+ v(this, o, void 0, F), v(this, o, e, q), v(this, o, e, K);
124
+ });
125
+ }
126
+ };
127
+ c = Pe();
128
+ T = /* @__PURE__ */ new WeakMap();
129
+ o = /* @__PURE__ */ new WeakSet();
130
+ B = /* @__PURE__ */ new WeakMap();
131
+ J = /* @__PURE__ */ new WeakMap();
132
+ z = y(c, 20, "#initial", ae, o, T), C = z.get, q = z.set;
133
+ E = y(c, 20, "#previous", ne, o, B), oe = E.get, F = E.set;
134
+ I = y(c, 20, "#current", se, o, J), H = I.get, K = I.set;
135
+ y(c, 2, "current", ie, k);
136
+ y(c, 2, "initial", re, k);
137
+ y(c, 2, "previous", te, k);
138
+ ee(c, k);
139
+ var g, We = class {
140
+ constructor() {
141
+ S(this, g, /* @__PURE__ */ new WeakMap());
142
+ }
143
+ get(e, t) {
144
+ var r;
145
+ return e ? (r = f(this, g).get(e)) == null ? void 0 : r.get(t) : void 0;
146
+ }
147
+ set(e, t, r) {
148
+ var i;
149
+ if (e)
150
+ return f(this, g).has(e) || f(this, g).set(e, /* @__PURE__ */ new Map()), (i = f(this, g).get(e)) == null ? void 0 : i.set(t, r);
151
+ }
152
+ clear(e) {
153
+ var t;
154
+ return e ? (t = f(this, g).get(e)) == null ? void 0 : t.clear() : void 0;
155
+ }
156
+ };
157
+ g = /* @__PURE__ */ new WeakMap();
7
158
  export {
8
- m as ClearButton
159
+ Ee as Signal,
160
+ k as ValueHistory,
161
+ We as WeakStore,
162
+ X as batch,
163
+ je as computed,
164
+ $ as deepEqual,
165
+ Me as derived,
166
+ le as effect,
167
+ Ve as effects,
168
+ b as enumerable,
169
+ W as reactive,
170
+ fe as signal,
171
+ ue as untracked
9
172
  };
10
173
  //# sourceMappingURL=fondue-components139.js.map