@hortiview/shared-components 0.0.5409 → 0.0.5431
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/dist/components/ContextMenu/ContextMenu.js +20 -18
- package/dist/components/ContextMenu/ContextMenu.test.js +11 -11
- package/dist/components/EmptyView/EmptyView.d.ts +15 -8
- package/dist/components/EmptyView/EmptyView.js +15 -5
- package/dist/components/EmptyView/EmptyView.test.js +21 -16
- package/package.json +1 -1
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
import "../../assets/ContextMenu.css";
|
|
2
2
|
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
-
import { Menu as
|
|
4
|
-
import { useState as p, useCallback as
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { Menu as c, IconButton as a, List as d, ListItem as f } from "@element/react-components";
|
|
4
|
+
import { useState as p, useCallback as s, useEffect as _ } from "react";
|
|
5
|
+
import { uniqueId as y } from "lodash";
|
|
6
|
+
const C = "_menu_1rfel_1", k = {
|
|
7
|
+
menu: C
|
|
7
8
|
}, M = ({
|
|
8
9
|
triggerOpen: o = null,
|
|
9
|
-
actions:
|
|
10
|
-
iconOrientation:
|
|
10
|
+
actions: r,
|
|
11
|
+
iconOrientation: u = "vertical"
|
|
11
12
|
}) => {
|
|
12
|
-
const [e, t] = p(!1),
|
|
13
|
+
const [e, t] = p(!1), m = s(() => {
|
|
13
14
|
t(!e);
|
|
14
|
-
}, [e]), l =
|
|
15
|
+
}, [e]), l = s(() => {
|
|
15
16
|
t(!1);
|
|
16
17
|
}, []);
|
|
17
|
-
return
|
|
18
|
+
return _(() => {
|
|
18
19
|
t(o !== null ? o : !1);
|
|
19
20
|
}, [o]), /* @__PURE__ */ n(
|
|
20
|
-
|
|
21
|
+
c,
|
|
21
22
|
{
|
|
22
|
-
className:
|
|
23
|
+
className: k.menu,
|
|
23
24
|
"data-testid": "selectionmenu",
|
|
24
25
|
open: e,
|
|
25
26
|
surfaceOnly: !0,
|
|
26
27
|
hoistToBody: !0,
|
|
27
28
|
onClose: l,
|
|
28
29
|
trigger: /* @__PURE__ */ n(
|
|
29
|
-
|
|
30
|
+
a,
|
|
30
31
|
{
|
|
31
32
|
variant: e ? "filled-primary" : void 0,
|
|
32
33
|
"data-testid": "openButton",
|
|
33
|
-
icon:
|
|
34
|
-
onClick:
|
|
34
|
+
icon: u === "vertical" ? "more_vert" : "more_horiz",
|
|
35
|
+
onClick: m
|
|
35
36
|
}
|
|
36
37
|
),
|
|
37
|
-
children: /* @__PURE__ */ n(d, { children:
|
|
38
|
+
children: /* @__PURE__ */ n(d, { children: r.map((i) => /* @__PURE__ */ n(
|
|
38
39
|
f,
|
|
39
40
|
{
|
|
40
|
-
...
|
|
41
|
+
...i,
|
|
41
42
|
leadingBlockType: "icon",
|
|
42
43
|
"data-testid": "listItemButton",
|
|
43
44
|
onClick: () => {
|
|
44
|
-
|
|
45
|
+
i?.onClick?.(), l();
|
|
45
46
|
}
|
|
46
|
-
}
|
|
47
|
+
},
|
|
48
|
+
y(`LI_${i.primaryText?.toString()}_`)
|
|
47
49
|
)) })
|
|
48
50
|
},
|
|
49
51
|
"selectionmenu"
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { r, s as n, f as o, w as a } from "../../react.esm-C0LtovhP.js";
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { r as d, s as n, f as o, w as a } from "../../react.esm-C0LtovhP.js";
|
|
3
3
|
import { ContextMenu as u } from "./ContextMenu.js";
|
|
4
|
-
import { v as
|
|
5
|
-
const T =
|
|
4
|
+
import { v as r, d as g, t as B, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
const T = r.fn(), l = r.fn(), i = r.fn(), p = [
|
|
6
6
|
{ primaryText: "Open", onClick: T, leadingBlock: "add" },
|
|
7
7
|
{ primaryText: "Delete", onClick: i, leadingBlock: "delete_outline" },
|
|
8
8
|
{ primaryText: "Edit", onClick: l, leadingBlock: "edit" }
|
|
9
9
|
];
|
|
10
|
-
|
|
11
|
-
B("render
|
|
12
|
-
|
|
10
|
+
g("ContextMenu Test", () => {
|
|
11
|
+
B("render contextMenu and close it", () => {
|
|
12
|
+
d(/* @__PURE__ */ m(u, { actions: p }));
|
|
13
|
+
const c = n.getByTestId("openButton"), t = n.getByTestId("selectionmenu");
|
|
14
|
+
e(t).toBeInTheDocument(), e(t).not.toHaveClass("mdc-menu-surface--open"), o.click(c), a(() => e(t).toHaveClass("mdc-menu-surface--open")), o.click(c), a(() => e(t).not.toHaveClass("mdc-menu-surface--open"));
|
|
15
|
+
}), B("render ContextMenu and open it", async () => {
|
|
16
|
+
d(/* @__PURE__ */ m(u, { actions: p, triggerOpen: !0 }));
|
|
13
17
|
const c = n.getByTestId("openButton"), t = n.getByTestId("selectionmenu");
|
|
14
18
|
e(t).toBeInTheDocument(), e(t).not.toHaveClass("mdc-menu-surface--open"), o.click(c), a(() => e(t).toHaveClass("mdc-menu-surface--open"));
|
|
15
19
|
const s = n.getAllByTestId("listItemButton");
|
|
16
20
|
e(s.length).toBe(3), e(n.getByText("Open")).toBeInTheDocument(), e(n.getByText("Delete")).toBeInTheDocument(), e(n.getByText("Edit")).toBeInTheDocument(), o.click(s[0]), e(T).toHaveBeenCalled(), e(i).not.toHaveBeenCalled(), e(l).not.toHaveBeenCalled(), o.click(s[1]), e(i).toHaveBeenCalled(), o.click(s[2]), e(l).toHaveBeenCalled();
|
|
17
|
-
}), B("render contextMenu and close it", () => {
|
|
18
|
-
r(/* @__PURE__ */ d(u, { actions: p }));
|
|
19
|
-
const c = n.getByTestId("openButton"), t = n.getByTestId("selectionmenu");
|
|
20
|
-
e(t).toBeInTheDocument(), e(t).not.toHaveClass("mdc-menu-surface--open"), o.click(c), a(() => e(t).toHaveClass("mdc-menu-surface--open")), o.click(c), a(() => e(t).not.toHaveClass("mdc-menu-surface--open"));
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type EmptyViewProps = {
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* The title of the empty view, optional, default is empty string
|
|
4
5
|
*/
|
|
5
|
-
title?: string
|
|
6
|
+
title?: string;
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* The subtitle of the empty view, optional, default is empty string
|
|
8
9
|
*/
|
|
9
|
-
subtitle?: string
|
|
10
|
+
subtitle?: string;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* The icon of the empty view, optional, default is 'dashbord'
|
|
12
13
|
*/
|
|
13
|
-
icon?: string
|
|
14
|
-
|
|
14
|
+
icon?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The action of the empty view, optional, default is empty
|
|
17
|
+
*/
|
|
18
|
+
action?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
export declare const EmptyView: ({ title, subtitle, icon, action, }: EmptyViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { Hero as
|
|
3
|
-
const
|
|
2
|
+
import { Hero as n, HeroContent as h, Icon as l } from "@element/react-components";
|
|
3
|
+
const d = ({
|
|
4
4
|
title: e = "",
|
|
5
5
|
subtitle: r = "",
|
|
6
|
-
icon: t = "dashbord"
|
|
7
|
-
|
|
6
|
+
icon: t = "dashbord",
|
|
7
|
+
action: i
|
|
8
|
+
}) => /* @__PURE__ */ o(n, { style: { width: "100%", height: "25vh" }, children: /* @__PURE__ */ o(
|
|
9
|
+
h,
|
|
10
|
+
{
|
|
11
|
+
logo: /* @__PURE__ */ o(l, { iconSize: "large", icon: t }),
|
|
12
|
+
overline: "",
|
|
13
|
+
subtitle: r,
|
|
14
|
+
title: e,
|
|
15
|
+
heroBtn: i
|
|
16
|
+
}
|
|
17
|
+
) });
|
|
8
18
|
export {
|
|
9
|
-
|
|
19
|
+
d as EmptyView
|
|
10
20
|
};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { r as
|
|
3
|
-
import { EmptyView as
|
|
4
|
-
import { d as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}),
|
|
9
|
-
|
|
10
|
-
}),
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
e
|
|
14
|
-
}),
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
e
|
|
2
|
+
import { r as n, s, w as r, f as c } from "../../react.esm-C0LtovhP.js";
|
|
3
|
+
import { EmptyView as i } from "./EmptyView.js";
|
|
4
|
+
import { d as T, t as a, g as t, v as l } from "../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
T("EmptyView", () => {
|
|
6
|
+
a("should render", () => {
|
|
7
|
+
n(/* @__PURE__ */ o(i, {})), t(s.getByText("dashbord")).toBeInTheDocument();
|
|
8
|
+
}), a("should render with custom icon", () => {
|
|
9
|
+
n(/* @__PURE__ */ o(i, { icon: "add" })), t(s.getByText("add")).toBeInTheDocument();
|
|
10
|
+
}), a("should render with title", () => {
|
|
11
|
+
n(/* @__PURE__ */ o(i, { icon: "add", title: "TITLE" }));
|
|
12
|
+
const e = s.getByText("TITLE");
|
|
13
|
+
t(e).toBeInTheDocument(), t(e).toHaveClass(/headline2/);
|
|
14
|
+
}), a("should render with subtitle", () => {
|
|
15
|
+
n(/* @__PURE__ */ o(i, { icon: "add", subtitle: "SUB_TITLE" }));
|
|
16
|
+
const e = s.getByText("SUB_TITLE");
|
|
17
|
+
t(e).toBeInTheDocument(), t(e).toHaveClass(/headline6/);
|
|
18
|
+
}), a("should render with an action", async () => {
|
|
19
|
+
const e = l.fn();
|
|
20
|
+
n(/* @__PURE__ */ o(i, { icon: "add", action: /* @__PURE__ */ o("button", { onClick: e, children: "BUTTON" }) }));
|
|
21
|
+
const d = s.getByText("BUTTON");
|
|
22
|
+
t(d).toBeInTheDocument(), await r(() => c.click(d)), t(e).toHaveBeenCalledTimes(1);
|
|
18
23
|
});
|
|
19
24
|
});
|
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.
|
|
4
|
+
"version": "0.0.5431",
|
|
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>",
|