@frontify/fondue-components 19.0.0 → 19.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,39 +1,41 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import * as n from "@radix-ui/react-separator";
3
- import { forwardRef as p } from "react";
4
- import { cn as f } from "./fondue-components36.js";
5
- import { dividerStyles as l } from "./fondue-components49.js";
6
- const c = p(
2
+ import * as p from "@radix-ui/react-separator";
3
+ import { forwardRef as f } from "react";
4
+ import { cn as l } from "./fondue-components36.js";
5
+ import { dividerStyles as c } from "./fondue-components49.js";
6
+ const v = f(
7
7
  ({
8
8
  "data-test-id": o = "fondue-divider",
9
9
  direction: t = "horizontal",
10
10
  className: i,
11
11
  variant: e,
12
12
  as: d = "div",
13
- ...a
14
- }, m) => {
15
- const s = d;
13
+ decorative: a,
14
+ ...m
15
+ }, s) => {
16
+ const n = d;
16
17
  return /* @__PURE__ */ r(
17
- n.Root,
18
+ p.Root,
18
19
  {
19
- ref: m,
20
- className: f(
21
- l({
20
+ ref: s,
21
+ className: l(
22
+ c({
22
23
  direction: t,
23
24
  variant: e,
24
- ...a
25
+ ...m
25
26
  }),
26
27
  i
27
28
  ),
28
29
  "data-test-id": o,
30
+ decorative: a,
29
31
  asChild: !0,
30
- children: /* @__PURE__ */ r(s, {})
32
+ children: /* @__PURE__ */ r(n, {})
31
33
  }
32
34
  );
33
35
  }
34
36
  );
35
- c.displayName = "Divider";
37
+ v.displayName = "Divider";
36
38
  export {
37
- c as Divider
39
+ v as Divider
38
40
  };
39
41
  //# sourceMappingURL=fondue-components10.js.map
@@ -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 { 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' | 'x-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 '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 ...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 className,\n )}\n data-test-id={dataTestId}\n asChild\n >\n <Component />\n </Separator.Root>\n );\n },\n);\n\nDivider.displayName = 'Divider';\n"],"names":["Divider","forwardRef","dataTestId","direction","className","variant","as","props","ref","Component","jsx","Separator","cn","dividerStyles"],"mappings":";;;;;AA4CO,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,GAAGC;AAAA,KAEPC,MACe;AACf,UAAMC,IAAYH;AAGd,WAAA,gBAAAI;AAAA,MAACC,EAAU;AAAA,MAAV;AAAA,QACG,KAAAH;AAAA,QACA,WAAWI;AAAA,UACPC,EAAc;AAAA,YACV,WAAAV;AAAA,YACA,SAAAE;AAAA,YACA,GAAGE;AAAA,UAAA,CACN;AAAA,UACDH;AAAA,QACJ;AAAA,QACA,gBAAcF;AAAA,QACd,SAAO;AAAA,QAEP,4BAACO,GAAU,CAAA,CAAA;AAAA,MAAA;AAAA,IACf;AAAA,EAAA;AAGZ;AAEAT,EAAQ,cAAc;"}
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 { 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' | 'x-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 className,\n )}\n data-test-id={dataTestId}\n decorative={decorative}\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"],"mappings":";;;;;AAkDO,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,UACDJ;AAAA,QACJ;AAAA,QACA,gBAAcF;AAAA,QACd,YAAAK;AAAA,QACA,SAAO;AAAA,QAEP,4BAACG,GAAU,CAAA,CAAA;AAAA,MAAA;AAAA,IACf;AAAA,EAAA;AAGZ;AAEAV,EAAQ,cAAc;"}
@@ -1,155 +1,155 @@
1
1
  import { jsx as t, jsxs as p } from "react/jsx-runtime";
2
- import { IconArrowUp as A, IconArrowDown as K, IconArrowBidirectional as h } from "@frontify/fondue-icons";
3
- import { forwardRef as b, useRef as w, useMemo as j } from "react";
2
+ import { IconArrowUp as A, IconArrowDown as K, IconArrowBidirectional as E } from "@frontify/fondue-icons";
3
+ import { forwardRef as b, useRef as w, useMemo as h } from "react";
4
4
  import { useSyncRefs as g } from "./fondue-components46.js";
5
5
  import { useTextTruncation as N } from "./fondue-components70.js";
6
- import { Box as L } from "./fondue-components5.js";
7
- import { LoadingCircle as S } from "./fondue-components18.js";
8
- import i from "./fondue-components71.js";
9
- import { handleKeyDown as $ } from "./fondue-components72.js";
6
+ import { Box as j } from "./fondue-components5.js";
7
+ import { LoadingCircle as L } from "./fondue-components18.js";
8
+ import o from "./fondue-components71.js";
9
+ import { handleKeyDown as S, isEventFromInteractiveElement as $ } from "./fondue-components72.js";
10
10
  const R = b(
11
- ({ layout: a = "auto", fontSize: e = "medium", sticky: d, children: r, ...o }, l) => /* @__PURE__ */ t("div", { onKeyDown: $, role: "grid", tabIndex: -1, children: /* @__PURE__ */ t(
11
+ ({ layout: a = "auto", fontSize: e = "medium", sticky: d, children: s, ...n }, l) => /* @__PURE__ */ t("div", { onKeyDown: S, role: "grid", tabIndex: -1, children: /* @__PURE__ */ t(
12
12
  "table",
13
13
  {
14
14
  ref: l,
15
- className: i.table,
15
+ className: o.table,
16
16
  "data-layout": a,
17
17
  "data-font-size": e,
18
18
  "data-sticky": d,
19
- ...o,
20
- children: r
19
+ ...n,
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: i.caption, children: a }));
26
- C.displayName = "Table.Caption";
27
- const x = b(
28
- ({ children: a, "aria-label": e, "aria-busy": d }, r) => /* @__PURE__ */ t("thead", { ref: r, className: i.header, "aria-label": e, "aria-busy": d, children: a })
25
+ const v = b(({ children: a }, e) => /* @__PURE__ */ t("caption", { ref: e, className: o.caption, children: a }));
26
+ v.displayName = "Table.Caption";
27
+ const C = b(
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
- x.displayName = "Table.Header";
31
- const v = b(
30
+ C.displayName = "Table.Header";
31
+ const x = b(
32
32
  ({
33
33
  noShrink: a = !1,
34
34
  truncate: e = !1,
35
35
  align: d = "left",
36
- scope: r = "col",
37
- sortTranslations: o,
36
+ scope: s = "col",
37
+ sortTranslations: n,
38
38
  sortDirection: l,
39
39
  colSpan: c,
40
40
  width: m,
41
41
  state: f = "idle",
42
42
  loadingStateAriaLabel: u,
43
- onSortChange: s,
44
- children: n
43
+ onSortChange: i,
44
+ children: r
45
45
  }, k) => {
46
46
  const y = w(null);
47
47
  g(y, k), N(y);
48
- const z = j(() => typeof n == "string" ? l === "ascending" ? (o == null ? void 0 : o.sortDescending) ?? `Sort by ${n} descending` : (o == null ? void 0 : o.sortAscending) ?? `Sort by ${n} ascending` : l === "ascending" ? "Sort descending" : "Sort ascending", [n, l, o]), B = () => {
49
- if (!s)
48
+ const z = h(() => typeof r == "string" ? l === "ascending" ? (n == null ? void 0 : n.sortDescending) ?? `Sort by ${r} descending` : (n == null ? void 0 : n.sortAscending) ?? `Sort by ${r} ascending` : l === "ascending" ? "Sort descending" : "Sort ascending", [r, l, n]), B = () => {
49
+ if (!i)
50
50
  return;
51
- s(l === void 0 || l === "descending" ? "ascending" : "descending");
51
+ i(l === void 0 || l === "descending" ? "ascending" : "descending");
52
52
  };
53
53
  return /* @__PURE__ */ t(
54
54
  "th",
55
55
  {
56
56
  ref: y,
57
57
  style: { width: m },
58
- className: i.headerCell,
59
- scope: r,
58
+ className: o.headerCell,
59
+ scope: s,
60
60
  colSpan: c,
61
61
  "data-align": d,
62
62
  "data-truncate": e,
63
63
  "data-no-shrink": a,
64
- "data-sortable": !!s,
65
- "aria-sort": s ? l || "none" : void 0,
66
- children: f === "loading" ? /* @__PURE__ */ p("div", { className: i.cellContent, "aria-live": "polite", "aria-label": u, children: [
67
- typeof n == "string" && e ? /* @__PURE__ */ t("span", { className: i.buttonText, children: n }) : n,
68
- /* @__PURE__ */ t(S, { "data-test-id": "fondue-loading-circle", size: "xx-small" })
69
- ] }) : s ? /* @__PURE__ */ p(
64
+ "data-sortable": !!i,
65
+ "aria-sort": i ? l || "none" : void 0,
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
+ /* @__PURE__ */ t(L, { "data-test-id": "fondue-loading-circle", size: "xx-small" })
69
+ ] }) : i ? /* @__PURE__ */ p(
70
70
  "button",
71
71
  {
72
- className: i.cellContent,
72
+ className: o.cellContent,
73
73
  "aria-label": z,
74
74
  "data-active": !!l,
75
75
  onClick: B,
76
76
  children: [
77
- typeof n == "string" && e ? /* @__PURE__ */ t("span", { className: i.buttonText, children: n }) : n,
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: i.sortIndicator, size: "12" }) })
77
+ typeof r == "string" && e ? /* @__PURE__ */ t("span", { className: o.buttonText, children: r }) : r,
78
+ /* @__PURE__ */ t(j, { width: 3, children: l === "ascending" ? /* @__PURE__ */ t(A, { size: "12" }) : l === "descending" ? /* @__PURE__ */ t(K, { size: "12" }) : /* @__PURE__ */ t(E, { className: o.sortIndicator, size: "12" }) })
79
79
  ]
80
80
  }
81
- ) : n
81
+ ) : r
82
82
  }
83
83
  );
84
84
  }
85
85
  );
86
- v.displayName = "Table.HeaderCell";
86
+ x.displayName = "Table.HeaderCell";
87
87
  const T = b(
88
- ({ children: a, "aria-busy": e }, d) => /* @__PURE__ */ t("tbody", { ref: d, className: i.body, "aria-busy": e, children: a })
88
+ ({ children: a, "aria-busy": e }, d) => /* @__PURE__ */ t("tbody", { ref: d, className: o.body, "aria-busy": e, children: a })
89
89
  );
90
90
  T.displayName = "Table.Body";
91
91
  const I = b(
92
- ({ disabled: a = !1, selected: e = !1, onClick: d, children: r, "aria-label": o, "data-test-id": l }, c) => {
93
- const m = d !== void 0 && !a, f = () => {
94
- a || d && d(e);
95
- }, u = (s) => {
96
- m && (s.key === "Enter" || s.key === " ") && (s.preventDefault(), f());
92
+ ({ disabled: a = !1, selected: e = !1, onClick: d, children: s, "aria-label": n, "data-test-id": l }, c) => {
93
+ const m = d !== void 0 && !a, f = (i) => {
94
+ a || d && !$(i) && d(e);
95
+ }, u = (i) => {
96
+ m && (i.key === "Enter" || i.key === " ") && (i.preventDefault(), f());
97
97
  };
98
98
  return /* @__PURE__ */ t(
99
99
  "tr",
100
100
  {
101
101
  ref: c,
102
- className: i.row,
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": o,
109
+ "aria-label": n,
110
110
  "aria-selected": e,
111
111
  onClick: m ? f : void 0,
112
112
  onKeyDown: m ? u : void 0,
113
113
  "data-test-id": l,
114
- children: r
114
+ children: s
115
115
  }
116
116
  );
117
117
  }
118
118
  );
119
119
  I.displayName = "Table.Row";
120
120
  const H = b(
121
- ({ colSpan: a, truncate: e, align: d = "left", children: r, "aria-label": o }, l) => {
121
+ ({ colSpan: a, truncate: e, align: d = "left", children: s, "aria-label": n }, l) => {
122
122
  const c = w(null);
123
123
  return g(c, l), N(c), /* @__PURE__ */ t(
124
124
  "td",
125
125
  {
126
126
  ref: c,
127
- className: i.rowCell,
127
+ className: o.rowCell,
128
128
  colSpan: a,
129
129
  "data-align": d,
130
130
  "data-truncate": e,
131
- "aria-label": o,
132
- children: r
131
+ "aria-label": n,
132
+ children: s
133
133
  }
134
134
  );
135
135
  }
136
136
  );
137
137
  H.displayName = "Table.RowCell";
138
- const Q = {
138
+ const V = {
139
139
  Root: R,
140
- Caption: C,
141
- Header: x,
142
- HeaderCell: v,
140
+ Caption: v,
141
+ Header: C,
142
+ HeaderCell: x,
143
143
  Body: T,
144
144
  Row: I,
145
145
  RowCell: H
146
146
  };
147
147
  export {
148
- Q as Table,
148
+ V as Table,
149
149
  T as TableBody,
150
- C as TableCaption,
151
- x as TableHeader,
152
- v as TableHeaderCell,
150
+ v as TableCaption,
151
+ C as TableHeader,
152
+ x as TableHeaderCell,
153
153
  R as TableRoot,
154
154
  I as TableRow,
155
155
  H as TableRowCell
@@ -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 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 } 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 = () => {\n if (disabled) {\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","TableRowCell","Table"],"mappings":";;;;;;;;;AAyCO,MAAMA,IAAYC;AAAA,EACrB,CAAC,EAAE,QAAAC,IAAS,QAAQ,UAAAC,IAAW,UAAU,QAAAC,GAAQ,UAAAC,GAAU,GAAGC,EAAM,GAAGC,wBAE9D,OAAI,EAAA,WAAWC,GAAe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hB,MAAMQ,IAAehD;AAAA,EACxB,CAAC,EAAE,SAAAqB,GAAS,UAAAL,GAAU,OAAAC,IAAQ,QAAQ,UAAAb,GAAU,cAAcQ,EAAU,GAAGN,MAAsB;AACvF,UAAAoB,IAAUC,EAA6B,IAAI;AACjD,WAAAC,EAAkCF,GAASpB,CAAG,GAE9CuB,EAAkBH,CAAO,GAGrB,gBAAAlB;AAAA,MAAC;AAAA,MAAA;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;AACA4C,EAAa,cAAc;AAEpB,MAAMC,IAAQ;AAAA,EACjB,MAAMlD;AAAA,EACN,SAASW;AAAA,EACT,QAAQC;AAAA,EACR,YAAYG;AAAA,EACZ,MAAMyB;AAAA,EACN,KAAKC;AAAA,EACL,SAASQ;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, isEventFromInteractiveElement } 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 (onClick && !isEventFromInteractiveElement(event)) {\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","isEventFromInteractiveElement","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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IAAQ;AAAA,EACjB,MAAMnD;AAAA,EACN,SAASW;AAAA,EACT,QAAQC;AAAA,EACR,YAAYG;AAAA,EACZ,MAAMyB;AAAA,EACN,KAAKC;AAAA,EACL,SAASS;AACb;"}
@@ -1,18 +1,32 @@
1
- function l(t, r) {
2
- const n = 'tr[tabindex="0"]', e = t.closest("table");
3
- if (!e)
1
+ function c(t, e) {
2
+ const n = 'tr[tabindex="0"]', r = t.closest("table");
3
+ if (!r)
4
4
  return null;
5
- const o = Array.from(e.querySelectorAll(n)), c = o.indexOf(t) + (r === "ArrowUp" ? -1 : 1);
6
- return c >= 0 && c < o.length ? o[c] : null;
5
+ const o = Array.from(r.querySelectorAll(n)), l = o.indexOf(t) + (e === "ArrowUp" ? -1 : 1);
6
+ return l >= 0 && l < o.length ? o[l] : null;
7
7
  }
8
- function u(t) {
9
- const r = t.target, n = r.closest("tr");
10
- if (!n || r !== n || !["ArrowUp", "ArrowDown"].includes(t.key))
8
+ function a(t) {
9
+ const e = t.target, n = e.closest("tr");
10
+ if (!n || e !== n || !["ArrowUp", "ArrowDown"].includes(t.key))
11
11
  return;
12
- const e = l(n, t.key);
13
- e && (t.preventDefault(), e.focus());
12
+ const r = c(n, t.key);
13
+ r && (t.preventDefault(), r.focus());
14
+ }
15
+ const s = [HTMLButtonElement, HTMLAnchorElement], u = ["button", "link"];
16
+ function f(t) {
17
+ let e = (t == null ? void 0 : t.target) instanceof Element ? t.target : null;
18
+ for (; e && !(e instanceof HTMLTableRowElement); ) {
19
+ if (s.some((r) => e instanceof r))
20
+ return !0;
21
+ const n = e.getAttribute("role");
22
+ if (n && u.includes(n))
23
+ return !0;
24
+ e = e.parentElement;
25
+ }
26
+ return !1;
14
27
  }
15
28
  export {
16
- u as handleKeyDown
29
+ a as handleKeyDown,
30
+ f as isEventFromInteractiveElement
17
31
  };
18
32
  //# sourceMappingURL=fondue-components72.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components72.js","sources":["../src/components/Table/utils.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type KeyboardEvent } from 'react';\n\nfunction getAdjacentRow(currentRow: HTMLElement, key: 'ArrowUp' | 'ArrowDown'): HTMLElement | null {\n const selector = 'tr[tabindex=\"0\"]';\n const table = currentRow.closest('table');\n if (!table) {\n return null;\n }\n\n const rows = Array.from(table.querySelectorAll(selector));\n const currentIndex = rows.indexOf(currentRow);\n const nextIndex = currentIndex + (key === 'ArrowUp' ? -1 : 1);\n\n return nextIndex >= 0 && nextIndex < rows.length ? (rows[nextIndex] as HTMLElement) : null;\n}\n\nexport function handleKeyDown(event: KeyboardEvent<HTMLTableElement>) {\n const target = event.target as HTMLElement;\n const currentRow = target.closest('tr');\n\n if (!currentRow || target !== currentRow || !['ArrowUp', 'ArrowDown'].includes(event.key)) {\n return;\n }\n\n const nextRow = getAdjacentRow(currentRow, event.key as 'ArrowUp' | 'ArrowDown');\n if (nextRow) {\n event.preventDefault();\n nextRow.focus();\n }\n}\n"],"names":["getAdjacentRow","currentRow","key","selector","table","rows","nextIndex","handleKeyDown","event","target","nextRow"],"mappings":"AAIA,SAASA,EAAeC,GAAyBC,GAAkD;AAC/F,QAAMC,IAAW,oBACXC,IAAQH,EAAW,QAAQ,OAAO;AACxC,MAAI,CAACG;AACM,WAAA;AAGX,QAAMC,IAAO,MAAM,KAAKD,EAAM,iBAAiBD,CAAQ,CAAC,GAElDG,IADeD,EAAK,QAAQJ,CAAU,KACVC,MAAQ,YAAY,KAAK;AAE3D,SAAOI,KAAa,KAAKA,IAAYD,EAAK,SAAUA,EAAKC,CAAS,IAAoB;AAC1F;AAEO,SAASC,EAAcC,GAAwC;AAClE,QAAMC,IAASD,EAAM,QACfP,IAAaQ,EAAO,QAAQ,IAAI;AAEtC,MAAI,CAACR,KAAcQ,MAAWR,KAAc,CAAC,CAAC,WAAW,WAAW,EAAE,SAASO,EAAM,GAAG;AACpF;AAGJ,QAAME,IAAUV,EAAeC,GAAYO,EAAM,GAA8B;AAC/E,EAAIE,MACAF,EAAM,eAAe,GACrBE,EAAQ,MAAM;AAEtB;"}
1
+ {"version":3,"file":"fondue-components72.js","sources":["../src/components/Table/utils.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type KeyboardEvent, type MouseEvent } from 'react';\n\nfunction getAdjacentRow(currentRow: HTMLElement, key: 'ArrowUp' | 'ArrowDown'): HTMLElement | null {\n const selector = 'tr[tabindex=\"0\"]';\n const table = currentRow.closest('table');\n if (!table) {\n return null;\n }\n\n const rows = Array.from(table.querySelectorAll(selector));\n const currentIndex = rows.indexOf(currentRow);\n const nextIndex = currentIndex + (key === 'ArrowUp' ? -1 : 1);\n\n return nextIndex >= 0 && nextIndex < rows.length ? (rows[nextIndex] as HTMLElement) : null;\n}\n\nexport function handleKeyDown(event: KeyboardEvent<HTMLTableElement>) {\n const target = event.target as HTMLElement;\n const currentRow = target.closest('tr');\n\n if (!currentRow || target !== currentRow || !['ArrowUp', 'ArrowDown'].includes(event.key)) {\n return;\n }\n\n const nextRow = getAdjacentRow(currentRow, event.key as 'ArrowUp' | 'ArrowDown');\n if (nextRow) {\n event.preventDefault();\n nextRow.focus();\n }\n}\n\nconst INTERACTIVE_ELEMENTS_LIST = [HTMLButtonElement, HTMLAnchorElement];\nconst INTERACTIVE_ROLES_LIST = ['button', 'link'];\n\nexport function isEventFromInteractiveElement(event?: MouseEvent): boolean {\n let node = event?.target instanceof Element ? event.target : null;\n\n while (node && !(node instanceof HTMLTableRowElement)) {\n if (INTERACTIVE_ELEMENTS_LIST.some((interactiveElement) => node instanceof interactiveElement)) {\n return true;\n }\n\n const role = node.getAttribute('role');\n if (role && INTERACTIVE_ROLES_LIST.includes(role)) {\n return true;\n }\n\n node = node.parentElement;\n }\n\n return false;\n}\n"],"names":["getAdjacentRow","currentRow","key","selector","table","rows","nextIndex","handleKeyDown","event","target","nextRow","INTERACTIVE_ELEMENTS_LIST","INTERACTIVE_ROLES_LIST","isEventFromInteractiveElement","node","interactiveElement","role"],"mappings":"AAIA,SAASA,EAAeC,GAAyBC,GAAkD;AAC/F,QAAMC,IAAW,oBACXC,IAAQH,EAAW,QAAQ,OAAO;AACxC,MAAI,CAACG;AACM,WAAA;AAGX,QAAMC,IAAO,MAAM,KAAKD,EAAM,iBAAiBD,CAAQ,CAAC,GAElDG,IADeD,EAAK,QAAQJ,CAAU,KACVC,MAAQ,YAAY,KAAK;AAE3D,SAAOI,KAAa,KAAKA,IAAYD,EAAK,SAAUA,EAAKC,CAAS,IAAoB;AAC1F;AAEO,SAASC,EAAcC,GAAwC;AAClE,QAAMC,IAASD,EAAM,QACfP,IAAaQ,EAAO,QAAQ,IAAI;AAEtC,MAAI,CAACR,KAAcQ,MAAWR,KAAc,CAAC,CAAC,WAAW,WAAW,EAAE,SAASO,EAAM,GAAG;AACpF;AAGJ,QAAME,IAAUV,EAAeC,GAAYO,EAAM,GAA8B;AAC/E,EAAIE,MACAF,EAAM,eAAe,GACrBE,EAAQ,MAAM;AAEtB;AAEA,MAAMC,IAA4B,CAAC,mBAAmB,iBAAiB,GACjEC,IAAyB,CAAC,UAAU,MAAM;AAEzC,SAASC,EAA8BL,GAA6B;AACvE,MAAIM,KAAON,KAAA,gBAAAA,EAAO,mBAAkB,UAAUA,EAAM,SAAS;AAEtD,SAAAM,KAAQ,EAAEA,aAAgB,wBAAsB;AACnD,QAAIH,EAA0B,KAAK,CAACI,MAAuBD,aAAgBC,CAAkB;AAClF,aAAA;AAGL,UAAAC,IAAOF,EAAK,aAAa,MAAM;AACrC,QAAIE,KAAQJ,EAAuB,SAASI,CAAI;AACrC,aAAA;AAGX,IAAAF,IAAOA,EAAK;AAAA,EAAA;AAGT,SAAA;AACX;"}
package/dist/index.d.ts CHANGED
@@ -643,6 +643,12 @@ declare type DividerProps = {
643
643
  * @default "div"
644
644
  */
645
645
  as?: 'div' | 'li';
646
+ /**
647
+ * When `true`, signifies that it is purely visual, carries no semantic
648
+ * meaning, and ensures it is not present in the accessibility tree.
649
+ * @default false
650
+ */
651
+ decorative?: boolean;
646
652
  'data-test-id'?: string;
647
653
  className?: string;
648
654
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontify/fondue-components",
3
3
  "type": "module",
4
- "version": "19.0.0",
4
+ "version": "19.1.0",
5
5
  "homepage": "https://github.com/Frontify/fondue",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,8 +30,8 @@
30
30
  "peerDependencies": {
31
31
  "react": "^18",
32
32
  "react-dom": "^18",
33
- "@frontify/fondue-tokens": "^4.2.0",
34
- "@frontify/fondue-icons": "^0.17.0"
33
+ "@frontify/fondue-icons": "^0.17.0",
34
+ "@frontify/fondue-tokens": "^4.2.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "@radix-ui/react-accordion": "^1.2.4",