@hortiview/shared-components 0.0.5635 → 0.0.5859
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,83 +1,89 @@
|
|
|
1
1
|
import "../../../assets/FormDatePicker.css";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { Datepicker as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
8
|
-
datePickerContainer:
|
|
2
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
3
|
+
import { Datepicker as h } from "@element/react-components";
|
|
4
|
+
import { g as v } from "../../../get-Dyz8NMrE.js";
|
|
5
|
+
import { useMemo as n } from "react";
|
|
6
|
+
import { useFormContext as q, Controller as F } from "react-hook-form";
|
|
7
|
+
const Y = "_datePickerContainer_gkrp1_1", H = "_invalid_gkrp1_5", M = "_fromPickerText_gkrp1_9", Q = "_datePickerCalendar_gkrp1_13", s = {
|
|
8
|
+
datePickerContainer: Y,
|
|
9
9
|
invalid: H,
|
|
10
|
-
fromPickerText:
|
|
11
|
-
datePickerCalendar:
|
|
12
|
-
},
|
|
13
|
-
propertyName:
|
|
14
|
-
label:
|
|
15
|
-
className:
|
|
16
|
-
minRangeYear:
|
|
17
|
-
maxRangeYear:
|
|
18
|
-
locale:
|
|
19
|
-
rules:
|
|
10
|
+
fromPickerText: M,
|
|
11
|
+
datePickerCalendar: Q
|
|
12
|
+
}, O = ({
|
|
13
|
+
propertyName: t,
|
|
14
|
+
label: u,
|
|
15
|
+
className: g,
|
|
16
|
+
minRangeYear: l,
|
|
17
|
+
maxRangeYear: m,
|
|
18
|
+
locale: x,
|
|
19
|
+
rules: o
|
|
20
20
|
}) => {
|
|
21
21
|
const {
|
|
22
|
-
control:
|
|
23
|
-
formState: { errors: r, isValidating:
|
|
24
|
-
} =
|
|
25
|
-
() =>
|
|
26
|
-
[
|
|
27
|
-
),
|
|
28
|
-
() =>
|
|
29
|
-
[
|
|
30
|
-
),
|
|
31
|
-
() => (/* @__PURE__ */ new Date()).getFullYear() - (
|
|
32
|
-
[d]
|
|
33
|
-
), C = t(
|
|
34
|
-
() => (/* @__PURE__ */ new Date()).getFullYear() + (l ?? 15),
|
|
22
|
+
control: _,
|
|
23
|
+
formState: { errors: r, isValidating: f }
|
|
24
|
+
} = q(), k = n(
|
|
25
|
+
() => o?.required?.value,
|
|
26
|
+
[o]
|
|
27
|
+
), P = n(
|
|
28
|
+
() => o?.required?.message,
|
|
29
|
+
[o]
|
|
30
|
+
), p = n(
|
|
31
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() - (l ?? 95),
|
|
35
32
|
[l]
|
|
36
|
-
),
|
|
37
|
-
() =>
|
|
38
|
-
[
|
|
39
|
-
),
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
), C = n(
|
|
34
|
+
() => (/* @__PURE__ */ new Date()).getFullYear() + (m ?? 15),
|
|
35
|
+
[m]
|
|
36
|
+
), c = n(
|
|
37
|
+
() => !f && v(r, t) !== void 0,
|
|
38
|
+
[r, t, f]
|
|
39
|
+
), T = n(() => ({
|
|
40
|
+
valid: !c,
|
|
41
|
+
helperTextPersistent: c || k,
|
|
42
42
|
helperText: (() => {
|
|
43
|
-
if (r && r[
|
|
44
|
-
const
|
|
45
|
-
return
|
|
43
|
+
if (r && r[t]) {
|
|
44
|
+
const i = r[t]?.message;
|
|
45
|
+
return i || "Invalid input";
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return P;
|
|
48
48
|
})(),
|
|
49
|
-
className: `${
|
|
50
|
-
}), [r,
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
-
|
|
49
|
+
className: `${s.fromPickerText} ${c ? s.invalid : ""}`
|
|
50
|
+
}), [r, P, t, k, c]);
|
|
51
|
+
return /* @__PURE__ */ d(
|
|
52
|
+
F,
|
|
53
53
|
{
|
|
54
|
-
name:
|
|
55
|
-
rules:
|
|
56
|
-
control:
|
|
57
|
-
render: ({ field: { ref:
|
|
58
|
-
|
|
54
|
+
name: t,
|
|
55
|
+
rules: o,
|
|
56
|
+
control: _,
|
|
57
|
+
render: ({ field: { ref: D, onChange: i, value: a, ...S } }) => /* @__PURE__ */ d("div", { className: s.datePickerContainer, children: /* @__PURE__ */ d(
|
|
58
|
+
h,
|
|
59
59
|
{
|
|
60
|
-
...
|
|
61
|
-
className:
|
|
62
|
-
value:
|
|
60
|
+
...S,
|
|
61
|
+
className: g ?? "",
|
|
62
|
+
value: a,
|
|
63
63
|
variant: "outlined",
|
|
64
|
-
label:
|
|
65
|
-
format: (
|
|
64
|
+
label: u,
|
|
65
|
+
format: (e) => e ? e.toLocaleDateString(x ?? "en") : "",
|
|
66
66
|
disableClearing: !0,
|
|
67
|
-
onSelect: (
|
|
68
|
-
|
|
67
|
+
onSelect: (e) => {
|
|
68
|
+
i(e);
|
|
69
|
+
},
|
|
70
|
+
onSelectMonth: (e) => {
|
|
71
|
+
a && (e.setDate(a.getDate()), i(e));
|
|
72
|
+
},
|
|
73
|
+
onSelectYear: (e) => {
|
|
74
|
+
a && (e.setDate(a.getDate()), i(e));
|
|
69
75
|
},
|
|
70
76
|
hoisted: !0,
|
|
71
|
-
calendarProps: { hoisted: !0, className:
|
|
72
|
-
minQuickSelectYear:
|
|
77
|
+
calendarProps: { hoisted: !0, className: s.datePickerCalendar },
|
|
78
|
+
minQuickSelectYear: p,
|
|
73
79
|
maxQuickSelectYear: C,
|
|
74
80
|
readOnly: !0,
|
|
75
|
-
textfieldProps:
|
|
81
|
+
textfieldProps: T
|
|
76
82
|
}
|
|
77
83
|
) })
|
|
78
84
|
}
|
|
79
85
|
);
|
|
80
86
|
};
|
|
81
87
|
export {
|
|
82
|
-
|
|
88
|
+
O as FormDatePicker
|
|
83
89
|
};
|
|
@@ -1,85 +1,88 @@
|
|
|
1
1
|
import "../../../assets/FormSelect.css";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as l, Fragment as O } from "react/jsx-runtime";
|
|
3
3
|
import { Select as P } from "@element/react-components";
|
|
4
|
-
import { g as
|
|
5
|
-
import { useMemo as
|
|
6
|
-
import { useFormContext as
|
|
7
|
-
|
|
4
|
+
import { g as d } from "../../../get-Dyz8NMrE.js";
|
|
5
|
+
import { useMemo as u } from "react";
|
|
6
|
+
import { useFormContext as V, Controller as g } from "react-hook-form";
|
|
7
|
+
import { isArray as k } from "lodash";
|
|
8
|
+
const w = "_invalid_1vo1h_1", z = "_formSelect_1vo1h_5", B = "_formSelectContainer_1vo1h_9", S = {
|
|
8
9
|
invalid: w,
|
|
9
10
|
formSelect: z,
|
|
10
|
-
formSelectContainer:
|
|
11
|
-
},
|
|
11
|
+
formSelectContainer: B
|
|
12
|
+
}, W = ({
|
|
12
13
|
propertyName: r,
|
|
13
|
-
label:
|
|
14
|
-
options:
|
|
15
|
-
multi:
|
|
16
|
-
disabled:
|
|
17
|
-
hoisted:
|
|
18
|
-
hidden:
|
|
19
|
-
valueKey:
|
|
20
|
-
textKey:
|
|
21
|
-
clearable:
|
|
22
|
-
noOptionsMessage:
|
|
23
|
-
rules:
|
|
24
|
-
...
|
|
14
|
+
label: h,
|
|
15
|
+
options: t,
|
|
16
|
+
multi: s = !1,
|
|
17
|
+
disabled: C = !1,
|
|
18
|
+
hoisted: p = !1,
|
|
19
|
+
hidden: q = !1,
|
|
20
|
+
valueKey: n = "value",
|
|
21
|
+
textKey: T = "text",
|
|
22
|
+
clearable: F = !1,
|
|
23
|
+
noOptionsMessage: M = "",
|
|
24
|
+
rules: i,
|
|
25
|
+
...b
|
|
25
26
|
}) => {
|
|
26
27
|
const {
|
|
27
|
-
control:
|
|
28
|
-
formState: { errors: o, isValidating:
|
|
29
|
-
} =
|
|
30
|
-
() => !
|
|
31
|
-
[o, r,
|
|
32
|
-
),
|
|
33
|
-
() =>
|
|
34
|
-
[
|
|
35
|
-
), $ =
|
|
36
|
-
() =>
|
|
37
|
-
[
|
|
38
|
-
),
|
|
28
|
+
control: v,
|
|
29
|
+
formState: { errors: o, isValidating: x }
|
|
30
|
+
} = V(), a = u(
|
|
31
|
+
() => !x && d(o, r) !== void 0,
|
|
32
|
+
[o, r, x]
|
|
33
|
+
), H = u(
|
|
34
|
+
() => i?.required?.value,
|
|
35
|
+
[i]
|
|
36
|
+
), $ = u(
|
|
37
|
+
() => i?.required?.message,
|
|
38
|
+
[i]
|
|
39
|
+
), j = () => {
|
|
39
40
|
if (o && o[r]) {
|
|
40
|
-
const
|
|
41
|
-
return
|
|
41
|
+
const f = o[r]?.message;
|
|
42
|
+
return f || "Invalid input";
|
|
42
43
|
}
|
|
43
44
|
return $;
|
|
44
45
|
};
|
|
45
|
-
return
|
|
46
|
-
|
|
46
|
+
return q ? /* @__PURE__ */ l(g, { name: r, control: v, render: () => /* @__PURE__ */ l(O, {}) }) : /* @__PURE__ */ l("div", { className: S.formSelectContainer, children: /* @__PURE__ */ l(
|
|
47
|
+
g,
|
|
47
48
|
{
|
|
48
49
|
name: r,
|
|
49
|
-
rules:
|
|
50
|
-
control:
|
|
51
|
-
render: ({ field: { ref:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
rules: i,
|
|
51
|
+
control: v,
|
|
52
|
+
render: ({ field: { ref: f, onChange: m, value: _, ...A } }) => {
|
|
53
|
+
let c = t;
|
|
54
|
+
k(t) && d(t[0], "options") !== void 0 && (c = t.flatMap((e) => d(e, "options") ?? []));
|
|
55
|
+
const E = s ? c?.filter(
|
|
56
|
+
(e) => _?.includes(e[n])
|
|
57
|
+
) : c?.find((e) => e[n] === _);
|
|
58
|
+
return /* @__PURE__ */ l(
|
|
56
59
|
P,
|
|
57
60
|
{
|
|
58
|
-
...
|
|
59
|
-
...
|
|
60
|
-
value:
|
|
61
|
-
label:
|
|
61
|
+
...A,
|
|
62
|
+
...b,
|
|
63
|
+
value: E,
|
|
64
|
+
label: h,
|
|
62
65
|
variant: "outlined",
|
|
63
|
-
helperText:
|
|
64
|
-
helperTextPersistent:
|
|
65
|
-
options:
|
|
66
|
-
valid: !
|
|
67
|
-
multiSelect:
|
|
68
|
-
className: `${
|
|
69
|
-
disabled:
|
|
70
|
-
valueKey:
|
|
71
|
-
textKey:
|
|
66
|
+
helperText: j(),
|
|
67
|
+
helperTextPersistent: H || a,
|
|
68
|
+
options: t,
|
|
69
|
+
valid: !a,
|
|
70
|
+
multiSelect: s,
|
|
71
|
+
className: `${S.formSelect} ${a ? S.invalid : ""}`,
|
|
72
|
+
disabled: C,
|
|
73
|
+
valueKey: n,
|
|
74
|
+
textKey: T,
|
|
72
75
|
onChange: (e) => {
|
|
73
76
|
if (e == null)
|
|
74
|
-
return
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
|
|
77
|
+
return m(e);
|
|
78
|
+
if (s)
|
|
79
|
+
return m(e.map((I) => I[n]));
|
|
80
|
+
m(e[n]);
|
|
78
81
|
},
|
|
79
|
-
hoisted:
|
|
80
|
-
noOptionsMessage:
|
|
82
|
+
hoisted: p,
|
|
83
|
+
noOptionsMessage: M,
|
|
81
84
|
searchable: !0,
|
|
82
|
-
clearable:
|
|
85
|
+
clearable: F,
|
|
83
86
|
menuMaxHeight: "15rem"
|
|
84
87
|
}
|
|
85
88
|
);
|
|
@@ -88,5 +91,5 @@ const w = "_invalid_1vo1h_1", z = "_formSelect_1vo1h_5", A = "_formSelectContain
|
|
|
88
91
|
) });
|
|
89
92
|
};
|
|
90
93
|
export {
|
|
91
|
-
|
|
94
|
+
W as FormSelect
|
|
92
95
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { r as
|
|
3
|
-
import { FormSelect as
|
|
4
|
-
import { v as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
...
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { r as l, s as t, f as i } from "../../../react.esm-C0LtovhP.js";
|
|
3
|
+
import { FormSelect as m } from "./FormSelect.js";
|
|
4
|
+
import { v as n, d as g, t as d, g as e } from "../../../vi.JYQecGiw-BbUbJcT8.js";
|
|
5
|
+
const p = n.fn();
|
|
6
|
+
n.mock("react-hook-form", () => ({
|
|
7
|
+
...n.importActual("react-hook-form"),
|
|
8
8
|
Controller: ({
|
|
9
|
-
render:
|
|
10
|
-
}) =>
|
|
9
|
+
render: r
|
|
10
|
+
}) => r({
|
|
11
11
|
field: {
|
|
12
12
|
ref: void 0,
|
|
13
|
-
onChange:
|
|
13
|
+
onChange: p,
|
|
14
14
|
value: "3"
|
|
15
15
|
}
|
|
16
16
|
}),
|
|
17
17
|
useFormContext: () => ({
|
|
18
18
|
control: {
|
|
19
|
-
register:
|
|
20
|
-
unregister:
|
|
21
|
-
getFieldState:
|
|
19
|
+
register: n.fn(),
|
|
20
|
+
unregister: n.fn(),
|
|
21
|
+
getFieldState: n.fn(),
|
|
22
22
|
_names: {
|
|
23
23
|
array: new Set("test"),
|
|
24
24
|
mount: new Set("test"),
|
|
@@ -28,11 +28,11 @@ e.mock("react-hook-form", () => ({
|
|
|
28
28
|
watchAll: !1
|
|
29
29
|
},
|
|
30
30
|
_subjects: {
|
|
31
|
-
watch:
|
|
32
|
-
array:
|
|
33
|
-
state:
|
|
31
|
+
watch: n.fn(),
|
|
32
|
+
array: n.fn(),
|
|
33
|
+
state: n.fn()
|
|
34
34
|
},
|
|
35
|
-
_getWatch:
|
|
35
|
+
_getWatch: n.fn(),
|
|
36
36
|
_formValues: ["test"],
|
|
37
37
|
_defaultValues: ["test"]
|
|
38
38
|
},
|
|
@@ -40,27 +40,63 @@ e.mock("react-hook-form", () => ({
|
|
|
40
40
|
getFieldState: () => ({ invalid: !1 })
|
|
41
41
|
})
|
|
42
42
|
}));
|
|
43
|
-
|
|
44
|
-
const
|
|
43
|
+
g("FormSelect Test", () => {
|
|
44
|
+
const r = [
|
|
45
45
|
{ id: "1", value: "Germany", description: "" },
|
|
46
46
|
{ id: "2", value: "France", description: "" },
|
|
47
47
|
{ id: "3", value: "Afar", description: "" }
|
|
48
|
+
], f = [
|
|
49
|
+
{
|
|
50
|
+
groupValue: "Europe",
|
|
51
|
+
groupName: "Europe",
|
|
52
|
+
options: [
|
|
53
|
+
{ id: "1", value: "Germany", description: "" },
|
|
54
|
+
{ id: "2", value: "France", description: "" }
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
groupValue: "Africa",
|
|
59
|
+
groupName: "Africa",
|
|
60
|
+
options: [{ id: "3", value: "Afar", description: "" }]
|
|
61
|
+
}
|
|
48
62
|
];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
63
|
+
d("render FormSelect", () => {
|
|
64
|
+
l(
|
|
65
|
+
/* @__PURE__ */ u(
|
|
66
|
+
m,
|
|
67
|
+
{
|
|
68
|
+
label: "address.country",
|
|
69
|
+
rules: { required: { value: !0, message: "required" } },
|
|
70
|
+
propertyName: "countryId",
|
|
71
|
+
options: r,
|
|
72
|
+
valueKey: "id",
|
|
73
|
+
textKey: "value"
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
const o = t.getByRole("combobox");
|
|
78
|
+
e(o).toBeInTheDocument(), e(o).toBeInstanceOf(HTMLInputElement), e(t.getByText("address.country")).toBeInTheDocument(), e(t.getByText("Afar")).toBeInTheDocument(), e(t.getByText("required")).toBeInTheDocument();
|
|
79
|
+
}), d("render grouped FormSelect and click on option", () => {
|
|
80
|
+
l(
|
|
81
|
+
/* @__PURE__ */ u(
|
|
82
|
+
m,
|
|
53
83
|
{
|
|
54
84
|
label: "address.country",
|
|
55
85
|
rules: { required: { value: !0, message: "required" } },
|
|
56
86
|
propertyName: "countryId",
|
|
57
|
-
options:
|
|
87
|
+
options: f,
|
|
58
88
|
valueKey: "id",
|
|
59
89
|
textKey: "value"
|
|
60
90
|
}
|
|
61
91
|
)
|
|
62
92
|
);
|
|
63
|
-
const
|
|
64
|
-
|
|
93
|
+
const o = t.getByRole("combobox");
|
|
94
|
+
e(o).toBeInTheDocument(), e(o).toBeInstanceOf(HTMLInputElement), e(t.getByText("address.country")).toBeInTheDocument(), e(t.getByText("Afar")).toBeInTheDocument(), e(t.getByText("required")).toBeInTheDocument(), i.mouseDown(o);
|
|
95
|
+
const s = t.getByText("Africa");
|
|
96
|
+
e(s).toBeInTheDocument(), e(s.parentElement?.parentElement).toBeInstanceOf(HTMLHeadingElement);
|
|
97
|
+
const c = t.getByText("Europe");
|
|
98
|
+
e(c).toBeInTheDocument(), e(c.parentElement?.parentElement).toBeInstanceOf(HTMLHeadingElement);
|
|
99
|
+
const a = t.getByText("France");
|
|
100
|
+
e(a).toBeInTheDocument(), e(a.parentElement?.parentElement).not.toBeInstanceOf(HTMLHeadingElement), e(t.getByText("Germany")).toBeInTheDocument(), e(t.getAllByText("Afar")).toHaveLength(2), i.click(a), e(p).toBeCalledWith("2");
|
|
65
101
|
});
|
|
66
102
|
});
|
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.5859",
|
|
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>",
|