@hortiview/shared-components 0.0.1

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.
Files changed (70) hide show
  1. package/README.md +34 -0
  2. package/dist/ListAreaService-D16C1IfO.js +67 -0
  3. package/dist/_commonjsHelpers-CT_km90n.js +30 -0
  4. package/dist/assets/BaseView.css +1 -0
  5. package/dist/assets/BasicHeading.css +1 -0
  6. package/dist/assets/BlockView.css +1 -0
  7. package/dist/assets/HashTabView.css +1 -0
  8. package/dist/assets/Iconify.css +1 -0
  9. package/dist/assets/ListAreaService.css +1 -0
  10. package/dist/assets/SearchBar.css +1 -0
  11. package/dist/assets/VerticalDivider.css +1 -0
  12. package/dist/components/BaseView/BaseView.d.ts +55 -0
  13. package/dist/components/BaseView/BaseView.js +63 -0
  14. package/dist/components/BaseView/BaseView.test.d.ts +1 -0
  15. package/dist/components/BaseView/BaseView.test.js +124 -0
  16. package/dist/components/BasicHeading/BasicHeading.d.ts +48 -0
  17. package/dist/components/BasicHeading/BasicHeading.js +80 -0
  18. package/dist/components/BasicHeading/BasicHeading.test.d.ts +1 -0
  19. package/dist/components/BasicHeading/BasicHeading.test.js +35 -0
  20. package/dist/components/BlockView/BlockView.d.ts +59 -0
  21. package/dist/components/BlockView/BlockView.js +73 -0
  22. package/dist/components/BlockView/BlockView.test.d.ts +1 -0
  23. package/dist/components/BlockView/BlockView.test.js +46 -0
  24. package/dist/components/EmptyView/EmptyView.d.ts +14 -0
  25. package/dist/components/EmptyView/EmptyView.js +10 -0
  26. package/dist/components/EmptyView/EmptyView.test.d.ts +1 -0
  27. package/dist/components/EmptyView/EmptyView.test.js +18 -0
  28. package/dist/components/HashTabView/HashTabView.d.ts +47 -0
  29. package/dist/components/HashTabView/HashTabView.js +81 -0
  30. package/dist/components/HashTabView/HashTabView.test.d.ts +1 -0
  31. package/dist/components/HashTabView/HashTabView.test.js +30 -0
  32. package/dist/components/Iconify/Iconify.d.ts +13 -0
  33. package/dist/components/Iconify/Iconify.js +38 -0
  34. package/dist/components/Iconify/Iconify.test.d.ts +1 -0
  35. package/dist/components/Iconify/Iconify.test.js +24 -0
  36. package/dist/components/ListArea/ListArea.d.ts +57 -0
  37. package/dist/components/ListArea/ListArea.js +892 -0
  38. package/dist/components/ListArea/ListArea.test.d.ts +1 -0
  39. package/dist/components/ListArea/ListArea.test.js +104 -0
  40. package/dist/components/ListArea/ListAreaService.d.ts +64 -0
  41. package/dist/components/ListArea/ListAreaService.js +10 -0
  42. package/dist/components/SearchBar/SearchBar.d.ts +24 -0
  43. package/dist/components/SearchBar/SearchBar.js +33 -0
  44. package/dist/components/SearchBar/SearchBar.test.d.ts +1 -0
  45. package/dist/components/SearchBar/SearchBar.test.js +21 -0
  46. package/dist/components/VerticalDivider/VerticalDivider.d.ts +13 -0
  47. package/dist/components/VerticalDivider/VerticalDivider.js +8 -0
  48. package/dist/components/VerticalDivider/VerticalDivider.test.d.ts +1 -0
  49. package/dist/components/VerticalDivider/VerticalDivider.test.js +14 -0
  50. package/dist/enums/AvailableCustomIcons.d.ts +15 -0
  51. package/dist/enums/AvailableCustomIcons.js +4 -0
  52. package/dist/hooks/useBreakpoint.d.ts +15 -0
  53. package/dist/hooks/useBreakpoint.js +6 -0
  54. package/dist/magic-string.es-irX7syie.js +732 -0
  55. package/dist/main.d.ts +13 -0
  56. package/dist/main.js +24 -0
  57. package/dist/services/BlockService.d.ts +8 -0
  58. package/dist/services/BlockService.js +4 -0
  59. package/dist/types/HashTab.d.ts +25 -0
  60. package/dist/types/HashTab.js +1 -0
  61. package/dist/types/ListElement.d.ts +94 -0
  62. package/dist/types/ListElement.js +1 -0
  63. package/dist/types/internal/Block.d.ts +9 -0
  64. package/dist/types/internal/Block.js +1 -0
  65. package/dist/types/internal/ReactRouterTypes.d.ts +28 -0
  66. package/dist/types/internal/ReactRouterTypes.js +1 -0
  67. package/dist/useBreakpoint-DyAmuka7.js +35 -0
  68. package/dist/vi.JYQecGiw-D8gb8QJV.js +22539 -0
  69. package/dist/vite-env.d.js +1 -0
  70. package/package.json +61 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,104 @@
1
+ import { jsx as r, Fragment as i } from "react/jsx-runtime";
2
+ import { TypoButton as p } from "@element/react-components";
3
+ import { d as m, t as n, r as s, s as a, g as t, f as u } from "../../vi.JYQecGiw-D8gb8QJV.js";
4
+ import { ListArea as c } from "./ListArea.js";
5
+ import { g as h } from "../../ListAreaService-D16C1IfO.js";
6
+ m("ListArea Test", () => {
7
+ const o = [
8
+ {
9
+ id: "1",
10
+ title: "user.personal_information",
11
+ icon: "account_circle",
12
+ route: "/personal-profile/personal-information",
13
+ component: /* @__PURE__ */ r(i, { children: "Personal information selected" })
14
+ },
15
+ {
16
+ id: "2",
17
+ title: "user.data_privacy",
18
+ icon: "privacy_tip",
19
+ route: "/personal-profile/data-privacy",
20
+ component: /* @__PURE__ */ r(i, { children: "Data Privacy selected" })
21
+ },
22
+ {
23
+ id: "3",
24
+ title: "user.security",
25
+ icon: "security",
26
+ route: "/personal-profile/security",
27
+ component: /* @__PURE__ */ r(i, { children: "Security selected" })
28
+ }
29
+ ];
30
+ n("render ListArea options properly", () => {
31
+ s(
32
+ /* @__PURE__ */ r(
33
+ c,
34
+ {
35
+ elements: o,
36
+ pathname: "/personal-profile/data-privacy",
37
+ routerLinkElement: void 0
38
+ }
39
+ )
40
+ );
41
+ const e = a.getAllByRole("option");
42
+ t(e.length).toBe(3), t(e[0]).toHaveTextContent(/privacy_tip/), t(e[0]).toHaveTextContent(/user.data_privacy/), t(e[0]).toHaveTextContent(/arrow_right/), t(e[1]).toHaveTextContent(/account_circle/), t(e[1]).toHaveTextContent(/user.personal_information/), t(e[1]).toHaveTextContent(/arrow_right/), t(e[2]).toHaveTextContent(/security/), t(e[2]).toHaveTextContent(/user.security/), t(e[2]).toHaveTextContent(/arrow_right/);
43
+ }), n("render ListArea with search bar", () => {
44
+ s(
45
+ /* @__PURE__ */ r(
46
+ c,
47
+ {
48
+ elements: o,
49
+ hasSearch: !0,
50
+ searchPlaceholder: "search",
51
+ pathname: "/personal-profile/data-privacy",
52
+ routerLinkElement: void 0
53
+ }
54
+ )
55
+ );
56
+ const e = a.getByRole("textbox", { name: "search" });
57
+ t(e).toBeInTheDocument(), t(e).toHaveAttribute("placeholder", "search");
58
+ }), n("filter ListArea options on setting search value", () => {
59
+ s(
60
+ /* @__PURE__ */ r(
61
+ c,
62
+ {
63
+ elements: o,
64
+ hasSearch: !0,
65
+ pathname: "/personal-profile/data-privacy",
66
+ routerLinkElement: void 0
67
+ }
68
+ )
69
+ );
70
+ const e = a.getByRole("textbox", { name: "search" });
71
+ u.change(e, { target: { value: "personal" } });
72
+ const l = a.getAllByRole("option");
73
+ t(l.length).toBe(1), t(l[0]).toHaveTextContent(/user.personal_information/);
74
+ });
75
+ });
76
+ m("ListAreaService Test", () => {
77
+ const o = [
78
+ {
79
+ id: "1",
80
+ groupName: "farm-1",
81
+ title: "GH1",
82
+ icon: "grass",
83
+ route: "/farm-1/gh1"
84
+ },
85
+ {
86
+ id: "2",
87
+ groupName: "farm-1",
88
+ title: "GH2",
89
+ icon: "grass",
90
+ route: "/farm-1/gh2"
91
+ },
92
+ {
93
+ id: "3",
94
+ groupName: "farm-2",
95
+ title: "GH3",
96
+ icon: "grass",
97
+ route: "/farm-2/gh3"
98
+ }
99
+ ];
100
+ n("should return grouped items", () => {
101
+ const e = h(o, "", "", void 0);
102
+ t(e.length).toBe(2), t(e[0].groupName).toStrictEqual(/* @__PURE__ */ r(p, { tag: "span", children: "farm-1" })), t(e[0].items.length).toBe(2), t(e[1].groupName).toStrictEqual(/* @__PURE__ */ r(p, { tag: "span", children: "farm-2" })), t(e[1].items.length).toBe(1);
103
+ });
104
+ });
@@ -0,0 +1,64 @@
1
+ import { ChangeEvent } from 'react';
2
+ import { LinkProps } from '../../types/internal/ReactRouterTypes';
3
+ import { ListElement } from '../../types/ListElement';
4
+ /**
5
+ * Groups items by groupName property and maps them to the schema of Bayer's List component
6
+ * @param items the items to group
7
+ * @param pathname current browser location
8
+ * @param itemClassName custom class name or CSS module style
9
+ * @returns an array objects with the schema { groupName, id, items }
10
+ */
11
+ export declare const getGroupedItems: (items: ListElement[], pathname: string, itemClassName: string, routerLinkElement: undefined | React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>) => {
12
+ groupName: string | JSX.Element;
13
+ id: string;
14
+ items: object[];
15
+ }[];
16
+ /**
17
+ * Maps items to the schema of Bayer's List component
18
+ * @param items the items to map
19
+ * @param pathname current browser location
20
+ * @param itemClassName custom class name or CSS module style
21
+ * @returns an array of objects with List component schema
22
+ */
23
+ export declare const getListedItems: (items: ListElement[], pathname: string, itemClassName: string, routerLinkElement: undefined | React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>) => {
24
+ select: boolean;
25
+ primaryText: import("react/jsx-runtime").JSX.Element;
26
+ secondaryText: import("react/jsx-runtime").JSX.Element | undefined;
27
+ trailingBlock: string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode>;
28
+ leadingBlock: string | import("react/jsx-runtime").JSX.Element | undefined;
29
+ nonInteractive: boolean | undefined;
30
+ value: string | undefined;
31
+ componentProps: {
32
+ leadingBlockType: "icon" | "checkbox" | "radio" | "switch" | "badge" | "meta" | "image" | "avatar" | "lgImage" | "thumbnail";
33
+ trailingBlockType: "icon" | "checkbox" | "radio" | "switch" | "badge" | "meta" | "image" | "avatar" | "lgImage" | "thumbnail";
34
+ className: string;
35
+ onClick: (_: ChangeEvent, value: string) => void | undefined;
36
+ tag: string | import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>> | undefined;
37
+ to: string | undefined;
38
+ };
39
+ }[];
40
+ /**
41
+ * Maps an item to the schema of Bayer's List component
42
+ * @param element the item to map
43
+ * @param pathname current browser location
44
+ * @param itemClassName custom class name or CSS module style
45
+ * @param isGrouped whether the item is part of a group
46
+ * @returns an object with List component schema
47
+ */
48
+ export declare const mapListElement: (element: ListElement, pathname: string | undefined, itemClassName: string | undefined, isGrouped: boolean, routerLinkElement: undefined | React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>) => {
49
+ select: boolean;
50
+ primaryText: import("react/jsx-runtime").JSX.Element;
51
+ secondaryText: import("react/jsx-runtime").JSX.Element | undefined;
52
+ trailingBlock: string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode>;
53
+ leadingBlock: string | import("react/jsx-runtime").JSX.Element | undefined;
54
+ nonInteractive: boolean | undefined;
55
+ value: string | undefined;
56
+ componentProps: {
57
+ leadingBlockType: "icon" | "checkbox" | "radio" | "switch" | "badge" | "meta" | "image" | "avatar" | "lgImage" | "thumbnail";
58
+ trailingBlockType: "icon" | "checkbox" | "radio" | "switch" | "badge" | "meta" | "image" | "avatar" | "lgImage" | "thumbnail";
59
+ className: string;
60
+ onClick: (_: ChangeEvent, value: string) => void | undefined;
61
+ tag: string | import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>> | undefined;
62
+ to: string | undefined;
63
+ };
64
+ };
@@ -0,0 +1,10 @@
1
+ import "react/jsx-runtime";
2
+ import "@element/react-components";
3
+ import "../Iconify/Iconify.js";
4
+ import { g as s, a as i, m as a } from "../../ListAreaService-D16C1IfO.js";
5
+ import "../../enums/AvailableCustomIcons.js";
6
+ export {
7
+ s as getGroupedItems,
8
+ i as getListedItems,
9
+ a as mapListElement
10
+ };
@@ -0,0 +1,24 @@
1
+ type SearchBarProps = {
2
+ /**
3
+ * the current search term
4
+ */
5
+ searchTerm: string;
6
+ /**
7
+ * the function to set the search term
8
+ */
9
+ setSearchTerm: (value: string) => void;
10
+ /**
11
+ * the placeholder of the search input
12
+ */
13
+ placeholder?: string;
14
+ /**
15
+ * if true the field is smaller, normal size otherwise, default: false
16
+ */
17
+ dense?: boolean;
18
+ /**
19
+ * optional className to customize the searchbar style
20
+ */
21
+ className?: string;
22
+ };
23
+ export declare const SearchBar: ({ className, dense, searchTerm, setSearchTerm, placeholder, }: SearchBarProps) => import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,33 @@
1
+ import "../../assets/SearchBar.css";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import { Textfield as c, IconButton as i } from "@element/react-components";
4
+ const s = "_searchbar_1fl50_1", u = {
5
+ searchbar: s
6
+ }, d = ({
7
+ className: r = "",
8
+ dense: n = !1,
9
+ searchTerm: a,
10
+ setSearchTerm: o,
11
+ placeholder: e
12
+ }) => /* @__PURE__ */ t(
13
+ c,
14
+ {
15
+ className: `${r ?? ""} ${u.searchbar}`,
16
+ dense: n,
17
+ variant: "outlined",
18
+ placeholder: e,
19
+ value: a,
20
+ onChange: (l) => o(l.target.value),
21
+ fullWidth: !0,
22
+ trailingIcon: /* @__PURE__ */ t(
23
+ i,
24
+ {
25
+ icon: a ? "close" : "search",
26
+ onClick: () => a ? o("") : void 0
27
+ }
28
+ )
29
+ }
30
+ );
31
+ export {
32
+ d as SearchBar
33
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { d as h, t as r, r as s, v as o, g as e, s as t, f as l, a as m } from "../../vi.JYQecGiw-D8gb8QJV.js";
3
+ import { SearchBar as n } from "./SearchBar.js";
4
+ h("SearchBar Test", () => {
5
+ r("renders SearchBar component", () => {
6
+ s(
7
+ /* @__PURE__ */ a(n, { searchTerm: "searchValue", setSearchTerm: o.fn(), placeholder: "search" })
8
+ ), e(t.getByRole("textbox")).toBeInTheDocument(), e(t.getByRole("textbox")).toHaveAttribute("placeholder", "search"), e(t.getByRole("textbox")).toHaveAttribute("value", "searchValue"), e(t.getByRole("textbox").parentElement).not.toHaveClass("lmnt-text-field--dense"), e(t.getByText("close")).toBeInTheDocument();
9
+ }), r("renders SearchBar component with custom classname", () => {
10
+ s(/* @__PURE__ */ a(n, { searchTerm: "search", setSearchTerm: o.fn(), className: "searchClass" })), e(t.getByRole("textbox").parentElement).toHaveClass("searchClass");
11
+ }), r("renders SearchBar component with dense look", () => {
12
+ s(/* @__PURE__ */ a(n, { searchTerm: "search", setSearchTerm: o.fn(), dense: !0 })), e(t.getByRole("textbox").parentElement).toHaveClass("lmnt-text-field--dense");
13
+ }), r("renders SearchBar component with search icon", () => {
14
+ s(/* @__PURE__ */ a(n, { searchTerm: "", setSearchTerm: o.fn(), dense: !0 })), e(t.getByText("search")).toBeInTheDocument();
15
+ }), r("renders SearchBar and changes value", () => {
16
+ const c = o.fn();
17
+ s(/* @__PURE__ */ a(n, { searchTerm: "", setSearchTerm: c })), e(t.getByText("search")).toBeInTheDocument(), e(t.getByRole("textbox")).toHaveAttribute("value", ""), l.change(t.getByRole("textbox"), { target: { value: "searchValue" } }), m(() => {
18
+ e(c).toHaveBeenCalledTimes(1), e(c).toHaveBeenCalledWith("searchValue");
19
+ });
20
+ });
21
+ });
@@ -0,0 +1,13 @@
1
+ type VerticalDividerProps = {
2
+ /**
3
+ * provided height in rem
4
+ * default: 2rem
5
+ */
6
+ height?: string;
7
+ /**
8
+ * optional className to customize the divider style
9
+ */
10
+ className?: string;
11
+ };
12
+ export declare const VerticalDivider: ({ height, className }: VerticalDividerProps) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,8 @@
1
+ import "../../assets/VerticalDivider.css";
2
+ import { jsx as e } from "react/jsx-runtime";
3
+ const d = "_divider_dqwln_1", t = {
4
+ divider: d
5
+ }, v = ({ height: i = "2rem", className: r = "" }) => /* @__PURE__ */ e("div", { className: `${t.divider} ${r}`, style: { height: i } });
6
+ export {
7
+ v as VerticalDivider
8
+ };
@@ -0,0 +1,14 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { d, t as s, r, g as i } from "../../vi.JYQecGiw-D8gb8QJV.js";
3
+ import { VerticalDivider as l } from "./VerticalDivider.js";
4
+ d("VerticalDivider Test", () => {
5
+ s("it should render with basic styling", () => {
6
+ r(/* @__PURE__ */ e(l, {}));
7
+ const t = document.body.firstElementChild;
8
+ i(t?.firstChild).toHaveClass(/divider/), i(t?.firstChild).toHaveStyle({ height: "2rem" });
9
+ }), s("it should render with custom styling", () => {
10
+ r(/* @__PURE__ */ e(l, { height: "3rem", className: "plus" }));
11
+ const t = document.body.firstElementChild;
12
+ i(t?.firstChild).toHaveClass(/divider/), i(t?.firstChild).toHaveClass(/plus/), i(t?.firstChild).toHaveStyle({ height: "3rem" });
13
+ });
14
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The available icons for the {@link Iconify} component.
3
+ */
4
+ export declare enum AvailableCustomIcons {
5
+ 'cloud-rain' = 0,
6
+ 'cloud-sunny' = 1,
7
+ 'farm-delete' = 2,
8
+ 'block-delete' = 3,
9
+ 'greenhouse-delete' = 4,
10
+ block = 5,
11
+ cloud = 6,
12
+ farm = 7,
13
+ subscription = 8,
14
+ wind = 9
15
+ }
@@ -0,0 +1,4 @@
1
+ var r = /* @__PURE__ */ ((d) => (d[d["cloud-rain"] = 0] = "cloud-rain", d[d["cloud-sunny"] = 1] = "cloud-sunny", d[d["farm-delete"] = 2] = "farm-delete", d[d["block-delete"] = 3] = "block-delete", d[d["greenhouse-delete"] = 4] = "greenhouse-delete", d[d.block = 5] = "block", d[d.cloud = 6] = "cloud", d[d.farm = 7] = "farm", d[d.subscription = 8] = "subscription", d[d.wind = 9] = "wind", d))(r || {});
2
+ export {
3
+ r as AvailableCustomIcons
4
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Custom hook that tells you whether a given media query is active.
3
+ *
4
+ * Inspired by https://usehooks.com/useMedia/
5
+ * https://gist.github.com/gragland/ed8cac563f5df71d78f4a1fefa8c5633
6
+ */
7
+ export declare function useMediaQuery(query: string): boolean;
8
+ export declare function useBreakpoints(): {
9
+ isXs: boolean;
10
+ isSm: boolean;
11
+ isMd: boolean;
12
+ isLg: boolean;
13
+ isXlg: boolean;
14
+ active: string;
15
+ };
@@ -0,0 +1,6 @@
1
+ import "react";
2
+ import { u as a, b as o } from "../useBreakpoint-DyAmuka7.js";
3
+ export {
4
+ a as useBreakpoints,
5
+ o as useMediaQuery
6
+ };