@frontify/fondue-components 3.0.2 → 3.1.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-components10.js +1 -1
- package/dist/fondue-components11.js +2 -2
- package/dist/fondue-components12.js +6 -6
- package/dist/fondue-components13.js +1 -1
- package/dist/fondue-components14.js +1 -1
- package/dist/fondue-components14.js.map +1 -1
- package/dist/fondue-components16.js +1 -1
- package/dist/fondue-components19.js +1 -1
- package/dist/fondue-components22.js +15 -17
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +19 -17
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +17 -35
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +16 -24
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +35 -9
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +22 -107
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +9 -12
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +109 -37
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components30.js +12 -8
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +42 -20
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +8 -56
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +20 -17
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +55 -14
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +18 -2
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +15 -39
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +5 -0
- package/dist/fondue-components37.js.map +1 -0
- package/dist/fondue-components38.js +42 -0
- package/dist/fondue-components38.js.map +1 -0
- package/dist/fondue-components7.js +89 -71
- package/dist/fondue-components7.js.map +1 -1
- package/dist/fondue-components8.js +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/style.css +1 -1
- package/package.json +6 -3
|
@@ -1,18 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { IconCross as w } from "@frontify/fondue-icons";
|
|
3
|
+
import { useState as x, useMemo as S, Children as f, isValidElement as u, cloneElement as B, useCallback as E } from "react";
|
|
4
|
+
import { ForwardedRefSelectItem as I } from "./fondue-components30.js";
|
|
5
|
+
import { ForwardedRefSelectSlot as c } from "./fondue-components32.js";
|
|
6
|
+
import { getSelectOptionValue as v } from "./fondue-components38.js";
|
|
7
|
+
const i = (s) => {
|
|
8
|
+
const t = [];
|
|
9
|
+
return f.forEach(s, (o) => {
|
|
10
|
+
if (u(o) && o.type === I)
|
|
11
|
+
t.push(v(o.props));
|
|
12
|
+
else if (u(o) && o.props.children) {
|
|
13
|
+
const l = i(o.props.children);
|
|
14
|
+
for (const a of l)
|
|
15
|
+
t.push(a);
|
|
8
16
|
}
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
}), t;
|
|
18
|
+
}, k = (s) => {
|
|
19
|
+
const [t, o] = x(""), { inputSlots: l, menuSlots: a, itemValues: p, clearButton: V } = S(() => {
|
|
20
|
+
const r = [], n = [];
|
|
21
|
+
let m;
|
|
22
|
+
return f.toArray(s).some(
|
|
23
|
+
(e) => u(e) && e.type === c
|
|
24
|
+
) ? (f.forEach(s, (e) => {
|
|
25
|
+
u(e) && e.type === c && (e.props.name === "menu" ? n.push(e.props.children) : e.props.name === "left" || e.props.name === "right" ? r.push(e) : e.props.name === "clear" && (e.props.children ? m = e : m = B(e, { children: /* @__PURE__ */ g(w, { size: 16 }) })));
|
|
26
|
+
}), {
|
|
27
|
+
inputSlots: r,
|
|
28
|
+
menuSlots: n,
|
|
29
|
+
clearButton: m,
|
|
30
|
+
itemValues: i(n)
|
|
31
|
+
}) : {
|
|
32
|
+
menuSlots: s,
|
|
33
|
+
inputSlots: [],
|
|
34
|
+
itemValues: i(s)
|
|
35
|
+
};
|
|
36
|
+
}, [s]), y = S(
|
|
37
|
+
() => p.filter(
|
|
38
|
+
(r) => t === "" || r.label.toLowerCase().includes(t.toLowerCase())
|
|
39
|
+
),
|
|
40
|
+
[p, t]
|
|
41
|
+
), C = E(
|
|
42
|
+
(r) => r ? p.find((n) => n.value === r) : void 0,
|
|
43
|
+
[p]
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
inputSlots: l,
|
|
47
|
+
menuSlots: a,
|
|
48
|
+
clearButton: V,
|
|
49
|
+
setFilterText: o,
|
|
50
|
+
filterText: t,
|
|
51
|
+
items: y,
|
|
52
|
+
getItemByValue: C
|
|
53
|
+
};
|
|
54
|
+
};
|
|
14
55
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
56
|
+
i as getRecursiveOptionValues,
|
|
57
|
+
k as useSelectData
|
|
17
58
|
};
|
|
18
59
|
//# sourceMappingURL=fondue-components34.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components34.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components34.js","sources":["../src/components/Select/useSelectData.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport { Children, cloneElement, isValidElement, useCallback, useMemo, useState, type ReactNode } from 'react';\n\nimport { ForwardedRefSelectItem, type SelectItemProps } from './SelectItem';\nimport { ForwardedRefSelectSlot, type SelectSlotProps } from './SelectSlot';\nimport { getSelectOptionValue } from './utils';\n\nexport type SelectItemType = {\n value: string;\n label: string;\n};\n\nexport const getRecursiveOptionValues = (children: ReactNode): { value: string; label: string }[] => {\n const values: { value: string; label: string }[] = [];\n Children.forEach(children, (child) => {\n if (isValidElement<SelectItemProps>(child) && child.type === ForwardedRefSelectItem) {\n values.push(getSelectOptionValue(child.props));\n } else if (isValidElement<{ children: ReactNode }>(child) && child.props.children) {\n const optionValues = getRecursiveOptionValues(child.props.children);\n for (const optionValue of optionValues) {\n values.push(optionValue);\n }\n }\n });\n return values;\n};\n\nexport const useSelectData = (children: ReactNode) => {\n const [filterText, setFilterText] = useState('');\n const { inputSlots, menuSlots, itemValues, clearButton } = useMemo(() => {\n const inputSlots: ReactNode[] = [];\n const menuSlots: ReactNode[] = [];\n let clearButton: ReactNode;\n const hasSlots = Children.toArray(children).some(\n (child) => isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot,\n );\n\n if (hasSlots) {\n Children.forEach(children, (child) => {\n if (isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot) {\n if (child.props.name === 'menu') {\n menuSlots.push(child.props.children);\n } else if (child.props.name === 'left' || child.props.name === 'right') {\n inputSlots.push(child);\n } else if (child.props.name === 'clear') {\n if (child.props.children) {\n clearButton = child;\n } else {\n clearButton = cloneElement(child, { children: <IconCross size={16} /> });\n }\n }\n }\n });\n\n return {\n inputSlots,\n menuSlots,\n clearButton,\n itemValues: getRecursiveOptionValues(menuSlots),\n };\n } else {\n return {\n menuSlots: children,\n inputSlots: [],\n itemValues: getRecursiveOptionValues(children),\n };\n }\n }, [children]);\n\n const filteredItems = useMemo(\n () =>\n itemValues.filter(\n (item) => filterText === '' || item.label.toLowerCase().includes(filterText.toLowerCase()),\n ),\n [itemValues, filterText],\n );\n\n const getItemByValue = useCallback(\n (value?: string) => (value ? itemValues.find((item) => item.value === value) : undefined),\n [itemValues],\n );\n\n return {\n inputSlots,\n menuSlots,\n clearButton,\n setFilterText,\n filterText,\n items: filteredItems,\n getItemByValue,\n };\n};\n"],"names":["getRecursiveOptionValues","children","values","Children","child","isValidElement","ForwardedRefSelectItem","getSelectOptionValue","optionValues","optionValue","useSelectData","filterText","setFilterText","useState","inputSlots","menuSlots","itemValues","clearButton","use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AAP;AAAAA,MACA,WAAAC;AAAAA,MACA,aAAAE;AAAAA,MACA,YAAYjB,EAAyBe,CAAS;AAAA,IAAA,KAG3C;AAAA,MACH,WAAWd;AAAA,MACX,YAAY,CAAC;AAAA,MACb,YAAYD,EAAyBC,CAAQ;AAAA,IAAA;AAAA,EAErD,GACD,CAACA,CAAQ,CAAC,GAEPqB,IAAgBJ;AAAA,IAClB,MACIF,EAAW;AAAA,MACP,CAACO,MAASZ,MAAe,MAAMY,EAAK,MAAM,YAAA,EAAc,SAASZ,EAAW,aAAa;AAAA,IAC7F;AAAA,IACJ,CAACK,GAAYL,CAAU;AAAA,EAAA,GAGrBa,IAAiBC;AAAA,IACnB,CAACC,MAAoBA,IAAQV,EAAW,KAAK,CAACO,MAASA,EAAK,UAAUG,CAAK,IAAI;AAAA,IAC/E,CAACV,CAAU;AAAA,EAAA;AAGR,SAAA;AAAA,IACH,YAAAF;AAAA,IACA,WAAAC;AAAA,IACA,aAAAE;AAAA,IACA,eAAAL;AAAA,IACA,YAAAD;AAAA,IACA,OAAOW;AAAA,IACP,gBAAAE;AAAA,EAAA;AAER;"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
const t = "
|
|
1
|
+
const o = "_root_1y56f_5", t = "_input_1y56f_52", s = "_slot_1y56f_71", _ = "_iconSuccess_1y56f_121", n = "_iconError_1y56f_129", c = "_loadingStatus_1y56f_137", i = "_spin_1y56f_1", r = {
|
|
2
|
+
root: o,
|
|
3
|
+
input: t,
|
|
4
|
+
slot: s,
|
|
5
|
+
iconSuccess: _,
|
|
6
|
+
iconError: n,
|
|
7
|
+
loadingStatus: c,
|
|
8
|
+
spin: i,
|
|
9
|
+
"tw-dark": "_tw-dark_1y56f_169"
|
|
10
|
+
};
|
|
2
11
|
export {
|
|
3
|
-
|
|
12
|
+
r as default,
|
|
13
|
+
n as iconError,
|
|
14
|
+
_ as iconSuccess,
|
|
15
|
+
t as input,
|
|
16
|
+
c as loadingStatus,
|
|
17
|
+
o as root,
|
|
18
|
+
s as slot,
|
|
19
|
+
i as spin
|
|
4
20
|
};
|
|
5
21
|
//# sourceMappingURL=fondue-components35.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components35.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components35.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
const n = [];
|
|
15
|
-
let t = 0;
|
|
16
|
-
return a.forEach(r, (e) => {
|
|
17
|
-
if (w(e, E) && u(e) && g(e.props).label.toLowerCase().includes((s == null ? void 0 : s.toLowerCase()) || ""))
|
|
18
|
-
n.push(o(e, p + t)), t++;
|
|
19
|
-
else if (u(e) && (e != null && e.props.children)) {
|
|
20
|
-
const { parsedChildren: m, subElementCount: C } = y(
|
|
21
|
-
e.props.children,
|
|
22
|
-
o,
|
|
23
|
-
"",
|
|
24
|
-
p + t
|
|
25
|
-
);
|
|
26
|
-
e = f(e, {
|
|
27
|
-
children: m,
|
|
28
|
-
key: `group-${p + t}`
|
|
29
|
-
}), n.push(e), t += C;
|
|
30
|
-
} else
|
|
31
|
-
n.push(e);
|
|
32
|
-
}), {
|
|
33
|
-
parsedChildren: n,
|
|
34
|
-
subElementCount: t
|
|
35
|
-
};
|
|
36
|
-
};
|
|
1
|
+
import { sv as t } from "./fondue-components15.js";
|
|
2
|
+
const o = t({
|
|
3
|
+
base: "tw-bg-box-neutral-mighty tw-text-box-neutral-mighty-inverse tw-rounded tw-max-w-48 tw-text-sm tw-overflow-hidden",
|
|
4
|
+
variants: {
|
|
5
|
+
padding: {
|
|
6
|
+
spacious: "tw-px-3 tw-py-2",
|
|
7
|
+
compact: "tw-px-2 tw-py-1"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
padding: "spacious"
|
|
12
|
+
}
|
|
13
|
+
}), e = "tw-w-2 tw-h-2 tw-bg-box-neutral-mighty tw-border-r tw-border-b tw-border-r-line-mighty tw-border-b-line-mighty tw-rotate-45 -tw-translate-y-1 tw-rounded-br-small";
|
|
37
14
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
y as recursiveMap
|
|
15
|
+
e as tooltipArrowStyles,
|
|
16
|
+
o as tooltipContentStyles
|
|
41
17
|
};
|
|
42
18
|
//# sourceMappingURL=fondue-components36.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components36.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components36.js","sources":["../src/components/Tooltip/styles/tooltipStyles.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { sv } from '#/utilities/styleUtilities';\n\nexport const tooltipContentStyles = sv({\n base: 'tw-bg-box-neutral-mighty tw-text-box-neutral-mighty-inverse tw-rounded tw-max-w-48 tw-text-sm tw-overflow-hidden',\n variants: {\n padding: {\n spacious: 'tw-px-3 tw-py-2',\n compact: 'tw-px-2 tw-py-1',\n },\n },\n defaultVariants: {\n padding: 'spacious',\n },\n});\n\nexport const tooltipArrowStyles =\n 'tw-w-2 tw-h-2 tw-bg-box-neutral-mighty tw-border-r tw-border-b tw-border-r-line-mighty tw-border-b-line-mighty tw-rotate-45 -tw-translate-y-1 tw-rounded-br-small';\n"],"names":["tooltipContentStyles","sv","tooltipArrowStyles"],"mappings":";AAIO,MAAMA,IAAuBC,EAAG;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AAAA,IACN,SAAS;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,IACb;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,SAAS;AAAA,EACb;AACJ,CAAC,GAEYC,IACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components37.js","sources":["../src/utilities/focusStyle.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nexport const FOCUS_OUTLINE =\n 'focus-visible:tw-outline has-[[data-show-focus-ring=true]]:tw-outline tw-outline-4 tw-outline-offset-2 tw-outline-blue focus-visible:tw-outline-blue'; // second declaration of tw-outline-blue is to assure that in firefox the outline isn't overriden by a global definition of :-moz-focusring which is coming from tailwinds normalization styling\n"],"names":["FOCUS_OUTLINE"],"mappings":"AAEO,MAAMA,IACT;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Children as a, isValidElement as u, cloneElement as f } from "react";
|
|
2
|
+
import { ForwardedRefSelectItem as E } from "./fondue-components30.js";
|
|
3
|
+
const g = ({
|
|
4
|
+
children: r,
|
|
5
|
+
value: o,
|
|
6
|
+
label: s
|
|
7
|
+
}) => r && typeof r == "string" ? {
|
|
8
|
+
value: o || r,
|
|
9
|
+
label: s || r
|
|
10
|
+
} : {
|
|
11
|
+
value: o || "",
|
|
12
|
+
label: s || o || ""
|
|
13
|
+
}, w = (r, o) => u(r) && r.type === o, y = (r, o, s, p = 0) => {
|
|
14
|
+
const n = [];
|
|
15
|
+
let t = 0;
|
|
16
|
+
return a.forEach(r, (e) => {
|
|
17
|
+
if (w(e, E) && u(e))
|
|
18
|
+
g(e.props).label.toLowerCase().includes((s == null ? void 0 : s.toLowerCase()) || "") && (n.push(o(e, p + t)), t++);
|
|
19
|
+
else if (u(e) && (e != null && e.props.children)) {
|
|
20
|
+
const { parsedChildren: m, subElementCount: C } = y(
|
|
21
|
+
e.props.children,
|
|
22
|
+
o,
|
|
23
|
+
"",
|
|
24
|
+
p + t
|
|
25
|
+
);
|
|
26
|
+
e = f(e, {
|
|
27
|
+
children: m,
|
|
28
|
+
key: `group-${p + t}`
|
|
29
|
+
}), n.push(e), t += C;
|
|
30
|
+
} else
|
|
31
|
+
n.push(e);
|
|
32
|
+
}), {
|
|
33
|
+
parsedChildren: n,
|
|
34
|
+
subElementCount: t
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
g as getSelectOptionValue,
|
|
39
|
+
w as isReactLeaf,
|
|
40
|
+
y as recursiveMap
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=fondue-components38.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fondue-components38.js","sources":["../src/components/Select/utils.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n Children,\n cloneElement,\n isValidElement,\n type JSXElementConstructor,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { ForwardedRefSelectItem, type SelectItemProps } from './SelectItem';\n\n/**\n * Extracts and returns an object containing `value` and `label` from a given SelectItemProps object.\n * It prioritizes explicit `value` and `label` properties but will fall back to using `children` as the value or label if necessary.\n *\n * @param {SelectItemProps} props - The properties of a select item, which include potential children, value, and label.\n * @returns {{ value: string; label: string }} An object containing `value` and `label` as strings.\n *\n * @example\n * // Returns { value: 'option1', label: 'Option 1' }\n * getSelectOptionValue({ value: 'option1', label: 'Option 1' });\n *\n * @example\n * // Uses children as the value and label when they are not explicitly provided\n * // Returns { value: 'Default', label: 'Default' }\n * getSelectOptionValue({ children: 'Default' });\n */\nexport const getSelectOptionValue = ({\n children,\n value,\n label,\n}: SelectItemProps): {\n value: string;\n label: string;\n} => {\n if (children && typeof children === 'string') {\n return {\n value: value ? value : children,\n label: label ? label : children,\n };\n }\n\n return {\n value: value || '',\n label: label ? label : value || '',\n };\n};\n/**\n * Determines if the child is a leaf node of React, meaning it has one final child of a native type;\n *\n * @param {ReactNode} child - The React child node to check.\n * @param {JSXElementConstructor<never>} Component - The React component constructor used for comparison.\n * @returns {boolean} Returns true if the `child` is a valid React element of the specified `Component` type.\n *\n * @example\n * // Assuming ForwardedRefSelectItem is a component that renders an <input> element\n * // Returns true\n * isReactLeaf(<ForwardedRefSelectItem />, ForwardedRefSelectItem);\n *\n * @example\n * // Returns false for non-matching types or non-leaf components\n * isReactLeaf(<div><ForwardedRefSelectItem /></div>, ForwardedRefSelectItem);\n */\nexport const isReactLeaf = (child: ReactNode, Component: JSXElementConstructor<never>): child is ReactElement =>\n isValidElement(child) && child.type === Component;\n\n/**\n * Recursively maps through React children, applying a callback to each child that meets the specified conditions.\n * This function is useful for deeply nested structures where modifications or checks are needed at multiple levels.\n *\n * @param {ReactNode} children - The children to be recursively processed.\n * @param {function(ReactNode, number): ReactNode} callback - A function that is called for each child that meets the condition. It receives the child and its index, and returns a React node.\n * @param {string} [filterText=''] - Optional text used to filter children based on their properties.\n * @param {number} [nextIndex=0] - The starting index for numbering children, defaults to 0.\n * @returns {{ parsedChildren: ReactNode[], subElementCount: number }} An object containing the transformed children array and the count of all processed sub-elements.\n *\n * @example\n * // Example usage in a select component where only items containing a certain text are modified\n * recursiveMap(children, (child, index) => React.cloneElement(child, { extraProp: 'value' }), 'specific text');\n *\n * @example\n * // Nested structure transformation, adding class names based on index\n * recursiveMap(children, (child, index) => React.cloneElement(child, { className: `item-${index}` }));\n */\nexport const recursiveMap = (\n children: ReactNode,\n callback: (child: ReactNode, nextIndex: number) => ReactNode,\n filterText?: string,\n nextIndex: number = 0,\n): {\n parsedChildren: ReactNode[];\n subElementCount: number;\n} => {\n const resultingChildren: ReactNode[] = [];\n let itemCounter = 0;\n Children.forEach(children, (child) => {\n if (isReactLeaf(child, ForwardedRefSelectItem) && isValidElement<SelectItemProps>(child)) {\n if (\n getSelectOptionValue(child.props)\n .label.toLowerCase()\n .includes(filterText?.toLowerCase() || '')\n ) {\n resultingChildren.push(callback(child, nextIndex + itemCounter));\n itemCounter++;\n }\n } else if (isValidElement<{ children: ReactNode }>(child) && child?.props.children) {\n const { parsedChildren, subElementCount } = recursiveMap(\n child.props.children,\n callback,\n '',\n nextIndex + itemCounter,\n );\n child = cloneElement(child, {\n children: parsedChildren,\n key: `group-${nextIndex + itemCounter}`,\n });\n resultingChildren.push(child);\n itemCounter += subElementCount;\n } else {\n resultingChildren.push(child);\n }\n });\n return {\n parsedChildren: resultingChildren,\n subElementCount: itemCounter,\n };\n};\n"],"names":["getSelectOptionValue","children","value","label","isReactLeaf","child","Component","isValidElement","recursiveMap","callback","filterText","nextIndex","resultingChildren","itemCounter","Children","ForwardedRefSelectItem","parsedChildren","subElementCount","cloneElement"],"mappings":";;AA6BO,MAAMA,IAAuB,CAAC;AAAA,EACjC,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AACJ,MAIQF,KAAY,OAAOA,KAAa,WACzB;AAAA,EACH,OAAOC,KAAgBD;AAAA,EACvB,OAAOE,KAAgBF;AAAA,IAIxB;AAAA,EACH,OAAOC,KAAS;AAAA,EAChB,OAAOC,KAAgBD,KAAS;AAAA,GAmB3BE,IAAc,CAACC,GAAkBC,MAC1CC,EAAeF,CAAK,KAAKA,EAAM,SAASC,GAoB/BE,IAAe,CACxBP,GACAQ,GACAC,GACAC,IAAoB,MAInB;AACD,QAAMC,IAAiC,CAAA;AACvC,MAAIC,IAAc;AACT,SAAAC,EAAA,QAAQb,GAAU,CAACI,MAAU;AAClC,QAAID,EAAYC,GAAOU,CAAsB,KAAKR,EAAgCF,CAAK;AACnF,MACIL,EAAqBK,EAAM,KAAK,EAC3B,MAAM,cACN,UAASK,KAAA,gBAAAA,EAAY,kBAAiB,EAAE,MAE7CE,EAAkB,KAAKH,EAASJ,GAAOM,IAAYE,CAAW,CAAC,GAC/DA;AAAA,aAEGN,EAAwCF,CAAK,MAAKA,KAAA,QAAAA,EAAO,MAAM,WAAU;AAC1E,YAAA,EAAE,gBAAAW,GAAgB,iBAAAC,EAAA,IAAoBT;AAAA,QACxCH,EAAM,MAAM;AAAA,QACZI;AAAA,QACA;AAAA,QACAE,IAAYE;AAAA,MAAA;AAEhB,MAAAR,IAAQa,EAAab,GAAO;AAAA,QACxB,UAAUW;AAAA,QACV,KAAK,SAASL,IAAYE,CAAW;AAAA,MAAA,CACxC,GACDD,EAAkB,KAAKP,CAAK,GACbQ,KAAAI;AAAA,IAAA;AAEf,MAAAL,EAAkB,KAAKP,CAAK;AAAA,EAChC,CACH,GACM;AAAA,IACH,gBAAgBO;AAAA,IAChB,iBAAiBC;AAAA,EAAA;AAEzB;"}
|
|
@@ -1,88 +1,106 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { IconCaretRight as
|
|
3
|
-
import * as
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { jsx as e, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { IconCaretRight as F } from "@frontify/fondue-icons";
|
|
3
|
+
import * as d from "@radix-ui/react-dropdown-menu";
|
|
4
|
+
import { forwardRef as s, useRef as c } from "react";
|
|
5
|
+
import { usePreventDropdownOverflow as I } from "./fondue-components22.js";
|
|
6
|
+
import { syncRefs as l } from "./fondue-components23.js";
|
|
7
|
+
import a from "./fondue-components24.js";
|
|
8
|
+
const m = ({
|
|
7
9
|
children: o,
|
|
8
10
|
open: t,
|
|
9
|
-
onOpenChange:
|
|
10
|
-
"data-test-id":
|
|
11
|
-
}) => /* @__PURE__ */
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
onOpenChange: r,
|
|
12
|
+
"data-test-id": n = "fondue-dropdown"
|
|
13
|
+
}) => /* @__PURE__ */ e(d.Root, { open: t, onOpenChange: r, "data-test-id": n, children: o });
|
|
14
|
+
m.displayName = "Dropdown.Root";
|
|
15
|
+
const f = ({ children: o, "data-test-id": t = "fondue-dropdown-trigger" }, r) => /* @__PURE__ */ e(d.Trigger, { asChild: !0, "data-test-id": t, ref: r, children: o });
|
|
16
|
+
f.displayName = "Dropdown.Trigger";
|
|
17
|
+
const g = ({
|
|
18
|
+
onOpen: o,
|
|
19
|
+
onClose: t,
|
|
20
|
+
side: r = "bottom",
|
|
21
|
+
children: n,
|
|
22
|
+
"data-test-id": u = "fondue-dropdown-content"
|
|
23
|
+
}, p) => {
|
|
24
|
+
const i = c(null), w = c(!1), { setMaxHeight: y } = I(i);
|
|
25
|
+
return /* @__PURE__ */ e(d.Portal, { children: /* @__PURE__ */ e(
|
|
26
|
+
d.Content,
|
|
27
|
+
{
|
|
28
|
+
align: "start",
|
|
29
|
+
collisionPadding: 8,
|
|
30
|
+
sideOffset: 8,
|
|
31
|
+
side: r,
|
|
32
|
+
className: a.content,
|
|
33
|
+
"data-test-id": u,
|
|
34
|
+
ref: i,
|
|
35
|
+
onCloseAutoFocus: () => {
|
|
36
|
+
l(i, p), t && t(), w.current = !1;
|
|
37
|
+
},
|
|
38
|
+
onFocus: () => {
|
|
39
|
+
w.current || (y(), l(i, p), o && o(), w.current = !0);
|
|
40
|
+
},
|
|
41
|
+
children: n
|
|
42
|
+
}
|
|
43
|
+
) });
|
|
44
|
+
};
|
|
45
|
+
g.displayName = "Dropdown.Content";
|
|
46
|
+
const D = ({ children: o, "data-test-id": t = "fondue-dropdown-group" }, r) => /* @__PURE__ */ e(d.Group, { className: a.group, "data-test-id": t, ref: r, children: o });
|
|
47
|
+
D.displayName = "Dropdown.Group";
|
|
48
|
+
const b = ({
|
|
31
49
|
children: o,
|
|
32
50
|
"data-test-id": t = "fondue-dropdown-submenu"
|
|
33
|
-
}) => /* @__PURE__ */
|
|
34
|
-
|
|
35
|
-
const
|
|
51
|
+
}) => /* @__PURE__ */ e(d.Sub, { "data-test-id": t, children: o });
|
|
52
|
+
b.displayName = "Dropdown.SubMenu";
|
|
53
|
+
const S = ({ children: o, "data-test-id": t = "fondue-dropdown-subtrigger" }, r) => /* @__PURE__ */ T(d.SubTrigger, { className: a.subTrigger, "data-test-id": t, ref: r, children: [
|
|
36
54
|
o,
|
|
37
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ e(F, { className: a.subMenuIndicator, size: 16 })
|
|
38
56
|
] });
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
57
|
+
S.displayName = "Dropdown.SubTrigger";
|
|
58
|
+
const R = ({ children: o, "data-test-id": t = "fondue-dropdown-subcontent" }, r) => /* @__PURE__ */ e(d.Portal, { children: /* @__PURE__ */ e(d.SubContent, { className: a.subContent, "data-test-id": t, ref: r, children: o }) });
|
|
59
|
+
R.displayName = "Dropdown.SubContent";
|
|
60
|
+
const N = ({
|
|
43
61
|
children: o,
|
|
44
62
|
disabled: t,
|
|
45
|
-
textValue:
|
|
46
|
-
onSelect:
|
|
47
|
-
"data-test-id":
|
|
48
|
-
...
|
|
49
|
-
},
|
|
50
|
-
|
|
63
|
+
textValue: r,
|
|
64
|
+
onSelect: n,
|
|
65
|
+
"data-test-id": u = "fondue-dropdown-subtrigger",
|
|
66
|
+
...p
|
|
67
|
+
}, i) => /* @__PURE__ */ e(
|
|
68
|
+
d.Item,
|
|
51
69
|
{
|
|
52
|
-
onSelect:
|
|
53
|
-
className:
|
|
54
|
-
textValue:
|
|
55
|
-
"data-test-id":
|
|
56
|
-
ref:
|
|
70
|
+
onSelect: n,
|
|
71
|
+
className: a.item,
|
|
72
|
+
textValue: r,
|
|
73
|
+
"data-test-id": u,
|
|
74
|
+
ref: i,
|
|
57
75
|
disabled: t,
|
|
58
|
-
...
|
|
76
|
+
...p,
|
|
59
77
|
children: o
|
|
60
78
|
}
|
|
61
79
|
);
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
Root:
|
|
67
|
-
Trigger:
|
|
68
|
-
Content:
|
|
69
|
-
Group:
|
|
70
|
-
SubMenu:
|
|
71
|
-
SubTrigger:
|
|
72
|
-
SubContent:
|
|
73
|
-
Item:
|
|
74
|
-
Slot:
|
|
80
|
+
N.displayName = "Dropdown.Item";
|
|
81
|
+
const C = ({ children: o, name: t, "data-test-id": r = "fondue-dropdown-slot" }, n) => /* @__PURE__ */ e("div", { "data-name": t, className: a.slot, "data-test-id": r, ref: n, children: o });
|
|
82
|
+
C.displayName = "Dropdown.Slot";
|
|
83
|
+
const h = s(f), x = s(g), G = s(D), M = s(S), P = s(R), v = s(N), j = s(C), B = {
|
|
84
|
+
Root: m,
|
|
85
|
+
Trigger: h,
|
|
86
|
+
Content: x,
|
|
87
|
+
Group: G,
|
|
88
|
+
SubMenu: b,
|
|
89
|
+
SubTrigger: M,
|
|
90
|
+
SubContent: P,
|
|
91
|
+
Item: v,
|
|
92
|
+
Slot: j
|
|
75
93
|
};
|
|
76
94
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
B as Dropdown,
|
|
96
|
+
g as DropdownContent,
|
|
97
|
+
D as DropdownGroup,
|
|
98
|
+
N as DropdownItem,
|
|
99
|
+
m as DropdownRoot,
|
|
100
|
+
C as DropdownSlot,
|
|
101
|
+
R as DropdownSubContent,
|
|
102
|
+
b as DropdownSubMenu,
|
|
103
|
+
S as DropdownSubTrigger,
|
|
104
|
+
f as DropdownTrigger
|
|
87
105
|
};
|
|
88
106
|
//# sourceMappingURL=fondue-components7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components7.js","sources":["../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretRight } from '@frontify/fondue-icons';\nimport * as RadixDropdown from '@radix-ui/react-dropdown-menu';\nimport { forwardRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport styles from './styles/dropdown.module.scss';\n\nexport type DropdownRootProps = {\n children?: ReactNode;\n /**\n * Controls the open state of the dropdown.\n */\n open?: boolean;\n /**\n * Callback that is called when the open state of the dropdown changes.\n */\n onOpenChange?: (open: boolean) => void;\n 'data-test-id'?: string;\n};\n\nexport const DropdownRoot = ({\n children,\n open,\n onOpenChange,\n 'data-test-id': dataTestId = 'fondue-dropdown',\n}: DropdownRootProps) => {\n return (\n <RadixDropdown.Root open={open} onOpenChange={onOpenChange} data-test-id={dataTestId}>\n {children}\n </RadixDropdown.Root>\n );\n};\nDropdownRoot.displayName = 'Dropdown.Root';\n\nexport type DropdownTriggerProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-trigger' }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.Trigger>\n );\n};\nDropdownTrigger.displayName = 'Dropdown.Trigger';\n\nexport type DropdownContentProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-content' }: DropdownContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.Content\n align=\"start\"\n collisionPadding={8}\n sideOffset={8}\n className={styles.content}\n data-test-id={dataTestId}\n ref={ref}\n >\n {children}\n </RadixDropdown.Content>\n </RadixDropdown.Portal>\n );\n};\nDropdownContent.displayName = 'Dropdown.Content';\n\nexport type DropdownGroupProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownGroup = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-group' }: DropdownGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Group className={styles.group} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.Group>\n );\n};\nDropdownGroup.displayName = 'Dropdown.Group';\n\nexport type DropdownSubMenuProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubMenu = ({\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-submenu',\n}: DropdownSubMenuProps) => {\n return <RadixDropdown.Sub data-test-id={dataTestId}>{children}</RadixDropdown.Sub>;\n};\nDropdownSubMenu.displayName = 'Dropdown.SubMenu';\n\nexport type DropdownSubTriggerProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger' }: DropdownSubTriggerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.SubTrigger className={styles.subTrigger} data-test-id={dataTestId} ref={ref}>\n {children}\n <IconCaretRight className={styles.subMenuIndicator} size={16} />\n </RadixDropdown.SubTrigger>\n );\n};\nDropdownSubTrigger.displayName = 'Dropdown.SubTrigger';\n\nexport type DropdownSubContentProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subcontent' }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.SubContent className={styles.subContent} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.SubContent>\n </RadixDropdown.Portal>\n );\n};\nDropdownSubContent.displayName = 'Dropdown.SubContent';\n\nexport type DropdownItemProps = {\n children: ReactNode;\n /**\n * Disables the item.\n */\n disabled?: boolean;\n /**\n * The text value of the item that is passed to the onSelect callback.\n */\n textValue?: string;\n /**\n * Callback that is called when the item is selected.\n */\n onSelect: (event: Event) => void;\n 'data-test-id'?: string;\n};\n\nexport const DropdownItem = (\n {\n children,\n disabled,\n textValue,\n onSelect,\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Item\n onSelect={onSelect}\n className={styles.item}\n textValue={textValue}\n data-test-id={dataTestId}\n ref={ref}\n disabled={disabled}\n {...props}\n >\n {children}\n </RadixDropdown.Item>\n );\n};\nDropdownItem.displayName = 'Dropdown.Item';\n\nexport type DropdownSlotProps = { children: ReactNode; name?: 'left' | 'right'; 'data-test-id'?: string };\n\nexport const DropdownSlot = (\n { children, name, 'data-test-id': dataTestId = 'fondue-dropdown-slot' }: DropdownSlotProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-name={name} className={styles.slot} data-test-id={dataTestId} ref={ref}>\n {children}\n </div>\n );\n};\nDropdownSlot.displayName = 'Dropdown.Slot';\n\nconst ForwardedRefDropdownTrigger = forwardRef<HTMLButtonElement, DropdownTriggerProps>(DropdownTrigger);\nconst ForwardedRefDropdownContent = forwardRef<HTMLDivElement, DropdownContentProps>(DropdownContent);\nconst ForwardedRefDropdownGroup = forwardRef<HTMLDivElement, DropdownGroupProps>(DropdownGroup);\nconst ForwardedRefDropdownSubTrigger = forwardRef<HTMLDivElement, DropdownSubTriggerProps>(DropdownSubTrigger);\nconst ForwardedRefDropdownSubContent = forwardRef<HTMLDivElement, DropdownSubContentProps>(DropdownSubContent);\nconst ForwardedRefDropdownItem = forwardRef<HTMLDivElement, DropdownItemProps>(DropdownItem);\nconst ForwardedRefDropdownSlot = forwardRef<HTMLDivElement, DropdownSlotProps>(DropdownSlot);\n\nexport const Dropdown = {\n Root: DropdownRoot,\n Trigger: ForwardedRefDropdownTrigger,\n Content: ForwardedRefDropdownContent,\n Group: ForwardedRefDropdownGroup,\n SubMenu: DropdownSubMenu,\n SubTrigger: ForwardedRefDropdownSubTrigger,\n SubContent: ForwardedRefDropdownSubContent,\n Item: ForwardedRefDropdownItem,\n Slot: ForwardedRefDropdownSlot,\n};\n"],"names":["DropdownRoot","children","open","onOpenChange","dataTestId","jsx","RadixDropdown","DropdownTrigger","ref","DropdownContent","styles","DropdownGroup","DropdownSubMenu","DropdownSubTrigger","jsxs","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","props","DropdownSlot","name","ForwardedRefDropdownTrigger","forwardRef","ForwardedRefDropdownContent","ForwardedRefDropdownGroup","ForwardedRefDropdownSubTrigger","ForwardedRefDropdownSubContent","ForwardedRefDropdownItem","ForwardedRefDropdownSlot","Dropdown"],"mappings":";;;;;AAqBO,MAAMA,IAAe,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAgBC,IAAa;AACjC,MAEQ,gBAAAC,EAACC,EAAc,MAAd,EAAmB,MAAAJ,GAAY,cAAAC,GAA4B,gBAAcC,GACrE,UAAAH,EACL,CAAA;AAGRD,EAAa,cAAc;AAId,MAAAO,IAAkB,CAC3B,EAAE,UAAAN,GAAU,gBAAgBG,IAAa,6BACzCI,MAGI,gBAAAH,EAACC,EAAc,SAAd,EAAsB,SAAO,IAAC,gBAAcF,GAAY,KAAAI,GACpD,UAAAP,EACL,CAAA;AAGRM,EAAgB,cAAc;AAIjB,MAAAE,IAAkB,CAC3B,EAAE,UAAAR,GAAU,gBAAgBG,IAAa,6BACzCI,MAGI,gBAAAH,EAACC,EAAc,QAAd,EACG,UAAA,gBAAAD;AAAA,EAACC,EAAc;AAAA,EAAd;AAAA,IACG,OAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,WAAWI,EAAO;AAAA,IAClB,gBAAcN;AAAA,IACd,KAAAI;AAAA,IAEC,UAAAP;AAAA,EAAA;AAET,EAAA,CAAA;AAGRQ,EAAgB,cAAc;AAIjB,MAAAE,IAAgB,CACzB,EAAE,UAAAV,GAAU,gBAAgBG,IAAa,2BACzCI,MAGI,gBAAAH,EAACC,EAAc,OAAd,EAAoB,WAAWI,EAAO,OAAO,gBAAcN,GAAY,KAAAI,GACnE,UAAAP,EACL,CAAA;AAGRU,EAAc,cAAc;AAIrB,MAAMC,IAAkB,CAAC;AAAA,EAC5B,UAAAX;AAAA,EACA,gBAAgBG,IAAa;A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8BC,EAAoDlB,CAAe,GACjGmB,IAA8BD,EAAiDhB,CAAe,GAC9FkB,IAA4BF,EAA+Cd,CAAa,GACxFiB,IAAiCH,EAAoDZ,CAAkB,GACvGgB,IAAiCJ,EAAoDT,CAAkB,GACvGc,IAA2BL,EAA8CR,CAAY,GACrFc,IAA2BN,EAA8CH,CAAY,GAE9EU,IAAW;AAAA,EACpB,MAAMhC;AAAA,EACN,SAASwB;AAAA,EACT,SAASE;AAAA,EACT,OAAOC;AAAA,EACP,SAASf;AAAA,EACT,YAAYgB;AAAA,EACZ,YAAYC;AAAA,EACZ,MAAMC;AAAA,EACN,MAAMC;AACV;"}
|
|
1
|
+
{"version":3,"file":"fondue-components7.js","sources":["../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretRight } from '@frontify/fondue-icons';\nimport * as RadixDropdown from '@radix-ui/react-dropdown-menu';\nimport { forwardRef, useRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\nimport { syncRefs } from '#/utilities/domUtilities';\n\nimport styles from './styles/dropdown.module.scss';\n\nexport type DropdownRootProps = {\n children?: ReactNode;\n /**\n * Controls the open state of the dropdown.\n */\n open?: boolean;\n /**\n * Callback that is called when the open state of the dropdown changes.\n */\n onOpenChange?: (open: boolean) => void;\n 'data-test-id'?: string;\n};\n\nexport const DropdownRoot = ({\n children,\n open,\n onOpenChange,\n 'data-test-id': dataTestId = 'fondue-dropdown',\n}: DropdownRootProps) => {\n return (\n <RadixDropdown.Root open={open} onOpenChange={onOpenChange} data-test-id={dataTestId}>\n {children}\n </RadixDropdown.Root>\n );\n};\nDropdownRoot.displayName = 'Dropdown.Root';\n\nexport type DropdownTriggerProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-trigger' }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.Trigger>\n );\n};\nDropdownTrigger.displayName = 'Dropdown.Trigger';\n\nexport type DropdownContentProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\n onOpen?: () => void;\n onClose?: () => void;\n /**\n * Defines the preferred side of the dropdown. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n};\n\nexport const DropdownContent = (\n {\n onOpen,\n onClose,\n side = 'bottom',\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-content',\n }: DropdownContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const localRef = useRef(null);\n const dropdownIsOpen = useRef(false);\n\n const { setMaxHeight } = usePreventDropdownOverflow(localRef);\n\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.Content\n align=\"start\"\n collisionPadding={8}\n sideOffset={8}\n side={side}\n className={styles.content}\n data-test-id={dataTestId}\n ref={localRef}\n onCloseAutoFocus={() => {\n syncRefs(localRef, ref);\n onClose && onClose();\n dropdownIsOpen.current = false;\n }}\n onFocus={() => {\n if (!dropdownIsOpen.current) {\n setMaxHeight();\n syncRefs(localRef, ref);\n onOpen && onOpen();\n dropdownIsOpen.current = true;\n }\n }}\n >\n {children}\n </RadixDropdown.Content>\n </RadixDropdown.Portal>\n );\n};\nDropdownContent.displayName = 'Dropdown.Content';\n\nexport type DropdownGroupProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownGroup = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-group' }: DropdownGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Group className={styles.group} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.Group>\n );\n};\nDropdownGroup.displayName = 'Dropdown.Group';\n\nexport type DropdownSubMenuProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubMenu = ({\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-submenu',\n}: DropdownSubMenuProps) => {\n return <RadixDropdown.Sub data-test-id={dataTestId}>{children}</RadixDropdown.Sub>;\n};\nDropdownSubMenu.displayName = 'Dropdown.SubMenu';\n\nexport type DropdownSubTriggerProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger' }: DropdownSubTriggerProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.SubTrigger className={styles.subTrigger} data-test-id={dataTestId} ref={ref}>\n {children}\n <IconCaretRight className={styles.subMenuIndicator} size={16} />\n </RadixDropdown.SubTrigger>\n );\n};\nDropdownSubTrigger.displayName = 'Dropdown.SubTrigger';\n\nexport type DropdownSubContentProps = { children: ReactNode; 'data-test-id'?: string };\n\nexport const DropdownSubContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subcontent' }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.SubContent className={styles.subContent} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.SubContent>\n </RadixDropdown.Portal>\n );\n};\nDropdownSubContent.displayName = 'Dropdown.SubContent';\n\nexport type DropdownItemProps = {\n children: ReactNode;\n /**\n * Disables the item.\n */\n disabled?: boolean;\n /**\n * The text value of the item that is passed to the onSelect callback.\n */\n textValue?: string;\n /**\n * Callback that is called when the item is selected.\n */\n onSelect?: (event: Event) => void;\n 'data-test-id'?: string;\n};\n\nexport const DropdownItem = (\n {\n children,\n disabled,\n textValue,\n onSelect,\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Item\n onSelect={onSelect}\n className={styles.item}\n textValue={textValue}\n data-test-id={dataTestId}\n ref={ref}\n disabled={disabled}\n {...props}\n >\n {children}\n </RadixDropdown.Item>\n );\n};\nDropdownItem.displayName = 'Dropdown.Item';\n\nexport type DropdownSlotProps = { children: ReactNode; name?: 'left' | 'right'; 'data-test-id'?: string };\n\nexport const DropdownSlot = (\n { children, name, 'data-test-id': dataTestId = 'fondue-dropdown-slot' }: DropdownSlotProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-name={name} className={styles.slot} data-test-id={dataTestId} ref={ref}>\n {children}\n </div>\n );\n};\nDropdownSlot.displayName = 'Dropdown.Slot';\n\nconst ForwardedRefDropdownTrigger = forwardRef<HTMLButtonElement, DropdownTriggerProps>(DropdownTrigger);\nconst ForwardedRefDropdownContent = forwardRef<HTMLDivElement, DropdownContentProps>(DropdownContent);\nconst ForwardedRefDropdownGroup = forwardRef<HTMLDivElement, DropdownGroupProps>(DropdownGroup);\nconst ForwardedRefDropdownSubTrigger = forwardRef<HTMLDivElement, DropdownSubTriggerProps>(DropdownSubTrigger);\nconst ForwardedRefDropdownSubContent = forwardRef<HTMLDivElement, DropdownSubContentProps>(DropdownSubContent);\nconst ForwardedRefDropdownItem = forwardRef<HTMLDivElement, DropdownItemProps>(DropdownItem);\nconst ForwardedRefDropdownSlot = forwardRef<HTMLDivElement, DropdownSlotProps>(DropdownSlot);\n\nexport const Dropdown = {\n Root: DropdownRoot,\n Trigger: ForwardedRefDropdownTrigger,\n Content: ForwardedRefDropdownContent,\n Group: ForwardedRefDropdownGroup,\n SubMenu: DropdownSubMenu,\n SubTrigger: ForwardedRefDropdownSubTrigger,\n SubContent: ForwardedRefDropdownSubContent,\n Item: ForwardedRefDropdownItem,\n Slot: ForwardedRefDropdownSlot,\n};\n"],"names":["DropdownRoot","children","open","onOpenChange","dataTestId","jsx","RadixDropdown","DropdownTrigger","ref","DropdownContent","onOpen","onClose","side","localRef","useRef","dropdownIsOpen","setMaxHeight","usePreventDropdownOverflow","styles","syncRefs","DropdownGroup","DropdownSubMenu","DropdownSubTrigger","jsxs","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","props","DropdownSlot","name","ForwardedRefDropdownTrigger","forwardRef","ForwardedRefDropdownContent","ForwardedRefDropdownGroup","ForwardedRefDropdownSubTrigger","ForwardedRefDropdownSubContent","ForwardedRefDropdownItem","ForwardedRefDropdownSlot","Dropdown"],"mappings":";;;;;;;AAwBO,MAAMA,IAAe,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAgBC,IAAa;AACjC,MAEQ,gBAAAC,EAACC,EAAc,MAAd,EAAmB,MAAAJ,GAAY,cAAAC,GAA4B,gBAAcC,GACrE,UAAAH,EACL,CAAA;AAGRD,EAAa,cAAc;AAId,MAAAO,IAAkB,CAC3B,EAAE,UAAAN,GAAU,gBAAgBG,IAAa,6BACzCI,MAGI,gBAAAH,EAACC,EAAc,SAAd,EAAsB,SAAO,IAAC,gBAAcF,GAAY,KAAAI,GACpD,UAAAP,EACL,CAAA;AAGRM,EAAgB,cAAc;AAcvB,MAAME,IAAkB,CAC3B;AAAA,EACI,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,UAAAX;AAAA,EACA,gBAAgBG,IAAa;AACjC,GACAI,MACC;AACK,QAAAK,IAAWC,EAAO,IAAI,GACtBC,IAAiBD,EAAO,EAAK,GAE7B,EAAE,cAAAE,EAAA,IAAiBC,EAA2BJ,CAAQ;AAGxD,SAAA,gBAAAR,EAACC,EAAc,QAAd,EACG,UAAA,gBAAAD;AAAA,IAACC,EAAc;AAAA,IAAd;AAAA,MACG,OAAM;AAAA,MACN,kBAAkB;AAAA,MAClB,YAAY;AAAA,MACZ,MAAAM;AAAA,MACA,WAAWM,EAAO;AAAA,MAClB,gBAAcd;AAAA,MACd,KAAKS;AAAA,MACL,kBAAkB,MAAM;AACpB,QAAAM,EAASN,GAAUL,CAAG,GACtBG,KAAWA,EAAQ,GACnBI,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AA,EAC7B,GAAG0B;AACP,GACAtB,MAGI,gBAAAH;AAAA,EAACC,EAAc;AAAA,EAAd;AAAA,IACG,UAAAuB;AAAA,IACA,WAAWX,EAAO;AAAA,IAClB,WAAAU;AAAA,IACA,gBAAcxB;AAAA,IACd,KAAAI;AAAA,IACA,UAAAmB;AAAA,IACC,GAAGG;AAAA,IAEH,UAAA7B;AAAA,EAAA;AAAA;AAIbyB,EAAa,cAAc;AAId,MAAAK,IAAe,CACxB,EAAE,UAAA9B,GAAU,MAAA+B,GAAM,gBAAgB5B,IAAa,uBAAuB,GACtEI,MAGI,gBAAAH,EAAC,OAAI,EAAA,aAAW2B,GAAM,WAAWd,EAAO,MAAM,gBAAcd,GAAY,KAAAI,GACnE,UAAAP,EACL,CAAA;AAGR8B,EAAa,cAAc;AAE3B,MAAME,IAA8BC,EAAoD3B,CAAe,GACjG4B,IAA8BD,EAAiDzB,CAAe,GAC9F2B,IAA4BF,EAA+Cd,CAAa,GACxFiB,IAAiCH,EAAoDZ,CAAkB,GACvGgB,IAAiCJ,EAAoDT,CAAkB,GACvGc,IAA2BL,EAA8CR,CAAY,GACrFc,IAA2BN,EAA8CH,CAAY,GAE9EU,IAAW;AAAA,EACpB,MAAMzC;AAAA,EACN,SAASiC;AAAA,EACT,SAASE;AAAA,EACT,OAAOC;AAAA,EACP,SAASf;AAAA,EACT,YAAYgB;AAAA,EACZ,YAAYC;AAAA,EACZ,MAAMC;AAAA,EACN,MAAMC;AACV;"}
|
|
@@ -2,7 +2,7 @@ import { jsx as a, jsxs as F } from "react/jsx-runtime";
|
|
|
2
2
|
import { IconCross as g } from "@frontify/fondue-icons";
|
|
3
3
|
import * as r from "@radix-ui/react-popover";
|
|
4
4
|
import { forwardRef as d } from "react";
|
|
5
|
-
import { flyoutContentStyles as N, flyoutHeaderStyles as C, flyoutFooterStyles as h, flyoutBodyStyles as x } from "./fondue-
|
|
5
|
+
import { flyoutContentStyles as N, flyoutHeaderStyles as C, flyoutFooterStyles as h, flyoutBodyStyles as x } from "./fondue-components25.js";
|
|
6
6
|
const i = ({ children: t, ...o }) => /* @__PURE__ */ a(r.Root, { ...o, children: t });
|
|
7
7
|
i.displayName = "Flyout.Root";
|
|
8
8
|
const y = ({ children: t, "data-test-id": o = "fondue-flyout-trigger" }, e) => /* @__PURE__ */ a(r.Trigger, { "data-test-id": o, asChild: !0, ref: e, children: t });
|
package/dist/index.d.ts
CHANGED
|
@@ -342,6 +342,13 @@ export declare const Dropdown: {
|
|
|
342
342
|
declare type DropdownContentProps = {
|
|
343
343
|
children?: ReactNode;
|
|
344
344
|
'data-test-id'?: string;
|
|
345
|
+
onOpen?: () => void;
|
|
346
|
+
onClose?: () => void;
|
|
347
|
+
/**
|
|
348
|
+
* Defines the preferred side of the dropdown. It will not be respected if there are collisions with the viewport.
|
|
349
|
+
* @default "bottom"
|
|
350
|
+
*/
|
|
351
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
345
352
|
};
|
|
346
353
|
|
|
347
354
|
declare type DropdownGroupProps = {
|
|
@@ -362,7 +369,7 @@ declare type DropdownItemProps = {
|
|
|
362
369
|
/**
|
|
363
370
|
* Callback that is called when the item is selected.
|
|
364
371
|
*/
|
|
365
|
-
onSelect
|
|
372
|
+
onSelect?: (event: Event) => void;
|
|
366
373
|
'data-test-id'?: string;
|
|
367
374
|
};
|
|
368
375
|
|
|
@@ -816,7 +823,7 @@ declare type TooltipContentProps = {
|
|
|
816
823
|
*/
|
|
817
824
|
padding?: 'spacious' | 'compact';
|
|
818
825
|
/**
|
|
819
|
-
* Defines the
|
|
826
|
+
* Defines the preferred side of the tooltip. It will not be respected if there are collisions with the viewport.
|
|
820
827
|
*/
|
|
821
828
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
822
829
|
maxWidth?: string;
|