@sebgroup/green-react 3.11.0 → 3.12.0
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/index.esm.js +9 -3
- package/package.json +1 -1
- package/src/lib/datepicker/datepicker.d.ts +49 -26
package/index.esm.js
CHANGED
|
@@ -953,9 +953,10 @@ var Datepicker = function Datepicker(_a) {
|
|
|
953
953
|
value = _a.value,
|
|
954
954
|
showWeeks = _a.showWeeks,
|
|
955
955
|
testId = _a.testId,
|
|
956
|
+
validator = _a.validator,
|
|
956
957
|
selectedDate = _a.selectedDate,
|
|
957
958
|
currentDate = _a.currentDate,
|
|
958
|
-
props = __rest(_a, ["label", "onChange", "minDate", "maxDate", "value", "showWeeks", "testId", "selectedDate", "currentDate"]);
|
|
959
|
+
props = __rest(_a, ["label", "onChange", "minDate", "maxDate", "value", "showWeeks", "testId", "validator", "selectedDate", "currentDate"]);
|
|
959
960
|
if (currentDate && !value) value = currentDate;
|
|
960
961
|
if (selectedDate && !value) value = selectedDate;
|
|
961
962
|
var min = minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
|
|
@@ -965,6 +966,12 @@ var Datepicker = function Datepicker(_a) {
|
|
|
965
966
|
onChange(e.detail.value);
|
|
966
967
|
}
|
|
967
968
|
};
|
|
969
|
+
var ref = React.useRef(null);
|
|
970
|
+
useEffect(function () {
|
|
971
|
+
if (ref.current) {
|
|
972
|
+
ref.current.validator = validator;
|
|
973
|
+
}
|
|
974
|
+
}, [validator]);
|
|
968
975
|
return jsx("div", {
|
|
969
976
|
className: "form-group",
|
|
970
977
|
children: jsx(CoreDatepicker, Object.assign({
|
|
@@ -974,9 +981,8 @@ var Datepicker = function Datepicker(_a) {
|
|
|
974
981
|
max: max,
|
|
975
982
|
showWeekNumbers: showWeeks,
|
|
976
983
|
onchange: onChangeHandler,
|
|
977
|
-
size: props.size,
|
|
978
984
|
value: value,
|
|
979
|
-
|
|
985
|
+
ref: ref
|
|
980
986
|
}, props))
|
|
981
987
|
});
|
|
982
988
|
};
|
package/package.json
CHANGED
|
@@ -1,55 +1,78 @@
|
|
|
1
1
|
import { GdsDatepicker } from '@sebgroup/green-core/components/datepicker/index.js';
|
|
2
|
+
import { GdsValidator } from '@sebgroup/green-core/components/form/form-control';
|
|
2
3
|
export declare const CoreDatepicker: import("@lit/react").ReactWebComponent<GdsDatepicker, {
|
|
3
4
|
onchange: string;
|
|
4
5
|
}>;
|
|
5
|
-
export
|
|
6
|
+
export type DatepickerOptions = {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* An array of dates that should be disabled in the calendar.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
disabledDates?: Date[];
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* Whether to disable weekends in the calendar.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
disabledWeekends: boolean;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Whether to hide the label above the input field.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
hideLabel: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Validation state of the form control. Setting this to true triggers the invalid state of the control.
|
|
21
|
+
*/
|
|
22
|
+
invalid: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validate the form control element. Should return the validity state and an optional validation message.
|
|
25
|
+
*/
|
|
26
|
+
validator: GdsValidator;
|
|
27
|
+
/**
|
|
28
|
+
* The label text displayed above the datepicker. This should always be set to a descriptive label.
|
|
29
|
+
*/
|
|
30
|
+
label: string;
|
|
18
31
|
/**
|
|
19
32
|
* The maximum date that can be selected.
|
|
20
33
|
*/
|
|
21
|
-
maxDate
|
|
34
|
+
maxDate: Date;
|
|
22
35
|
/**
|
|
23
|
-
* The
|
|
36
|
+
* The minimum date that can be selected.
|
|
24
37
|
*/
|
|
25
|
-
|
|
38
|
+
minDate: Date;
|
|
26
39
|
/**
|
|
27
|
-
*
|
|
40
|
+
* Controls whether the datepicker popover is open.
|
|
28
41
|
*/
|
|
29
|
-
|
|
42
|
+
open: boolean;
|
|
30
43
|
/**
|
|
31
|
-
*
|
|
44
|
+
* Callback function that is called when the value of the Datepicker changes.
|
|
32
45
|
*/
|
|
33
|
-
|
|
46
|
+
onChange?: (value: any) => void;
|
|
34
47
|
/**
|
|
35
|
-
*
|
|
48
|
+
* Sets the datepicker as a required field for forms.
|
|
36
49
|
*/
|
|
37
|
-
|
|
50
|
+
required: boolean;
|
|
38
51
|
/**
|
|
39
|
-
* Whether to
|
|
52
|
+
* Whether to show a column of week numbers in the calendar.
|
|
40
53
|
*/
|
|
41
|
-
|
|
54
|
+
showWeeks: boolean;
|
|
42
55
|
/**
|
|
43
|
-
* Whether to
|
|
56
|
+
* Whether to use the small variant of the datepicker field.
|
|
44
57
|
*/
|
|
45
|
-
|
|
58
|
+
size: 'small' | 'medium';
|
|
46
59
|
/**
|
|
47
|
-
*
|
|
60
|
+
* The test ID used for testing.
|
|
61
|
+
*/
|
|
62
|
+
testId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The Date value of the datepicker. This can be set to undefined to clear the datepicker.
|
|
65
|
+
* This can be a string if set via the value attribute in markup, or via the setAttribute DOM API.
|
|
66
|
+
*/
|
|
67
|
+
value?: Date;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use `value` instead.
|
|
48
70
|
*/
|
|
49
|
-
disabledDates?: Date[];
|
|
50
|
-
/** @deprecated Use `value` instead */
|
|
51
71
|
selectedDate?: Date;
|
|
52
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Use `value` instead.
|
|
74
|
+
*/
|
|
53
75
|
currentDate?: Date;
|
|
54
|
-
}
|
|
55
|
-
export declare const Datepicker: ({ label, onChange, minDate, maxDate, value, showWeeks, testId, selectedDate, currentDate, ...props }: DatepickerOptions) => import("react/jsx-runtime").JSX.Element;
|
|
76
|
+
};
|
|
77
|
+
export declare const Datepicker: ({ label, onChange, minDate, maxDate, value, showWeeks, testId, validator, selectedDate, currentDate, ...props }: DatepickerOptions) => import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
export default Datepicker;
|