@frontify/fondue-components 3.3.2 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components18.js +79 -63
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components31.js +1 -1
- package/dist/fondue-components36.js +12 -12
- package/dist/fondue-components39.js +12 -12
- package/dist/fondue-components48.js +66 -58
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +13 -9
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components50.js +60 -41
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components52.js +22 -20
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +1 -1
- package/dist/fondue-components56.js +14 -14
- package/dist/fondue-components59.js +38 -10
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components60.js +10 -38
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components7.js +66 -63
- package/dist/fondue-components7.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,46 +1,65 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { Slot as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { usePreventDropdownOverflow as
|
|
6
|
-
import
|
|
7
|
-
import { recursiveMap as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "@radix-ui/react-popover";
|
|
3
|
+
import { Slot as S } from "@radix-ui/react-slot";
|
|
4
|
+
import { useRef as g, isValidElement as C } from "react";
|
|
5
|
+
import { usePreventDropdownOverflow as M } from "./fondue-components38.js";
|
|
6
|
+
import n from "./fondue-components52.js";
|
|
7
|
+
import { recursiveMap as N, getSelectOptionValue as P } from "./fondue-components59.js";
|
|
8
|
+
const V = ({
|
|
9
|
+
highlightedIndex: p,
|
|
10
|
+
getMenuProps: u,
|
|
11
|
+
getItemProps: m,
|
|
12
|
+
children: f,
|
|
13
|
+
filterText: c,
|
|
14
|
+
selectedItem: r,
|
|
15
|
+
hasInteractedSinceOpening: d
|
|
16
|
+
}) => {
|
|
17
|
+
const s = g(null), { setMaxHeight: v } = M(s), h = (e) => {
|
|
18
|
+
e.preventDefault(), v();
|
|
11
19
|
};
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
return /* @__PURE__ */ t(l.Portal, { children: /* @__PURE__ */ t(l.Content, { onOpenAutoFocus: h, className: n.portal, children: /* @__PURE__ */ t(
|
|
21
|
+
"ul",
|
|
22
|
+
{
|
|
23
|
+
className: n.menu,
|
|
24
|
+
...u(),
|
|
25
|
+
ref: s,
|
|
26
|
+
"data-has-interacted": d ? "true" : "false",
|
|
27
|
+
"data-test-id": "fondue-select-menu",
|
|
28
|
+
children: N(
|
|
29
|
+
f,
|
|
30
|
+
(e, i) => {
|
|
31
|
+
if (((o) => (
|
|
32
|
+
// @ts-expect-error - We are explicitly checking for ref
|
|
33
|
+
C(o) && o.ref !== void 0
|
|
34
|
+
))(e)) {
|
|
35
|
+
const o = P(e.props), a = m({
|
|
36
|
+
item: o,
|
|
37
|
+
index: i,
|
|
38
|
+
...e.ref ? { ref: e.ref } : {}
|
|
39
|
+
});
|
|
40
|
+
return /* @__PURE__ */ t(
|
|
41
|
+
S,
|
|
42
|
+
{
|
|
43
|
+
className: n.item,
|
|
44
|
+
"data-highlighted": p === i,
|
|
45
|
+
"data-selected": (r == null ? void 0 : r.value) === o.value,
|
|
46
|
+
onTouchStart: (O) => {
|
|
47
|
+
a.onClick && a.onClick(O);
|
|
48
|
+
},
|
|
49
|
+
...a,
|
|
50
|
+
children: e
|
|
51
|
+
},
|
|
52
|
+
e.props.value
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
c
|
|
57
|
+
).parsedChildren
|
|
58
|
+
}
|
|
59
|
+
) }) });
|
|
41
60
|
};
|
|
42
|
-
|
|
61
|
+
V.displayName = "Select.Menu";
|
|
43
62
|
export {
|
|
44
|
-
|
|
63
|
+
V as SelectMenu
|
|
45
64
|
};
|
|
46
65
|
//# sourceMappingURL=fondue-components50.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components50.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, useRef, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\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\nexport const SelectMenu = ({
|
|
1
|
+
{"version":3,"file":"fondue-components50.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, useRef, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { usePreventDropdownOverflow } from '#/hooks/usePreventDropdownOverflow';\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 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 selectedItem,\n hasInteractedSinceOpening,\n}: SelectMenuProps) => {\n const ref = useRef<HTMLUListElement | null>(null);\n\n const { setMaxHeight } = usePreventDropdownOverflow(ref);\n\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n setMaxHeight();\n };\n\n return (\n <RadixPopover.Portal>\n <RadixPopover.Content onOpenAutoFocus={handleOnOpenAutoFocus} className={styles.portal}>\n <ul\n className={styles.menu}\n {...getMenuProps()}\n ref={ref}\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 </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","selectedItem","hasInteractedSinceOpening","ref","useRef","setMaxHeight","usePreventDropdownOverflow","handleOnOpenAutoFocus","event","jsx","RadixPopover","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AAsDO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;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;AAAA,IAAA;AAAA,EAAA,EAGd,CAAA,EACJ,CAAA;AAER;AACAL,EAAW,cAAc;"}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
const
|
|
2
|
-
root:
|
|
1
|
+
const n = "_root_1nim9_5", o = "_input_1nim9_59", c = "_slot_1nim9_78", _ = "_clear_1nim9_127", t = "_icons_1nim9_140", s = "_caret_1nim9_146", i = "_iconSuccess_1nim9_168", r = "_iconError_1nim9_174", m = "_menu_1nim9_180", e = "_portal_1nim9_194", a = "_item_1nim9_198", u = "_checkmarkIcon_1nim9_217", l = "_group_1nim9_231", p = {
|
|
2
|
+
root: n,
|
|
3
3
|
input: o,
|
|
4
|
-
slot:
|
|
4
|
+
slot: c,
|
|
5
5
|
clear: _,
|
|
6
|
-
icons:
|
|
6
|
+
icons: t,
|
|
7
7
|
caret: s,
|
|
8
|
-
iconSuccess:
|
|
9
|
-
iconError:
|
|
10
|
-
menu:
|
|
11
|
-
portal:
|
|
12
|
-
item:
|
|
13
|
-
|
|
8
|
+
iconSuccess: i,
|
|
9
|
+
iconError: r,
|
|
10
|
+
menu: m,
|
|
11
|
+
portal: e,
|
|
12
|
+
item: a,
|
|
13
|
+
checkmarkIcon: u,
|
|
14
|
+
group: l
|
|
14
15
|
};
|
|
15
16
|
export {
|
|
16
17
|
s as caret,
|
|
18
|
+
u as checkmarkIcon,
|
|
17
19
|
_ as clear,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
p as default,
|
|
21
|
+
l as group,
|
|
22
|
+
r as iconError,
|
|
23
|
+
i as iconSuccess,
|
|
24
|
+
t as icons,
|
|
23
25
|
o as input,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
a as item,
|
|
27
|
+
m as menu,
|
|
28
|
+
e as portal,
|
|
29
|
+
n as root,
|
|
30
|
+
c as slot
|
|
29
31
|
};
|
|
30
32
|
//# sourceMappingURL=fondue-components52.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components52.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components52.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -3,7 +3,7 @@ import { IconCross as x } from "@frontify/fondue-icons";
|
|
|
3
3
|
import { useState as B, useMemo as i, Children as f, isValidElement as a, cloneElement as E, useCallback as v } from "react";
|
|
4
4
|
import { ForwardedRefSelectItem as F } from "./fondue-components49.js";
|
|
5
5
|
import { ForwardedRefSelectSlot as c } from "./fondue-components51.js";
|
|
6
|
-
import { getSelectOptionValue as I } from "./fondue-
|
|
6
|
+
import { getSelectOptionValue as I } from "./fondue-components59.js";
|
|
7
7
|
const S = (r) => {
|
|
8
8
|
const t = [];
|
|
9
9
|
return f.forEach(r, (o) => {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
const
|
|
2
|
-
root:
|
|
3
|
-
input:
|
|
4
|
-
slot:
|
|
1
|
+
const o = "_root_2iy13_5", t = "_input_2iy13_52", s = "_slot_2iy13_71", _ = "_iconSuccess_2iy13_121", i = "_iconError_2iy13_129", n = "_loadingStatus_2iy13_137", c = "_spin_2iy13_1", r = {
|
|
2
|
+
root: o,
|
|
3
|
+
input: t,
|
|
4
|
+
slot: s,
|
|
5
5
|
iconSuccess: _,
|
|
6
|
-
iconError:
|
|
7
|
-
loadingStatus:
|
|
8
|
-
spin:
|
|
9
|
-
"tw-dark": "_tw-
|
|
6
|
+
iconError: i,
|
|
7
|
+
loadingStatus: n,
|
|
8
|
+
spin: c,
|
|
9
|
+
"tw-dark": "_tw-dark_2iy13_169"
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
12
|
r as default,
|
|
13
|
-
|
|
13
|
+
i as iconError,
|
|
14
14
|
_ as iconSuccess,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
t as input,
|
|
16
|
+
n as loadingStatus,
|
|
17
|
+
o as root,
|
|
18
|
+
s as slot,
|
|
19
|
+
c as spin
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=fondue-components56.js.map
|
|
@@ -1,14 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Children as a, isValidElement as u, cloneElement as f } from "react";
|
|
2
|
+
import { ForwardedRefSelectItem as E } from "./fondue-components49.js";
|
|
3
|
+
const g = ({
|
|
4
|
+
children: r,
|
|
5
|
+
value: o,
|
|
6
|
+
label: s
|
|
7
|
+
}) => r && typeof r == "string" ? {
|
|
8
|
+
value: o || r,
|
|
9
|
+
label: s || r
|
|
10
|
+
} : {
|
|
11
|
+
value: o || "",
|
|
12
|
+
label: s || o || ""
|
|
13
|
+
}, w = (r, o) => u(r) && r.type === o, y = (r, o, s, p = 0) => {
|
|
14
|
+
const n = [];
|
|
15
|
+
let t = 0;
|
|
16
|
+
return a.forEach(r, (e) => {
|
|
17
|
+
if (w(e, E) && u(e))
|
|
18
|
+
g(e.props).label.toLowerCase().includes((s == null ? void 0 : s.toLowerCase()) || "") && (n.push(o(e, p + t)), t++);
|
|
19
|
+
else if (u(e) && (e != null && e.props.children)) {
|
|
20
|
+
const { parsedChildren: m, subElementCount: C } = y(
|
|
21
|
+
e.props.children,
|
|
22
|
+
o,
|
|
23
|
+
"",
|
|
24
|
+
p + t
|
|
25
|
+
);
|
|
26
|
+
e = f(e, {
|
|
27
|
+
children: m,
|
|
28
|
+
key: `group-${p + t}`
|
|
29
|
+
}), n.push(e), t += C;
|
|
30
|
+
} else
|
|
31
|
+
n.push(e);
|
|
32
|
+
}), {
|
|
33
|
+
parsedChildren: n,
|
|
34
|
+
subElementCount: t
|
|
35
|
+
};
|
|
6
36
|
};
|
|
7
37
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_ as default,
|
|
12
|
-
o as root
|
|
38
|
+
g as getSelectOptionValue,
|
|
39
|
+
w as isReactLeaf,
|
|
40
|
+
y as recursiveMap
|
|
13
41
|
};
|
|
14
42
|
//# sourceMappingURL=fondue-components59.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components59.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components59.js","sources":["../src/components/Select/utils.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n Children,\n cloneElement,\n isValidElement,\n type JSXElementConstructor,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { ForwardedRefSelectItem, type SelectItemProps } from './SelectItem';\n\n/**\n * Extracts and returns an object containing `value` and `label` from a given SelectItemProps object.\n * It prioritizes explicit `value` and `label` properties but will fall back to using `children` as the value or label if necessary.\n *\n * @param {SelectItemProps} props - The properties of a select item, which include potential children, value, and label.\n * @returns {{ value: string; label: string }} An object containing `value` and `label` as strings.\n *\n * @example\n * // Returns { value: 'option1', label: 'Option 1' }\n * getSelectOptionValue({ value: 'option1', label: 'Option 1' });\n *\n * @example\n * // Uses children as the value and label when they are not explicitly provided\n * // Returns { value: 'Default', label: 'Default' }\n * getSelectOptionValue({ children: 'Default' });\n */\nexport const getSelectOptionValue = ({\n children,\n value,\n label,\n}: SelectItemProps): {\n value: string;\n label: string;\n} => {\n if (children && typeof children === 'string') {\n return {\n value: value ? value : children,\n label: label ? label : children,\n };\n }\n\n return {\n value: value || '',\n label: label ? label : value || '',\n };\n};\n/**\n * Determines if the child is a leaf node of React, meaning it has one final child of a native type;\n *\n * @param {ReactNode} child - The React child node to check.\n * @param {JSXElementConstructor<never>} Component - The React component constructor used for comparison.\n * @returns {boolean} Returns true if the `child` is a valid React element of the specified `Component` type.\n *\n * @example\n * // Assuming ForwardedRefSelectItem is a component that renders an <input> element\n * // Returns true\n * isReactLeaf(<ForwardedRefSelectItem />, ForwardedRefSelectItem);\n *\n * @example\n * // Returns false for non-matching types or non-leaf components\n * isReactLeaf(<div><ForwardedRefSelectItem /></div>, ForwardedRefSelectItem);\n */\nexport const isReactLeaf = (child: ReactNode, Component: JSXElementConstructor<never>): child is ReactElement =>\n isValidElement(child) && child.type === Component;\n\n/**\n * Recursively maps through React children, applying a callback to each child that meets the specified conditions.\n * This function is useful for deeply nested structures where modifications or checks are needed at multiple levels.\n *\n * @param {ReactNode} children - The children to be recursively processed.\n * @param {function(ReactNode, number): ReactNode} callback - A function that is called for each child that meets the condition. It receives the child and its index, and returns a React node.\n * @param {string} [filterText=''] - Optional text used to filter children based on their properties.\n * @param {number} [nextIndex=0] - The starting index for numbering children, defaults to 0.\n * @returns {{ parsedChildren: ReactNode[], subElementCount: number }} An object containing the transformed children array and the count of all processed sub-elements.\n *\n * @example\n * // Example usage in a select component where only items containing a certain text are modified\n * recursiveMap(children, (child, index) => React.cloneElement(child, { extraProp: 'value' }), 'specific text');\n *\n * @example\n * // Nested structure transformation, adding class names based on index\n * recursiveMap(children, (child, index) => React.cloneElement(child, { className: `item-${index}` }));\n */\nexport const recursiveMap = (\n children: ReactNode,\n callback: (child: ReactNode, nextIndex: number) => ReactNode,\n filterText?: string,\n nextIndex: number = 0,\n): {\n parsedChildren: ReactNode[];\n subElementCount: number;\n} => {\n const resultingChildren: ReactNode[] = [];\n let itemCounter = 0;\n Children.forEach(children, (child) => {\n if (isReactLeaf(child, ForwardedRefSelectItem) && isValidElement<SelectItemProps>(child)) {\n if (\n getSelectOptionValue(child.props)\n .label.toLowerCase()\n .includes(filterText?.toLowerCase() || '')\n ) {\n resultingChildren.push(callback(child, nextIndex + itemCounter));\n itemCounter++;\n }\n } else if (isValidElement<{ children: ReactNode }>(child) && child?.props.children) {\n const { parsedChildren, subElementCount } = recursiveMap(\n child.props.children,\n callback,\n '',\n nextIndex + itemCounter,\n );\n child = cloneElement(child, {\n children: parsedChildren,\n key: `group-${nextIndex + itemCounter}`,\n });\n resultingChildren.push(child);\n itemCounter += subElementCount;\n } else {\n resultingChildren.push(child);\n }\n });\n return {\n parsedChildren: resultingChildren,\n subElementCount: itemCounter,\n };\n};\n"],"names":["getSelectOptionValue","children","value","label","isReactLeaf","child","Component","isValidElement","recursiveMap","callback","filterText","nextIndex","resultingChildren","itemCounter","Children","ForwardedRefSelectItem","parsedChildren","subElementCount","cloneElement"],"mappings":";;AA6BO,MAAMA,IAAuB,CAAC;AAAA,EACjC,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AACJ,MAIQF,KAAY,OAAOA,KAAa,WACzB;AAAA,EACH,OAAOC,KAAgBD;AAAA,EACvB,OAAOE,KAAgBF;AAAA,IAIxB;AAAA,EACH,OAAOC,KAAS;AAAA,EAChB,OAAOC,KAAgBD,KAAS;AAAA,GAmB3BE,IAAc,CAACC,GAAkBC,MAC1CC,EAAeF,CAAK,KAAKA,EAAM,SAASC,GAoB/BE,IAAe,CACxBP,GACAQ,GACAC,GACAC,IAAoB,MAInB;AACD,QAAMC,IAAiC,CAAA;AACvC,MAAIC,IAAc;AACT,SAAAC,EAAA,QAAQb,GAAU,CAACI,MAAU;AAClC,QAAID,EAAYC,GAAOU,CAAsB,KAAKR,EAAgCF,CAAK;AACnF,MACIL,EAAqBK,EAAM,KAAK,EAC3B,MAAM,cACN,UAASK,KAAA,gBAAAA,EAAY,kBAAiB,EAAE,MAE7CE,EAAkB,KAAKH,EAASJ,GAAOM,IAAYE,CAAW,CAAC,GAC/DA;AAAA,aAEGN,EAAwCF,CAAK,MAAKA,KAAA,QAAAA,EAAO,MAAM,WAAU;AAC1E,YAAA,EAAE,gBAAAW,GAAgB,iBAAAC,EAAA,IAAoBT;AAAA,QACxCH,EAAM,MAAM;AAAA,QACZI;AAAA,QACA;AAAA,QACAE,IAAYE;AAAA,MAAA;AAEhB,MAAAR,IAAQa,EAAab,GAAO;AAAA,QACxB,UAAUW;AAAA,QACV,KAAK,SAASL,IAAYE,CAAW;AAAA,MAAA,CACxC,GACDD,EAAkB,KAAKP,CAAK,GACbQ,KAAAI;AAAA,IAAA;AAEf,MAAAL,EAAkB,KAAKP,CAAK;AAAA,EAChC,CACH,GACM;AAAA,IACH,gBAAgBO;AAAA,IAChB,iBAAiBC;AAAA,EAAA;AAEzB;"}
|
|
@@ -1,42 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
label: s
|
|
7
|
-
}) => r && typeof r == "string" ? {
|
|
8
|
-
value: o || r,
|
|
9
|
-
label: s || r
|
|
10
|
-
} : {
|
|
11
|
-
value: o || "",
|
|
12
|
-
label: s || o || ""
|
|
13
|
-
}, w = (r, o) => u(r) && r.type === o, y = (r, o, s, p = 0) => {
|
|
14
|
-
const n = [];
|
|
15
|
-
let t = 0;
|
|
16
|
-
return a.forEach(r, (e) => {
|
|
17
|
-
if (w(e, E) && u(e))
|
|
18
|
-
g(e.props).label.toLowerCase().includes((s == null ? void 0 : s.toLowerCase()) || "") && (n.push(o(e, p + t)), t++);
|
|
19
|
-
else if (u(e) && (e != null && e.props.children)) {
|
|
20
|
-
const { parsedChildren: m, subElementCount: C } = y(
|
|
21
|
-
e.props.children,
|
|
22
|
-
o,
|
|
23
|
-
"",
|
|
24
|
-
p + t
|
|
25
|
-
);
|
|
26
|
-
e = f(e, {
|
|
27
|
-
children: m,
|
|
28
|
-
key: `group-${p + t}`
|
|
29
|
-
}), n.push(e), t += C;
|
|
30
|
-
} else
|
|
31
|
-
n.push(e);
|
|
32
|
-
}), {
|
|
33
|
-
parsedChildren: n,
|
|
34
|
-
subElementCount: t
|
|
35
|
-
};
|
|
1
|
+
const o = "_root_6hy5w_5", c = "_colorName_6hy5w_53", t = "_colorIndicator_6hy5w_57", r = "_caret_6hy5w_63", _ = {
|
|
2
|
+
root: o,
|
|
3
|
+
colorName: c,
|
|
4
|
+
colorIndicator: t,
|
|
5
|
+
caret: r
|
|
36
6
|
};
|
|
37
7
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
r as caret,
|
|
9
|
+
t as colorIndicator,
|
|
10
|
+
c as colorName,
|
|
11
|
+
_ as default,
|
|
12
|
+
o as root
|
|
41
13
|
};
|
|
42
14
|
//# sourceMappingURL=fondue-components60.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components60.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components60.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,95 +1,98 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as o, jsxs as F } from "react/jsx-runtime";
|
|
2
2
|
import { IconCross as w } from "@frontify/fondue-icons";
|
|
3
3
|
import * as i from "@radix-ui/react-dialog";
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import { addAutoFocusAttribute as
|
|
6
|
-
import
|
|
7
|
-
const s = ({ children: t, ...
|
|
8
|
-
|
|
9
|
-
const
|
|
4
|
+
import { createContext as M, forwardRef as l, useContext as S } from "react";
|
|
5
|
+
import { addAutoFocusAttribute as B, addShowFocusRing as H } from "./fondue-components35.js";
|
|
6
|
+
import d from "./fondue-components36.js";
|
|
7
|
+
const s = M({ isModal: !1 }), n = ({ children: t, ...a }) => /* @__PURE__ */ o(s.Provider, { value: { isModal: a.modal ?? !1 }, children: /* @__PURE__ */ o(i.Root, { ...a, children: t }) });
|
|
8
|
+
n.displayName = "Dialog.Root";
|
|
9
|
+
const g = ({ children: t, "data-test-id": a = "fondue-dialog-trigger" }, e) => /* @__PURE__ */ o(
|
|
10
10
|
i.Trigger,
|
|
11
11
|
{
|
|
12
|
-
onMouseDown:
|
|
12
|
+
onMouseDown: B,
|
|
13
13
|
"data-auto-focus-visible": "true",
|
|
14
14
|
"data-auto-focus-trigger": !0,
|
|
15
|
-
"data-test-id":
|
|
15
|
+
"data-test-id": a,
|
|
16
16
|
asChild: !0,
|
|
17
17
|
ref: e,
|
|
18
18
|
children: t
|
|
19
19
|
}
|
|
20
20
|
);
|
|
21
|
-
|
|
22
|
-
const
|
|
21
|
+
g.displayName = "Dialog.Trigger";
|
|
22
|
+
const j = ({ children: t, showUnderlay: a }) => {
|
|
23
|
+
const { isModal: e } = S(s);
|
|
24
|
+
return e ? /* @__PURE__ */ o(i.Overlay, { "data-visible": a, className: d.underlay, children: t }) : /* @__PURE__ */ o("div", { className: d.underlay, "data-visible": a, children: t });
|
|
25
|
+
}, c = ({
|
|
23
26
|
maxWidth: t = "800px",
|
|
24
|
-
minWidth:
|
|
27
|
+
minWidth: a = "400px",
|
|
25
28
|
minHeight: e = "200px",
|
|
26
|
-
padding:
|
|
29
|
+
padding: r = "compact",
|
|
27
30
|
verticalAlign: N = "center",
|
|
28
|
-
"data-test-id":
|
|
31
|
+
"data-test-id": v = "fondue-dialog-content",
|
|
29
32
|
showUnderlay: h = !1,
|
|
30
|
-
children:
|
|
31
|
-
rounded:
|
|
33
|
+
children: x,
|
|
34
|
+
rounded: b = !0,
|
|
32
35
|
...R
|
|
33
|
-
}, T) => /* @__PURE__ */
|
|
36
|
+
}, T) => /* @__PURE__ */ o(i.Portal, { children: /* @__PURE__ */ o(j, { showUnderlay: h, children: /* @__PURE__ */ o(
|
|
34
37
|
i.Content,
|
|
35
38
|
{
|
|
36
39
|
style: {
|
|
37
40
|
"--dialog-max-width": t,
|
|
38
|
-
"--dialog-min-width":
|
|
41
|
+
"--dialog-min-width": a,
|
|
39
42
|
"--dialog-min-height": e
|
|
40
43
|
},
|
|
41
44
|
ref: T,
|
|
42
|
-
className:
|
|
43
|
-
onFocus:
|
|
44
|
-
"data-dialog-rounded":
|
|
45
|
-
"data-dialog-spacing":
|
|
46
|
-
"data-test-id":
|
|
45
|
+
className: d.content,
|
|
46
|
+
onFocus: H,
|
|
47
|
+
"data-dialog-rounded": b,
|
|
48
|
+
"data-dialog-spacing": r,
|
|
49
|
+
"data-test-id": v,
|
|
47
50
|
"data-dialog-vertical-align": N,
|
|
48
51
|
...R,
|
|
49
|
-
children:
|
|
52
|
+
children: x
|
|
50
53
|
}
|
|
51
54
|
) }) });
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
55
|
+
c.displayName = "Dialog.Content";
|
|
56
|
+
const u = ({ children: t, showCloseButton: a = !0, "data-test-id": e = "fondue-dialog-header" }, r) => /* @__PURE__ */ F("div", { "data-test-id": e, ref: r, className: d.header, "data-dialog-layout-component": !0, children: [
|
|
57
|
+
/* @__PURE__ */ o("div", { children: t }),
|
|
58
|
+
a && /* @__PURE__ */ o(i.Close, { role: "button", "data-test-id": `${e}-close`, className: "tw-cursor-pointer", children: /* @__PURE__ */ o(w, { size: 20 }) })
|
|
56
59
|
] });
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
Root:
|
|
72
|
-
Title:
|
|
73
|
-
Description:
|
|
74
|
-
Close:
|
|
75
|
-
Trigger:
|
|
76
|
-
Content:
|
|
77
|
-
Header:
|
|
78
|
-
Footer:
|
|
79
|
-
Body:
|
|
80
|
-
SideContent:
|
|
60
|
+
u.displayName = "Dialog.Header";
|
|
61
|
+
const m = ({ children: t, "data-test-id": a = "fondue-dialog-footer" }, e) => /* @__PURE__ */ o("div", { "data-test-id": a, ref: e, className: d.footer, "data-dialog-layout-component": !0, children: t });
|
|
62
|
+
m.displayName = "Dialog.Footer";
|
|
63
|
+
const p = ({ children: t, "data-test-id": a = "fondue-dialog-body" }, e) => /* @__PURE__ */ o("div", { "data-test-id": a, ref: e, className: d.body, "data-dialog-layout-component": !0, children: t });
|
|
64
|
+
p.displayName = "Dialog.Body";
|
|
65
|
+
const D = ({ children: t, "data-test-id": a = "fondue-dialog-side-content" }, e) => /* @__PURE__ */ o("div", { "data-test-id": a, ref: e, className: d.sideContent, "data-dialog-layout-component": !0, children: t });
|
|
66
|
+
D.displayName = "Dialog.SideContent";
|
|
67
|
+
const y = ({ children: t }) => /* @__PURE__ */ o(i.Close, { asChild: !0, children: t });
|
|
68
|
+
y.displayName = "Dialog.Close";
|
|
69
|
+
const f = ({ children: t, asChild: a }) => /* @__PURE__ */ o(i.Title, { asChild: a, children: t });
|
|
70
|
+
f.displayName = "Dialog.Title";
|
|
71
|
+
const C = ({ children: t, asChild: a }) => /* @__PURE__ */ o(i.Description, { asChild: a, children: t });
|
|
72
|
+
C.displayName = "Dialog.Description";
|
|
73
|
+
const k = {
|
|
74
|
+
Root: n,
|
|
75
|
+
Title: f,
|
|
76
|
+
Description: C,
|
|
77
|
+
Close: y,
|
|
78
|
+
Trigger: l(g),
|
|
79
|
+
Content: l(c),
|
|
80
|
+
Header: l(u),
|
|
81
|
+
Footer: l(m),
|
|
82
|
+
Body: l(p),
|
|
83
|
+
SideContent: l(D)
|
|
81
84
|
};
|
|
82
85
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
k as Dialog,
|
|
87
|
+
p as DialogBody,
|
|
88
|
+
y as DialogClose,
|
|
89
|
+
c as DialogContent,
|
|
90
|
+
C as DialogDescription,
|
|
91
|
+
m as DialogFooter,
|
|
92
|
+
u as DialogHeader,
|
|
93
|
+
n as DialogRoot,
|
|
94
|
+
D as DialogSideContent,
|
|
95
|
+
f as DialogTitle,
|
|
96
|
+
g as DialogTrigger
|
|
94
97
|
};
|
|
95
98
|
//# sourceMappingURL=fondue-components7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components7.js","sources":["../src/components/Dialog/Dialog.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport * as RadixDialog from '@radix-ui/react-dialog';\nimport { forwardRef, type CSSProperties, type ForwardedRef, type ReactNode } from 'react';\n\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport styles from './styles/dialog.module.scss';\n\nexport type DialogRootProps = {\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 dialog\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 type DialogContentProps = {\n /**\n * Add rounded corners to the dialog\n * @default true\n */\n rounded?: boolean;\n /**\n * Define the padding of the dialog\n * @default \"compact\"\n */\n padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';\n /**\n * The vertical alignment of the divider\n * @default \"center\"\n */\n verticalAlign?: 'top' | 'center';\n\n /**\n * Define a maximum width for the dialog\n * @default \"800px\"\n */\n maxWidth?: string;\n /**\n * Define a minimum width for the dialog\n * @default \"400px\"\n */\n minWidth?: string;\n /**\n * Define a maximum height for the dialog\n * @default \"200px\"\n */\n minHeight?: string;\n /**\n * Show a dark underlay behind the dialog\n * @default false\n */\n showUnderlay?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport type DialogTriggerProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogHeaderProps = {\n /**\n * Show a close button in the header\n * @default true\n */\n showCloseButton?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport type DialogFooterProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogBodyProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogSideContentProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogCloseProps = { children?: ReactNode };\n\nexport type DialogAnnouncementProps = { children?: ReactNode; asChild?: boolean };\n\nexport const DialogRoot = ({ children, ...props }: DialogRootProps) => {\n return <RadixDialog.Root {...props}>{children}</RadixDialog.Root>;\n};\nDialogRoot.displayName = 'Dialog.Root';\n\nexport const DialogTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-trigger' }: DialogTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDialog.Trigger\n onMouseDown={addAutoFocusAttribute}\n data-auto-focus-visible=\"true\"\n data-auto-focus-trigger\n data-test-id={dataTestId}\n asChild\n ref={ref}\n >\n {children}\n </RadixDialog.Trigger>\n );\n};\nDialogTrigger.displayName = 'Dialog.Trigger';\n\nexport const DialogContent = (\n {\n maxWidth = '800px',\n minWidth = '400px',\n minHeight = '200px',\n padding = 'compact',\n verticalAlign = 'center',\n 'data-test-id': dataTestId = 'fondue-dialog-content',\n showUnderlay = false,\n children,\n rounded = true,\n ...props\n }: DialogContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDialog.Portal>\n <RadixDialog.Overlay data-visible={showUnderlay} className={styles.underlay}>\n <RadixDialog.Content\n style={\n {\n '--dialog-max-width': maxWidth,\n '--dialog-min-width': minWidth,\n '--dialog-min-height': minHeight,\n } as CSSProperties\n }\n ref={ref}\n className={styles.content}\n onFocus={addShowFocusRing}\n data-dialog-rounded={rounded}\n data-dialog-spacing={padding}\n data-test-id={dataTestId}\n data-dialog-vertical-align={verticalAlign}\n {...props}\n >\n {children}\n </RadixDialog.Content>\n </RadixDialog.Overlay>\n </RadixDialog.Portal>\n );\n};\nDialogContent.displayName = 'Dialog.Content';\n\nexport const DialogHeader = (\n { children, showCloseButton = true, 'data-test-id': dataTestId = 'fondue-dialog-header' }: DialogHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.header} data-dialog-layout-component>\n <div>{children}</div>\n {showCloseButton && (\n <RadixDialog.Close role=\"button\" data-test-id={`${dataTestId}-close`} className=\"tw-cursor-pointer\">\n <IconCross size={20} />\n </RadixDialog.Close>\n )}\n </div>\n );\n};\nDialogHeader.displayName = 'Dialog.Header';\n\nexport const DialogFooter = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-footer' }: DialogFooterProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.footer} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogFooter.displayName = 'Dialog.Footer';\n\nexport const DialogBody = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-body' }: DialogBodyProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.body} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogBody.displayName = 'Dialog.Body';\n\nexport const DialogSideContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-side-content' }: DialogSideContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.sideContent} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogSideContent.displayName = 'Dialog.SideContent';\n\nexport const DialogClose = ({ children }: DialogCloseProps) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>;\n};\nDialogClose.displayName = 'Dialog.Close';\n\nexport const DialogTitle = ({ children, asChild }: DialogAnnouncementProps) => {\n return <RadixDialog.Title asChild={asChild}>{children}</RadixDialog.Title>;\n};\nDialogTitle.displayName = 'Dialog.Title';\n\nexport const DialogDescription = ({ children, asChild }: DialogAnnouncementProps) => {\n return <RadixDialog.Description asChild={asChild}>{children}</RadixDialog.Description>;\n};\nDialogDescription.displayName = 'Dialog.Description';\n\nexport const Dialog = {\n Root: DialogRoot,\n Title: DialogTitle,\n Description: DialogDescription,\n Close: DialogClose,\n Trigger: forwardRef<HTMLButtonElement, DialogTriggerProps>(DialogTrigger),\n Content: forwardRef<HTMLDivElement, DialogContentProps>(DialogContent),\n Header: forwardRef<HTMLDivElement, DialogHeaderProps>(DialogHeader),\n Footer: forwardRef<HTMLDivElement, DialogFooterProps>(DialogFooter),\n Body: forwardRef<HTMLDivElement, DialogBodyProps>(DialogBody),\n SideContent: forwardRef<HTMLDivElement, DialogSideContentProps>(DialogSideContent),\n};\n"],"names":["DialogRoot","children","props","RadixDialog","DialogTrigger","dataTestId","ref","jsx","addAutoFocusAttribute","DialogContent","maxWidth","minWidth","minHeight","padding","verticalAlign","showUnderlay","rounded","styles","addShowFocusRing","DialogHeader","showCloseButton","jsxs","IconCross","DialogFooter","DialogBody","DialogSideContent","DialogClose","DialogTitle","asChild","DialogDescription","Dialog","forwardRef"],"mappings":";;;;;;AA2FO,MAAMA,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAC9BC,EAAY,MAAZ,EAAkB,GAAGD,GAAQ,UAAAD,EAAS,CAAA;AAElDD,EAAW,cAAc;AAEZ,MAAAI,IAAgB,CACzB,EAAE,UAAAH,GAAU,gBAAgBI,IAAa,2BACzCC,MAGI,gBAAAC;AAAA,EAACJ,EAAY;AAAA,EAAZ;AAAA,IACG,aAAaK;AAAA,IACb,2BAAwB;AAAA,IACxB,2BAAuB;AAAA,IACvB,gBAAcH;AAAA,IACd,SAAO;AAAA,IACP,KAAAC;AAAA,IAEC,UAAAL;AAAA,EAAA;AAAA;AAIbG,EAAc,cAAc;AAErB,MAAMK,IAAgB,CACzB;AAAA,EACI,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU;AAAA,EACV,eAAAC,IAAgB;AAAA,EAChB,gBAAgBT,IAAa;AAAA,EAC7B,cAAAU,IAAe;AAAA,EACf,UAAAd;AAAA,EACA,SAAAe,IAAU;AAAA,EACV,GAAGd;AACP,GACAI,MAGK,gBAAAC,EAAAJ,EAAY,QAAZ,EACG,UAAC,gBAAAI,EAAAJ,EAAY,SAAZ,EAAoB,gBAAcY,GAAc,WAAWE,EAAO,UAC/D,UAAA,gBAAAV;AAAA,EAACJ,EAAY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AAxB,GAAU,gBAAgBI,IAAa,gCACzCC,MAGI,gBAAAC,EAAC,OAAI,EAAA,gBAAcF,GAAY,KAAAC,GAAU,WAAWW,EAAO,aAAa,gCAA4B,IAC/F,UAAAhB,EACL,CAAA;AAGRwB,EAAkB,cAAc;AAEzB,MAAMC,IAAc,CAAC,EAAE,UAAAzB,0BAClBE,EAAY,OAAZ,EAAkB,SAAO,IAAE,UAAAF,EAAS,CAAA;AAEhDyB,EAAY,cAAc;AAEnB,MAAMC,IAAc,CAAC,EAAE,UAAA1B,GAAU,SAAA2B,QAC5B,gBAAArB,EAAAJ,EAAY,OAAZ,EAAkB,SAAAyB,GAAmB,UAAA3B,EAAS,CAAA;AAE1D0B,EAAY,cAAc;AAEnB,MAAME,IAAoB,CAAC,EAAE,UAAA5B,GAAU,SAAA2B,QAClC,gBAAArB,EAAAJ,EAAY,aAAZ,EAAwB,SAAAyB,GAAmB,UAAA3B,EAAS,CAAA;AAEhE4B,EAAkB,cAAc;AAEzB,MAAMC,IAAS;AAAA,EAClB,MAAM9B;AAAA,EACN,OAAO2B;AAAA,EACP,aAAaE;AAAA,EACb,OAAOH;AAAA,EACP,SAASK,EAAkD3B,CAAa;AAAA,EACxE,SAAS2B,EAA+CtB,CAAa;AAAA,EACrE,QAAQsB,EAA8CZ,CAAY;AAAA,EAClE,QAAQY,EAA8CR,CAAY;AAAA,EAClE,MAAMQ,EAA4CP,CAAU;AAAA,EAC5D,aAAaO,EAAmDN,CAAiB;AACrF;"}
|
|
1
|
+
{"version":3,"file":"fondue-components7.js","sources":["../src/components/Dialog/Dialog.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport * as RadixDialog from '@radix-ui/react-dialog';\nimport { createContext, forwardRef, useContext, type CSSProperties, type ForwardedRef, type ReactNode } from 'react';\n\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport styles from './styles/dialog.module.scss';\n\nexport type DialogRootProps = {\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 dialog\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 type DialogContentProps = {\n /**\n * Add rounded corners to the dialog\n * @default true\n */\n rounded?: boolean;\n /**\n * Define the padding of the dialog\n * @default \"compact\"\n */\n padding?: 'none' | 'tight' | 'compact' | 'comfortable' | 'spacious';\n /**\n * The vertical alignment of the divider\n * @default \"center\"\n */\n verticalAlign?: 'top' | 'center';\n\n /**\n * Define a maximum width for the dialog\n * @default \"800px\"\n */\n maxWidth?: string;\n /**\n * Define a minimum width for the dialog\n * @default \"400px\"\n */\n minWidth?: string;\n /**\n * Define a maximum height for the dialog\n * @default \"200px\"\n */\n minHeight?: string;\n /**\n * Show a dark underlay behind the dialog\n * @default false\n */\n showUnderlay?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport type DialogTriggerProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogHeaderProps = {\n /**\n * Show a close button in the header\n * @default true\n */\n showCloseButton?: boolean;\n children?: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport type DialogFooterProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogBodyProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogSideContentProps = { children?: ReactNode; 'data-test-id'?: string };\n\nexport type DialogCloseProps = { children?: ReactNode };\n\nexport type DialogAnnouncementProps = { children?: ReactNode; asChild?: boolean };\n\ntype DialogContextType = {\n isModal: boolean;\n};\n\nconst DialogContext = createContext<DialogContextType>({ isModal: false });\n\nexport const DialogRoot = ({ children, ...props }: DialogRootProps) => {\n return (\n <DialogContext.Provider value={{ isModal: props.modal ?? false }}>\n <RadixDialog.Root {...props}>{children}</RadixDialog.Root>\n </DialogContext.Provider>\n );\n};\nDialogRoot.displayName = 'Dialog.Root';\n\nexport const DialogTrigger = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-trigger' }: DialogTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixDialog.Trigger\n onMouseDown={addAutoFocusAttribute}\n data-auto-focus-visible=\"true\"\n data-auto-focus-trigger\n data-test-id={dataTestId}\n asChild\n ref={ref}\n >\n {children}\n </RadixDialog.Trigger>\n );\n};\nDialogTrigger.displayName = 'Dialog.Trigger';\n\nconst DialogUnderlay = ({ children, showUnderlay }: { children: ReactNode; showUnderlay: boolean }) => {\n const { isModal } = useContext(DialogContext);\n if (isModal) {\n return (\n <RadixDialog.Overlay data-visible={showUnderlay} className={styles.underlay}>\n {children}\n </RadixDialog.Overlay>\n );\n }\n return (\n <div className={styles.underlay} data-visible={showUnderlay}>\n {children}\n </div>\n );\n};\n\nexport const DialogContent = (\n {\n maxWidth = '800px',\n minWidth = '400px',\n minHeight = '200px',\n padding = 'compact',\n verticalAlign = 'center',\n 'data-test-id': dataTestId = 'fondue-dialog-content',\n showUnderlay = false,\n children,\n rounded = true,\n ...props\n }: DialogContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <RadixDialog.Portal>\n <DialogUnderlay showUnderlay={showUnderlay}>\n <RadixDialog.Content\n style={\n {\n '--dialog-max-width': maxWidth,\n '--dialog-min-width': minWidth,\n '--dialog-min-height': minHeight,\n } as CSSProperties\n }\n ref={ref}\n className={styles.content}\n onFocus={addShowFocusRing}\n data-dialog-rounded={rounded}\n data-dialog-spacing={padding}\n data-test-id={dataTestId}\n data-dialog-vertical-align={verticalAlign}\n {...props}\n >\n {children}\n </RadixDialog.Content>\n </DialogUnderlay>\n </RadixDialog.Portal>\n );\n};\nDialogContent.displayName = 'Dialog.Content';\n\nexport const DialogHeader = (\n { children, showCloseButton = true, 'data-test-id': dataTestId = 'fondue-dialog-header' }: DialogHeaderProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.header} data-dialog-layout-component>\n <div>{children}</div>\n {showCloseButton && (\n <RadixDialog.Close role=\"button\" data-test-id={`${dataTestId}-close`} className=\"tw-cursor-pointer\">\n <IconCross size={20} />\n </RadixDialog.Close>\n )}\n </div>\n );\n};\nDialogHeader.displayName = 'Dialog.Header';\n\nexport const DialogFooter = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-footer' }: DialogFooterProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.footer} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogFooter.displayName = 'Dialog.Footer';\n\nexport const DialogBody = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-body' }: DialogBodyProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.body} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogBody.displayName = 'Dialog.Body';\n\nexport const DialogSideContent = (\n { children, 'data-test-id': dataTestId = 'fondue-dialog-side-content' }: DialogSideContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={ref} className={styles.sideContent} data-dialog-layout-component>\n {children}\n </div>\n );\n};\nDialogSideContent.displayName = 'Dialog.SideContent';\n\nexport const DialogClose = ({ children }: DialogCloseProps) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>;\n};\nDialogClose.displayName = 'Dialog.Close';\n\nexport const DialogTitle = ({ children, asChild }: DialogAnnouncementProps) => {\n return <RadixDialog.Title asChild={asChild}>{children}</RadixDialog.Title>;\n};\nDialogTitle.displayName = 'Dialog.Title';\n\nexport const DialogDescription = ({ children, asChild }: DialogAnnouncementProps) => {\n return <RadixDialog.Description asChild={asChild}>{children}</RadixDialog.Description>;\n};\nDialogDescription.displayName = 'Dialog.Description';\n\nexport const Dialog = {\n Root: DialogRoot,\n Title: DialogTitle,\n Description: DialogDescription,\n Close: DialogClose,\n Trigger: forwardRef<HTMLButtonElement, DialogTriggerProps>(DialogTrigger),\n Content: forwardRef<HTMLDivElement, DialogContentProps>(DialogContent),\n Header: forwardRef<HTMLDivElement, DialogHeaderProps>(DialogHeader),\n Footer: forwardRef<HTMLDivElement, DialogFooterProps>(DialogFooter),\n Body: forwardRef<HTMLDivElement, DialogBodyProps>(DialogBody),\n SideContent: forwardRef<HTMLDivElement, DialogSideContentProps>(DialogSideContent),\n};\n"],"names":["DialogContext","createContext","DialogRoot","children","props","RadixDialog","DialogTrigger","dataTestId","ref","jsx","addAutoFocusAttribute","DialogUnderlay","showUnderlay","isModal","useContext","styles","DialogContent","maxWidth","minWidth","minHeight","padding","verticalAlign","rounded","addShowFocusRing","DialogHeader","showCloseButton","jsxs","IconCross","DialogFooter","DialogBody","DialogSideContent","DialogClose","DialogTitle","asChild","DialogDescription","Dialog","forwardRef"],"mappings":";;;;;;AA+FA,MAAMA,IAAgBC,EAAiC,EAAE,SAAS,GAAO,CAAA,GAE5DC,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAEjCJ,EAAc,UAAd,EAAuB,OAAO,EAAE,SAASI,EAAM,SAAS,GAAM,GAC3D,4BAACC,EAAY,MAAZ,EAAkB,GAAGD,GAAQ,UAAAD,GAAS,EAC3C,CAAA;AAGRD,EAAW,cAAc;AAEZ,MAAAI,IAAgB,CACzB,EAAE,UAAAH,GAAU,gBAAgBI,IAAa,2BACzCC,MAGI,gBAAAC;AAAA,EAACJ,EAAY;AAAA,EAAZ;AAAA,IACG,aAAaK;AAAA,IACb,2BAAwB;AAAA,IACxB,2BAAuB;AAAA,IACvB,gBAAcH;AAAA,IACd,SAAO;AAAA,IACP,KAAAC;AAAA,IAEC,UAAAL;AAAA,EAAA;AAAA;AAIbG,EAAc,cAAc;AAE5B,MAAMK,IAAiB,CAAC,EAAE,UAAAR,GAAU,cAAAS,QAAmE;AACnG,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAWd,CAAa;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