@hortiview/shared-components 0.0.7501 → 0.0.7520

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.
@@ -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,
63
- value: f,
62
+ ...l,
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
  )
@@ -1,21 +1,24 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { Padding as l, TypoCaption as d, Group as s } from "@element/react-components";
2
+ import { Padding as c, TypoCaption as o, Group as s } from "@element/react-components";
3
3
  import { GenericCard as m } from "./GenericCard.js";
4
- import { s as i } from "../../../genericCard.module-CnQn6tMH.js";
4
+ import { s as t } from "../../../genericCard.module-CnQn6tMH.js";
5
5
  const u = ({
6
6
  columns: n,
7
7
  data: e,
8
- hiddenColumns: a = [],
9
- noContentText: o
10
- }) => e?.length === 0 ? /* @__PURE__ */ r("div", { className: i.emptyContainer, children: /* @__PURE__ */ r(l, { variant: "standard", style: { textAlign: "center" }, className: i.empty, children: /* @__PURE__ */ r(d, { children: o }) }) }) : /* @__PURE__ */ r(s, { fullWidth: !0, direction: "vertical", primaryAlign: "center", secondaryAlign: "center", children: e?.map((t, c) => /* @__PURE__ */ r(
11
- m,
12
- {
13
- item: t,
14
- columns: n,
15
- hiddenColumns: a
16
- },
17
- t.id ?? c
18
- )) });
8
+ hiddenColumns: d = [],
9
+ noContentText: l
10
+ }) => e?.length === 0 ? /* @__PURE__ */ r("div", { className: t.emptyContainer, children: /* @__PURE__ */ r(c, { variant: "standard", style: { textAlign: "center" }, className: t.empty, children: /* @__PURE__ */ r(o, { children: l }) }) }) : (
11
+ // needs the div to surround the Group by an element with display: block to avoid visual errors
12
+ /* @__PURE__ */ r("div", { style: { width: "100%" }, children: /* @__PURE__ */ r(s, { fullWidth: !0, direction: "vertical", primaryAlign: "center", secondaryAlign: "center", children: e?.map((i, a) => /* @__PURE__ */ r(
13
+ m,
14
+ {
15
+ item: i,
16
+ columns: n,
17
+ hiddenColumns: d
18
+ },
19
+ i.id ?? a
20
+ )) }) })
21
+ );
19
22
  export {
20
23
  u as GenericCardList
21
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.7501",
4
+ "version": "0.0.7520",
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>",