@hortiview/shared-components 0.0.5962 → 0.0.6044
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.
package/dist/assets/FormText.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._formTextAreaHelperText_1n0bk_1{align-self:flex-end;color:var(--lmnt-helper-text-color);padding-right:1rem}._invalid_1n0bk_6._formTextAreaHelperText_1n0bk_1{color:var(--lmnt-theme-danger)}._required_1n0bk_9._formTextAreaHelperText_1n0bk_1{margin-top:-1.125rem}._invalid_1n0bk_6+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{color:var(--lmnt-theme-danger)!important}._formTextArea_1n0bk_1{width:100%;display:flex;flex-flow:column}
|
|
@@ -1,109 +1,115 @@
|
|
|
1
1
|
import "../../../assets/FormText.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Textfield as P } from "@element/react-components";
|
|
4
|
-
import { useState as R, useMemo as
|
|
5
|
-
import { useFormContext as V, Controller as
|
|
6
|
-
const W = "
|
|
2
|
+
import { jsx as n, Fragment as h, jsxs as I } from "react/jsx-runtime";
|
|
3
|
+
import { Textfield as M, TypoCaption as P } from "@element/react-components";
|
|
4
|
+
import { useState as R, useMemo as d } from "react";
|
|
5
|
+
import { useFormContext as V, Controller as C } from "react-hook-form";
|
|
6
|
+
const W = "_formTextAreaHelperText_1n0bk_1", w = "_invalid_1n0bk_6", D = "_required_1n0bk_9", E = "_formTextArea_1n0bk_1", i = {
|
|
7
7
|
formTextAreaHelperText: W,
|
|
8
|
-
invalid:
|
|
9
|
-
|
|
10
|
-
formTextArea:
|
|
11
|
-
},
|
|
8
|
+
invalid: w,
|
|
9
|
+
required: D,
|
|
10
|
+
formTextArea: E
|
|
11
|
+
}, G = ({
|
|
12
12
|
count: e,
|
|
13
13
|
maxCount: c,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}) => /* @__PURE__ */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
invalid: m = !1,
|
|
15
|
+
required: r = !1
|
|
16
|
+
}) => /* @__PURE__ */ n(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: `${i.formTextAreaHelperText} ${m ? i.invalid : ""} ${r ? i.required : ""}`,
|
|
20
|
+
children: /* @__PURE__ */ n(P, { children: `${e}/${c}` })
|
|
21
|
+
}
|
|
22
|
+
), Z = (e) => e.textarea ? /* @__PURE__ */ n(J, { ...e }) : /* @__PURE__ */ n(K, { ...e }), J = (e) => /* @__PURE__ */ n("div", { className: i.formTextArea, children: /* @__PURE__ */ n(_, { ...e }) }), K = (e) => /* @__PURE__ */ n(_, { ...e }), _ = ({
|
|
20
23
|
propertyName: e,
|
|
21
24
|
label: c,
|
|
22
|
-
disabled:
|
|
25
|
+
disabled: m = !1,
|
|
23
26
|
textarea: r = !1,
|
|
24
27
|
hidden: A = !1,
|
|
25
|
-
placeholder:
|
|
26
|
-
type:
|
|
27
|
-
prefixText:
|
|
28
|
-
inputMode:
|
|
29
|
-
trailingIcon:
|
|
30
|
-
trigger:
|
|
31
|
-
rules:
|
|
28
|
+
placeholder: q,
|
|
29
|
+
type: F,
|
|
30
|
+
prefixText: $,
|
|
31
|
+
inputMode: L,
|
|
32
|
+
trailingIcon: k,
|
|
33
|
+
trigger: x = "likeForm",
|
|
34
|
+
rules: t
|
|
32
35
|
}) => {
|
|
33
36
|
const {
|
|
34
37
|
control: f,
|
|
35
38
|
getFieldState: u,
|
|
36
|
-
formState: { errors:
|
|
39
|
+
formState: { errors: s },
|
|
37
40
|
trigger: T
|
|
38
|
-
} = V(), [
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
return
|
|
41
|
+
} = V(), [H, b] = R(0), S = (a) => {
|
|
42
|
+
const l = a.target.value;
|
|
43
|
+
b(l?.length ?? 0);
|
|
44
|
+
}, B = () => {
|
|
45
|
+
if (s && s[e]) {
|
|
46
|
+
const a = s[e]?.message;
|
|
47
|
+
return a || "Invalid input";
|
|
45
48
|
}
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
() => n?.minLength?.value,
|
|
60
|
-
[n]
|
|
61
|
-
), v = s(
|
|
62
|
-
() => n?.required?.value,
|
|
63
|
-
[n]
|
|
64
|
-
), g = s(
|
|
65
|
-
() => n?.required?.message,
|
|
66
|
-
[n]
|
|
49
|
+
return z;
|
|
50
|
+
}, o = d(
|
|
51
|
+
() => t?.maxLength?.value,
|
|
52
|
+
[t]
|
|
53
|
+
), j = d(
|
|
54
|
+
() => t?.minLength?.value,
|
|
55
|
+
[t]
|
|
56
|
+
), v = d(
|
|
57
|
+
() => t?.required?.value,
|
|
58
|
+
[t]
|
|
59
|
+
), z = d(
|
|
60
|
+
() => t?.required?.message,
|
|
61
|
+
[t]
|
|
67
62
|
);
|
|
68
|
-
return A ? /* @__PURE__ */
|
|
69
|
-
|
|
63
|
+
return A ? /* @__PURE__ */ n(C, { name: e, control: f, render: () => /* @__PURE__ */ n(h, {}) }) : /* @__PURE__ */ n(
|
|
64
|
+
C,
|
|
70
65
|
{
|
|
71
66
|
name: e,
|
|
72
|
-
rules:
|
|
67
|
+
rules: t,
|
|
73
68
|
control: f,
|
|
74
|
-
render: ({ field: { ref:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
69
|
+
render: ({ field: { ref: a, ...l } }) => /* @__PURE__ */ I(h, { children: [
|
|
70
|
+
/* @__PURE__ */ n(
|
|
71
|
+
M,
|
|
72
|
+
{
|
|
73
|
+
...l,
|
|
74
|
+
value: l.value ?? "",
|
|
75
|
+
type: F,
|
|
76
|
+
fullWidth: !0,
|
|
77
|
+
inputMode: L,
|
|
78
|
+
placeholder: q,
|
|
79
|
+
prefixText: $,
|
|
80
|
+
disabled: m,
|
|
81
|
+
helperText: B(),
|
|
82
|
+
helperTextPersistent: s !== void 0 || v || o !== void 0 && r,
|
|
83
|
+
label: c,
|
|
84
|
+
variant: "outlined",
|
|
85
|
+
maxlength: o,
|
|
86
|
+
minLength: j,
|
|
87
|
+
textarea: r,
|
|
88
|
+
noResize: !1,
|
|
89
|
+
onBlur: () => {
|
|
90
|
+
x === "onBlur" && T(e);
|
|
91
|
+
},
|
|
92
|
+
onChange: (g) => {
|
|
93
|
+
l.onChange(g), r && o !== void 0 && S(g), x === "onChange" && T(e);
|
|
94
|
+
},
|
|
95
|
+
valid: !u(e).invalid,
|
|
96
|
+
className: `${i.formText} ${u(e).invalid ? i.invalid : ""}`,
|
|
97
|
+
trailingIcon: k
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
o && r && /* @__PURE__ */ n(
|
|
101
|
+
G,
|
|
102
|
+
{
|
|
103
|
+
count: H,
|
|
104
|
+
maxCount: o,
|
|
105
|
+
invalid: u(e).invalid,
|
|
106
|
+
required: v
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] })
|
|
104
110
|
}
|
|
105
111
|
);
|
|
106
112
|
};
|
|
107
113
|
export {
|
|
108
|
-
|
|
114
|
+
Z as FormText
|
|
109
115
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { r as s, s as r, f as d } from "../../../react.esm-C0LtovhP.js";
|
|
3
|
-
import { FormText as
|
|
4
|
-
import { v as a, d as i, t as
|
|
3
|
+
import { FormText as o } from "./FormText.js";
|
|
4
|
+
import { v as a, d as i, t as l, g as e } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
const m = a.fn();
|
|
6
6
|
a.mock("react-hook-form", () => ({
|
|
7
7
|
...a.importActual("react-hook-form"),
|
|
8
8
|
Controller: ({
|
|
9
|
-
render:
|
|
10
|
-
}) =>
|
|
9
|
+
render: t
|
|
10
|
+
}) => t({
|
|
11
11
|
field: {
|
|
12
12
|
ref: void 0,
|
|
13
13
|
onChange: m,
|
|
@@ -42,10 +42,10 @@ a.mock("react-hook-form", () => ({
|
|
|
42
42
|
})
|
|
43
43
|
}));
|
|
44
44
|
i("FormText Test", () => {
|
|
45
|
-
|
|
45
|
+
l("render FormText and return single line text field", () => {
|
|
46
46
|
s(
|
|
47
47
|
/* @__PURE__ */ n(
|
|
48
|
-
|
|
48
|
+
o,
|
|
49
49
|
{
|
|
50
50
|
rules: {
|
|
51
51
|
maxLength: {
|
|
@@ -58,12 +58,12 @@ i("FormText Test", () => {
|
|
|
58
58
|
}
|
|
59
59
|
)
|
|
60
60
|
);
|
|
61
|
-
const
|
|
62
|
-
t
|
|
63
|
-
}),
|
|
61
|
+
const t = r.getByRole("textbox");
|
|
62
|
+
e(t).toBeInTheDocument(), e(t).toBeInstanceOf(HTMLInputElement), e(t).toHaveAttribute("maxlength", "100"), e(r.getByText("address.line2")).toBeInTheDocument();
|
|
63
|
+
}), l("change value of single line text field", () => {
|
|
64
64
|
s(
|
|
65
65
|
/* @__PURE__ */ n(
|
|
66
|
-
|
|
66
|
+
o,
|
|
67
67
|
{
|
|
68
68
|
rules: {
|
|
69
69
|
maxLength: {
|
|
@@ -76,12 +76,12 @@ i("FormText Test", () => {
|
|
|
76
76
|
}
|
|
77
77
|
)
|
|
78
78
|
);
|
|
79
|
-
const
|
|
80
|
-
t
|
|
81
|
-
}),
|
|
79
|
+
const t = r.getByRole("textbox");
|
|
80
|
+
e(t).toHaveValue("test"), d.change(t, { target: { value: "test-change" } }), e(m).toHaveBeenCalled();
|
|
81
|
+
}), l("render FormText and return text area", () => {
|
|
82
82
|
s(
|
|
83
83
|
/* @__PURE__ */ n(
|
|
84
|
-
|
|
84
|
+
o,
|
|
85
85
|
{
|
|
86
86
|
rules: {
|
|
87
87
|
required: {
|
|
@@ -99,12 +99,29 @@ i("FormText Test", () => {
|
|
|
99
99
|
}
|
|
100
100
|
)
|
|
101
101
|
);
|
|
102
|
-
const
|
|
103
|
-
t
|
|
104
|
-
}),
|
|
102
|
+
const t = r.getByRole("textbox");
|
|
103
|
+
e(t).toBeInTheDocument(), e(t).toBeInstanceOf(HTMLTextAreaElement), e(t).toHaveAttribute("maxlength", "200"), e(r.getByText("address.line1")).toBeInTheDocument(), e(r.getByText("required")).toBeInTheDocument();
|
|
104
|
+
}), l("render FormText with maxLength indicator", () => {
|
|
105
105
|
s(
|
|
106
106
|
/* @__PURE__ */ n(
|
|
107
|
-
|
|
107
|
+
o,
|
|
108
|
+
{
|
|
109
|
+
rules: {
|
|
110
|
+
maxLength: {
|
|
111
|
+
value: 200,
|
|
112
|
+
message: "max length is 200"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
label: "address.line1",
|
|
116
|
+
propertyName: "addressLine1",
|
|
117
|
+
textarea: !0
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
), e(r.getByText("address.line1")).toBeInTheDocument(), e(r.queryByText("required")).not.toBeInTheDocument(), e(r.getByText("0/200")).toBeInTheDocument();
|
|
121
|
+
}), l("change value of text area", () => {
|
|
122
|
+
s(
|
|
123
|
+
/* @__PURE__ */ n(
|
|
124
|
+
o,
|
|
108
125
|
{
|
|
109
126
|
rules: {
|
|
110
127
|
required: {
|
|
@@ -122,7 +139,7 @@ i("FormText Test", () => {
|
|
|
122
139
|
}
|
|
123
140
|
)
|
|
124
141
|
);
|
|
125
|
-
const
|
|
126
|
-
d.change(
|
|
142
|
+
const t = r.getByRole("textbox");
|
|
143
|
+
d.change(t, { target: { value: "test-change" } }), e(m).toHaveBeenCalled();
|
|
127
144
|
});
|
|
128
145
|
});
|
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.6044",
|
|
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>",
|