@frontify/fondue-components 4.0.1 → 4.0.2
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.map +1 -1
- package/dist/fondue-components11.js +40 -36
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js.map +1 -1
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components14.js.map +1 -1
- package/dist/fondue-components15.js.map +1 -1
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +27 -27
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +1 -1
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js.map +1 -1
- package/dist/fondue-components40.js +1 -1
- package/dist/fondue-components42.js +6 -6
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +6 -6
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components5.js.map +1 -1
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +1 -1
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components54.js +1 -1
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +9 -9
- package/dist/fondue-components6.js.map +1 -1
- package/dist/fondue-components60.js +1 -1
- package/dist/fondue-components62.js +10 -38
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +38 -10
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components7.js.map +1 -1
- package/dist/fondue-components8.js.map +1 -1
- package/dist/fondue-components9.js +29 -16
- package/dist/fondue-components9.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/style.css +1 -1
- package/package.json +48 -48
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as I } from "react/jsx-runtime";
|
|
2
2
|
import { IconCaretRight as h } from "@frontify/fondue-icons";
|
|
3
|
-
import * as
|
|
3
|
+
import * as n from "@radix-ui/react-dropdown-menu";
|
|
4
4
|
import { forwardRef as s, useRef as l } from "react";
|
|
5
5
|
import { usePreventDropdownOverflow as v } from "./fondue-components39.js";
|
|
6
6
|
import { syncRefs as f } from "./fondue-components36.js";
|
|
@@ -9,30 +9,30 @@ const g = ({
|
|
|
9
9
|
children: o,
|
|
10
10
|
open: t,
|
|
11
11
|
onOpenChange: r,
|
|
12
|
-
"data-test-id":
|
|
13
|
-
}) => /* @__PURE__ */ e(
|
|
12
|
+
"data-test-id": d = "fondue-dropdown"
|
|
13
|
+
}) => /* @__PURE__ */ e(n.Root, { open: t, onOpenChange: r, "data-test-id": d, children: o });
|
|
14
14
|
g.displayName = "Dropdown.Root";
|
|
15
|
-
const D = ({ asChild: o = !0, children: t, "data-test-id": r = "fondue-dropdown-trigger" },
|
|
15
|
+
const D = ({ asChild: o = !0, children: t, "data-test-id": r = "fondue-dropdown-trigger" }, d) => /* @__PURE__ */ e(n.Trigger, { asChild: o, "data-test-id": r, ref: d, children: t });
|
|
16
16
|
D.displayName = "Dropdown.Trigger";
|
|
17
17
|
const b = ({
|
|
18
18
|
onOpen: o,
|
|
19
19
|
onClose: t,
|
|
20
20
|
side: r = "bottom",
|
|
21
|
-
padding:
|
|
21
|
+
padding: d = "comfortable",
|
|
22
22
|
align: p = "start",
|
|
23
23
|
children: u,
|
|
24
24
|
"data-test-id": c = "fondue-dropdown-content"
|
|
25
25
|
}, m) => {
|
|
26
26
|
const i = l(null), w = l(!1), { setMaxHeight: F } = v(i);
|
|
27
|
-
return /* @__PURE__ */ e(
|
|
28
|
-
|
|
27
|
+
return /* @__PURE__ */ e(n.Portal, { children: /* @__PURE__ */ e(
|
|
28
|
+
n.Content,
|
|
29
29
|
{
|
|
30
30
|
align: p,
|
|
31
31
|
collisionPadding: 8,
|
|
32
32
|
sideOffset: 8,
|
|
33
33
|
side: r,
|
|
34
34
|
className: a.content,
|
|
35
|
-
"data-padding":
|
|
35
|
+
"data-padding": d,
|
|
36
36
|
"data-test-id": c,
|
|
37
37
|
ref: i,
|
|
38
38
|
onCloseAutoFocus: () => {
|
|
@@ -46,31 +46,44 @@ const b = ({
|
|
|
46
46
|
) });
|
|
47
47
|
};
|
|
48
48
|
b.displayName = "Dropdown.Content";
|
|
49
|
-
const N = ({ children: o, "data-test-id": t = "fondue-dropdown-group" }, r) => /* @__PURE__ */ e(
|
|
49
|
+
const N = ({ 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 });
|
|
50
50
|
N.displayName = "Dropdown.Group";
|
|
51
51
|
const S = ({
|
|
52
52
|
children: o,
|
|
53
53
|
"data-test-id": t = "fondue-dropdown-submenu"
|
|
54
|
-
}) => /* @__PURE__ */ e(
|
|
54
|
+
}) => /* @__PURE__ */ e(n.Sub, { "data-test-id": t, children: o });
|
|
55
55
|
S.displayName = "Dropdown.SubMenu";
|
|
56
|
-
const R = ({ children: o, "data-test-id": t = "fondue-dropdown-subtrigger" }, r) => /* @__PURE__ */ I(
|
|
56
|
+
const R = ({ children: o, "data-test-id": t = "fondue-dropdown-subtrigger" }, r) => /* @__PURE__ */ I(n.SubTrigger, { className: a.subTrigger, "data-test-id": t, ref: r, children: [
|
|
57
57
|
/* @__PURE__ */ e("div", { className: a.itemContent, children: o }),
|
|
58
58
|
/* @__PURE__ */ e(h, { className: a.subMenuIndicator, size: 16 })
|
|
59
59
|
] });
|
|
60
60
|
R.displayName = "Dropdown.SubTrigger";
|
|
61
|
-
const C = ({
|
|
61
|
+
const C = ({
|
|
62
|
+
padding: o = "comfortable",
|
|
63
|
+
children: t,
|
|
64
|
+
"data-test-id": r = "fondue-dropdown-subcontent"
|
|
65
|
+
}, d) => /* @__PURE__ */ e(n.Portal, { children: /* @__PURE__ */ e(
|
|
66
|
+
n.SubContent,
|
|
67
|
+
{
|
|
68
|
+
className: a.subContent,
|
|
69
|
+
"data-padding": o,
|
|
70
|
+
"data-test-id": r,
|
|
71
|
+
ref: d,
|
|
72
|
+
children: t
|
|
73
|
+
}
|
|
74
|
+
) });
|
|
62
75
|
C.displayName = "Dropdown.SubContent";
|
|
63
76
|
const y = ({
|
|
64
77
|
children: o,
|
|
65
78
|
disabled: t,
|
|
66
79
|
textValue: r,
|
|
67
|
-
onSelect:
|
|
80
|
+
onSelect: d,
|
|
68
81
|
"data-test-id": p = "fondue-dropdown-subtrigger",
|
|
69
82
|
...u
|
|
70
83
|
}, c) => /* @__PURE__ */ e(
|
|
71
|
-
|
|
84
|
+
n.Item,
|
|
72
85
|
{
|
|
73
|
-
onSelect:
|
|
86
|
+
onSelect: d,
|
|
74
87
|
className: a.item,
|
|
75
88
|
textValue: r,
|
|
76
89
|
"data-test-id": p,
|
|
@@ -81,7 +94,7 @@ const y = ({
|
|
|
81
94
|
}
|
|
82
95
|
);
|
|
83
96
|
y.displayName = "Dropdown.Item";
|
|
84
|
-
const T = ({ children: o, name: t, "data-test-id": r = "fondue-dropdown-slot" },
|
|
97
|
+
const T = ({ 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 });
|
|
85
98
|
T.displayName = "Dropdown.Slot";
|
|
86
99
|
const x = s(D), G = s(b), M = s(N), P = s(R), j = s(C), O = s(y), z = s(T), J = {
|
|
87
100
|
Root: g,
|
|
@@ -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 { 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 = {\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 { asChild = true, children, 'data-test-id': dataTestId = 'fondue-dropdown-trigger' }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild={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 * 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\nexport const DropdownContent = (\n {\n onOpen,\n onClose,\n side = 'bottom',\n padding = 'comfortable',\n align = 'start',\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={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={() => {\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 <div className={styles.itemContent}>{children}</div>\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 <div className={styles.itemContent}>{children}</div>\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","ref","DropdownContent","onOpen","onClose","side","padding","align","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;AAYd,MAAAO,IAAkB,CAC3B,EAAE,SAAAC,IAAU,IAAM,UAAAP,GAAU,gBAAgBG,IAAa,0BAA0B,GACnFK,MAGI,gBAAAJ,EAACC,EAAc,SAAd,EAAsB,SAAAE,GAAkB,gBAAcJ,GAAY,KAAAK,GAC9D,UAAAR,EACL,CAAA;AAGRM,EAAgB,cAAc;AAwBvB,MAAMG,IAAkB,CAC3B;AAAA,EACI,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,OAAAC,IAAQ;AAAA,EACR,UAAAd;AAAA,EACA,gBAAgBG,IAAa;AACjC,GACAK,MACC;AACK,QAAAO,IAAWC,EAAO,IAAI,GACtBC,IAAiBD,EAAO,EAAK,GAE7B,EAAE,cAAAE,EAAA,IAAiBC,EAA2BJ,CAAQ;AAGxD,SAAA,gBAAAX,EAACC,EAAc,QAAd,EACG,UAAA,gBAAAD;AAAA,IAACC,EAAc;AAAA,IAAd;AAAA,MACG,OAAAS;AAAA,MACA,kBAAkB;AAAA,MAClB,YAAY;AAAA,MACZ,MAAAF;AAAA,MACA,WAAWQ,E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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 { 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 = {\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 { asChild = true, children, 'data-test-id': dataTestId = 'fondue-dropdown-trigger' }: DropdownTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDropdown.Trigger asChild={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 * 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\nexport const DropdownContent = (\n {\n onOpen,\n onClose,\n side = 'bottom',\n padding = 'comfortable',\n align = 'start',\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={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={() => {\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 <div className={styles.itemContent}>{children}</div>\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 * 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 <div className={styles.itemContent}>{children}</div>\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","ref","DropdownContent","onOpen","onClose","side","padding","align","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,GACL;AAGRD,EAAa,cAAc;AAYd,MAAAO,IAAkB,CAC3B,EAAE,SAAAC,IAAU,IAAM,UAAAP,GAAU,gBAAgBG,IAAa,0BAA0B,GACnFK,MAGI,gBAAAJ,EAACC,EAAc,SAAd,EAAsB,SAAAE,GAAkB,gBAAcJ,GAAY,KAAAK,GAC9D,UAAAR,GACL;AAGRM,EAAgB,cAAc;AAwBvB,MAAMG,IAAkB,CAC3B;AAAA,EACI,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,OAAAC,IAAQ;AAAA,EACR,UAAAd;AAAA,EACA,gBAAgBG,IAAa;AACjC,GACAK,MACC;AACK,QAAAO,IAAWC,EAAO,IAAI,GACtBC,IAAiBD,EAAO,EAAK,GAE7B,EAAE,cAAAE,EAAA,IAAiBC,EAA2BJ,CAAQ;AAGxD,SAAA,gBAAAX,EAACC,EAAc,QAAd,EACG,UAAA,gBAAAD;AAAA,IAACC,EAAc;AAAA,IAAd;AAAA,MACG,OAAAS;AAAA,MACA,kBAAkB;AAAA,MAClB,YAAY;AAAA,MACZ,MAAAF;AAAA,MACA,WAAWQ,EAAO;AAAA,MAClB,gBAAcP;AAAA,MACd,gBAAcV;AAAA,MACd,KAAKY;AAAA,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;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -541,6 +541,11 @@ declare type DropdownSlotProps = {
|
|
|
541
541
|
};
|
|
542
542
|
|
|
543
543
|
declare type DropdownSubContentProps = {
|
|
544
|
+
/**
|
|
545
|
+
* The vertical padding around each dropdown item.
|
|
546
|
+
* @default "comfortable"
|
|
547
|
+
*/
|
|
548
|
+
padding?: 'comfortable' | 'compact';
|
|
544
549
|
children: ReactNode;
|
|
545
550
|
'data-test-id'?: string;
|
|
546
551
|
};
|
|
@@ -632,11 +637,16 @@ declare type FlyoutBodyProps = {
|
|
|
632
637
|
};
|
|
633
638
|
|
|
634
639
|
declare type FlyoutContentProps = {
|
|
640
|
+
/**
|
|
641
|
+
* Add a shadow to the flyout
|
|
642
|
+
* @default "medium"
|
|
643
|
+
*/
|
|
644
|
+
shadow?: 'none' | 'medium' | 'large';
|
|
635
645
|
/**
|
|
636
646
|
* Add rounded corners to the flyout
|
|
637
|
-
* @default
|
|
647
|
+
* @default "medium"
|
|
638
648
|
*/
|
|
639
|
-
rounded?:
|
|
649
|
+
rounded?: 'none' | 'medium' | 'large';
|
|
640
650
|
/**
|
|
641
651
|
* Define the prefered side of the flyout. Can be overriden by viewport collisions viewport.
|
|
642
652
|
* @default "bottom"
|
|
@@ -652,6 +662,11 @@ declare type FlyoutContentProps = {
|
|
|
652
662
|
* @default "compact"
|
|
653
663
|
*/
|
|
654
664
|
padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';
|
|
665
|
+
/**
|
|
666
|
+
* Define the fixed width of the flyout
|
|
667
|
+
* @default "fit-content"
|
|
668
|
+
*/
|
|
669
|
+
width?: string;
|
|
655
670
|
/**
|
|
656
671
|
* Define the maximum width of the flyout
|
|
657
672
|
* @default "360px"
|