@frontify/fondue-components 15.0.1 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,130 +1,137 @@
1
- import { jsx as d, jsxs as m } from "react/jsx-runtime";
2
- import { IconCaretRight as I } from "@frontify/fondue-icons";
3
- import * as n from "@radix-ui/react-dropdown-menu";
4
- import { forwardRef as i } from "react";
5
- import { useFondueTheme as w, ThemeProvider as f } from "./fondue-components28.js";
6
- import { useProcessedChildren as g } from "./fondue-components47.js";
7
- import a from "./fondue-components48.js";
8
- const D = ({
9
- children: t,
10
- open: o,
11
- modal: e = !1,
12
- onOpenChange: r,
13
- "data-test-id": s = "fondue-dropdown"
14
- }) => /* @__PURE__ */ d(n.Root, { open: o, modal: e, onOpenChange: r, "data-test-id": s, children: t });
15
- D.displayName = "Dropdown.Root";
1
+ import { jsx as n, jsxs as w } from "react/jsx-runtime";
2
+ import { IconCaretRight as P } from "@frontify/fondue-icons";
3
+ import * as d from "@radix-ui/react-dropdown-menu";
4
+ import { forwardRef as i, useMemo as F, Children as G } from "react";
5
+ import { useFondueTheme as f, ThemeProvider as g } from "./fondue-components28.js";
6
+ import { useProcessedChildren as D } from "./fondue-components47.js";
7
+ import s from "./fondue-components48.js";
16
8
  const b = ({
17
- asChild: t = !0,
18
9
  children: o,
10
+ open: t,
11
+ modal: e = !1,
12
+ onOpenChange: r,
13
+ "data-test-id": a = "fondue-dropdown"
14
+ }) => /* @__PURE__ */ n(d.Root, { open: t, modal: e, onOpenChange: r, "data-test-id": a, children: o });
15
+ b.displayName = "Dropdown.Root";
16
+ const N = ({
17
+ asChild: o = !0,
18
+ children: t,
19
19
  "data-test-id": e = "fondue-dropdown-trigger",
20
20
  ...r
21
- }, s) => /* @__PURE__ */ d(n.Trigger, { asChild: t, "data-test-id": e, ref: s, ...r, children: o });
22
- b.displayName = "Dropdown.Trigger";
23
- const P = {
21
+ }, a) => /* @__PURE__ */ n(d.Trigger, { asChild: o, "data-test-id": e, ref: a, ...r, children: t });
22
+ N.displayName = "Dropdown.Trigger";
23
+ const M = {
24
24
  compact: 8,
25
25
  comfortable: 12,
26
26
  spacious: 16
27
+ }, A = {
28
+ compact: 8,
29
+ spacious: 24
27
30
  }, S = ({
28
- side: t = "bottom",
29
- align: o = "start",
31
+ side: o = "bottom",
32
+ align: t = "start",
30
33
  triggerOffset: e = "compact",
31
34
  children: r,
32
- preventTriggerFocusOnClose: s,
33
- "data-test-id": p = "fondue-dropdown-content"
34
- }, u) => {
35
- const c = w();
36
- return /* @__PURE__ */ d(n.Portal, { children: /* @__PURE__ */ d(f, { theme: c, children: /* @__PURE__ */ d(
37
- n.Content,
35
+ preventTriggerFocusOnClose: a,
36
+ viewportCollisionPadding: p = "compact",
37
+ "data-test-id": u = "fondue-dropdown-content"
38
+ }, c) => {
39
+ const l = f();
40
+ return /* @__PURE__ */ n(d.Portal, { children: /* @__PURE__ */ n(g, { theme: l, children: /* @__PURE__ */ n(
41
+ d.Content,
38
42
  {
39
- align: o,
40
- collisionPadding: 8,
41
- sideOffset: P[e],
42
- side: t,
43
- className: a.content,
44
- "data-test-id": p,
45
- ref: u,
46
- onCloseAutoFocus: (l) => {
47
- s && l.preventDefault();
43
+ align: t,
44
+ collisionPadding: A[p],
45
+ sideOffset: M[e],
46
+ side: o,
47
+ className: s.content,
48
+ "data-test-id": u,
49
+ ref: c,
50
+ onCloseAutoFocus: (m) => {
51
+ a && m.preventDefault();
48
52
  },
49
53
  children: r
50
54
  }
51
55
  ) }) });
52
56
  };
53
57
  S.displayName = "Dropdown.Content";
54
- const N = ({ children: t, heading: o, "data-test-id": e = "fondue-dropdown-group" }, r) => /* @__PURE__ */ m(n.Group, { className: a.group, "data-test-id": e, ref: r, children: [
55
- o ? /* @__PURE__ */ d("div", { className: a.groupHeading, children: /* @__PURE__ */ d("span", { "aria-label": o, children: o }) }) : null,
56
- t
57
- ] });
58
- N.displayName = "Dropdown.Group";
59
- const C = ({
60
- children: t,
61
- "data-test-id": o = "fondue-dropdown-submenu"
62
- }) => /* @__PURE__ */ d(n.Sub, { "data-test-id": o, children: t });
63
- C.displayName = "Dropdown.SubMenu";
64
- const h = ({ children: t, "data-test-id": o = "fondue-dropdown-subtrigger" }, e) => {
65
- const { content: r } = g(t);
66
- return /* @__PURE__ */ m(n.SubTrigger, { className: a.subTrigger, "data-test-id": o, ref: e, children: [
58
+ const C = ({ children: o, heading: t, "data-test-id": e = "fondue-dropdown-group" }, r) => F(
59
+ () => G.toArray(o).filter((p) => p !== null).length > 0,
60
+ [o]
61
+ ) ? /* @__PURE__ */ w(d.Group, { className: s.group, "data-test-id": e, ref: r, children: [
62
+ t ? /* @__PURE__ */ n("div", { className: s.groupHeading, children: /* @__PURE__ */ n("span", { "aria-label": t, children: t }) }) : null,
63
+ o
64
+ ] }) : null;
65
+ C.displayName = "Dropdown.Group";
66
+ const h = ({
67
+ children: o,
68
+ "data-test-id": t = "fondue-dropdown-submenu"
69
+ }) => /* @__PURE__ */ n(d.Sub, { "data-test-id": t, children: o });
70
+ h.displayName = "Dropdown.SubMenu";
71
+ const R = ({ children: o, "data-test-id": t = "fondue-dropdown-subtrigger" }, e) => {
72
+ const { content: r } = D(o);
73
+ return /* @__PURE__ */ w(d.SubTrigger, { className: s.subTrigger, "data-test-id": t, ref: e, children: [
67
74
  r,
68
- /* @__PURE__ */ d(I, { className: a.subMenuIndicator, size: 16 })
75
+ /* @__PURE__ */ n(P, { className: s.subMenuIndicator, size: 16 })
69
76
  ] });
70
77
  };
71
- h.displayName = "Dropdown.SubTrigger";
72
- const R = ({ children: t, "data-test-id": o = "fondue-dropdown-subcontent" }, e) => {
73
- const r = w();
74
- return /* @__PURE__ */ d(n.Portal, { children: /* @__PURE__ */ d(f, { theme: r, children: /* @__PURE__ */ d(n.SubContent, { className: a.subContent, "data-test-id": o, ref: e, children: t }) }) });
78
+ R.displayName = "Dropdown.SubTrigger";
79
+ const T = ({ children: o, "data-test-id": t = "fondue-dropdown-subcontent" }, e) => {
80
+ const r = f();
81
+ return /* @__PURE__ */ n(d.Portal, { children: /* @__PURE__ */ n(g, { theme: r, children: /* @__PURE__ */ n(d.SubContent, { className: s.subContent, "data-test-id": t, ref: e, children: o }) }) });
75
82
  };
76
- R.displayName = "Dropdown.SubContent";
77
- const T = ({
78
- children: t,
79
- disabled: o,
83
+ T.displayName = "Dropdown.SubContent";
84
+ const I = ({
85
+ children: o,
86
+ disabled: t,
80
87
  textValue: e,
81
88
  onSelect: r,
82
- emphasis: s = "default",
89
+ emphasis: a = "default",
83
90
  asChild: p = !1,
84
91
  "data-test-id": u = "fondue-dropdown-subtrigger",
85
92
  ...c
86
93
  }, l) => {
87
- const { content: F } = g(t);
88
- return /* @__PURE__ */ d(
89
- n.Item,
94
+ const { content: m } = D(o);
95
+ return /* @__PURE__ */ n(
96
+ d.Item,
90
97
  {
91
98
  onSelect: r,
92
- className: a.item,
99
+ className: s.item,
93
100
  textValue: e,
94
101
  "data-test-id": u,
95
- "data-emphasis": s,
102
+ "data-emphasis": a,
96
103
  ref: l,
97
- disabled: o,
104
+ disabled: t,
98
105
  asChild: p,
99
106
  ...c,
100
- children: F
107
+ children: m
101
108
  }
102
109
  );
103
110
  };
104
- T.displayName = "Dropdown.Item";
105
- const y = ({ children: t, name: o, "data-test-id": e = "fondue-dropdown-slot" }, r) => /* @__PURE__ */ d("div", { "data-name": o, className: a.slot, "data-test-id": e, ref: r, children: t });
111
+ I.displayName = "Dropdown.Item";
112
+ const y = ({ children: o, name: t, "data-test-id": e = "fondue-dropdown-slot" }, r) => /* @__PURE__ */ n("div", { "data-name": t, className: s.slot, "data-test-id": e, ref: r, children: o });
106
113
  y.displayName = "Dropdown.Slot";
107
- const G = i(b), M = i(S), v = i(N), x = i(h), A = i(R), j = i(T), z = i(y), E = {
108
- Root: D,
109
- Trigger: G,
110
- Content: M,
111
- Group: v,
112
- SubMenu: C,
113
- SubTrigger: x,
114
- SubContent: A,
115
- Item: j,
114
+ const v = i(N), x = i(S), O = i(C), _ = i(R), j = i(T), L = i(I), z = i(y), B = {
115
+ Root: b,
116
+ Trigger: v,
117
+ Content: x,
118
+ Group: O,
119
+ SubMenu: h,
120
+ SubTrigger: _,
121
+ SubContent: j,
122
+ Item: L,
116
123
  Slot: z
117
124
  };
118
125
  export {
119
- E as Dropdown,
126
+ B as Dropdown,
120
127
  S as DropdownContent,
121
- N as DropdownGroup,
122
- T as DropdownItem,
123
- D as DropdownRoot,
128
+ C as DropdownGroup,
129
+ I as DropdownItem,
130
+ b as DropdownRoot,
124
131
  y as DropdownSlot,
125
- R as DropdownSubContent,
126
- C as DropdownSubMenu,
127
- h as DropdownSubTrigger,
128
- b as DropdownTrigger
132
+ T as DropdownSubContent,
133
+ h as DropdownSubMenu,
134
+ R as DropdownSubTrigger,
135
+ N as DropdownTrigger
129
136
  };
130
137
  //# sourceMappingURL=fondue-components10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components10.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 { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { useProcessedChildren } from './hooks/useProcessedChildren';\nimport styles from './styles/dropdown.module.scss';\n\nexport type DropdownRootProps = {\n children?: ReactNode;\n /**\n * When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.\n * @default false\n */\n modal?: boolean;\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 modal = false,\n onOpenChange,\n 'data-test-id': dataTestId = 'fondue-dropdown',\n}: DropdownRootProps) => {\n return (\n <RadixDropdown.Root open={open} modal={modal} 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\ntype DropdownSpacing = 'compact' | 'comfortable' | 'spacious';\n\nexport type DropdownContentProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\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 * Defines the spacing between the dropdown and its trigger.\n * @default 'compact'\n */\n triggerOffset?: DropdownSpacing;\n /**\n * Prevents the focus from being set on the trigger when the dropdown is closed.\n */\n preventTriggerFocusOnClose?: boolean;\n};\n\nconst SPACING_MAP: Record<DropdownSpacing, number> = {\n compact: 8,\n comfortable: 12,\n spacious: 16,\n};\n\nexport const DropdownContent = (\n {\n side = 'bottom',\n align = 'start',\n triggerOffset = 'compact',\n children,\n preventTriggerFocusOnClose,\n 'data-test-id': dataTestId = 'fondue-dropdown-content',\n }: DropdownContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n\n return (\n <RadixDropdown.Portal>\n <ThemeProvider theme={theme}>\n <RadixDropdown.Content\n align={align}\n collisionPadding={8}\n sideOffset={SPACING_MAP[triggerOffset]}\n side={side}\n className={styles.content}\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 </ThemeProvider>\n </RadixDropdown.Portal>\n );\n};\nDropdownContent.displayName = 'Dropdown.Content';\n\nexport type DropdownGroupProps = { children: ReactNode; heading?: string; 'data-test-id'?: string };\n\nexport const DropdownGroup = (\n { children, heading, '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 {heading ? (\n <div className={styles.groupHeading}>\n <span aria-label={heading}>{heading}</span>\n </div>\n ) : null}\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 children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const DropdownSubContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subcontent' }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n return (\n <RadixDropdown.Portal>\n <ThemeProvider theme={theme}>\n <RadixDropdown.SubContent className={styles.subContent} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.SubContent>\n </ThemeProvider>\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 /**\n * If true, the item props will be passed to the child element.\n * @default false\n */\n asChild?: boolean;\n 'data-test-id'?: string;\n};\n\nexport const DropdownItem = (\n {\n children,\n disabled,\n textValue,\n onSelect,\n emphasis = 'default',\n asChild = false,\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { content } = useProcessedChildren(children);\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={asChild}\n {...props}\n >\n {content}\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","modal","onOpenChange","dataTestId","jsx","RadixDropdown","DropdownTrigger","asChild","props","ref","SPACING_MAP","DropdownContent","side","align","triggerOffset","preventTriggerFocusOnClose","theme","useFondueTheme","ThemeProvider","styles","event","DropdownGroup","heading","jsxs","DropdownSubMenu","DropdownSubTrigger","content","useProcessedChildren","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","emphasis","DropdownSlot","name","ForwardedRefDropdownTrigger","forwardRef","ForwardedRefDropdownContent","ForwardedRefDropdownGroup","ForwardedRefDropdownSubTrigger","ForwardedRefDropdownSubContent","ForwardedRefDropdownItem","ForwardedRefDropdownSlot","Dropdown"],"mappings":";;;;;;;AA8BO,MAAMA,IAAe,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC,IA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EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAA3B,IAAU;AAAA,EACV,gBAAgBJ,IAAa;AAAA,EAC7B,GAAGK;AACP,GACAC,MACC;AACD,QAAM,EAAE,SAAAiB,EAAA,IAAYC,EAAqB5B,CAAQ;AAG7C,SAAA,gBAAAK;AAAA,IAACC,EAAc;AAAA,IAAd;AAAA,MACG,UAAA4B;AAAA,MACA,WAAWd,EAAO;AAAA,MAClB,WAAAa;AAAA,MACA,gBAAc7B;AAAA,MACd,iBAAe+B;AAAA,MACf,KAAAzB;AAAA,MACA,UAAAsB;AAAA,MACA,SAAAxB;AAAA,MACC,GAAGC;AAAA,MAEH,UAAAkB;AAAA,IAAA;AAAA,EACL;AAER;AACAI,EAAa,cAAc;AAId,MAAAK,IAAe,CACxB,EAAE,UAAApC,GAAU,MAAAqC,GAAM,gBAAgBjC,IAAa,uBAAuB,GACtEM,MAGI,gBAAAL,EAAC,OAAI,EAAA,aAAWgC,GAAM,WAAWjB,EAAO,MAAM,gBAAchB,GAAY,KAAAM,GACnE,UAAAV,EACL,CAAA;AAGRoC,EAAa,cAAc;AAE3B,MAAME,IAA8BC,EAAoDhC,CAAe,GACjGiC,IAA8BD,EAAiD3B,CAAe,GAC9F6B,IAA4BF,EAA+CjB,CAAa,GACxFoB,IAAiCH,EAAoDb,CAAkB,GACvGiB,IAAiCJ,EAAoDT,CAAkB,GACvGc,IAA2BL,EAA8CR,CAAY,GACrFc,IAA2BN,EAA8CH,CAAY,GAE9EU,IAAW;AAAA,EACpB,MAAM/C;AAAA,EACN,SAASuC;AAAA,EACT,SAASE;AAAA,EACT,OAAOC;AAAA,EACP,SAAShB;AAAA,EACT,YAAYiB;AAAA,EACZ,YAAYC;AAAA,EACZ,MAAMC;AAAA,EACN,MAAMC;AACV;"}
1
+ {"version":3,"file":"fondue-components10.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 { Children, forwardRef, useMemo, type ForwardedRef, type ReactNode } from 'react';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { useProcessedChildren } from './hooks/useProcessedChildren';\nimport styles from './styles/dropdown.module.scss';\n\nexport type DropdownRootProps = {\n children?: ReactNode;\n /**\n * When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.\n * @default false\n */\n modal?: boolean;\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 modal = false,\n onOpenChange,\n 'data-test-id': dataTestId = 'fondue-dropdown',\n}: DropdownRootProps) => {\n return (\n <RadixDropdown.Root open={open} modal={modal} 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\ntype DropdownSpacing = 'compact' | 'comfortable' | 'spacious';\ntype DropdownViewportCollisionPadding = 'compact' | 'spacious';\nexport type DropdownContentProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\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 * Defines the spacing between the dropdown and its trigger.\n * @default 'compact'\n */\n triggerOffset?: DropdownSpacing;\n /**\n * Prevents the focus from being set on the trigger when the dropdown is closed.\n */\n preventTriggerFocusOnClose?: boolean;\n /**\n * Define the minimum distance between the dropdown and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: DropdownViewportCollisionPadding;\n};\n\nconst SPACING_MAP: Record<DropdownSpacing, number> = {\n compact: 8,\n comfortable: 12,\n spacious: 16,\n};\n\nconst VIEWPORT_COLLISION_PADDING_MAP: Record<DropdownViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n};\n\nexport const DropdownContent = (\n {\n side = 'bottom',\n align = 'start',\n triggerOffset = 'compact',\n children,\n preventTriggerFocusOnClose,\n viewportCollisionPadding = 'compact',\n 'data-test-id': dataTestId = 'fondue-dropdown-content',\n }: DropdownContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n\n return (\n <RadixDropdown.Portal>\n <ThemeProvider theme={theme}>\n <RadixDropdown.Content\n align={align}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding]}\n sideOffset={SPACING_MAP[triggerOffset]}\n side={side}\n className={styles.content}\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 </ThemeProvider>\n </RadixDropdown.Portal>\n );\n};\nDropdownContent.displayName = 'Dropdown.Content';\n\nexport type DropdownGroupProps = { children: ReactNode; heading?: string; 'data-test-id'?: string };\n\nexport const DropdownGroup = (\n { children, heading, 'data-test-id': dataTestId = 'fondue-dropdown-group' }: DropdownGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const hasChildren = useMemo(\n () => Children.toArray(children).filter((child) => child !== null).length > 0,\n [children],\n );\n\n if (!hasChildren) {\n return null;\n }\n\n return (\n <RadixDropdown.Group className={styles.group} data-test-id={dataTestId} ref={ref}>\n {heading ? (\n <div className={styles.groupHeading}>\n <span aria-label={heading}>{heading}</span>\n </div>\n ) : null}\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 children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const DropdownSubContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dropdown-subcontent' }: DropdownSubContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n return (\n <RadixDropdown.Portal>\n <ThemeProvider theme={theme}>\n <RadixDropdown.SubContent className={styles.subContent} data-test-id={dataTestId} ref={ref}>\n {children}\n </RadixDropdown.SubContent>\n </ThemeProvider>\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 /**\n * If true, the item props will be passed to the child element.\n * @default false\n */\n asChild?: boolean;\n 'data-test-id'?: string;\n};\n\nexport const DropdownItem = (\n {\n children,\n disabled,\n textValue,\n onSelect,\n emphasis = 'default',\n asChild = false,\n 'data-test-id': dataTestId = 'fondue-dropdown-subtrigger',\n ...props\n }: DropdownItemProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { content } = useProcessedChildren(children);\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={asChild}\n {...props}\n >\n {content}\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","modal","onOpenChange","dataTestId","jsx","RadixDropdown","DropdownTrigger","asChild","props","ref","SPACING_MAP","VIEWPORT_COLLISION_PADDING_MAP","DropdownContent","side","align","triggerOffset","preventTriggerFocusOnClose","viewportCollisionPadding","theme","useFondueTheme","ThemeProvider","styles","event","DropdownGroup","heading","useMemo","Children","child","jsxs","DropdownSubMenu","DropdownSubTrigger","content","useProcessedChildren","IconCaretRight","DropdownSubContent","DropdownItem","disabled","textValue","onSelect","emphasis","DropdownSlot","name","ForwardedRefDropdownTrigger","forwardRef","ForwardedRefDropdownContent","ForwardedRefDropdownGroup","ForwardedRefDropdownSubTrigger","ForwardedRefDropdownSubContent","ForwardedRefDropdownItem","ForwardedRefDropdownSlot","Dropdown"],"mappings":";;;;;;;AA8BO,MAAMA,IAAe,CAAC;AAAA,EACzB,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,cAAAC;AAAA,EACA,gBAAgBC,IAAa;AACjC,MAEQ,gBAAAC,EAACC,EAAc,MAAd,EAAmB,MAAAL,GAAY,OAAAC,GAAc,cAAAC,GAA4B,gBAAcC,GACnF,UAAAJ,GACL;AAGRD,EAAa,cAAc;AAYpB,MAAMQ,IAAkB,CAC3B;AAAA,EACI,SAAAC,IAAU;A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/fondue-icons";
2
+ import { IconCross as b } from "@frontify/fondue-icons";
3
3
  import * as i from "@radix-ui/react-popover";
4
- import { forwardRef as s } from "react";
4
+ import { forwardRef as r } from "react";
5
5
  import { addAutoFocusAttribute as w, addShowFocusRing as x } from "./fondue-components44.js";
6
- import { useFondueTheme as P, ThemeProvider as T } from "./fondue-components28.js";
7
- import r from "./fondue-components50.js";
8
- const n = ({ children: t, ...o }) => /* @__PURE__ */ a(i.Root, { ...o, children: t });
9
- n.displayName = "Flyout.Root";
10
- const c = ({ asChild: t = !0, children: o, "data-test-id": e = "fondue-flyout-trigger", ...d }, l) => /* @__PURE__ */ a(
6
+ import { useFondueTheme as A, ThemeProvider as T } from "./fondue-components28.js";
7
+ import s from "./fondue-components50.js";
8
+ const c = ({ children: t, ...o }) => /* @__PURE__ */ a(i.Root, { ...o, children: t });
9
+ c.displayName = "Flyout.Root";
10
+ const n = ({ asChild: t = !0, children: o, "data-test-id": e = "fondue-flyout-trigger", ...d }, l) => /* @__PURE__ */ a(
11
11
  i.Trigger,
12
12
  {
13
13
  onMouseDown: w,
@@ -20,11 +20,14 @@ const c = ({ asChild: t = !0, children: o, "data-test-id": e = "fondue-flyout-tr
20
20
  children: o
21
21
  }
22
22
  );
23
- c.displayName = "Flyout.Trigger";
24
- const A = {
23
+ n.displayName = "Flyout.Trigger";
24
+ const I = {
25
25
  compact: 8,
26
26
  comfortable: 12,
27
27
  spacious: 16
28
+ }, O = {
29
+ compact: 8,
30
+ spacious: 24
28
31
  }, m = ({
29
32
  align: t = "start",
30
33
  maxWidth: o = "360px",
@@ -33,13 +36,14 @@ const A = {
33
36
  width: l = "fit-content",
34
37
  shadow: F = "medium",
35
38
  triggerOffset: g = "compact",
39
+ viewportCollisionPadding: N = "compact",
36
40
  "data-test-id": h = "fondue-flyout-content",
37
- children: N,
38
- ...v
39
- }, b) => {
40
- const C = P();
41
- return /* @__PURE__ */ a(i.Portal, { children: /* @__PURE__ */ u(T, { theme: C, children: [
42
- /* @__PURE__ */ a("div", { className: r.overlay }),
41
+ children: v,
42
+ ...P
43
+ }, C) => {
44
+ const R = A();
45
+ return /* @__PURE__ */ a(i.Portal, { children: /* @__PURE__ */ u(T, { theme: R, children: [
46
+ /* @__PURE__ */ a("div", { className: s.overlay }),
43
47
  /* @__PURE__ */ a(
44
48
  i.Content,
45
49
  {
@@ -47,29 +51,29 @@ const A = {
47
51
  "--flyout-max-width": o,
48
52
  "--flyout-width": l
49
53
  },
50
- ref: b,
54
+ ref: C,
51
55
  align: t,
52
- collisionPadding: 8,
53
- sideOffset: A[g],
54
- className: r.root,
56
+ collisionPadding: O[N],
57
+ sideOffset: I[g],
58
+ className: s.root,
55
59
  "data-flyout-spacing": e,
56
60
  "data-rounded": d,
57
61
  "data-shadow": F,
58
62
  "data-test-id": h,
59
63
  onFocus: x,
60
- ...v,
61
- children: N
64
+ ...P,
65
+ children: v
62
66
  }
63
67
  )
64
68
  ] }) });
65
69
  };
66
70
  m.displayName = "Flyout.Content";
67
- const y = ({ showCloseButton: t, children: o, "data-test-id": e = "fondue-flyout-header" }, d) => /* @__PURE__ */ u("div", { "data-test-id": e, ref: d, className: r.header, children: [
71
+ const y = ({ showCloseButton: t, children: o, "data-test-id": e = "fondue-flyout-header" }, d) => /* @__PURE__ */ u("div", { "data-test-id": e, ref: d, className: s.header, children: [
68
72
  /* @__PURE__ */ a("div", { children: o }),
69
- t && /* @__PURE__ */ a(i.Close, { role: "button", "data-test-id": `${e}-close`, className: r.close, children: /* @__PURE__ */ a(R, { size: 20 }) })
73
+ t && /* @__PURE__ */ a(i.Close, { role: "button", "data-test-id": `${e}-close`, className: s.close, children: /* @__PURE__ */ a(b, { size: 20 }) })
70
74
  ] });
71
75
  y.displayName = "Flyout.Header";
72
- const f = ({ children: t, "data-test-id": o = "fondue-flyout-footer" }, e) => /* @__PURE__ */ a("div", { "data-test-id": o, ref: e, className: r.footer, children: t });
76
+ const f = ({ children: t, "data-test-id": o = "fondue-flyout-footer" }, e) => /* @__PURE__ */ a("div", { "data-test-id": o, ref: e, className: s.footer, children: t });
73
77
  f.displayName = "Flyout.Footer";
74
78
  const p = ({ children: t, "data-test-id": o = "fondue-flyout-body", scrollable: e = !1 }, d) => /* @__PURE__ */ a(
75
79
  "div",
@@ -78,26 +82,26 @@ const p = ({ children: t, "data-test-id": o = "fondue-flyout-body", scrollable:
78
82
  ref: d,
79
83
  "data-flyout-spacing": "compact",
80
84
  "data-scrollable": e,
81
- className: r.body,
85
+ className: s.body,
82
86
  children: t
83
87
  }
84
88
  );
85
89
  p.displayName = "Flyout.Body";
86
- const D = {
87
- Root: n,
88
- Trigger: s(c),
89
- Content: s(m),
90
- Header: s(y),
91
- Footer: s(f),
92
- Body: s(p)
90
+ const j = {
91
+ Root: c,
92
+ Trigger: r(n),
93
+ Content: r(m),
94
+ Header: r(y),
95
+ Footer: r(f),
96
+ Body: r(p)
93
97
  };
94
98
  export {
95
- D as Flyout,
99
+ j as Flyout,
96
100
  p as FlyoutBody,
97
101
  m as FlyoutContent,
98
102
  f as FlyoutFooter,
99
103
  y as FlyoutHeader,
100
- n as FlyoutRoot,
101
- c as FlyoutTrigger
104
+ c as FlyoutRoot,
105
+ n as FlyoutTrigger
102
106
  };
103
107
  //# sourceMappingURL=fondue-components12.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components12.js","sources":["../src/components/Flyout/Flyout.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { forwardRef, type CSSProperties, type ForwardedRef, type ReactNode } from 'react';\n\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport styles from './styles/flyout.module.scss';\n\nexport type FlyoutRootProps = {\n /**\n * Disable interaction with the rest of the page\n * @default false\n */\n modal?: boolean;\n /**\n * The controlled `open` state of the flyout\n * @default false\n */\n open?: boolean;\n /**\n * Event handler called when the `open` state changes\n */\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n};\n\nexport const FlyoutRoot = ({ children, ...props }: FlyoutRootProps) => {\n return <RadixPopover.Root {...props}>{children}</RadixPopover.Root>;\n};\nFlyoutRoot.displayName = 'Flyout.Root';\n\nexport type FlyoutTriggerProps = {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default true\n */\n asChild?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const FlyoutTrigger = (\n { asChild = true, children, 'data-test-id': dataTestId = 'fondue-flyout-trigger', ...props }: FlyoutTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixPopover.Trigger\n onMouseDown={addAutoFocusAttribute}\n data-auto-focus-visible=\"true\"\n data-auto-focus-trigger\n data-test-id={dataTestId}\n asChild={asChild}\n ref={ref}\n {...props}\n >\n {children}\n </RadixPopover.Trigger>\n );\n};\nFlyoutTrigger.displayName = 'Flyout.Trigger';\n\ntype FlyoutSpacing = 'compact' | 'comfortable' | 'spacious';\nexport type FlyoutContentProps = {\n /**\n * Add a shadow to the flyout\n * @default \"medium\"\n */\n shadow?: 'none' | 'medium' | 'large';\n /**\n * Add rounded corners to the flyout\n * @default \"medium\"\n */\n rounded?: 'none' | 'medium' | 'large';\n /**\n * Define the prefered side of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"bottom\"\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n /**\n * Define the prefered alignment of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"start\"\n */\n align?: 'start' | 'center' | 'end';\n /**\n * Define the padding of the flyout\n * @default \"compact\"\n */\n padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';\n /**\n * Define the fixed width of the flyout\n * @default \"fit-content\"\n */\n width?: string;\n /**\n * Defines the spacing between the dropdown and its trigger.\n * @default 'compact'\n */\n triggerOffset?: FlyoutSpacing;\n /**\n * Define the maximum width of the flyout\n * @default \"360px\"\n */\n maxWidth?: string;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nconst SPACING_MAP: Record<FlyoutSpacing, number> = {\n compact: 8,\n comfortable: 12,\n spacious: 16,\n};\n\nexport const FlyoutContent = (\n {\n align = 'start',\n maxWidth = '360px',\n padding = 'compact',\n rounded = 'medium',\n width = 'fit-content',\n shadow = 'medium',\n triggerOffset = 'compact',\n 'data-test-id': dataTestId = 'fondue-flyout-content',\n children,\n ...props\n }: FlyoutContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <div className={styles.overlay} />\n <RadixPopover.Content\n style={\n {\n '--flyout-max-width': maxWidth,\n '--flyout-width': width,\n } as CSSProperties\n }\n ref={ref}\n align={align}\n collisionPadding={8}\n sideOffset={SPACING_MAP[triggerOffset]}\n className={styles.root}\n data-flyout-spacing={padding}\n data-rounded={rounded}\n data-shadow={shadow}\n data-test-id={dataTestId}\n onFocus={addShowFocusRing}\n {...props}\n >\n {children}\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nFlyoutContent.displayName = 'Flyout.Content';\n\nexport type FlyoutHeaderProps = {\n /**\n * Show a close button in the header\n * @default false\n */\n showCloseButton?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const FlyoutHeader = (\n { showCloseButton, children, 'data-test-id': dataTestId = 'fondue-flyout-header' }: FlyoutHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.header}>\n <div>{children}</div>\n {showCloseButton && (\n <RadixPopover.Close role=\"button\" data-test-id={`${dataTestId}-close`} className={styles.close}>\n <IconCross size={20} />\n </RadixPopover.Close>\n )}\n </div>\n );\n};\nFlyoutHeader.displayName = 'Flyout.Header';\n\nexport type FlyoutFooterProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const FlyoutFooter = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-footer' }: FlyoutFooterProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.footer}>\n {children}\n </div>\n );\n};\nFlyoutFooter.displayName = 'Flyout.Footer';\n\nexport type FlyoutBodyProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\n /**\n * Allow the body to scroll if the max height of the flyout is reached\n * @default false\n */\n scrollable?: boolean;\n};\n\nexport const FlyoutBody = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-body', scrollable = false }: FlyoutBodyProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-test-id={dataTestId}\n ref={ref}\n data-flyout-spacing=\"compact\"\n data-scrollable={scrollable}\n className={styles.body}\n >\n {children}\n </div>\n );\n};\nFlyoutBody.displayName = 'Flyout.Body';\n\nexport const Flyout = {\n Root: FlyoutRoot,\n Trigger: forwardRef<HTMLButtonElement, FlyoutTriggerProps>(FlyoutTrigger),\n Content: forwardRef<HTMLDivElement, FlyoutContentProps>(FlyoutContent),\n Header: forwardRef<HTMLDivElement, FlyoutHeaderProps>(FlyoutHeader),\n Footer: forwardRef<HTMLDivElement, FlyoutFooterProps>(FlyoutFooter),\n Body: forwardRef<HTMLDivElement, FlyoutBodyProps>(FlyoutBody),\n};\n"],"names":["FlyoutRoot","children","props","RadixPopover","FlyoutTrigger","asChild","dataTestId","ref","jsx","addAutoFocusAttribute","SPACING_MAP","FlyoutContent","align","maxWidth","padding","rounded","width","shadow","triggerOffset","theme","useFondueTheme","jsxs","ThemeProvider","styles","addShowFocusRing","FlyoutHeader","showCloseButton","IconCross","FlyoutFooter","FlyoutBody","scrollable","Flyout","forwardRef"],"mappings":";;;;;;;AA8BO,MAAMA,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAC9BC,EAAa,MAAb,EAAmB,GAAGD,GAAQ,UAAAD,GAAS;AAEn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","sources":["../src/components/Flyout/Flyout.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { forwardRef, type CSSProperties, type ForwardedRef, type ReactNode } from 'react';\n\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport styles from './styles/flyout.module.scss';\n\nexport type FlyoutRootProps = {\n /**\n * Disable interaction with the rest of the page\n * @default false\n */\n modal?: boolean;\n /**\n * The controlled `open` state of the flyout\n * @default false\n */\n open?: boolean;\n /**\n * Event handler called when the `open` state changes\n */\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n};\n\nexport const FlyoutRoot = ({ children, ...props }: FlyoutRootProps) => {\n return <RadixPopover.Root {...props}>{children}</RadixPopover.Root>;\n};\nFlyoutRoot.displayName = 'Flyout.Root';\n\nexport type FlyoutTriggerProps = {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default true\n */\n asChild?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const FlyoutTrigger = (\n { asChild = true, children, 'data-test-id': dataTestId = 'fondue-flyout-trigger', ...props }: FlyoutTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixPopover.Trigger\n onMouseDown={addAutoFocusAttribute}\n data-auto-focus-visible=\"true\"\n data-auto-focus-trigger\n data-test-id={dataTestId}\n asChild={asChild}\n ref={ref}\n {...props}\n >\n {children}\n </RadixPopover.Trigger>\n );\n};\nFlyoutTrigger.displayName = 'Flyout.Trigger';\n\ntype FlyoutSpacing = 'compact' | 'comfortable' | 'spacious';\ntype FlyoutViewportCollisionPadding = 'compact' | 'spacious';\nexport type FlyoutContentProps = {\n /**\n * Add a shadow to the flyout\n * @default \"medium\"\n */\n shadow?: 'none' | 'medium' | 'large';\n /**\n * Add rounded corners to the flyout\n * @default \"medium\"\n */\n rounded?: 'none' | 'medium' | 'large';\n /**\n * Define the prefered side of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"bottom\"\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n /**\n * Define the prefered alignment of the flyout. Can be overriden by viewport collisions viewport.\n * @default \"start\"\n */\n align?: 'start' | 'center' | 'end';\n /**\n * Define the padding of the flyout\n * @default \"compact\"\n */\n padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';\n /**\n * Define the fixed width of the flyout\n * @default \"fit-content\"\n */\n width?: string;\n /**\n * Defines the spacing between the dropdown and its trigger.\n * @default 'compact'\n */\n triggerOffset?: FlyoutSpacing;\n /**\n * Define the maximum width of the flyout\n * @default \"360px\"\n */\n maxWidth?: string;\n /**\n * Define the minimum distance between the flyout and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: FlyoutViewportCollisionPadding;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nconst SPACING_MAP: Record<FlyoutSpacing, number> = {\n compact: 8,\n comfortable: 12,\n spacious: 16,\n};\n\nconst VIEWPORT_COLLISION_PADDING_MAP: Record<FlyoutViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n};\n\nexport const FlyoutContent = (\n {\n align = 'start',\n maxWidth = '360px',\n padding = 'compact',\n rounded = 'medium',\n width = 'fit-content',\n shadow = 'medium',\n triggerOffset = 'compact',\n viewportCollisionPadding = 'compact',\n 'data-test-id': dataTestId = 'fondue-flyout-content',\n children,\n ...props\n }: FlyoutContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <div className={styles.overlay} />\n <RadixPopover.Content\n style={\n {\n '--flyout-max-width': maxWidth,\n '--flyout-width': width,\n } as CSSProperties\n }\n ref={ref}\n align={align}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding]}\n sideOffset={SPACING_MAP[triggerOffset]}\n className={styles.root}\n data-flyout-spacing={padding}\n data-rounded={rounded}\n data-shadow={shadow}\n data-test-id={dataTestId}\n onFocus={addShowFocusRing}\n {...props}\n >\n {children}\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nFlyoutContent.displayName = 'Flyout.Content';\n\nexport type FlyoutHeaderProps = {\n /**\n * Show a close button in the header\n * @default false\n */\n showCloseButton?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const FlyoutHeader = (\n { showCloseButton, children, 'data-test-id': dataTestId = 'fondue-flyout-header' }: FlyoutHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.header}>\n <div>{children}</div>\n {showCloseButton && (\n <RadixPopover.Close role=\"button\" data-test-id={`${dataTestId}-close`} className={styles.close}>\n <IconCross size={20} />\n </RadixPopover.Close>\n )}\n </div>\n );\n};\nFlyoutHeader.displayName = 'Flyout.Header';\n\nexport type FlyoutFooterProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport const FlyoutFooter = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-footer' }: FlyoutFooterProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.footer}>\n {children}\n </div>\n );\n};\nFlyoutFooter.displayName = 'Flyout.Footer';\n\nexport type FlyoutBodyProps = {\n children?: ReactNode;\n 'data-test-id'?: string;\n /**\n * Allow the body to scroll if the max height of the flyout is reached\n * @default false\n */\n scrollable?: boolean;\n};\n\nexport const FlyoutBody = (\n { children, 'data-test-id': dataTestId = 'fondue-flyout-body', scrollable = false }: FlyoutBodyProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div\n data-test-id={dataTestId}\n ref={ref}\n data-flyout-spacing=\"compact\"\n data-scrollable={scrollable}\n className={styles.body}\n >\n {children}\n </div>\n );\n};\nFlyoutBody.displayName = 'Flyout.Body';\n\nexport const Flyout = {\n Root: FlyoutRoot,\n Trigger: forwardRef<HTMLButtonElement, FlyoutTriggerProps>(FlyoutTrigger),\n Content: forwardRef<HTMLDivElement, FlyoutContentProps>(FlyoutContent),\n Header: forwardRef<HTMLDivElement, FlyoutHeaderProps>(FlyoutHeader),\n Footer: forwardRef<HTMLDivElement, FlyoutFooterProps>(FlyoutFooter),\n Body: forwardRef<HTMLDivElement, FlyoutBodyProps>(FlyoutBody),\n};\n"],"names":["FlyoutRoot","children","props","RadixPopover","FlyoutTrigger","asChild","dataTestId","ref","jsx","addAutoFocusAttribute","SPACING_MAP","VIEWPORT_COLLISION_PADDING_MAP","FlyoutContent","align","maxWidth","padding","rounded","width","shadow","triggerOffset","viewportCollisionPadding","theme","useFondueTheme","jsxs","ThemeProvider","styles","addShowFocusRing","FlyoutHeader","showCloseButton","IconCross","FlyoutFooter","FlyoutBody","scrollable","Flyout","forwardRef"],"mappings":";;;;;;;AA8BO,MAAMA,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAC9BC,EAAa,MAAb,EAAmB,GAAGD,GAAQ,UAAAD,GAAS;AAEnDD,EAAW,cAAc;AAYlB,MAAMI,IAAgB,CACzB,EAAE,SAAAC,IAAU,IAAM,UAAAJ,GAAU,gBAAgBK,IAAa,yBAAyB,GAAGJ,EAAM,GAC3FK,MAGI,gBAAAC;AAAA,EAACL,EAAa;AAAA,EAAb;AAAA,IACG,aAAaM;AAAA,IACb,2BAAwB;AAAA,IACxB,2BAAuB;AAAA,IACvB,gBAAcH;AAAA,IACd,SAAAD;AAAA,IACA,KAAAE;AAAA,IACC,GAAGL;AAAA,IAEH,UAAAD;AAAA,EAAA;AACL;AAGRG,EAAc,cAAc;AAsD5B,MAAMM,IAA6C;AAAA,EAC/C,SAAS;AAAA,EACT,aAAa;AAAA,EACb,UAAU;AACd,GAEMC,IAAiF;AAAA,EACnF,SAAS;AAAA,EACT,UAAU;AACd,GAEaC,IAAgB,CAC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WAAWmB,EAAO,OACrF,4BAACI,GAAU,EAAA,MAAM,IAAI,EACzB,CAAA;AAAA,GAER;AAGRF,EAAa,cAAc;AAId,MAAAG,IAAe,CACxB,EAAE,UAAA7B,GAAU,gBAAgBK,IAAa,0BACzCC,MAGI,gBAAAC,EAAC,SAAI,gBAAcF,GAAY,KAAAC,GAAU,WAAWkB,EAAO,QACtD,UAAAxB,GACL;AAGR6B,EAAa,cAAc;AAYd,MAAAC,IAAa,CACtB,EAAE,UAAA9B,GAAU,gBAAgBK,IAAa,sBAAsB,YAAA0B,IAAa,GAAM,GAClFzB,MAGI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,gBAAcF;AAAA,IACd,KAAAC;AAAA,IACA,uBAAoB;AAAA,IACpB,mBAAiByB;AAAA,IACjB,WAAWP,EAAO;AAAA,IAEjB,UAAAxB;AAAA,EAAA;AACL;AAGR8B,EAAW,cAAc;AAElB,MAAME,IAAS;AAAA,EAClB,MAAMjC;AAAA,EACN,SAASkC,EAAkD9B,CAAa;AAAA,EACxE,SAAS8B,EAA+CtB,CAAa;AAAA,EACrE,QAAQsB,EAA8CP,CAAY;AAAA,EAClE,QAAQO,EAA8CJ,CAAY;AAAA,EAClE,MAAMI,EAA4CH,CAAU;AAChE;"}
@@ -1,15 +1,15 @@
1
1
  import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
- import { IconCaretDown as H, IconCheckMark as T, IconExclamationMarkTriangle as $ } from "@frontify/fondue-icons";
2
+ import { IconCaretDown as T, IconCheckMark as $, IconExclamationMarkTriangle as A } from "@frontify/fondue-icons";
3
3
  import * as g from "@radix-ui/react-popover";
4
- import { Slot as A } from "@radix-ui/react-slot";
5
- import { useSelect as q } from "downshift";
6
- import { forwardRef as J, useRef as K, useState as L } from "react";
7
- import { ForwardedRefCombobox as Q } from "./fondue-components59.js";
8
- import { ForwardedRefSelectItem as U, ForwardedRefSelectItemGroup as W } from "./fondue-components60.js";
9
- import { SelectMenu as X } from "./fondue-components61.js";
10
- import { ForwardedRefSelectSlot as Y } from "./fondue-components62.js";
4
+ import { Slot as q } from "@radix-ui/react-slot";
5
+ import { useSelect as J } from "downshift";
6
+ import { forwardRef as K, useRef as L, useState as Q } from "react";
7
+ import { ForwardedRefCombobox as U } from "./fondue-components59.js";
8
+ import { ForwardedRefSelectItem as W, ForwardedRefSelectItemGroup as X } from "./fondue-components60.js";
9
+ import { SelectMenu as Y } from "./fondue-components61.js";
10
+ import { ForwardedRefSelectSlot as Z } from "./fondue-components62.js";
11
11
  import o from "./fondue-components63.js";
12
- import { useSelectData as Z } from "./fondue-components64.js";
12
+ import { useSelectData as _ } from "./fondue-components64.js";
13
13
  const S = ({
14
14
  children: h,
15
15
  onSelect: s,
@@ -22,39 +22,40 @@ const S = ({
22
22
  side: y = "bottom",
23
23
  id: C,
24
24
  showStringValue: R = !0,
25
- "data-test-id": i = "fondue-select",
25
+ "data-test-id": c = "fondue-select",
26
+ viewportCollisionPadding: x = "compact",
26
27
  ...l
27
- }, x) => {
28
- const { inputSlots: F, menuSlots: k, items: v, clearButton: u, getItemByValue: f } = Z(h), B = f(I), M = f(b), c = K(!1), [P, p] = L(!1), { getToggleButtonProps: G, getMenuProps: O, getItemProps: z, reset: D, selectedItem: r, isOpen: V, highlightedIndex: j } = q({
29
- items: v,
30
- defaultSelectedItem: B,
31
- selectedItem: M,
28
+ }, F) => {
29
+ const { inputSlots: k, menuSlots: v, items: B, clearButton: u, getItemByValue: p } = _(h), M = p(I), P = p(b), i = L(!1), [G, f] = Q(!1), { getToggleButtonProps: O, getMenuProps: z, getItemProps: D, reset: V, selectedItem: r, isOpen: j, highlightedIndex: E } = J({
30
+ items: B,
31
+ defaultSelectedItem: M,
32
+ selectedItem: P,
32
33
  toggleButtonId: C,
33
34
  labelId: "aria-labelledby" in l ? l["aria-labelledby"] : void 0,
34
35
  onIsOpenChange: () => {
35
- p(!1);
36
+ f(!1);
36
37
  },
37
38
  onHighlightedIndexChange: () => {
38
- p(!0);
39
+ f(!0);
39
40
  },
40
41
  onSelectedItemChange: ({ selectedItem: e }) => {
41
42
  s == null || s((e == null ? void 0 : e.value) ?? null);
42
43
  },
43
44
  itemToString: (e) => e ? e.label : ""
44
- }), E = r ? !R && r.children || r.label : N;
45
- return /* @__PURE__ */ d(g.Root, { open: V, children: [
45
+ }), H = r ? !R && r.children || r.label : N;
46
+ return /* @__PURE__ */ d(g.Root, { open: j, children: [
46
47
  /* @__PURE__ */ a(
47
48
  g.Anchor,
48
49
  {
49
50
  asChild: !0,
50
51
  onMouseDown: (e) => {
51
- c.current = !0, e.currentTarget.dataset.showFocusRing = "false";
52
+ i.current = !0, e.currentTarget.dataset.showFocusRing = "false";
52
53
  },
53
54
  onFocus: (e) => {
54
- c.current || (e.target.dataset.showFocusRing = "true");
55
+ i.current || (e.target.dataset.showFocusRing = "true");
55
56
  },
56
57
  onBlur: (e) => {
57
- e.target.dataset.showFocusRing = "false", c.current = !1;
58
+ e.target.dataset.showFocusRing = "false", i.current = !1;
58
59
  },
59
60
  children: /* @__PURE__ */ d(
60
61
  "div",
@@ -63,40 +64,40 @@ const S = ({
63
64
  "data-status": n,
64
65
  "data-disabled": m,
65
66
  "data-empty": !r,
66
- "data-test-id": i,
67
- ...m ? {} : G({
67
+ "data-test-id": c,
68
+ ...m ? {} : O({
68
69
  "aria-label": "aria-label" in l ? l["aria-label"] : void 0,
69
- ref: x
70
+ ref: F
70
71
  }),
71
72
  children: [
72
- /* @__PURE__ */ a("span", { className: o.selectedValue, children: E }),
73
- F,
73
+ /* @__PURE__ */ a("span", { className: o.selectedValue, children: H }),
74
+ k,
74
75
  u && /* @__PURE__ */ a(
75
- A,
76
+ q,
76
77
  {
77
78
  onClick: (e) => {
78
- e.stopPropagation(), D();
79
+ e.stopPropagation(), V();
79
80
  },
80
81
  className: o.clear,
81
82
  children: u
82
83
  }
83
84
  ),
84
85
  /* @__PURE__ */ d("div", { className: o.icons, children: [
85
- /* @__PURE__ */ a(H, { size: 16, className: o.caret }),
86
+ /* @__PURE__ */ a(T, { size: 16, className: o.caret }),
86
87
  n === "success" ? /* @__PURE__ */ a(
87
- T,
88
+ $,
88
89
  {
89
90
  size: 16,
90
91
  className: o.iconSuccess,
91
- "data-test-id": `${i}-success-icon`
92
+ "data-test-id": `${c}-success-icon`
92
93
  }
93
94
  ) : null,
94
95
  n === "error" ? /* @__PURE__ */ a(
95
- $,
96
+ A,
96
97
  {
97
98
  size: 16,
98
99
  className: o.iconError,
99
- "data-test-id": `${i}-error-icon`
100
+ "data-test-id": `${c}-error-icon`
100
101
  }
101
102
  ) : null
102
103
  ] })
@@ -106,33 +107,34 @@ const S = ({
106
107
  }
107
108
  ),
108
109
  /* @__PURE__ */ a(
109
- X,
110
+ Y,
110
111
  {
111
112
  align: w,
112
113
  side: y,
113
- highlightedIndex: j,
114
- getMenuProps: O,
115
- getItemProps: z,
114
+ highlightedIndex: E,
115
+ getMenuProps: z,
116
+ getItemProps: D,
116
117
  selectedItem: r,
117
- hasInteractedSinceOpening: P,
118
- children: k
118
+ hasInteractedSinceOpening: G,
119
+ viewportCollisionPadding: x,
120
+ children: v
119
121
  }
120
122
  )
121
123
  ] });
122
124
  };
123
125
  S.displayName = "Select";
124
- const _ = J(S), t = _;
126
+ const ee = K(S), t = ee;
125
127
  t.displayName = "Select";
126
- t.Combobox = Q;
128
+ t.Combobox = U;
127
129
  t.Combobox.displayName = "Select.Combobox";
128
- t.Item = U;
130
+ t.Item = W;
129
131
  t.Item.displayName = "Select.Item";
130
- t.Group = W;
132
+ t.Group = X;
131
133
  t.Group.displayName = "Select.Group";
132
- t.Slot = Y;
134
+ t.Slot = Z;
133
135
  t.Slot.displayName = "Select.Slot";
134
136
  export {
135
- _ as ForwardedRefSelect,
137
+ ee as ForwardedRefSelect,
136
138
  t as Select,
137
139
  S as SelectInput
138
140
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components21.js","sources":["../src/components/Select/Select.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useSelect } from 'downshift';\nimport { forwardRef, useRef, useState, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { ForwardedRefCombobox } from './Combobox';\nimport { ForwardedRefSelectItem, ForwardedRefSelectItemGroup } from './SelectItem';\nimport { SelectMenu } from './SelectMenu';\nimport { ForwardedRefSelectSlot } from './SelectSlot';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } from './useSelectData';\n\nexport type SelectComponentProps = {\n /**\n * Children of the Select component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu.\n */\n children?: ReactNode;\n /**\n * Callback function that is called when an item is selected.\n */\n onSelect?: (selectedValue: string | null) => void;\n /**\n * The active value in the select component. This is used to control the select externally.\n */\n value?: string | null;\n /**\n * The default value of the select component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the select component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the select component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end';\n /**\n * Defines the preferred side of the select. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * The data test id of the select component.\n */\n 'data-test-id'?: string;\n /**\n * Id of the select component\n */\n id?: string;\n /**\n * The value of the select is shown as plan text when set to true, items child components are used if set to true\n * @default true\n */\n showStringValue?: boolean;\n} & CommonAriaProps;\n\nexport const SelectInput = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n alignMenu = 'start',\n side = 'bottom',\n id,\n showStringValue = true,\n 'data-test-id': dataTestId = 'fondue-select',\n ...props\n }: SelectComponentProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, clearButton, getItemByValue } = useSelectData(children);\n\n const defaultItem = getItemByValue(defaultValue);\n const activeItem = getItemByValue(value);\n\n const wasClicked = useRef(false);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const { getToggleButtonProps, getMenuProps, getItemProps, reset, selectedItem, isOpen, highlightedIndex } =\n useSelect({\n items,\n defaultSelectedItem: defaultItem,\n selectedItem: activeItem,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const displayedValue = selectedItem\n ? (!showStringValue && selectedItem.children) || selectedItem.label\n : placeholder;\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor\n asChild\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n }}\n >\n <div\n className={styles.root}\n data-status={status}\n data-disabled={disabled}\n data-empty={!selectedItem}\n data-test-id={dataTestId}\n {...(disabled\n ? {}\n : getToggleButtonProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n ref: forwardedRef,\n }))}\n >\n <span className={styles.selectedValue}>{displayedValue}</span>\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n >\n {clearButton}\n </RadixSlot>\n )}\n <div className={styles.icons}>\n <IconCaretDown size={16} className={styles.caret} />\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectInput.displayName = 'Select';\n\nexport const ForwardedRefSelect = forwardRef<HTMLDivElement, SelectComponentProps>(SelectInput);\n\n// @ts-expect-error We support both Select and Select.Combobox as the Root\nexport const Select: typeof SelectInput & {\n Combobox: typeof ForwardedRefCombobox;\n Item: typeof ForwardedRefSelectItem;\n Group: typeof ForwardedRefSelectItemGroup;\n Slot: typeof ForwardedRefSelectSlot;\n} = ForwardedRefSelect;\nSelect.displayName = 'Select';\nSelect.Combobox = ForwardedRefCombobox;\nSelect.Combobox.displayName = 'Select.Combobox';\nSelect.Item = ForwardedRefSelectItem;\nSelect.Item.displayName = 'Select.Item';\nSelect.Group = ForwardedRefSelectItemGroup;\nSelect.Group.displayName = 'Select.Group';\nSelect.Slot = ForwardedRefSelectSlot;\nSelect.Slot.displayName = 'Select.Slot';\n"],"names":["SelectInput","children","onSelect","value","defaultValue","placeholder","status","disabled","alignMenu","side","id","showStringValue","dataTestId","props","forwardedRef","inputSlots","menuSlots","items","clearButton","getItemByValue","useSelectData","defaultItem","activeItem","wasClicked","useRef","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","useSelect","item","displayedValue","jsxs","RadixPopover","jsx","mouseEvent","focusEvent","blurEvent","styles","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefSelect","forwardRef","Select","ForwardedRefCombobox","ForwardedRefSelectItem","ForwardedRefSelectItemGroup","ForwardedRefSelectSlot"],"mappings":";;;;;;;;;;;;AAwEO,MAAMA,IAAc,CACvB;AAAA,EACI,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,gBAAgBC,IAAa;AAAA,EAC7B,GAAGC;AACP,GACAC,MACC;AACK,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,aAAAC,GAAa,gBAAAC,EAAe,IAAIC,EAAcnB,CAAQ,GAEtFoB,IAAcF,EAAef,CAAY,GACzCkB,IAAaH,EAAehB,CAAK,GAEjCoB,IAAaC,EAAO,EAAK,GAEzB,CAACC,GAA2BC,CAA4B,IAAIC,EAAS,EAAK,GAE1E,EAAE,sBAAAC,GAAsB,cAAAC,GAAc,cAAAC,GAAc,OAAAC,GAAO,cAAAC,GAAc,QAAAC,GAAQ,kBAAAC,EAAiB,IACpGC,EAAU;AAAA,IACN,OAAAlB;AAAA,IACA,qBAAqBI;AAAA,IACrB,cAAcC;AAAA,IACd,gBAAgBZ;AAAA,IAChB,SAAS,qBAAqBG,IAAQA,EAAM,iBAAiB,IAAI;AAAA,IACjE,gBAAgB,MAAM;AAClB,MAAAa,EAA6B,EAAK;AAAA,IACtC;AAAA,IACA,0BAA0B,MAAM;AAC5B,MAAAA,EAA6B,EAAI;AAAA,IACrC;AAAA,IACA,sBAAsB,CAAC,EAAE,cAAAM,QAAmB;AAC7BA,MAAAA,KAAAA,QAAAA,GAAAA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AAoB,EAAA,OAAA,EAAI,WAAWM,EAAO,OACnB,UAAA;AAAA,gBAAA,gBAAAJ,EAACO,GAAc,EAAA,MAAM,IAAI,WAAWH,EAAO,OAAO;AAAA,gBACjDtC,MAAW,YACR,gBAAAkC;AAAA,kBAACQ;AAAA,kBAAA;AAAA,oBACG,MAAM;AAAA,oBACN,WAAWJ,EAAO;AAAA,oBAClB,gBAAc,GAAGhC,CAAU;AAAA,kBAAA;AAAA,gBAAA,IAE/B;AAAA,gBACHN,MAAW,UACR,gBAAAkC;AAAA,kBAACS;AAAA,kBAAA;AAAA,oBACG,MAAM;AAAA,oBACN,WAAWL,EAAO;AAAA,oBAClB,gBAAc,GAAGhC,CAAU;AAAA,kBAAA;AAAA,gBAAA,IAE/B;AAAA,cAAA,EACR,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IACJ;AAAA,IAEA,gBAAA4B;AAAA,MAACU;AAAA,MAAA;AAAA,QACG,OAAO1C;AAAA,QACP,MAAAC;AAAA,QACA,kBAAAyB;AAAA,QACA,cAAAL;AAAA,QACA,cAAAC;AAAA,QACA,cAAAE;AAAA,QACA,2BAAAP;AAAA,QAEC,UAAAT;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACAhB,EAAY,cAAc;AAEb,MAAAmD,IAAqBC,EAAiDpD,CAAW,GAGjFqD,IAKTF;AACJE,EAAO,cAAc;AACrBA,EAAO,WAAWC;AAClBD,EAAO,SAAS,cAAc;AAC9BA,EAAO,OAAOE;AACdF,EAAO,KAAK,cAAc;AAC1BA,EAAO,QAAQG;AACfH,EAAO,MAAM,cAAc;AAC3BA,EAAO,OAAOI;AACdJ,EAAO,KAAK,cAAc;"}
1
+ {"version":3,"file":"fondue-components21.js","sources":["../src/components/Select/Select.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useSelect } from 'downshift';\nimport { forwardRef, useRef, useState, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { ForwardedRefCombobox } from './Combobox';\nimport { ForwardedRefSelectItem, ForwardedRefSelectItemGroup } from './SelectItem';\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } from './SelectMenu';\nimport { ForwardedRefSelectSlot } from './SelectSlot';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } from './useSelectData';\n\nexport type SelectComponentProps = {\n /**\n * Children of the Select component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu.\n */\n children?: ReactNode;\n /**\n * Callback function that is called when an item is selected.\n */\n onSelect?: (selectedValue: string | null) => void;\n /**\n * The active value in the select component. This is used to control the select externally.\n */\n value?: string | null;\n /**\n * The default value of the select component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the select component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the select component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end';\n /**\n * Defines the preferred side of the select. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * The data test id of the select component.\n */\n 'data-test-id'?: string;\n /**\n * Id of the select component\n */\n id?: string;\n /**\n * The value of the select is shown as plan text when set to true, items child components are used if set to true\n * @default true\n */\n showStringValue?: boolean;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n} & CommonAriaProps;\n\nexport const SelectInput = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n alignMenu = 'start',\n side = 'bottom',\n id,\n showStringValue = true,\n 'data-test-id': dataTestId = 'fondue-select',\n viewportCollisionPadding = 'compact',\n ...props\n }: SelectComponentProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, clearButton, getItemByValue } = useSelectData(children);\n\n const defaultItem = getItemByValue(defaultValue);\n const activeItem = getItemByValue(value);\n\n const wasClicked = useRef(false);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const { getToggleButtonProps, getMenuProps, getItemProps, reset, selectedItem, isOpen, highlightedIndex } =\n useSelect({\n items,\n defaultSelectedItem: defaultItem,\n selectedItem: activeItem,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const displayedValue = selectedItem\n ? (!showStringValue && selectedItem.children) || selectedItem.label\n : placeholder;\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor\n asChild\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n }}\n >\n <div\n className={styles.root}\n data-status={status}\n data-disabled={disabled}\n data-empty={!selectedItem}\n data-test-id={dataTestId}\n {...(disabled\n ? {}\n : getToggleButtonProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n ref: forwardedRef,\n }))}\n >\n <span className={styles.selectedValue}>{displayedValue}</span>\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n >\n {clearButton}\n </RadixSlot>\n )}\n <div className={styles.icons}>\n <IconCaretDown size={16} className={styles.caret} />\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectInput.displayName = 'Select';\n\nexport const ForwardedRefSelect = forwardRef<HTMLDivElement, SelectComponentProps>(SelectInput);\n\n// @ts-expect-error We support both Select and Select.Combobox as the Root\nexport const Select: typeof SelectInput & {\n Combobox: typeof ForwardedRefCombobox;\n Item: typeof ForwardedRefSelectItem;\n Group: typeof ForwardedRefSelectItemGroup;\n Slot: typeof ForwardedRefSelectSlot;\n} = ForwardedRefSelect;\nSelect.displayName = 'Select';\nSelect.Combobox = ForwardedRefCombobox;\nSelect.Combobox.displayName = 'Select.Combobox';\nSelect.Item = ForwardedRefSelectItem;\nSelect.Item.displayName = 'Select.Item';\nSelect.Group = ForwardedRefSelectItemGroup;\nSelect.Group.displayName = 'Select.Group';\nSelect.Slot = ForwardedRefSelectSlot;\nSelect.Slot.displayName = 'Select.Slot';\n"],"names":["SelectInput","children","onSelect","value","defaultValue","placeholder","status","disabled","alignMenu","side","id","showStringValue","dataTestId","viewportCollisionPadding","props","forwardedRef","inputSlots","menuSlots","items","clearButton","getItemByValue","useSelectData","defaultItem","activeItem","wasClicked","useRef","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","useSelect","item","displayedValue","jsxs","RadixPopover","jsx","mouseEvent","focusEvent","blurEvent","styles","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefSelect","forwardRef","Select","ForwardedRefCombobox","ForwardedRefSelectItem","ForwardedRefSelectItemGroup","ForwardedRefSelectSlot"],"mappings":";;;;;;;;;;;;AA6EO,MAAMA,IAAc,CACvB;AAAA,EACI,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,gBAAgBC,IAAa;AAAA,EAC7B,0BAAAC,IAA2B;AAAA,EAC3B,GAAGC;AACP,GACAC,MACC;AACK,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,aAAAC,GAAa,gBAAAC,EAAe,IAAIC,EAAcpB,CAAQ,GAEtFqB,IAAcF,EAAehB,CAAY,GACzCmB,IAAaH,EAAejB,CAAK,GAEjCqB,IAAaC,EAAO,EAAK,GAEzB,CAACC,GAA2BC,CAA4B,IAAIC,EAAS,EAAK,GAE1E,EAAE,sBAAAC,GAAsB,cAAAC,GAAc,cAAAC,GAAc,OAAAC,GAAO,cAAAC,GAAc,QAAAC,GAAQ,kBAAAC,EAAiB,IACpGC,EAAU;AAAA,IACN,OAAAlB;AAAA,IACA,qBAAqBI;AAAA,IACrB,cAAcC;AAAA,IACd,gBAAgBb;AAAA,IAChB,SAAS,qBAAqBI,IAAQA,EAAM,iBAAiB,IAAI;AAAA,IACjE,gBAAgB,MAAM;AAClB,MAAAa,EAA6B,EAAK;AAAA,IACtC;AAAA,IACA,0BAA0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,12 +1,12 @@
1
1
  import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
- import { IconCaretDown as E, IconCheckMark as q, IconExclamationMarkTriangle as G } from "@frontify/fondue-icons";
2
+ import { IconCaretDown as q, IconCheckMark as G, IconExclamationMarkTriangle as J } from "@frontify/fondue-icons";
3
3
  import * as w from "@radix-ui/react-popover";
4
- import { Slot as J } from "@radix-ui/react-slot";
5
- import { useCombobox as K } from "downshift";
6
- import { forwardRef as Q, useState as U, useRef as W, useMemo as X } from "react";
7
- import { SelectMenu as Y } from "./fondue-components61.js";
4
+ import { Slot as K } from "@radix-ui/react-slot";
5
+ import { useCombobox as Q } from "downshift";
6
+ import { forwardRef as U, useState as W, useRef as X, useMemo as Y } from "react";
7
+ import { SelectMenu as Z } from "./fondue-components61.js";
8
8
  import o from "./fondue-components63.js";
9
- import { useSelectData as Z } from "./fondue-components64.js";
9
+ import { useSelectData as _ } from "./fondue-components64.js";
10
10
  const N = ({
11
11
  children: S,
12
12
  onSelect: l,
@@ -19,22 +19,23 @@ const N = ({
19
19
  alignMenu: M = "start",
20
20
  side: y = "bottom",
21
21
  id: F,
22
+ viewportCollisionPadding: L = "compact",
22
23
  ...a
23
- }, L) => {
24
- const { inputSlots: P, menuSlots: k, items: c, filterText: v, clearButton: f, getItemByValue: h, setFilterText: D } = Z(S), [H, p] = U(!1), {
24
+ }, P) => {
25
+ const { inputSlots: k, menuSlots: v, items: c, filterText: D, clearButton: f, getItemByValue: p, setFilterText: H } = _(S), [T, h] = W(!1), {
25
26
  getInputProps: u,
26
- getToggleButtonProps: T,
27
- getMenuProps: V,
28
- getItemProps: z,
27
+ getToggleButtonProps: V,
28
+ getMenuProps: z,
29
+ getItemProps: j,
29
30
  reset: b,
30
31
  selectedItem: r,
31
- isOpen: j,
32
- highlightedIndex: $,
32
+ isOpen: $,
33
+ highlightedIndex: A,
33
34
  inputValue: d
34
- } = K({
35
+ } = Q({
35
36
  items: c,
36
- selectedItem: h(B),
37
- defaultSelectedItem: h(O),
37
+ selectedItem: p(B),
38
+ defaultSelectedItem: p(O),
38
39
  defaultHighlightedIndex: 0,
39
40
  toggleButtonId: F,
40
41
  labelId: "aria-labelledby" in a ? a["aria-labelledby"] : void 0,
@@ -42,24 +43,24 @@ const N = ({
42
43
  l == null || l((e == null ? void 0 : e.value) ?? null);
43
44
  },
44
45
  onInputValueChange: ({ inputValue: e }) => {
45
- D(e);
46
+ H(e);
46
47
  },
47
48
  onIsOpenChange: () => {
48
- p(!1);
49
+ h(!1);
49
50
  },
50
51
  onHighlightedIndexChange: () => {
51
- p(!0);
52
+ h(!0);
52
53
  },
53
54
  itemToString: (e) => e ? e.label : ""
54
- }), n = W(!1), C = X(
55
+ }), n = X(!1), C = Y(
55
56
  () => !c.find((e) => e.label.toLowerCase().includes(d.toLowerCase())),
56
57
  [d, c]
57
- ), A = (e) => {
58
+ ), E = (e) => {
58
59
  var x, I;
59
60
  e.target.dataset.showFocusRing = "false", n.current = !1, (r == null ? void 0 : r.label.toLocaleLowerCase()) !== d.toLocaleLowerCase() && b(), u().onBlur && ((I = (x = u()).onBlur) == null || I.call(x, e));
60
61
  };
61
- return /* @__PURE__ */ m(w.Root, { open: j, children: [
62
- /* @__PURE__ */ t(w.Anchor, { asChild: !0, children: /* @__PURE__ */ m("div", { ref: L, className: o.root, "data-status": C ? "error" : s, children: [
62
+ return /* @__PURE__ */ m(w.Root, { open: $, children: [
63
+ /* @__PURE__ */ t(w.Anchor, { asChild: !0, children: /* @__PURE__ */ m("div", { ref: P, className: o.root, "data-status": C ? "error" : s, children: [
63
64
  /* @__PURE__ */ t(
64
65
  "input",
65
66
  {
@@ -76,12 +77,12 @@ const N = ({
76
77
  onFocus: (e) => {
77
78
  n.current || (e.target.dataset.showFocusRing = "true");
78
79
  },
79
- onBlur: A
80
+ onBlur: E
80
81
  }
81
82
  ),
82
- P,
83
+ k,
83
84
  f && /* @__PURE__ */ t(
84
- J,
85
+ K,
85
86
  {
86
87
  onClick: (e) => {
87
88
  e.stopPropagation(), b();
@@ -96,17 +97,17 @@ const N = ({
96
97
  "button",
97
98
  {
98
99
  "aria-label": "toggle menu",
99
- ...T(),
100
+ ...V(),
100
101
  type: "button",
101
102
  disabled: g,
102
103
  onMouseDown: () => {
103
104
  n.current = !0;
104
105
  },
105
- children: /* @__PURE__ */ t(E, { size: 16, className: o.caret })
106
+ children: /* @__PURE__ */ t(q, { size: 16, className: o.caret })
106
107
  }
107
108
  ),
108
109
  s === "success" ? /* @__PURE__ */ t(
109
- q,
110
+ G,
110
111
  {
111
112
  size: 16,
112
113
  className: o.iconSuccess,
@@ -114,7 +115,7 @@ const N = ({
114
115
  }
115
116
  ) : null,
116
117
  C || s === "error" ? /* @__PURE__ */ t(
117
- G,
118
+ J,
118
119
  {
119
120
  size: 16,
120
121
  className: o.iconError,
@@ -124,25 +125,26 @@ const N = ({
124
125
  ] })
125
126
  ] }) }),
126
127
  /* @__PURE__ */ t(
127
- Y,
128
+ Z,
128
129
  {
129
130
  align: M,
130
131
  side: y,
131
- highlightedIndex: $,
132
- filterText: v,
133
- getMenuProps: V,
134
- getItemProps: z,
132
+ highlightedIndex: A,
133
+ filterText: D,
134
+ getMenuProps: z,
135
+ getItemProps: j,
135
136
  selectedItem: r,
136
- hasInteractedSinceOpening: H,
137
- children: k
137
+ hasInteractedSinceOpening: T,
138
+ viewportCollisionPadding: L,
139
+ children: v
138
140
  }
139
141
  )
140
142
  ] });
141
143
  };
142
144
  N.displayName = "Select.Combobox";
143
- const ie = Q(N);
145
+ const ce = U(N);
144
146
  export {
145
- ie as ForwardedRefCombobox,
147
+ ce as ForwardedRefCombobox,
146
148
  N as SelectCombobox
147
149
  };
148
150
  //# sourceMappingURL=fondue-components59.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components59.js","sources":["../src/components/Select/Combobox.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useCombobox } from 'downshift';\nimport { forwardRef, useMemo, useRef, useState, type FocusEvent, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { SelectMenu } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } from './useSelectData';\n\nexport type ComboboxProps = {\n /**\n * Children of the Combobox component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu.\n */\n children?: ReactNode;\n /**\n * Callback function that is called when an item is selected.\n */\n onSelect?: (selectedValue: string | null) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string | null;\n /**\n * The default value of the combobox component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the combobox component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the combobox component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end' /**\n * Defines the preferred side of the combobox. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */;\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * Id of the combobox component\n */\n id?: string;\n /**\n * The data test id of the combobox component.\n */\n 'data-test-id'?: string;\n} & CommonAriaProps;\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n side = 'bottom',\n id,\n ...props\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText } =\n useSelectData(children);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const {\n getInputProps,\n getToggleButtonProps,\n getMenuProps,\n getItemProps,\n reset,\n selectedItem,\n isOpen,\n highlightedIndex,\n inputValue,\n } = useCombobox({\n items,\n selectedItem: getItemByValue(value),\n defaultSelectedItem: getItemByValue(defaultValue),\n defaultHighlightedIndex: 0,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const wasClicked = useRef(false);\n\n const valueInvalid = useMemo(\n () => !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items],\n );\n\n const onBlurHandler = (blurEvent: FocusEvent<HTMLInputElement, Element>) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n\n const selectedItemNullOrOutdated = selectedItem?.label.toLocaleLowerCase() !== inputValue.toLocaleLowerCase();\n\n if (selectedItemNullOrOutdated) {\n // if there is no selection or\n // the existing selected value is not the same as the input value (old),\n // reset the input\n reset();\n }\n\n if (getInputProps().onBlur) {\n getInputProps().onBlur?.(blurEvent);\n }\n };\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={valueInvalid ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={onBlurHandler}\n />\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n role=\"button\"\n >\n {clearButton}\n </RadixSlot>\n )}\n <div className={styles.icons}>\n <button\n aria-label=\"toggle menu\"\n {...getToggleButtonProps()}\n type=\"button\"\n disabled={disabled}\n onMouseDown={() => {\n wasClicked.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {valueInvalid || status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectCombobox.displayName = 'Select.Combobox';\n\nexport const ForwardedRefCombobox = forwardRef<HTMLDivElement, ComboboxProps>(SelectCombobox);\n"],"names":["SelectCombobox","children","onSelect","value","defaultValue","placeholder","status","disabled","dataTestId","alignMenu","side","id","props","forwardedRef","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":";;;;;;;;;AA+DO,MAAMA,IAAiB,CAC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ondue-components59.js","sources":["../src/components/Select/Combobox.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCaretDown, IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { useCombobox } from 'downshift';\nimport { forwardRef, useMemo, useRef, useState, type FocusEvent, type ForwardedRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\n\nimport { SelectMenu, type SelectMenuViewportCollisionPadding } from './SelectMenu';\nimport styles from './styles/select.module.scss';\nimport { useSelectData } from './useSelectData';\n\nexport type ComboboxProps = {\n /**\n * Children of the Combobox component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu.\n */\n children?: ReactNode;\n /**\n * Callback function that is called when an item is selected.\n */\n onSelect?: (selectedValue: string | null) => void;\n /**\n * The active value in the combobox component. This is used to control the combobox externally.\n */\n value?: string | null;\n /**\n * The default value of the combobox component. Used for uncontrolled usages.\n */\n defaultValue?: string;\n /**\n * The placeholder in the combobox component.\n */\n placeholder?: string;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error';\n /**\n * Disables the combobox component.\n */\n disabled?: boolean;\n /**\n * The alignment of the menu.\n * @default \"start\"\n */\n alignMenu?: 'start' | 'center' | 'end' /**\n * Defines the preferred side of the combobox. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */;\n side?: 'left' | 'right' | 'bottom' | 'top';\n /**\n * Id of the combobox component\n */\n id?: string;\n /**\n * The data test id of the combobox component.\n */\n 'data-test-id'?: string;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n} & CommonAriaProps;\n\nexport const SelectCombobox = (\n {\n children,\n onSelect,\n value,\n defaultValue,\n placeholder = '',\n status = 'neutral',\n disabled,\n 'data-test-id': dataTestId = 'fondue-select-combobox',\n alignMenu = 'start',\n side = 'bottom',\n id,\n viewportCollisionPadding = 'compact',\n ...props\n }: ComboboxProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const { inputSlots, menuSlots, items, filterText, clearButton, getItemByValue, setFilterText } =\n useSelectData(children);\n\n const [hasInteractedSinceOpening, setHasInteractedSinceOpening] = useState(false);\n\n const {\n getInputProps,\n getToggleButtonProps,\n getMenuProps,\n getItemProps,\n reset,\n selectedItem,\n isOpen,\n highlightedIndex,\n inputValue,\n } = useCombobox({\n items,\n selectedItem: getItemByValue(value),\n defaultSelectedItem: getItemByValue(defaultValue),\n defaultHighlightedIndex: 0,\n toggleButtonId: id,\n labelId: 'aria-labelledby' in props ? props['aria-labelledby'] : undefined,\n onSelectedItemChange: ({ selectedItem }) => {\n onSelect?.(selectedItem?.value ?? null);\n },\n onInputValueChange: ({ inputValue }) => {\n setFilterText(inputValue);\n },\n onIsOpenChange: () => {\n setHasInteractedSinceOpening(false);\n },\n onHighlightedIndexChange: () => {\n setHasInteractedSinceOpening(true);\n },\n itemToString: (item) => (item ? item.label : ''),\n });\n\n const wasClicked = useRef(false);\n\n const valueInvalid = useMemo(\n () => !items.find((item) => item.label.toLowerCase().includes(inputValue.toLowerCase())),\n [inputValue, items],\n );\n\n const onBlurHandler = (blurEvent: FocusEvent<HTMLInputElement, Element>) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n\n const selectedItemNullOrOutdated = selectedItem?.label.toLocaleLowerCase() !== inputValue.toLocaleLowerCase();\n\n if (selectedItemNullOrOutdated) {\n // if there is no selection or\n // the existing selected value is not the same as the input value (old),\n // reset the input\n reset();\n }\n\n if (getInputProps().onBlur) {\n getInputProps().onBlur?.(blurEvent);\n }\n };\n\n return (\n <RadixPopover.Root open={isOpen}>\n <RadixPopover.Anchor asChild>\n <div ref={forwardedRef} className={styles.root} data-status={valueInvalid ? 'error' : status}>\n <input\n {...getInputProps({\n 'aria-label': 'aria-label' in props ? props['aria-label'] : undefined,\n })}\n data-test-id={dataTestId}\n placeholder={placeholder}\n className={styles.input}\n disabled={disabled}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n }}\n onBlur={onBlurHandler}\n />\n {inputSlots}\n {clearButton && (\n <RadixSlot\n onClick={(event) => {\n event.stopPropagation();\n reset();\n }}\n className={styles.clear}\n role=\"button\"\n >\n {clearButton}\n </RadixSlot>\n )}\n <div className={styles.icons}>\n <button\n aria-label=\"toggle menu\"\n {...getToggleButtonProps()}\n type=\"button\"\n disabled={disabled}\n onMouseDown={() => {\n wasClicked.current = true;\n }}\n >\n <IconCaretDown size={16} className={styles.caret} />\n </button>\n {status === 'success' ? (\n <IconCheckMark\n size={16}\n className={styles.iconSuccess}\n data-test-id={`${dataTestId}-success-icon`}\n />\n ) : null}\n {valueInvalid || status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n </div>\n </div>\n </RadixPopover.Anchor>\n\n <SelectMenu\n align={alignMenu}\n side={side}\n highlightedIndex={highlightedIndex}\n filterText={filterText}\n getMenuProps={getMenuProps}\n getItemProps={getItemProps}\n selectedItem={selectedItem}\n hasInteractedSinceOpening={hasInteractedSinceOpening}\n viewportCollisionPadding={viewportCollisionPadding}\n >\n {menuSlots}\n </SelectMenu>\n </RadixPopover.Root>\n );\n};\nSelectCombobox.displayName = 'Select.Combobox';\n\nexport const ForwardedRefCombobox = forwardRef<HTMLDivElement, ComboboxProps>(SelectCombobox);\n"],"names":["SelectCombobox","children","onSelect","value","defaultValue","placeholder","status","disabled","dataTestId","alignMenu","side","id","viewportCollisionPadding","props","forwardedRef","inputSlots","menuSlots","items","filterText","clearButton","getItemByValue","setFilterText","useSelectData","hasInteractedSinceOpening","setHasInteractedSinceOpening","useState","getInputProps","getToggleButtonProps","getMenuProps","getItemProps","reset","selectedItem","isOpen","highlightedIndex","inputValue","useCombobox","item","wasClicked","useRef","valueInvalid","useMemo","onBlurHandler","blurEvent","_b","_a","jsxs","RadixPopover","jsx","styles","mouseEvent","focusEvent","RadixSlot","event","IconCaretDown","IconCheckMark","IconExclamationMarkTriangle","SelectMenu","ForwardedRefCombobox","forwardRef"],"mappings":";;;;;;;;;AAoEO,MAAMA,IAAiB,CAC1B;AAAA,EACI,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,gBAAgBC,IAAa;AAAA,EAC7B,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,IAAAC;AAAA,EACA,0BAAAC,IAA2B;AAAA,EAC3B,GAAGC;AACP,GACAC,MACC;AACK,QAAA,EAAE,YAAAC,GAAY,WAAAC,GAAW,OAAAC,GAAO,YAAAC,GAAY,aAAAC,GAAa,gBAAAC,GAAgB,eAAAC,EAAA,IAC3EC,EAAcrB,CAAQ,GAEpB,CAACsB,GAA2BC,CAA4B,IAAIC,EAAS,EAAK,GAE1E;AAAA,IACF,eAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,YAAAC;AAAA,MACAC,EAAY;AAAA,IACZ,OAAAlB;AAAA,IACA,cAAcG,EAAejB,CAAK;AAAA,IAClC,qBAAqBiB,EAAehB,CAAY;AAAA,IAChD,yBAAyB;AAAA,IACzB,gBAAgBO;AAAA,IAChB,SAAS,qBAAqBE,IAAQA,EAAM,iBAAiB,IAAI;AAAA,IACjE,sBAAsB,CAAC,EAAE,cAAAkB,QAAmB;AAC7BA,MAA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AAAA,IAEA,gBAAAuC;AAAA,MAACS;AAAA,MAAA;AAAA,QACG,OAAO/C;AAAA,QACP,MAAAC;AAAA,QACA,kBAAAuB;AAAA,QACA,YAAAf;AAAA,QACA,cAAAU;AAAA,QACA,cAAAC;AAAA,QACA,cAAAE;AAAA,QACA,2BAAAR;AAAA,QACA,0BAAAX;AAAA,QAEC,UAAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EACL,GACJ;AAER;AACAhB,EAAe,cAAc;AAEhB,MAAAyD,KAAuBC,EAA0C1D,CAAc;"}
@@ -1,57 +1,61 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import * as s from "@radix-ui/react-popover";
3
- import { Slot as g } from "@radix-ui/react-slot";
4
- import { isValidElement as C } from "react";
5
- import { useFondueTheme as N, ThemeProvider as O } from "./fondue-components28.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import * as i from "@radix-ui/react-popover";
3
+ import { Slot as C } from "@radix-ui/react-slot";
4
+ import { isValidElement as V } from "react";
5
+ import { useFondueTheme as g, ThemeProvider as A } from "./fondue-components28.js";
6
6
  import n from "./fondue-components63.js";
7
- import { recursiveMap as V, getSelectOptionValue as F } from "./fondue-components78.js";
8
- const M = ({
9
- highlightedIndex: l,
10
- getMenuProps: p,
7
+ import { recursiveMap as D, getSelectOptionValue as M } from "./fondue-components78.js";
8
+ const T = ({
9
+ highlightedIndex: p,
10
+ getMenuProps: l,
11
11
  getItemProps: u,
12
12
  children: m,
13
- filterText: f,
14
- align: c,
13
+ filterText: c,
14
+ align: f,
15
15
  side: d,
16
16
  selectedItem: t,
17
- hasInteractedSinceOpening: h
17
+ hasInteractedSinceOpening: h,
18
+ viewportCollisionPadding: P = "compact"
18
19
  }) => {
19
20
  const v = (e) => {
20
21
  e.preventDefault();
21
- }, P = N();
22
- return /* @__PURE__ */ o(s.Portal, { children: /* @__PURE__ */ o(O, { theme: P, children: /* @__PURE__ */ o(
23
- s.Content,
22
+ }, O = {
23
+ compact: 8,
24
+ spacious: 24
25
+ }, N = g();
26
+ return /* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ r(A, { theme: N, children: /* @__PURE__ */ r(
27
+ i.Content,
24
28
  {
25
- align: c,
29
+ align: f,
26
30
  side: d,
27
- collisionPadding: 16,
31
+ collisionPadding: O[P] + 8,
28
32
  onOpenAutoFocus: v,
29
33
  className: n.portal,
30
- children: /* @__PURE__ */ o(
34
+ children: /* @__PURE__ */ r(
31
35
  "ul",
32
36
  {
33
37
  className: n.menu,
34
- ...p({}, { suppressRefError: !0 }),
38
+ ...l({}, { suppressRefError: !0 }),
35
39
  "data-has-interacted": h ? "true" : "false",
36
40
  "data-test-id": "fondue-select-menu",
37
- children: V(
41
+ children: D(
38
42
  m,
39
- (e, i) => {
40
- if (((r) => (
43
+ (e, s) => {
44
+ if (((o) => (
41
45
  // @ts-expect-error - We are explicitly checking for ref
42
- C(r) && r.ref !== void 0
46
+ V(o) && o.ref !== void 0
43
47
  ))(e)) {
44
- const r = F(e.props), a = u({
45
- item: r,
46
- index: i,
48
+ const o = M(e.props), a = u({
49
+ item: o,
50
+ index: s,
47
51
  ...e.ref ? { ref: e.ref } : {}
48
52
  });
49
- return /* @__PURE__ */ o(
50
- g,
53
+ return /* @__PURE__ */ r(
54
+ C,
51
55
  {
52
56
  className: n.item,
53
- "data-highlighted": l === i,
54
- "data-selected": (t == null ? void 0 : t.value) === r.value,
57
+ "data-highlighted": p === s,
58
+ "data-selected": (t == null ? void 0 : t.value) === o.value,
55
59
  onTouchStart: (S) => {
56
60
  a.onClick && a.onClick(S);
57
61
  },
@@ -62,15 +66,15 @@ const M = ({
62
66
  );
63
67
  }
64
68
  },
65
- f
69
+ c
66
70
  ).parsedChildren
67
71
  }
68
72
  )
69
73
  }
70
74
  ) }) });
71
75
  };
72
- M.displayName = "Select.Menu";
76
+ T.displayName = "Select.Menu";
73
77
  export {
74
- M as SelectMenu
78
+ T as SelectMenu
75
79
  };
76
80
  //# sourceMappingURL=fondue-components61.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components61.js","sources":["../src/components/Select/SelectMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { type UseComboboxPropGetters, type UseSelectPropGetters } from 'downshift';\nimport { isValidElement, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\n\nexport type SelectMenuProps = {\n /**\n * @internal\n * The index of the highlighted item in the menu.\n */\n highlightedIndex: number;\n /**\n * @internal\n * Callback function to retrieve the props for a menu element.\n */\n getMenuProps: UseSelectPropGetters<unknown>['getMenuProps'] | UseComboboxPropGetters<unknown>['getMenuProps'];\n /**\n * @internal\n * Callback function to retrieve the props for a item element.\n */\n getItemProps: UseSelectPropGetters<unknown>['getItemProps'] | UseComboboxPropGetters<unknown>['getItemProps'];\n /**\n * @internal\n * The children of the menu component. This can contain multiple `Select.Item` or `Select.Group` components.\n */\n children: ReactNode;\n /**\n * @internal\n * The filter text shown in the combobox input element.\n */\n filterText?: string;\n /**\n * @internal\n * The alignment of the menu.\n */\n align: 'start' | 'center' | 'end';\n /**\n * @internal\n * Defines the preferred side of the select. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side: 'left' | 'right' | 'bottom' | 'top';\n /**\n * @internal\n * The type of the menu.\n */\n selectedItem?: {\n value: string;\n } | null;\n /**\n * @internal\n * A boolean to indicate if highlighted item was changed since opening the menu.\n * This is used to determine the style of the selected/highlighted item.\n */\n hasInteractedSinceOpening?: boolean;\n};\n\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n side,\n selectedItem,\n hasInteractedSinceOpening,\n}: SelectMenuProps) => {\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n };\n\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <RadixPopover.Content\n align={align}\n side={side}\n collisionPadding={16}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n className={styles.portal}\n >\n <ul\n className={styles.menu}\n // TODO: fix this accessibility issue\n // We are mounting/unmounting the menu on open/close\n // We should instead toggle its visibility for accessibility reasons\n // https://github.com/downshift-js/downshift?tab=readme-ov-file#getmenuprops\n {...getMenuProps({}, { suppressRefError: true })}\n data-has-interacted={hasInteractedSinceOpening ? 'true' : 'false'}\n data-test-id=\"fondue-select-menu\"\n >\n {\n recursiveMap(\n children,\n (child, index) => {\n const isValid = <TProps,>(\n child: ReactNode,\n ): child is ReactElement<TProps> & { ref: ForwardedRef<HTMLElement> } =>\n // @ts-expect-error - We are explicitly checking for ref\n isValidElement<TProps>(child) && child.ref !== undefined;\n\n if (isValid<SelectItemProps>(child)) {\n const optionData = getSelectOptionValue(child.props);\n const itemProps = getItemProps({\n item: optionData,\n index,\n ...(child.ref ? { ref: child.ref } : {}),\n });\n\n return (\n <RadixSlot\n className={styles.item}\n data-highlighted={highlightedIndex === index}\n data-selected={selectedItem?.value === optionData.value}\n key={child.props.value}\n // Workaround for the issue where the onClick event is not fired on touch devices because of portal usage\n onTouchStart={(event) => {\n if (itemProps.onClick) {\n itemProps.onClick(event as unknown as MouseEvent<HTMLElement>);\n }\n }}\n {...itemProps}\n >\n {child}\n </RadixSlot>\n );\n }\n },\n filterText,\n ).parsedChildren\n }\n </ul>\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","align","side","selectedItem","hasInteractedSinceOpening","handleOnOpenAutoFocus","event","theme","useFondueTheme","RadixPopover","jsx","ThemeProvider","styles","recursiveM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AAA,oBACvC,kBAAeZ,KAAA,gBAAAA,EAAc,WAAUc,EAAW;AAAA,oBAGlD,cAAc,CAACX,MAAU;AACrB,sBAAIa,EAAU,WACVA,EAAU,QAAQb,CAA2C;AAAA,oBAErE;AAAA,oBACC,GAAGa;AAAA,oBAEH,UAAAL;AAAA,kBAAA;AAAA,kBATIA,EAAM,MAAM;AAAA,gBAUrB;AAAA,cAAA;AAAA,YAGZ;AAAA,YACAd;AAAA,UAAA,EACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAEV;AAAA,KAER,EACJ,CAAA;AAER;AACAL,EAAW,cAAc;"}
1
+ {"version":3,"file":"fondue-components61.js","sources":["../src/components/Select/SelectMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { type UseComboboxPropGetters, type UseSelectPropGetters } from 'downshift';\nimport { isValidElement, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\n\nexport type SelectMenuViewportCollisionPadding = 'compact' | 'spacious';\n\nexport type SelectMenuProps = {\n /**\n * @internal\n * The index of the highlighted item in the menu.\n */\n highlightedIndex: number;\n /**\n * @internal\n * Callback function to retrieve the props for a menu element.\n */\n getMenuProps: UseSelectPropGetters<unknown>['getMenuProps'] | UseComboboxPropGetters<unknown>['getMenuProps'];\n /**\n * @internal\n * Callback function to retrieve the props for a item element.\n */\n getItemProps: UseSelectPropGetters<unknown>['getItemProps'] | UseComboboxPropGetters<unknown>['getItemProps'];\n /**\n * @internal\n * The children of the menu component. This can contain multiple `Select.Item` or `Select.Group` components.\n */\n children: ReactNode;\n /**\n * @internal\n * The filter text shown in the combobox input element.\n */\n filterText?: string;\n /**\n * @internal\n * The alignment of the menu.\n */\n align: 'start' | 'center' | 'end';\n /**\n * @internal\n * Defines the preferred side of the select. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side: 'left' | 'right' | 'bottom' | 'top';\n /**\n * @internal\n * The type of the menu.\n */\n selectedItem?: {\n value: string;\n } | null;\n /**\n * @internal\n * A boolean to indicate if highlighted item was changed since opening the menu.\n * This is used to determine the style of the selected/highlighted item.\n */\n hasInteractedSinceOpening?: boolean;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n};\n\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n side,\n selectedItem,\n hasInteractedSinceOpening,\n viewportCollisionPadding = 'compact',\n}: SelectMenuProps) => {\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n };\n\n const VIEWPORT_COLLISION_PADDING_MAP: Record<SelectMenuViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n };\n\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <RadixPopover.Content\n align={align}\n side={side}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding] + 8}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n className={styles.portal}\n >\n <ul\n className={styles.menu}\n // TODO: fix this accessibility issue\n // We are mounting/unmounting the menu on open/close\n // We should instead toggle its visibility for accessibility reasons\n // https://github.com/downshift-js/downshift?tab=readme-ov-file#getmenuprops\n {...getMenuProps({}, { suppressRefError: true })}\n data-has-interacted={hasInteractedSinceOpening ? 'true' : 'false'}\n data-test-id=\"fondue-select-menu\"\n >\n {\n recursiveMap(\n children,\n (child, index) => {\n const isValid = <TProps,>(\n child: ReactNode,\n ): child is ReactElement<TProps> & { ref: ForwardedRef<HTMLElement> } =>\n // @ts-expect-error - We are explicitly checking for ref\n isValidElement<TProps>(child) && child.ref !== undefined;\n\n if (isValid<SelectItemProps>(child)) {\n const optionData = getSelectOptionValue(child.props);\n const itemProps = getItemProps({\n item: optionData,\n index,\n ...(child.ref ? { ref: child.ref } : {}),\n });\n\n return (\n <RadixSlot\n className={styles.item}\n data-highlighted={highlightedIndex === index}\n data-selected={selectedItem?.value === optionData.value}\n key={child.props.value}\n // Workaround for the issue where the onClick event is not fired on touch devices because of portal usage\n onTouchStart={(event) => {\n if (itemProps.onClick) {\n itemProps.onClick(event as unknown as MouseEvent<HTMLElement>);\n }\n }}\n {...itemProps}\n >\n {child}\n </RadixSlot>\n );\n }\n },\n filterText,\n ).parsedChildren\n }\n </ul>\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","align","side","selectedItem","hasInteractedSinceOpening","viewportCollisionPadding","handleOnOpenAutoFocus","event","VIEWPORT_COLLISION_PADDING_MAP","theme","useFondueTheme","RadixPopover","jsx","ThemeProvider","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AAwEO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,0BAAAC,IAA2B;AAC/B,MAAuB;AACb,QAAAC,IAAwB,CAACC,MAAiB;AAC5C,IAAAA,EAAM,eAAe;AAAA,EACzB,GAEMC,IAAqF;AAAA,IACvF,SAAS;AAAA,IACT,UAAU;AAAA,EACd,GAEMC,IAAQC,EAAe;AAC7B,2BACKC,EAAa,QAAb,EACG,UAAA,gBAAAC,EAACC,KAAc,OAAAJ,GACX,UAAA,gBAAAG;AAAA,IAACD,EAA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ContentProps = {
620
620
  * Prevents the focus from being set on the trigger when the dropdown is closed.
621
621
  */
622
622
  preventTriggerFocusOnClose?: boolean;
623
+ /**
624
+ * Define the minimum distance between the dropdown and the viewport edge
625
+ * @default 'compact'
626
+ */
627
+ viewportCollisionPadding?: DropdownViewportCollisionPadding;
623
628
  };
624
629
 
625
630
  declare type DropdownGroupProps = {
@@ -706,6 +711,8 @@ declare type DropdownTriggerProps = {
706
711
  'data-test-id'?: string;
707
712
  };
708
713
 
714
+ declare type DropdownViewportCollisionPadding = 'compact' | 'spacious';
715
+
709
716
  export declare const Flex: ForwardRefExoticComponent<LayoutComponentProps & {
710
717
  /**
711
718
  * The element to render the Flex component as.
@@ -813,6 +820,11 @@ declare type FlyoutContentProps = {
813
820
  * @default "360px"
814
821
  */
815
822
  maxWidth?: string;
823
+ /**
824
+ * Define the minimum distance between the flyout and the viewport edge
825
+ * @default 'compact'
826
+ */
827
+ viewportCollisionPadding?: FlyoutViewportCollisionPadding;
816
828
  children?: ReactNode;
817
829
  'data-test-id'?: string;
818
830
  };
@@ -862,6 +874,8 @@ declare type FlyoutTriggerProps = {
862
874
  'data-test-id'?: string;
863
875
  };
864
876
 
877
+ declare type FlyoutViewportCollisionPadding = 'compact' | 'spacious';
878
+
865
879
  declare const ForwardedRefCombobox: ForwardRefExoticComponent< {
866
880
  /**
867
881
  * Children of the Combobox component. This can contain the `Select.Slot` components for the label, decorators, clear action and menu.
@@ -909,6 +923,11 @@ id?: string;
909
923
  * The data test id of the combobox component.
910
924
  */
911
925
  'data-test-id'?: string;
926
+ /**
927
+ * Define the minimum distance between the select menu and the viewport edge
928
+ * @default 'compact'
929
+ */
930
+ viewportCollisionPadding?: SelectMenuViewportCollisionPadding;
912
931
  } & CommonAriaProps & RefAttributes<HTMLDivElement>>;
913
932
 
914
933
  declare const ForwardedRefSelectItem: ForwardRefExoticComponent<SelectItemProps & RefAttributes<HTMLLIElement>>;
@@ -1380,10 +1399,15 @@ declare type SelectComponentProps = {
1380
1399
  * @default true
1381
1400
  */
1382
1401
  showStringValue?: boolean;
1402
+ /**
1403
+ * Define the minimum distance between the select menu and the viewport edge
1404
+ * @default 'compact'
1405
+ */
1406
+ viewportCollisionPadding?: SelectMenuViewportCollisionPadding;
1383
1407
  } & CommonAriaProps;
1384
1408
 
1385
1409
  declare const SelectInput: {
1386
- ({ children, onSelect, value, defaultValue, placeholder, status, disabled, alignMenu, side, id, showStringValue, "data-test-id": dataTestId, ...props }: SelectComponentProps, forwardedRef: ForwardedRef<HTMLDivElement>): JSX_2.Element;
1410
+ ({ children, onSelect, value, defaultValue, placeholder, status, disabled, alignMenu, side, id, showStringValue, "data-test-id": dataTestId, viewportCollisionPadding, ...props }: SelectComponentProps, forwardedRef: ForwardedRef<HTMLDivElement>): JSX_2.Element;
1387
1411
  displayName: string;
1388
1412
  };
1389
1413
 
@@ -1425,6 +1449,8 @@ declare type SelectItemProps = {
1425
1449
  children: string;
1426
1450
  });
1427
1451
 
1452
+ declare type SelectMenuViewportCollisionPadding = 'compact' | 'spacious';
1453
+
1428
1454
  declare type SelectSlotProps = {
1429
1455
  /**
1430
1456
  * The children of the select slot. This can be a custom component.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontify/fondue-components",
3
3
  "type": "module",
4
- "version": "15.0.1",
4
+ "version": "16.0.0",
5
5
  "homepage": "https://github.com/Frontify/fondue",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "peerDependencies": {
31
31
  "react": "^18",
32
32
  "react-dom": "^18",
33
- "@frontify/fondue-icons": "^0.14.0",
33
+ "@frontify/fondue-icons": "^0.15.0",
34
34
  "@frontify/fondue-tokens": "^4.1.1"
35
35
  },
36
36
  "dependencies": {
@@ -104,8 +104,8 @@
104
104
  "vite-plugin-dts": "^4.5.0",
105
105
  "vite-tsconfig-paths": "^5.1.4",
106
106
  "vitest": "^3.0.4",
107
- "@frontify/fondue-tokens": "^4.1.1",
108
- "@frontify/fondue-icons": "^0.14.0"
107
+ "@frontify/fondue-icons": "^0.15.0",
108
+ "@frontify/fondue-tokens": "^4.1.1"
109
109
  },
110
110
  "scripts": {
111
111
  "build": "vite build",