asma-ui-core 3.20.1 → 3.21.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,14 +1,14 @@
1
- import { CloseIcon as s } from "../../icons/close-icon/CloseIcon.js";
1
+ import { CloseIcon as d } from "../../icons/close-icon/CloseIcon.js";
2
2
  import { ErrorOutlineIcon as p } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
3
3
  import { TextField as c } from "@mui/material";
4
4
  import { jsx as o, jsxs as m } from "react/jsx-runtime";
5
- var h = ({ allowClear: l, onClear: n, readOnly: t, disabled: u, error: e, helperText: a, dataTest: d, ...r }) => /* @__PURE__ */ o(c, {
5
+ var h = ({ allowClear: l, onClear: n, readOnly: t, disabled: u, error: e, helperText: a, dataTest: s, ...r }) => /* @__PURE__ */ o(c, {
6
6
  ...r,
7
- "data-testid": d,
7
+ "data-testid": s,
8
8
  disabled: (u ?? !1) || (t ?? !1),
9
9
  error: e,
10
- helperText: t ? null : e ? /* @__PURE__ */ m("div", {
11
- className: "flex items-center gap-1",
10
+ helperText: t ? null : e ? /* @__PURE__ */ m("span", {
11
+ className: "inline-flex items-center gap-1",
12
12
  children: [/* @__PURE__ */ o(p, {
13
13
  width: 20,
14
14
  height: 20,
@@ -24,7 +24,7 @@ var h = ({ allowClear: l, onClear: n, readOnly: t, disabled: u, error: e, helper
24
24
  onClick: (i) => {
25
25
  i.stopPropagation(), i.preventDefault(), n?.();
26
26
  },
27
- children: /* @__PURE__ */ o(s, {
27
+ children: /* @__PURE__ */ o(d, {
28
28
  width: 18,
29
29
  height: 18
30
30
  })
@@ -1,27 +1,29 @@
1
1
  import { ChevronDownIcon as a } from "../../../icons/chevron-down-icon/ChevronDownIcon.js";
2
2
  import r from "./StyledAccordion.module.js";
3
- import t from "clsx";
3
+ import o from "clsx";
4
4
  import "react";
5
- import { Fragment as s, jsx as o, jsxs as c } from "react/jsx-runtime";
6
- import { Accordion as g } from "@base-ui/react/accordion";
7
- var S = ({ size: m = "large", expandChevronRight: n, className: l, headerClassName: d, sx: p, children: i, ...x }) => {
8
- const e = m === "small", h = {
9
- "--trigger-height": e ? "48px" : "72px",
10
- "--trigger-padding-x": e ? "8px" : "16px",
11
- "--trigger-font-size": e ? "14px" : "18px",
12
- "--chevron-size": e ? "20px" : "24px",
5
+ import { Fragment as n, jsx as e, jsxs as s } from "react/jsx-runtime";
6
+ import { Accordion as c } from "@base-ui/react/accordion";
7
+ var N = ({ size: g = "large", expandChevronRight: m, className: l, headerClassName: d, sx: p, children: i, ...x }) => {
8
+ const t = g === "small", f = {
9
+ "--trigger-height": t ? "48px" : "72px",
10
+ "--trigger-padding-x": t ? "8px" : "16px",
11
+ "--trigger-font-size": t ? "14px" : "18px",
12
+ "--chevron-size": t ? "20px" : "24px",
13
13
  ...p
14
14
  };
15
- return /* @__PURE__ */ o(g.Header, {
16
- className: t(r.Header, d),
17
- children: /* @__PURE__ */ o(g.Trigger, {
15
+ return /* @__PURE__ */ e(c.Header, {
16
+ className: o(r.Header, d),
17
+ children: /* @__PURE__ */ e(c.Trigger, {
18
18
  ...x,
19
- className: t(r.Trigger, l),
20
- style: h,
21
- children: n ? /* @__PURE__ */ c(s, { children: [i, /* @__PURE__ */ o(a, {
22
- className: t(r.TriggerIcon, r.TriggerIconRight),
19
+ nativeButton: !1,
20
+ render: /* @__PURE__ */ e("div", {}),
21
+ className: o(r.Trigger, l),
22
+ style: f,
23
+ children: m ? /* @__PURE__ */ s(n, { children: [i, /* @__PURE__ */ e(a, {
24
+ className: o(r.TriggerIcon, r.TriggerIconRight),
23
25
  "data-state-icon": !0
24
- })] }) : /* @__PURE__ */ c(s, { children: [/* @__PURE__ */ o(a, {
26
+ })] }) : /* @__PURE__ */ s(n, { children: [/* @__PURE__ */ e(a, {
25
27
  className: r.TriggerIcon,
26
28
  "data-state-icon": !0
27
29
  }), i] })
@@ -29,5 +31,5 @@ var S = ({ size: m = "large", expandChevronRight: n, className: l, headerClassNa
29
31
  });
30
32
  };
31
33
  export {
32
- S as StyledAccordionSummary
34
+ N as StyledAccordionSummary
33
35
  };
@@ -4,7 +4,7 @@ import { ColumnDef, IAction, ICustomAction, RowActionsState } from '../../../typ
4
4
  export declare function generateActionsColumn<TData>(options: {
5
5
  headerPin: boolean;
6
6
  actions?: (row: Row<TData>) => (IAction<TData> | ICustomAction<TData>)[];
7
- customActionsNode?: (row: CellContext<TData, TData>) => ReactNode;
7
+ customActionsNode?: (row: CellContext<TData, unknown>) => ReactNode;
8
8
  rowHeight?: number;
9
9
  customActionsColumnProps?: Partial<ColumnDef<TData, unknown>>;
10
10
  rowActionsState?: (row: Row<TData>) => RowActionsState | undefined;
@@ -1,5 +1,5 @@
1
1
  import { HeaderContext } from '@tanstack/react-table';
2
2
  export declare function HeaderActionMenu<TData>({ headerData, locale, }: {
3
- headerData: HeaderContext<TData, TData>;
3
+ headerData: HeaderContext<TData, unknown>;
4
4
  locale?: 'en' | 'no';
5
5
  }): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { CellContext, Row } from '@tanstack/react-table';
2
2
  import { IAction, ICustomAction, RowActionsState } from '../../../../types';
3
3
  export declare function RowActionMenu<TData>({ tableData, actions, rowActionsState, }: {
4
- tableData: CellContext<TData, TData>;
4
+ tableData: CellContext<TData, unknown>;
5
5
  actions: (row: Row<TData>) => (IAction<TData> | ICustomAction<TData>)[];
6
6
  rowActionsState?: (row: Row<TData>) => RowActionsState | undefined;
7
7
  }): JSX.Element;
@@ -1,2 +1,2 @@
1
- import { ColumnDef } from '../../types';
2
- export declare function selectColumn<TData>(isFixed: boolean, rowHeight?: number): ColumnDef<TData, unknown>;
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ export declare function selectColumn<TData>(isFixed: boolean, rowHeight?: number, locale?: 'en' | 'no'): ColumnDef<TData, unknown>;
@@ -70,7 +70,11 @@ export type StyledTableProps<TData, TCustomData> = {
70
70
  locale?: 'no' | 'en';
71
71
  height?: string | number;
72
72
  actions?: (row: Row<TData>) => (IAction<TData> | ICustomAction<TData>)[];
73
- customActionsNode?: (row: CellContext<TData, TData>) => ReactNode;
73
+ /**
74
+ * Receives the actions cell context for the internal actions column.
75
+ * Use row.original and the row APIs instead of getValue(), because this column stores an unknown accessor value.
76
+ */
77
+ customActionsNode?: (row: CellContext<TData, unknown>) => ReactNode;
74
78
  customSubRowData?: Map<string, TCustomData[]>;
75
79
  headerPin?: boolean;
76
80
  expandArrow?: boolean;
@@ -1,56 +1,57 @@
1
- var l = "_tbody_15l6x_119", e = "_expanded_row_15l6x_182", _ = "_selected_15l6x_200", t = "_shadowed_15l6x_229", a = "_resizer_15l6x_283", o = "_isResizing_15l6x_295", r = {
2
- "asma-ui-table-styled-table": "_asma-ui-table-styled-table_15l6x_1",
3
- "table-wrapper": "_table-wrapper_15l6x_26",
4
- "table-shell": "_table-shell_15l6x_33",
5
- "table-wrapper--no-rows": "_table-wrapper--no-rows_15l6x_39",
6
- "table-wrapper--proxy": "_table-wrapper--proxy_15l6x_42",
7
- "table-wrapper--proxy-bottom": "_table-wrapper--proxy-bottom_15l6x_43",
8
- "table-wrapper-fetching": "_table-wrapper-fetching_15l6x_53",
9
- "table-scroll": "_table-scroll_15l6x_56",
10
- "table-x--fill-height": "_table-x--fill-height_15l6x_65",
11
- "table-x": "_table-x_15l6x_65",
12
- "table-header--sticky": "_table-header--sticky_15l6x_80",
13
- "table-hscroll": "_table-hscroll_15l6x_85",
14
- "table-hscroll__content": "_table-hscroll__content_15l6x_95",
15
- "no-rows-overlay-container": "_no-rows-overlay-container_15l6x_98",
16
- "no-rows-overlay-content": "_no-rows-overlay-content_15l6x_106",
17
- "styled-table": "_styled-table_15l6x_110",
18
- tbody: l,
19
- "loading-icon": "_loading-icon_15l6x_124",
20
- "t-row": "_t-row_15l6x_131",
21
- "t-cell": "_t-cell_15l6x_131",
22
- "action-cell": "_action-cell_15l6x_141",
23
- "fixed-cell": "_fixed-cell_15l6x_145",
24
- "fixed-right-cell": "_fixed-right-cell_15l6x_148",
25
- expanded_row: e,
26
- selected: _,
27
- "single-selection": "_single-selection_15l6x_203",
28
- "action-cell--no-shadow": "_action-cell--no-shadow_15l6x_220",
29
- "action-cell--not-fixed": "_action-cell--not-fixed_15l6x_223",
1
+ var e = "_tbody_1u0xz_124", _ = "_expanded_row_1u0xz_187", l = "_selected_1u0xz_205", t = "_shadowed_1u0xz_234", a = "_resizer_1u0xz_288", o = "_isResizing_1u0xz_300", r = {
2
+ "asma-ui-table-styled-table": "_asma-ui-table-styled-table_1u0xz_1",
3
+ "table-wrapper": "_table-wrapper_1u0xz_26",
4
+ "table-shell": "_table-shell_1u0xz_33",
5
+ "table-wrapper--no-rows": "_table-wrapper--no-rows_1u0xz_39",
6
+ "table-wrapper--proxy": "_table-wrapper--proxy_1u0xz_42",
7
+ "table-wrapper--proxy-bottom": "_table-wrapper--proxy-bottom_1u0xz_43",
8
+ "table-wrapper-fetching": "_table-wrapper-fetching_1u0xz_53",
9
+ "table-scroll": "_table-scroll_1u0xz_56",
10
+ "table-x--fill-height": "_table-x--fill-height_1u0xz_65",
11
+ "table-x": "_table-x_1u0xz_65",
12
+ "table-content": "_table-content_1u0xz_80",
13
+ "table-header--sticky": "_table-header--sticky_1u0xz_85",
14
+ "table-hscroll": "_table-hscroll_1u0xz_90",
15
+ "table-hscroll__content": "_table-hscroll__content_1u0xz_100",
16
+ "no-rows-overlay-container": "_no-rows-overlay-container_1u0xz_103",
17
+ "no-rows-overlay-content": "_no-rows-overlay-content_1u0xz_111",
18
+ "styled-table": "_styled-table_1u0xz_115",
19
+ tbody: e,
20
+ "loading-icon": "_loading-icon_1u0xz_129",
21
+ "t-row": "_t-row_1u0xz_136",
22
+ "t-cell": "_t-cell_1u0xz_136",
23
+ "action-cell": "_action-cell_1u0xz_146",
24
+ "fixed-cell": "_fixed-cell_1u0xz_150",
25
+ "fixed-right-cell": "_fixed-right-cell_1u0xz_153",
26
+ expanded_row: _,
27
+ selected: l,
28
+ "single-selection": "_single-selection_1u0xz_208",
29
+ "action-cell--no-shadow": "_action-cell--no-shadow_1u0xz_225",
30
+ "action-cell--not-fixed": "_action-cell--not-fixed_1u0xz_228",
30
31
  shadowed: t,
31
- "shadowed-right": "_shadowed-right_15l6x_263",
32
- "is-loading": "_is-loading_15l6x_267",
33
- "action-cell-default-background": "_action-cell-default-background_15l6x_270",
34
- "fixed-cell-default-background": "_fixed-cell-default-background_15l6x_273",
35
- "fixed-right-cell-default-background": "_fixed-right-cell-default-background_15l6x_276",
36
- "sortable-column": "_sortable-column_15l6x_279",
32
+ "shadowed-right": "_shadowed-right_1u0xz_268",
33
+ "is-loading": "_is-loading_1u0xz_272",
34
+ "action-cell-default-background": "_action-cell-default-background_1u0xz_275",
35
+ "fixed-cell-default-background": "_fixed-cell-default-background_1u0xz_278",
36
+ "fixed-right-cell-default-background": "_fixed-right-cell-default-background_1u0xz_281",
37
+ "sortable-column": "_sortable-column_1u0xz_284",
37
38
  resizer: a,
38
39
  isResizing: o,
39
- "hide-table-header": "_hide-table-header_15l6x_307",
40
- "show-table-header": "_show-table-header_15l6x_311",
41
- "table-header": "_table-header_15l6x_80",
42
- "hide-header": "_hide-header_15l6x_336",
43
- "t-cell__actions": "_t-cell__actions_15l6x_339",
44
- "t-cell__actions--no-shadow": "_t-cell__actions--no-shadow_15l6x_347",
45
- "t-cell__actions--not-fixed": "_t-cell__actions--not-fixed_15l6x_350",
46
- "t-cell__fixed": "_t-cell__fixed_15l6x_357",
47
- "t-cell__fixed-right": "_t-cell__fixed-right_15l6x_364",
48
- "sort-icon": "_sort-icon_15l6x_371",
49
- "table-footer--sticky": "_table-footer--sticky_15l6x_374",
50
- "table-footer--inline": "_table-footer--inline_15l6x_385",
51
- "table-bottom": "_table-bottom_15l6x_396",
52
- "table-bottom--sticky": "_table-bottom--sticky_15l6x_410",
53
- "cursor-not-allowed": "_cursor-not-allowed_15l6x_414"
40
+ "hide-table-header": "_hide-table-header_1u0xz_312",
41
+ "show-table-header": "_show-table-header_1u0xz_316",
42
+ "table-header": "_table-header_1u0xz_85",
43
+ "hide-header": "_hide-header_1u0xz_341",
44
+ "t-cell__actions": "_t-cell__actions_1u0xz_344",
45
+ "t-cell__actions--no-shadow": "_t-cell__actions--no-shadow_1u0xz_352",
46
+ "t-cell__actions--not-fixed": "_t-cell__actions--not-fixed_1u0xz_355",
47
+ "t-cell__fixed": "_t-cell__fixed_1u0xz_362",
48
+ "t-cell__fixed-right": "_t-cell__fixed-right_1u0xz_369",
49
+ "sort-icon": "_sort-icon_1u0xz_376",
50
+ "table-footer--sticky": "_table-footer--sticky_1u0xz_379",
51
+ "table-footer--inline": "_table-footer--inline_1u0xz_390",
52
+ "table-bottom": "_table-bottom_1u0xz_401",
53
+ "table-bottom--sticky": "_table-bottom--sticky_1u0xz_415",
54
+ "cursor-not-allowed": "_cursor-not-allowed_1u0xz_419"
54
55
  };
55
56
  export {
56
57
  r as default
@@ -2,7 +2,7 @@ import { cn as p } from "../helpers/cn.js";
2
2
  import { RootContextProvider as te } from "../context/RootContext.js";
3
3
  import { mobileView as oe, useWindowWidthSize as re } from "../hooks/useWindowWidthSize.hook.js";
4
4
  import { useStyledTable as ne } from "../hooks/useStyledTable.js";
5
- import o from "./StyledTable.module.js";
5
+ import e from "./StyledTable.module.js";
6
6
  import { injectColumns as le } from "../helpers/injectColumns.js";
7
7
  import { TableHeader as se } from "./table-header/TableHeader.js";
8
8
  import { TableBody as ie } from "./TableBody.js";
@@ -12,38 +12,38 @@ import { useProxyHorizontalScrollSync as ce } from "./columns/helpers/useProxyHo
12
12
  import { useElementHeightPx as $ } from "./columns/helpers/useElementHeightPx.js";
13
13
  import { useColumnVirtualizer as de } from "../hooks/useColumnVirtualizer.js";
14
14
  import { useLayoutEffect as q, useMemo as O, useRef as L, useState as me } from "react";
15
- import { Fragment as X, jsx as e, jsxs as R } from "react/jsx-runtime";
15
+ import { Fragment as X, jsx as t, jsxs as w } from "react/jsx-runtime";
16
16
  import { DndContext as fe, closestCenter as he } from "@dnd-kit/core";
17
17
  import { restrictToParentElement as be, restrictToVerticalAxis as ue } from "@dnd-kit/modifiers";
18
18
  import { arrayMove as pe } from "@dnd-kit/sortable";
19
- function we({ enabled: l, data: t, setData: i, children: w }) {
20
- const v = O(() => t.map((c) => c.id), [t]), S = (c) => {
19
+ function we({ enabled: l, data: o, setData: i, children: v }) {
20
+ const y = O(() => o.map((c) => c.id), [o]), S = (c) => {
21
21
  if (!l || !i) return;
22
22
  const { active: m, over: f } = c;
23
- !m || !f || m.id === f.id || i((y) => pe(y, v.indexOf(m.id), v.indexOf(f.id)));
23
+ !m || !f || m.id === f.id || i((g) => pe(g, y.indexOf(m.id), y.indexOf(f.id)));
24
24
  };
25
- return l ? /* @__PURE__ */ e(fe, {
25
+ return l ? /* @__PURE__ */ t(fe, {
26
26
  collisionDetection: he,
27
27
  modifiers: [ue, be],
28
28
  onDragEnd: S,
29
- children: w
30
- }) : /* @__PURE__ */ e(X, { children: w });
29
+ children: v
30
+ }) : /* @__PURE__ */ t(X, { children: v });
31
31
  }
32
- function ve({ enabled: l, className: t, children: i }) {
33
- return l ? /* @__PURE__ */ e("div", {
34
- className: t,
32
+ function ve({ enabled: l, className: o, children: i }) {
33
+ return l ? /* @__PURE__ */ t("div", {
34
+ className: o,
35
35
  children: i
36
- }) : /* @__PURE__ */ e(X, { children: i });
36
+ }) : /* @__PURE__ */ t(X, { children: i });
37
37
  }
38
38
  var Ve = (l) => {
39
- const t = O(() => ({
39
+ const o = O(() => ({
40
40
  ...l,
41
41
  rowHeight: l.rowHeight ?? 48
42
- }), [l]), { className: i, tableClassName: w, height: v, noRowsOverlay: S, data: c, enableDnd: m, setData: f, loading: y } = t;
43
- le(t);
44
- const { table: a } = ne(t), C = c.length > 0, F = C && !!y, h = !C && !y, z = oe(re()), r = !!t.stickyFooter && !z, [G, M] = me(!1), g = L(null), W = L(null), P = t.hideHeader ? 0 : 32, { tableScrollRef: x, tableXRef: H, hScrollRef: J, hScrollContentRef: K } = ce(!r);
42
+ }), [l]), { className: i, tableClassName: v, height: y, noRowsOverlay: S, data: c, enableDnd: m, setData: f, loading: g } = o;
43
+ le(o);
44
+ const { table: a } = ne(o), C = c.length > 0, F = C && !!g, h = !C && !g, z = oe(re()), r = !!o.stickyFooter && !z, [G, M] = me(!1), x = L(null), W = L(null), P = o.hideHeader ? 0 : 32, { tableScrollRef: R, tableXRef: H, hScrollRef: J, hScrollContentRef: K } = ce(!r);
45
45
  q(() => {
46
- const n = r ? g.current : H.current ?? x.current;
46
+ const n = r ? x.current : H.current ?? R.current;
47
47
  if (!n) {
48
48
  M(!1);
49
49
  return;
@@ -60,26 +60,26 @@ var Ve = (l) => {
60
60
  }, [
61
61
  r,
62
62
  H,
63
- x
63
+ R
64
64
  ]);
65
- const { ref: Q, heightPx: k } = $(), { ref: U, heightPx: D } = $(), T = t.rowHeight ?? 48, E = a.getRowModel().rows.length, V = t.hideHeader ? 0 : 32, _ = 12, Y = O(() => {
66
- if (T <= 0) return 0;
65
+ const { ref: Q, heightPx: k } = $(), { ref: U, heightPx: D } = $(), N = o.rowHeight ?? 48, E = a.getRowModel().rows.length, V = o.hideHeader ? 0 : 32, _ = 12, Y = O(() => {
66
+ if (N <= 0) return 0;
67
67
  const n = r ? 0 : V + D + _, s = Math.max(0, k - n);
68
- return Math.floor(s / T);
68
+ return Math.floor(s / N);
69
69
  }, [
70
70
  r,
71
71
  D,
72
72
  V,
73
73
  _,
74
- T,
74
+ N,
75
75
  k
76
- ]), N = !r && E > 0 && E <= Y, Z = p(r ? o["table-wrapper"] : N || !r && h ? o["table-wrapper--proxy-bottom"] : o["table-wrapper--proxy"], F && o["table-wrapper-fetching"], h && o["table-wrapper--no-rows"], i), { columnWindow: j } = de({
76
+ ]), T = !r && E > 0 && E <= Y, Z = p(r ? e["table-wrapper"] : T || !r && h ? e["table-wrapper--proxy-bottom"] : e["table-wrapper--proxy"], F && e["table-wrapper-fetching"], h && e["table-wrapper--no-rows"], i), { columnWindow: j } = de({
77
77
  table: a,
78
- scrollRef: r ? g : x,
78
+ scrollRef: r ? x : R,
79
79
  isMobileView: z
80
80
  });
81
81
  q(() => {
82
- const n = g.current, s = W.current, b = () => n?.style.removeProperty("--no-rows-content-height");
82
+ const n = x.current, s = W.current, b = () => n?.style.removeProperty("--no-rows-content-height");
83
83
  if (!n || !h || !s) {
84
84
  b();
85
85
  return;
@@ -91,83 +91,82 @@ var Ve = (l) => {
91
91
  u.disconnect(), b();
92
92
  };
93
93
  }, [h, P]);
94
- const A = /* @__PURE__ */ R("table", {
95
- className: o["styled-table"],
96
- style: {
97
- width: a.getTotalSize(),
98
- minWidth: "100%"
99
- },
100
- children: [
101
- /* @__PURE__ */ e(se, {
94
+ const A = /* @__PURE__ */ w("div", {
95
+ className: e["table-content"],
96
+ children: [/* @__PURE__ */ w("table", {
97
+ className: e["styled-table"],
98
+ style: {
99
+ width: a.getTotalSize(),
100
+ minWidth: "100%"
101
+ },
102
+ children: [/* @__PURE__ */ t(se, {
102
103
  table: a,
103
- styledTableProps: t,
104
- tableCanResize: !!t.enableColumnResizing,
104
+ styledTableProps: o,
105
+ tableCanResize: !!o.enableColumnResizing,
105
106
  tableWidth: null,
106
107
  columnWindow: j
107
- }),
108
- /* @__PURE__ */ e(ae, { fetching: !!F }),
109
- /* @__PURE__ */ e(ie, {
108
+ }), /* @__PURE__ */ t(ie, {
110
109
  table: a,
111
- styledTableProps: t,
110
+ styledTableProps: o,
112
111
  columnWindow: j
113
- })
114
- ]
115
- }), ee = h ? /* @__PURE__ */ e("div", {
116
- className: o["no-rows-overlay-container"],
112
+ })]
113
+ }), /* @__PURE__ */ t(ae, { fetching: !!F })]
114
+ }), ee = h ? /* @__PURE__ */ t("div", {
115
+ className: e["no-rows-overlay-container"],
117
116
  style: { top: P },
118
- children: /* @__PURE__ */ e("div", {
117
+ children: /* @__PURE__ */ t("div", {
119
118
  ref: W,
120
- className: o["no-rows-overlay-content"],
119
+ className: e["no-rows-overlay-content"],
121
120
  children: S
122
121
  })
123
122
  }) : null;
124
- return /* @__PURE__ */ e(te, { children: /* @__PURE__ */ e(we, {
123
+ return /* @__PURE__ */ t(te, { children: /* @__PURE__ */ t(we, {
125
124
  enabled: !!m,
126
125
  data: c,
127
126
  setData: f,
128
- children: /* @__PURE__ */ R("div", {
127
+ children: /* @__PURE__ */ w("div", {
129
128
  ref: Q,
130
- className: p(o["asma-ui-table-styled-table"], w),
129
+ className: p(e["asma-ui-table-styled-table"], v),
131
130
  "data-x-overflow": G ? "true" : "false",
132
- style: { height: v },
133
- children: [/* @__PURE__ */ e(ve, {
131
+ style: { height: y },
132
+ children: [/* @__PURE__ */ t(ve, {
134
133
  enabled: r,
135
- className: o["table-shell"],
136
- children: /* @__PURE__ */ R("div", {
137
- ref: g,
134
+ className: e["table-shell"],
135
+ children: /* @__PURE__ */ w("div", {
136
+ ref: x,
138
137
  className: Z,
139
- children: [r ? A : /* @__PURE__ */ R("div", {
140
- ref: x,
141
- className: p(o["table-scroll"]),
138
+ children: [r ? A : /* @__PURE__ */ w("div", {
139
+ ref: R,
140
+ className: p(e["table-scroll"]),
142
141
  children: [
143
- /* @__PURE__ */ e("div", {
142
+ /* @__PURE__ */ t("div", {
144
143
  ref: H,
145
- className: p(o["table-x"], !N && o["table-x--fill-height"]),
144
+ className: p(e["table-x"], !T && e["table-x--fill-height"]),
146
145
  children: A
147
146
  }),
148
- /* @__PURE__ */ e("div", {
147
+ /* @__PURE__ */ t("div", {
149
148
  ref: J,
150
- className: o["table-hscroll"],
151
- children: /* @__PURE__ */ e("div", {
149
+ className: e["table-hscroll"],
150
+ children: /* @__PURE__ */ t("div", {
152
151
  ref: K,
153
- className: o["table-hscroll__content"]
152
+ className: e["table-hscroll__content"]
154
153
  })
155
154
  }),
156
- /* @__PURE__ */ e("div", {
155
+ /* @__PURE__ */ t("div", {
157
156
  ref: U,
158
- className: p(o["table-bottom"], N && o["table-bottom--sticky"]),
159
- children: /* @__PURE__ */ e(B, {
157
+ className: p(e["table-bottom"], T && e["table-bottom--sticky"]),
158
+ children: /* @__PURE__ */ t(B, {
160
159
  table: a,
161
- styledTableProps: t,
160
+ styledTableProps: o,
162
161
  canShowStickyFooter: !1
163
162
  })
164
163
  })
165
164
  ]
166
165
  }), ee]
167
166
  })
168
- }), r && /* @__PURE__ */ e(B, {
167
+ }), r && /* @__PURE__ */ t(B, {
169
168
  table: a,
170
- styledTableProps: t,
169
+ styledTableProps: o,
171
170
  canShowStickyFooter: !0
172
171
  })]
173
172
  })
@@ -1,59 +1,88 @@
1
- import { SELECT_COLUMN_ID as a } from "../../types.js";
2
- import c from "../StyledTable.module.js";
3
- import { StyledCheckbox as r } from "../../shared-components/StyledCheckbox.js";
4
- import { StyledTooltip as d } from "../../shared-components/tooltip/index.js";
5
- import { jsx as t } from "react/jsx-runtime";
6
- function S(i, s) {
1
+ import { SELECT_COLUMN_ID as u } from "../../types.js";
2
+ import m from "../StyledTable.module.js";
3
+ import { StyledCheckbox as n } from "../../shared-components/StyledCheckbox.js";
4
+ import { StyledTooltip as p } from "../../shared-components/tooltip/index.js";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ var s = (t) => {
7
+ t.preventDefault(), t.stopPropagation();
8
+ }, i = (t, o) => {
9
+ t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), o());
10
+ }, w = (t) => t === "no" ? {
11
+ selectAll: "Velg alle rader",
12
+ selectRow: (o) => `Velg rad ${o}`
13
+ } : {
14
+ selectAll: "Select all rows",
15
+ selectRow: (o) => `Select row ${o}`
16
+ };
17
+ function k(t, o, c) {
18
+ const a = w(c);
7
19
  return {
8
- id: a,
20
+ id: u,
9
21
  minSize: 38,
10
22
  maxSize: 38,
11
23
  size: 38,
12
- header: ({ table: e }) => /* @__PURE__ */ t("button", {
13
- type: "button",
24
+ header: ({ table: e }) => /* @__PURE__ */ r("div", {
25
+ role: "checkbox",
26
+ tabIndex: 0,
27
+ "aria-label": a.selectAll,
28
+ "aria-checked": e.getIsSomeRowsSelected() ? "mixed" : e.getIsAllRowsSelected(),
14
29
  className: "flex size-full items-center justify-start pl-2",
15
30
  onClick: () => e.toggleAllRowsSelected(),
16
- children: /* @__PURE__ */ t(r, {
31
+ onMouseDown: s,
32
+ onMouseUp: s,
33
+ onKeyDown: (l) => i(l, () => e.toggleAllRowsSelected()),
34
+ children: /* @__PURE__ */ r(n, {
17
35
  size: "small",
18
36
  dataTest: "cell-select-all",
37
+ "aria-hidden": !0,
38
+ tabIndex: -1,
19
39
  checked: e.getIsAllRowsSelected(),
20
40
  indeterminate: e.getIsSomeRowsSelected(),
41
+ className: "pointer-events-none",
21
42
  hideWrapper: !0
22
43
  })
23
44
  }),
24
45
  cell: ({ cell: e }) => {
25
46
  const l = !e.row.getCanSelect();
26
- return /* @__PURE__ */ t("button", {
27
- type: "button",
28
- style: { height: s ?? "auto" },
29
- className: "m-0 flex w-full items-center justify-start p-0 pl-2",
47
+ return /* @__PURE__ */ r("div", {
48
+ role: "checkbox",
49
+ tabIndex: l ? -1 : 0,
50
+ "aria-label": a.selectRow(e.row.index + 1),
51
+ "aria-checked": e.row.getIsSelected(),
30
52
  "aria-disabled": l,
53
+ style: { height: o ?? "auto" },
54
+ className: "m-0 flex w-full items-center justify-start p-0 pl-2",
31
55
  onClick: () => {
32
56
  l || e.row.toggleSelected();
33
57
  },
34
- children: /* @__PURE__ */ t(d, {
58
+ onMouseDown: s,
59
+ onMouseUp: s,
60
+ onKeyDown: (d) => {
61
+ l || i(d, () => e.row.toggleSelected());
62
+ },
63
+ children: /* @__PURE__ */ r(p, {
35
64
  arrow: !0,
36
65
  placement: "top-start",
37
66
  title: e.row.getRowSelectionTooltip(),
38
- children: /* @__PURE__ */ t("span", {
39
- className: l ? c["cursor-not-allowed"] : void 0,
40
- children: /* @__PURE__ */ t(r, {
67
+ children: /* @__PURE__ */ r("span", {
68
+ className: l ? m["cursor-not-allowed"] : void 0,
69
+ children: /* @__PURE__ */ r(n, {
41
70
  size: "small",
42
71
  dataTest: "cell-select",
72
+ "aria-hidden": !0,
73
+ tabIndex: -1,
43
74
  checked: e.row.getIsSelected(),
44
75
  hideWrapper: !0,
45
76
  disabled: l,
46
- onMouseUp: (o) => {
47
- o.preventDefault(), o.stopPropagation();
48
- }
77
+ className: "pointer-events-none"
49
78
  })
50
79
  })
51
80
  })
52
81
  });
53
82
  },
54
- fixedLeft: i
83
+ fixedLeft: t
55
84
  };
56
85
  }
57
86
  export {
58
- S as selectColumn
87
+ k as selectColumn
59
88
  };
@@ -4,17 +4,17 @@ import { generateExpandColumn as h } from "../components/columns/expandColumn.js
4
4
  import { generateActionsColumn as x } from "../components/columns/action-column/actionColumn.js";
5
5
  import { generateDndHandleColumn as _ } from "../components/columns/dndHandleColumn.js";
6
6
  import { generateShowFullTextColumn as A } from "../components/columns/showTextColumn.js";
7
- var T = (s) => {
8
- const { columns: o, actions: i, customActionsNode: r, headerPin: d = !0, enableRowSelection: f, expandArrow: l, enableDnd: u, customDndColumnProps: a, rowHeight: e, textExpandArrow: m, customActionsColumnProps: c, rowActionsState: p, locale: C } = s, t = o.some((n) => n.fixedLeft === !0);
7
+ var T = (f) => {
8
+ const { columns: o, actions: i, customActionsNode: r, headerPin: d = !0, enableRowSelection: l, expandArrow: u, enableDnd: a, customDndColumnProps: c, rowHeight: e, textExpandArrow: m, customActionsColumnProps: p, rowActionsState: C, locale: s } = f, t = o.some((n) => n.fixedLeft === !0);
9
9
  !o.find((n) => n.id === "actions") && (i || r || d) && o.push(x({
10
10
  headerPin: d,
11
11
  actions: i,
12
12
  customActionsNode: r,
13
13
  rowHeight: e,
14
- customActionsColumnProps: c,
15
- rowActionsState: p,
16
- locale: C
17
- })), m && !o.find((n) => n.id === "show-full-text") && o.unshift(A(t, e)), l && !m && !o.find((n) => n.id === "expand-column-id") && o.unshift(h(t, e)), u && !o.find((n) => n.id === "dnd-handle") && o.unshift(_(a, e)), f && !o.find((n) => n.id === "select") && o.unshift(D(t, e));
14
+ customActionsColumnProps: p,
15
+ rowActionsState: C,
16
+ locale: s
17
+ })), m && !o.find((n) => n.id === "show-full-text") && o.unshift(A(t, e)), u && !m && !o.find((n) => n.id === "expand-column-id") && o.unshift(h(t, e)), a && !o.find((n) => n.id === "dnd-handle") && o.unshift(_(c, e)), l && !o.find((n) => n.id === "select") && o.unshift(D(t, e, s));
18
18
  };
19
19
  export {
20
20
  T as injectColumns
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.20.1",
6
+ "version": "3.21.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",