@frontify/fondue-components 20.0.0-beta.4 → 20.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components10.js.map +1 -1
- package/dist/fondue-components13.js +49 -48
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components25.js +39 -39
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components28.js +33 -32
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components31.js +4 -4
- package/dist/fondue-components32.js +2 -2
- package/dist/fondue-components37.js +2 -2
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +1 -1
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +1 -1
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components40.js +1 -1
- package/dist/fondue-components42.js +1 -1
- package/dist/fondue-components48.js +4 -4
- package/dist/fondue-components50.js +4 -5
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components52.js +12 -12
- package/dist/fondue-components54.js +8 -10
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components56.js +17 -18
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components59.js +6 -6
- package/dist/fondue-components62.js +9 -9
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components67.js +26 -26
- package/dist/fondue-components69.js +8 -8
- package/dist/fondue-components70.js +12 -12
- package/dist/fondue-components72.js +6 -6
- package/dist/fondue-components75.js +6 -6
- package/dist/fondue-components76.js +22 -23
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +8 -8
- package/dist/fondue-components79.js +4 -4
- package/dist/fondue-components80.js +2 -5
- package/dist/fondue-components80.js.map +1 -1
- package/dist/fondue-components81.js +4 -4
- package/dist/fondue-components81.js.map +1 -1
- package/dist/fondue-components82.js +4 -16
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +17 -2
- package/dist/fondue-components83.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components10.js","sources":["../src/components/Divider/Divider.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as Separator from '@radix-ui/react-separator';\nimport { forwardRef, type ForwardedRef, type ReactElement } from 'react';\n\nimport { cn } from '#/utilities/styleUtilities';\n\nimport borderStyles from './styles/borderStyles.module.scss';\nimport { dividerStyles } from './styles/dividerStyles';\n\ntype DividerStyle = 'noline' | 'dashed' | 'solid';\ntype DividerPadding = 'none' | 'small' | 'medium' | 'large';\ntype DividerDirection = 'horizontal' | 'vertical';\ntype DividerColor = 'weak' | 'default' | 'strong'
|
|
1
|
+
{"version":3,"file":"fondue-components10.js","sources":["../src/components/Divider/Divider.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as Separator from '@radix-ui/react-separator';\nimport { forwardRef, type ForwardedRef, type ReactElement } from 'react';\n\nimport { cn } from '#/utilities/styleUtilities';\n\nimport borderStyles from './styles/borderStyles.module.scss';\nimport { dividerStyles } from './styles/dividerStyles';\n\ntype DividerStyle = 'noline' | 'dashed' | 'solid';\ntype DividerPadding = 'none' | 'small' | 'medium' | 'large';\ntype DividerDirection = 'horizontal' | 'vertical';\ntype DividerColor = 'weak' | 'default' | 'strong';\n\nexport type DividerProps = {\n /**\n * The style of the divider\n * @default \"solid\"\n */\n variant?: DividerStyle;\n /**\n * The padding of the divider\n * @default \"medium\"\n */\n padding?: DividerPadding;\n /**\n * The color of the divider\n * @default \"default\"\n */\n color?: DividerColor;\n /**\n * The direction of the divider\n * @default \"horizontal\"\n */\n direction?: DividerDirection;\n /**\n * The html element to be used\n * @default \"div\"\n */\n as?: 'div' | 'li';\n /**\n * When `true`, signifies that it is purely visual, carries no semantic\n * meaning, and ensures it is not present in the accessibility tree.\n * @default false\n */\n decorative?: boolean;\n 'data-test-id'?: string;\n className?: string;\n};\n\nexport const Divider = forwardRef<HTMLDivElement, DividerProps>(\n (\n {\n 'data-test-id': dataTestId = 'fondue-divider',\n direction = 'horizontal',\n className,\n variant,\n as = 'div',\n decorative,\n ...props\n }: DividerProps,\n ref: ForwardedRef<HTMLDivElement | null>,\n ): ReactElement => {\n const Component = as;\n\n return (\n <Separator.Root\n ref={ref}\n className={cn(\n dividerStyles({\n direction,\n variant,\n ...props,\n }),\n borderStyles.root,\n className,\n )}\n data-variant={variant}\n data-test-id={dataTestId}\n decorative={decorative}\n data-orientation={direction}\n asChild\n >\n <Component />\n </Separator.Root>\n );\n },\n);\n\nDivider.displayName = 'Divider';\n"],"names":["Divider","forwardRef","dataTestId","direction","className","variant","as","decorative","props","ref","Component","jsx","Separator","cn","dividerStyles","borderStyles"],"mappings":";;;;;;AAmDO,MAAMA,IAAUC;AAAA,EACnB,CACI;AAAA,IACI,gBAAgBC,IAAa;AAAA,IAC7B,WAAAC,IAAY;AAAA,IACZ,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,IAAAC,IAAK;AAAA,IACL,YAAAC;AAAA,IACA,GAAGC;AAAA,KAEPC,MACe;AACf,UAAMC,IAAYJ;AAGd,WAAA,gBAAAK;AAAA,MAACC,EAAU;AAAA,MAAV;AAAA,QACG,KAAAH;AAAA,QACA,WAAWI;AAAA,UACPC,EAAc;AAAA,YACV,WAAAX;AAAA,YACA,SAAAE;AAAA,YACA,GAAGG;AAAA,UAAA,CACN;AAAA,UACDO,EAAa;AAAA,UACbX;AAAA,QACJ;AAAA,QACA,gBAAcC;AAAA,QACd,gBAAcH;AAAA,QACd,YAAAK;AAAA,QACA,oBAAkBJ;AAAA,QAClB,SAAO;AAAA,QAEP,4BAACO,GAAU,CAAA,CAAA;AAAA,MAAA;AAAA,IACf;AAAA,EAAA;AAGZ;AAEAV,EAAQ,cAAc;"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { IconCross as
|
|
3
|
-
import * as
|
|
4
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { IconCross as b } from "@frontify/fondue-icons";
|
|
3
|
+
import * as i from "@radix-ui/react-popover";
|
|
4
|
+
import { forwardRef as r } from "react";
|
|
5
5
|
import { addAutoFocusAttribute as w, addShowFocusRing as x } from "./fondue-components47.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
6
|
+
import { Button as A } from "./fondue-components6.js";
|
|
7
|
+
import { useFondueTheme as T, ThemeProvider as I } from "./fondue-components29.js";
|
|
8
|
+
import l from "./fondue-components54.js";
|
|
9
|
+
const n = ({ children: t, ...o }) => /* @__PURE__ */ e(i.Root, { ...o, children: t });
|
|
9
10
|
n.displayName = "Flyout.Root";
|
|
10
|
-
const c = ({ asChild: t = !0, children: o, "data-test-id":
|
|
11
|
-
|
|
11
|
+
const c = ({ asChild: t = !0, children: o, "data-test-id": a = "fondue-flyout-trigger", ...d }, s) => /* @__PURE__ */ e(
|
|
12
|
+
i.Trigger,
|
|
12
13
|
{
|
|
13
14
|
onMouseDown: w,
|
|
14
15
|
"data-auto-focus-visible": "true",
|
|
15
16
|
"data-auto-focus-trigger": !0,
|
|
16
|
-
"data-test-id":
|
|
17
|
+
"data-test-id": a,
|
|
17
18
|
asChild: t,
|
|
18
|
-
ref:
|
|
19
|
+
ref: s,
|
|
19
20
|
...d,
|
|
20
21
|
children: o
|
|
21
22
|
}
|
|
22
23
|
);
|
|
23
24
|
c.displayName = "Flyout.Trigger";
|
|
24
|
-
const
|
|
25
|
+
const B = {
|
|
25
26
|
compact: 8,
|
|
26
27
|
comfortable: 12,
|
|
27
28
|
spacious: 16
|
|
@@ -31,35 +32,35 @@ const I = {
|
|
|
31
32
|
}, m = ({
|
|
32
33
|
align: t = "start",
|
|
33
34
|
maxWidth: o = "360px",
|
|
34
|
-
padding:
|
|
35
|
+
padding: a = "compact",
|
|
35
36
|
rounded: d = "medium",
|
|
36
|
-
width:
|
|
37
|
+
width: s = "fit-content",
|
|
37
38
|
shadow: F = "medium",
|
|
38
39
|
triggerOffset: g = "compact",
|
|
39
|
-
viewportCollisionPadding:
|
|
40
|
-
"data-test-id":
|
|
40
|
+
viewportCollisionPadding: h = "compact",
|
|
41
|
+
"data-test-id": N = "fondue-flyout-content",
|
|
41
42
|
children: v,
|
|
42
43
|
...C
|
|
43
44
|
}, P) => {
|
|
44
|
-
const
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
|
|
45
|
+
const R = T();
|
|
46
|
+
return /* @__PURE__ */ e(i.Portal, { children: /* @__PURE__ */ u(I, { theme: R, children: [
|
|
47
|
+
/* @__PURE__ */ e("div", { "data-test-id": "fondue-flyout-overlay", className: l.overlay }),
|
|
48
|
+
/* @__PURE__ */ e(
|
|
49
|
+
i.Content,
|
|
49
50
|
{
|
|
50
51
|
style: {
|
|
51
52
|
"--flyout-max-width": o,
|
|
52
|
-
"--flyout-width":
|
|
53
|
+
"--flyout-width": s
|
|
53
54
|
},
|
|
54
55
|
ref: P,
|
|
55
56
|
align: t,
|
|
56
|
-
collisionPadding: O[
|
|
57
|
-
sideOffset:
|
|
58
|
-
className:
|
|
59
|
-
"data-flyout-spacing":
|
|
57
|
+
collisionPadding: O[h],
|
|
58
|
+
sideOffset: B[g],
|
|
59
|
+
className: l.root,
|
|
60
|
+
"data-flyout-spacing": a,
|
|
60
61
|
"data-rounded": d,
|
|
61
62
|
"data-shadow": F,
|
|
62
|
-
"data-test-id":
|
|
63
|
+
"data-test-id": N,
|
|
63
64
|
onFocus: x,
|
|
64
65
|
...C,
|
|
65
66
|
children: v
|
|
@@ -68,45 +69,45 @@ const I = {
|
|
|
68
69
|
] }) });
|
|
69
70
|
};
|
|
70
71
|
m.displayName = "Flyout.Content";
|
|
71
|
-
const y = ({ showCloseButton: t, children: o, "data-test-id":
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
t && /* @__PURE__ */
|
|
74
|
-
|
|
72
|
+
const y = ({ showCloseButton: t, children: o, "data-test-id": a = "fondue-flyout-header", closeProps: d }, s) => /* @__PURE__ */ u("div", { "data-test-id": a, ref: s, className: l.header, children: [
|
|
73
|
+
/* @__PURE__ */ e("div", { children: o }),
|
|
74
|
+
t && /* @__PURE__ */ e(i.Close, { asChild: !0, ...d, children: /* @__PURE__ */ e(
|
|
75
|
+
A,
|
|
75
76
|
{
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
77
|
+
size: "small",
|
|
78
|
+
aspect: "square",
|
|
79
|
+
emphasis: "weak",
|
|
79
80
|
"aria-label": "Close",
|
|
80
|
-
|
|
81
|
-
children: /* @__PURE__ */
|
|
81
|
+
"data-test-id": `${a}-close`,
|
|
82
|
+
children: /* @__PURE__ */ e(b, { size: 20 })
|
|
82
83
|
}
|
|
83
|
-
)
|
|
84
|
+
) })
|
|
84
85
|
] });
|
|
85
86
|
y.displayName = "Flyout.Header";
|
|
86
|
-
const f = ({ children: t, "data-test-id": o = "fondue-flyout-footer" },
|
|
87
|
+
const f = ({ children: t, "data-test-id": o = "fondue-flyout-footer" }, a) => /* @__PURE__ */ e("div", { "data-test-id": o, ref: a, className: l.footer, children: t });
|
|
87
88
|
f.displayName = "Flyout.Footer";
|
|
88
|
-
const p = ({ children: t, "data-test-id": o = "fondue-flyout-body", scrollable:
|
|
89
|
+
const p = ({ children: t, "data-test-id": o = "fondue-flyout-body", scrollable: a = !1 }, d) => /* @__PURE__ */ e(
|
|
89
90
|
"div",
|
|
90
91
|
{
|
|
91
92
|
"data-test-id": o,
|
|
92
93
|
ref: d,
|
|
93
94
|
"data-flyout-spacing": "compact",
|
|
94
|
-
"data-scrollable":
|
|
95
|
-
className:
|
|
95
|
+
"data-scrollable": a,
|
|
96
|
+
className: l.body,
|
|
96
97
|
children: t
|
|
97
98
|
}
|
|
98
99
|
);
|
|
99
100
|
p.displayName = "Flyout.Body";
|
|
100
|
-
const
|
|
101
|
+
const G = {
|
|
101
102
|
Root: n,
|
|
102
|
-
Trigger:
|
|
103
|
-
Content:
|
|
104
|
-
Header:
|
|
105
|
-
Footer:
|
|
106
|
-
Body:
|
|
103
|
+
Trigger: r(c),
|
|
104
|
+
Content: r(m),
|
|
105
|
+
Header: r(y),
|
|
106
|
+
Footer: r(f),
|
|
107
|
+
Body: r(p)
|
|
107
108
|
};
|
|
108
109
|
export {
|
|
109
|
-
|
|
110
|
+
G as Flyout,
|
|
110
111
|
p as FlyoutBody,
|
|
111
112
|
m as FlyoutContent,
|
|
112
113
|
f as FlyoutFooter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components13.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 { type CommonAriaProps } from '#/helpers/aria';\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 data-test-id=\"fondue-flyout-overlay\" 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 closeProps?: CommonAriaProps;\n};\n\nexport const FlyoutHeader = (\n { showCloseButton, children, 'data-test-id': dataTestId = 'fondue-flyout-header', closeProps }: 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\n role=\"button\"\n data-test-id={`${dataTestId}-close`}\n className={styles.close}\n aria-label=\"Close\"\n {...closeProps}\n >\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","closeProps","IconCross","FlyoutFooter","FlyoutBody","scrollable","Flyout","forwardRef"],"mappings":";;;;;;;AA+BO,MAAMA,IAAa,CAAC,EAAE,UAAA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AAAA,IAEjB,UAAAxB;AAAA,EAAA;AACL;AAGR+B,EAAW,cAAc;AAElB,MAAME,IAAS;AAAA,EAClB,MAAMlC;AAAA,EACN,SAASmC,EAAkD/B,CAAa;AAAA,EACxE,SAAS+B,EAA+CvB,CAAa;AAAA,EACrE,QAAQuB,EAA8CR,CAAY;AAAA,EAClE,QAAQQ,EAA8CJ,CAAY;AAAA,EAClE,MAAMI,EAA4CH,CAAU;AAChE;"}
|
|
1
|
+
{"version":3,"file":"fondue-components13.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 { type CommonAriaProps } from '#/helpers/aria';\nimport { addAutoFocusAttribute, addShowFocusRing } from '#/utilities/domUtilities';\n\nimport { Button } from '../Button/Button';\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 data-test-id=\"fondue-flyout-overlay\" 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 closeProps?: CommonAriaProps;\n};\n\nexport const FlyoutHeader = (\n { showCloseButton, children, 'data-test-id': dataTestId = 'fondue-flyout-header', closeProps }: 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 asChild {...closeProps}>\n <Button\n size=\"small\"\n aspect=\"square\"\n emphasis=\"weak\"\n aria-label=\"Close\"\n data-test-id={`${dataTestId}-close`}\n >\n <IconCross size={20} />\n </Button>\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","closeProps","Button","IconCross","FlyoutFooter","FlyoutBody","scrollable","Flyout","forwardRef"],"mappings":";;;;;;;;AAgCO,MAAMA,IAAa,CAAC,EAAE,UAAAC,GAAU,GAAGC,0BAC9BC,EAAa,MAAb,EAAmB,GAAGD,GAAQ,UAAAD,GAAS;AAEnDD,EAAW,cAAc;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AAGRgC,EAAW,cAAc;AAElB,MAAME,IAAS;AAAA,EAClB,MAAMnC;AAAA,EACN,SAASoC,EAAkDhC,CAAa;AAAA,EACxE,SAASgC,EAA+CxB,CAAa;AAAA,EACrE,QAAQwB,EAA8CT,CAAY;AAAA,EAClE,QAAQS,EAA8CJ,CAAY;AAAA,EAClE,MAAMI,EAA4CH,CAAU;AAChE;"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
2
2
|
import { IconArrowUp as A, IconArrowDown as K, IconArrowBidirectional as h } from "@frontify/fondue-icons";
|
|
3
3
|
import { forwardRef as b, useRef as w, useMemo as j } from "react";
|
|
4
|
-
import { useSyncRefs as
|
|
5
|
-
import { useTextTruncation as
|
|
4
|
+
import { useSyncRefs as N } from "./fondue-components46.js";
|
|
5
|
+
import { useTextTruncation as g } from "./fondue-components71.js";
|
|
6
6
|
import { Box as L } from "./fondue-components5.js";
|
|
7
7
|
import { LoadingCircle as S } from "./fondue-components18.js";
|
|
8
|
-
import
|
|
8
|
+
import o from "./fondue-components72.js";
|
|
9
9
|
import { handleKeyDown as $, shouldIgnoreRowClick as D } from "./fondue-components73.js";
|
|
10
10
|
const R = b(
|
|
11
|
-
({ layout: a = "auto", fontSize: e = "medium", sticky:
|
|
11
|
+
({ layout: a = "auto", fontSize: e = "medium", sticky: d, children: s, ...i }, l) => /* @__PURE__ */ t("div", { onKeyDown: $, role: "grid", tabIndex: -1, children: /* @__PURE__ */ t(
|
|
12
12
|
"table",
|
|
13
13
|
{
|
|
14
14
|
ref: l,
|
|
15
|
-
className:
|
|
15
|
+
className: o.table,
|
|
16
16
|
"data-layout": a,
|
|
17
17
|
"data-font-size": e,
|
|
18
|
-
"data-sticky":
|
|
19
|
-
...
|
|
18
|
+
"data-sticky": d,
|
|
19
|
+
...i,
|
|
20
20
|
children: s
|
|
21
21
|
}
|
|
22
22
|
) })
|
|
23
23
|
);
|
|
24
24
|
R.displayName = "Table.Root";
|
|
25
|
-
const C = b(({ children: a }, e) => /* @__PURE__ */ t("caption", { ref: e, className:
|
|
25
|
+
const C = b(({ children: a }, e) => /* @__PURE__ */ t("caption", { ref: e, className: o.caption, children: a }));
|
|
26
26
|
C.displayName = "Table.Caption";
|
|
27
27
|
const x = b(
|
|
28
|
-
({ children: a, "aria-label": e, "aria-busy":
|
|
28
|
+
({ children: a, "aria-label": e, "aria-busy": d }, s) => /* @__PURE__ */ t("thead", { ref: s, className: o.header, "aria-label": e, "aria-busy": d, children: a })
|
|
29
29
|
);
|
|
30
30
|
x.displayName = "Table.Header";
|
|
31
31
|
const v = b(
|
|
32
32
|
({
|
|
33
33
|
noShrink: a = !1,
|
|
34
34
|
truncate: e = !1,
|
|
35
|
-
align:
|
|
35
|
+
align: d = "left",
|
|
36
36
|
scope: s = "col",
|
|
37
|
-
sortTranslations:
|
|
37
|
+
sortTranslations: i,
|
|
38
38
|
sortDirection: l,
|
|
39
39
|
colSpan: c,
|
|
40
40
|
width: m,
|
|
@@ -44,8 +44,8 @@ const v = b(
|
|
|
44
44
|
children: r
|
|
45
45
|
}, H) => {
|
|
46
46
|
const y = w(null);
|
|
47
|
-
|
|
48
|
-
const z = j(() => typeof r == "string" ? l === "ascending" ? (
|
|
47
|
+
N(y, H), g(y);
|
|
48
|
+
const z = j(() => typeof r == "string" ? l === "ascending" ? (i == null ? void 0 : i.sortDescending) ?? `Sort by ${r} descending` : (i == null ? void 0 : i.sortAscending) ?? `Sort by ${r} ascending` : l === "ascending" ? "Sort descending" : "Sort ascending", [r, l, i]), B = () => {
|
|
49
49
|
if (!n)
|
|
50
50
|
return;
|
|
51
51
|
n(l === void 0 || l === "descending" ? "ascending" : "descending");
|
|
@@ -55,27 +55,27 @@ const v = b(
|
|
|
55
55
|
{
|
|
56
56
|
ref: y,
|
|
57
57
|
style: { width: m },
|
|
58
|
-
className:
|
|
58
|
+
className: o.headerCell,
|
|
59
59
|
scope: s,
|
|
60
60
|
colSpan: c,
|
|
61
|
-
"data-align":
|
|
61
|
+
"data-align": d,
|
|
62
62
|
"data-truncate": e,
|
|
63
63
|
"data-no-shrink": a,
|
|
64
64
|
"data-sortable": !!n,
|
|
65
65
|
"aria-sort": n ? l || "none" : void 0,
|
|
66
|
-
children: f === "loading" ? /* @__PURE__ */ p("div", { className:
|
|
67
|
-
typeof r == "string" && e ? /* @__PURE__ */ t("span", { className:
|
|
66
|
+
children: f === "loading" ? /* @__PURE__ */ p("div", { className: o.cellContent, "aria-live": "polite", "aria-label": u, children: [
|
|
67
|
+
typeof r == "string" && e ? /* @__PURE__ */ t("span", { className: o.buttonText, children: r }) : r,
|
|
68
68
|
/* @__PURE__ */ t(S, { "data-test-id": "fondue-loading-circle", size: "xx-small" })
|
|
69
69
|
] }) : n ? /* @__PURE__ */ p(
|
|
70
70
|
"button",
|
|
71
71
|
{
|
|
72
|
-
className:
|
|
72
|
+
className: o.cellContent,
|
|
73
73
|
"aria-label": z,
|
|
74
74
|
"data-active": !!l,
|
|
75
75
|
onClick: B,
|
|
76
76
|
children: [
|
|
77
|
-
typeof r == "string" && e ? /* @__PURE__ */ t("span", { className:
|
|
78
|
-
/* @__PURE__ */ t(L, { width: 3, children: l === "ascending" ? /* @__PURE__ */ t(A, { size: "12" }) : l === "descending" ? /* @__PURE__ */ t(K, { size: "12" }) : /* @__PURE__ */ t(h, { className:
|
|
77
|
+
typeof r == "string" && e ? /* @__PURE__ */ t("span", { className: o.buttonText, children: r }) : r,
|
|
78
|
+
/* @__PURE__ */ t(L, { width: 3, children: l === "ascending" ? /* @__PURE__ */ t(A, { className: o.sortIndicator, size: "12" }) : l === "descending" ? /* @__PURE__ */ t(K, { className: o.sortIndicator, size: "12" }) : /* @__PURE__ */ t(h, { className: o.sortIndicator, size: "12" }) })
|
|
79
79
|
]
|
|
80
80
|
}
|
|
81
81
|
) : r
|
|
@@ -84,14 +84,14 @@ const v = b(
|
|
|
84
84
|
}
|
|
85
85
|
);
|
|
86
86
|
v.displayName = "Table.HeaderCell";
|
|
87
|
-
const T = b(
|
|
88
|
-
({ children: a, "aria-busy": e }, o) => /* @__PURE__ */ t("tbody", { ref: o, className: i.body, "aria-busy": e, children: a })
|
|
89
|
-
);
|
|
90
|
-
T.displayName = "Table.Body";
|
|
91
87
|
const I = b(
|
|
92
|
-
({
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
({ children: a, "aria-busy": e }, d) => /* @__PURE__ */ t("tbody", { ref: d, className: o.body, "aria-busy": e, children: a })
|
|
89
|
+
);
|
|
90
|
+
I.displayName = "Table.Body";
|
|
91
|
+
const T = b(
|
|
92
|
+
({ disabled: a = !1, selected: e = !1, onClick: d, children: s, "aria-label": i, "data-test-id": l }, c) => {
|
|
93
|
+
const m = d !== void 0 && !a, f = (n) => {
|
|
94
|
+
a || D(n) || d && d(e);
|
|
95
95
|
}, u = (n) => {
|
|
96
96
|
m && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), f());
|
|
97
97
|
};
|
|
@@ -99,14 +99,14 @@ const I = b(
|
|
|
99
99
|
"tr",
|
|
100
100
|
{
|
|
101
101
|
ref: c,
|
|
102
|
-
className:
|
|
102
|
+
className: o.row,
|
|
103
103
|
tabIndex: 0,
|
|
104
104
|
role: m ? "button" : "row",
|
|
105
105
|
"data-disabled": a,
|
|
106
106
|
"data-interactive": m,
|
|
107
107
|
"data-selected": e,
|
|
108
108
|
"aria-disabled": a,
|
|
109
|
-
"aria-label":
|
|
109
|
+
"aria-label": i,
|
|
110
110
|
"aria-selected": e,
|
|
111
111
|
onClick: m ? f : void 0,
|
|
112
112
|
onKeyDown: m ? u : void 0,
|
|
@@ -116,19 +116,19 @@ const I = b(
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
|
-
|
|
119
|
+
T.displayName = "Table.Row";
|
|
120
120
|
const k = b(
|
|
121
|
-
({ colSpan: a, truncate: e, align:
|
|
121
|
+
({ colSpan: a, truncate: e, align: d = "left", children: s, "aria-label": i }, l) => {
|
|
122
122
|
const c = w(null);
|
|
123
|
-
return
|
|
123
|
+
return N(c, l), g(c), /* @__PURE__ */ t(
|
|
124
124
|
"td",
|
|
125
125
|
{
|
|
126
126
|
ref: c,
|
|
127
|
-
className:
|
|
127
|
+
className: o.rowCell,
|
|
128
128
|
colSpan: a,
|
|
129
|
-
"data-align":
|
|
129
|
+
"data-align": d,
|
|
130
130
|
"data-truncate": e,
|
|
131
|
-
"aria-label":
|
|
131
|
+
"aria-label": i,
|
|
132
132
|
children: s
|
|
133
133
|
}
|
|
134
134
|
);
|
|
@@ -140,18 +140,18 @@ const V = {
|
|
|
140
140
|
Caption: C,
|
|
141
141
|
Header: x,
|
|
142
142
|
HeaderCell: v,
|
|
143
|
-
Body:
|
|
144
|
-
Row:
|
|
143
|
+
Body: I,
|
|
144
|
+
Row: T,
|
|
145
145
|
RowCell: k
|
|
146
146
|
};
|
|
147
147
|
export {
|
|
148
148
|
V as Table,
|
|
149
|
-
|
|
149
|
+
I as TableBody,
|
|
150
150
|
C as TableCaption,
|
|
151
151
|
x as TableHeader,
|
|
152
152
|
v as TableHeaderCell,
|
|
153
153
|
R as TableRoot,
|
|
154
|
-
|
|
154
|
+
T as TableRow,
|
|
155
155
|
k as TableRowCell
|
|
156
156
|
};
|
|
157
157
|
//# sourceMappingURL=fondue-components25.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components25.js","sources":["../src/components/Table/Table.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconArrowBidirectional, IconArrowDown, IconArrowUp } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useMemo,\n useRef,\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { useSyncRefs } from '#/hooks/useSyncRefs';\nimport { useTextTruncation } from '#/hooks/useTextTruncation';\nimport { type CommonAriaAttrs } from '#/utilities/types';\n\nimport { Box } from '../Box/Box';\nimport { LoadingCircle } from '../LoadingCircle/LoadingCircle';\n\nimport styles from './styles/table.module.scss';\nimport { handleKeyDown, shouldIgnoreRowClick } from './utils';\n\ntype TableRootProps = {\n /**\n * Whether the table should have a fixed or auto layout\n * @default 'auto'\n */\n layout?: 'auto' | 'fixed';\n /**\n * Font size of the table content\n * @default 'small'\n */\n fontSize?: 'small' | 'medium';\n /**\n * Whether header should stick to the top when scrolling\n */\n sticky?: 'head' | 'col' | 'both';\n children: ReactNode;\n} & CommonAriaAttrs;\n\nexport const TableRoot = forwardRef<HTMLTableElement, TableRootProps>(\n ({ layout = 'auto', fontSize = 'medium', sticky, children, ...props }, ref) => {\n return (\n <div onKeyDown={handleKeyDown} role=\"grid\" tabIndex={-1}>\n <table\n ref={ref}\n className={styles.table}\n data-layout={layout}\n data-font-size={fontSize}\n data-sticky={sticky}\n {...props}\n >\n {children}\n </table>\n </div>\n );\n },\n);\nTableRoot.displayName = 'Table.Root';\n\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, { children: ReactNode }>(({ children }, ref) => {\n return (\n <caption ref={ref} className={styles.caption}>\n {children}\n </caption>\n );\n});\nTableCaption.displayName = 'Table.Caption';\n\ntype TableHeaderProps = {\n children: ReactNode;\n 'aria-label'?: string;\n 'aria-busy'?: boolean;\n};\n\nexport const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>(\n ({ children, 'aria-label': ariaLabel, 'aria-busy': ariaBusy }, ref) => {\n return (\n <thead ref={ref} className={styles.header} aria-label={ariaLabel} aria-busy={ariaBusy}>\n {children}\n </thead>\n );\n },\n);\nTableHeader.displayName = 'Table.Header';\n\ntype SortDirection = 'ascending' | 'descending' | undefined;\ntype HorizontalAlignment = 'left' | 'center' | 'right';\n\ntype TableHeaderCellProps = {\n /**\n * Scope of the column\n * @default 'col'\n */\n scope?: HTMLTableCellElement['scope'];\n /**\n * Number of columns the cell should span\n */\n colSpan?: HTMLTableCellElement['colSpan'];\n /**\n * Width of the column\n */\n width?: CSSProperties['width'];\n /**\n * Current sort direction of the column\n */\n sortDirection?: SortDirection;\n /**\n * Horizontal alignment of the content\n * @default 'left'\n */\n align?: HorizontalAlignment;\n /**\n * Whether to truncate content with ellipsis when it overflows\n * @default false\n */\n truncate?: boolean;\n /**\n * Aria label for asceding/descending sort. Variables: {column} - column name\n * @default \"Sort by {column} ascending/descending\"\n */\n sortTranslations?: {\n sortAscending?: string;\n sortDescending?: string;\n };\n /**\n * Whether the column should have a minimum width\n * @default false\n */\n noShrink?: boolean;\n /**\n * State of the cell, used for displaying loading state\n * @default 'idle'\n */\n state?: 'idle' | 'loading';\n /**\n * The aria-label to be applied when state='loading'\n */\n loadingStateAriaLabel?: string;\n /**\n * Handler called when the sort direction changes\n * @param direction - The new sort direction\n */\n onSortChange?: (direction: SortDirection) => void;\n children: ReactNode;\n};\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n (\n {\n noShrink = false,\n truncate = false,\n align = 'left',\n scope = 'col',\n sortTranslations,\n sortDirection,\n colSpan,\n width,\n state = 'idle',\n loadingStateAriaLabel,\n onSortChange,\n children,\n },\n ref,\n ) => {\n const cellRef = useRef<HTMLTableCellElement>(null);\n useSyncRefs<HTMLTableCellElement>(cellRef, ref);\n\n useTextTruncation(cellRef);\n\n const sortLabel = useMemo(() => {\n if (typeof children === 'string') {\n if (sortDirection === 'ascending') {\n return sortTranslations?.sortDescending ?? `Sort by ${children} descending`;\n }\n return sortTranslations?.sortAscending ?? `Sort by ${children} ascending`;\n }\n\n return sortDirection === 'ascending' ? 'Sort descending' : 'Sort ascending';\n }, [children, sortDirection, sortTranslations]);\n\n const handleSortChange = () => {\n if (!onSortChange) {\n return;\n }\n\n const newDirection: SortDirection =\n sortDirection === undefined || sortDirection === 'descending' ? 'ascending' : 'descending';\n\n onSortChange(newDirection);\n };\n\n return (\n <th\n ref={cellRef}\n style={{ width }}\n className={styles.headerCell}\n scope={scope}\n colSpan={colSpan}\n data-align={align}\n data-truncate={truncate}\n data-no-shrink={noShrink}\n data-sortable={!!onSortChange}\n aria-sort={onSortChange ? sortDirection || 'none' : undefined}\n >\n {state === 'loading' ? (\n <div className={styles.cellContent} aria-live=\"polite\" aria-label={loadingStateAriaLabel}>\n {typeof children === 'string' && truncate ? (\n <span className={styles.buttonText}>{children}</span>\n ) : (\n children\n )}\n <LoadingCircle data-test-id=\"fondue-loading-circle\" size=\"xx-small\" />\n </div>\n ) : onSortChange ? (\n <button\n className={styles.cellContent}\n aria-label={sortLabel}\n data-active={!!sortDirection}\n onClick={handleSortChange}\n >\n {typeof children === 'string' && truncate ? (\n <span className={styles.buttonText}>{children}</span>\n ) : (\n children\n )}\n <Box width={3}>\n {sortDirection === 'ascending' ? (\n <IconArrowUp size=\"12\" />\n ) : sortDirection === 'descending' ? (\n <IconArrowDown size=\"12\" />\n ) : (\n <IconArrowBidirectional className={styles.sortIndicator} size=\"12\" />\n )}\n </Box>\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\nTableHeaderCell.displayName = 'Table.HeaderCell';\n\ntype TableBodyProps = {\n children: ReactNode;\n 'aria-busy'?: boolean;\n};\n\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(\n ({ children, 'aria-busy': ariaBusy }, ref) => {\n return (\n <tbody ref={ref} className={styles.body} aria-busy={ariaBusy}>\n {children}\n </tbody>\n );\n },\n);\nTableBody.displayName = 'Table.Body';\n\ntype BaseTableRowProps = {\n /**\n * Whether the row is in a selected state\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to disable interactions for this row\n * @default false\n */\n disabled?: boolean;\n /**\n * Content to be rendered within the row\n */\n children: ReactNode;\n /**\n * Accessible label for the row\n */\n 'aria-label'?: string;\n 'data-test-id'?: string;\n};\n\ntype ClickableTableRowProps = BaseTableRowProps & {\n /**\n * Handler called when the row is clicked or activated via keyboard\n * If provided, the row will be hoverable and interactive\n */\n onClick: (selected: boolean) => void;\n onNavigate?: never;\n href?: never;\n};\n\ntype NavigableTableRowProps = BaseTableRowProps & {\n onClick?: never;\n /**\n * Handler called when the row is clicked or activated via keyboard for navigation\n * Must be provided together with href\n */\n onNavigate: (href: string) => void;\n /**\n * URL associated with this row for navigation\n * Must be provided together with onNavigate\n */\n href: string;\n};\n\ntype NonInteractiveTableRowProps = BaseTableRowProps & {\n onClick?: never;\n onNavigate?: never;\n href?: never;\n};\n\ntype TableRowProps = ClickableTableRowProps | NavigableTableRowProps | NonInteractiveTableRowProps;\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { disabled = false, selected = false, onClick, children, 'aria-label': ariaLabel, 'data-test-id': dataTestId },\n ref,\n ) => {\n const isInteractive = onClick !== undefined && !disabled;\n\n const handleClick = (event?: MouseEvent) => {\n if (disabled) {\n return;\n }\n\n if (shouldIgnoreRowClick(event)) {\n return;\n }\n\n if (onClick) {\n onClick(selected);\n }\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTableRowElement>) => {\n if (!isInteractive) {\n return;\n }\n\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleClick();\n }\n };\n\n return (\n <tr\n ref={ref}\n className={styles.row}\n tabIndex={0}\n role={isInteractive ? 'button' : 'row'}\n data-disabled={disabled}\n data-interactive={isInteractive}\n data-selected={selected}\n aria-disabled={disabled}\n aria-label={ariaLabel}\n aria-selected={selected}\n onClick={isInteractive ? handleClick : undefined}\n onKeyDown={isInteractive ? handleKeyDown : undefined}\n data-test-id={dataTestId}\n >\n {children}\n </tr>\n );\n },\n);\nTableRow.displayName = 'Table.Row';\n\ntype TableRowCellProps = {\n /**\n * Number of columns the cell should span\n */\n colSpan?: HTMLTableCellElement['colSpan'];\n /**\n * Whether to truncate content with ellipsis when it overflows\n * @default false\n */\n truncate?: boolean;\n /**\n * Horizontal alignment of the content\n * @default 'left'\n */\n align?: HorizontalAlignment;\n children: ReactNode;\n 'aria-label'?: string;\n};\n\nexport const TableRowCell = forwardRef<HTMLTableCellElement, TableRowCellProps>(\n ({ colSpan, truncate, align = 'left', children, 'aria-label': ariaLabel }, ref): ReactElement => {\n const cellRef = useRef<HTMLTableCellElement>(null);\n useSyncRefs<HTMLTableCellElement>(cellRef, ref);\n\n useTextTruncation(cellRef);\n\n return (\n <td\n ref={cellRef}\n className={styles.rowCell}\n colSpan={colSpan}\n data-align={align}\n data-truncate={truncate}\n aria-label={ariaLabel}\n >\n {children}\n </td>\n );\n },\n);\nTableRowCell.displayName = 'Table.RowCell';\n\nexport const Table = {\n Root: TableRoot,\n Caption: TableCaption,\n Header: TableHeader,\n HeaderCell: TableHeaderCell,\n Body: TableBody,\n Row: TableRow,\n RowCell: TableRowCell,\n};\n"],"names":["TableRoot","forwardRef","layout","fontSize","sticky","children","props","ref","handleKeyDown","jsx","styles","TableCaption","TableHeader","ariaLabel","ariaBusy","TableHeaderCell","noShrink","truncate","align","scope","sortTranslations","sortDirection","colSpan","width","state","loadingStateAriaLabel","onSortChange","cellRef","useRef","useSyncRefs","useTextTruncation","sortLabel","useMemo","handleSortChange","jsxs","LoadingCircle","Box","IconArrowUp","IconArrowDown","IconArrowBidirectional","TableBody","TableRow","disabled","selected","onClick","dataTestId","isInteractive","handleClick","event","shouldIgnoreRowClick","TableRowCell","Table"],"mappings":";;;;;;;;;AA0CO,MAAMA,IAAYC;AAAA,EACrB,CAAC,EAAE,QAAAC,IAAS,QAAQ,UAAAC,IAAW,UAAU,QAAAC,GAAQ,UAAAC,GAAU,GAAGC,EAAM,GAAGC,wBAE9D,OAAI,EAAA,WAAWC,GAAe,MAAK,QAAO,UAAU,IACjD,UAAA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,KAAAF;AAAA,MACA,WAAWG,EAAO;AAAA,MAClB,eAAaR;AAAA,MACb,kBAAgBC;AAAA,MAChB,eAAaC;AAAA,MACZ,GAAGE;AAAA,MAEH,UAAAD;AAAA,IAAA;AAAA,EAAA,GAET;AAGZ;AACAL,EAAU,cAAc;AAEjB,MAAMW,IAAeV,EAA6D,CAAC,EA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AAA;AAAA,QACG,KAAKkB;AAAA,QACL,WAAWjB,EAAO;AAAA,QAClB,SAAAY;AAAA,QACA,cAAYJ;AAAA,QACZ,iBAAeD;AAAA,QACf,cAAYJ;AAAA,QAEX,UAAAR;AAAA,MAAA;AAAA,IACL;AAAA,EAAA;AAGZ;AACA6C,EAAa,cAAc;AAEpB,MAAMC,IAAQ;AAAA,EACjB,MAAMnD;AAAA,EACN,SAASW;AAAA,EACT,QAAQC;AAAA,EACR,YAAYG;AAAA,EACZ,MAAMyB;AAAA,EACN,KAAKC;AAAA,EACL,SAASS;AACb;"}
|
|
1
|
+
{"version":3,"file":"fondue-components25.js","sources":["../src/components/Table/Table.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconArrowBidirectional, IconArrowDown, IconArrowUp } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useMemo,\n useRef,\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport { useSyncRefs } from '#/hooks/useSyncRefs';\nimport { useTextTruncation } from '#/hooks/useTextTruncation';\nimport { type CommonAriaAttrs } from '#/utilities/types';\n\nimport { Box } from '../Box/Box';\nimport { LoadingCircle } from '../LoadingCircle/LoadingCircle';\n\nimport styles from './styles/table.module.scss';\nimport { handleKeyDown, shouldIgnoreRowClick } from './utils';\n\ntype TableRootProps = {\n /**\n * Whether the table should have a fixed or auto layout\n * @default 'auto'\n */\n layout?: 'auto' | 'fixed';\n /**\n * Font size of the table content\n * @default 'small'\n */\n fontSize?: 'small' | 'medium';\n /**\n * Whether header should stick to the top when scrolling\n */\n sticky?: 'head' | 'col' | 'both';\n children: ReactNode;\n} & CommonAriaAttrs;\n\nexport const TableRoot = forwardRef<HTMLTableElement, TableRootProps>(\n ({ layout = 'auto', fontSize = 'medium', sticky, children, ...props }, ref) => {\n return (\n <div onKeyDown={handleKeyDown} role=\"grid\" tabIndex={-1}>\n <table\n ref={ref}\n className={styles.table}\n data-layout={layout}\n data-font-size={fontSize}\n data-sticky={sticky}\n {...props}\n >\n {children}\n </table>\n </div>\n );\n },\n);\nTableRoot.displayName = 'Table.Root';\n\nexport const TableCaption = forwardRef<HTMLTableCaptionElement, { children: ReactNode }>(({ children }, ref) => {\n return (\n <caption ref={ref} className={styles.caption}>\n {children}\n </caption>\n );\n});\nTableCaption.displayName = 'Table.Caption';\n\ntype TableHeaderProps = {\n children: ReactNode;\n 'aria-label'?: string;\n 'aria-busy'?: boolean;\n};\n\nexport const TableHeader = forwardRef<HTMLTableSectionElement, TableHeaderProps>(\n ({ children, 'aria-label': ariaLabel, 'aria-busy': ariaBusy }, ref) => {\n return (\n <thead ref={ref} className={styles.header} aria-label={ariaLabel} aria-busy={ariaBusy}>\n {children}\n </thead>\n );\n },\n);\nTableHeader.displayName = 'Table.Header';\n\ntype SortDirection = 'ascending' | 'descending' | undefined;\ntype HorizontalAlignment = 'left' | 'center' | 'right';\n\ntype TableHeaderCellProps = {\n /**\n * Scope of the column\n * @default 'col'\n */\n scope?: HTMLTableCellElement['scope'];\n /**\n * Number of columns the cell should span\n */\n colSpan?: HTMLTableCellElement['colSpan'];\n /**\n * Width of the column\n */\n width?: CSSProperties['width'];\n /**\n * Current sort direction of the column\n */\n sortDirection?: SortDirection;\n /**\n * Horizontal alignment of the content\n * @default 'left'\n */\n align?: HorizontalAlignment;\n /**\n * Whether to truncate content with ellipsis when it overflows\n * @default false\n */\n truncate?: boolean;\n /**\n * Aria label for asceding/descending sort. Variables: {column} - column name\n * @default \"Sort by {column} ascending/descending\"\n */\n sortTranslations?: {\n sortAscending?: string;\n sortDescending?: string;\n };\n /**\n * Whether the column should have a minimum width\n * @default false\n */\n noShrink?: boolean;\n /**\n * State of the cell, used for displaying loading state\n * @default 'idle'\n */\n state?: 'idle' | 'loading';\n /**\n * The aria-label to be applied when state='loading'\n */\n loadingStateAriaLabel?: string;\n /**\n * Handler called when the sort direction changes\n * @param direction - The new sort direction\n */\n onSortChange?: (direction: SortDirection) => void;\n children: ReactNode;\n};\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n (\n {\n noShrink = false,\n truncate = false,\n align = 'left',\n scope = 'col',\n sortTranslations,\n sortDirection,\n colSpan,\n width,\n state = 'idle',\n loadingStateAriaLabel,\n onSortChange,\n children,\n },\n ref,\n ) => {\n const cellRef = useRef<HTMLTableCellElement>(null);\n useSyncRefs<HTMLTableCellElement>(cellRef, ref);\n\n useTextTruncation(cellRef);\n\n const sortLabel = useMemo(() => {\n if (typeof children === 'string') {\n if (sortDirection === 'ascending') {\n return sortTranslations?.sortDescending ?? `Sort by ${children} descending`;\n }\n return sortTranslations?.sortAscending ?? `Sort by ${children} ascending`;\n }\n\n return sortDirection === 'ascending' ? 'Sort descending' : 'Sort ascending';\n }, [children, sortDirection, sortTranslations]);\n\n const handleSortChange = () => {\n if (!onSortChange) {\n return;\n }\n\n const newDirection: SortDirection =\n sortDirection === undefined || sortDirection === 'descending' ? 'ascending' : 'descending';\n\n onSortChange(newDirection);\n };\n\n return (\n <th\n ref={cellRef}\n style={{ width }}\n className={styles.headerCell}\n scope={scope}\n colSpan={colSpan}\n data-align={align}\n data-truncate={truncate}\n data-no-shrink={noShrink}\n data-sortable={!!onSortChange}\n aria-sort={onSortChange ? sortDirection || 'none' : undefined}\n >\n {state === 'loading' ? (\n <div className={styles.cellContent} aria-live=\"polite\" aria-label={loadingStateAriaLabel}>\n {typeof children === 'string' && truncate ? (\n <span className={styles.buttonText}>{children}</span>\n ) : (\n children\n )}\n <LoadingCircle data-test-id=\"fondue-loading-circle\" size=\"xx-small\" />\n </div>\n ) : onSortChange ? (\n <button\n className={styles.cellContent}\n aria-label={sortLabel}\n data-active={!!sortDirection}\n onClick={handleSortChange}\n >\n {typeof children === 'string' && truncate ? (\n <span className={styles.buttonText}>{children}</span>\n ) : (\n children\n )}\n <Box width={3}>\n {sortDirection === 'ascending' ? (\n <IconArrowUp className={styles.sortIndicator} size=\"12\" />\n ) : sortDirection === 'descending' ? (\n <IconArrowDown className={styles.sortIndicator} size=\"12\" />\n ) : (\n <IconArrowBidirectional className={styles.sortIndicator} size=\"12\" />\n )}\n </Box>\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\nTableHeaderCell.displayName = 'Table.HeaderCell';\n\ntype TableBodyProps = {\n children: ReactNode;\n 'aria-busy'?: boolean;\n};\n\nexport const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(\n ({ children, 'aria-busy': ariaBusy }, ref) => {\n return (\n <tbody ref={ref} className={styles.body} aria-busy={ariaBusy}>\n {children}\n </tbody>\n );\n },\n);\nTableBody.displayName = 'Table.Body';\n\ntype BaseTableRowProps = {\n /**\n * Whether the row is in a selected state\n * @default false\n */\n selected?: boolean;\n /**\n * Whether to disable interactions for this row\n * @default false\n */\n disabled?: boolean;\n /**\n * Content to be rendered within the row\n */\n children: ReactNode;\n /**\n * Accessible label for the row\n */\n 'aria-label'?: string;\n 'data-test-id'?: string;\n};\n\ntype ClickableTableRowProps = BaseTableRowProps & {\n /**\n * Handler called when the row is clicked or activated via keyboard\n * If provided, the row will be hoverable and interactive\n */\n onClick: (selected: boolean) => void;\n onNavigate?: never;\n href?: never;\n};\n\ntype NavigableTableRowProps = BaseTableRowProps & {\n onClick?: never;\n /**\n * Handler called when the row is clicked or activated via keyboard for navigation\n * Must be provided together with href\n */\n onNavigate: (href: string) => void;\n /**\n * URL associated with this row for navigation\n * Must be provided together with onNavigate\n */\n href: string;\n};\n\ntype NonInteractiveTableRowProps = BaseTableRowProps & {\n onClick?: never;\n onNavigate?: never;\n href?: never;\n};\n\ntype TableRowProps = ClickableTableRowProps | NavigableTableRowProps | NonInteractiveTableRowProps;\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { disabled = false, selected = false, onClick, children, 'aria-label': ariaLabel, 'data-test-id': dataTestId },\n ref,\n ) => {\n const isInteractive = onClick !== undefined && !disabled;\n\n const handleClick = (event?: MouseEvent) => {\n if (disabled) {\n return;\n }\n\n if (shouldIgnoreRowClick(event)) {\n return;\n }\n\n if (onClick) {\n onClick(selected);\n }\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTableRowElement>) => {\n if (!isInteractive) {\n return;\n }\n\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n handleClick();\n }\n };\n\n return (\n <tr\n ref={ref}\n className={styles.row}\n tabIndex={0}\n role={isInteractive ? 'button' : 'row'}\n data-disabled={disabled}\n data-interactive={isInteractive}\n data-selected={selected}\n aria-disabled={disabled}\n aria-label={ariaLabel}\n aria-selected={selected}\n onClick={isInteractive ? handleClick : undefined}\n onKeyDown={isInteractive ? handleKeyDown : undefined}\n data-test-id={dataTestId}\n >\n {children}\n </tr>\n );\n },\n);\nTableRow.displayName = 'Table.Row';\n\ntype TableRowCellProps = {\n /**\n * Number of columns the cell should span\n */\n colSpan?: HTMLTableCellElement['colSpan'];\n /**\n * Whether to truncate content with ellipsis when it overflows\n * @default false\n */\n truncate?: boolean;\n /**\n * Horizontal alignment of the content\n * @default 'left'\n */\n align?: HorizontalAlignment;\n children: ReactNode;\n 'aria-label'?: string;\n};\n\nexport const TableRowCell = forwardRef<HTMLTableCellElement, TableRowCellProps>(\n ({ colSpan, truncate, align = 'left', children, 'aria-label': ariaLabel }, ref): ReactElement => {\n const cellRef = useRef<HTMLTableCellElement>(null);\n useSyncRefs<HTMLTableCellElement>(cellRef, ref);\n\n useTextTruncation(cellRef);\n\n return (\n <td\n ref={cellRef}\n className={styles.rowCell}\n colSpan={colSpan}\n data-align={align}\n data-truncate={truncate}\n aria-label={ariaLabel}\n >\n {children}\n </td>\n );\n },\n);\nTableRowCell.displayName = 'Table.RowCell';\n\nexport const Table = {\n Root: TableRoot,\n Caption: TableCaption,\n Header: TableHeader,\n HeaderCell: TableHeaderCell,\n Body: TableBody,\n Row: TableRow,\n RowCell: TableRowCell,\n};\n"],"names":["TableRoot","forwardRef","layout","fontSize","sticky","children","props","ref","handleKeyDown","jsx","styles","TableCaption","TableHeader","ariaLabel","ariaBusy","TableHeaderCell","noShrink","truncate","align","scope","sortTranslations","sortDirection","colSpan","width","state","loadingStateAriaLabel","onSortChange","cellRef","useRef","useSyncRefs","useTextTruncation","sortLabel","useMemo","handleSortChange","jsxs","LoadingCircle","Box","IconArrowUp","IconArrowDown","IconArrowBidirectional","TableBody","TableRow","disabled","selected","onClick","dataTestId","isInteractive","handleClick","event","shouldIgnoreRowClick","TableRowCell","Table"],"mappings":";;;;;;;;;AA0CO,MAAMA,IAAYC;AAAA,EACrB,CAAC,EAAE,QAAAC,IAAS,QAAQ,UAAAC,IAAW,UAAU,QAAAC,GAAQ,UAAAC,GAAU,GAAGC,EAAM,GAAGC,wBAE9D,OAAI,EAAA,WAAWC,GAAe,MAAK,QAAO,UAAU,IACjD,UAAA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,KAAAF;AAAA,MACA,WAAWG,EAAO;AAAA,MAClB,eAAaR;AAAA,MACb,kBAAgBC;AAAA,MAChB,eAAaC;AAAA,MACZ,GAAGE;AAAA,MAEH,UAAAD;AAAA,IAAA;AAAA,EAAA,GAET;AAGZ;AACAL,EAAU,cAAc;AAEjB,MAAMW,IAAeV,EAA6D,CAAC,EAAE,UAAAI,EAAA,GAAYE,wBAE/F,WAAQ,EAAA,KAAAA,GAAU,WAAWG,EAAO,SAChC,UAAAL,GACL,CAEP;AACDM,EAAa,cAAc;AAQpB,MAAMC,IAAcX;AAAA,EACvB,CAAC,EAAE,UAAAI,GAAU,cAAcQ,GAAW,aAAaC,KAAYP,MAEvD,gBAAAE,EAAC,SAAM,EAAA,KAAAF,GAAU,WAAWG,EAAO,QAAQ,cAAYG,GAAW,aAAWC,GACxE,UAAAT,EACL,CAAA;AAGZ;AACAO,EAAY,cAAc;AA+DnB,MAAMG,IAAkBd;AAAA,EAC3B,CACI;AAAA,IACI,UAAAe,IAAW;AAAA,IACX,UAAAC,IAAW;AAAA,IACX,OA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s as w, jsx as
|
|
2
|
-
import { IconCheckMark as N, IconExclamationMarkTriangle as
|
|
3
|
-
import { forwardRef as n, useRef as
|
|
1
|
+
import { jsxs as w, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { IconCheckMark as N, IconExclamationMarkTriangle as h } from "@frontify/fondue-icons";
|
|
3
|
+
import { forwardRef as n, useRef as S } from "react";
|
|
4
4
|
import { cn as m } from "./fondue-components36.js";
|
|
5
|
-
import
|
|
5
|
+
import { LoadingCircle as T } from "./fondue-components18.js";
|
|
6
|
+
import l from "./fondue-components77.js";
|
|
6
7
|
const f = ({
|
|
7
|
-
children:
|
|
8
|
-
className:
|
|
8
|
+
children: i,
|
|
9
|
+
className: c,
|
|
9
10
|
status: e = "neutral",
|
|
10
|
-
"data-test-id":
|
|
11
|
-
"aria-errormessage":
|
|
12
|
-
...
|
|
11
|
+
"data-test-id": a = "fondue-text-input",
|
|
12
|
+
"aria-errormessage": F,
|
|
13
|
+
...r
|
|
13
14
|
}, R) => {
|
|
14
|
-
const d =
|
|
15
|
-
return /* @__PURE__ */ w("div", { className: m(
|
|
16
|
-
e === "loading" ? /* @__PURE__ */
|
|
17
|
-
/* @__PURE__ */
|
|
15
|
+
const d = S(!1);
|
|
16
|
+
return /* @__PURE__ */ w("div", { className: m(l.root, c), "data-status": e, "data-test-id": a, children: [
|
|
17
|
+
e === "loading" ? /* @__PURE__ */ t("div", { className: l.loadingStatus, "data-test-id": `${a}-loader`, children: /* @__PURE__ */ t(T, { size: "xx-small" }) }) : null,
|
|
18
|
+
/* @__PURE__ */ t(
|
|
18
19
|
"input",
|
|
19
20
|
{
|
|
20
21
|
onMouseDown: (o) => {
|
|
21
22
|
d.current = !0, o.currentTarget.dataset.showFocusRing = "false";
|
|
22
23
|
},
|
|
23
24
|
type: "text",
|
|
24
|
-
...
|
|
25
|
+
...r,
|
|
25
26
|
onFocus: (o) => {
|
|
26
27
|
var s;
|
|
27
|
-
console.log("focusEvent", o), d.current || (o.target.dataset.showFocusRing = "true"), (s =
|
|
28
|
+
console.log("focusEvent", o), d.current || (o.target.dataset.showFocusRing = "true"), (s = r.onFocus) == null || s.call(r, o);
|
|
28
29
|
},
|
|
29
30
|
onBlur: (o) => {
|
|
30
31
|
var s;
|
|
31
|
-
o.target.dataset.showFocusRing = "false", d.current = !1, (s =
|
|
32
|
+
o.target.dataset.showFocusRing = "false", d.current = !1, (s = r.onBlur) == null || s.call(r, o);
|
|
32
33
|
},
|
|
33
34
|
ref: R,
|
|
34
|
-
className:
|
|
35
|
+
className: l.input,
|
|
35
36
|
"aria-invalid": e === "error",
|
|
36
|
-
"aria-errormessage": e === "error" ?
|
|
37
|
+
"aria-errormessage": e === "error" ? F : void 0
|
|
37
38
|
}
|
|
38
39
|
),
|
|
39
|
-
e === "success" ? /* @__PURE__ */
|
|
40
|
-
e === "error" ? /* @__PURE__ */
|
|
41
|
-
|
|
40
|
+
e === "success" ? /* @__PURE__ */ t(N, { size: 16, className: l.iconSuccess, "data-test-id": `${a}-success-icon` }) : null,
|
|
41
|
+
e === "error" ? /* @__PURE__ */ t(
|
|
42
|
+
h,
|
|
42
43
|
{
|
|
43
44
|
size: 16,
|
|
44
|
-
className:
|
|
45
|
-
"data-test-id": `${
|
|
45
|
+
className: l.iconError,
|
|
46
|
+
"data-test-id": `${a}-error-icon`
|
|
46
47
|
}
|
|
47
48
|
) : null,
|
|
48
|
-
|
|
49
|
+
i
|
|
49
50
|
] });
|
|
50
51
|
};
|
|
51
52
|
f.displayName = "TextField.Root";
|
|
52
|
-
const u = ({ name:
|
|
53
|
+
const u = ({ name: i, className: c, ...e }, a) => /* @__PURE__ */ t(
|
|
53
54
|
"div",
|
|
54
55
|
{
|
|
55
56
|
"data-slot": !0,
|
|
56
|
-
"data-name":
|
|
57
|
+
"data-name": i,
|
|
57
58
|
...e,
|
|
58
|
-
ref:
|
|
59
|
-
className: m(
|
|
59
|
+
ref: a,
|
|
60
|
+
className: m(l.slot, c)
|
|
60
61
|
}
|
|
61
62
|
);
|
|
62
63
|
u.displayName = "TextField.Slot";
|
|
63
|
-
const x = n(f),
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const x = n(f), k = n(u), g = x;
|
|
65
|
+
g.Root = x;
|
|
66
|
+
g.Slot = k;
|
|
66
67
|
export {
|
|
67
68
|
f as TextFieldRoot,
|
|
68
69
|
u as TextFieldSlot,
|
|
69
|
-
|
|
70
|
+
g as TextInput
|
|
70
71
|
};
|
|
71
72
|
//# sourceMappingURL=fondue-components28.js.map
|