@frontify/fondue-components 8.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components10.js +1 -1
- package/dist/fondue-components11.js +65 -75
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +1 -1
- package/dist/fondue-components14.js +1 -1
- package/dist/fondue-components15.js +1 -1
- package/dist/fondue-components16.js +1 -1
- package/dist/fondue-components17.js +2 -2
- package/dist/fondue-components18.js +6 -6
- package/dist/fondue-components19.js +1 -1
- package/dist/fondue-components20.js +1 -1
- package/dist/fondue-components21.js +46 -46
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +3 -3
- package/dist/fondue-components23.js +1 -1
- package/dist/fondue-components24.js +1 -1
- package/dist/fondue-components28.js +1 -1
- package/dist/fondue-components31.js +1 -1
- package/dist/fondue-components33.js +1 -1
- package/dist/fondue-components37.js +10 -25
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components40.js +17 -14
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +17 -18
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +4 -16
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +13 -3
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +3 -13
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +35 -5
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +13 -35
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +4 -12
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +24 -4
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +16 -24
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components50.js +139 -16
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +16 -140
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +70 -16
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +8 -72
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +33 -8
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +48 -32
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +10 -48
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +10 -8
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +7 -12
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +12 -7
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components60.js +20 -12
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +15 -19
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +52 -14
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +14 -52
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +17 -14
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +6 -17
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +2 -7
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +15 -2
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +38 -14
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components9.js +91 -101
- package/dist/fondue-components9.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/fondue-components69.js +0 -42
- package/dist/fondue-components69.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components63.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components63.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
const
|
|
2
|
-
root:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const s = "_root_1s6a3_5", o = "_input_1s6a3_59", t = "_slot_1s6a3_82", _ = "_iconSuccess_1s6a3_132", n = "_iconError_1s6a3_140", c = "_loadingStatus_1s6a3_148", a = "_spin_1s6a3_1", i = {
|
|
2
|
+
root: s,
|
|
3
|
+
input: o,
|
|
4
|
+
slot: t,
|
|
5
|
+
iconSuccess: _,
|
|
6
|
+
iconError: n,
|
|
7
|
+
loadingStatus: c,
|
|
8
|
+
spin: a,
|
|
9
|
+
"tw-dark": "_tw-dark_1s6a3_180"
|
|
8
10
|
};
|
|
9
11
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
i as default,
|
|
13
|
+
n as iconError,
|
|
14
|
+
_ as iconSuccess,
|
|
15
|
+
o as input,
|
|
16
|
+
c as loadingStatus,
|
|
17
|
+
s as root,
|
|
18
|
+
t as slot,
|
|
19
|
+
a as spin
|
|
17
20
|
};
|
|
18
21
|
//# sourceMappingURL=fondue-components64.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components64.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components64.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
root:
|
|
3
|
-
|
|
4
|
-
slot: s,
|
|
5
|
-
iconSuccess: _,
|
|
6
|
-
iconError: n,
|
|
7
|
-
loadingStatus: c,
|
|
8
|
-
spin: i,
|
|
9
|
-
"tw-dark": "_tw-dark_y2kt3_176"
|
|
1
|
+
const o = "_root_18vgg_4", r = "_arrow_18vgg_22", t = {
|
|
2
|
+
root: o,
|
|
3
|
+
arrow: r
|
|
10
4
|
};
|
|
11
5
|
export {
|
|
12
|
-
r as
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
o as input,
|
|
16
|
-
c as loadingStatus,
|
|
17
|
-
t as root,
|
|
18
|
-
s as slot,
|
|
19
|
-
i as spin
|
|
6
|
+
r as arrow,
|
|
7
|
+
t as default,
|
|
8
|
+
o as root
|
|
20
9
|
};
|
|
21
10
|
//# sourceMappingURL=fondue-components65.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components65.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components65.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
root: o,
|
|
3
|
-
arrow: r
|
|
4
|
-
};
|
|
1
|
+
const t = "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";
|
|
5
2
|
export {
|
|
6
|
-
|
|
7
|
-
t as default,
|
|
8
|
-
o as root
|
|
3
|
+
t as FOCUS_OUTLINE
|
|
9
4
|
};
|
|
10
5
|
//# sourceMappingURL=fondue-components66.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components66.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components66.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;"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
const t = "
|
|
1
|
+
const o = "_root_8a8rm_5", t = "_button_8a8rm_56", c = "_colorIndicator_8a8rm_69", r = "_actions_8a8rm_75", a = "_clear_8a8rm_85", _ = "_caret_8a8rm_98", n = {
|
|
2
|
+
root: o,
|
|
3
|
+
button: t,
|
|
4
|
+
colorIndicator: c,
|
|
5
|
+
actions: r,
|
|
6
|
+
clear: a,
|
|
7
|
+
caret: _
|
|
8
|
+
};
|
|
2
9
|
export {
|
|
3
|
-
|
|
10
|
+
r as actions,
|
|
11
|
+
t as button,
|
|
12
|
+
_ as caret,
|
|
13
|
+
a as clear,
|
|
14
|
+
c as colorIndicator,
|
|
15
|
+
n as default,
|
|
16
|
+
o as root
|
|
4
17
|
};
|
|
5
18
|
//# sourceMappingURL=fondue-components67.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components67.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components67.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Children as a, isValidElement as u, cloneElement as f } from "react";
|
|
2
|
+
import { ForwardedRefSelectItem as E } from "./fondue-components51.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
|
+
};
|
|
8
36
|
};
|
|
9
37
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
a as clear,
|
|
14
|
-
c as colorIndicator,
|
|
15
|
-
n as default,
|
|
16
|
-
o as root
|
|
38
|
+
g as getSelectOptionValue,
|
|
39
|
+
w as isReactLeaf,
|
|
40
|
+
y as recursiveMap
|
|
17
41
|
};
|
|
18
42
|
//# sourceMappingURL=fondue-components68.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components68.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components68.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;AAC3B,IAGG;AAAA,EACH,OAAOC,KAAS;AAAA,EAChB,OAAOC,KAAgBD,KAAS;AACpC,GAkBSE,IAAc,CAACC,GAAkBC,MAC1CC,EAAeF,CAAK,KAAKA,EAAM,SAASC,GAoB/BE,IAAe,CACxBP,GACAQ,GACAC,GACAC,IAAoB,MAInB;AACD,QAAMC,IAAiC,CAAC;AACxC,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,MAChB;AACA,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,EACrB;AACJ;"}
|
|
@@ -1,139 +1,129 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { IconCaretRight as
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { IconCaretRight as F } from "@frontify/fondue-icons";
|
|
3
3
|
import * as n from "@radix-ui/react-dropdown-menu";
|
|
4
|
-
import { Slot as
|
|
5
|
-
import { forwardRef as s
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import a from "./fondue-components42.js";
|
|
10
|
-
const b = ({
|
|
4
|
+
import { Slot as I } from "@radix-ui/react-slot";
|
|
5
|
+
import { forwardRef as s } from "react";
|
|
6
|
+
import { useProcessedChildren as w } from "./fondue-components40.js";
|
|
7
|
+
import a from "./fondue-components41.js";
|
|
8
|
+
const m = ({
|
|
11
9
|
children: o,
|
|
12
10
|
open: t,
|
|
13
11
|
onOpenChange: r,
|
|
14
|
-
"data-test-id":
|
|
15
|
-
}) => /* @__PURE__ */
|
|
16
|
-
|
|
17
|
-
const
|
|
12
|
+
"data-test-id": d = "fondue-dropdown"
|
|
13
|
+
}) => /* @__PURE__ */ e(n.Root, { open: t, onOpenChange: r, "data-test-id": d, children: o });
|
|
14
|
+
m.displayName = "Dropdown.Root";
|
|
15
|
+
const l = ({
|
|
18
16
|
asChild: o = !0,
|
|
19
17
|
children: t,
|
|
20
18
|
"data-test-id": r = "fondue-dropdown-trigger",
|
|
21
|
-
...
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
children: w
|
|
53
|
-
}
|
|
54
|
-
) });
|
|
55
|
-
};
|
|
56
|
-
R.displayName = "Dropdown.Content";
|
|
57
|
-
const N = ({ children: o, "data-test-id": t = "fondue-dropdown-group" }, r) => /* @__PURE__ */ d(n.Group, { className: a.group, "data-test-id": t, ref: r, children: o });
|
|
58
|
-
N.displayName = "Dropdown.Group";
|
|
59
|
-
const C = ({
|
|
19
|
+
...d
|
|
20
|
+
}, i) => /* @__PURE__ */ e(n.Trigger, { asChild: o, "data-test-id": r, ref: i, ...d, children: t });
|
|
21
|
+
l.displayName = "Dropdown.Trigger";
|
|
22
|
+
const g = ({
|
|
23
|
+
side: o = "bottom",
|
|
24
|
+
padding: t = "comfortable",
|
|
25
|
+
align: r = "start",
|
|
26
|
+
children: d,
|
|
27
|
+
preventTriggerFocusOnClose: i,
|
|
28
|
+
"data-test-id": p = "fondue-dropdown-content"
|
|
29
|
+
}, u) => /* @__PURE__ */ e(n.Portal, { children: /* @__PURE__ */ e(
|
|
30
|
+
n.Content,
|
|
31
|
+
{
|
|
32
|
+
align: r,
|
|
33
|
+
collisionPadding: 8,
|
|
34
|
+
sideOffset: 8,
|
|
35
|
+
side: o,
|
|
36
|
+
className: a.content,
|
|
37
|
+
"data-padding": t,
|
|
38
|
+
"data-test-id": p,
|
|
39
|
+
ref: u,
|
|
40
|
+
onCloseAutoFocus: (c) => {
|
|
41
|
+
i && c.preventDefault();
|
|
42
|
+
},
|
|
43
|
+
children: d
|
|
44
|
+
}
|
|
45
|
+
) });
|
|
46
|
+
g.displayName = "Dropdown.Content";
|
|
47
|
+
const f = ({ children: o, "data-test-id": t = "fondue-dropdown-group" }, r) => /* @__PURE__ */ e(n.Group, { className: a.group, "data-test-id": t, ref: r, children: o });
|
|
48
|
+
f.displayName = "Dropdown.Group";
|
|
49
|
+
const D = ({
|
|
60
50
|
children: o,
|
|
61
51
|
"data-test-id": t = "fondue-dropdown-submenu"
|
|
62
|
-
}) => /* @__PURE__ */
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const { content:
|
|
66
|
-
return /* @__PURE__ */
|
|
67
|
-
|
|
68
|
-
/* @__PURE__ */
|
|
52
|
+
}) => /* @__PURE__ */ e(n.Sub, { "data-test-id": t, children: o });
|
|
53
|
+
D.displayName = "Dropdown.SubMenu";
|
|
54
|
+
const b = ({ children: o, "data-test-id": t = "fondue-dropdown-subtrigger" }, r) => {
|
|
55
|
+
const { content: d } = w(o);
|
|
56
|
+
return /* @__PURE__ */ h(n.SubTrigger, { className: a.subTrigger, "data-test-id": t, ref: r, children: [
|
|
57
|
+
d,
|
|
58
|
+
/* @__PURE__ */ e(F, { className: a.subMenuIndicator, size: 16 })
|
|
69
59
|
] });
|
|
70
60
|
};
|
|
71
|
-
|
|
72
|
-
const
|
|
61
|
+
b.displayName = "Dropdown.SubTrigger";
|
|
62
|
+
const S = ({
|
|
73
63
|
padding: o = "comfortable",
|
|
74
64
|
children: t,
|
|
75
65
|
"data-test-id": r = "fondue-dropdown-subcontent"
|
|
76
|
-
},
|
|
66
|
+
}, d) => /* @__PURE__ */ e(n.Portal, { children: /* @__PURE__ */ e(
|
|
77
67
|
n.SubContent,
|
|
78
68
|
{
|
|
79
69
|
className: a.subContent,
|
|
80
70
|
"data-padding": o,
|
|
81
71
|
"data-test-id": r,
|
|
82
|
-
ref:
|
|
72
|
+
ref: d,
|
|
83
73
|
children: t
|
|
84
74
|
}
|
|
85
75
|
) });
|
|
86
|
-
|
|
87
|
-
const
|
|
76
|
+
S.displayName = "Dropdown.SubContent";
|
|
77
|
+
const N = ({
|
|
88
78
|
children: o,
|
|
89
79
|
disabled: t,
|
|
90
80
|
textValue: r,
|
|
91
|
-
onSelect:
|
|
92
|
-
emphasis:
|
|
93
|
-
"data-test-id":
|
|
94
|
-
...
|
|
95
|
-
},
|
|
96
|
-
const { content:
|
|
97
|
-
return /* @__PURE__ */
|
|
81
|
+
onSelect: d,
|
|
82
|
+
emphasis: i = "default",
|
|
83
|
+
"data-test-id": p = "fondue-dropdown-subtrigger",
|
|
84
|
+
...u
|
|
85
|
+
}, c) => {
|
|
86
|
+
const { content: R, isLink: T } = w(o), y = T ? I : "div";
|
|
87
|
+
return /* @__PURE__ */ e(
|
|
98
88
|
n.Item,
|
|
99
89
|
{
|
|
100
|
-
onSelect:
|
|
90
|
+
onSelect: d,
|
|
101
91
|
className: a.item,
|
|
102
92
|
textValue: r,
|
|
103
|
-
"data-test-id":
|
|
104
|
-
"data-emphasis":
|
|
105
|
-
ref:
|
|
93
|
+
"data-test-id": p,
|
|
94
|
+
"data-emphasis": i,
|
|
95
|
+
ref: c,
|
|
106
96
|
disabled: t,
|
|
107
97
|
asChild: !0,
|
|
108
|
-
...
|
|
109
|
-
children: /* @__PURE__ */
|
|
98
|
+
...u,
|
|
99
|
+
children: /* @__PURE__ */ e(y, { children: R })
|
|
110
100
|
}
|
|
111
101
|
);
|
|
112
102
|
};
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
Root:
|
|
118
|
-
Trigger:
|
|
119
|
-
Content:
|
|
120
|
-
Group:
|
|
121
|
-
SubMenu:
|
|
122
|
-
SubTrigger:
|
|
123
|
-
SubContent:
|
|
124
|
-
Item:
|
|
125
|
-
Slot:
|
|
103
|
+
N.displayName = "Dropdown.Item";
|
|
104
|
+
const C = ({ children: o, name: t, "data-test-id": r = "fondue-dropdown-slot" }, d) => /* @__PURE__ */ e("div", { "data-name": t, className: a.slot, "data-test-id": r, ref: d, children: o });
|
|
105
|
+
C.displayName = "Dropdown.Slot";
|
|
106
|
+
const G = s(l), x = s(g), M = s(f), P = s(b), v = s(S), j = s(N), k = s(C), B = {
|
|
107
|
+
Root: m,
|
|
108
|
+
Trigger: G,
|
|
109
|
+
Content: x,
|
|
110
|
+
Group: M,
|
|
111
|
+
SubMenu: D,
|
|
112
|
+
SubTrigger: P,
|
|
113
|
+
SubContent: v,
|
|
114
|
+
Item: j,
|
|
115
|
+
Slot: k
|
|
126
116
|
};
|
|
127
117
|
export {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
118
|
+
B as Dropdown,
|
|
119
|
+
g as DropdownContent,
|
|
120
|
+
f as DropdownGroup,
|
|
121
|
+
N as DropdownItem,
|
|
122
|
+
m as DropdownRoot,
|
|
123
|
+
C as DropdownSlot,
|
|
124
|
+
S as DropdownSubContent,
|
|
125
|
+
D as DropdownSubMenu,
|
|
126
|
+
b as DropdownSubTrigger,
|
|
127
|
+
l as DropdownTrigger
|
|
138
128
|
};
|
|
139
129
|
//# sourceMappingURL=fondue-components9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components9.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 { Slot } from '@radix-ui/react-slot';\nimport { forwardRef, useRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\nimport { syncRefs } from '#/utilities/domUtilities';\n\nimport { useProcessedChildren } from './hooks/useProcessedChildren';\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\n 'data-test-id'?: string;\n};\n\nexport const DropdownRoot = ({\n children,\n open,\n onOpenChange,\n\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 = {\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 DropdownTrigger = (\n {\n asChild = true,\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-trigger',\n ...props\n }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild={asChild} data-test-id={dataTestId} ref={ref} {...props}>\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 * The vertical padding around each dropdown item.\n * @default \"comfortable\"\n */\n padding?: 'comfortable' | 'compact';\n /**\n * Defines the alignment of the dropdown.\n * @default \"start\"\n */\n align?: 'start' | 'center' | 'end';\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 * Prevents the focus from being set on the trigger when the dropdown is closed.\n */\n preventTriggerFocusOnClose?: boolean;\n};\n\nexport const DropdownContent = (\n {\n onOpen,\n onClose,\n side = 'bottom',\n padding = 'comfortable',\n align = 'start',\n children,\n preventTriggerFocusOnClose,\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={align}\n collisionPadding={8}\n sideOffset={8}\n side={side}\n className={styles.content}\n data-padding={padding}\n data-test-id={dataTestId}\n ref={localRef}\n onCloseAutoFocus={(event) => {\n if (preventTriggerFocusOnClose) {\n event.preventDefault();\n }\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 const { content } = useProcessedChildren(children);\n return (\n <RadixDropdown.SubTrigger className={styles.subTrigger} data-test-id={dataTestId} ref={ref}>\n {content}\n <IconCaretRight className={styles.subMenuIndicator} size={16} />\n </RadixDropdown.SubTrigger>\n );\n};\nDropdownSubTrigger.displayName = 'Dropdown.SubTrigger';\n\nexport type DropdownSubContentProps = {\n /**\n * The vertical padding around each dropdown item.\n * @default \"comfortable\"\n */\n padding?: 'comfortable' | 'compact';\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const DropdownSubContent = (\n {\n padding = 'comfortable',\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-subcontent',\n }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.SubContent\n className={styles.subContent}\n data-padding={padding}\n data-test-id={dataTestId}\n ref={ref}\n >\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 * The style of the item.\n * @default \"default\"\n */\n emphasis?: 'default' | 'danger';\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 emphasis = 'default',\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { content, isLink } = useProcessedChildren(children);\n\n const Wrapper = isLink ? Slot : 'div';\n\n return (\n <RadixDropdown.Item\n onSelect={onSelect}\n className={styles.item}\n textValue={textValue}\n data-test-id={dataTestId}\n data-emphasis={emphasis}\n ref={ref}\n disabled={disabled}\n asChild\n {...props}\n >\n <Wrapper>{content}</Wrapper>\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","asChild","props","ref","DropdownContent","onOpen","onClose","side","padding","align","preventTriggerFocusOnClose","localRef","useRef","dropdownIsOpen","setMaxHeight","usePreventDropdownOverflow","styles","event","syncRefs","DropdownGroup","DropdownSubMenu","DropdownSubTrigger","content","useProcessedChildren","jsxs","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","emphasis","isLink","Wrapper","Slot","DropdownSlot","name","ForwardedRefDropdownTrigger","forwardRef","ForwardedRefDropdownContent","ForwardedRefDropdownGroup","ForwardedRefDropdownSubTrigger","ForwardedRefDropdownSubContent","ForwardedRefDropdownItem","ForwardedRefDropdownSlot","Dropdown"],"mappings":";;;;;;;;;AA2BO,MAAMA,IAAe,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EAEA,gBAAgBC,IAAa;AACjC,MAEQ,gBAAAC,EAACC,EAAc,MAAd,EAAmB,MAAAJ,GAAY,cAAAC,GAA4B,gBAAcC,GACrE,UAAAH,GACL;AAGRD,EAAa,cAAc;AAYpB,MAAMO,IAAkB,CAC3B;AAAA,EACI,SAAAC,IAAU;AAAA,EACV,UAAAP;AAAA,EACA,gBAAgBG,IAAa;AAAA,EAC7B,GAAGK;AACP,GACAC,MAGI,gBAAAL,EAACC,EAAc,SAAd,EAAsB,SAAAE,GAAkB,gBAAcJ,GAAY,KAAAM,GAAW,GAAGD,GAC5E,UAAAR,EACL,CAAA;AAGRM,EAAgB,cAAc;AA4BvB,MAAMI,IAAkB,CAC3B;AAAA,EACI,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,S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;AAAA,EACtB;AAER;AACAK,EAAa,cAAc;AAId,MAAAQ,IAAe,CACxB,EAAE,UAAAzC,GAAU,MAAA0C,GAAM,gBAAgBvC,IAAa,uBAAuB,GACtEM,MAGI,gBAAAL,EAAC,OAAI,EAAA,aAAWsC,GAAM,WAAWpB,EAAO,MAAM,gBAAcnB,GAAY,KAAAM,GACnE,UAAAT,EACL,CAAA;AAGRyC,EAAa,cAAc;AAE3B,MAAME,IAA8BC,EAAoDtC,CAAe,GACjGuC,IAA8BD,EAAiDlC,CAAe,GAC9FoC,IAA4BF,EAA+CnB,CAAa,GACxFsB,IAAiCH,EAAoDjB,CAAkB,GACvGqB,IAAiCJ,EAAoDZ,CAAkB,GACvGiB,IAA2BL,EAA8CX,CAAY,GACrFiB,IAA2BN,EAA8CH,CAAY,GAE9EU,IAAW;AAAA,EACpB,MAAMpD;AAAA,EACN,SAAS4C;AAAA,EACT,SAASE;AAAA,EACT,OAAOC;AAAA,EACP,SAASpB;AAAA,EACT,YAAYqB;AAAA,EACZ,YAAYC;AAAA,EACZ,MAAMC;AAAA,EACN,MAAMC;AACV;"}
|
|
1
|
+
{"version":3,"file":"fondue-components9.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 { Slot } from '@radix-ui/react-slot';\nimport { forwardRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport { useProcessedChildren } from './hooks/useProcessedChildren';\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\n 'data-test-id'?: string;\n};\n\nexport const DropdownRoot = ({\n children,\n open,\n onOpenChange,\n\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 = {\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 DropdownTrigger = (\n {\n asChild = true,\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-trigger',\n ...props\n }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild={asChild} data-test-id={dataTestId} ref={ref} {...props}>\n {children}\n </RadixDropdown.Trigger>\n );\n};\nDropdownTrigger.displayName = 'Dropdown.Trigger';\n\nexport type DropdownContentProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\n /**\n * The vertical padding around each dropdown item.\n * @default \"comfortable\"\n */\n padding?: 'comfortable' | 'compact';\n /**\n * Defines the alignment of the dropdown.\n * @default \"start\"\n */\n align?: 'start' | 'center' | 'end';\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 * Prevents the focus from being set on the trigger when the dropdown is closed.\n */\n preventTriggerFocusOnClose?: boolean;\n};\n\nexport const DropdownContent = (\n {\n side = 'bottom',\n padding = 'comfortable',\n align = 'start',\n children,\n preventTriggerFocusOnClose,\n 'data-test-id': dataTestId = 'fondue-dropdown-content',\n }: DropdownContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.Content\n align={align}\n collisionPadding={8}\n sideOffset={8}\n side={side}\n className={styles.content}\n data-padding={padding}\n data-test-id={dataTestId}\n ref={ref}\n onCloseAutoFocus={(event) => {\n if (preventTriggerFocusOnClose) {\n event.preventDefault();\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 const { content } = useProcessedChildren(children);\n return (\n <RadixDropdown.SubTrigger className={styles.subTrigger} data-test-id={dataTestId} ref={ref}>\n {content}\n <IconCaretRight className={styles.subMenuIndicator} size={16} />\n </RadixDropdown.SubTrigger>\n );\n};\nDropdownSubTrigger.displayName = 'Dropdown.SubTrigger';\n\nexport type DropdownSubContentProps = {\n /**\n * The vertical padding around each dropdown item.\n * @default \"comfortable\"\n */\n padding?: 'comfortable' | 'compact';\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const DropdownSubContent = (\n {\n padding = 'comfortable',\n children,\n 'data-test-id': dataTestId = 'fondue-dropdown-subcontent',\n }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDropdown.Portal>\n <RadixDropdown.SubContent\n className={styles.subContent}\n data-padding={padding}\n data-test-id={dataTestId}\n ref={ref}\n >\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 * The style of the item.\n * @default \"default\"\n */\n emphasis?: 'default' | 'danger';\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 emphasis = 'default',\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { content, isLink } = useProcessedChildren(children);\n\n const Wrapper = isLink ? Slot : 'div';\n\n return (\n <RadixDropdown.Item\n onSelect={onSelect}\n className={styles.item}\n textValue={textValue}\n data-test-id={dataTestId}\n data-emphasis={emphasis}\n ref={ref}\n disabled={disabled}\n asChild\n {...props}\n >\n <Wrapper>{content}</Wrapper>\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","asChild","props","ref","DropdownContent","side","padding","align","preventTriggerFocusOnClose","styles","event","DropdownGroup","DropdownSubMenu","DropdownSubTrigger","content","useProcessedChildren","jsxs","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","emphasis","isLink","Wrapper","Slot","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,EAEA,gBAAgBC,IAAa;AACjC,MAEQ,gBAAAC,EAACC,EAAc,MAAd,EAAmB,MAAAJ,GAAY,cAAAC,GAA4B,gBAAcC,GACrE,UAAAH,GACL;AAGRD,EAAa,cAAc;AAYpB,MAAMO,IAAkB,CAC3B;AAAA,EACI,SAAAC,IAAU;AAAA,EACV,UAAAP;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GAAU,MAAAkC,GAAM,gBAAgB/B,IAAa,uBAAuB,GACtEM,MAGI,gBAAAL,EAAC,OAAI,EAAA,aAAW8B,GAAM,WAAWnB,EAAO,MAAM,gBAAcZ,GAAY,KAAAM,GACnE,UAAAT,EACL,CAAA;AAGRiC,EAAa,cAAc;AAE3B,MAAME,IAA8BC,EAAoD9B,CAAe,GACjG+B,IAA8BD,EAAiD1B,CAAe,GAC9F4B,IAA4BF,EAA+CnB,CAAa,GACxFsB,IAAiCH,EAAoDjB,CAAkB,GACvGqB,IAAiCJ,EAAoDZ,CAAkB,GACvGiB,IAA2BL,EAA8CX,CAAY,GACrFiB,IAA2BN,EAA8CH,CAAY,GAE9EU,IAAW;AAAA,EACpB,MAAM5C;AAAA,EACN,SAASoC;AAAA,EACT,SAASE;AAAA,EACT,OAAOC;AAAA,EACP,SAASpB;AAAA,EACT,YAAYqB;AAAA,EACZ,YAAYC;AAAA,EACZ,MAAMC;AAAA,EACN,MAAMC;AACV;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -510,8 +510,6 @@ export declare const Dropdown: {
|
|
|
510
510
|
declare type DropdownContentProps = {
|
|
511
511
|
children?: ReactNode;
|
|
512
512
|
'data-test-id'?: string;
|
|
513
|
-
onOpen?: () => void;
|
|
514
|
-
onClose?: () => void;
|
|
515
513
|
/**
|
|
516
514
|
* The vertical padding around each dropdown item.
|
|
517
515
|
* @default "comfortable"
|