@hortiview/shared-components 0.0.6285 → 0.0.6332

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 +1 @@
1
- ._bulletPoint_469qk_1{display:list-item;margin-left:1.5rem}._modal_469qk_6 [class*="lmnt-modal__actions mdc-dialog__actions"]{margin-bottom:0!important}._colorDanger_469qk_10{color:var(--lmnt-theme-danger-on-surface)}
1
+ ._bulletPoint_1kyg0_1{display:list-item;margin-left:1.5rem}._modal_1kyg0_6 [class*="lmnt-modal__actions mdc-dialog__actions"]{margin-bottom:0!important}._colorDanger_1kyg0_10{color:var(--lmnt-theme-danger-on-surface)}._crossedOut_1kyg0_14{position:relative;display:inline-block}._crossedOut_1kyg0_14:after{content:"";position:absolute;width:3rem;height:.25rem;left:50%;top:50%;background:var(--lmnt-theme-danger-on-surface);box-shadow:0 0 0 .125rem var(--lmnt-theme-background);transform:translate(-50%,calc(-50% - .25rem)) rotate(45deg);transform-origin:center;z-index:2}
@@ -31,7 +31,12 @@ type DeleteModalProps = {
31
31
  /**
32
32
  * The icon to display in the modal.
33
33
  */
34
- icon?: string;
34
+ icon?: string | JSX.Element;
35
+ /**
36
+ * If true, the icon to display in the modal will be crossed out with a red line.
37
+ * The icon should not be larger than 2.5 rem height and 3 rem width.
38
+ */
39
+ isIconCrossedOut?: boolean;
35
40
  /**
36
41
  * The state of the modal.
37
42
  */
@@ -61,11 +66,12 @@ type DeleteModalProps = {
61
66
  * @prop {string | JSX.Element} deleteText - A text or JSX element to display in the delete modal. If provided the deleteBody will be ignored.
62
67
  * @prop {string} impossibleDeleteHeader - The header to display in the modal if the {@link isDeletePossible} is false.
63
68
  * @prop {string} icon - The icon to display in the modal.
69
+ * @prop {boolean} isIconCrossedOut - If true, the icon to display in the modal will be crossed out with a red line. The icon should not be larger than 2.5 rem height and 3 rem width.
64
70
  * @prop {boolean} open - The state of the modal.
65
71
  * @prop {function} setOpen - The function to set the state of the modal.
66
72
  * @prop {function} onDelete - The function to call when the confirm button is clicked.
67
73
  * @prop {boolean} isDeletePossible - If true, the delete button will be enabled. If false, the delete button will be disabled and the {@link impossibleDeleteHeader} will be displayed. Default is _true_.
68
74
  * @returns {ReactElement} A modal component for deleting items.
69
75
  */
70
- export declare const DeleteModal: ({ title, confirmButtonLabel, cancelButtonLabel, deleteHeader, deleteBody, deleteText, icon, impossibleDeleteHeader, open, setOpen, onDelete, isDeletePossible, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
76
+ export declare const DeleteModal: ({ title, confirmButtonLabel, cancelButtonLabel, deleteHeader, deleteBody, deleteText, icon, isIconCrossedOut, impossibleDeleteHeader, open, setOpen, onDelete, isDeletePossible, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
71
77
  export {};
@@ -1,77 +1,94 @@
1
1
  import "../../assets/DeleteModal.css";
2
- import { jsx as o, jsxs as m, Fragment as d } from "react/jsx-runtime";
3
- import { Modal as D, Button as u, Group as i, Icon as j, TypoBody as n } from "@element/react-components";
4
- import { uniqueId as q } from "lodash";
5
- import { AvailableCustomIcons as g } from "../../enums/AvailableCustomIcons.js";
6
- import { Iconify as x } from "../Iconify/Iconify.js";
7
- const I = "_bulletPoint_469qk_1", N = "_modal_469qk_6", S = "_colorDanger_469qk_10", e = {
8
- bulletPoint: I,
9
- modal: N,
10
- colorDanger: S
11
- }, F = ({
12
- title: h,
13
- confirmButtonLabel: p,
14
- cancelButtonLabel: v,
15
- deleteHeader: b,
16
- deleteBody: t,
17
- deleteText: r,
18
- icon: l,
19
- impossibleDeleteHeader: f,
20
- open: y,
21
- setOpen: c,
22
- onDelete: k,
23
- isDeletePossible: s = !0
2
+ import { jsx as o, jsxs as g, Fragment as i } from "react/jsx-runtime";
3
+ import { Modal as C, Button as u, Group as s, Icon as D, TypoBody as t } from "@element/react-components";
4
+ import { uniqueId as I } from "lodash";
5
+ import { AvailableCustomIcons as O } from "../../enums/AvailableCustomIcons.js";
6
+ import { Iconify as N } from "../Iconify/Iconify.js";
7
+ const S = "_bulletPoint_1kyg0_1", x = "_modal_1kyg0_6", M = "_colorDanger_1kyg0_10", j = "_crossedOut_1kyg0_14", n = {
8
+ bulletPoint: S,
9
+ modal: x,
10
+ colorDanger: M,
11
+ crossedOut: j
12
+ }, J = ({
13
+ title: r,
14
+ confirmButtonLabel: e,
15
+ cancelButtonLabel: l,
16
+ deleteHeader: a,
17
+ deleteBody: c,
18
+ deleteText: p,
19
+ icon: f,
20
+ isIconCrossedOut: h,
21
+ impossibleDeleteHeader: y,
22
+ open: b,
23
+ setOpen: d,
24
+ onDelete: v,
25
+ isDeletePossible: m = !0
24
26
  }) => {
25
- const C = (a) => {
26
- a.detail.action === "close" && c(!1);
27
+ const _ = (k) => {
28
+ k.detail.action === "close" && d(!1);
27
29
  };
28
30
  return /* @__PURE__ */ o(
29
- D,
31
+ C,
30
32
  {
31
- className: e.modal,
33
+ className: n.modal,
32
34
  modalSize: "small",
33
- open: y,
34
- onClose: C,
35
- title: h,
35
+ open: b,
36
+ onClose: _,
37
+ title: r,
36
38
  primaryButton: /* @__PURE__ */ o(
37
39
  u,
38
40
  {
39
41
  variant: "danger",
40
- label: p,
41
- onClick: k,
42
- disabled: !s
42
+ label: e,
43
+ onClick: v,
44
+ disabled: !m
43
45
  }
44
46
  ),
45
- dismissiveButton: /* @__PURE__ */ o(u, { variant: "text", label: v, onClick: () => c(!1) }),
46
- children: /* @__PURE__ */ m(i, { direction: "vertical", secondaryAlign: "center", children: [
47
- l && Object.values(g).includes(l) && /* @__PURE__ */ o(
48
- x,
47
+ footerSupplemental: /* @__PURE__ */ o(u, { variant: "text", label: l, onClick: () => d(!1) }),
48
+ children: /* @__PURE__ */ g(s, { direction: "vertical", secondaryAlign: "center", children: [
49
+ /* @__PURE__ */ o(z, { element: /* @__PURE__ */ o(P, { icon: f }), isCrossedOut: h }),
50
+ /* @__PURE__ */ o(s, { direction: "vertical", children: m ? /* @__PURE__ */ o(
51
+ A,
49
52
  {
50
- icon: l,
51
- iconSize: "xlarge",
52
- className: e.colorDanger
53
+ deleteHeader: a,
54
+ deleteText: p,
55
+ deleteBody: c
53
56
  }
54
- ),
55
- l && !Object.values(g).includes(l) && /* @__PURE__ */ o(j, { icon: l, iconSize: "xlarge", className: e.colorDanger }),
56
- /* @__PURE__ */ o(i, { direction: "vertical", children: s ? /* @__PURE__ */ m(d, { children: [
57
- /* @__PURE__ */ o(n, { level: 1, themeColor: "text-primary-on-background", children: b }),
58
- r && typeof r == "string" && /* @__PURE__ */ o(n, { level: 2, themeColor: "text-secondary-on-background", children: r }),
59
- r && typeof r != "string" && /* @__PURE__ */ o(d, { children: r }),
60
- t && r === void 0 && /* @__PURE__ */ o(i, { direction: "vertical", gap: "none", children: t.map((a, _) => /* @__PURE__ */ o(
61
- n,
62
- {
63
- level: 2,
64
- className: e.bulletPoint,
65
- themeColor: "text-secondary-on-background",
66
- children: a
67
- },
68
- q(_.toString())
69
- )) })
70
- ] }) : /* @__PURE__ */ o(n, { level: 1, themeColor: "text-primary-on-background", children: f }) })
57
+ ) : /* @__PURE__ */ o(B, { impossibleDeleteHeader: y }) })
71
58
  ] })
72
59
  }
73
60
  );
74
- };
61
+ }, z = ({
62
+ element: r,
63
+ isCrossedOut: e = !1
64
+ }) => e ? /* @__PURE__ */ o("span", { className: n.crossedOut, children: r }) : r, P = ({ icon: r }) => r ? typeof r != "string" ? r : Object.values(O).includes(r) ? /* @__PURE__ */ o(
65
+ N,
66
+ {
67
+ icon: r,
68
+ iconSize: "xlarge",
69
+ className: n.colorDanger
70
+ }
71
+ ) : /* @__PURE__ */ o(D, { icon: r, iconSize: "xlarge", className: n.colorDanger }) : /* @__PURE__ */ o(i, {}), A = ({
72
+ deleteHeader: r,
73
+ deleteText: e,
74
+ deleteBody: l
75
+ }) => /* @__PURE__ */ g(i, { children: [
76
+ /* @__PURE__ */ o(t, { level: 1, themeColor: "text-primary-on-background", children: r }),
77
+ e && typeof e == "string" && /* @__PURE__ */ o(t, { level: 2, themeColor: "text-secondary-on-background", children: e }),
78
+ e && typeof e != "string" && /* @__PURE__ */ o(i, { children: e }),
79
+ l && e === void 0 && /* @__PURE__ */ o(s, { direction: "vertical", gap: "none", children: l.map((a, c) => /* @__PURE__ */ o(
80
+ t,
81
+ {
82
+ level: 2,
83
+ className: n.bulletPoint,
84
+ themeColor: "text-secondary-on-background",
85
+ children: a
86
+ },
87
+ I(c.toString())
88
+ )) })
89
+ ] }), B = ({
90
+ impossibleDeleteHeader: r
91
+ }) => /* @__PURE__ */ o(t, { level: 1, themeColor: "text-primary-on-background", children: r });
75
92
  export {
76
- F as DeleteModal
93
+ J as DeleteModal
77
94
  };
@@ -50,4 +50,4 @@ import { TableLayoutProps } from '../../types/GenericTable';
50
50
  * @param headerTranslation function that will be called to translate the headers by its key
51
51
  * @returns a table based on a given type and data
52
52
  */
53
- export declare const GenericTable: <T>({ data, hiddenColumns, order, cellTemplates, tableActions, noContentText, headerTranslation, pagination, getRowActions, }: TableLayoutProps<T>) => import("react/jsx-runtime").JSX.Element;
53
+ export declare const GenericTable: <T>({ data, hiddenColumns, order, cellTemplates, tableActions, noContentText, headerTranslation, pagination, getRowActions, customColumnWidth, title, }: TableLayoutProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,89 +1,98 @@
1
1
  import "../../assets/GenericTable.css";
2
- import { jsx as n } from "react/jsx-runtime";
3
- import { Elevation as h, Table as v, TableTopBar as y, Group as d, TypoSubtitle as B } from "@element/react-components";
4
- import { useMemo as b, Fragment as g } from "react";
5
- import { ContextMenu as T } from "../ContextMenu/ContextMenu.js";
6
- const x = "_topBar_1msoo_1", N = "_filterBar_1msoo_5", C = "_emptyTable_1msoo_9", I = "_elevation_1msoo_17", M = "_table_1msoo_22", m = {
7
- topBar: x,
8
- filterBar: N,
9
- emptyTable: C,
10
- elevation: I,
11
- table: M
12
- }, W = (e, l) => {
13
- if (!e)
2
+ import { jsx as e, jsxs as B } from "react/jsx-runtime";
3
+ import { Elevation as T, Table as x, TableTopBar as b, Group as _, Padding as N, TypoDisplay as j, TypoSubtitle as C } from "@element/react-components";
4
+ import { useMemo as v, Fragment as D } from "react";
5
+ import { ContextMenu as I } from "../ContextMenu/ContextMenu.js";
6
+ const M = "_topBar_1msoo_1", G = "_filterBar_1msoo_5", O = "_emptyTable_1msoo_9", P = "_elevation_1msoo_17", W = "_table_1msoo_22", d = {
7
+ topBar: M,
8
+ filterBar: G,
9
+ emptyTable: O,
10
+ elevation: P,
11
+ table: W
12
+ }, z = (n, l) => {
13
+ if (!n)
14
14
  return [];
15
- let o = Object.keys(e).map((r) => r);
16
- return l.length > 0 && (o = o.sort((r, u) => {
17
- const p = l.findIndex((s) => s === r), i = l.findIndex((s) => s === u);
18
- return p === -1 ? 1 : i === -1 ? -1 : p - i;
15
+ let o = Object.keys(n).map((t) => t);
16
+ return l.length > 0 && (o = o.sort((t, i) => {
17
+ const m = l.findIndex((c) => c === t), s = l.findIndex((c) => c === i);
18
+ return m === -1 ? 1 : s === -1 ? -1 : m - s;
19
19
  })), o;
20
- }, E = ({
21
- data: e = [],
20
+ }, $ = ({
21
+ data: n = [],
22
22
  hiddenColumns: l = [],
23
23
  order: o = [],
24
- cellTemplates: r = void 0,
25
- tableActions: u = [],
26
- noContentText: p = "No data available",
27
- headerTranslation: i = (f) => f,
28
- pagination: s = !1,
29
- getRowActions: c = void 0
24
+ cellTemplates: t = void 0,
25
+ tableActions: i = [],
26
+ noContentText: m = "No data available",
27
+ headerTranslation: s = (f) => f,
28
+ pagination: c = !1,
29
+ getRowActions: p = void 0,
30
+ customColumnWidth: h,
31
+ title: u
30
32
  }) => {
31
- const f = b(() => {
32
- if (e.length === 0)
33
+ const f = v(() => {
34
+ if (n.length === 0)
33
35
  return [];
34
- const a = W(e[0], o).map((t) => ({
35
- id: t,
36
- header: i(t),
37
- accessor: t,
38
- cellTemplate: r ? r[t] : void 0
39
- }));
40
- return c ? [...a, { id: "actions", header: "", accessor: "actions" }] : a;
41
- }, [e, r, o, i, c]), _ = b(() => c ? e.map((a) => {
42
- const t = /* @__PURE__ */ n(T, { actions: c(a), iconOrientation: "horizontal" });
43
- return { ...a, actions: t };
44
- }) : e, [e, c]);
45
- return /* @__PURE__ */ n(h, { elevation: 1, className: m.elevation, children: /* @__PURE__ */ n(
46
- v,
36
+ const a = z(n[0], o).map((r) => {
37
+ const y = h ? h[r] : void 0;
38
+ return {
39
+ id: r,
40
+ header: s(r),
41
+ accessor: r,
42
+ cellTemplate: t ? t[r] : void 0,
43
+ cellProps: { width: y }
44
+ };
45
+ });
46
+ return p ? [...a, { id: "actions", header: "", accessor: "actions" }] : a;
47
+ }, [n, t, o, s, p, h]), g = v(() => p ? n.map((a) => {
48
+ const r = /* @__PURE__ */ e(I, { actions: p(a), iconOrientation: "horizontal" });
49
+ return { ...a, actions: r };
50
+ }) : n, [n, p]);
51
+ return /* @__PURE__ */ e(T, { elevation: 1, className: d.elevation, children: /* @__PURE__ */ e(
52
+ x,
47
53
  {
48
- className: m.table,
54
+ className: d.table,
49
55
  fullWidth: !0,
50
56
  alwaysUseDivTags: !0,
51
57
  layout: "standard",
52
58
  hiddenColumns: l,
53
- data: _,
59
+ data: g,
54
60
  columns: f,
55
- leadingContent: u.length > 0 && /* @__PURE__ */ n(
56
- y,
61
+ leadingContent: u && i.length === 0 ? /* @__PURE__ */ e(b, { title: u }) : i.length > 0 && /* @__PURE__ */ e(
62
+ b,
57
63
  {
58
- className: m.topBar,
59
- filterBar: /* @__PURE__ */ n(
60
- d,
61
- {
62
- className: m.filterBar,
63
- fullWidth: !0,
64
- primaryAlign: "center",
65
- secondaryAlign: "center",
66
- children: u.map((a, t) => /* @__PURE__ */ n(g, { children: a }, `action_${t}`))
67
- }
68
- )
64
+ className: d.topBar,
65
+ filterBar: /* @__PURE__ */ B(_, { fullWidth: !0, direction: "vertical", gap: "none", children: [
66
+ u && /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(j, { level: 6, children: u }) }),
67
+ /* @__PURE__ */ e(
68
+ _,
69
+ {
70
+ className: d.filterBar,
71
+ fullWidth: !0,
72
+ primaryAlign: "center",
73
+ secondaryAlign: "center",
74
+ children: i.map((a, r) => /* @__PURE__ */ e(D, { children: a }, `action_${r}`))
75
+ }
76
+ )
77
+ ] })
69
78
  }
70
79
  ),
71
- paginated: s,
80
+ paginated: c,
72
81
  sortable: !0,
73
82
  noContentIncludeTable: !!f,
74
- noContentMessage: /* @__PURE__ */ n(
75
- d,
83
+ noContentMessage: /* @__PURE__ */ e(
84
+ _,
76
85
  {
77
86
  fullWidth: !0,
78
87
  primaryAlign: "center",
79
88
  secondaryAlign: "center",
80
- className: m.emptyTable,
81
- children: /* @__PURE__ */ n(B, { children: p })
89
+ className: d.emptyTable,
90
+ children: /* @__PURE__ */ e(C, { children: m })
82
91
  }
83
92
  )
84
93
  }
85
94
  ) });
86
95
  };
87
96
  export {
88
- E as GenericTable
97
+ $ as GenericTable
89
98
  };
@@ -1,54 +1,71 @@
1
- import { jsx as o, jsxs as B } from "react/jsx-runtime";
2
- import { r as d, s as t } from "../../react.esm-D9-uytwS.js";
1
+ import { jsx as a, jsxs as u } from "react/jsx-runtime";
2
+ import { r as i, s as e } from "../../react.esm-D9-uytwS.js";
3
3
  import { GenericTable as c } from "./GenericTable.js";
4
- import { d as u, t as i, g as e, v as m } from "../../vi.JYQecGiw-BbUbJcT8.js";
5
- u("GenericTable Test", () => {
6
- const T = [];
7
- i("render GenericTable with custom no content text", () => {
8
- d(/* @__PURE__ */ o(c, { data: T, noContentText: "noContent" })), e(t.getByText("noContent")).toBeInTheDocument();
9
- }), i("render GenericTable with data should render headers", () => {
10
- d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }] })), e(t.getByText("id")).toBeInTheDocument(), e(t.getByText("name")).toBeInTheDocument();
11
- }), i("render GenericTable with hidden headers", () => {
12
- d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], hiddenColumns: ["name"] })), e(t.getByText("id")).toBeInTheDocument(), e(t.queryByText("name")).not.toBeInTheDocument();
13
- }), i("render GenericTable with custom header translation", () => {
14
- d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], headerTranslation: (a) => a + ".translated" })), e(t.getByText("id.translated")).toBeInTheDocument(), e(t.getByText("name.translated")).toBeInTheDocument();
15
- }), i("render GenericTable with custom cell template", () => {
16
- d(
17
- /* @__PURE__ */ o(
4
+ import { d as B, t as d, g as t, v as r } from "../../vi.JYQecGiw-BbUbJcT8.js";
5
+ B("GenericTable Test", () => {
6
+ const m = [];
7
+ d("render GenericTable with custom no content text", () => {
8
+ i(/* @__PURE__ */ a(c, { data: m, noContentText: "noContent" })), t(e.getByText("noContent")).toBeInTheDocument();
9
+ }), d("render GenericTable with data should render headers", () => {
10
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }] })), t(e.getByText("id")).toBeInTheDocument(), t(e.getByText("name")).toBeInTheDocument();
11
+ }), d("render GenericTable with hidden headers", () => {
12
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], hiddenColumns: ["name"] })), t(e.getByText("id")).toBeInTheDocument(), t(e.queryByText("name")).not.toBeInTheDocument();
13
+ }), d("render GenericTable with custom header translation", () => {
14
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], headerTranslation: (o) => o + ".translated" })), t(e.getByText("id.translated")).toBeInTheDocument(), t(e.getByText("name.translated")).toBeInTheDocument();
15
+ }), d("render GenericTable with custom cell template", () => {
16
+ i(
17
+ /* @__PURE__ */ a(
18
18
  c,
19
19
  {
20
20
  data: [{ id: 1, name: "test" }],
21
- cellTemplates: { id: (a) => /* @__PURE__ */ B("div", { children: [
21
+ cellTemplates: { id: (o) => /* @__PURE__ */ u("div", { children: [
22
22
  "label: ",
23
- a.row.original.id
23
+ o.row.original.id
24
24
  ] }) }
25
25
  }
26
26
  )
27
- ), e(t.getByText("label: 1")).toBeInTheDocument();
28
- }), i("render GenericTable with custom table actions", () => {
29
- const n = m.fn();
30
- d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test" }], tableActions: [
31
- /* @__PURE__ */ o("button", { "data-testid": "testButton", onClick: n, children: "testbutton" }, "test")
32
- ] })), e(t.getByText("testbutton")).toBeInTheDocument(), t.getByTestId("testButton").click(), e(n).toHaveBeenCalled();
33
- }), i("render GenericTable with custom pagination", () => {
34
- d(/* @__PURE__ */ o(c, { data: [
27
+ ), t(e.getByText("label: 1")).toBeInTheDocument();
28
+ }), d("render GenericTable with custom table actions", () => {
29
+ const n = r.fn();
30
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], tableActions: [
31
+ /* @__PURE__ */ a("button", { "data-testid": "testButton", onClick: n, children: "testbutton" }, "test")
32
+ ] })), t(e.getByText("testbutton")).toBeInTheDocument(), e.getByTestId("testButton").click(), t(n).toHaveBeenCalled();
33
+ }), d("render GenericTable with custom pagination", () => {
34
+ i(/* @__PURE__ */ a(c, { data: [
35
35
  { id: 1, name: "test" },
36
36
  { id: 2, name: "test2" },
37
37
  { id: 3, name: "test3" }
38
- ], pagination: !0 })), e(t.getByText("1 - 3 of 3")).toBeInTheDocument(), e(t.getByText("last_page")).toBeInTheDocument();
39
- }), i("render GenericTable with custom getRowActions", () => {
40
- const n = [{ id: 1, name: "test" }], a = m.fn();
41
- d(/* @__PURE__ */ o(c, { data: n, getRowActions: (l) => [
38
+ ], pagination: !0 })), t(e.getByText("1 - 3 of 3")).toBeInTheDocument(), t(e.getByText("last_page")).toBeInTheDocument();
39
+ }), d("render GenericTable with custom getRowActions", () => {
40
+ const n = [{ id: 1, name: "test" }], o = r.fn();
41
+ i(/* @__PURE__ */ a(c, { data: n, getRowActions: (T) => [
42
42
  {
43
43
  primaryText: "primText",
44
44
  secondaryText: "secText",
45
- onClick: () => a(l.id),
45
+ onClick: () => o(T.id),
46
46
  leadingBlock: "edit"
47
47
  }
48
- ] })), e(t.getByText("primText")).toBeInTheDocument(), t.getByText("primText").click(), e(a).toHaveBeenCalledWith(1);
49
- }), i("render GenericTable with custom order", () => {
50
- d(/* @__PURE__ */ o(c, { data: [{ id: 1, name: "test", age: 20 }], order: ["name", "age"] }));
51
- const a = t.getByText("id"), r = t.getByText("name"), s = t.getByText("age");
52
- e(r).toBeInTheDocument(), e(s).toBeInTheDocument(), e(a).toBeInTheDocument(), e(r.compareDocumentPosition(s)).toBe(4), e(s.compareDocumentPosition(a)).toBe(4);
48
+ ] })), t(e.getByText("primText")).toBeInTheDocument(), e.getByText("primText").click(), t(o).toHaveBeenCalledWith(1);
49
+ }), d("render GenericTable with custom order", () => {
50
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test", age: 20 }], order: ["name", "age"] }));
51
+ const o = e.getByText("id"), s = e.getByText("name"), l = e.getByText("age");
52
+ t(s).toBeInTheDocument(), t(l).toBeInTheDocument(), t(o).toBeInTheDocument(), t(s.compareDocumentPosition(l)).toBe(4), t(l.compareDocumentPosition(o)).toBe(4);
53
+ }), d("render GenericTable with custom columnWidth in pixel", () => {
54
+ i(
55
+ /* @__PURE__ */ a(c, { data: [{ id: 1, name: "test", age: 20 }], customColumnWidth: { id: 200, name: 200, age: 200 } })
56
+ );
57
+ const s = e.getAllByRole("cell")[0].getAttribute("width");
58
+ t(s).toBe("200");
59
+ }), d("render GenericTable with custom columnWidth in percent", () => {
60
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], customColumnWidth: { id: "50%", name: "50%" } }));
61
+ const s = e.getAllByRole("cell")[0].getAttribute("width");
62
+ t(s).toBe("50%");
63
+ }), d("render GenericTable with title", () => {
64
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], title: "test-title" })), t(e.getByText("test-title")).toBeInTheDocument();
65
+ }), d("render GenericTable with title and table actions", () => {
66
+ const n = r.fn();
67
+ i(/* @__PURE__ */ a(c, { data: [{ id: 1, name: "test" }], title: "test-title", tableActions: [
68
+ /* @__PURE__ */ a("button", { "data-testid": "testButton", onClick: n, children: "test-button" }, "test")
69
+ ] })), t(e.getByText("test-title")).toBeInTheDocument(), t(e.getByText("test-button")).toBeInTheDocument(), e.getByTestId("testButton").click(), t(n).toHaveBeenCalled();
53
70
  });
54
71
  });
@@ -61,6 +61,15 @@ export type TableLayoutProps<T> = {
61
61
  * @returns an array of ListItemProps that will be shown as actions for the row
62
62
  */
63
63
  getRowActions?: (row: T) => ListItemProps[];
64
+ /**
65
+ * custom column width that is specified by a column key. Note, can be a unit-less number (in pixels) or a percentage "10%"
66
+ * @example customColumnWidth={{ id: '15%', actionColumn: '10%' }}
67
+ */
68
+ customColumnWidth?: Partial<Record<keyof T, number | string>>;
69
+ /**
70
+ * table title to be displayed in the TableTopBar
71
+ */
72
+ title?: string;
64
73
  };
65
74
  /**
66
75
  * Props for the CellTemplate component {@link CellTemplate}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/shared-components",
3
3
  "description": "This is a shared component library. It should used in the HortiView platform and its modules.",
4
- "version": "0.0.6285",
4
+ "version": "0.0.6332",
5
5
  "type": "module",
6
6
  "repository": "https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared",
7
7
  "author": "Falk Menge <falk.menge.ext@bayer.com>",