@hortiview/shared-components 0.0.7515 → 0.0.7544

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,8 +1,8 @@
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 u, Select as j, IconButton as z, NotificationBadge as N } from "@element/react-components";
3
- import { useState as g } from "react";
4
- import { s as a } from "../../genericTable.module-Dk3yy2S3.js";
5
- import { u as k } from "../../useBreakpoints-BNeVhjjZ.js";
1
+ import { jsx as t, jsxs as B, Fragment as I } from "react/jsx-runtime";
2
+ import { Group as y, Modal as T, Button as h, Select as W, Switch as j, IconButton as z, NotificationBadge as b } from "@element/react-components";
3
+ import { useState as v } from "react";
4
+ import { s as c } from "../../genericTable.module-Dk3yy2S3.js";
5
+ import { u as A } from "../../useBreakpoints-BNeVhjjZ.js";
6
6
  import "../../alertBanner.module-HneYdVzN.js";
7
7
  import { I as H } from "../../Iconify-CY9lZjFd.js";
8
8
  import "../../react-tooltip.min-BzHiZW8k.js";
@@ -11,7 +11,7 @@ import "../../isArray-Ca4KR8TK.js";
11
11
  import "../../_baseToString-BNXOi2Mf.js";
12
12
  import "../../_equalByTag-DJhSpgVG.js";
13
13
  import "../../iconify.module-C89oaw5b.js";
14
- import "../../searchBar.module-9gKyrZRT.js";
14
+ import { SearchBar as K } from "../SearchBar/SearchBar.js";
15
15
  import "../../listArea.module-CGpHPOji.js";
16
16
  import "../../verticalDivider.module-C3_GL-fH.js";
17
17
  import "../../baseView.module-ve87u_d0.js";
@@ -31,123 +31,139 @@ import "react-hook-form";
31
31
  import "../../formDatePicker.module-BV3ma_7y.js";
32
32
  import "../../formSelect.module-C18N-SsT.js";
33
33
  import "../../formText.module-C0by6_DK.js";
34
- const vt = ({
35
- clearFilterText: l,
36
- closeCallback: o,
37
- currentFilter: r,
38
- filterButtonAsIcon: e = !1,
39
- filterButtonText: i,
40
- filterModalTitle: f,
41
- filters: m,
42
- modalCancelButtonText: c,
43
- modalConfirmButtonText: n,
44
- useModal: C = !0
34
+ const Bt = ({
35
+ clearFilterText: m,
36
+ closeCallback: a,
37
+ currentFilter: i,
38
+ filterButtonAsIcon: n = !1,
39
+ filterButtonText: r,
40
+ filterModalTitle: p,
41
+ filters: d,
42
+ modalCancelButtonText: u,
43
+ modalConfirmButtonText: s,
44
+ useModal: e = !0
45
45
  }) => {
46
- const { isDesktop: b } = k(), [A, h] = g(!1), [s, x] = g(r), [_, B] = g(0), F = () => {
47
- h(!1), o(s), B(
48
- s.reduce((p, { selectedOptions: d }) => p + d.length, 0)
46
+ const { isDesktop: N } = A(), [w, g] = v(!1), [f, C] = v(i), [O, x] = v(0), S = () => {
47
+ g(!1), a(f), x(
48
+ f.reduce((l, { filterValue: o }) => o === void 0 ? l : typeof o == "boolean" ? o ? l + 1 : l : Array.isArray(o) ? l + o.length : typeof o == "string" && o.length ? l + 1 : l, 0)
49
49
  );
50
- }, w = () => {
51
- x([]), B(0);
52
- }, S = (p) => {
53
- const d = [
54
- ...s.filter((D) => D.id !== p.id),
55
- p
50
+ }, _ = () => {
51
+ C([]), x(0);
52
+ }, F = (l) => {
53
+ const o = [
54
+ ...f.filter((D) => D.id !== l.id),
55
+ l
56
56
  ];
57
- x(d), C || o(d);
57
+ C(o), e || a(o);
58
58
  };
59
- return C ? /* @__PURE__ */ y(I, { children: [
59
+ return e ? /* @__PURE__ */ B(I, { children: [
60
60
  /* @__PURE__ */ t(
61
- K,
61
+ G,
62
62
  {
63
- filterButtonText: i,
64
- filterButtonAsIcon: e,
65
- count: _,
66
- onClick: () => h(!0)
63
+ filterButtonText: r,
64
+ filterButtonAsIcon: n,
65
+ count: O,
66
+ onClick: () => g(!0)
67
67
  }
68
68
  ),
69
69
  /* @__PURE__ */ t(
70
- W,
70
+ T,
71
71
  {
72
- open: A,
73
- onClose: F,
74
- title: f,
75
- modalSize: b ? "small" : "fullscreen",
76
- headerActions: /* @__PURE__ */ t(u, { variant: "text", onClick: w, children: l }),
77
- dismissiveButton: /* @__PURE__ */ t(u, { variant: "outlined", onClick: () => h(!1), children: c }),
78
- primaryButton: /* @__PURE__ */ t(u, { variant: "filled", onClick: F, children: n }),
79
- children: /* @__PURE__ */ t(v, { direction: "vertical", children: O(m, s, S) })
72
+ open: w,
73
+ onClose: S,
74
+ title: p,
75
+ modalSize: N ? "small" : "fullscreen",
76
+ headerActions: /* @__PURE__ */ t(h, { variant: "text", onClick: _, children: m }),
77
+ dismissiveButton: /* @__PURE__ */ t(h, { variant: "outlined", onClick: () => g(!1), children: u }),
78
+ primaryButton: /* @__PURE__ */ t(h, { variant: "filled", onClick: S, children: s }),
79
+ children: /* @__PURE__ */ t(y, { direction: "vertical", children: k(d, f, F) })
80
80
  }
81
81
  )
82
- ] }) : /* @__PURE__ */ t(v, { secondaryAlign: "center", fullWidth: !0, children: O(m, s, S, !1) });
83
- }, O = (l, o, r, e = !0) => l.map(({ id: i, title: f, availableOptions: m, icon: c }) => /* @__PURE__ */ y(v, { fullWidth: !0, secondaryAlign: "center", children: [
84
- c ? /* @__PURE__ */ t(H, { icon: c, iconSize: "medium" }) : null,
85
- /* @__PURE__ */ t(
86
- j,
82
+ ] }) : /* @__PURE__ */ t(y, { secondaryAlign: "center", fullWidth: !0, children: k(d, f, F, !1) });
83
+ }, k = (m, a, i, n = !0) => m.map(({ id: r, title: p, availableOptions: d, icon: u, type: s }) => /* @__PURE__ */ B(y, { fullWidth: !0, secondaryAlign: "center", children: [
84
+ u ? /* @__PURE__ */ t(H, { icon: u, iconSize: "medium" }) : null,
85
+ s === "select" && /* @__PURE__ */ t(
86
+ W,
87
87
  {
88
- className: e ? void 0 : a.dense,
88
+ className: n ? void 0 : c.dense,
89
89
  variant: "outlined",
90
- options: m,
91
- label: f,
90
+ options: d,
91
+ label: p,
92
92
  multiSelect: !0,
93
93
  textKey: "text",
94
94
  valueKey: "id",
95
- value: o.find((n) => n.id === i)?.selectedOptions ?? [],
96
- onChange: (n) => r({ id: i, selectedOptions: n }),
95
+ value: a.find((e) => e.id === r)?.filterValue ?? [],
96
+ onChange: (e) => i({ id: r, type: s, filterValue: e }),
97
97
  hoisted: !0,
98
98
  menuMaxHeight: "300px",
99
- disabled: i === "location",
99
+ disabled: r === "location",
100
100
  showOptionFilter: !1,
101
- dense: !e,
102
- fixedHeightInput: !e,
103
- multiDisplayType: e ? "pills" : "text"
101
+ dense: !n,
102
+ fixedHeightInput: !n,
103
+ multiDisplayType: n ? "pills" : "text"
104
+ }
105
+ ),
106
+ s === "toggle" && /* @__PURE__ */ t(
107
+ j,
108
+ {
109
+ label: p,
110
+ onChange: (e) => i({ id: r, type: s, filterValue: e }),
111
+ checked: !!a.find((e) => e.id === r)?.filterValue
112
+ }
113
+ ),
114
+ s === "search" && /* @__PURE__ */ t(
115
+ K,
116
+ {
117
+ placeholder: p,
118
+ searchTerm: a.find((e) => e.id === r)?.filterValue,
119
+ setSearchTerm: (e) => i({ id: r, type: s, filterValue: e })
104
120
  }
105
121
  )
106
- ] }, i)), K = ({
107
- filterButtonText: l,
108
- filterButtonAsIcon: o,
109
- count: r,
110
- onClick: e
122
+ ] }, r)), G = ({
123
+ filterButtonText: m,
124
+ filterButtonAsIcon: a,
125
+ count: i,
126
+ onClick: n
111
127
  }) => {
112
- const { isDesktop: i } = k();
113
- return o ? /* @__PURE__ */ t(
128
+ const { isDesktop: r } = A();
129
+ return a ? /* @__PURE__ */ t(
114
130
  z,
115
131
  {
116
132
  icon: "filter_list_alt",
117
- onClick: e,
118
- badge: r !== 0 && /* @__PURE__ */ t(
119
- N,
133
+ onClick: n,
134
+ badge: i !== 0 && /* @__PURE__ */ t(
135
+ b,
120
136
  {
121
- counter: r,
122
- className: a.filterBadge,
137
+ counter: i,
138
+ className: c.filterBadge,
123
139
  themeColor: "secondary",
124
140
  "data-testid": "filter-badge"
125
141
  }
126
142
  )
127
143
  }
128
- ) : /* @__PURE__ */ y(
144
+ ) : /* @__PURE__ */ B(
129
145
  "div",
130
146
  {
131
- className: a.relativeParent,
132
- style: { height: "100%", width: i ? void 0 : "100%" },
147
+ className: c.relativeParent,
148
+ style: { height: "100%", width: r ? void 0 : "100%" },
133
149
  children: [
134
150
  /* @__PURE__ */ t(
135
- u,
151
+ h,
136
152
  {
137
153
  variant: "outlined",
138
154
  themeColor: "primary",
139
155
  leadingIcon: "filter_list_alt",
140
- onClick: e,
141
- className: a.filterButton,
142
- fullWidth: !i,
143
- children: l
156
+ onClick: n,
157
+ className: c.filterButton,
158
+ fullWidth: !r,
159
+ children: m
144
160
  }
145
161
  ),
146
- r !== 0 && /* @__PURE__ */ t(
147
- N,
162
+ i !== 0 && /* @__PURE__ */ t(
163
+ b,
148
164
  {
149
- counter: r,
150
- className: a.filterBadge,
165
+ counter: i,
166
+ className: c.filterBadge,
151
167
  themeColor: "secondary",
152
168
  "data-testid": "filter-badge"
153
169
  }
@@ -157,5 +173,5 @@ const vt = ({
157
173
  );
158
174
  };
159
175
  export {
160
- vt as Filter
176
+ Bt as Filter
161
177
  };
@@ -1,22 +1,23 @@
1
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";
2
+ import { a, s as t, f as c, t as u, w as d } from "../../react.esm-Dy4VzU4L.js";
3
+ import { a as s } from "../../useBreakpoints-BNeVhjjZ.js";
4
4
  import { Filter as T } from "./Filter.js";
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({
5
+ import { v as x, b as f, d as y, t as B, g as e } from "../../vi.JYQecGiw-BbUbJcT8.js";
6
+ const o = x.fn();
7
+ f(() => {
8
+ x.spyOn(s, "useBreakpoints").mockReturnValue({
9
9
  isDesktop: !0,
10
10
  isMobile: !1,
11
11
  isTablet: !1,
12
12
  isDesktopNavbar: !1
13
13
  });
14
14
  });
15
- f("Filter", () => {
15
+ y("Filter", () => {
16
16
  const l = [
17
17
  {
18
18
  id: "1",
19
19
  title: "Filter 1",
20
+ type: "select",
20
21
  icon: "farm",
21
22
  availableOptions: [
22
23
  { id: "1", text: "Option 1" },
@@ -26,14 +27,25 @@ f("Filter", () => {
26
27
  {
27
28
  id: "2",
28
29
  title: "Filter 2",
30
+ type: "select",
29
31
  availableOptions: [
30
32
  { id: "3", text: "Option 3" },
31
33
  { id: "4", text: "Option 4" }
32
34
  ]
35
+ },
36
+ {
37
+ id: "3",
38
+ title: "Filter Toggle",
39
+ type: "toggle"
40
+ },
41
+ {
42
+ id: "4",
43
+ title: "Filter Search",
44
+ type: "search"
33
45
  }
34
46
  ], n = [
35
- { id: "1", selectedOptions: [{ id: "1", text: "Option 1" }] },
36
- { id: "2", selectedOptions: [{ id: "3", text: "Option 3" }] }
47
+ { id: "1", filterValue: [{ id: "1", text: "Option 1" }], type: "select" },
48
+ { id: "2", filterValue: [{ id: "3", text: "Option 3" }], type: "select" }
37
49
  ];
38
50
  B("should render filter", () => {
39
51
  a(
@@ -50,9 +62,11 @@ f("Filter", () => {
50
62
  clearFilterText: "clearFilterText"
51
63
  }
52
64
  )
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(() => {
65
+ ), 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(), e(t.getByText("Filter Toggle")).toBeInTheDocument();
66
+ const i = t.getByRole("textbox");
67
+ e(i.getAttribute("placeholder")).toBe("Filter Search");
68
+ const m = t.getByRole("button", { name: "modalConfirmButtonText" });
69
+ c.click(m), u.act(() => {
56
70
  e(o).toHaveBeenCalledTimes(1), e(t.getByText("2")).toBeInTheDocument();
57
71
  });
58
72
  }), B("should clear filter", () => {
@@ -72,7 +86,7 @@ f("Filter", () => {
72
86
  )
73
87
  );
74
88
  const i = t.getByText("clearFilterText");
75
- u.click(i), c.act(() => {
89
+ c.click(i), u.act(() => {
76
90
  e(o).toHaveBeenCalledTimes(1), e(t.queryByTestId("filter-badge")).not.toBeInTheDocument();
77
91
  });
78
92
  }), B("should close filter", () => {
@@ -92,9 +106,9 @@ f("Filter", () => {
92
106
  )
93
107
  );
94
108
  const i = t.getByRole("button", { name: "modalCancelButtonText" });
95
- u.click(i), c.act(() => {
109
+ c.click(i), u.act(() => {
96
110
  e(o).toHaveBeenCalledTimes(1), e(t.queryByTestId("filter-badge")).not.toBeInTheDocument();
97
- }), x(() => {
111
+ }), d(() => {
98
112
  e(t.queryByText("filterModalTitle")).not.toBeInTheDocument(), e(t.queryByText("modalCancelButtonText")).not.toBeInTheDocument(), e(t.queryByText("modalConfirmButtonText")).not.toBeInTheDocument(), e(t.queryByText("clearFilterText")).not.toBeInTheDocument();
99
113
  });
100
114
  }), B("should render as icon button ", () => {
@@ -4,7 +4,7 @@ import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
4
4
  /**
5
5
  * a generic FormSelector property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
6
6
  */
7
- type FormSelectProps<T extends FieldValues> = Omit<SelectProps, 'className' | 'clearable' | 'disabled' | 'helperText' | 'helperTextPersistent' | 'hidden' | 'hoisted' | 'label' | 'menuMaxHeight' | 'multi' | 'multiSelect' | 'noOptionsMessage' | 'onChange' | 'options' | 'searchable' | 'textKey' | 'valid' | 'value' | 'valueKey' | 'variant'> & {
7
+ type FormSelectProps<T extends FieldValues> = Omit<SelectProps, 'className' | 'clearable' | 'disabled' | 'helperText' | 'helperTextPersistent' | 'hidden' | 'hoisted' | 'label' | 'menuMaxHeight' | 'multi' | 'multiSelect' | 'noOptionsMessage' | 'options' | 'searchable' | 'textKey' | 'valid' | 'value' | 'valueKey' | 'variant'> & {
8
8
  /** the name of the property in the form */
9
9
  propertyName: Path<T>;
10
10
  /** the label of the select */
@@ -3,25 +3,25 @@ import { Select as k } from "@element/react-components";
3
3
  import { g as h } from "../../../get-UxX31Aph.js";
4
4
  import { i as z } from "../../../isArray-Ca4KR8TK.js";
5
5
  import { useMemo as S } from "react";
6
- import { useFormContext as B, Controller as v } from "react-hook-form";
6
+ import { useFormContext as B, Controller as C } from "react-hook-form";
7
7
  import { H as G } from "../../../react-tooltip.min-BzHiZW8k.js";
8
8
  import { SelectTooltipText as J } from "./SelectTooltipText.js";
9
- import { s as l } from "../../../formSelect.module-C18N-SsT.js";
9
+ import { s as a } from "../../../formSelect.module-C18N-SsT.js";
10
10
  const N = ({
11
11
  propertyName: r,
12
12
  label: d,
13
- options: o,
14
- multi: a = !1,
13
+ options: n,
14
+ multi: m = !1,
15
15
  disabled: F = !1,
16
16
  hoisted: I = !1,
17
17
  hidden: $ = !1,
18
18
  valueKey: i = "value",
19
19
  textKey: T = "text",
20
20
  clearable: j = !1,
21
- searchable: w = !0,
22
- noOptionsMessage: A = "",
23
- rules: n,
24
- ...m
21
+ searchable: v = !0,
22
+ noOptionsMessage: w = "",
23
+ rules: o,
24
+ ...l
25
25
  }) => {
26
26
  const {
27
27
  control: p,
@@ -29,12 +29,12 @@ const N = ({
29
29
  } = B(), c = S(
30
30
  () => !H && h(s, r) !== void 0,
31
31
  [s, r, H]
32
- ), C = S(
33
- () => n?.required?.value,
34
- [n]
32
+ ), A = S(
33
+ () => o?.required?.value,
34
+ [o]
35
35
  ), D = S(
36
- () => n?.required?.message,
37
- [n]
36
+ () => o?.required?.message,
37
+ [o]
38
38
  ), E = () => {
39
39
  if (s && s[r]) {
40
40
  const u = s[r]?.message;
@@ -42,33 +42,33 @@ const N = ({
42
42
  }
43
43
  return D;
44
44
  };
45
- return $ ? /* @__PURE__ */ e(v, { name: r, control: p, render: () => /* @__PURE__ */ e(M, {}) }) : /* @__PURE__ */ e("div", { className: l.formSelectContainer, "data-tooltip-id": d, children: /* @__PURE__ */ e(
46
- v,
45
+ return $ ? /* @__PURE__ */ e(C, { name: r, control: p, render: () => /* @__PURE__ */ e(M, {}) }) : /* @__PURE__ */ e("div", { className: a.formSelectContainer, "data-tooltip-id": d, children: /* @__PURE__ */ e(
46
+ C,
47
47
  {
48
48
  name: r,
49
- rules: n,
49
+ rules: o,
50
50
  control: p,
51
51
  render: ({ field: { ref: u, onChange: x, value: q, ...O } }) => {
52
- let g = o;
53
- z(o) && h(o[0], "options") !== void 0 && (g = o.flatMap((t) => h(t, "options") ?? []));
54
- const f = a ? g?.filter(
52
+ let g = n;
53
+ z(n) && h(n[0], "options") !== void 0 && (g = n.flatMap((t) => h(t, "options") ?? []));
54
+ const f = m ? g?.filter(
55
55
  (t) => q?.includes(t[i])
56
- ) : g?.find((t) => t[i] === q), P = a && m.multiDisplayType === "text" && m.fixedHeightInput;
56
+ ) : g?.find((t) => t[i] === q), P = m && l.multiDisplayType === "text" && l.fixedHeightInput;
57
57
  return /* @__PURE__ */ b(M, { children: [
58
58
  /* @__PURE__ */ e(
59
59
  k,
60
60
  {
61
61
  ...O,
62
- ...m,
62
+ ...l,
63
63
  value: f ?? [],
64
64
  label: d,
65
65
  variant: "outlined",
66
66
  helperText: E(),
67
- helperTextPersistent: C || c,
68
- options: o,
67
+ helperTextPersistent: A || c,
68
+ options: n,
69
69
  valid: !c,
70
- multiSelect: a,
71
- className: `${l.formSelect} ${c ? l.invalid : ""} ${P ? l.multiText : ""}`,
70
+ multiSelect: m,
71
+ className: `${a.formSelect} ${c ? a.invalid : ""} ${P ? a.multiText : ""}`,
72
72
  disabled: F,
73
73
  valueKey: i,
74
74
  textKey: T,
@@ -77,15 +77,15 @@ const N = ({
77
77
  x(t);
78
78
  return;
79
79
  }
80
- if (a) {
80
+ if (m) {
81
81
  x(t.map((V) => V[i]));
82
82
  return;
83
83
  }
84
- x(t[i]);
84
+ x(t[i]), l?.onChange?.(t);
85
85
  },
86
86
  hoisted: I,
87
- noOptionsMessage: A,
88
- searchable: w,
87
+ noOptionsMessage: w,
88
+ searchable: v,
89
89
  clearable: j,
90
90
  menuMaxHeight: "15rem"
91
91
  }
@@ -97,8 +97,8 @@ const N = ({
97
97
  noArrow: !0,
98
98
  place: "bottom",
99
99
  delayShow: 420,
100
- className: l.tooltip,
101
- hidden: !f || f.length === 0 || !m.fixedHeightInput,
100
+ className: a.tooltip,
101
+ hidden: !f || f.length === 0 || !l.fixedHeightInput,
102
102
  children: /* @__PURE__ */ e(J, { value: f, textKey: T, valueKey: i })
103
103
  }
104
104
  )
@@ -80,7 +80,7 @@ const dr = ({
80
80
  {
81
81
  className: e.filterBar,
82
82
  fullWidth: !0,
83
- primaryAlign: "center",
83
+ primaryAlign: "end",
84
84
  secondaryAlign: "center",
85
85
  children: i.map((d, N) => /* @__PURE__ */ r(j, { children: d }, `action_${N}_${d.key}`))
86
86
  }
@@ -1,15 +1,28 @@
1
+ type FilterDataCommon = {
2
+ id: string;
3
+ title: string;
4
+ icon?: string;
5
+ };
6
+ type FilterDataType = {
7
+ type: 'select';
8
+ /**
9
+ * Available options for the filter
10
+ */
11
+ availableOptions: FilterOption[];
12
+ } | {
13
+ type: 'toggle';
14
+ availableOptions?: never;
15
+ } | {
16
+ type: 'search';
17
+ availableOptions?: never;
18
+ };
1
19
  /**
2
20
  * Filter data type
3
21
  * @param id - filter id (unique)
4
22
  * @param title - filter title
5
23
  * @param availableOptions - available options for the filter
6
24
  */
7
- export type FilterData = {
8
- id: string;
9
- title: string;
10
- icon?: string;
11
- availableOptions: FilterOption[];
12
- };
25
+ export type FilterData = FilterDataCommon & FilterDataType;
13
26
  /**
14
27
  * Filter option data type
15
28
  * @param id - option id (unique)
@@ -21,12 +34,23 @@ export type FilterOption = {
21
34
  text: string;
22
35
  icon?: string;
23
36
  };
37
+ type FilterSelectionCommon = {
38
+ id: string;
39
+ };
40
+ type FilterSelectionType = {
41
+ type: 'select';
42
+ filterValue: FilterOption[];
43
+ } | {
44
+ type: 'toggle';
45
+ filterValue: boolean;
46
+ } | {
47
+ type: 'search';
48
+ filterValue: string | undefined;
49
+ };
24
50
  /**
25
51
  * Filter selection data type
26
52
  * @param id - filter id (unique)
27
53
  * @param selectedOptions - selected options of the filter (multiple)
28
54
  */
29
- export type FilterSelection = {
30
- id: string;
31
- selectedOptions: FilterOption[];
32
- };
55
+ export type FilterSelection = FilterSelectionCommon & FilterSelectionType;
56
+ export {};
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.7515",
4
+ "version": "0.0.7544",
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>",