@entur/datepicker 11.0.1-beta.0 → 11.0.2
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/DatePicker/DateField.d.ts +2 -1
- package/dist/DatePicker/DatePicker.d.ts +1 -1
- package/dist/TimePicker/TimePicker.d.ts +2 -1
- package/dist/TimePicker/TimePickerArrowButton.d.ts +2 -1
- package/dist/datepicker.cjs.development.js +18 -11
- package/dist/datepicker.cjs.development.js.map +1 -1
- package/dist/datepicker.cjs.production.min.js +1 -1
- package/dist/datepicker.cjs.production.min.js.map +1 -1
- package/dist/datepicker.esm.js +18 -11
- package/dist/datepicker.esm.js.map +1 -1
- package/dist/styles.css +43 -43
- package/package.json +8 -8
|
@@ -77,9 +77,10 @@ export type DateFieldProps<DateType extends DateValue> = Omit<AriaDatePickerProp
|
|
|
77
77
|
fieldProps?: DateFieldProps<DateType>;
|
|
78
78
|
dateFieldRef?: React.Ref<HTMLDivElement>;
|
|
79
79
|
disabled?: boolean;
|
|
80
|
+
readOnly?: boolean;
|
|
80
81
|
/** Ekstra klassenavn */
|
|
81
82
|
className?: string;
|
|
82
83
|
style?: React.CSSProperties;
|
|
83
84
|
};
|
|
84
|
-
export declare const DateField: <DateType extends DateValue>({ selectedDate, onChange, label, locale: customLocale, showTimeZone, showTime, granularity, disabled, isDisabled, variant, feedback, validationVariant, validationFeedback, labelTooltip, minDate, maxDate, forcedReturnType, style, className, labelProps: parentLabelProps, append, prepend, dateFieldRef: ref, ...rest }: DateFieldProps<DateType>) => React.JSX.Element;
|
|
85
|
+
export declare const DateField: <DateType extends DateValue>({ selectedDate, onChange, label, locale: customLocale, showTimeZone, showTime, granularity, disabled, readOnly, isDisabled, variant, feedback, validationVariant, validationFeedback, labelTooltip, minDate, maxDate, forcedReturnType, style, className, labelProps: parentLabelProps, append, prepend, dateFieldRef: ref, ...rest }: DateFieldProps<DateType>) => React.JSX.Element;
|
|
85
86
|
export {};
|
|
@@ -39,4 +39,4 @@ export type DatePickerProps<DateType extends DateValue> = Omit<DateFieldProps<Da
|
|
|
39
39
|
*/
|
|
40
40
|
ariaLabelForDate?: (date: CalendarDate) => string;
|
|
41
41
|
};
|
|
42
|
-
export declare const DatePicker: <DateType extends DateValue>({ selectedDate, locale, disabled, showTime, showTimeZone, classNameForDate, className, variant, feedback, validationVariant, validationFeedback, showWeekNumbers, weekNumberHeader, disableModal, labelTooltip, navigationDescription, minDate, maxDate, modalTreshold, forcedReturnType, ariaLabelForDate, append, prepend, granularity, ...rest }: DatePickerProps<DateType>) => React.JSX.Element;
|
|
42
|
+
export declare const DatePicker: <DateType extends DateValue>({ selectedDate, locale, disabled, readOnly, showTime, showTimeZone, classNameForDate, className, variant, feedback, validationVariant, validationFeedback, showWeekNumbers, weekNumberHeader, disableModal, labelTooltip, navigationDescription, minDate, maxDate, modalTreshold, forcedReturnType, ariaLabelForDate, append, prepend, granularity, ...rest }: DatePickerProps<DateType>) => React.JSX.Element;
|
|
@@ -47,6 +47,7 @@ export type TimePickerProps<TimeType extends TimeValue> = {
|
|
|
47
47
|
variant?: VariantType | typeof error | typeof info;
|
|
48
48
|
labelTooltip?: React.ReactNode;
|
|
49
49
|
disabled?: boolean;
|
|
50
|
+
readOnly?: boolean;
|
|
50
51
|
inputRef?: React.ForwardedRef<HTMLDivElement>;
|
|
51
52
|
/** Tvinger typen på onChange til den gitte typen.
|
|
52
53
|
* Dette er nyttig når utgangsverdien din er 'null', men du ønsker at
|
|
@@ -63,5 +64,5 @@ export type TimePickerProps<TimeType extends TimeValue> = {
|
|
|
63
64
|
className?: string;
|
|
64
65
|
style?: React.CSSProperties;
|
|
65
66
|
} & Omit<AriaTimeFieldProps<TimeType>, 'value' | 'onChange' | 'label' | 'hideTimeZone' | 'placeholder' | 'minValue' | 'maxValue'> & Omit<Partial<BaseFormControlProps>, 'children' | 'label'>;
|
|
66
|
-
export declare const TimePicker: <TimeType extends TimeValue>({ selectedTime, onChange, disabled, className, style, label, labelTooltip, feedback, granularity, variant, locale: customLocale, showTimeZone, showSeconds, minuteIncrementForArrowButtons, leftArrowButtonAriaLabel, rightArrowButtonAriaLabel, inputRef, forcedReturnType, forcedTimeZone, append, prepend, ...rest }: TimePickerProps<TimeType>) => React.JSX.Element;
|
|
67
|
+
export declare const TimePicker: <TimeType extends TimeValue>({ selectedTime, onChange, disabled, readOnly, className, style, label, labelTooltip, feedback, granularity, variant, locale: customLocale, showTimeZone, showSeconds, minuteIncrementForArrowButtons, leftArrowButtonAriaLabel, rightArrowButtonAriaLabel, inputRef, forcedReturnType, forcedTimeZone, append, prepend, ...rest }: TimePickerProps<TimeType>) => React.JSX.Element;
|
|
67
68
|
export {};
|
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
type TimePickerArrowButtonProps = {
|
|
3
3
|
direction: 'left' | 'right';
|
|
4
4
|
disabled?: boolean;
|
|
5
|
+
readonly?: boolean;
|
|
5
6
|
'aria-label': string;
|
|
6
7
|
onClick?: () => void;
|
|
7
8
|
onFocus?: () => void;
|
|
8
9
|
};
|
|
9
|
-
export declare const TimePickerArrowButton: ({ direction, onClick, disabled, "aria-label": ariaLabel, ...rest }: TimePickerArrowButtonProps) => React.JSX.Element;
|
|
10
|
+
export declare const TimePickerArrowButton: ({ direction, onClick, disabled, readonly, "aria-label": ariaLabel, ...rest }: TimePickerArrowButtonProps) => React.JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -220,7 +220,7 @@ function handleOnChange(_ref2) {
|
|
|
220
220
|
onChange == null || onChange(value);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
var _excluded$a = ["selectedDate", "onChange", "label", "locale", "showTimeZone", "showTime", "granularity", "disabled", "isDisabled", "variant", "feedback", "validationVariant", "validationFeedback", "labelTooltip", "minDate", "maxDate", "forcedReturnType", "style", "className", "labelProps", "append", "prepend", "dateFieldRef"];
|
|
223
|
+
var _excluded$a = ["selectedDate", "onChange", "label", "locale", "showTimeZone", "showTime", "granularity", "disabled", "readOnly", "isDisabled", "variant", "feedback", "validationVariant", "validationFeedback", "labelTooltip", "minDate", "maxDate", "forcedReturnType", "style", "className", "labelProps", "append", "prepend", "dateFieldRef"];
|
|
224
224
|
var DateField = function DateField(_ref) {
|
|
225
225
|
var selectedDate = _ref.selectedDate,
|
|
226
226
|
_onChange = _ref.onChange,
|
|
@@ -231,6 +231,7 @@ var DateField = function DateField(_ref) {
|
|
|
231
231
|
_ref$granularity = _ref.granularity,
|
|
232
232
|
granularity = _ref$granularity === void 0 ? showTime ? 'minute' : 'day' : _ref$granularity,
|
|
233
233
|
disabled = _ref.disabled,
|
|
234
|
+
readOnly = _ref.readOnly,
|
|
234
235
|
isDisabled = _ref.isDisabled,
|
|
235
236
|
variant = _ref.variant,
|
|
236
237
|
feedback = _ref.feedback,
|
|
@@ -269,7 +270,7 @@ var DateField = function DateField(_ref) {
|
|
|
269
270
|
minValue: minDate,
|
|
270
271
|
// this weird logic makes sure the entire day is included if no time is provided in maxDate
|
|
271
272
|
maxValue: 'hour' in (maxDate != null ? maxDate : {}) ? maxDate : maxDate !== undefined ? lastMillisecondOfDay(maxDate) : undefined,
|
|
272
|
-
isDisabled: isDisabled || disabled,
|
|
273
|
+
isDisabled: isDisabled || disabled || readOnly,
|
|
273
274
|
shouldForceLeadingZeros: true
|
|
274
275
|
});
|
|
275
276
|
var state = datepicker$1.useDateFieldState(_props);
|
|
@@ -292,6 +293,7 @@ var DateField = function DateField(_ref) {
|
|
|
292
293
|
'eds-datefield--has-tooltip': labelTooltip !== undefined
|
|
293
294
|
}),
|
|
294
295
|
disabled: isDisabled || disabled,
|
|
296
|
+
readOnly: readOnly,
|
|
295
297
|
disableLabelAnimation: true,
|
|
296
298
|
feedback: feedback != null ? feedback : state.validationState === 'invalid' ? validationFeedback : undefined,
|
|
297
299
|
label: label,
|
|
@@ -524,11 +526,12 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
524
526
|
})));
|
|
525
527
|
};
|
|
526
528
|
|
|
527
|
-
var _excluded$5 = ["selectedDate", "locale", "disabled", "showTime", "showTimeZone", "classNameForDate", "className", "variant", "feedback", "validationVariant", "validationFeedback", "showWeekNumbers", "weekNumberHeader", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "forcedReturnType", "ariaLabelForDate", "append", "prepend", "granularity"];
|
|
529
|
+
var _excluded$5 = ["selectedDate", "locale", "disabled", "readOnly", "showTime", "showTimeZone", "classNameForDate", "className", "variant", "feedback", "validationVariant", "validationFeedback", "showWeekNumbers", "weekNumberHeader", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "forcedReturnType", "ariaLabelForDate", "append", "prepend", "granularity"];
|
|
528
530
|
var DatePicker = function DatePicker(_ref) {
|
|
529
531
|
var selectedDate = _ref.selectedDate,
|
|
530
532
|
locale = _ref.locale,
|
|
531
533
|
disabled = _ref.disabled,
|
|
534
|
+
readOnly = _ref.readOnly,
|
|
532
535
|
showTime = _ref.showTime,
|
|
533
536
|
_ref$showTimeZone = _ref.showTimeZone,
|
|
534
537
|
showTimeZone = _ref$showTimeZone === void 0 ? false : _ref$showTimeZone,
|
|
@@ -565,7 +568,7 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
565
568
|
maxValue: 'hour' in (maxDate != null ? maxDate : {}) ? maxDate : maxDate !== undefined ? lastMillisecondOfDay(maxDate) : undefined,
|
|
566
569
|
value: selectedDate,
|
|
567
570
|
granularity: granularity,
|
|
568
|
-
isDisabled: disabled
|
|
571
|
+
isDisabled: disabled || readOnly
|
|
569
572
|
});
|
|
570
573
|
var state = datepicker$1.useDatePickerState(_props);
|
|
571
574
|
var _useDatePicker = datepicker.useDatePicker(_props, state, datePickerRef),
|
|
@@ -639,7 +642,7 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
639
642
|
}, child);
|
|
640
643
|
}
|
|
641
644
|
}, React.createElement(DateField, _extends({}, groupProps, fieldProps, rest, {
|
|
642
|
-
append: !disabled && React.createElement("div", {
|
|
645
|
+
append: !disabled && !readOnly && React.createElement("div", {
|
|
643
646
|
style: {
|
|
644
647
|
display: 'flex',
|
|
645
648
|
alignItems: 'center'
|
|
@@ -656,6 +659,7 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
656
659
|
'eds-datepicker--disabled': disabled
|
|
657
660
|
}),
|
|
658
661
|
disabled: disabled,
|
|
662
|
+
readOnly: readOnly,
|
|
659
663
|
feedback: feedback,
|
|
660
664
|
labelProps: labelProps,
|
|
661
665
|
labelTooltip: labelTooltip,
|
|
@@ -747,7 +751,7 @@ var NativeDatePickerBase = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
747
751
|
}, rest));
|
|
748
752
|
});
|
|
749
753
|
|
|
750
|
-
var _excluded$3 = ["direction", "onClick", "disabled", "aria-label"];
|
|
754
|
+
var _excluded$3 = ["direction", "onClick", "disabled", "readonly", "aria-label"];
|
|
751
755
|
var TimePickerArrowButton = function TimePickerArrowButton(_ref) {
|
|
752
756
|
var direction = _ref.direction,
|
|
753
757
|
onClick = _ref.onClick,
|
|
@@ -766,11 +770,12 @@ var TimePickerArrowButton = function TimePickerArrowButton(_ref) {
|
|
|
766
770
|
}, rest), direction === 'left' ? React.createElement(icons.LeftArrowIcon, null) : React.createElement(icons.RightArrowIcon, null));
|
|
767
771
|
};
|
|
768
772
|
|
|
769
|
-
var _excluded$2 = ["selectedTime", "onChange", "disabled", "className", "style", "label", "labelTooltip", "feedback", "granularity", "variant", "locale", "showTimeZone", "showSeconds", "minuteIncrementForArrowButtons", "leftArrowButtonAriaLabel", "rightArrowButtonAriaLabel", "inputRef", "forcedReturnType", "forcedTimeZone", "append", "prepend"];
|
|
773
|
+
var _excluded$2 = ["selectedTime", "onChange", "disabled", "readOnly", "className", "style", "label", "labelTooltip", "feedback", "granularity", "variant", "locale", "showTimeZone", "showSeconds", "minuteIncrementForArrowButtons", "leftArrowButtonAriaLabel", "rightArrowButtonAriaLabel", "inputRef", "forcedReturnType", "forcedTimeZone", "append", "prepend"];
|
|
770
774
|
var TimePicker = function TimePicker(_ref) {
|
|
771
775
|
var selectedTime = _ref.selectedTime,
|
|
772
776
|
onChange = _ref.onChange,
|
|
773
777
|
disabled = _ref.disabled,
|
|
778
|
+
readOnly = _ref.readOnly,
|
|
774
779
|
className = _ref.className,
|
|
775
780
|
style = _ref.style,
|
|
776
781
|
label = _ref.label,
|
|
@@ -816,7 +821,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
816
821
|
value: selectedTime,
|
|
817
822
|
granularity: (granularity != null ? granularity : showSeconds) ? 'second' : 'minute',
|
|
818
823
|
hideTimeZone: !showTimeZone,
|
|
819
|
-
isDisabled: disabled,
|
|
824
|
+
isDisabled: disabled || readOnly,
|
|
820
825
|
shouldForceLeadingZeros: true
|
|
821
826
|
}, rest));
|
|
822
827
|
var timeFieldRef = React.useRef(null);
|
|
@@ -856,7 +861,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
856
861
|
}
|
|
857
862
|
}, append, React.createElement(TimePickerArrowButton, {
|
|
858
863
|
direction: "right",
|
|
859
|
-
disabled: disabled,
|
|
864
|
+
disabled: disabled || readOnly,
|
|
860
865
|
"aria-label": rightArrowButtonAriaLabel,
|
|
861
866
|
onClick: function onClick() {
|
|
862
867
|
return handleOnClickArrowButton('add');
|
|
@@ -869,9 +874,11 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
869
874
|
"aria-describedby": timePickerId + 'description',
|
|
870
875
|
className: classNames('eds-timepicker', className, {
|
|
871
876
|
'eds-timepicker--disabled': disabled,
|
|
872
|
-
'eds-timepicker--has-tooltip': labelTooltip !== undefined
|
|
877
|
+
'eds-timepicker--has-tooltip': labelTooltip !== undefined,
|
|
878
|
+
'eds-timepicker--readonly': readOnly
|
|
873
879
|
}),
|
|
874
880
|
disabled: disabled,
|
|
881
|
+
readOnly: readOnly,
|
|
875
882
|
disableLabelAnimation: true,
|
|
876
883
|
feedback: feedback,
|
|
877
884
|
label: label,
|
|
@@ -887,7 +894,7 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
887
894
|
}
|
|
888
895
|
}, React.createElement(TimePickerArrowButton, {
|
|
889
896
|
direction: "left",
|
|
890
|
-
disabled: disabled,
|
|
897
|
+
disabled: disabled || readOnly,
|
|
891
898
|
"aria-label": leftArrowButtonAriaLabel,
|
|
892
899
|
onClick: function onClick() {
|
|
893
900
|
return handleOnClickArrowButton('subtract');
|