@hortiview/shared-components 2.3.0 → 2.4.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,3 +1,5 @@
1
+ import { OfflineViewProps } from '../OfflineView/OfflineView';
2
+
1
3
  type DeleteModalProps = {
2
4
  /**
3
5
  * The title of the modal.
@@ -58,6 +60,14 @@ type DeleteModalProps = {
58
60
  * Default is _true_.
59
61
  */
60
62
  isDeletePossible?: boolean;
63
+ /**
64
+ * Whether the user is online; shows OfflineView when false.
65
+ */
66
+ isOnline?: boolean;
67
+ /**
68
+ * Props forwarded to <OfflineView /> when offline.
69
+ */
70
+ offlineViewProps?: Partial<OfflineViewProps>;
61
71
  };
62
72
  /**
63
73
  * A modal component for deleting items.
@@ -75,7 +85,9 @@ type DeleteModalProps = {
75
85
  * @prop {function} onDelete - The function to call when the confirm button is clicked.
76
86
  * @prop {function} onCancel - A optional function to call when the cancel button is clicked.
77
87
  * @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_.
88
+ * @prop {boolean} isOnline - Whether the user is online; shows OfflineView when false.
89
+ * @prop {Partial} offlineViewProps - Props forwarded to OfflineView when offline.
78
90
  * @returns {ReactElement} A modal component for deleting items.
79
91
  */
80
- export declare const DeleteModal: ({ title, confirmButtonLabel, cancelButtonLabel, deleteHeader, deleteBody, deleteText, icon, isIconCrossedOut, impossibleDeleteHeader, open, setOpen, onDelete, onCancel, isDeletePossible, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
92
+ export declare const DeleteModal: ({ title, confirmButtonLabel, cancelButtonLabel, deleteHeader, deleteBody, deleteText, icon, isIconCrossedOut, impossibleDeleteHeader, open, setOpen, onDelete, onCancel, isDeletePossible, isOnline, offlineViewProps, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
81
93
  export {};
@@ -1,96 +1,100 @@
1
- import { jsx as o, jsxs as p, Fragment as i } from "react/jsx-runtime";
2
- import { B as u } from "../../index.es-CiqbARoC.js";
3
- import { G as c } from "../../index.es-DntoATwO.js";
4
- import { I as D } from "../../index.es-3043KTnb.js";
1
+ import { jsx as o, jsxs as f, Fragment as c } from "react/jsx-runtime";
2
+ import { B as p } from "../../index.es-CiqbARoC.js";
3
+ import { G as i } from "../../index.es-DntoATwO.js";
4
+ import { I } from "../../index.es-3043KTnb.js";
5
5
  import { T as l } from "../../index.es-D54RuMc_.js";
6
- import { u as k } from "../../uniqueId-NU3-C36A.js";
7
- import { AvailableCustomIcons as I } from "../../enums/AvailableCustomIcons.js";
8
- import { u as N } from "../../useBreakpoints-MzTZ0tCT.js";
9
- import { Iconify as O } from "../Iconify/Iconify.js";
10
- import { Modal as S } from "../Modal/Modal.js";
11
- import '../../assets/DeleteModal.css';const x = "_bulletPoint_bd412_1", B = "_modal_bd412_7", M = "_colorDanger_bd412_11", j = "_crossedOut_bd412_15", t = {
12
- bulletPoint: x,
13
- modal: B,
14
- colorDanger: M,
15
- crossedOut: j
16
- }, R = ({
6
+ import { u as N } from "../../uniqueId-NU3-C36A.js";
7
+ import { AvailableCustomIcons as S } from "../../enums/AvailableCustomIcons.js";
8
+ import { u as x } from "../../useBreakpoints-MzTZ0tCT.js";
9
+ import { Iconify as B } from "../Iconify/Iconify.js";
10
+ import { Modal as M } from "../Modal/Modal.js";
11
+ import '../../assets/DeleteModal.css';const O = "_bulletPoint_bd412_1", j = "_modal_bd412_7", z = "_colorDanger_bd412_11", P = "_crossedOut_bd412_15", t = {
12
+ bulletPoint: O,
13
+ modal: j,
14
+ colorDanger: z,
15
+ crossedOut: P
16
+ }, V = ({
17
17
  title: r,
18
18
  confirmButtonLabel: e,
19
19
  cancelButtonLabel: n,
20
20
  deleteHeader: a,
21
21
  deleteBody: s,
22
- deleteText: f,
23
- icon: b,
24
- isIconCrossedOut: g,
25
- impossibleDeleteHeader: h,
26
- open: v,
22
+ deleteText: b,
23
+ icon: g,
24
+ isIconCrossedOut: h,
25
+ impossibleDeleteHeader: v,
26
+ open: y,
27
27
  setOpen: d,
28
- onDelete: y,
29
- onCancel: _,
30
- isDeletePossible: m = !0
28
+ onDelete: _,
29
+ onCancel: C,
30
+ isDeletePossible: m = !0,
31
+ isOnline: u = !0,
32
+ offlineViewProps: D
31
33
  }) => {
32
- const { isDesktop: C } = N();
34
+ const { isDesktop: k } = x();
33
35
  return /* @__PURE__ */ o(
34
- S,
36
+ M,
35
37
  {
38
+ isOnline: u,
39
+ offlineViewProps: D,
36
40
  className: `${t.modal}`,
37
- modalSize: C ? "small" : "fullscreen",
38
- open: v,
41
+ modalSize: k ? "small" : "fullscreen",
42
+ open: y,
39
43
  title: r,
40
44
  onClose: () => d(!1),
41
45
  primaryButton: /* @__PURE__ */ o(
42
- u,
46
+ p,
43
47
  {
44
48
  "data-testid": "delete-button",
45
49
  variant: "danger",
46
50
  label: e,
47
- onClick: y,
48
- disabled: !m
51
+ onClick: _,
52
+ disabled: !m || !u
49
53
  }
50
54
  ),
51
55
  footerSupplemental: /* @__PURE__ */ o(
52
- u,
56
+ p,
53
57
  {
54
58
  "data-testid": "cancel-button",
55
59
  variant: "text",
56
60
  label: n,
57
61
  onClick: () => {
58
- _?.(), d(!1);
62
+ C?.(), d(!1);
59
63
  }
60
64
  }
61
65
  ),
62
- children: /* @__PURE__ */ p(c, { direction: "vertical", secondaryAlign: "center", children: [
63
- /* @__PURE__ */ o(z, { element: /* @__PURE__ */ o(P, { icon: b }), isCrossedOut: g }),
64
- /* @__PURE__ */ o(c, { direction: "vertical", children: m ? /* @__PURE__ */ o(
65
- A,
66
+ children: /* @__PURE__ */ f(i, { direction: "vertical", secondaryAlign: "center", children: [
67
+ /* @__PURE__ */ o(A, { element: /* @__PURE__ */ o(G, { icon: g }), isCrossedOut: h }),
68
+ /* @__PURE__ */ o(i, { direction: "vertical", children: m ? /* @__PURE__ */ o(
69
+ q,
66
70
  {
67
71
  deleteHeader: a,
68
- deleteText: f,
72
+ deleteText: b,
69
73
  deleteBody: s
70
74
  }
71
- ) : /* @__PURE__ */ o(G, { impossibleDeleteHeader: h }) })
75
+ ) : /* @__PURE__ */ o(F, { impossibleDeleteHeader: v }) })
72
76
  ] })
73
77
  }
74
78
  );
75
- }, z = ({
79
+ }, A = ({
76
80
  element: r,
77
81
  isCrossedOut: e = !1
78
- }) => e ? /* @__PURE__ */ o("span", { className: t.crossedOut, children: r }) : r, P = ({ icon: r }) => r ? typeof r != "string" ? r : Object.values(I).includes(r) ? /* @__PURE__ */ o(
79
- O,
82
+ }) => e ? /* @__PURE__ */ o("span", { className: t.crossedOut, children: r }) : r, G = ({ icon: r }) => r ? typeof r != "string" ? r : Object.values(S).includes(r) ? /* @__PURE__ */ o(
83
+ B,
80
84
  {
81
85
  icon: r,
82
86
  iconSize: "xlarge",
83
87
  className: t.colorDanger
84
88
  }
85
- ) : /* @__PURE__ */ o(D, { icon: r, iconSize: "xlarge", className: t.colorDanger }) : /* @__PURE__ */ o(i, {}), A = ({
89
+ ) : /* @__PURE__ */ o(I, { icon: r, iconSize: "xlarge", className: t.colorDanger }) : /* @__PURE__ */ o(c, {}), q = ({
86
90
  deleteHeader: r,
87
91
  deleteText: e,
88
92
  deleteBody: n
89
- }) => /* @__PURE__ */ p(i, { children: [
93
+ }) => /* @__PURE__ */ f(c, { children: [
90
94
  /* @__PURE__ */ o(l, { level: 1, themeColor: "text-primary-on-background", children: r }),
91
95
  e && typeof e == "string" && /* @__PURE__ */ o(l, { level: 2, themeColor: "text-secondary-on-background", children: e }),
92
- e && typeof e != "string" && /* @__PURE__ */ o(i, { children: e }),
93
- n && e === void 0 && /* @__PURE__ */ o(c, { direction: "vertical", gap: "none", children: n.map((a, s) => /* @__PURE__ */ o(
96
+ e && typeof e != "string" && /* @__PURE__ */ o(c, { children: e }),
97
+ n && e === void 0 && /* @__PURE__ */ o(i, { direction: "vertical", gap: "none", children: n.map((a, s) => /* @__PURE__ */ o(
94
98
  l,
95
99
  {
96
100
  level: 2,
@@ -98,11 +102,11 @@ import '../../assets/DeleteModal.css';const x = "_bulletPoint_bd412_1", B = "_mo
98
102
  themeColor: "text-secondary-on-background",
99
103
  children: a
100
104
  },
101
- k(s.toString())
105
+ N(s.toString())
102
106
  )) })
103
- ] }), G = ({
107
+ ] }), F = ({
104
108
  impossibleDeleteHeader: r
105
109
  }) => /* @__PURE__ */ o(l, { level: 1, themeColor: "text-primary-on-background", children: r });
106
110
  export {
107
- R as DeleteModal
111
+ V as DeleteModal
108
112
  };
@@ -1,12 +1,12 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { a as c, s as e } from "../../react.esm-CX1WJ2Pp.js";
3
- import { DeleteModal as b } from "./DeleteModal.js";
4
- import { d as B, t as a, a as o, g as t } from "../../vi.CjhMlMwf-CKxPQtd6.js";
5
- B("DeleteModal Test", () => {
6
- a("should render the DeleteModal properly", () => {
3
+ import { DeleteModal as a } from "./DeleteModal.js";
4
+ import { d, t as b, a as o, g as t } from "../../vi.CjhMlMwf-CKxPQtd6.js";
5
+ d("DeleteModal Test", () => {
6
+ b("should render the DeleteModal properly", () => {
7
7
  c(
8
8
  /* @__PURE__ */ n(
9
- b,
9
+ a,
10
10
  {
11
11
  icon: "block",
12
12
  open: !0,
@@ -22,10 +22,10 @@ B("DeleteModal Test", () => {
22
22
  }
23
23
  )
24
24
  ), t(e.getByText("DELETE")).toBeInTheDocument(), t(e.getByTestId("block")).toBeInTheDocument(), t(e.getByText("block 1")).toBeInTheDocument(), t(e.getByText("block 2")).toBeInTheDocument(), t(e.getByText("block 3")).toBeInTheDocument(), t(e.getByText("Remove")).toBeInTheDocument(), t(e.getByText("Cancel")).toBeInTheDocument(), t(e.queryByText("block cant be deleted")).not.toBeInTheDocument();
25
- }), a("should render the DeleteModal properly when isDeletePossible = false", () => {
25
+ }), b("should render the DeleteModal properly when isDeletePossible = false", () => {
26
26
  c(
27
27
  /* @__PURE__ */ n(
28
- b,
28
+ a,
29
29
  {
30
30
  icon: "block",
31
31
  open: !0,
@@ -41,11 +41,11 @@ B("DeleteModal Test", () => {
41
41
  }
42
42
  )
43
43
  ), t(e.getByText("DELETE")).toBeInTheDocument(), t(e.getByTestId("block")).toBeInTheDocument(), t(e.queryByText("block 1")).not.toBeInTheDocument(), t(e.queryByText("block 2")).not.toBeInTheDocument(), t(e.queryByText("block 3")).not.toBeInTheDocument(), t(e.getByText("Remove")).toBeInTheDocument(), t(e.getByText("Remove").parentElement).toBeDisabled(), t(e.getByText("Cancel")).toBeInTheDocument(), t(e.queryByText("block cant be deleted")).toBeInTheDocument();
44
- }), a("should call setOpen with false when clicking on cancel button", () => {
44
+ }), b("should call setOpen with false when clicking on cancel button", () => {
45
45
  const l = o.fn();
46
46
  c(
47
47
  /* @__PURE__ */ n(
48
- b,
48
+ a,
49
49
  {
50
50
  icon: "block",
51
51
  open: !0,
@@ -61,11 +61,11 @@ B("DeleteModal Test", () => {
61
61
  }
62
62
  )
63
63
  ), e.getByText("Cancel").click(), t(l).toHaveBeenCalledWith(!1);
64
- }), a("should call onDelete when clicking on delete button", () => {
64
+ }), b("should call onDelete when clicking on delete button", () => {
65
65
  const l = o.fn();
66
66
  c(
67
67
  /* @__PURE__ */ n(
68
- b,
68
+ a,
69
69
  {
70
70
  icon: "block",
71
71
  open: !0,
@@ -81,5 +81,29 @@ B("DeleteModal Test", () => {
81
81
  }
82
82
  )
83
83
  ), e.getByText("Remove").click(), t(l).toHaveBeenCalled();
84
+ }), b("render DeleteModal with OfflineView", () => {
85
+ const l = o.fn();
86
+ c(
87
+ /* @__PURE__ */ n(
88
+ a,
89
+ {
90
+ icon: "block",
91
+ open: !0,
92
+ setOpen: o.fn(),
93
+ onDelete: l,
94
+ title: "DELETE",
95
+ confirmButtonLabel: "Remove",
96
+ cancelButtonLabel: "Cancel",
97
+ deleteHeader: "Delete my block",
98
+ impossibleDeleteHeader: "block cant be deleted",
99
+ deleteBody: ["block 1", "block 2", "block 3"],
100
+ isDeletePossible: !0,
101
+ isOnline: !1,
102
+ offlineViewProps: {
103
+ "data-testid": "offline-test"
104
+ }
105
+ }
106
+ )
107
+ ), e.getByText("Remove").click(), t(l).not.toHaveBeenCalled(), t(e.getByTestId("offline-test")).toBeInTheDocument();
84
108
  });
85
109
  });
@@ -60,6 +60,8 @@ import { TableLayoutProps } from '../../types/GenericTable';
60
60
  * @param tableActionPosition position of the table actions, can be 'start' or 'end'
61
61
  * @param tableElevationLevel elevation level of the table
62
62
  * @param tableLayout layout of the table, can be 'standard' or 'flex'
63
+ * @param isOnline Whether the user is online; shows OfflineView when false.
64
+ * @param offlineViewProps Props forwarded to OfflineView when offline.
63
65
  * @returns a table based on a given type and data
64
66
  */
65
- export declare const GenericTable: <T>({ data, hiddenColumns, order, cellTemplates, tableActions, noContentText, headerTranslation, pagination, getRowActions, customColumnWidth, title, cardTitleColumn, cardSubTitleColumn, pageTranslation, pageOfTranslation, rowsPerPageTranslation, tableActionPosition, tableElevationLevel, tableLayout, }: TableLayoutProps<T>) => import("react/jsx-runtime").JSX.Element;
67
+ export declare const GenericTable: <T>({ data, hiddenColumns, order, cellTemplates, tableActions, noContentText, headerTranslation, pagination, getRowActions, customColumnWidth, title, cardTitleColumn, cardSubTitleColumn, pageTranslation, pageOfTranslation, rowsPerPageTranslation, tableActionPosition, tableElevationLevel, tableLayout, isOnline, offlineViewProps, }: TableLayoutProps<T>) => import("react/jsx-runtime").JSX.Element;