@hortiview/shared-components 0.0.9195 → 0.0.9233

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,4 +1,4 @@
1
- import { jsx as e, Fragment as $, jsxs as b } from "react/jsx-runtime";
1
+ import { jsx as r, Fragment as M, jsxs as b } from "react/jsx-runtime";
2
2
  import { Select as k } from "@element/react-components";
3
3
  import { g as h } from "../../../get-DAwLfiRB.js";
4
4
  import { i as z } from "../../../isArray-thIeLpc5.js";
@@ -8,104 +8,113 @@ import { H as G } from "../../../react-tooltip.min-BzHiZW8k.js";
8
8
  import { SelectTooltipText as J } from "./SelectTooltipText.js";
9
9
  import { s as n } from "../../../formSelect.module-DMHh1bp8.js";
10
10
  const N = ({
11
- propertyName: r,
12
- label: d,
11
+ propertyName: e,
12
+ label: f,
13
13
  options: o,
14
- multi: m = !1,
14
+ multi: d = !1,
15
15
  disabled: T = !1,
16
16
  hoisted: F = !1,
17
17
  hidden: I = !1,
18
18
  valueKey: i = "value",
19
- textKey: p = "text",
19
+ textKey: H = "text",
20
20
  clearable: j = !1,
21
21
  searchable: v = !0,
22
22
  noOptionsMessage: w = "",
23
- rules: l,
24
- ...s
23
+ rules: s,
24
+ ...l
25
25
  }) => {
26
26
  const {
27
- control: H,
28
- formState: { errors: a, isValidating: q }
27
+ control: $,
28
+ formState: { errors: a, isValidating: p }
29
29
  } = B(), c = S(
30
- () => !q && h(a, r) !== void 0,
31
- [a, r, q]
30
+ () => !p && h(a, e) !== void 0,
31
+ [a, e, p]
32
32
  ), A = S(
33
- () => l?.required?.value,
34
- [l]
33
+ () => s?.required?.value,
34
+ [s]
35
35
  ), D = S(
36
- () => l?.required?.message,
37
- [l]
36
+ () => s?.required?.message,
37
+ [s]
38
38
  ), E = () => {
39
- if (a && a[r]) {
40
- const u = a[r]?.message;
39
+ if (a && a[e]) {
40
+ const u = a[e]?.message;
41
41
  return u || "Invalid input";
42
42
  }
43
43
  return D;
44
44
  };
45
- return I ? /* @__PURE__ */ e(C, { name: r, control: H, render: () => /* @__PURE__ */ e($, {}) }) : /* @__PURE__ */ e("div", { className: n.formSelectContainer, "data-tooltip-id": d, children: /* @__PURE__ */ e(
46
- C,
45
+ return I ? /* @__PURE__ */ r(C, { name: e, control: $, render: () => /* @__PURE__ */ r(M, {}) }) : /* @__PURE__ */ r(
46
+ "div",
47
47
  {
48
- name: r,
49
- rules: l,
50
- control: H,
51
- render: ({ field: { ref: u, onChange: x, value: M, ...O } }) => {
52
- let g = o;
53
- z(o) && h(o[0], "options") !== void 0 && (g = o.flatMap((t) => h(t, "options") ?? []));
54
- const f = m ? g?.filter(
55
- (t) => M?.includes(t[i])
56
- ) : g?.find((t) => t[i] === M), P = m && s.multiDisplayType === "text" && s.fixedHeightInput;
57
- return /* @__PURE__ */ b($, { children: [
58
- /* @__PURE__ */ e(
59
- k,
60
- {
61
- ...O,
62
- ...s,
63
- value: f ?? [],
64
- label: d,
65
- variant: "outlined",
66
- helperText: E(),
67
- helperTextPersistent: A || c,
68
- options: o,
69
- valid: !c,
70
- multiSelect: m,
71
- className: `${n.formSelect} ${c ? n.invalid : ""} ${P ? n.multiText : ""} ${T ? n.disabled : ""}`,
72
- disabled: T,
73
- valueKey: i,
74
- textKey: p,
75
- onChange: (t) => {
76
- if (t == null) {
77
- x(t);
78
- return;
48
+ "data-testid": "form-select-container",
49
+ className: n.formSelectContainer,
50
+ "data-tooltip-id": f,
51
+ children: /* @__PURE__ */ r(
52
+ C,
53
+ {
54
+ name: e,
55
+ rules: s,
56
+ control: $,
57
+ render: ({ field: { ref: u, onChange: x, value: q, ...O } }) => {
58
+ let g = o;
59
+ z(o) && h(o[0], "options") !== void 0 && (g = o.flatMap((t) => h(t, "options") ?? []));
60
+ const m = d ? g?.filter(
61
+ (t) => q?.includes(t[i])
62
+ ) : g?.find((t) => t[i] === q), P = d && l.multiDisplayType === "text" && l.fixedHeightInput;
63
+ return /* @__PURE__ */ b(M, { children: [
64
+ /* @__PURE__ */ r(
65
+ k,
66
+ {
67
+ ...O,
68
+ ...l,
69
+ value: m ?? [],
70
+ label: f,
71
+ variant: "outlined",
72
+ helperText: E(),
73
+ helperTextPersistent: A || c,
74
+ options: o,
75
+ valid: !c,
76
+ "data-testid": `select-${e}`,
77
+ multiSelect: d,
78
+ className: `${n.formSelect} ${c ? n.invalid : ""} ${P ? n.multiText : ""} ${T ? n.disabled : ""}`,
79
+ disabled: T,
80
+ valueKey: i,
81
+ textKey: H,
82
+ onChange: (t) => {
83
+ if (t == null) {
84
+ x(t);
85
+ return;
86
+ }
87
+ if (d) {
88
+ x(t.map((V) => V[i]));
89
+ return;
90
+ }
91
+ x(t[i]), l?.onChange?.(t);
92
+ },
93
+ hoisted: F,
94
+ noOptionsMessage: w,
95
+ searchable: v,
96
+ clearable: j,
97
+ menuMaxHeight: "15rem"
79
98
  }
80
- if (m) {
81
- x(t.map((V) => V[i]));
82
- return;
99
+ ),
100
+ /* @__PURE__ */ r(
101
+ G,
102
+ {
103
+ id: f,
104
+ noArrow: !0,
105
+ place: "bottom",
106
+ delayShow: 420,
107
+ className: n.tooltip,
108
+ hidden: !m || m.length === 0 || !l.fixedHeightInput,
109
+ children: /* @__PURE__ */ r(J, { value: m, textKey: H, valueKey: i })
83
110
  }
84
- x(t[i]), s?.onChange?.(t);
85
- },
86
- hoisted: F,
87
- noOptionsMessage: w,
88
- searchable: v,
89
- clearable: j,
90
- menuMaxHeight: "15rem"
91
- }
92
- ),
93
- /* @__PURE__ */ e(
94
- G,
95
- {
96
- id: d,
97
- noArrow: !0,
98
- place: "bottom",
99
- delayShow: 420,
100
- className: n.tooltip,
101
- hidden: !f || f.length === 0 || !s.fixedHeightInput,
102
- children: /* @__PURE__ */ e(J, { value: f, textKey: p, valueKey: i })
103
- }
104
- )
105
- ] });
106
- }
111
+ )
112
+ ] });
113
+ }
114
+ }
115
+ )
107
116
  }
108
- ) });
117
+ );
109
118
  };
110
119
  export {
111
120
  N as FormSelect
@@ -1,29 +1,30 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import { Slider as s } from "@element/react-components";
3
- import { useFormContext as u, Controller as x } from "react-hook-form";
2
+ import { Slider as d } from "@element/react-components";
3
+ import { useFormContext as p, Controller as u } from "react-hook-form";
4
4
  const f = ({
5
- propertyName: n,
6
- label: e,
7
- minValue: t,
5
+ propertyName: e,
6
+ label: t,
7
+ minValue: n,
8
8
  maxValue: m,
9
9
  step: a,
10
10
  disabled: i
11
11
  }) => {
12
- const { control: l } = u();
12
+ const { control: l } = p();
13
13
  return /* @__PURE__ */ o(
14
- x,
14
+ u,
15
15
  {
16
- name: n,
16
+ name: e,
17
17
  control: l,
18
18
  render: ({ field: r }) => /* @__PURE__ */ o(
19
- s,
19
+ d,
20
20
  {
21
+ "data-testid": "slider",
21
22
  ...r,
22
- onChange: (p) => {
23
- r.onChange(p.value);
23
+ onChange: (s) => {
24
+ r.onChange(s.value);
24
25
  },
25
- label: e,
26
- min: t,
26
+ label: t,
27
+ min: n,
27
28
  max: m,
28
29
  step: a,
29
30
  disabled: i
@@ -6,53 +6,55 @@ import { useFormContext as X, Controller as j } from "react-hook-form";
6
6
  import { s as i } from "../../../formText.module-C0by6_DK.js";
7
7
  const Y = ({
8
8
  count: e,
9
- maxCount: d,
10
- invalid: m = !1,
9
+ maxCount: u,
10
+ invalid: f = !1,
11
11
  hasRequiredText: r = !1
12
12
  }) => /* @__PURE__ */ t(
13
13
  "div",
14
14
  {
15
- className: `${i.formTextAreaHelperText} ${m ? i.invalid : ""} ${r ? i.required : ""}`,
16
- children: /* @__PURE__ */ t(O, { children: `${e}/${d}` })
15
+ "data-testid": "character-counter-container",
16
+ className: `${i.formTextAreaHelperText} ${f ? i.invalid : ""} ${r ? i.required : ""}`,
17
+ children: /* @__PURE__ */ t(O, { children: `${e}/${u}` })
17
18
  }
18
- ), re = (e) => e.textarea ? /* @__PURE__ */ t(Z, { ...e }) : /* @__PURE__ */ t(_, { ...e }), Z = (e) => /* @__PURE__ */ t("div", { className: i.formTextArea, children: /* @__PURE__ */ t(k, { ...e }) }), _ = (e) => /* @__PURE__ */ t(
19
+ ), re = (e) => e.textarea ? /* @__PURE__ */ t(Z, { ...e }) : /* @__PURE__ */ t(_, { ...e }), Z = (e) => /* @__PURE__ */ t("div", { "data-testid": "form-text-area", className: i.formTextArea, children: /* @__PURE__ */ t(k, { ...e }) }), _ = (e) => /* @__PURE__ */ t(
19
20
  "div",
20
21
  {
22
+ "data-testid": "form-text-field",
21
23
  className: `${e.hasCharacterCount ? i.characterCount : i.withoutCharacterCount}`,
22
24
  children: /* @__PURE__ */ t(k, { ...e })
23
25
  }
24
26
  ), k = ({
25
27
  propertyName: e,
26
- label: d,
27
- disabled: m = !1,
28
+ label: u,
29
+ disabled: f = !1,
28
30
  textarea: r = !1,
29
- hasCharacterCount: u = !1,
31
+ hasCharacterCount: d = !1,
30
32
  hidden: H = !1,
31
33
  placeholder: R,
32
34
  type: b,
33
35
  prefixText: w,
34
36
  inputMode: z,
35
37
  trailingIcon: E,
36
- trigger: v = "likeForm",
38
+ trigger: h = "likeForm",
37
39
  rules: n,
38
- ...x
40
+ ...v
39
41
  }) => {
40
42
  const {
41
43
  control: T,
42
- getFieldState: f,
44
+ getFieldState: m,
43
45
  formState: { errors: C },
44
- trigger: F
45
- } = X(), [I, g] = A(0), [o, M] = A(), h = Q(
46
+ trigger: $
47
+ } = X(), [I, x] = A(0), [o, M] = A(), g = Q(
46
48
  (l) => {
47
49
  if (o != null) {
48
- g(o.length);
50
+ x(o.length);
49
51
  return;
50
52
  }
51
53
  if (l) {
52
- g(l.length);
54
+ x(l.length);
53
55
  return;
54
56
  }
55
- g(0);
57
+ x(0);
56
58
  },
57
59
  [o]
58
60
  ), P = () => {
@@ -61,7 +63,7 @@ const Y = ({
61
63
  const s = l.message;
62
64
  return s || "Invalid input";
63
65
  }
64
- return $;
66
+ return F;
65
67
  }, a = c(
66
68
  () => n?.maxLength?.value,
67
69
  [n]
@@ -71,13 +73,13 @@ const Y = ({
71
73
  ), W = c(
72
74
  () => n?.required?.value,
73
75
  [n]
74
- ), $ = c(
76
+ ), F = c(
75
77
  () => n?.required?.message,
76
78
  [n]
77
79
  );
78
80
  return U(() => {
79
- (r || u) && a !== void 0 && o != null && h();
80
- }, [o, r, u, a, h]), H ? /* @__PURE__ */ t(j, { name: e, control: T, render: () => /* @__PURE__ */ t(S, {}) }) : /* @__PURE__ */ t(
81
+ (r || d) && a !== void 0 && o != null && g();
82
+ }, [o, r, d, a, g]), H ? /* @__PURE__ */ t(j, { name: e, control: T, render: () => /* @__PURE__ */ t(S, {}) }) : /* @__PURE__ */ t(
81
83
  j,
82
84
  {
83
85
  name: e,
@@ -85,47 +87,48 @@ const Y = ({
85
87
  control: T,
86
88
  render: ({ field: { ref: l, ...s }, formState: { defaultValues: D } }) => {
87
89
  const q = B(D, e);
88
- return !o && q && (u || r) && h(q), /* @__PURE__ */ J(S, { children: [
90
+ return !o && q && (d || r) && g(q), /* @__PURE__ */ J(S, { children: [
89
91
  /* @__PURE__ */ t(
90
92
  K,
91
93
  {
92
- ...x,
94
+ ...v,
93
95
  ...s,
94
96
  value: s.value ?? "",
95
97
  type: b,
96
98
  fullWidth: !0,
99
+ "data-testid": `textfield-${e}`,
97
100
  inputMode: z,
98
101
  placeholder: R,
99
102
  prefixText: w,
100
- disabled: m,
103
+ disabled: f,
101
104
  helperText: P(),
102
- helperTextPersistent: C !== void 0 || W || a !== void 0 && (r || u),
103
- label: d,
105
+ helperTextPersistent: C !== void 0 || W || a !== void 0 && (r || d),
106
+ label: u,
104
107
  variant: "outlined",
105
108
  maxlength: a,
106
109
  minLength: V,
107
110
  textarea: r,
108
111
  noResize: !1,
109
112
  onBlur: () => {
110
- v === "onBlur" && F(e), x.onBlur?.();
113
+ h === "onBlur" && $(e), v.onBlur?.();
111
114
  },
112
115
  onChange: (L) => {
113
116
  s.onChange(L);
114
117
  const G = L?.target?.value;
115
- M(G), v === "onChange" && F(e);
118
+ M(G), h === "onChange" && $(e);
116
119
  },
117
- valid: !f(e).invalid,
118
- className: `${i.formText} ${f(e).invalid ? i.invalid : ""}`,
120
+ valid: !m(e).invalid,
121
+ className: `${i.formText} ${m(e).invalid ? i.invalid : ""}`,
119
122
  trailingIcon: E
120
123
  }
121
124
  ),
122
- a !== void 0 && (u || r) && /* @__PURE__ */ t(
125
+ a !== void 0 && (d || r) && /* @__PURE__ */ t(
123
126
  Y,
124
127
  {
125
128
  count: I,
126
129
  maxCount: a,
127
- invalid: f(e).invalid,
128
- hasRequiredText: !!$
130
+ invalid: m(e).invalid,
131
+ hasRequiredText: !!F
129
132
  }
130
133
  )
131
134
  ] });
@@ -1,73 +1,84 @@
1
- import { jsx as i, jsxs as m, Fragment as y } from "react/jsx-runtime";
2
- import { Elevation as I, Group as o, TabBar as N, Tab as $, Padding as b } from "@element/react-components";
1
+ import { jsx as i, jsxs as m, Fragment as B } from "react/jsx-runtime";
2
+ import { Elevation as $, Group as o, TabBar as y, Tab as I, Padding as N } from "@element/react-components";
3
3
  import { useState as k, useEffect as w } from "react";
4
4
  import { u as x } from "../../useBreakpoints-MzTZ0tCT.js";
5
- import { s as r } from "../../HashTabView.module-DUekkiTC.js";
6
- const u = (n, t) => !t || !n ? 0 : n.findIndex((a) => a.hash === t.replace("#", "")) ?? 0, z = ({
7
- tabs: n,
8
- hasHash: t = !0,
9
- hash: a = "",
5
+ import { s as a } from "../../HashTabView.module-DUekkiTC.js";
6
+ const u = (t, n) => !n || !t ? 0 : t.findIndex((r) => r.hash === n.replace("#", "")) ?? 0, z = ({
7
+ tabs: t,
8
+ hasHash: n = !0,
9
+ hash: r = "",
10
10
  clusterAlign: f = "start",
11
- hasClusteredTabs: g,
11
+ hasClusteredTabs: h,
12
12
  children: s,
13
- verticalGap: v = "none",
14
- elevation: h = 0,
13
+ verticalGap: g = "none",
14
+ elevation: v = 0,
15
15
  backgroundColor: T = "themeBackground",
16
- onChange: A
16
+ onChange: b
17
17
  }) => {
18
- const [l, p] = k(u(n, a)), { isDesktop: d } = x();
18
+ const [l, p] = k(u(t, r)), { isDesktop: d } = x();
19
19
  w(() => {
20
- if (!t || !a)
20
+ if (!n || !r)
21
21
  return;
22
- const e = u(n, a);
22
+ const e = u(t, r);
23
23
  p(e);
24
- }, [n, a, t]);
25
- const B = (e) => {
26
- const c = n[e].hash;
27
- c != null && t && window.history.replaceState(null, "", `#${c}`), p(e), A?.(e);
24
+ }, [t, r, n]);
25
+ const A = (e) => {
26
+ const c = t[e].hash;
27
+ c != null && n && window.history.replaceState(null, "", `#${c}`), p(e), b?.(e);
28
28
  };
29
29
  return /* @__PURE__ */ i(
30
- I,
30
+ $,
31
31
  {
32
- elevation: h,
33
- className: `${r.elevation} ${T === "none" ? "" : r.themeBackground}`,
34
- children: /* @__PURE__ */ m(o, { direction: "vertical", gap: v, secondaryAlign: "stretch", children: [
35
- /* @__PURE__ */ m(o, { direction: d ? "horizontal" : "vertical", className: r.tabWrapper, children: [
36
- /* @__PURE__ */ i(
37
- N,
38
- {
39
- className: r.tabBar,
40
- clustered: d ? g : !1,
41
- clusterAlign: f,
42
- variant: "surface",
43
- activeTabIndex: l,
44
- onTabActivated: B,
45
- children: n.map((e, c) => /* @__PURE__ */ i(
46
- $,
32
+ elevation: v,
33
+ className: `${a.elevation} ${T === "none" ? "" : a.themeBackground}`,
34
+ children: /* @__PURE__ */ m(
35
+ o,
36
+ {
37
+ "data-testid": "hash-tab-container",
38
+ direction: "vertical",
39
+ gap: g,
40
+ secondaryAlign: "stretch",
41
+ children: [
42
+ /* @__PURE__ */ m(o, { direction: d ? "horizontal" : "vertical", className: a.tabWrapper, children: [
43
+ /* @__PURE__ */ i(
44
+ y,
47
45
  {
48
- icon: e.leadingIcon,
49
- className: s ? r.tabButton : "",
50
- active: l === c,
51
- children: /* @__PURE__ */ m(o, { gap: "dense", children: [
52
- e.title,
53
- e.trailingIcon
54
- ] })
55
- },
56
- `${c}_${e.hash}`
57
- ))
58
- }
59
- ),
60
- s ? /* @__PURE__ */ i(
61
- b,
62
- {
63
- variant: "dense",
64
- className: d ? r.childContainer : r.childContainerPhone,
65
- children: /* @__PURE__ */ i(o, { gap: "dense", primaryAlign: "center", secondaryAlign: "center", children: s })
66
- }
67
- ) : /* @__PURE__ */ i(y, {})
68
- ] }),
69
- n[l]?.component
70
- ] })
46
+ "data-testid": "tab-bar",
47
+ className: a.tabBar,
48
+ clustered: d ? h : !1,
49
+ clusterAlign: f,
50
+ variant: "surface",
51
+ activeTabIndex: l,
52
+ onTabActivated: A,
53
+ children: t.map((e, c) => /* @__PURE__ */ i(
54
+ I,
55
+ {
56
+ "data-testid": `tab-${e.title}`,
57
+ icon: e.leadingIcon,
58
+ className: s ? a.tabButton : "",
59
+ active: l === c,
60
+ children: /* @__PURE__ */ m(o, { gap: "dense", children: [
61
+ e.title,
62
+ e.trailingIcon
63
+ ] })
64
+ },
65
+ `${c}_${e.hash}`
66
+ ))
67
+ }
68
+ ),
69
+ s ? /* @__PURE__ */ i(
70
+ N,
71
+ {
72
+ variant: "dense",
73
+ className: d ? a.childContainer : a.childContainerPhone,
74
+ children: /* @__PURE__ */ i(o, { gap: "dense", primaryAlign: "center", secondaryAlign: "center", children: s })
75
+ }
76
+ ) : /* @__PURE__ */ i(B, {})
77
+ ] }),
78
+ t[l]?.component
79
+ ]
80
+ }
81
+ )
71
82
  }
72
83
  );
73
84
  };