@hortiview/shared-components 0.0.7862 → 0.0.7951
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,3 +1,4 @@
|
|
|
1
|
+
import { DatepickerProps as ElementDatePickerProps } from '@element/react-components';
|
|
1
2
|
import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
|
|
2
3
|
type DatePickerProps<T extends FieldValues> = {
|
|
3
4
|
/** Name of the property that this date picker represents. */
|
|
@@ -33,9 +34,10 @@ type DatePickerProps<T extends FieldValues> = {
|
|
|
33
34
|
* @param minRangeYear - number of years to subtract from the current date as bottom of range
|
|
34
35
|
* @param maxRangeYear - number of years to add to the current date as top of range
|
|
35
36
|
* @param locale - locale to be used for the date picker.
|
|
37
|
+
* @param props - additional props to be passed to the date picker, which are the props of the element date picker {@link ElementDatePickerProps}.
|
|
36
38
|
* @param rules - rules for the date picker. default _undefined_ example: _{ required: { value: true, message: 'This field is required' } }_
|
|
37
39
|
*
|
|
38
40
|
* @returns A JSX element that renders a date picker form input.
|
|
39
41
|
*/
|
|
40
|
-
export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, closeLabel, className, minRangeYear, maxRangeYear, locale, rules, }: DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const FormDatePicker: <T extends FieldValues>({ propertyName, label, closeLabel, className, minRangeYear, maxRangeYear, locale, rules, ...props }: ElementDatePickerProps & DatePickerProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
41
43
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { Datepicker as
|
|
3
|
-
import { g as
|
|
4
|
-
import { useMemo as s, useState as
|
|
5
|
-
import { useFormContext as
|
|
1
|
+
import { jsx as n, jsxs as Y } from "react/jsx-runtime";
|
|
2
|
+
import { Datepicker as b, Divider as j, Padding as H, Button as M } from "@element/react-components";
|
|
3
|
+
import { g as Q } from "../../../get-UxX31Aph.js";
|
|
4
|
+
import { useMemo as s, useState as $ } from "react";
|
|
5
|
+
import { useFormContext as w, Controller as B } from "react-hook-form";
|
|
6
6
|
import { s as l } from "../../../formDatePicker.module-BV3ma_7y.js";
|
|
7
|
-
const
|
|
7
|
+
const G = ({
|
|
8
8
|
propertyName: t,
|
|
9
9
|
label: k,
|
|
10
10
|
closeLabel: p,
|
|
@@ -12,27 +12,28 @@ const A = ({
|
|
|
12
12
|
minRangeYear: m,
|
|
13
13
|
maxRangeYear: f,
|
|
14
14
|
locale: D,
|
|
15
|
-
rules: o
|
|
15
|
+
rules: o,
|
|
16
|
+
...S
|
|
16
17
|
}) => {
|
|
17
18
|
const {
|
|
18
|
-
control:
|
|
19
|
+
control: h,
|
|
19
20
|
formState: { errors: r, isValidating: u }
|
|
20
|
-
} =
|
|
21
|
+
} = w(), g = s(
|
|
21
22
|
() => o?.required?.value,
|
|
22
23
|
[o]
|
|
23
24
|
), x = s(
|
|
24
25
|
() => o?.required?.message,
|
|
25
26
|
[o]
|
|
26
|
-
),
|
|
27
|
+
), C = s(
|
|
27
28
|
() => (/* @__PURE__ */ new Date()).getFullYear() - (m ?? 95),
|
|
28
29
|
[m]
|
|
29
|
-
),
|
|
30
|
+
), v = s(
|
|
30
31
|
() => (/* @__PURE__ */ new Date()).getFullYear() + (f ?? 15),
|
|
31
32
|
[f]
|
|
32
33
|
), c = s(
|
|
33
|
-
() => !u &&
|
|
34
|
+
() => !u && Q(r, t) !== void 0,
|
|
34
35
|
[r, t, u]
|
|
35
|
-
),
|
|
36
|
+
), T = s(() => ({
|
|
36
37
|
valid: !c,
|
|
37
38
|
helperTextPersistent: c || g,
|
|
38
39
|
helperText: (() => {
|
|
@@ -43,26 +44,27 @@ const A = ({
|
|
|
43
44
|
return x;
|
|
44
45
|
})(),
|
|
45
46
|
className: `${l.fromPickerText} ${c ? l.invalid : ""}`
|
|
46
|
-
}), [r, x, t, g, c]), [
|
|
47
|
+
}), [r, x, t, g, c]), [q, d] = $(!1);
|
|
47
48
|
return /* @__PURE__ */ n(
|
|
48
|
-
|
|
49
|
+
B,
|
|
49
50
|
{
|
|
50
51
|
name: t,
|
|
51
52
|
rules: o,
|
|
52
|
-
control:
|
|
53
|
-
render: ({ field: { ref:
|
|
54
|
-
|
|
53
|
+
control: h,
|
|
54
|
+
render: ({ field: { ref: F, onChange: i, value: a, ...O } }) => /* @__PURE__ */ n("div", { className: l.datePickerContainer, children: /* @__PURE__ */ n(
|
|
55
|
+
b,
|
|
55
56
|
{
|
|
56
|
-
...
|
|
57
|
+
...S,
|
|
58
|
+
...O,
|
|
57
59
|
className: P ?? "",
|
|
58
60
|
value: a,
|
|
59
61
|
variant: "outlined",
|
|
60
62
|
label: k,
|
|
61
63
|
format: (e) => e ? e.toLocaleDateString(D ?? "en") : "",
|
|
62
64
|
disableClearing: !0,
|
|
63
|
-
trailingContent: /* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */ n(
|
|
65
|
-
/* @__PURE__ */ n(
|
|
65
|
+
trailingContent: /* @__PURE__ */ Y("div", { className: l.trailingContent, children: [
|
|
66
|
+
/* @__PURE__ */ n(j, {}),
|
|
67
|
+
/* @__PURE__ */ n(H, { variant: "dense", children: /* @__PURE__ */ n(M, { label: p, variant: "text", onClick: () => d(!1) }) })
|
|
66
68
|
] }),
|
|
67
69
|
onClick: () => {
|
|
68
70
|
d(!0);
|
|
@@ -78,16 +80,16 @@ const A = ({
|
|
|
78
80
|
},
|
|
79
81
|
hoisted: !0,
|
|
80
82
|
calendarProps: { hoisted: !0, className: l.datePickerCalendar },
|
|
81
|
-
minQuickSelectYear:
|
|
82
|
-
maxQuickSelectYear:
|
|
83
|
+
minQuickSelectYear: C,
|
|
84
|
+
maxQuickSelectYear: v,
|
|
83
85
|
readOnly: !0,
|
|
84
|
-
textfieldProps:
|
|
85
|
-
alwaysOpen:
|
|
86
|
+
textfieldProps: T,
|
|
87
|
+
alwaysOpen: q
|
|
86
88
|
}
|
|
87
89
|
) })
|
|
88
90
|
}
|
|
89
91
|
);
|
|
90
92
|
};
|
|
91
93
|
export {
|
|
92
|
-
|
|
94
|
+
G as FormDatePicker
|
|
93
95
|
};
|
|
@@ -4,7 +4,7 @@ import { FieldPath, FieldValues, Path, RegisterOptions } from 'react-hook-form';
|
|
|
4
4
|
/**
|
|
5
5
|
* a generic FormSelector property type. the generic T represents the interface, which is used in the form, like {@link CreateOrganizationDto}
|
|
6
6
|
*/
|
|
7
|
-
type FormSelectProps<T extends FieldValues> = Omit<SelectProps, 'className' | 'clearable' | 'disabled' | 'helperText' | 'helperTextPersistent' | 'hidden' | 'hoisted' | 'label' | 'menuMaxHeight' | 'multi' | 'multiSelect' | '
|
|
7
|
+
type FormSelectProps<T extends FieldValues> = Omit<SelectProps, 'className' | 'clearable' | 'disabled' | 'helperText' | 'helperTextPersistent' | 'hidden' | 'hoisted' | 'label' | 'menuMaxHeight' | 'multi' | 'multiSelect' | 'options' | 'searchable' | 'textKey' | 'valid' | 'value' | 'valueKey' | 'variant'> & {
|
|
8
8
|
/** the name of the property in the form */
|
|
9
9
|
propertyName: Path<T>;
|
|
10
10
|
/** the label of the select */
|
|
@@ -27,8 +27,6 @@ type FormSelectProps<T extends FieldValues> = Omit<SelectProps, 'className' | 'c
|
|
|
27
27
|
clearable?: boolean;
|
|
28
28
|
/** if true, the select allows the user to search for options */
|
|
29
29
|
searchable?: boolean;
|
|
30
|
-
/** a message if no options a present */
|
|
31
|
-
noOptionsMessage?: string;
|
|
32
30
|
/**
|
|
33
31
|
* the rules for the picker
|
|
34
32
|
* @default undefined
|
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.7951",
|
|
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>",
|