@hortiview/shared-components 0.0.4779 → 0.0.4804
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/FormDatePicker.css +1 -1
- package/dist/components/FormComponents/FormDatePicker/FormDatePicker.js +72 -49
- package/dist/components/FormComponents/FormDatePicker/FormDatePicker.test.js +8 -21
- package/dist/components/FormComponents/FormText/FormText.d.ts +11 -18
- package/dist/components/FormComponents/FormText/FormText.js +76 -75
- package/dist/components/FormComponents/FormText/FormText.test.js +85 -41
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._datePickerContainer_zxe48_1{width:100%}._invalid_zxe48_5+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{color:var(--lmnt-theme-danger)!important}._fromPickerText_zxe48_9+*[class*=mdc-text-field-helper-line] *[class*=mdc-text-field-helper-text]{margin-bottom:-19.33px!important}
|
|
@@ -1,64 +1,87 @@
|
|
|
1
1
|
import "../../../assets/FormDatePicker.css";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { Datepicker as F } from "@element/react-components";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import { useState as T, useEffect as k, useMemo as c } from "react";
|
|
5
|
+
import { useFormContext as z, Controller as I } from "react-hook-form";
|
|
6
|
+
const O = "_datePickerContainer_zxe48_1", Q = "_invalid_zxe48_5", Y = "_fromPickerText_zxe48_9", d = {
|
|
7
|
+
datePickerContainer: O,
|
|
8
|
+
invalid: Q,
|
|
9
|
+
fromPickerText: Y
|
|
10
|
+
}, H = ({
|
|
11
|
+
propertyName: e,
|
|
12
|
+
label: x,
|
|
13
|
+
required: n = !1,
|
|
14
|
+
requiredText: o,
|
|
15
|
+
className: P,
|
|
16
|
+
minRangeYear: f,
|
|
17
|
+
maxRangeYear: m,
|
|
17
18
|
locale: D
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
20
21
|
control: g,
|
|
21
|
-
formState: { errors:
|
|
22
|
-
watch:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
formState: { errors: t },
|
|
23
|
+
watch: S,
|
|
24
|
+
getFieldState: a
|
|
25
|
+
} = z(), [_, u] = T(), v = S(e);
|
|
26
|
+
k(() => {
|
|
27
|
+
u(/* @__PURE__ */ new Date());
|
|
28
|
+
}, []), k(() => {
|
|
29
|
+
u(new Date(v));
|
|
30
|
+
}, [v]);
|
|
31
|
+
const C = c(
|
|
32
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() - (f ?? 95),
|
|
33
|
+
[f]
|
|
34
|
+
), h = c(
|
|
35
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() + (m ?? 15),
|
|
36
|
+
[m]
|
|
37
|
+
), w = c(() => {
|
|
38
|
+
const s = () => {
|
|
39
|
+
if (t && t[e]) {
|
|
40
|
+
const r = t[e]?.message;
|
|
41
|
+
return r || "Invalid input";
|
|
42
|
+
}
|
|
43
|
+
return o;
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
valid: !a(e).invalid,
|
|
47
|
+
helperTextPersistent: t !== void 0 || n,
|
|
48
|
+
helperText: s(),
|
|
49
|
+
className: `${d.fromPickerText} ${a(e).invalid ? d.invalid : ""}`
|
|
50
|
+
};
|
|
51
|
+
}, [t, o, e, n, a]);
|
|
52
|
+
return /* @__PURE__ */ l(
|
|
53
|
+
I,
|
|
32
54
|
{
|
|
33
|
-
name:
|
|
55
|
+
name: e,
|
|
34
56
|
rules: {
|
|
35
|
-
required:
|
|
57
|
+
required: n ? {
|
|
58
|
+
value: n,
|
|
59
|
+
message: o
|
|
60
|
+
} : void 0
|
|
36
61
|
},
|
|
37
62
|
control: g,
|
|
38
|
-
render: ({ field: { onChange:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
a && Y(k, t) && /* @__PURE__ */ r("span", { className: i.errorText, children: m })
|
|
58
|
-
] })
|
|
63
|
+
render: ({ field: { onChange: s, ...r } }) => /* @__PURE__ */ l("div", { className: d.datePickerContainer, children: /* @__PURE__ */ l(
|
|
64
|
+
F,
|
|
65
|
+
{
|
|
66
|
+
...r,
|
|
67
|
+
className: P ?? "",
|
|
68
|
+
value: _,
|
|
69
|
+
variant: "outlined",
|
|
70
|
+
label: x,
|
|
71
|
+
format: (i) => i ? i.toLocaleDateString(D ?? "en") : "",
|
|
72
|
+
disableClearing: !0,
|
|
73
|
+
onChange: (i) => {
|
|
74
|
+
s(i?.toISOString());
|
|
75
|
+
},
|
|
76
|
+
minQuickSelectYear: C,
|
|
77
|
+
maxQuickSelectYear: h,
|
|
78
|
+
readOnly: !0,
|
|
79
|
+
textfieldProps: w
|
|
80
|
+
}
|
|
81
|
+
) })
|
|
59
82
|
}
|
|
60
83
|
);
|
|
61
84
|
};
|
|
62
85
|
export {
|
|
63
|
-
|
|
86
|
+
H as FormDatePicker
|
|
64
87
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { r as n, s as a, f as
|
|
2
|
+
import { r as n, s as a, f as l } from "../../../react.esm-BeDwcQWb.js";
|
|
3
3
|
import { FormDatePicker as s } from "./FormDatePicker.js";
|
|
4
|
-
import { v as e, d as
|
|
4
|
+
import { v as e, d as m, t as c, g as r } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
5
|
const f = e.fn();
|
|
6
6
|
e.mock("react-hook-form", () => ({
|
|
7
7
|
...e.importActual("react-hook-form"),
|
|
@@ -35,35 +35,22 @@ e.mock("react-hook-form", () => ({
|
|
|
35
35
|
_defaultValues: ["test"]
|
|
36
36
|
},
|
|
37
37
|
formState: { errors: {} },
|
|
38
|
-
watch: () => "2024-08-07"
|
|
38
|
+
watch: () => "2024-08-07",
|
|
39
|
+
getFieldState: e.fn().mockReturnValue({ invalid: !1 })
|
|
39
40
|
})
|
|
40
41
|
}));
|
|
41
|
-
|
|
42
|
+
m("FormDatePicker Test", () => {
|
|
42
43
|
c("render FormDatePicker", () => {
|
|
43
44
|
n(
|
|
44
|
-
/* @__PURE__ */ o(
|
|
45
|
-
s,
|
|
46
|
-
{
|
|
47
|
-
propertyName: "birthday",
|
|
48
|
-
label: "user.date-of-birth",
|
|
49
|
-
maxRangeYear: 0
|
|
50
|
-
}
|
|
51
|
-
)
|
|
45
|
+
/* @__PURE__ */ o(s, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
|
|
52
46
|
);
|
|
53
47
|
const t = a.getByRole("textbox");
|
|
54
48
|
r(t).toBeInTheDocument(), r(t).toBeInstanceOf(HTMLInputElement), r(["7.8.2024", "8/7/2024"]).toContainEqual(t.value), r(a.getByText("user.date-of-birth")).toBeInTheDocument();
|
|
55
49
|
}), c("change FormDatePicker value", () => {
|
|
56
50
|
n(
|
|
57
|
-
/* @__PURE__ */ o(
|
|
58
|
-
s,
|
|
59
|
-
{
|
|
60
|
-
propertyName: "birthday",
|
|
61
|
-
label: "user.date-of-birth",
|
|
62
|
-
maxRangeYear: 0
|
|
63
|
-
}
|
|
64
|
-
)
|
|
51
|
+
/* @__PURE__ */ o(s, { propertyName: "birthday", label: "user.date-of-birth", maxRangeYear: 0 })
|
|
65
52
|
);
|
|
66
53
|
const t = a.getByRole("textbox");
|
|
67
|
-
|
|
54
|
+
l.change(t, { target: { value: "1.1.24" } });
|
|
68
55
|
});
|
|
69
56
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { FieldValues, Path,
|
|
2
|
+
import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
|
|
3
3
|
/**
|
|
4
4
|
* a generic FormText property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
|
|
5
5
|
*/
|
|
@@ -8,22 +8,12 @@ type FormTextProps<T extends FieldValues> = {
|
|
|
8
8
|
propertyName: Path<T>;
|
|
9
9
|
/** the label of the Textbox */
|
|
10
10
|
label: string;
|
|
11
|
-
/** the max character length */
|
|
12
|
-
maxLength?: number;
|
|
13
|
-
/** the min character length */
|
|
14
|
-
minLength?: number;
|
|
15
|
-
/** if the field is required */
|
|
16
|
-
required?: boolean;
|
|
17
|
-
/** the text which is shown if the field is required and not filled */
|
|
18
|
-
requiredText?: string;
|
|
19
11
|
/** a boolean to set a textarea or a textfield */
|
|
20
12
|
textarea?: boolean;
|
|
21
13
|
/** a boolean to disable the field/set to readonly */
|
|
22
14
|
disabled?: boolean;
|
|
23
15
|
/** a boolean to hide the field */
|
|
24
16
|
hidden?: boolean;
|
|
25
|
-
/** a pattern to validate the field */
|
|
26
|
-
pattern?: ValidationRule<RegExp>;
|
|
27
17
|
/** a placeholder text */
|
|
28
18
|
placeholder?: string;
|
|
29
19
|
/** the type of the input field */
|
|
@@ -40,9 +30,15 @@ type FormTextProps<T extends FieldValues> = {
|
|
|
40
30
|
*/
|
|
41
31
|
trigger?: 'onBlur' | 'onChange' | 'likeForm';
|
|
42
32
|
/**
|
|
43
|
-
*
|
|
33
|
+
* the rules for the field
|
|
34
|
+
* @default undefined
|
|
35
|
+
* @example { required: { value: true, message: 'This field is required' } }
|
|
36
|
+
* @example { maxLength: { value: 10, message: 'Max length is 10' } }
|
|
37
|
+
* @example { minLength: { value: 5, message: 'Min length is 5' } }
|
|
38
|
+
* @example { pattern: { value: /^[A-Za-z]+$/, message: 'Only letters are allowed' } }
|
|
39
|
+
* @example { validate: (value) => value === 'admin' }
|
|
44
40
|
*/
|
|
45
|
-
|
|
41
|
+
rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'disabled' | 'valueAsNumber' | 'valueAsDate' | 'setValueAs'> | undefined;
|
|
46
42
|
};
|
|
47
43
|
/**
|
|
48
44
|
* creates a Textfield which should be part of a form component.
|
|
@@ -51,18 +47,15 @@ type FormTextProps<T extends FieldValues> = {
|
|
|
51
47
|
* @param hidden if the field should be hidden
|
|
52
48
|
* @param inputMode the input mode of the field @example 'search' or 'numeric'
|
|
53
49
|
* @param label the label of the field
|
|
54
|
-
* @param maxLength the max character length
|
|
55
|
-
* @param minLength the min character length
|
|
56
50
|
* @param pattern a pattern to validate the field @example /^[A-Za-z]+$/
|
|
57
51
|
* @param placeholder a placeholder text
|
|
58
52
|
* @param prefixText a prefix text
|
|
59
53
|
* @param propertyName the name of the property in the form
|
|
60
|
-
* @param required if the field is required
|
|
61
|
-
* @param requiredText the text which is shown if the field is required and not filled
|
|
62
54
|
* @param textarea if the field is a textarea
|
|
63
55
|
* @param trigger the trigger to validate the field. @default 'likeForm' @example 'onBlur' or 'onChange'
|
|
64
|
-
* @param validate a custom validation function or an object with multiple validation functions
|
|
65
56
|
* @param trailingIcon a trailing icon
|
|
57
|
+
* @param type the type of the input field
|
|
58
|
+
* @param rules the rules for the field @example { required: { value: true, message: 'This field is required' } }
|
|
66
59
|
* @returns a JSX element that renders a textfield form input
|
|
67
60
|
*/
|
|
68
61
|
export declare const FormText: <T extends FieldValues>(props: FormTextProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,108 +1,109 @@
|
|
|
1
1
|
import "../../../assets/FormText.css";
|
|
2
|
-
import { jsx as t, Fragment as
|
|
3
|
-
import { Textfield as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
const
|
|
7
|
-
formTextAreaHelperText:
|
|
8
|
-
invalid:
|
|
9
|
-
formText:
|
|
10
|
-
formTextArea:
|
|
11
|
-
},
|
|
2
|
+
import { jsx as t, Fragment as z, jsxs as I } from "react/jsx-runtime";
|
|
3
|
+
import { Textfield as P } from "@element/react-components";
|
|
4
|
+
import { useState as R, useMemo as s } from "react";
|
|
5
|
+
import { useFormContext as V, Controller as _ } from "react-hook-form";
|
|
6
|
+
const W = "_formTextAreaHelperText_7ae2c_1", b = "_invalid_7ae2c_6", w = "_formText_7ae2c_1", D = "_formTextArea_7ae2c_1", m = {
|
|
7
|
+
formTextAreaHelperText: W,
|
|
8
|
+
invalid: b,
|
|
9
|
+
formText: w,
|
|
10
|
+
formTextArea: D
|
|
11
|
+
}, E = ({
|
|
12
12
|
count: e,
|
|
13
13
|
maxCount: c,
|
|
14
|
-
required:
|
|
15
|
-
requiredText:
|
|
16
|
-
}) => /* @__PURE__ */
|
|
17
|
-
|
|
14
|
+
required: x = !1,
|
|
15
|
+
requiredText: r = ""
|
|
16
|
+
}) => /* @__PURE__ */ I("div", { className: m.formTextAreaHelperText, children: [
|
|
17
|
+
x ? /* @__PURE__ */ t("div", { children: r }) : /* @__PURE__ */ t("div", {}),
|
|
18
18
|
/* @__PURE__ */ t("div", { children: `${e}/${c}` })
|
|
19
|
-
] }),
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
requiredText: m = "",
|
|
26
|
-
disabled: h = !1,
|
|
27
|
-
textarea: i = !1,
|
|
28
|
-
hidden: C = !1,
|
|
29
|
-
pattern: A,
|
|
22
|
+
disabled: x = !1,
|
|
23
|
+
textarea: r = !1,
|
|
24
|
+
hidden: A = !1,
|
|
30
25
|
placeholder: F,
|
|
31
|
-
type:
|
|
32
|
-
prefixText:
|
|
33
|
-
inputMode:
|
|
34
|
-
trailingIcon:
|
|
35
|
-
trigger:
|
|
36
|
-
|
|
26
|
+
type: L,
|
|
27
|
+
prefixText: H,
|
|
28
|
+
inputMode: q,
|
|
29
|
+
trailingIcon: S,
|
|
30
|
+
trigger: d = "likeForm",
|
|
31
|
+
rules: n
|
|
37
32
|
}) => {
|
|
38
33
|
const {
|
|
39
|
-
control:
|
|
40
|
-
getFieldState:
|
|
41
|
-
formState: { errors:
|
|
42
|
-
trigger:
|
|
43
|
-
} =
|
|
44
|
-
const
|
|
45
|
-
|
|
34
|
+
control: f,
|
|
35
|
+
getFieldState: u,
|
|
36
|
+
formState: { errors: l },
|
|
37
|
+
trigger: T
|
|
38
|
+
} = V(), [$, B] = R(0), j = (i) => {
|
|
39
|
+
const a = i.target.value;
|
|
40
|
+
B(a?.length ?? 0);
|
|
46
41
|
}, M = () => {
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
return
|
|
42
|
+
if (l && l[e]) {
|
|
43
|
+
const i = l[e]?.message;
|
|
44
|
+
return i || "Invalid input";
|
|
50
45
|
}
|
|
51
|
-
return
|
|
52
|
-
|
|
46
|
+
return o && r ? /* @__PURE__ */ t(
|
|
47
|
+
E,
|
|
53
48
|
{
|
|
54
|
-
count:
|
|
55
|
-
maxCount:
|
|
56
|
-
required:
|
|
57
|
-
requiredText:
|
|
49
|
+
count: $,
|
|
50
|
+
maxCount: o,
|
|
51
|
+
required: v,
|
|
52
|
+
requiredText: g
|
|
58
53
|
}
|
|
59
|
-
) :
|
|
60
|
-
}
|
|
61
|
-
|
|
54
|
+
) : g;
|
|
55
|
+
}, o = s(
|
|
56
|
+
() => n?.maxLength?.value,
|
|
57
|
+
[n]
|
|
58
|
+
), k = s(
|
|
59
|
+
() => n?.minLength?.value,
|
|
60
|
+
[n]
|
|
61
|
+
), v = s(
|
|
62
|
+
() => n?.required?.value,
|
|
63
|
+
[n]
|
|
64
|
+
), g = s(
|
|
65
|
+
() => n?.required?.message,
|
|
66
|
+
[n]
|
|
67
|
+
);
|
|
68
|
+
return A ? /* @__PURE__ */ t(_, { name: e, control: f, render: () => /* @__PURE__ */ t(z, {}) }) : /* @__PURE__ */ t(
|
|
62
69
|
_,
|
|
63
70
|
{
|
|
64
71
|
name: e,
|
|
65
|
-
rules:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
pattern: A,
|
|
70
|
-
validate: j
|
|
71
|
-
},
|
|
72
|
-
control: x,
|
|
73
|
-
render: ({ field: { ref: n, ...o } }) => /* @__PURE__ */ t(
|
|
74
|
-
V,
|
|
72
|
+
rules: n,
|
|
73
|
+
control: f,
|
|
74
|
+
render: ({ field: { ref: i, ...a } }) => /* @__PURE__ */ t(
|
|
75
|
+
P,
|
|
75
76
|
{
|
|
76
|
-
...
|
|
77
|
-
value:
|
|
78
|
-
type:
|
|
77
|
+
...a,
|
|
78
|
+
value: a.value ?? "",
|
|
79
|
+
type: L,
|
|
79
80
|
fullWidth: !0,
|
|
80
|
-
inputMode:
|
|
81
|
+
inputMode: q,
|
|
81
82
|
placeholder: F,
|
|
82
|
-
prefixText:
|
|
83
|
-
disabled:
|
|
83
|
+
prefixText: H,
|
|
84
|
+
disabled: x,
|
|
84
85
|
helperText: M(),
|
|
85
|
-
helperTextPersistent:
|
|
86
|
+
helperTextPersistent: l !== void 0 || v || o !== void 0 && r,
|
|
86
87
|
label: c,
|
|
87
88
|
variant: "outlined",
|
|
88
|
-
maxlength:
|
|
89
|
-
minLength:
|
|
90
|
-
textarea:
|
|
89
|
+
maxlength: o,
|
|
90
|
+
minLength: k,
|
|
91
|
+
textarea: r,
|
|
91
92
|
noResize: !1,
|
|
92
93
|
onBlur: () => {
|
|
93
|
-
|
|
94
|
+
d === "onBlur" && T(e);
|
|
94
95
|
},
|
|
95
|
-
onChange: (
|
|
96
|
-
|
|
96
|
+
onChange: (h) => {
|
|
97
|
+
a.onChange(h), r && o !== void 0 && j(h), d === "onChange" && T(e);
|
|
97
98
|
},
|
|
98
|
-
valid: !
|
|
99
|
-
className: `${
|
|
100
|
-
trailingIcon:
|
|
99
|
+
valid: !u(e).invalid,
|
|
100
|
+
className: `${m.formText} ${u(e).invalid ? m.invalid : ""}`,
|
|
101
|
+
trailingIcon: S
|
|
101
102
|
}
|
|
102
103
|
)
|
|
103
104
|
}
|
|
104
105
|
);
|
|
105
106
|
};
|
|
106
107
|
export {
|
|
107
|
-
|
|
108
|
+
Y as FormText
|
|
108
109
|
};
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { r as
|
|
3
|
-
import { FormText as
|
|
4
|
-
import { v as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
...
|
|
8
|
-
Controller: ({
|
|
2
|
+
import { r as s, s as r, f as d } from "../../../react.esm-BeDwcQWb.js";
|
|
3
|
+
import { FormText as l } from "./FormText.js";
|
|
4
|
+
import { v as a, d as i, t as o, g as t } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
const m = a.fn();
|
|
6
|
+
a.mock("react-hook-form", () => ({
|
|
7
|
+
...a.importActual("react-hook-form"),
|
|
8
|
+
Controller: ({
|
|
9
|
+
render: e
|
|
10
|
+
}) => e({
|
|
9
11
|
field: {
|
|
10
12
|
ref: void 0,
|
|
11
|
-
onChange:
|
|
13
|
+
onChange: m,
|
|
12
14
|
value: "test"
|
|
13
15
|
}
|
|
14
16
|
}),
|
|
15
17
|
useFormContext: () => ({
|
|
16
|
-
watch:
|
|
18
|
+
watch: a.fn(),
|
|
17
19
|
control: {
|
|
18
|
-
register:
|
|
19
|
-
unregister:
|
|
20
|
-
getFieldState:
|
|
20
|
+
register: a.fn(),
|
|
21
|
+
unregister: a.fn(),
|
|
22
|
+
getFieldState: a.fn(),
|
|
21
23
|
_names: {
|
|
22
24
|
array: new Set("test"),
|
|
23
25
|
mount: new Set("test"),
|
|
@@ -27,11 +29,11 @@ r.mock("react-hook-form", () => ({
|
|
|
27
29
|
watchAll: !1
|
|
28
30
|
},
|
|
29
31
|
_subjects: {
|
|
30
|
-
watch:
|
|
31
|
-
array:
|
|
32
|
-
state:
|
|
32
|
+
watch: a.fn(),
|
|
33
|
+
array: a.fn(),
|
|
34
|
+
state: a.fn()
|
|
33
35
|
},
|
|
34
|
-
_getWatch:
|
|
36
|
+
_getWatch: a.fn(),
|
|
35
37
|
_formValues: ["test"],
|
|
36
38
|
_defaultValues: ["test"]
|
|
37
39
|
},
|
|
@@ -39,46 +41,88 @@ r.mock("react-hook-form", () => ({
|
|
|
39
41
|
getFieldState: () => ({ invalid: !1 })
|
|
40
42
|
})
|
|
41
43
|
}));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const e = a.getByRole("textbox");
|
|
46
|
-
t(e).toBeInTheDocument(), t(e).toBeInstanceOf(HTMLInputElement), t(e).toHaveAttribute("maxlength", "100"), t(a.getByText("address.line2")).toBeInTheDocument();
|
|
47
|
-
}), l("change value of single line text field", () => {
|
|
48
|
-
o(/* @__PURE__ */ n(s, { maxLength: 100, label: "address.line2", propertyName: "addressLine2" }));
|
|
49
|
-
const e = a.getByRole("textbox");
|
|
50
|
-
t(e).toHaveValue("test"), i.change(e, { target: { value: "test-change" } }), t(d).toHaveBeenCalled();
|
|
51
|
-
}), l("render FormText and return text area", () => {
|
|
52
|
-
o(
|
|
44
|
+
i("FormText Test", () => {
|
|
45
|
+
o("render FormText and return single line text field", () => {
|
|
46
|
+
s(
|
|
53
47
|
/* @__PURE__ */ n(
|
|
54
|
-
|
|
48
|
+
l,
|
|
55
49
|
{
|
|
56
|
-
|
|
50
|
+
rules: {
|
|
51
|
+
maxLength: {
|
|
52
|
+
value: 100,
|
|
53
|
+
message: "max length is 100"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
label: "address.line2",
|
|
57
|
+
propertyName: "addressLine2"
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
const e = r.getByRole("textbox");
|
|
62
|
+
t(e).toBeInTheDocument(), t(e).toBeInstanceOf(HTMLInputElement), t(e).toHaveAttribute("maxlength", "100"), t(r.getByText("address.line2")).toBeInTheDocument();
|
|
63
|
+
}), o("change value of single line text field", () => {
|
|
64
|
+
s(
|
|
65
|
+
/* @__PURE__ */ n(
|
|
66
|
+
l,
|
|
67
|
+
{
|
|
68
|
+
rules: {
|
|
69
|
+
maxLength: {
|
|
70
|
+
value: 100,
|
|
71
|
+
message: "max length is 100"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
label: "address.line2",
|
|
75
|
+
propertyName: "addressLine2"
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
const e = r.getByRole("textbox");
|
|
80
|
+
t(e).toHaveValue("test"), d.change(e, { target: { value: "test-change" } }), t(m).toHaveBeenCalled();
|
|
81
|
+
}), o("render FormText and return text area", () => {
|
|
82
|
+
s(
|
|
83
|
+
/* @__PURE__ */ n(
|
|
84
|
+
l,
|
|
85
|
+
{
|
|
86
|
+
rules: {
|
|
87
|
+
required: {
|
|
88
|
+
value: !0,
|
|
89
|
+
message: "required"
|
|
90
|
+
},
|
|
91
|
+
maxLength: {
|
|
92
|
+
value: 200,
|
|
93
|
+
message: "max length is 200"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
57
96
|
label: "address.line1",
|
|
58
97
|
propertyName: "addressLine1",
|
|
59
|
-
required: !0,
|
|
60
|
-
requiredText: "required",
|
|
61
98
|
textarea: !0
|
|
62
99
|
}
|
|
63
100
|
)
|
|
64
101
|
);
|
|
65
|
-
const e =
|
|
66
|
-
t(e).toBeInTheDocument(), t(e).toBeInstanceOf(HTMLTextAreaElement), t(e).toHaveAttribute("maxlength", "200"), t(
|
|
67
|
-
}),
|
|
68
|
-
|
|
102
|
+
const e = r.getByRole("textbox");
|
|
103
|
+
t(e).toBeInTheDocument(), t(e).toBeInstanceOf(HTMLTextAreaElement), t(e).toHaveAttribute("maxlength", "200"), t(r.getByText("address.line1")).toBeInTheDocument(), t(r.getByText("required")).toBeInTheDocument();
|
|
104
|
+
}), o("change value of text area", () => {
|
|
105
|
+
s(
|
|
69
106
|
/* @__PURE__ */ n(
|
|
70
|
-
|
|
107
|
+
l,
|
|
71
108
|
{
|
|
72
|
-
|
|
109
|
+
rules: {
|
|
110
|
+
required: {
|
|
111
|
+
value: !0,
|
|
112
|
+
message: "required"
|
|
113
|
+
},
|
|
114
|
+
maxLength: {
|
|
115
|
+
value: 200,
|
|
116
|
+
message: "max length is 200"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
73
119
|
label: "address.line1",
|
|
74
120
|
propertyName: "addressLine1",
|
|
75
|
-
required: !0,
|
|
76
|
-
requiredText: "required",
|
|
77
121
|
textarea: !0
|
|
78
122
|
}
|
|
79
123
|
)
|
|
80
124
|
);
|
|
81
|
-
const e =
|
|
82
|
-
|
|
125
|
+
const e = r.getByRole("textbox");
|
|
126
|
+
d.change(e, { target: { value: "test-change" } }), t(m).toHaveBeenCalled();
|
|
83
127
|
});
|
|
84
128
|
});
|
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.4804",
|
|
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>",
|