@hortiview/shared-components 0.0.4801 → 0.0.4806
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,20 +1,20 @@
|
|
|
1
1
|
import "../../../assets/FormDatePicker.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Datepicker as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
const
|
|
7
|
-
datePickerContainer:
|
|
8
|
-
invalid:
|
|
9
|
-
fromPickerText:
|
|
10
|
-
},
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { Datepicker as T } from "@element/react-components";
|
|
4
|
+
import { useState as z, useEffect as k, useMemo as l } from "react";
|
|
5
|
+
import { useFormContext as I, Controller as O } from "react-hook-form";
|
|
6
|
+
const Q = "_datePickerContainer_zxe48_1", Y = "_invalid_zxe48_5", $ = "_fromPickerText_zxe48_9", c = {
|
|
7
|
+
datePickerContainer: Q,
|
|
8
|
+
invalid: Y,
|
|
9
|
+
fromPickerText: $
|
|
10
|
+
}, L = ({
|
|
11
11
|
propertyName: e,
|
|
12
12
|
label: x,
|
|
13
13
|
required: n = !1,
|
|
14
14
|
requiredText: o,
|
|
15
15
|
className: P,
|
|
16
|
-
minRangeYear:
|
|
17
|
-
maxRangeYear:
|
|
16
|
+
minRangeYear: d,
|
|
17
|
+
maxRangeYear: f,
|
|
18
18
|
locale: D
|
|
19
19
|
}) => {
|
|
20
20
|
const {
|
|
@@ -22,20 +22,20 @@ const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPick
|
|
|
22
22
|
formState: { errors: t },
|
|
23
23
|
watch: S,
|
|
24
24
|
getFieldState: a
|
|
25
|
-
} =
|
|
25
|
+
} = I(), [_, m] = z(), u = S(e);
|
|
26
26
|
k(() => {
|
|
27
|
-
|
|
27
|
+
m(/* @__PURE__ */ new Date());
|
|
28
28
|
}, []), k(() => {
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
const C =
|
|
32
|
-
() => (/* @__PURE__ */ new Date()).getFullYear() - (
|
|
29
|
+
m(new Date(u));
|
|
30
|
+
}, [u]);
|
|
31
|
+
const C = l(
|
|
32
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() - (d ?? 95),
|
|
33
|
+
[d]
|
|
34
|
+
), h = l(
|
|
35
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() + (f ?? 15),
|
|
33
36
|
[f]
|
|
34
|
-
),
|
|
35
|
-
|
|
36
|
-
[m]
|
|
37
|
-
), w = c(() => {
|
|
38
|
-
const s = () => {
|
|
37
|
+
), w = l(() => {
|
|
38
|
+
const v = () => {
|
|
39
39
|
if (t && t[e]) {
|
|
40
40
|
const r = t[e]?.message;
|
|
41
41
|
return r || "Invalid input";
|
|
@@ -45,12 +45,12 @@ const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPick
|
|
|
45
45
|
return {
|
|
46
46
|
valid: !a(e).invalid,
|
|
47
47
|
helperTextPersistent: t !== void 0 || n,
|
|
48
|
-
helperText:
|
|
49
|
-
className: `${
|
|
48
|
+
helperText: v(),
|
|
49
|
+
className: `${c.fromPickerText} ${a(e).invalid ? c.invalid : ""}`
|
|
50
50
|
};
|
|
51
51
|
}, [t, o, e, n, a]);
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
|
|
52
|
+
return /* @__PURE__ */ s(
|
|
53
|
+
O,
|
|
54
54
|
{
|
|
55
55
|
name: e,
|
|
56
56
|
rules: {
|
|
@@ -60,10 +60,10 @@ const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPick
|
|
|
60
60
|
} : void 0
|
|
61
61
|
},
|
|
62
62
|
control: g,
|
|
63
|
-
render: ({ field: { onChange:
|
|
64
|
-
|
|
63
|
+
render: ({ field: { ref: v, onChange: r, ...F } }) => /* @__PURE__ */ s("div", { className: c.datePickerContainer, children: /* @__PURE__ */ s(
|
|
64
|
+
T,
|
|
65
65
|
{
|
|
66
|
-
...
|
|
66
|
+
...F,
|
|
67
67
|
className: P ?? "",
|
|
68
68
|
value: _,
|
|
69
69
|
variant: "outlined",
|
|
@@ -71,7 +71,7 @@ const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPick
|
|
|
71
71
|
format: (i) => i ? i.toLocaleDateString(D ?? "en") : "",
|
|
72
72
|
disableClearing: !0,
|
|
73
73
|
onChange: (i) => {
|
|
74
|
-
|
|
74
|
+
r(i?.toISOString());
|
|
75
75
|
},
|
|
76
76
|
minQuickSelectYear: C,
|
|
77
77
|
maxQuickSelectYear: h,
|
|
@@ -83,5 +83,5 @@ const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPick
|
|
|
83
83
|
);
|
|
84
84
|
};
|
|
85
85
|
export {
|
|
86
|
-
|
|
86
|
+
L as FormDatePicker
|
|
87
87
|
};
|
|
@@ -2,7 +2,7 @@ import "../../../assets/FormText.css";
|
|
|
2
2
|
import { jsx as t, Fragment as z, jsxs as I } from "react/jsx-runtime";
|
|
3
3
|
import { Textfield as P } from "@element/react-components";
|
|
4
4
|
import { useState as R, useMemo as s } from "react";
|
|
5
|
-
import { useFormContext as V, Controller as
|
|
5
|
+
import { useFormContext as V, Controller as _ } from "react-hook-form";
|
|
6
6
|
const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formText_7ae2c_1", D = "_formTextArea_7ae2c_1", m = {
|
|
7
7
|
formTextAreaHelperText: W,
|
|
8
8
|
invalid: b,
|
|
@@ -16,17 +16,17 @@ const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formT
|
|
|
16
16
|
}) => /* @__PURE__ */ I("div", { className: m.formTextAreaHelperText, children: [
|
|
17
17
|
x ? /* @__PURE__ */ t("div", { children: r }) : /* @__PURE__ */ t("div", {}),
|
|
18
18
|
/* @__PURE__ */ t("div", { children: `${e}/${c}` })
|
|
19
|
-
] }), Y = (e) => e.textarea ? /* @__PURE__ */ t(G, { ...e }) : /* @__PURE__ */ t(J, { ...e }), G = (e) => /* @__PURE__ */ t("div", { className: m.formTextArea, children: /* @__PURE__ */ t(
|
|
19
|
+
] }), Y = (e) => e.textarea ? /* @__PURE__ */ t(G, { ...e }) : /* @__PURE__ */ t(J, { ...e }), G = (e) => /* @__PURE__ */ t("div", { className: m.formTextArea, children: /* @__PURE__ */ t(C, { ...e }) }), J = (e) => /* @__PURE__ */ t(C, { ...e }), C = ({
|
|
20
20
|
propertyName: e,
|
|
21
21
|
label: c,
|
|
22
22
|
disabled: x = !1,
|
|
23
23
|
textarea: r = !1,
|
|
24
|
-
hidden:
|
|
25
|
-
placeholder:
|
|
26
|
-
type:
|
|
27
|
-
prefixText:
|
|
28
|
-
inputMode:
|
|
29
|
-
trailingIcon:
|
|
24
|
+
hidden: A = !1,
|
|
25
|
+
placeholder: F,
|
|
26
|
+
type: L,
|
|
27
|
+
prefixText: H,
|
|
28
|
+
inputMode: q,
|
|
29
|
+
trailingIcon: S,
|
|
30
30
|
trigger: d = "likeForm",
|
|
31
31
|
rules: n
|
|
32
32
|
}) => {
|
|
@@ -35,10 +35,10 @@ const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formT
|
|
|
35
35
|
getFieldState: u,
|
|
36
36
|
formState: { errors: l },
|
|
37
37
|
trigger: T
|
|
38
|
-
} = V(), [
|
|
38
|
+
} = V(), [$, B] = R(0), j = (i) => {
|
|
39
39
|
const a = i.target.value;
|
|
40
|
-
|
|
41
|
-
},
|
|
40
|
+
B(a?.length ?? 0);
|
|
41
|
+
}, M = () => {
|
|
42
42
|
if (l && l[e]) {
|
|
43
43
|
const i = l[e]?.message;
|
|
44
44
|
return i || "Invalid input";
|
|
@@ -46,27 +46,27 @@ const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formT
|
|
|
46
46
|
return o && r ? /* @__PURE__ */ t(
|
|
47
47
|
E,
|
|
48
48
|
{
|
|
49
|
-
count:
|
|
49
|
+
count: $,
|
|
50
50
|
maxCount: o,
|
|
51
|
-
required:
|
|
52
|
-
requiredText:
|
|
51
|
+
required: v,
|
|
52
|
+
requiredText: g
|
|
53
53
|
}
|
|
54
|
-
) :
|
|
54
|
+
) : g;
|
|
55
55
|
}, o = s(
|
|
56
56
|
() => n?.maxLength?.value,
|
|
57
57
|
[n]
|
|
58
|
-
),
|
|
58
|
+
), k = s(
|
|
59
59
|
() => n?.minLength?.value,
|
|
60
60
|
[n]
|
|
61
|
-
),
|
|
61
|
+
), v = s(
|
|
62
62
|
() => n?.required?.value,
|
|
63
63
|
[n]
|
|
64
|
-
),
|
|
64
|
+
), g = s(
|
|
65
65
|
() => n?.required?.message,
|
|
66
66
|
[n]
|
|
67
67
|
);
|
|
68
|
-
return
|
|
69
|
-
|
|
68
|
+
return A ? /* @__PURE__ */ t(_, { name: e, control: f, render: () => /* @__PURE__ */ t(z, {}) }) : /* @__PURE__ */ t(
|
|
69
|
+
_,
|
|
70
70
|
{
|
|
71
71
|
name: e,
|
|
72
72
|
rules: n,
|
|
@@ -76,29 +76,29 @@ const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formT
|
|
|
76
76
|
{
|
|
77
77
|
...a,
|
|
78
78
|
value: a.value ?? "",
|
|
79
|
-
type:
|
|
79
|
+
type: L,
|
|
80
80
|
fullWidth: !0,
|
|
81
|
-
inputMode:
|
|
82
|
-
placeholder:
|
|
83
|
-
prefixText:
|
|
81
|
+
inputMode: q,
|
|
82
|
+
placeholder: F,
|
|
83
|
+
prefixText: H,
|
|
84
84
|
disabled: x,
|
|
85
|
-
helperText:
|
|
86
|
-
helperTextPersistent: l !== void 0 ||
|
|
85
|
+
helperText: M(),
|
|
86
|
+
helperTextPersistent: l !== void 0 || v || o !== void 0 && r,
|
|
87
87
|
label: c,
|
|
88
88
|
variant: "outlined",
|
|
89
89
|
maxlength: o,
|
|
90
|
-
minLength:
|
|
90
|
+
minLength: k,
|
|
91
91
|
textarea: r,
|
|
92
92
|
noResize: !1,
|
|
93
93
|
onBlur: () => {
|
|
94
94
|
d === "onBlur" && T(e);
|
|
95
95
|
},
|
|
96
|
-
onChange: (
|
|
97
|
-
a.onChange(
|
|
96
|
+
onChange: (h) => {
|
|
97
|
+
a.onChange(h), r && o !== void 0 && j(h), d === "onChange" && T(e);
|
|
98
98
|
},
|
|
99
99
|
valid: !u(e).invalid,
|
|
100
100
|
className: `${m.formText} ${u(e).invalid ? m.invalid : ""}`,
|
|
101
|
-
trailingIcon:
|
|
101
|
+
trailingIcon: S
|
|
102
102
|
}
|
|
103
103
|
)
|
|
104
104
|
}
|
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.
|
|
4
|
+
"version": "0.0.4806",
|
|
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>",
|