@hortiview/shared-components 2.12.2 → 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.
- package/CHANGELOG.md +22 -0
- package/README.md +9 -1
- package/dist/assets/BaseView.css +1 -1
- package/dist/components/Allowed/Allowed.d.ts +5 -5
- package/dist/components/Allowed/Allowed.js +2 -2
- package/dist/components/Allowed/Allowed.test.js +3 -3
- package/dist/components/AllowedButton/AllowedButton.d.ts +3 -3
- package/dist/components/AllowedButton/AllowedButton.js +1 -1
- package/dist/components/AllowedButton/AllowedButton.test.js +32 -32
- package/dist/components/AllowedIconButton/AllowedIconButton.d.ts +3 -3
- package/dist/components/AllowedIconButton/AllowedIconButton.js +1 -1
- package/dist/components/AllowedIconButton/AllowedIconButton.test.js +17 -17
- package/dist/components/BaseView/BaseView.d.ts +1 -0
- package/dist/components/BaseView/BaseView.js +79 -79
- package/dist/components/BaseView/BaseView.test.js +58 -18
- package/dist/components/ContextMenu/ContextMenu.d.ts +5 -1
- package/dist/components/ContextMenu/ContextMenu.js +40 -35
- package/dist/components/ContextMenu/ContextMenu.test.js +74 -23
- package/dist/components/DeleteModal/DeleteModal.d.ts +6 -1
- package/dist/components/DeleteModal/DeleteModal.js +73 -58
- package/dist/components/DeleteModal/DeleteModal.test.js +42 -19
- package/dist/components/PermissionChecks/PermissionService.d.ts +15 -8
- package/dist/components/PermissionChecks/PermissionService.js +18 -20
- package/dist/components/PermissionChecks/PermissionService.test.js +27 -19
- package/dist/main.d.ts +1 -0
- package/dist/types/ListElement.d.ts +5 -0
- package/dist/types/Permission.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import { jsx as e, Fragment as
|
|
2
|
-
import { D as
|
|
3
|
-
import { G as
|
|
4
|
-
import { P as
|
|
5
|
-
import { c as
|
|
6
|
-
import { useMemo as
|
|
7
|
-
import { BasicHeading as
|
|
8
|
-
import { EmptyView as
|
|
9
|
-
import { ListArea as
|
|
10
|
-
import { u as
|
|
11
|
-
import { O
|
|
12
|
-
import { useScrollableInfo as
|
|
13
|
-
import '../../assets/BaseView.css';const
|
|
14
|
-
fullHeight:
|
|
15
|
-
fullWidth:
|
|
16
|
-
maxWidth:
|
|
17
|
-
list:
|
|
18
|
-
desktopList:
|
|
19
|
-
noRoundedCorners:
|
|
20
|
-
detail:
|
|
21
|
-
desktopDetail:
|
|
22
|
-
},
|
|
23
|
-
heading:
|
|
24
|
-
action:
|
|
25
|
-
hint:
|
|
26
|
-
elements:
|
|
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:
|
|
29
|
-
isSorted:
|
|
30
|
-
className:
|
|
31
|
-
withAvatar:
|
|
32
|
-
listMaxHeight:
|
|
33
|
-
titleLevel:
|
|
34
|
-
detailTitleLevel:
|
|
35
|
-
pathname:
|
|
36
|
-
basicHeadingIcon:
|
|
37
|
-
isOnline:
|
|
38
|
-
offlineViewProps:
|
|
39
|
-
noRoundedListItemEdges:
|
|
40
|
-
routerLinkElement:
|
|
41
|
-
searchPlaceholder:
|
|
42
|
-
isGrouped:
|
|
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 } =
|
|
45
|
-
|
|
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__ */
|
|
49
|
-
|
|
48
|
+
return /* @__PURE__ */ c(
|
|
49
|
+
l,
|
|
50
50
|
{
|
|
51
51
|
"data-testid": "base-view-container",
|
|
52
|
-
className: `${i.fullHeight} ${
|
|
52
|
+
className: `${i.fullHeight} ${k ?? ""}`,
|
|
53
53
|
fullWidth: !0,
|
|
54
54
|
children: [
|
|
55
|
-
|
|
56
|
-
|
|
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:
|
|
61
|
+
className: g(
|
|
62
62
|
i.list,
|
|
63
63
|
o && i.desktopList,
|
|
64
|
-
|
|
64
|
+
_ && i.noRoundedCorners
|
|
65
65
|
),
|
|
66
66
|
children: [
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
u && /* @__PURE__ */ e(
|
|
68
|
+
w,
|
|
69
69
|
{
|
|
70
|
-
icon:
|
|
70
|
+
icon: N,
|
|
71
71
|
"data-testid": "heading",
|
|
72
|
-
heading:
|
|
73
|
-
level:
|
|
72
|
+
heading: u,
|
|
73
|
+
level: b,
|
|
74
74
|
marginBottom: 0,
|
|
75
75
|
inList: !0,
|
|
76
|
-
children:
|
|
76
|
+
children: f
|
|
77
77
|
}
|
|
78
78
|
),
|
|
79
|
-
|
|
79
|
+
v,
|
|
80
80
|
/* @__PURE__ */ e(
|
|
81
|
-
|
|
81
|
+
F,
|
|
82
82
|
{
|
|
83
|
-
hasLastItemNoRoundedEdges:
|
|
84
|
-
elements:
|
|
85
|
-
hasSearch:
|
|
86
|
-
maxHeight:
|
|
87
|
-
isSorted:
|
|
88
|
-
pathname:
|
|
89
|
-
routerLinkElement:
|
|
90
|
-
searchPlaceholder:
|
|
91
|
-
isGrouped:
|
|
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
|
-
|
|
98
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
114
|
+
withAvatar: x,
|
|
115
115
|
subHeading: t?.detailSubTitle,
|
|
116
|
-
children: t?.detailAction ??
|
|
116
|
+
children: t?.detailAction ?? f
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
|
-
|
|
119
|
+
G && /* @__PURE__ */ e(V, {}),
|
|
120
120
|
/* @__PURE__ */ e(
|
|
121
|
-
|
|
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:
|
|
127
|
-
children:
|
|
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
|
-
|
|
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
|
|
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
|
|
5
|
-
import { d as
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
41
|
+
r("render BaseView with empty view and navigation list", () => {
|
|
42
42
|
n(
|
|
43
43
|
/* @__PURE__ */ o(
|
|
44
|
-
|
|
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
|
-
}),
|
|
56
|
+
}), r("render BaseView with data and navigation list", () => {
|
|
57
57
|
n(
|
|
58
58
|
/* @__PURE__ */ o(
|
|
59
|
-
|
|
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
|
-
}),
|
|
72
|
+
}), r("render BaseView with custom detail title and no detail icon", () => {
|
|
73
73
|
n(
|
|
74
74
|
/* @__PURE__ */ o(
|
|
75
|
-
|
|
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
|
-
}),
|
|
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
|
-
|
|
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
|
-
}),
|
|
107
|
+
}), r("render BaseView with selected detail section", () => {
|
|
108
108
|
n(
|
|
109
109
|
/* @__PURE__ */ o(
|
|
110
|
-
|
|
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
|
-
),
|
|
122
|
-
}),
|
|
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
|
-
|
|
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
|
|
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
|
|
4
|
-
import { useState as
|
|
5
|
-
import { u as
|
|
6
|
-
import { O as
|
|
7
|
-
import '../../assets/ContextMenu.css';const
|
|
8
|
-
menu:
|
|
9
|
-
icon:
|
|
10
|
-
listItem:
|
|
11
|
-
offlineViewMargin:
|
|
12
|
-
},
|
|
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:
|
|
14
|
+
actions: o,
|
|
15
15
|
iconOrientation: c = "vertical",
|
|
16
|
-
"data-testid":
|
|
16
|
+
"data-testid": u,
|
|
17
17
|
isOnline: d = !0,
|
|
18
|
-
offlineViewProps:
|
|
18
|
+
offlineViewProps: _
|
|
19
19
|
}) => {
|
|
20
|
-
const [
|
|
21
|
-
n(!
|
|
22
|
-
}, [
|
|
20
|
+
const [i, n] = g(!1), M = f(() => {
|
|
21
|
+
n(!i);
|
|
22
|
+
}, [i]), a = f(() => {
|
|
23
23
|
n(!1);
|
|
24
24
|
}, []);
|
|
25
|
-
|
|
25
|
+
h(() => {
|
|
26
26
|
n(l !== null ? l : !1);
|
|
27
|
-
}, [l])
|
|
28
|
-
|
|
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":
|
|
32
|
-
open:
|
|
36
|
+
"data-testid": u ?? "selection-menu",
|
|
37
|
+
open: i,
|
|
33
38
|
surfaceOnly: !0,
|
|
34
39
|
hoistToBody: !0,
|
|
35
|
-
onClose:
|
|
36
|
-
trigger: /* @__PURE__ */
|
|
40
|
+
onClose: a,
|
|
41
|
+
trigger: /* @__PURE__ */ t(
|
|
37
42
|
I,
|
|
38
43
|
{
|
|
39
44
|
className: s.icon,
|
|
40
|
-
variant:
|
|
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__ */
|
|
47
|
-
e.dividerBefore && /* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
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 &&
|
|
61
|
+
e?.onClick?.(), e.closeOnClick !== !1 && a();
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
),
|
|
60
|
-
e.dividerAfter && /* @__PURE__ */
|
|
61
|
-
] },
|
|
62
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
80
|
+
q as ContextMenu
|
|
76
81
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { a
|
|
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
|
|
5
|
-
const g =
|
|
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:
|
|
9
|
+
onClick: p,
|
|
10
10
|
leadingBlock: "delete_outline",
|
|
11
11
|
"data-testid": "delete-testid"
|
|
12
12
|
},
|
|
13
|
-
{ primaryText: "Edit", onClick:
|
|
13
|
+
{ primaryText: "Edit", onClick: B, leadingBlock: "edit", "data-testid": "edit-testid" }
|
|
14
14
|
];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"),
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
e(n).toBeInTheDocument(), e(n).not.toHaveClass("mdc-menu-surface--open"),
|
|
24
|
-
const
|
|
25
|
-
e(
|
|
26
|
-
}),
|
|
27
|
-
|
|
28
|
-
/* @__PURE__ */
|
|
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:
|
|
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
|
|
41
|
-
|
|
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
|
});
|
|
@@ -60,6 +60,10 @@ type DeleteModalProps = {
|
|
|
60
60
|
* Default is _true_.
|
|
61
61
|
*/
|
|
62
62
|
isDeletePossible?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the delete action is pending; shows a loading state on the confirm button when true.
|
|
65
|
+
*/
|
|
66
|
+
isDeletePending?: boolean;
|
|
63
67
|
/**
|
|
64
68
|
* Whether the user is online; shows OfflineView when false.
|
|
65
69
|
*/
|
|
@@ -85,9 +89,10 @@ type DeleteModalProps = {
|
|
|
85
89
|
* @prop {function} onDelete - The function to call when the confirm button is clicked.
|
|
86
90
|
* @prop {function} onCancel - A optional function to call when the cancel button is clicked.
|
|
87
91
|
* @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_.
|
|
92
|
+
* @prop {boolean} isDeletePending - Whether the delete action is pending; shows a loading state on the confirm button when true.
|
|
88
93
|
* @prop {boolean} isOnline - Whether the user is online; shows OfflineView when false.
|
|
89
94
|
* @prop {Partial} offlineViewProps - Props forwarded to OfflineView when offline.
|
|
90
95
|
* @returns {ReactElement} A modal component for deleting items.
|
|
91
96
|
*/
|
|
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;
|
|
97
|
+
export declare const DeleteModal: ({ title, confirmButtonLabel, cancelButtonLabel, deleteHeader, deleteBody, deleteText, icon, isIconCrossedOut, impossibleDeleteHeader, open, setOpen, onDelete, onCancel, isDeletePossible, isDeletePending, isOnline, offlineViewProps, }: DeleteModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
93
98
|
export {};
|