@hortiview/shared-components 0.0.6403 → 0.0.6504
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,9 +1,10 @@
|
|
|
1
|
+
import { TextfieldProps } from '@element/react-components';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
|
|
3
4
|
/**
|
|
4
5
|
* a generic FormText property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
|
|
5
6
|
*/
|
|
6
|
-
export type FormTextProps<T extends FieldValues> = {
|
|
7
|
+
export type FormTextProps<T extends FieldValues> = TextfieldProps & {
|
|
7
8
|
/** the path to the property, like Address.AddressLine1 */
|
|
8
9
|
propertyName: Path<T>;
|
|
9
10
|
/** the label of the Textbox */
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "../../../assets/FormText.css";
|
|
2
|
-
import { jsx as n, Fragment as
|
|
3
|
-
import { Textfield as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
const
|
|
7
|
-
formTextAreaHelperText:
|
|
8
|
-
invalid:
|
|
9
|
-
required:
|
|
10
|
-
formTextArea:
|
|
11
|
-
},
|
|
2
|
+
import { jsx as n, Fragment as C, jsxs as M } from "react/jsx-runtime";
|
|
3
|
+
import { Textfield as P, TypoCaption as R } from "@element/react-components";
|
|
4
|
+
import { useState as V, useMemo as d } from "react";
|
|
5
|
+
import { useFormContext as W, Controller as _ } from "react-hook-form";
|
|
6
|
+
const w = "_formTextAreaHelperText_1n0bk_1", D = "_invalid_1n0bk_6", E = "_required_1n0bk_9", G = "_formTextArea_1n0bk_1", i = {
|
|
7
|
+
formTextAreaHelperText: w,
|
|
8
|
+
invalid: D,
|
|
9
|
+
required: E,
|
|
10
|
+
formTextArea: G
|
|
11
|
+
}, J = ({
|
|
12
12
|
count: e,
|
|
13
13
|
maxCount: c,
|
|
14
14
|
invalid: m = !1,
|
|
@@ -17,93 +17,95 @@ const W = "_formTextAreaHelperText_1n0bk_1", w = "_invalid_1n0bk_6", D = "_requi
|
|
|
17
17
|
"div",
|
|
18
18
|
{
|
|
19
19
|
className: `${i.formTextAreaHelperText} ${m ? i.invalid : ""} ${r ? i.required : ""}`,
|
|
20
|
-
children: /* @__PURE__ */ n(
|
|
20
|
+
children: /* @__PURE__ */ n(R, { children: `${e}/${c}` })
|
|
21
21
|
}
|
|
22
|
-
),
|
|
22
|
+
), N = (e) => e.textarea ? /* @__PURE__ */ n(K, { ...e }) : /* @__PURE__ */ n(O, { ...e }), K = (e) => /* @__PURE__ */ n("div", { className: i.formTextArea, children: /* @__PURE__ */ n(A, { ...e }) }), O = (e) => /* @__PURE__ */ n(A, { ...e }), A = ({
|
|
23
23
|
propertyName: e,
|
|
24
24
|
label: c,
|
|
25
25
|
disabled: m = !1,
|
|
26
26
|
textarea: r = !1,
|
|
27
|
-
hidden:
|
|
28
|
-
placeholder:
|
|
29
|
-
type:
|
|
30
|
-
prefixText:
|
|
31
|
-
inputMode:
|
|
32
|
-
trailingIcon:
|
|
27
|
+
hidden: q = !1,
|
|
28
|
+
placeholder: F,
|
|
29
|
+
type: $,
|
|
30
|
+
prefixText: L,
|
|
31
|
+
inputMode: k,
|
|
32
|
+
trailingIcon: H,
|
|
33
33
|
trigger: x = "likeForm",
|
|
34
|
-
rules: t
|
|
34
|
+
rules: t,
|
|
35
|
+
...f
|
|
35
36
|
}) => {
|
|
36
37
|
const {
|
|
37
|
-
control:
|
|
38
|
+
control: v,
|
|
38
39
|
getFieldState: u,
|
|
39
40
|
formState: { errors: s },
|
|
40
41
|
trigger: T
|
|
41
|
-
} =
|
|
42
|
+
} = W(), [b, B] = V(0), S = (a) => {
|
|
42
43
|
const l = a.target.value;
|
|
43
|
-
|
|
44
|
-
},
|
|
44
|
+
B(l?.length ?? 0);
|
|
45
|
+
}, j = () => {
|
|
45
46
|
if (s && s[e]) {
|
|
46
47
|
const a = s[e]?.message;
|
|
47
48
|
return a || "Invalid input";
|
|
48
49
|
}
|
|
49
|
-
return
|
|
50
|
+
return I;
|
|
50
51
|
}, o = d(
|
|
51
52
|
() => t?.maxLength?.value,
|
|
52
53
|
[t]
|
|
53
|
-
),
|
|
54
|
+
), z = d(
|
|
54
55
|
() => t?.minLength?.value,
|
|
55
56
|
[t]
|
|
56
|
-
),
|
|
57
|
+
), g = d(
|
|
57
58
|
() => t?.required?.value,
|
|
58
59
|
[t]
|
|
59
|
-
),
|
|
60
|
+
), I = d(
|
|
60
61
|
() => t?.required?.message,
|
|
61
62
|
[t]
|
|
62
63
|
);
|
|
63
|
-
return
|
|
64
|
-
|
|
64
|
+
return q ? /* @__PURE__ */ n(_, { name: e, control: v, render: () => /* @__PURE__ */ n(C, {}) }) : /* @__PURE__ */ n(
|
|
65
|
+
_,
|
|
65
66
|
{
|
|
66
67
|
name: e,
|
|
67
68
|
rules: t,
|
|
68
|
-
control:
|
|
69
|
-
render: ({ field: { ref: a, ...l } }) => /* @__PURE__ */
|
|
69
|
+
control: v,
|
|
70
|
+
render: ({ field: { ref: a, ...l } }) => /* @__PURE__ */ M(C, { children: [
|
|
70
71
|
/* @__PURE__ */ n(
|
|
71
|
-
|
|
72
|
+
P,
|
|
72
73
|
{
|
|
74
|
+
...f,
|
|
73
75
|
...l,
|
|
74
76
|
value: l.value ?? "",
|
|
75
|
-
type:
|
|
77
|
+
type: $,
|
|
76
78
|
fullWidth: !0,
|
|
77
|
-
inputMode:
|
|
78
|
-
placeholder:
|
|
79
|
-
prefixText:
|
|
79
|
+
inputMode: k,
|
|
80
|
+
placeholder: F,
|
|
81
|
+
prefixText: L,
|
|
80
82
|
disabled: m,
|
|
81
|
-
helperText:
|
|
82
|
-
helperTextPersistent: s !== void 0 ||
|
|
83
|
+
helperText: j(),
|
|
84
|
+
helperTextPersistent: s !== void 0 || g || o !== void 0 && r,
|
|
83
85
|
label: c,
|
|
84
86
|
variant: "outlined",
|
|
85
87
|
maxlength: o,
|
|
86
|
-
minLength:
|
|
88
|
+
minLength: z,
|
|
87
89
|
textarea: r,
|
|
88
90
|
noResize: !1,
|
|
89
91
|
onBlur: () => {
|
|
90
|
-
x === "onBlur" && T(e);
|
|
92
|
+
x === "onBlur" && T(e), f.onBlur?.();
|
|
91
93
|
},
|
|
92
|
-
onChange: (
|
|
93
|
-
l.onChange(
|
|
94
|
+
onChange: (h) => {
|
|
95
|
+
l.onChange(h), r && o !== void 0 && S(h), x === "onChange" && T(e);
|
|
94
96
|
},
|
|
95
97
|
valid: !u(e).invalid,
|
|
96
98
|
className: `${i.formText} ${u(e).invalid ? i.invalid : ""}`,
|
|
97
|
-
trailingIcon:
|
|
99
|
+
trailingIcon: H
|
|
98
100
|
}
|
|
99
101
|
),
|
|
100
|
-
o && r && /* @__PURE__ */ n(
|
|
101
|
-
|
|
102
|
+
o !== void 0 && r && /* @__PURE__ */ n(
|
|
103
|
+
J,
|
|
102
104
|
{
|
|
103
|
-
count:
|
|
105
|
+
count: b,
|
|
104
106
|
maxCount: o,
|
|
105
107
|
invalid: u(e).invalid,
|
|
106
|
-
required:
|
|
108
|
+
required: g
|
|
107
109
|
}
|
|
108
110
|
)
|
|
109
111
|
] })
|
|
@@ -111,5 +113,5 @@ const W = "_formTextAreaHelperText_1n0bk_1", w = "_invalid_1n0bk_6", D = "_requi
|
|
|
111
113
|
);
|
|
112
114
|
};
|
|
113
115
|
export {
|
|
114
|
-
|
|
116
|
+
N as FormText
|
|
115
117
|
};
|
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.6504",
|
|
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>",
|