@hortiview/shared-components 2.13.0 → 2.14.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,130 +1,130 @@
1
- import { jsx as e, Fragment as a, jsxs as n } from "react/jsx-runtime";
2
- import { D as G } from "../../index.es-B1h6DPYp.js";
3
- import { G as s } from "../../index.es-oxil0uFe.js";
4
- import { P as V } from "../../index.es-BanVdXEd.js";
5
- import { c as w } from "../../index-BcGujPyk.js";
6
- import { useMemo as d } from "react";
7
- import { BasicHeading as _ } from "../BasicHeading/BasicHeading.js";
8
- import { EmptyView as $ } from "../EmptyView/EmptyView.js";
9
- import { ListArea as y } from "../ListArea/ListArea.js";
10
- import { u as F } from "../../useBreakpoints-MzTZ0tCT.js";
11
- import { O as M } from "../../OfflineView-CIwV08EQ.js";
12
- import { useScrollableInfo as O } from "./BaseView.service.js";
13
- import '../../assets/BaseView.css';const P = "_fullHeight_1a5ww_1", T = "_fullWidth_1a5ww_5", q = "_maxWidth_1a5ww_9", z = "_list_1a5ww_14", J = "_desktopList_1a5ww_23", K = "_noRoundedCorners_1a5ww_28", Q = "_detail_1a5ww_32", U = "_desktopDetail_1a5ww_40", i = {
14
- fullHeight: P,
15
- fullWidth: T,
16
- maxWidth: q,
17
- list: z,
18
- desktopList: J,
19
- noRoundedCorners: K,
20
- detail: Q,
21
- desktopDetail: U
22
- }, dt = ({
23
- heading: c,
24
- action: u = /* @__PURE__ */ e(a, {}),
25
- hint: g = /* @__PURE__ */ e(a, {}),
26
- elements: l,
1
+ import { jsx as e, Fragment as d, jsxs as c } from "react/jsx-runtime";
2
+ import { D as V } from "../../index.es-B1h6DPYp.js";
3
+ import { G as l } from "../../index.es-oxil0uFe.js";
4
+ import { P as $ } from "../../index.es-BanVdXEd.js";
5
+ import { c as g } from "../../index-BcGujPyk.js";
6
+ import { useMemo as n } from "react";
7
+ import { BasicHeading as w } from "../BasicHeading/BasicHeading.js";
8
+ import { EmptyView as y } from "../EmptyView/EmptyView.js";
9
+ import { ListArea as F } from "../ListArea/ListArea.js";
10
+ import { u as M } from "../../useBreakpoints-MzTZ0tCT.js";
11
+ import { O } from "../../OfflineView-CIwV08EQ.js";
12
+ import { useScrollableInfo as P } from "./BaseView.service.js";
13
+ import '../../assets/BaseView.css';const T = "_fullHeight_71rfc_1", q = "_fullWidth_71rfc_5", z = "_maxWidth_71rfc_9", J = "_list_71rfc_13", K = "_desktopList_71rfc_22", Q = "_noRoundedCorners_71rfc_27", U = "_detail_71rfc_31", X = "_desktopDetail_71rfc_39", i = {
14
+ fullHeight: T,
15
+ fullWidth: q,
16
+ maxWidth: z,
17
+ list: J,
18
+ desktopList: K,
19
+ noRoundedCorners: Q,
20
+ detail: U,
21
+ desktopDetail: X
22
+ }, ct = ({
23
+ heading: u,
24
+ action: f = /* @__PURE__ */ e(d, {}),
25
+ hint: v = /* @__PURE__ */ e(d, {}),
26
+ elements: r,
27
27
  emptyText: m,
28
- hasSearch: v = !0,
29
- isSorted: D = !0,
30
- className: W,
31
- withAvatar: k = !1,
32
- listMaxHeight: x = "calc(100vh - 220px)",
33
- titleLevel: L = 5,
34
- detailTitleLevel: b,
35
- pathname: r,
36
- basicHeadingIcon: H,
37
- isOnline: f = !0,
38
- offlineViewProps: h,
39
- noRoundedListItemEdges: p = !0,
40
- routerLinkElement: N,
41
- searchPlaceholder: B,
42
- isGrouped: R = !1
28
+ hasSearch: D = !0,
29
+ isSorted: W = !0,
30
+ className: k,
31
+ withAvatar: x = !1,
32
+ listMaxHeight: L = "calc(100vh - 220px)",
33
+ titleLevel: b = 5,
34
+ detailTitleLevel: H,
35
+ pathname: s,
36
+ basicHeadingIcon: N,
37
+ isOnline: h = !0,
38
+ offlineViewProps: p,
39
+ noRoundedListItemEdges: _ = !0,
40
+ routerLinkElement: B,
41
+ searchPlaceholder: R,
42
+ isGrouped: A = !1
43
43
  }) => {
44
- const { isDesktopNavbar: o } = F(), t = d(() => l.find((E) => E.route === r), [r, l]), C = d(() => f ? t?.component ? t.component : o ? /* @__PURE__ */ e(V, { className: i.fullWidth, children: /* @__PURE__ */ e($, { title: m }) }) : /* @__PURE__ */ e(a, {}) : /* @__PURE__ */ e(M, { ...h, fullWidth: !0 }), [t?.component, m, o, f, h]), { showList: I, showDetail: S } = d(() => o ? { showList: !0, showDetail: !0 } : { showList: !t, showDetail: !!t }, [t, o]), { ref: A, hasScrolled: j } = O([
45
- r,
44
+ const { isDesktopNavbar: o } = M(), t = n(() => r.find((a) => a.route === s), [s, r]), C = n(() => r.filter((a) => a.isAllowed !== !1), [r]), I = n(() => h ? t?.component ? t.component : o ? /* @__PURE__ */ e($, { className: i.fullWidth, children: /* @__PURE__ */ e(y, { title: m }) }) : /* @__PURE__ */ e(d, {}) : /* @__PURE__ */ e(O, { ...p, fullWidth: !0 }), [t?.component, m, o, h, p]), { showList: S, showDetail: E } = n(() => o ? { showList: !0, showDetail: !0 } : { showList: !t, showDetail: !!t }, [t, o]), { ref: j, hasScrolled: G } = P([
45
+ s,
46
46
  o
47
47
  ]);
48
- return /* @__PURE__ */ n(
49
- s,
48
+ return /* @__PURE__ */ c(
49
+ l,
50
50
  {
51
51
  "data-testid": "base-view-container",
52
- className: `${i.fullHeight} ${W ?? ""}`,
52
+ className: `${i.fullHeight} ${k ?? ""}`,
53
53
  fullWidth: !0,
54
54
  children: [
55
- I && /* @__PURE__ */ n(
56
- s,
55
+ S && /* @__PURE__ */ c(
56
+ l,
57
57
  {
58
58
  "data-testid": "show-list-container",
59
59
  gap: "none",
60
60
  direction: "vertical",
61
- className: w(
61
+ className: g(
62
62
  i.list,
63
63
  o && i.desktopList,
64
- p && i.noRoundedCorners
64
+ _ && i.noRoundedCorners
65
65
  ),
66
66
  children: [
67
- c && /* @__PURE__ */ e(
68
- _,
67
+ u && /* @__PURE__ */ e(
68
+ w,
69
69
  {
70
- icon: H,
70
+ icon: N,
71
71
  "data-testid": "heading",
72
- heading: c,
73
- level: L,
72
+ heading: u,
73
+ level: b,
74
74
  marginBottom: 0,
75
75
  inList: !0,
76
- children: u
76
+ children: f
77
77
  }
78
78
  ),
79
- g,
79
+ v,
80
80
  /* @__PURE__ */ e(
81
- y,
81
+ F,
82
82
  {
83
- hasLastItemNoRoundedEdges: p,
84
- elements: l,
85
- hasSearch: v,
86
- maxHeight: x,
87
- isSorted: D,
88
- pathname: r,
89
- routerLinkElement: N,
90
- searchPlaceholder: B,
91
- isGrouped: R
83
+ hasLastItemNoRoundedEdges: _,
84
+ elements: C,
85
+ hasSearch: D,
86
+ maxHeight: L,
87
+ isSorted: W,
88
+ pathname: s,
89
+ routerLinkElement: B,
90
+ searchPlaceholder: R,
91
+ isGrouped: A
92
92
  }
93
93
  )
94
94
  ]
95
95
  }
96
96
  ),
97
- S && /* @__PURE__ */ n(
98
- s,
97
+ E && /* @__PURE__ */ c(
98
+ l,
99
99
  {
100
100
  "data-testid": "show-details-container",
101
101
  gap: "none",
102
102
  direction: "vertical",
103
- className: w(i.detail, o && i.desktopDetail),
103
+ className: g(i.detail, o && i.desktopDetail),
104
104
  children: [
105
105
  /* @__PURE__ */ e(
106
- _,
106
+ w,
107
107
  {
108
108
  className: i.maxWidth,
109
109
  heading: t?.detailTitle ?? t?.title ?? "",
110
- level: b,
110
+ level: H,
111
111
  icon: t?.hideIconInDetail === !0 ? void 0 : t?.detailIcon ?? t?.icon,
112
112
  marginBottom: 0,
113
113
  invisibleButton: t?.detailAction === void 0,
114
- withAvatar: k,
114
+ withAvatar: x,
115
115
  subHeading: t?.detailSubTitle,
116
- children: t?.detailAction ?? u
116
+ children: t?.detailAction ?? f
117
117
  }
118
118
  ),
119
- j && /* @__PURE__ */ e(G, {}),
119
+ G && /* @__PURE__ */ e(V, {}),
120
120
  /* @__PURE__ */ e(
121
- s,
121
+ l,
122
122
  {
123
123
  "data-testid": "base-view-show-details-scroll-component-group",
124
124
  fullWidth: !0,
125
125
  direction: "vertical",
126
- ref: A,
127
- children: C
126
+ ref: j,
127
+ children: I
128
128
  }
129
129
  )
130
130
  ]
@@ -135,5 +135,5 @@ import '../../assets/BaseView.css';const P = "_fullHeight_1a5ww_1", T = "_fullWi
135
135
  );
136
136
  };
137
137
  export {
138
- dt as BaseView
138
+ ct as BaseView
139
139
  };
@@ -1,10 +1,10 @@
1
1
  import { jsx as o, Fragment as s } from "react/jsx-runtime";
2
- import { a as n, s as e, f as p } from "../../react.esm-Bm0cAgpZ.js";
2
+ import { a as n, s as e, f as d } from "../../react.esm-Bm0cAgpZ.js";
3
3
  import { a as l } from "../../useBreakpoints-MzTZ0tCT.js";
4
- import { BaseView as r } from "./BaseView.js";
5
- import { d as u, b as d, a as c, t as i, g as t } from "../../vi.bdSIJ99Y-B308Q-4w.js";
6
- u("BaseView Test", () => {
7
- d(() => {
4
+ import { BaseView as i } from "./BaseView.js";
5
+ import { d as p, b as m, a as c, t as r, g as t } from "../../vi.bdSIJ99Y-B308Q-4w.js";
6
+ p("BaseView Test", () => {
7
+ m(() => {
8
8
  c.spyOn(l, "useBreakpoints").mockReturnValue({
9
9
  isMobile: !1,
10
10
  isTablet: !1,
@@ -38,10 +38,10 @@ u("BaseView Test", () => {
38
38
  component: /* @__PURE__ */ o(s, { children: "Security selected" })
39
39
  }
40
40
  ];
41
- i("render BaseView with empty view and navigation list", () => {
41
+ r("render BaseView with empty view and navigation list", () => {
42
42
  n(
43
43
  /* @__PURE__ */ o(
44
- r,
44
+ i,
45
45
  {
46
46
  pathname: "/personal-profile",
47
47
  elements: a,
@@ -53,10 +53,10 @@ u("BaseView Test", () => {
53
53
  }
54
54
  )
55
55
  ), t(e.getByText("user.noselection")).toBeInTheDocument(), t(e.getByText("user.personal-profile")).toBeInTheDocument(), t(e.getByText("user.personal_information")).toBeInTheDocument(), t(e.getByText("user.data_privacy")).toBeInTheDocument(), t(e.getByText("user.security")).toBeInTheDocument();
56
- }), i("render BaseView with data and navigation list", () => {
56
+ }), r("render BaseView with data and navigation list", () => {
57
57
  n(
58
58
  /* @__PURE__ */ o(
59
- r,
59
+ i,
60
60
  {
61
61
  pathname: "/personal-profile/personal-information",
62
62
  elements: a,
@@ -69,10 +69,10 @@ u("BaseView Test", () => {
69
69
  }
70
70
  )
71
71
  ), t(e.getByText("Personal information selected")).toBeInTheDocument(), t(e.getAllByText("user.personal_information")).toHaveLength(2), t(e.getByText("account_circle")).toBeInTheDocument(), t(e.getByText("border_clear")).toBeInTheDocument(), t(e.getByText("directions_car")).toBeInTheDocument();
72
- }), i("render BaseView with custom detail title and no detail icon", () => {
72
+ }), r("render BaseView with custom detail title and no detail icon", () => {
73
73
  n(
74
74
  /* @__PURE__ */ o(
75
- r,
75
+ i,
76
76
  {
77
77
  pathname: "/personal-profile/data-privacy",
78
78
  elements: a,
@@ -84,7 +84,7 @@ u("BaseView Test", () => {
84
84
  }
85
85
  )
86
86
  ), t(e.getByText("Data Privacy selected")).toBeInTheDocument(), t(e.getByText("Data Privacy 2000")).toBeInTheDocument(), t(e.getAllByText("privacy_tip")).toHaveLength(1), t(e.getAllByText("user.data_privacy")).toHaveLength(1);
87
- }), i("hide empty view when screen is small", () => {
87
+ }), r("hide empty view when screen is small", () => {
88
88
  c.spyOn(l, "useBreakpoints").mockReturnValue({
89
89
  isMobile: !0,
90
90
  isTablet: !1,
@@ -92,7 +92,7 @@ u("BaseView Test", () => {
92
92
  isDesktopNavbar: !1
93
93
  }), n(
94
94
  /* @__PURE__ */ o(
95
- r,
95
+ i,
96
96
  {
97
97
  pathname: "/personal-profile/data-privacy",
98
98
  elements: a,
@@ -104,10 +104,10 @@ u("BaseView Test", () => {
104
104
  }
105
105
  )
106
106
  ), t(e.queryByText("user.noselection")).not.toBeInTheDocument();
107
- }), i("render BaseView with selected detail section", () => {
107
+ }), r("render BaseView with selected detail section", () => {
108
108
  n(
109
109
  /* @__PURE__ */ o(
110
- r,
110
+ i,
111
111
  {
112
112
  pathname: "/personal-profile/data-privacy",
113
113
  elements: a,
@@ -118,11 +118,11 @@ u("BaseView Test", () => {
118
118
  routerLinkElement: void 0
119
119
  }
120
120
  )
121
- ), p.click(e.getAllByRole("option")[1]), t(e.getByText("Data Privacy selected")).toBeInTheDocument();
122
- }), i("renders only offline view when offline", () => {
121
+ ), d.click(e.getAllByRole("option")[1]), t(e.getByText("Data Privacy selected")).toBeInTheDocument();
122
+ }), r("renders only offline view when offline", () => {
123
123
  n(
124
124
  /* @__PURE__ */ o(
125
- r,
125
+ i,
126
126
  {
127
127
  pathname: "/personal-profile/personal-information",
128
128
  elements: a,
@@ -136,5 +136,45 @@ u("BaseView Test", () => {
136
136
  }
137
137
  )
138
138
  ), t(e.queryByText("Personal information selected")).not.toBeInTheDocument(), t(e.getByTestId("offline-test")).toBeInTheDocument();
139
+ }), r("does not render elements when isAllowed is false", () => {
140
+ n(
141
+ /* @__PURE__ */ o(
142
+ i,
143
+ {
144
+ pathname: "",
145
+ elements: [
146
+ {
147
+ id: "1",
148
+ title: "Allowed Element",
149
+ icon: "account_circle",
150
+ route: "/allowed",
151
+ component: /* @__PURE__ */ o(s, { children: "Allowed content" }),
152
+ isAllowed: !0
153
+ },
154
+ {
155
+ id: "2",
156
+ title: "Not Allowed Element",
157
+ icon: "privacy_tip",
158
+ route: "/not-allowed",
159
+ component: /* @__PURE__ */ o(s, { children: "Not allowed content" }),
160
+ isAllowed: !1
161
+ },
162
+ {
163
+ id: "3",
164
+ title: "Another Allowed Element",
165
+ icon: "security",
166
+ route: "/allowed-2",
167
+ component: /* @__PURE__ */ o(s, { children: "Another allowed content" }),
168
+ isAllowed: !0
169
+ }
170
+ ],
171
+ heading: "Permission Test",
172
+ hasSearch: !1,
173
+ emptyText: "No selection",
174
+ isSorted: !1,
175
+ routerLinkElement: void 0
176
+ }
177
+ )
178
+ ), t(e.getByText("Allowed Element")).toBeInTheDocument(), t(e.getByText("Another Allowed Element")).toBeInTheDocument(), t(e.queryByText("Not Allowed Element")).not.toBeInTheDocument();
139
179
  });
140
180
  });
@@ -34,6 +34,10 @@ export type ActionProps = ListItemProps & {
34
34
  'data-testid'?: string;
35
35
  dividerBefore?: boolean;
36
36
  dividerAfter?: boolean;
37
+ /**
38
+ * whether the user has the permission to trigger the action, if false the action will not be shown
39
+ */
40
+ isAllowed?: boolean;
37
41
  };
38
42
  /**
39
43
  *
@@ -50,5 +54,5 @@ export type ActionProps = ListItemProps & {
50
54
  * @param {OfflineViewProps} offlineViewProps Props forwarded to OfflineView when offline.
51
55
  * @returns a context menu with the given actions as ListItems
52
56
  */
53
- export declare const ContextMenu: ({ triggerOpen, actions, iconOrientation, "data-testid": dataTestId, isOnline, offlineViewProps, }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
57
+ export declare const ContextMenu: ({ triggerOpen, actions, iconOrientation, "data-testid": dataTestId, isOnline, offlineViewProps, }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element | null;
54
58
  export {};
@@ -1,51 +1,56 @@
1
- import { jsx as i, jsxs as v } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as v } from "react/jsx-runtime";
2
2
  import { I } from "../../index.es-t87yNd9Y.js";
3
- import { M, L as p, a, b as C } from "../../index.es-BHvm4m-B.js";
4
- import { useState as k, useCallback as r, useEffect as y, Fragment as g } from "react";
5
- import { u as h } from "../../uniqueId-BNVTeImh.js";
6
- import { O as w } from "../../OfflineView-CIwV08EQ.js";
7
- import '../../assets/ContextMenu.css';const x = "_menu_148i2_1", L = "_icon_148i2_6", V = "_listItem_148i2_10", B = "_offlineViewMargin_148i2_20", s = {
8
- menu: x,
9
- icon: L,
10
- listItem: V,
11
- offlineViewMargin: B
12
- }, S = ({
3
+ import { M as p, L as w, a as m, b as C } from "../../index.es-BHvm4m-B.js";
4
+ import { useState as g, useCallback as f, useEffect as h, useMemo as k, Fragment as y } from "react";
5
+ import { u as x } from "../../uniqueId-BNVTeImh.js";
6
+ import { O as L } from "../../OfflineView-CIwV08EQ.js";
7
+ import '../../assets/ContextMenu.css';const V = "_menu_148i2_1", B = "_icon_148i2_6", N = "_listItem_148i2_10", b = "_offlineViewMargin_148i2_20", s = {
8
+ menu: V,
9
+ icon: B,
10
+ listItem: N,
11
+ offlineViewMargin: b
12
+ }, q = ({
13
13
  triggerOpen: l = null,
14
- actions: m,
14
+ actions: o,
15
15
  iconOrientation: c = "vertical",
16
- "data-testid": f,
16
+ "data-testid": u,
17
17
  isOnline: d = !0,
18
- offlineViewProps: u
18
+ offlineViewProps: _
19
19
  }) => {
20
- const [t, n] = k(!1), _ = r(() => {
21
- n(!t);
22
- }, [t]), o = r(() => {
20
+ const [i, n] = g(!1), M = f(() => {
21
+ n(!i);
22
+ }, [i]), a = f(() => {
23
23
  n(!1);
24
24
  }, []);
25
- return y(() => {
25
+ h(() => {
26
26
  n(l !== null ? l : !1);
27
- }, [l]), /* @__PURE__ */ i(
28
- M,
27
+ }, [l]);
28
+ const r = k(
29
+ () => o.filter((e) => e.isAllowed !== !1),
30
+ [o]
31
+ );
32
+ return r.length === 0 ? null : /* @__PURE__ */ t(
33
+ p,
29
34
  {
30
35
  className: s.menu,
31
- "data-testid": f ?? "selection-menu",
32
- open: t,
36
+ "data-testid": u ?? "selection-menu",
37
+ open: i,
33
38
  surfaceOnly: !0,
34
39
  hoistToBody: !0,
35
- onClose: o,
36
- trigger: /* @__PURE__ */ i(
40
+ onClose: a,
41
+ trigger: /* @__PURE__ */ t(
37
42
  I,
38
43
  {
39
44
  className: s.icon,
40
- variant: t ? "filled-primary" : void 0,
45
+ variant: i ? "filled-primary" : void 0,
41
46
  "data-testid": "open-button",
42
47
  icon: c === "vertical" ? "more_vert" : "more_horiz",
43
- onClick: _
48
+ onClick: M
44
49
  }
45
50
  ),
46
- children: d ? /* @__PURE__ */ i(p, { "data-testid": "selection-list", children: m.map((e) => /* @__PURE__ */ v(g, { children: [
47
- e.dividerBefore && /* @__PURE__ */ i(a, {}),
48
- /* @__PURE__ */ i(
51
+ children: d ? /* @__PURE__ */ t(w, { "data-testid": "selection-list", children: r.map((e) => /* @__PURE__ */ v(y, { children: [
52
+ e.dividerBefore && /* @__PURE__ */ t(m, {}),
53
+ /* @__PURE__ */ t(
49
54
  C,
50
55
  {
51
56
  className: s.listItem,
@@ -53,18 +58,18 @@ import '../../assets/ContextMenu.css';const x = "_menu_148i2_1", L = "_icon_148i
53
58
  leadingBlockType: "icon",
54
59
  "data-testid": e["data-testid"],
55
60
  onClick: () => {
56
- e?.onClick?.(), e.closeOnClick !== !1 && o();
61
+ e?.onClick?.(), e.closeOnClick !== !1 && a();
57
62
  }
58
63
  }
59
64
  ),
60
- e.dividerAfter && /* @__PURE__ */ i(a, {})
61
- ] }, h(`LI_${e.primaryText?.toString()}_`))) }) : /* @__PURE__ */ i(
62
- w,
65
+ e.dividerAfter && /* @__PURE__ */ t(m, {})
66
+ ] }, x(`LI_${e.primaryText?.toString()}_`))) }) : /* @__PURE__ */ t(
67
+ L,
63
68
  {
64
69
  size: "small",
65
70
  variant: "filled",
66
71
  className: s.offlineViewMargin,
67
- ...u
72
+ ..._
68
73
  }
69
74
  )
70
75
  },
@@ -72,5 +77,5 @@ import '../../assets/ContextMenu.css';const x = "_menu_148i2_1", L = "_icon_148i
72
77
  );
73
78
  };
74
79
  export {
75
- S as ContextMenu
80
+ q as ContextMenu
76
81
  };
@@ -1,34 +1,34 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { a as i, s as t, f as o, w as c } from "../../react.esm-Bm0cAgpZ.js";
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { a, s as t, f as l, w as c } from "../../react.esm-Bm0cAgpZ.js";
3
3
  import { ContextMenu as d } from "./ContextMenu.js";
4
- import { a as B, d as I, t as l, g as e } from "../../vi.bdSIJ99Y-B308Q-4w.js";
5
- const g = B.fn(), m = B.fn(), r = B.fn(), u = [
4
+ import { a as i, d as y, t as r, g as e } from "../../vi.bdSIJ99Y-B308Q-4w.js";
5
+ const g = i.fn(), B = i.fn(), p = i.fn(), m = [
6
6
  { primaryText: "Open", onClick: g, leadingBlock: "add", "data-testid": "open-testid" },
7
7
  {
8
8
  primaryText: "Delete",
9
- onClick: r,
9
+ onClick: p,
10
10
  leadingBlock: "delete_outline",
11
11
  "data-testid": "delete-testid"
12
12
  },
13
- { primaryText: "Edit", onClick: m, leadingBlock: "edit", "data-testid": "edit-testid" }
13
+ { primaryText: "Edit", onClick: B, leadingBlock: "edit", "data-testid": "edit-testid" }
14
14
  ];
15
- I("ContextMenu Test", () => {
16
- l("render contextMenu and close it", () => {
17
- i(/* @__PURE__ */ a(d, { actions: u }));
18
- const s = t.getByTestId("open-button"), n = t.getByTestId("selection-menu");
19
- e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"), o.click(s), c(() => e(n).toHaveClass("mdc-menu-surface--open")), o.click(s), c(() => e(n).not.toHaveClass("mdc-menu-surface--open"));
20
- }), l("render ContextMenu and open it", async () => {
21
- i(/* @__PURE__ */ a(d, { actions: u, triggerOpen: !0 }));
22
- const s = t.getByTestId("open-button"), n = t.getByTestId("selection-menu");
23
- e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"), o.click(s), await c(() => e(n).toHaveClass("mdc-menu-surface--animating-open")), e(t.getByText("Open")).toBeInTheDocument(), e(t.getByText("Delete")).toBeInTheDocument(), e(t.getByText("Edit")).toBeInTheDocument();
24
- const p = t.getByTestId("open-testid"), T = t.getByTestId("delete-testid"), f = t.getByTestId("edit-testid");
25
- e(p).toBeInTheDocument(), e(T).toBeInTheDocument(), e(f).toBeInTheDocument(), o.click(p), e(g).toHaveBeenCalled(), e(r).not.toHaveBeenCalled(), e(m).not.toHaveBeenCalled(), o.click(T), e(r).toHaveBeenCalled(), o.click(f), e(m).toHaveBeenCalled();
26
- }), l("render ContextMenu with offlineView", async () => {
27
- i(
28
- /* @__PURE__ */ a(
15
+ y("ContextMenu Test", () => {
16
+ r("render contextMenu and close it", () => {
17
+ a(/* @__PURE__ */ s(d, { actions: m }));
18
+ const o = t.getByTestId("open-button"), n = t.getByTestId("selection-menu");
19
+ e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"), l.click(o), c(() => e(n).toHaveClass("mdc-menu-surface--open")), l.click(o), c(() => e(n).not.toHaveClass("mdc-menu-surface--open"));
20
+ }), r("render ContextMenu and open it", async () => {
21
+ a(/* @__PURE__ */ s(d, { actions: m, triggerOpen: !0 }));
22
+ const o = t.getByTestId("open-button"), n = t.getByTestId("selection-menu");
23
+ e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"), l.click(o), await c(() => e(n).toHaveClass("mdc-menu-surface--animating-open")), e(t.getByText("Open")).toBeInTheDocument(), e(t.getByText("Delete")).toBeInTheDocument(), e(t.getByText("Edit")).toBeInTheDocument();
24
+ const u = t.getByTestId("open-testid"), T = t.getByTestId("delete-testid"), f = t.getByTestId("edit-testid");
25
+ e(u).toBeInTheDocument(), e(T).toBeInTheDocument(), e(f).toBeInTheDocument(), l.click(u), e(g).toHaveBeenCalled(), e(p).not.toHaveBeenCalled(), e(B).not.toHaveBeenCalled(), l.click(T), e(p).toHaveBeenCalled(), l.click(f), e(B).toHaveBeenCalled();
26
+ }), r("render ContextMenu with offlineView", async () => {
27
+ a(
28
+ /* @__PURE__ */ s(
29
29
  d,
30
30
  {
31
- actions: u,
31
+ actions: m,
32
32
  triggerOpen: !0,
33
33
  isOnline: !1,
34
34
  offlineViewProps: {
@@ -37,9 +37,60 @@ I("ContextMenu Test", () => {
37
37
  }
38
38
  )
39
39
  );
40
- const s = t.getByTestId("open-button");
41
- o.click(s);
40
+ const o = t.getByTestId("open-button");
41
+ l.click(o);
42
42
  const n = t.getByTestId("selection-menu");
43
43
  await c(() => e(n).toHaveClass("mdc-menu-surface--animating-open")), e(t.getByTestId("offline-test")).toBeInTheDocument();
44
+ }), r("does not render action when isAllowed is false", async () => {
45
+ const o = [
46
+ {
47
+ primaryText: "Allowed Action",
48
+ onClick: i.fn(),
49
+ leadingBlock: "add",
50
+ "data-testid": "allowed-action",
51
+ isAllowed: !0
52
+ },
53
+ {
54
+ primaryText: "Not Allowed Action",
55
+ onClick: i.fn(),
56
+ leadingBlock: "delete_outline",
57
+ "data-testid": "not-allowed-action",
58
+ isAllowed: !1
59
+ },
60
+ {
61
+ primaryText: "Another Allowed Action",
62
+ onClick: i.fn(),
63
+ leadingBlock: "edit",
64
+ "data-testid": "another-allowed-action",
65
+ isAllowed: !0
66
+ }
67
+ ];
68
+ a(/* @__PURE__ */ s(d, { actions: o, triggerOpen: !0 }));
69
+ const n = t.getByTestId("open-button");
70
+ l.click(n);
71
+ const u = t.getByTestId("selection-menu");
72
+ await c(() => e(u).toHaveClass("mdc-menu-surface--animating-open")), e(t.getByText("Allowed Action")).toBeInTheDocument(), e(t.getByText("Another Allowed Action")).toBeInTheDocument(), e(t.queryByText("Not Allowed Action")).not.toBeInTheDocument();
73
+ }), r("does not render component when all actions have isAllowed false", () => {
74
+ const o = [
75
+ {
76
+ primaryText: "Not Allowed 1",
77
+ onClick: i.fn(),
78
+ leadingBlock: "add",
79
+ isAllowed: !1
80
+ },
81
+ {
82
+ primaryText: "Not Allowed 2",
83
+ onClick: i.fn(),
84
+ leadingBlock: "delete_outline",
85
+ isAllowed: !1
86
+ },
87
+ {
88
+ primaryText: "Not Allowed 3",
89
+ onClick: i.fn(),
90
+ leadingBlock: "edit",
91
+ isAllowed: !1
92
+ }
93
+ ];
94
+ a(/* @__PURE__ */ s(d, { actions: o })), e(t.queryByTestId("open-button")).not.toBeInTheDocument();
44
95
  });
45
96
  });