@frontify/fondue-components 28.0.0 → 29.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components.js +60 -56
- package/dist/fondue-components.js.map +1 -1
- package/dist/fondue-components10.js +1 -1
- package/dist/fondue-components100.js +22 -16
- package/dist/fondue-components100.js.map +1 -1
- package/dist/fondue-components101.js +34 -151
- package/dist/fondue-components101.js.map +1 -1
- package/dist/fondue-components102.js +10 -44
- package/dist/fondue-components102.js.map +1 -1
- package/dist/fondue-components103.js +67 -13
- package/dist/fondue-components103.js.map +1 -1
- package/dist/fondue-components104.js +13 -13
- package/dist/fondue-components105.js +26 -111
- package/dist/fondue-components105.js.map +1 -1
- package/dist/fondue-components106.js +18 -12
- package/dist/fondue-components106.js.map +1 -1
- package/dist/fondue-components107.js +25 -17
- package/dist/fondue-components107.js.map +1 -1
- package/dist/fondue-components108.js +8 -12
- package/dist/fondue-components108.js.map +1 -1
- package/dist/fondue-components109.js +30 -16
- package/dist/fondue-components109.js.map +1 -1
- package/dist/fondue-components11.js +3 -3
- package/dist/fondue-components110.js +7 -6
- package/dist/fondue-components110.js.map +1 -1
- package/dist/fondue-components111.js +4 -11
- package/dist/fondue-components111.js.map +1 -1
- package/dist/fondue-components112.js +4 -70
- package/dist/fondue-components112.js.map +1 -1
- package/dist/fondue-components113.js +16 -14
- package/dist/fondue-components113.js.map +1 -1
- package/dist/fondue-components114.js +14 -7
- package/dist/fondue-components114.js.map +1 -1
- package/dist/fondue-components115.js +14 -88
- package/dist/fondue-components115.js.map +1 -1
- package/dist/fondue-components116.js +108 -78
- package/dist/fondue-components116.js.map +1 -1
- package/dist/fondue-components117.js +12 -30
- package/dist/fondue-components117.js.map +1 -1
- package/dist/fondue-components118.js +17 -29
- package/dist/fondue-components118.js.map +1 -1
- package/dist/fondue-components119.js +16 -0
- package/dist/fondue-components119.js.map +1 -0
- package/dist/fondue-components12.js +3 -3
- package/dist/fondue-components120.js +127 -41
- package/dist/fondue-components120.js.map +1 -1
- package/dist/fondue-components121.js +11 -19
- package/dist/fondue-components121.js.map +1 -1
- package/dist/fondue-components122.js +33 -18
- package/dist/fondue-components122.js.map +1 -1
- package/dist/fondue-components123.js +215 -38
- package/dist/fondue-components123.js.map +1 -1
- package/dist/fondue-components124.js +18 -67
- package/dist/fondue-components124.js.map +1 -1
- package/dist/fondue-components125.js +16 -30
- package/dist/fondue-components125.js.map +1 -1
- package/dist/fondue-components126.js +151 -9
- package/dist/fondue-components126.js.map +1 -1
- package/dist/fondue-components127.js +44 -152
- package/dist/fondue-components127.js.map +1 -1
- package/dist/fondue-components128.js +168 -106
- package/dist/fondue-components128.js.map +1 -1
- package/dist/fondue-components129.js +61 -17
- package/dist/fondue-components129.js.map +1 -1
- package/dist/fondue-components13.js +61 -35
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components130.js +8 -15
- package/dist/fondue-components130.js.map +1 -1
- package/dist/fondue-components131.js +255 -28
- package/dist/fondue-components131.js.map +1 -1
- package/dist/fondue-components132.js +29 -13
- package/dist/fondue-components132.js.map +1 -1
- package/dist/fondue-components134.js +44 -0
- package/dist/fondue-components134.js.map +1 -0
- package/dist/fondue-components135.js +9 -0
- package/dist/fondue-components135.js.map +1 -0
- package/dist/fondue-components136.js +15 -0
- package/dist/fondue-components136.js.map +1 -0
- package/dist/fondue-components137.js +74 -0
- package/dist/fondue-components137.js.map +1 -0
- package/dist/fondue-components138.js +18 -0
- package/dist/fondue-components138.js.map +1 -0
- package/dist/fondue-components139.js +10 -0
- package/dist/fondue-components139.js.map +1 -0
- package/dist/fondue-components14.js +36 -121
- package/dist/fondue-components14.js.map +1 -1
- package/dist/fondue-components140.js +92 -0
- package/dist/fondue-components140.js.map +1 -0
- package/dist/fondue-components141.js +84 -0
- package/dist/fondue-components141.js.map +1 -0
- package/dist/fondue-components142.js +34 -0
- package/dist/fondue-components142.js.map +1 -0
- package/dist/fondue-components143.js +22 -0
- package/dist/fondue-components143.js.map +1 -0
- package/dist/fondue-components144.js +73 -0
- package/dist/fondue-components144.js.map +1 -0
- package/dist/fondue-components145.js +1355 -0
- package/dist/fondue-components145.js.map +1 -0
- package/dist/fondue-components146.js +944 -0
- package/dist/fondue-components146.js.map +1 -0
- package/dist/fondue-components147.js +201 -0
- package/dist/fondue-components147.js.map +1 -0
- package/dist/fondue-components148.js +24 -0
- package/dist/fondue-components148.js.map +1 -0
- package/dist/fondue-components149.js +43 -0
- package/dist/fondue-components149.js.map +1 -0
- package/dist/fondue-components15.js +121 -36
- package/dist/fondue-components15.js.map +1 -1
- package/dist/fondue-components150.js +71 -0
- package/dist/fondue-components150.js.map +1 -0
- package/dist/fondue-components151.js +34 -0
- package/dist/fondue-components151.js.map +1 -0
- package/dist/fondue-components152.js +12 -0
- package/dist/fondue-components152.js.map +1 -0
- package/dist/fondue-components153.js +156 -0
- package/dist/fondue-components153.js.map +1 -0
- package/dist/fondue-components154.js +111 -0
- package/dist/fondue-components154.js.map +1 -0
- package/dist/fondue-components155.js +19 -0
- package/dist/fondue-components155.js.map +1 -0
- package/dist/fondue-components156.js +19 -0
- package/dist/fondue-components156.js.map +1 -0
- package/dist/fondue-components157.js +32 -0
- package/dist/fondue-components157.js.map +1 -0
- package/dist/fondue-components158.js +16 -0
- package/dist/fondue-components158.js.map +1 -0
- package/dist/{fondue-components133.js → fondue-components159.js} +1 -1
- package/dist/{fondue-components133.js.map → fondue-components159.js.map} +1 -1
- package/dist/fondue-components16.js +30 -39
- package/dist/fondue-components16.js.map +1 -1
- package/dist/fondue-components17.js +44 -41
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js +42 -57
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js +55 -41
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js +39 -16
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +17 -43
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +42 -69
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +69 -17
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +71 -74
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +18 -36
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +72 -50
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +36 -23
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +50 -50
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +23 -100
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components3.js +1 -1
- package/dist/fondue-components30.js +50 -28
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +92 -188
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +31 -144
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +192 -129
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +141 -27
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +123 -71
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +28 -120
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +80 -35
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +119 -52
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +36 -20
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js +3 -3
- package/dist/fondue-components40.js +56 -25
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +20 -7
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +25 -8
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +8 -41
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +8 -4
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +41 -5
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +3 -11
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +5 -32
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +12 -53
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +32 -131
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components5.js +2 -2
- package/dist/fondue-components50.js +53 -20
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +131 -53
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +20 -7
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +53 -13
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +7 -16
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +13 -5
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +17 -18
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +4 -18
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +18 -44
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +18 -24
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components6.js +1 -1
- package/dist/fondue-components60.js +43 -22
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +24 -4
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +22 -12
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +6 -4
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +4 -17
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +12 -10
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +4 -36
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +17 -6
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +10 -4
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components69.js +34 -10
- package/dist/fondue-components69.js.map +1 -1
- package/dist/fondue-components7.js +1 -1
- package/dist/fondue-components70.js +6 -8
- package/dist/fondue-components70.js.map +1 -1
- package/dist/fondue-components71.js +4 -12
- package/dist/fondue-components71.js.map +1 -1
- package/dist/fondue-components72.js +11 -3
- package/dist/fondue-components72.js.map +1 -1
- package/dist/fondue-components73.js +50 -23
- package/dist/fondue-components73.js.map +1 -1
- package/dist/fondue-components74.js +44 -17
- package/dist/fondue-components74.js.map +1 -1
- package/dist/fondue-components75.js +6 -20
- package/dist/fondue-components75.js.map +1 -1
- package/dist/fondue-components76.js +6 -20
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +12 -19
- package/dist/fondue-components77.js.map +1 -1
- package/dist/fondue-components78.js +24 -16
- package/dist/fondue-components78.js.map +1 -1
- package/dist/fondue-components79.js +13 -19
- package/dist/fondue-components79.js.map +1 -1
- package/dist/fondue-components8.js +5 -5
- package/dist/fondue-components80.js +5 -8
- package/dist/fondue-components80.js.map +1 -1
- package/dist/fondue-components81.js +12 -10
- package/dist/fondue-components81.js.map +1 -1
- package/dist/fondue-components82.js +47 -10
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +20 -4
- package/dist/fondue-components83.js.map +1 -1
- package/dist/fondue-components84.js +628 -12
- package/dist/fondue-components84.js.map +1 -1
- package/dist/fondue-components85.js +8 -22
- package/dist/fondue-components85.js.map +1 -1
- package/dist/fondue-components86.js +13 -34
- package/dist/fondue-components86.js.map +1 -1
- package/dist/fondue-components87.js +4 -10
- package/dist/fondue-components87.js.map +1 -1
- package/dist/fondue-components88.js +23 -66
- package/dist/fondue-components88.js.map +1 -1
- package/dist/fondue-components89.js +14 -12
- package/dist/fondue-components89.js.map +1 -1
- package/dist/fondue-components9.js +5 -5
- package/dist/fondue-components90.js +20 -25
- package/dist/fondue-components90.js.map +1 -1
- package/dist/fondue-components91.js +20 -19
- package/dist/fondue-components91.js.map +1 -1
- package/dist/fondue-components92.js +20 -25
- package/dist/fondue-components92.js.map +1 -1
- package/dist/fondue-components93.js +20 -9
- package/dist/fondue-components93.js.map +1 -1
- package/dist/fondue-components94.js +19 -31
- package/dist/fondue-components94.js.map +1 -1
- package/dist/fondue-components95.js +8 -7
- package/dist/fondue-components95.js.map +1 -1
- package/dist/fondue-components96.js +10 -4
- package/dist/fondue-components96.js.map +1 -1
- package/dist/fondue-components97.js +10 -4
- package/dist/fondue-components97.js.map +1 -1
- package/dist/fondue-components98.js +6 -216
- package/dist/fondue-components98.js.map +1 -1
- package/dist/fondue-components99.js +12 -18
- package/dist/fondue-components99.js.map +1 -1
- package/dist/index.d.ts +100 -2
- package/dist/style.css +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const e = "_wrapper_ejipv_4", t = "_root_ejipv_8", o = "_toggleMonthButtonContainer_ejipv_8", n = "_nextMonthButtonContainer_ejipv_22", _ = "_weekday_ejipv_27", d = "_weekdays_ejipv_39", s = "_week_ejipv_27", c = "_day_ejipv_49", i = "_disabled_ejipv_69", r = "_dayContent_ejipv_72", a = "_outside_ejipv_76", v = "_dayButton_ejipv_89", l = "_selected_ejipv_123", p = "_selectedMiddle_ejipv_133", j = "_selectedStart_ejipv_146", y = "_selectedEnd_ejipv_146", h = "_hoverAfter_ejipv_179", u = "_hoverSelected_ejipv_192", w = "_hoverBefore_ejipv_253", B = {
|
|
2
|
+
wrapper: e,
|
|
3
|
+
root: t,
|
|
4
|
+
toggleMonthButtonContainer: o,
|
|
5
|
+
nextMonthButtonContainer: n,
|
|
6
|
+
weekday: _,
|
|
7
|
+
weekdays: d,
|
|
8
|
+
week: s,
|
|
9
|
+
day: c,
|
|
10
|
+
disabled: i,
|
|
11
|
+
dayContent: r,
|
|
12
|
+
outside: a,
|
|
13
|
+
dayButton: v,
|
|
14
|
+
selected: l,
|
|
15
|
+
selectedMiddle: p,
|
|
16
|
+
selectedStart: j,
|
|
17
|
+
selectedEnd: y,
|
|
18
|
+
hoverAfter: h,
|
|
19
|
+
hoverSelected: u,
|
|
20
|
+
hoverBefore: w
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
c as day,
|
|
24
|
+
v as dayButton,
|
|
25
|
+
r as dayContent,
|
|
26
|
+
B as default,
|
|
27
|
+
i as disabled,
|
|
28
|
+
h as hoverAfter,
|
|
29
|
+
w as hoverBefore,
|
|
30
|
+
u as hoverSelected,
|
|
31
|
+
n as nextMonthButtonContainer,
|
|
32
|
+
a as outside,
|
|
33
|
+
t as root,
|
|
34
|
+
l as selected,
|
|
35
|
+
y as selectedEnd,
|
|
36
|
+
p as selectedMiddle,
|
|
37
|
+
j as selectedStart,
|
|
38
|
+
o as toggleMonthButtonContainer,
|
|
39
|
+
s as week,
|
|
40
|
+
_ as weekday,
|
|
41
|
+
d as weekdays,
|
|
42
|
+
e as wrapper
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=fondue-components134.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components134.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useMemo as t } from "react";
|
|
2
|
+
const m = (n, s) => t(() => n.map((r) => {
|
|
3
|
+
const o = s(r), p = (o == null ? void 0 : o.label) ?? r;
|
|
4
|
+
return { value: r, displayValue: p };
|
|
5
|
+
}), [n, s]);
|
|
6
|
+
export {
|
|
7
|
+
m as useBadgeItems
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=fondue-components135.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components135.js","sources":["../src/components/Select/hooks/useBadgeItems.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useMemo } from 'react';\n\ntype SelectItemLike = {\n value: string;\n label: string;\n};\n\ntype BadgeItem = {\n value: string;\n displayValue: string;\n};\n\nexport const useBadgeItems = (\n selectedItemValues: string[],\n getItemByValue: (value?: string) => SelectItemLike | undefined,\n): BadgeItem[] => {\n return useMemo(() => {\n return selectedItemValues.map((value) => {\n const item = getItemByValue(value);\n const displayValue = item?.label ?? value;\n return { value, displayValue };\n });\n }, [selectedItemValues, getItemByValue]);\n};\n"],"names":["useBadgeItems","selectedItemValues","getItemByValue","useMemo","value","item","displayValue"],"mappings":";AAcO,MAAMA,IAAgB,CACzBC,GACAC,MAEOC,EAAQ,MACJF,EAAmB,IAAI,CAACG,MAAU;AACrC,QAAMC,IAAOH,EAAeE,CAAK,GAC3BE,KAAeD,KAAA,gBAAAA,EAAM,UAASD;AACpC,SAAO,EAAE,OAAAA,GAAO,cAAAE,EAAA;AACpB,CAAC,GACF,CAACL,GAAoBC,CAAc,CAAC;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 };
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
c as useFocusRing
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=fondue-components136.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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);
|
|
34
|
+
}
|
|
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
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
g as getRecursiveOptionValues,
|
|
72
|
+
q as useSelectData
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=fondue-components137.js.map
|
|
@@ -0,0 +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,gBAAgB,CAAA;AAAA,MAChB,OAAO,CAAA;AAAA,IAAC,CACX,GAGDP,MACAE,EAAa,EAAI,GACjBF,EAAcD,CAAU,EACnB,KAAK,CAACU,MAAU;AACb,MAAAF,EAAe;AAAA,QACX,gBAAgBE,EAAM,IAAI,CAACC,MACvB,gBAAAC,EAACC,GAAA,EAAwC,OAAOF,EAAK,OAAO,OAAOA,EAAK,OACnE,YAAK,UAAUA,EAAK,UAAUA,EAAK,MAAA,GADXA,EAAK,KAElC,CACH;AAAA,QACD,OAAOD,EAAM,IAAI,CA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KR,EAAM,MAAM,QAAQ,IAC5BA,EAAM,MAAM,SAAS,UAAUA,EAAM,MAAM,SAAS,UAC3DO,EAAW,KAAKP,CAAK,IACdA,EAAM,MAAM,SAAS,YACxBA,EAAM,MAAM,WACZU,IAAcV,IAEdU,IAAcG,EAAab,GAAO,EAAE,UAAU,gBAAAN,EAACoB,GAAA,CAAA,CAAY,GAAI;AAAA,IAI/E,CAAC,IAEDN,EAAU,KAAKX,CAAQ;AAG3B,UAAMY,IAAab,EAAyBY,CAAS;AAErD,WAAO,EAAE,YAAAD,GAAY,WAAAC,GAAW,YAAAC,GAAY,aAAAC,EAAAA;AAAAA,EAChD,GAAG,CAACb,CAAQ,CAAC,GAEPL,IAAQmB;AAAA,IACV,MACIF,EAAW;AAAA,MACP,CAAChB,MAASX,MAAe,MAAMW,EAAK,MAAM,cAAc,SAASX,EAAW,YAAA,CAAa;AAAA,IAAA;AAAA,IAEjG,CAAC2B,GAAY3B,CAAU;AAAA,EAAA,GAGrBiC,IAAiBC;AAAA,IACnB,CAACC,MAA2BA,MAAU,SAAYR,EAAW,KAAK,CAAChB,MAASA,EAAK,UAAUwB,CAAK,IAAI;AAAA,IACpG,CAACR,CAAU;AAAA,EAAA,GAGTS,IAAarC,EAAcC,GAAYC,CAAa;AAE1D,SAAO;AAAA,IACH,OAAO,CAAC,GAAGS,GAAO,GAAG0B,EAAW,KAAK;AAAA,IACrC,WAAW,CAAC,GAAGV,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;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 };
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
g as useSelectionDescription
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=fondue-components138.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 });
|
|
7
|
+
export {
|
|
8
|
+
m as ClearButton
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=fondue-components139.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components139.js","sources":["../src/components/Select/components/ClearButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { type MouseEvent, type ReactNode } from 'react';\n\nimport styles from '../styles/select.module.scss';\n\ntype ClearButtonProps = {\n /** The clear button element to render inside the slot. */\n children: ReactNode;\n /** Callback fired when the clear button is clicked. */\n onClear: () => void;\n};\n\nexport const ClearButton = ({ children, onClear }: ClearButtonProps): ReactNode => {\n const handleClick = (event: MouseEvent): void => {\n event.stopPropagation();\n onClear();\n };\n\n return (\n <RadixSlot onClick={handleClick} className={styles.clear} role=\"button\" aria-label=\"Clear selection\">\n {children}\n </RadixSlot>\n );\n};\n"],"names":["ClearButton","children","onClear","jsx","RadixSlot","event","styles"],"mappings":";;;AAcO,MAAMA,IAAc,CAAC,EAAE,UAAAC,GAAU,SAAAC,QAOhC,gBAAAC,EAACC,GAAA,EAAU,SANK,CAACC,MAA4B;AAC7C,EAAAA,EAAM,gBAAA,GACNH,EAAA;AACJ,GAGqC,WAAWI,EAAO,OAAO,MAAK,UAAS,cAAW,mBAC9E,UAAAL,EAAA,CACL;"}
|
|
@@ -1,125 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as n } from "react";
|
|
3
|
+
import { propsToCssVariables as y } from "./fondue-components45.js";
|
|
4
|
+
import x from "./fondue-components64.js";
|
|
5
|
+
const u = n(
|
|
6
|
+
({
|
|
7
|
+
as: a = "div",
|
|
8
|
+
"data-test-id": e = "fondue-flex",
|
|
9
|
+
children: r,
|
|
10
|
+
role: i,
|
|
11
|
+
"aria-label": d,
|
|
12
|
+
"aria-hidden": s,
|
|
13
|
+
"aria-describedby": t,
|
|
14
|
+
"aria-labelledby": o,
|
|
15
|
+
"aria-expanded": l,
|
|
16
|
+
"aria-haspopup": p,
|
|
17
|
+
...b
|
|
18
|
+
}, f) => /* @__PURE__ */ m(
|
|
19
|
+
a,
|
|
20
|
+
{
|
|
21
|
+
className: x.root,
|
|
22
|
+
"data-test-id": e,
|
|
23
|
+
style: y(b, { justify: "justify-content" }),
|
|
24
|
+
role: i,
|
|
25
|
+
"aria-label": d,
|
|
26
|
+
"aria-hidden": s,
|
|
27
|
+
"aria-describedby": t,
|
|
28
|
+
"aria-labelledby": o,
|
|
29
|
+
"aria-expanded": l,
|
|
30
|
+
"aria-haspopup": p,
|
|
31
|
+
ref: f,
|
|
32
|
+
children: r
|
|
33
|
+
}
|
|
34
|
+
)
|
|
24
35
|
);
|
|
25
|
-
|
|
26
|
-
const D = {
|
|
27
|
-
compact: 8,
|
|
28
|
-
comfortable: 12,
|
|
29
|
-
spacious: 16
|
|
30
|
-
}, H = {
|
|
31
|
-
compact: 8,
|
|
32
|
-
spacious: 24
|
|
33
|
-
}, p = ({
|
|
34
|
-
align: t = "start",
|
|
35
|
-
maxWidth: o = "360px",
|
|
36
|
-
padding: a = "compact",
|
|
37
|
-
rounded: r = "medium",
|
|
38
|
-
width: d = "fit-content",
|
|
39
|
-
shadow: n = "medium",
|
|
40
|
-
side: N,
|
|
41
|
-
triggerOffset: v = "compact",
|
|
42
|
-
viewportCollisionPadding: C = "compact",
|
|
43
|
-
"data-test-id": P = "fondue-flyout-content",
|
|
44
|
-
children: R,
|
|
45
|
-
...b
|
|
46
|
-
}, w) => {
|
|
47
|
-
const { theme: A, dir: c } = S(), T = (s) => !s || c === "ltr" ? s : s === "left" ? "right" : s === "right" ? "left" : s;
|
|
48
|
-
return /* @__PURE__ */ e(l.Portal, { children: /* @__PURE__ */ m(j, { theme: A, dir: c, children: [
|
|
49
|
-
/* @__PURE__ */ e("div", { "data-test-id": "fondue-flyout-overlay", className: u.overlay }),
|
|
50
|
-
/* @__PURE__ */ e(
|
|
51
|
-
l.Content,
|
|
52
|
-
{
|
|
53
|
-
dir: c,
|
|
54
|
-
style: {
|
|
55
|
-
"--flyout-max-width": o,
|
|
56
|
-
"--flyout-width": d
|
|
57
|
-
},
|
|
58
|
-
ref: w,
|
|
59
|
-
align: t,
|
|
60
|
-
collisionPadding: H[C],
|
|
61
|
-
sideOffset: D[v],
|
|
62
|
-
side: T(N),
|
|
63
|
-
className: u.root,
|
|
64
|
-
"data-flyout-spacing": a,
|
|
65
|
-
"data-rounded": r,
|
|
66
|
-
"data-shadow": n,
|
|
67
|
-
"data-test-id": P,
|
|
68
|
-
onFocus: B,
|
|
69
|
-
...b,
|
|
70
|
-
children: R
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
] }) });
|
|
74
|
-
};
|
|
75
|
-
p.displayName = "Flyout.Content";
|
|
76
|
-
const F = ({ showCloseButton: t, children: o, "data-test-id": a = "fondue-flyout-header", closeProps: r }, d) => {
|
|
77
|
-
const { t: n } = I();
|
|
78
|
-
return /* @__PURE__ */ m("div", { "data-test-id": a, ref: d, className: u.header, children: [
|
|
79
|
-
/* @__PURE__ */ e("div", { children: o }),
|
|
80
|
-
t && /* @__PURE__ */ e(l.Close, { asChild: !0, ...r, children: /* @__PURE__ */ e(
|
|
81
|
-
O,
|
|
82
|
-
{
|
|
83
|
-
size: "small",
|
|
84
|
-
aspect: "square",
|
|
85
|
-
emphasis: "weak",
|
|
86
|
-
"aria-label": n("Flyout_close"),
|
|
87
|
-
"data-test-id": `${a}-close`,
|
|
88
|
-
children: /* @__PURE__ */ e(x, { size: 20 })
|
|
89
|
-
}
|
|
90
|
-
) })
|
|
91
|
-
] });
|
|
92
|
-
};
|
|
93
|
-
F.displayName = "Flyout.Header";
|
|
94
|
-
const g = ({ children: t, "data-test-id": o = "fondue-flyout-footer" }, a) => /* @__PURE__ */ e("div", { "data-test-id": o, ref: a, className: u.footer, children: t });
|
|
95
|
-
g.displayName = "Flyout.Footer";
|
|
96
|
-
const h = ({ children: t, "data-test-id": o = "fondue-flyout-body", scrollable: a = !1 }, r) => /* @__PURE__ */ e(
|
|
97
|
-
"div",
|
|
98
|
-
{
|
|
99
|
-
"data-test-id": o,
|
|
100
|
-
ref: r,
|
|
101
|
-
"data-flyout-spacing": "compact",
|
|
102
|
-
"data-scrollable": a,
|
|
103
|
-
className: u.body,
|
|
104
|
-
children: t
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
h.displayName = "Flyout.Body";
|
|
108
|
-
const W = {
|
|
109
|
-
Root: f,
|
|
110
|
-
Trigger: i(y),
|
|
111
|
-
Content: i(p),
|
|
112
|
-
Header: i(F),
|
|
113
|
-
Footer: i(g),
|
|
114
|
-
Body: i(h)
|
|
115
|
-
};
|
|
36
|
+
u.displayName = "Flex";
|
|
116
37
|
export {
|
|
117
|
-
|
|
118
|
-
h as FlyoutBody,
|
|
119
|
-
p as FlyoutContent,
|
|
120
|
-
g as FlyoutFooter,
|
|
121
|
-
F as FlyoutHeader,
|
|
122
|
-
f as FlyoutRoot,
|
|
123
|
-
y as FlyoutTrigger
|
|
38
|
+
u as Flex
|
|
124
39
|
};
|
|
125
40
|
//# sourceMappingURL=fondue-components14.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components14.js","sources":["../src/components/Flyout/Flyout.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { forwardRef, type CSSProperties, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { useTranslation } from '#/hooks/useTranslation';\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport { Button } from '../Button/Button';\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport styles from './styles/flyout.module.scss';\n\nexport type FlyoutRootProps = {\n /**\n * Disable interaction with the rest of the page\n * @default false\n */\n modal?: boolean;\n /**\n * The controlled `open` state of the flyout\n * @default false\n */\n open?: boolean;\n /**\n * Event handler called when the `open` state changes\n */\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n};\n\nexport const FlyoutRoot = ({ children, ...props }: FlyoutRootProps) => {\n return <RadixPopover.Root {...props}>{children}</RadixPopover.Root>;\n};\nFlyoutRoot.displayName = 'Flyout.Root';\n\nexport type FlyoutTriggerProps = {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default true\n */\n asChild?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const FlyoutTrigger = (\n { asChild = true, children, 'data-test-id': dataTestId = 'fondue-flyout-trigger', ...props }: FlyoutTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixPopover.Trigger\n onMouseDown={addAutoFocusAttribute}\n data-auto-focus-visible=\"true\"\n data-auto-focus-trigger\n data-test-id={dataTestId}\n asChild={asChild}\n ref={ref}\n {...props}\n >\n {children}\n </RadixPopover.Trigger>\n );\n};\nFlyoutTrigger.displayName = 'Flyout.Trigger';\n\ntype FlyoutSpacing = 'compact' | 'comfortable' | 'spacious';\ntype FlyoutViewportCollisionPadding = 'compact' | 'spacious';\nexport type FlyoutContentProps = {\n /**\n * Add a shadow to the flyout\n * @default \"medium\"\n */\n shadow?: 'none' | 'medium' | 'large';\n /**\n * Add rounded corners to the flyout\n * @default \"medium\"\n */\n rounded?: 'none' | 'medium' | 'large';\n /**\n * Define the prefered side of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"bottom\"\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n /**\n * Define the prefered alignment of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"start\"\n */\n align?: 'start' | 'center' | 'end';\n /**\n * Define the padding of the flyout\n * @default \"compact\"\n */\n padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';\n /**\n * Define the fixed width of the flyout\n * @default \"fit-content\"\n */\n width?: string;\n /**\n * Defines the spacing between the dropdown and its trigger.\n * @default 'compact'\n */\n triggerOffset?: FlyoutSpacing;\n /**\n * Define the maximum width of the flyout\n * @default \"360px\"\n */\n maxWidth?: string;\n /**\n * Define the minimum distance between the flyout and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: FlyoutViewportCollisionPadding;\n /**\n * Event handler called when auto-focusing on open\n */\n onOpenAutoFocus?: (event: Event) => void;\n /**\n * Event handler called when the escape key is pressed.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nconst SPACING_MAP: Record<FlyoutSpacing, number> = {\n compact: 8,\n comfortable: 12,\n spacious: 16,\n};\n\nconst VIEWPORT_COLLISION_PADDING_MAP: Record<FlyoutViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n};\n\nexport const FlyoutContent = (\n {\n align = 'start',\n maxWidth = '360px',\n padding = 'compact',\n rounded = 'medium',\n width = 'fit-content',\n shadow = 'medium',\n side,\n triggerOffset = 'compact',\n viewportCollisionPadding = 'compact',\n 'data-test-id': dataTestId = 'fondue-flyout-content',\n children,\n ...props\n }: FlyoutContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { theme, dir } = useFondueTheme();\n\n const getAdjustedSide = (side?: 'top' | 'right' | 'bottom' | 'left') => {\n if (!side || 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 <div data-test-id=\"fondue-flyout-overlay\" className={styles.overlay} />\n <RadixPopover.Content\n dir={dir}\n style={\n {\n '--flyout-max-width': maxWidth,\n '--flyout-width': width,\n } as CSSProperties\n }\n ref={ref}\n align={align}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding]}\n sideOffset={SPACING_MAP[triggerOffset]}\n side={getAdjustedSide(side)}\n className={styles.root}\n data-flyout-spacing={padding}\n data-rounded={rounded}\n data-shadow={shadow}\n data-test-id={dataTestId}\n onFocus={addShowFocusRing}\n {...props}\n >\n {children}\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nFlyoutContent.displayName = 'Flyout.Content';\n\nexport type FlyoutHeaderProps = {\n /**\n * Show a close button in the header\n * @default false\n */\n showCloseButton?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n closeProps?: CommonAriaProps;\n};\n\nexport const FlyoutHeader = (\n { showCloseButton, children, 'data-test-id': dataTestId = 'fondue-flyout-header', closeProps }: FlyoutHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { t } = useTranslation();\n\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.header}>\n <div>{children}</div>\n {showCloseButton && (\n <RadixPopover.Close asChild {...closeProps}>\n <Button\n size=\"small\"\n aspect=\"square\"\n emphasis=\"weak\"\n aria-label={t('Flyout_close')}\n data-test-id={`${dataTestId}-close`}\n >\n <IconCross size={20} />\n </Button>\n </RadixPopover.Close>\n )}\n </div>\n );\n};\nFlyoutHeader.displayName = 'Flyout.Header';\n\nexport type FlyoutFooterProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const FlyoutFooter = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-footer' }: FlyoutFooterProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.footer}>\n {children}\n </div>\n );\n};\nFlyoutFooter.displayName = 'Flyout.Footer';\n\nexport type FlyoutBodyProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\n /**\n * Allow the body to scroll if the max height of the flyout is reached\n * @default false\n */\n scrollable?: boolean;\n};\n\nexport const FlyoutBody = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-body', scrollable = false }: FlyoutBodyProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-test-id={dataTestId}\n ref={ref}\n data-flyout-spacing=\"compact\"\n data-scrollable={scrollable}\n className={styles.body}\n >\n {children}\n </div>\n );\n};\nFlyoutBody.displayName = 'Flyout.Body';\n\nexport const Flyout = {\n Root: FlyoutRoot,\n Trigger: forwardRef<HTMLButtonElement, FlyoutTriggerProps>(FlyoutTrigger),\n Content: forwardRef<HTMLDivElement, FlyoutContentProps>(FlyoutContent),\n Header: forwardRef<HTMLDivElement, FlyoutHeaderProps>(FlyoutHeader),\n Footer: forwardRef<HTMLDivElement, FlyoutFooterProps>(FlyoutFooter),\n Body: forwardRef<HTMLDivElement, FlyoutBodyProps>(FlyoutBody),\n};\n"],"names":["FlyoutRoot","children","props","RadixPopover","FlyoutTrigger","asChild","dataTestId","ref","jsx","addAutoFocusAttribute","SPACING_MAP","VIEWPORT_COLLISION_PADDING_MAP","FlyoutContent","align","maxWidth","padding","rounded","width","shadow","side","triggerOffset","viewportCollisionPadding","theme","dir","useFondueTheme","getAdjustedSide","jsxs","ThemeProvider","styles","addShowFocusRing","FlyoutHeader","showCloseButton","closeProps","t","useTranslation","Button","IconCross","FlyoutFooter","FlyoutBody","scrollable","Flyout","forwardRef"],"mappings":";;;;;;;;;AAiCO,MAAMA,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAC9BC,EAAa,MAAb,EAAmB,GAAGD,GAAQ,UAAAD,GAAS;AAEnDD,EAAW,cAAc;AAYlB,MAAMI,IAAgB,CACzB,EAAE,SAAAC,IAAU,IAAM,UAAAJ,GAAU,gBAAgBK,IAAa,yBAAyB,GAAGJ,EAAA,GACrFK,MAGI,gBAAAC;AAAA,EAACL,EAAa;AAAA,EAAb;AAAA,IACG,aAAaM;AAAA,IACb,2BAAwB;AAAA,IACxB,2BAAuB;AAAA,IACvB,gBAAcH;AAAA,IACd,SAAAD;AAAA,IACA,KAAAE;AAAA,IACC,GAAGL;AAAA,IAEH,UAAAD;AAAA,EAAA;AAAA;AAIbG,EAAc,cAAc;AA8D5B,MAAMM,IAA6C;AAAA,EAC/C,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACd,GAEMC,IAAiF;AAAA,EACnF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AQ6B,EAA8CX,CAAY;AAAA,EAClE,QAAQW,EAA8CJ,CAAY;AAAA,EAClE,MAAMI,EAA4CH,CAAU;AAChE;"}
|
|
1
|
+
{"version":3,"file":"fondue-components14.js","sources":["../src/components/Flex/Flex.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { forwardRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { type Responsive, type SizeValue, type LayoutComponentProps } from '#/helpers/layout';\nimport { propsToCssVariables } from '#/helpers/propsToCssVariables';\n\nimport styles from './styles/flex.module.scss';\n\nexport type FlexProps = LayoutComponentProps & {\n /**\n * The element to render the Flex component as.\n * @default 'div'\n */\n as?: 'div' | 'span';\n /**\n * The display property.\n * @default 'flex'\n */\n display?: Responsive<'none' | 'flex' | 'inline-flex'>;\n /**\n * The direction of the children.\n * @default 'row'\n */\n direction?: Responsive<'row' | 'row-reverse' | 'column' | 'column-reverse'>;\n /**\n * The alignment of the children.\n */\n align?: Responsive<'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'>;\n /**\n * The justification of the children.\n */\n justify?: Responsive<'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'>;\n /**\n * The wrap property.\n */\n wrap?: Responsive<'nowrap' | 'wrap' | 'wrap-reverse'>;\n /**\n * The gap between the children.\n */\n gap?: Responsive<SizeValue>;\n /**\n * The horizontal gap between the children.\n */\n gapX?: Responsive<SizeValue>;\n /**\n * The vertical gap between the children.\n */\n gapY?: Responsive<SizeValue>;\n\n children?: ReactNode;\n 'data-test-id'?: string;\n} & CommonAriaProps;\n\nexport const Flex = forwardRef<HTMLDivElement, FlexProps>(\n (\n {\n as: Component = 'div',\n 'data-test-id': dataTestId = 'fondue-flex',\n children,\n role,\n 'aria-label': ariaLabel,\n 'aria-hidden': ariaHidden,\n 'aria-describedby': ariaDescribedBy,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-expanded': ariaExpanded,\n 'aria-haspopup': ariaHasPopup,\n ...props\n },\n ref,\n ) => {\n return (\n <Component\n className={styles.root}\n data-test-id={dataTestId}\n style={propsToCssVariables(props, { justify: 'justify-content' })}\n role={role}\n aria-label={ariaLabel}\n aria-hidden={ariaHidden}\n aria-describedby={ariaDescribedBy}\n aria-labelledby={ariaLabelledBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n ref={ref}\n >\n {children}\n </Component>\n );\n },\n);\nFlex.displayName = 'Flex';\n"],"names":["Flex","forwardRef","Component","dataTestId","children","role","ariaLabel","ariaHidden","ariaDescribedBy","ariaLabelledBy","ariaExpanded","ariaHasPopup","props","ref","jsx","styles","propsToCssVariables"],"mappings":";;;;AAuDO,MAAMA,IAAOC;AAAA,EAChB,CACI;AAAA,IACI,IAAIC,IAAY;AAAA,IAChB,gBAAgBC,IAAa;AAAA,IAC7B,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAcC;AAAA,IACd,eAAeC;AAAA,IACf,oBAAoBC;AAAA,IACpB,mBAAmBC;AAAA,IACnB,iBAAiBC;AAAA,IACjB,iBAAiBC;AAAA,IACjB,GAAGC;AAAA,EAAA,GAEPC,MAGI,gBAAAC;AAAA,IAACZ;AAAA,IAAA;AAAA,MACG,WAAWa,EAAO;AAAA,MAClB,gBAAcZ;AAAA,MACd,OAAOa,EAAoBJ,GAAO,EAAE,SAAS,mBAAmB;AAAA,MAChE,MAAAP;AAAA,MACA,cAAYC;AAAA,MACZ,eAAaC;AAAA,MACb,oBAAkBC;AAAA,MAClB,mBAAiBC;AAAA,MACjB,iBAAeC;AAAA,MACf,iBAAeC;AAAA,MACf,KAAAE;AAAA,MAEC,UAAAT;AAAA,IAAA;AAAA,EAAA;AAIjB;AACAJ,EAAK,cAAc;"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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-components127.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
|
+
] });
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
x as CollapsibleBadges
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=fondue-components140.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components140.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;A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BAAA;AAAA,QAEd;AAAA,QACA,aAAa,MAAY;AACrB,UAAAjB,EAAc,UAAU;AAAA,QAC5B;AAAA,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;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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-components127.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
|
+
)
|
|
77
|
+
}
|
|
78
|
+
) }) });
|
|
79
|
+
};
|
|
80
|
+
j.displayName = "Select.Menu";
|
|
81
|
+
export {
|
|
82
|
+
j as SelectMenu
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=fondue-components141.js.map
|