@hortiview/shared-components 0.0.7369 → 0.0.7373

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.
@@ -9,6 +9,7 @@ type FilterProps = {
9
9
  filterButtonText: string;
10
10
  filterModalTitle: string;
11
11
  filters: FilterData[];
12
+ useModal?: boolean;
12
13
  };
13
14
  /**
14
15
  * Filter component that allows the user to filter the data provided
@@ -21,7 +22,9 @@ type FilterProps = {
21
22
  * @param filters - the filter data
22
23
  * @param modalCancelButtonText - the text for the cancel button in the modal
23
24
  * @param modalConfirmButtonText - the text for the confirm button in the modal
25
+ * @param useModal - if the filter should use a modal and a filter button, default is true,
26
+ * if false the filters will be displayed directly in the page, be aware that the filters will be displayed in a row and there needs to be enough space for them
24
27
  * @returns
25
28
  */
26
- export declare const Filter: ({ clearFilterText, closeCallback, currentFilter, filterButtonAsIcon, filterButtonText, filterModalTitle, filters, modalCancelButtonText, modalConfirmButtonText, }: FilterProps) => import("react/jsx-runtime").JSX.Element;
29
+ export declare const Filter: ({ clearFilterText, closeCallback, currentFilter, filterButtonAsIcon, filterButtonText, filterModalTitle, filters, modalCancelButtonText, modalConfirmButtonText, useModal, }: FilterProps) => import("react/jsx-runtime").JSX.Element;
27
30
  export {};
@@ -1,15 +1,16 @@
1
- import { jsxs as B, Fragment as I, jsx as t } from "react/jsx-runtime";
2
- import { Modal as j, Button as s, Group as A, Select as D, IconButton as K, NotificationBadge as v } from "@element/react-components";
3
- import { useState as u } from "react";
4
- import { s as f } from "../../genericTable.module-CXfRg0e4.js";
5
- import { u as F } from "../../useBreakpoints-BNeVhjjZ.js";
1
+ import { jsx as t, jsxs as y, Fragment as I } from "react/jsx-runtime";
2
+ import { Group as v, Modal as W, Button as p, Select as j, IconButton as z, NotificationBadge as S } from "@element/react-components";
3
+ import { useState as g } from "react";
4
+ import { s as d } from "../../genericTable.module-CNV1Yt1K.js";
5
+ import { u as O } from "../../useBreakpoints-BNeVhjjZ.js";
6
6
  import "../../alertBanner.module-HneYdVzN.js";
7
- import "../../iconify.module-C89oaw5b.js";
8
- import "../../isArray-Ca4KR8TK.js";
7
+ import { I as H } from "../../Iconify-CY9lZjFd.js";
9
8
  import "../../react-tooltip.min-BzHiZW8k.js";
10
9
  import "../../basicHeading.module-BYb8xvuk.js";
10
+ import "../../isArray-Ca4KR8TK.js";
11
11
  import "../../_baseToString-BNXOi2Mf.js";
12
12
  import "../../_equalByTag-DJhSpgVG.js";
13
+ import "../../iconify.module-C89oaw5b.js";
13
14
  import "../../searchBar.module-9gKyrZRT.js";
14
15
  import "../../listArea.module-CGpHPOji.js";
15
16
  import "../../verticalDivider.module-C3_GL-fH.js";
@@ -30,111 +31,118 @@ import "react-hook-form";
30
31
  import "../../formDatePicker.module-BV3ma_7y.js";
31
32
  import "../../formSelect.module-C18N-SsT.js";
32
33
  import "../../formText.module-C0by6_DK.js";
33
- const ft = ({
34
- clearFilterText: a,
35
- closeCallback: m,
36
- currentFilter: i,
37
- filterButtonAsIcon: r = !1,
38
- filterButtonText: l,
39
- filterModalTitle: x,
40
- filters: y,
41
- modalCancelButtonText: S,
42
- modalConfirmButtonText: k
34
+ const vt = ({
35
+ clearFilterText: o,
36
+ closeCallback: l,
37
+ currentFilter: r,
38
+ filterButtonAsIcon: e = !1,
39
+ filterButtonText: i,
40
+ filterModalTitle: u,
41
+ filters: a,
42
+ modalCancelButtonText: m,
43
+ modalConfirmButtonText: n,
44
+ useModal: b = !0
43
45
  }) => {
44
- const { isDesktop: O } = F(), [b, p] = u(!1), [n, h] = u(i), [N, g] = u(0), C = () => {
45
- p(!1), m(n), g(
46
- n.reduce((e, { selectedOptions: o }) => e + o.length, 0)
46
+ const { isDesktop: N } = O(), [A, f] = g(!1), [s, C] = g(r), [_, x] = g(0), B = () => {
47
+ f(!1), l(s), x(
48
+ s.reduce((c, { selectedOptions: h }) => c + h.length, 0)
47
49
  );
48
- }, _ = () => {
49
- h([]), g(0);
50
- }, w = (e) => {
51
- const o = [
52
- ...n.filter((c) => c.id !== e.id),
53
- e
50
+ }, w = () => {
51
+ C([]), x(0);
52
+ }, F = (c) => {
53
+ const h = [
54
+ ...s.filter((D) => D.id !== c.id),
55
+ c
54
56
  ];
55
- h(o);
57
+ C(h);
56
58
  };
57
- return /* @__PURE__ */ B(I, { children: [
59
+ return b ? /* @__PURE__ */ y(I, { children: [
58
60
  /* @__PURE__ */ t(
59
- M,
61
+ K,
60
62
  {
61
- filterButtonText: l,
62
- filterButtonAsIcon: r,
63
- count: N,
64
- onClick: () => p(!0)
63
+ filterButtonText: i,
64
+ filterButtonAsIcon: e,
65
+ count: _,
66
+ onClick: () => f(!0)
65
67
  }
66
68
  ),
67
69
  /* @__PURE__ */ t(
68
- j,
70
+ W,
69
71
  {
70
- open: b,
71
- onClose: C,
72
- title: x,
73
- modalSize: O ? "small" : "fullscreen",
74
- headerActions: /* @__PURE__ */ t(s, { variant: "text", onClick: _, children: a }),
75
- dismissiveButton: /* @__PURE__ */ t(s, { variant: "outlined", onClick: () => p(!1), children: S }),
76
- primaryButton: /* @__PURE__ */ t(s, { variant: "filled", onClick: C, children: k }),
77
- children: /* @__PURE__ */ t(A, { direction: "vertical", children: y.map(({ id: e, title: o, availableOptions: c }) => /* @__PURE__ */ t(
78
- D,
79
- {
80
- variant: "outlined",
81
- options: c,
82
- label: o,
83
- multiSelect: !0,
84
- textKey: "text",
85
- valueKey: "id",
86
- value: n.find((d) => d.id === e)?.selectedOptions ?? [],
87
- onChange: (d) => w({ id: e, selectedOptions: d }),
88
- hoisted: !0,
89
- menuMaxHeight: "300px",
90
- disabled: e === "location",
91
- showOptionFilter: !1
92
- },
93
- e
94
- )) })
72
+ open: A,
73
+ onClose: B,
74
+ title: u,
75
+ modalSize: N ? "small" : "fullscreen",
76
+ headerActions: /* @__PURE__ */ t(p, { variant: "text", onClick: w, children: o }),
77
+ dismissiveButton: /* @__PURE__ */ t(p, { variant: "outlined", onClick: () => f(!1), children: m }),
78
+ primaryButton: /* @__PURE__ */ t(p, { variant: "filled", onClick: B, children: n }),
79
+ children: /* @__PURE__ */ t(v, { direction: "vertical", children: k(a, s, F) })
95
80
  }
96
81
  )
97
- ] });
98
- }, M = ({
99
- filterButtonText: a,
100
- filterButtonAsIcon: m,
101
- count: i,
102
- onClick: r
82
+ ] }) : /* @__PURE__ */ t(v, { secondaryAlign: "center", fullWidth: !0, children: k(a, s, F, !1) });
83
+ }, k = (o, l, r, e = !0) => o.map(({ id: i, title: u, availableOptions: a, icon: m }) => /* @__PURE__ */ y(v, { fullWidth: !0, secondaryAlign: "center", children: [
84
+ m ? /* @__PURE__ */ t(H, { icon: m, iconSize: "medium" }) : null,
85
+ /* @__PURE__ */ t(
86
+ j,
87
+ {
88
+ className: e ? void 0 : d.dense,
89
+ variant: "outlined",
90
+ options: a,
91
+ label: u,
92
+ multiSelect: !0,
93
+ textKey: "text",
94
+ valueKey: "id",
95
+ value: l.find((n) => n.id === i)?.selectedOptions ?? [],
96
+ onChange: (n) => r({ id: i, selectedOptions: n }),
97
+ hoisted: !0,
98
+ menuMaxHeight: "300px",
99
+ disabled: i === "location",
100
+ showOptionFilter: !1,
101
+ dense: !e,
102
+ fixedHeightInput: !e,
103
+ multiDisplayType: e ? "pills" : "text"
104
+ }
105
+ )
106
+ ] }, i)), K = ({
107
+ filterButtonText: o,
108
+ filterButtonAsIcon: l,
109
+ count: r,
110
+ onClick: e
103
111
  }) => {
104
- const { isDesktop: l } = F();
105
- return m ? /* @__PURE__ */ t(
106
- K,
112
+ const { isDesktop: i } = O();
113
+ return l ? /* @__PURE__ */ t(
114
+ z,
107
115
  {
108
116
  icon: "filter_list_alt",
109
- onClick: r,
110
- badge: i !== 0 && /* @__PURE__ */ t(
111
- v,
117
+ onClick: e,
118
+ badge: r !== 0 && /* @__PURE__ */ t(
119
+ S,
112
120
  {
113
- counter: i,
114
- className: f.filterBadge,
121
+ counter: r,
122
+ className: d.filterBadge,
115
123
  themeColor: "secondary",
116
124
  "data-testid": "filter-badge"
117
125
  }
118
126
  )
119
127
  }
120
- ) : /* @__PURE__ */ B("div", { style: { height: "100%", width: l ? void 0 : "100%" }, children: [
128
+ ) : /* @__PURE__ */ y("div", { style: { height: "100%", width: i ? void 0 : "100%" }, children: [
121
129
  /* @__PURE__ */ t(
122
- s,
130
+ p,
123
131
  {
124
132
  variant: "outlined",
125
133
  themeColor: "primary",
126
134
  leadingIcon: "filter_list_alt",
127
- onClick: r,
128
- className: f.filterButton,
129
- fullWidth: !l,
130
- children: a
135
+ onClick: e,
136
+ className: d.filterButton,
137
+ fullWidth: !i,
138
+ children: o
131
139
  }
132
140
  ),
133
- i !== 0 && /* @__PURE__ */ t(
134
- v,
141
+ r !== 0 && /* @__PURE__ */ t(
142
+ S,
135
143
  {
136
- counter: i,
137
- className: f.filterBadge,
144
+ counter: r,
145
+ className: d.filterBadge,
138
146
  themeColor: "secondary",
139
147
  "data-testid": "filter-badge"
140
148
  }
@@ -142,5 +150,5 @@ const ft = ({
142
150
  ] });
143
151
  };
144
152
  export {
145
- ft as Filter
153
+ vt as Filter
146
154
  };
@@ -1,11 +1,11 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { a as r, s as t, f as c, t as u, w as m } from "../../react.esm-Dy4VzU4L.js";
3
- import { a as s } from "../../useBreakpoints-BNeVhjjZ.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { a, s as t, f as u, t as c, w as x } from "../../react.esm-Dy4VzU4L.js";
3
+ import { a as d } from "../../useBreakpoints-BNeVhjjZ.js";
4
4
  import { Filter as T } from "./Filter.js";
5
- import { v as x, b as d, d as f, t as B, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
6
- const o = x.fn();
7
- d(() => {
8
- x.spyOn(s, "useBreakpoints").mockReturnValue({
5
+ import { v as m, b as s, d as f, t as B, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
6
+ const o = m.fn();
7
+ s(() => {
8
+ m.spyOn(d, "useBreakpoints").mockReturnValue({
9
9
  isDesktop: !0,
10
10
  isMobile: !1,
11
11
  isTablet: !1,
@@ -13,10 +13,11 @@ d(() => {
13
13
  });
14
14
  });
15
15
  f("Filter", () => {
16
- const n = [
16
+ const l = [
17
17
  {
18
18
  id: "1",
19
19
  title: "Filter 1",
20
+ icon: "farm",
20
21
  availableOptions: [
21
22
  { id: "1", text: "Option 1" },
22
23
  { id: "2", text: "Option 2" }
@@ -30,17 +31,17 @@ f("Filter", () => {
30
31
  { id: "4", text: "Option 4" }
31
32
  ]
32
33
  }
33
- ], i = [
34
+ ], n = [
34
35
  { id: "1", selectedOptions: [{ id: "1", text: "Option 1" }] },
35
36
  { id: "2", selectedOptions: [{ id: "3", text: "Option 3" }] }
36
37
  ];
37
38
  B("should render filter", () => {
38
- r(
39
- /* @__PURE__ */ a(
39
+ a(
40
+ /* @__PURE__ */ r(
40
41
  T,
41
42
  {
42
- filters: n,
43
- currentFilter: i,
43
+ filters: l,
44
+ currentFilter: n,
44
45
  closeCallback: o,
45
46
  filterButtonText: "filterButtonText",
46
47
  filterModalTitle: "filterModalTitle",
@@ -49,18 +50,18 @@ f("Filter", () => {
49
50
  clearFilterText: "clearFilterText"
50
51
  }
51
52
  )
52
- ), e(t.getByText("filterButtonText")).toBeInTheDocument(), e(t.getByText("filterModalTitle")).toBeInTheDocument(), e(t.getByText("modalCancelButtonText")).toBeInTheDocument(), e(t.getByText("modalConfirmButtonText")).toBeInTheDocument(), e(t.getByText("clearFilterText")).toBeInTheDocument(), e(t.getByText("Filter 1")).toBeInTheDocument(), e(t.getByText("Filter 2")).toBeInTheDocument(), e(t.getByText("Option 1")).toBeInTheDocument(), e(t.getByText("Option 3")).toBeInTheDocument();
53
- const l = t.getByRole("button", { name: "modalConfirmButtonText" });
54
- c.click(l), u.act(() => {
53
+ ), e(t.getByText("filterButtonText")).toBeInTheDocument(), e(t.getByText("filterModalTitle")).toBeInTheDocument(), e(t.getByText("modalCancelButtonText")).toBeInTheDocument(), e(t.getByText("modalConfirmButtonText")).toBeInTheDocument(), e(t.getByText("clearFilterText")).toBeInTheDocument(), e(t.getByText("Filter 1")).toBeInTheDocument(), e(t.getByText("Filter 2")).toBeInTheDocument(), e(t.getByText("Option 1")).toBeInTheDocument(), e(t.getByText("Option 3")).toBeInTheDocument(), e(t.getByTestId("farm")).toBeInTheDocument();
54
+ const i = t.getByRole("button", { name: "modalConfirmButtonText" });
55
+ u.click(i), c.act(() => {
55
56
  e(o).toHaveBeenCalledTimes(1), e(t.getByText("2")).toBeInTheDocument();
56
57
  });
57
58
  }), B("should clear filter", () => {
58
- r(
59
- /* @__PURE__ */ a(
59
+ a(
60
+ /* @__PURE__ */ r(
60
61
  T,
61
62
  {
62
- filters: n,
63
- currentFilter: i,
63
+ filters: l,
64
+ currentFilter: n,
64
65
  closeCallback: o,
65
66
  filterButtonText: "filterButtonText",
66
67
  filterModalTitle: "filterModalTitle",
@@ -70,17 +71,17 @@ f("Filter", () => {
70
71
  }
71
72
  )
72
73
  );
73
- const l = t.getByText("clearFilterText");
74
- c.click(l), u.act(() => {
74
+ const i = t.getByText("clearFilterText");
75
+ u.click(i), c.act(() => {
75
76
  e(o).toHaveBeenCalledTimes(1), e(t.queryByTestId("filter-badge")).not.toBeInTheDocument();
76
77
  });
77
78
  }), B("should close filter", () => {
78
- r(
79
- /* @__PURE__ */ a(
79
+ a(
80
+ /* @__PURE__ */ r(
80
81
  T,
81
82
  {
82
- filters: n,
83
- currentFilter: i,
83
+ filters: l,
84
+ currentFilter: n,
84
85
  closeCallback: o,
85
86
  filterButtonText: "filterButtonText",
86
87
  filterModalTitle: "filterModalTitle",
@@ -90,19 +91,19 @@ f("Filter", () => {
90
91
  }
91
92
  )
92
93
  );
93
- const l = t.getByRole("button", { name: "modalCancelButtonText" });
94
- c.click(l), u.act(() => {
94
+ const i = t.getByRole("button", { name: "modalCancelButtonText" });
95
+ u.click(i), c.act(() => {
95
96
  e(o).toHaveBeenCalledTimes(1), e(t.queryByTestId("filter-badge")).not.toBeInTheDocument();
96
- }), m(() => {
97
+ }), x(() => {
97
98
  e(t.queryByText("filterModalTitle")).not.toBeInTheDocument(), e(t.queryByText("modalCancelButtonText")).not.toBeInTheDocument(), e(t.queryByText("modalConfirmButtonText")).not.toBeInTheDocument(), e(t.queryByText("clearFilterText")).not.toBeInTheDocument();
98
99
  });
99
100
  }), B("should render as icon button ", () => {
100
- r(
101
- /* @__PURE__ */ a(
101
+ a(
102
+ /* @__PURE__ */ r(
102
103
  T,
103
104
  {
104
- filters: n,
105
- currentFilter: i,
105
+ filters: l,
106
+ currentFilter: n,
106
107
  closeCallback: o,
107
108
  filterButtonText: "filterButtonText",
108
109
  filterModalTitle: "filterModalTitle",
@@ -113,5 +114,22 @@ f("Filter", () => {
113
114
  }
114
115
  )
115
116
  ), e(t.queryByText("filterButtonText")).not.toBeInTheDocument(), e(t.getByText("filter_list_alt")).toBeInTheDocument(), e(t.getByText("filter_list_alt").tagName).toBe("I");
117
+ }), B("should render filter without modal", () => {
118
+ a(
119
+ /* @__PURE__ */ r(
120
+ T,
121
+ {
122
+ filters: l,
123
+ currentFilter: n,
124
+ closeCallback: o,
125
+ filterButtonText: "filterButtonText",
126
+ filterModalTitle: "filterModalTitle",
127
+ modalCancelButtonText: "modalCancelButtonText",
128
+ modalConfirmButtonText: "modalConfirmButtonText",
129
+ clearFilterText: "clearFilterText",
130
+ useModal: !1
131
+ }
132
+ )
133
+ ), e(t.queryByText("filterButtonText")).not.toBeInTheDocument(), e(t.queryByText("clearFilterText")).not.toBeInTheDocument(), e(t.queryByText("modalCancelButtonText")).not.toBeInTheDocument(), e(t.queryByText("modalConfirmButtonText")).not.toBeInTheDocument(), e(t.queryByText("clearFilterText")).not.toBeInTheDocument(), e(t.getByTestId("farm")).toBeInTheDocument(), e(t.getByText("Filter 1")).toBeInTheDocument(), e(t.getByText("Filter 2")).toBeInTheDocument(), e(t.getByText("Option 1")).toBeInTheDocument(), e(t.getByText("Option 3")).toBeInTheDocument();
116
134
  });
117
135
  });
@@ -1,7 +1,7 @@
1
1
  import { jsx as r, jsxs as B } from "react/jsx-runtime";
2
2
  import { Elevation as D, Table as G, TableTopBar as u, Group as l, Padding as W, TypoDisplay as k, TypoSubtitle as C } from "@element/react-components";
3
3
  import { Fragment as j } from "react";
4
- import { a as e } from "../../genericTable.module-CXfRg0e4.js";
4
+ import { a as e } from "../../genericTable.module-CNV1Yt1K.js";
5
5
  import { u as x } from "../../useBreakpoints-BNeVhjjZ.js";
6
6
  import "../../alertBanner.module-HneYdVzN.js";
7
7
  import "../../iconify.module-C89oaw5b.js";
@@ -0,0 +1,16 @@
1
+ import "./assets/genericTable.css";
2
+ const t = "_filterButton_1xlao_1", e = "_filterBadge_1xlao_6", o = "_dense_1xlao_12", i = {
3
+ filterButton: t,
4
+ filterBadge: e,
5
+ dense: o
6
+ }, s = "_topBar_1msoo_1", a = "_filterBar_1msoo_5", _ = "_emptyTable_1msoo_9", l = "_elevation_1msoo_17", n = "_table_1msoo_22", B = {
7
+ topBar: s,
8
+ filterBar: a,
9
+ emptyTable: _,
10
+ elevation: l,
11
+ table: n
12
+ };
13
+ export {
14
+ B as a,
15
+ i as s
16
+ };
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./genericTable.module-CXfRg0e4.js";
1
+ import "./genericTable.module-CNV1Yt1K.js";
2
2
  import { AlertBanner as t } from "./components/AlertBanner/AlertBanner.js";
3
3
  import { BaseView as p } from "./components/BaseView/BaseView.js";
4
4
  import { BasicHeading as x } from "./components/BasicHeading/BasicHeading.js";
@@ -7,6 +7,7 @@
7
7
  export type FilterData = {
8
8
  id: string;
9
9
  title: string;
10
+ icon?: string;
10
11
  availableOptions: FilterOption[];
11
12
  };
12
13
  /**
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.7369",
4
+ "version": "0.0.7373",
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>",
@@ -1,15 +0,0 @@
1
- import "./assets/genericTable.css";
2
- const t = "_filterButton_66wbq_1", e = "_filterBadge_66wbq_6", n = {
3
- filterButton: t,
4
- filterBadge: e
5
- }, o = "_topBar_1msoo_1", a = "_filterBar_1msoo_5", s = "_emptyTable_1msoo_9", _ = "_elevation_1msoo_17", l = "_table_1msoo_22", i = {
6
- topBar: o,
7
- filterBar: a,
8
- emptyTable: s,
9
- elevation: _,
10
- table: l
11
- };
12
- export {
13
- i as a,
14
- n as s
15
- };