@entur/datepicker 12.0.0 → 12.0.2-beta.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.
|
@@ -6,7 +6,7 @@ import { VariantType } from '../../../utils';
|
|
|
6
6
|
declare const info = "info";
|
|
7
7
|
/** @deprecated use variant="negative" instead */
|
|
8
8
|
declare const error = "error";
|
|
9
|
-
type ExtendedSimpleTimePickerProps<TimeType extends TimeValue> = Omit<AriaTimeFieldProps<TimeType>, keyof BaseSimpleTimePickerProps<TimeType> | 'value' | 'hideTimeZone' | 'placeholder' | 'minValue' | 'maxValue' | 'locale' | 'isReadOnly' | 'isDisabled' | 'locale'> & Omit<Partial<BaseFormControlProps>, keyof BaseSimpleTimePickerProps<TimeType> | 'children' | 'defaultValue' | 'value' | 'isFilled' | 'size'>;
|
|
9
|
+
type ExtendedSimpleTimePickerProps<TimeType extends TimeValue> = Omit<AriaTimeFieldProps<TimeType>, keyof BaseSimpleTimePickerProps<TimeType> | 'value' | 'defaultValue' | 'hideTimeZone' | 'placeholder' | 'minValue' | 'maxValue' | 'locale' | 'isReadOnly' | 'isDisabled' | 'locale'> & Omit<Partial<BaseFormControlProps>, keyof BaseSimpleTimePickerProps<TimeType> | 'children' | 'defaultValue' | 'value' | 'isFilled' | 'size'>;
|
|
10
10
|
type BaseSimpleTimePickerProps<TimeType extends TimeValue> = {
|
|
11
11
|
/** Den valgte tiden. Tid i '@internationalized/date'-pakkens format */
|
|
12
12
|
selectedTime: TimeType | null;
|
|
@@ -6,7 +6,7 @@ import { VariantType } from '../../../utils';
|
|
|
6
6
|
declare const info = "info";
|
|
7
7
|
/** @deprecated use variant="negative" instead */
|
|
8
8
|
declare const error = "error";
|
|
9
|
-
type ExtendedTimePickerProps<TimeType extends TimeValue> = Omit<AriaTimeFieldProps<TimeType>, keyof BaseTimePickerProps<TimeValue> | 'value' | 'hideTimeZone' | 'placeholder' | 'minValue' | 'maxValue'> & Omit<Partial<BaseFormControlProps>, keyof BaseTimePickerProps<TimeType> | 'children' | 'defaultValue' | 'value' | 'isFilled' | 'size'>;
|
|
9
|
+
type ExtendedTimePickerProps<TimeType extends TimeValue> = Omit<AriaTimeFieldProps<TimeType>, keyof BaseTimePickerProps<TimeValue> | 'value' | 'defaultValue' | 'hideTimeZone' | 'placeholder' | 'minValue' | 'maxValue'> & Omit<Partial<BaseFormControlProps>, keyof BaseTimePickerProps<TimeType> | 'children' | 'defaultValue' | 'value' | 'isFilled' | 'size'>;
|
|
10
10
|
type BaseTimePickerProps<TimeType extends TimeValue> = {
|
|
11
11
|
/** Den valgte tiden. Tid i '@internationalized/date'-pakkens format */
|
|
12
12
|
selectedTime: TimeType | null;
|
package/dist/datepicker.cjs
CHANGED
|
@@ -65,7 +65,7 @@ const nativeDateToDateTime = (date$1, timeZone, offset) => {
|
|
|
65
65
|
);
|
|
66
66
|
};
|
|
67
67
|
function nativeDateToDateValue(date$1, noTimeOnlyDate = false, timeZone, offset) {
|
|
68
|
-
if (date$1
|
|
68
|
+
if (date$1 == null) return null;
|
|
69
69
|
if (noTimeOnlyDate)
|
|
70
70
|
return new date.CalendarDate(
|
|
71
71
|
date$1.getFullYear(),
|
|
@@ -75,7 +75,7 @@ function nativeDateToDateValue(date$1, noTimeOnlyDate = false, timeZone, offset)
|
|
|
75
75
|
return nativeDateToDateTime(date$1, timeZone, offset);
|
|
76
76
|
}
|
|
77
77
|
function nativeDateToTimeValue(date$1, noDateOnlyTime = false, timeZone, offset) {
|
|
78
|
-
if (date$1
|
|
78
|
+
if (date$1 == null) return null;
|
|
79
79
|
if (noDateOnlyTime)
|
|
80
80
|
return new date.Time(
|
|
81
81
|
date$1.getHours(),
|
|
@@ -86,7 +86,7 @@ function nativeDateToTimeValue(date$1, noDateOnlyTime = false, timeZone, offset)
|
|
|
86
86
|
return nativeDateToDateTime(date$1, timeZone, offset);
|
|
87
87
|
}
|
|
88
88
|
function timeOrDateValueToNativeDate(value, timeZoneForCalendarDateTime) {
|
|
89
|
-
if (value
|
|
89
|
+
if (value == null) return null;
|
|
90
90
|
if (!("day" in value)) {
|
|
91
91
|
const date2 = /* @__PURE__ */ new Date();
|
|
92
92
|
date2.setHours(value.hour);
|
|
@@ -125,7 +125,7 @@ const convertValueToType = ({
|
|
|
125
125
|
type,
|
|
126
126
|
timezone = "Europe/Oslo"
|
|
127
127
|
}) => {
|
|
128
|
-
if (value
|
|
128
|
+
if (value == null) return null;
|
|
129
129
|
switch (type) {
|
|
130
130
|
case "CalendarDate":
|
|
131
131
|
if (!("day" in value)) return date.today(timezone);
|
|
@@ -162,7 +162,7 @@ const focusSegment = (ref, segment) => {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
function getWeekNumberForDate(date$1) {
|
|
165
|
-
if (date$1
|
|
165
|
+
if (date$1 == null) return -1;
|
|
166
166
|
const calendarDate = convertValueToType({
|
|
167
167
|
value: date$1,
|
|
168
168
|
type: "CalendarDate"
|
|
@@ -186,7 +186,7 @@ function handleOnChange({
|
|
|
186
186
|
convertValueToType({
|
|
187
187
|
value,
|
|
188
188
|
type: forcedReturnType ?? "ZonedDateTime",
|
|
189
|
-
timezone: (value
|
|
189
|
+
timezone: (value != null && "timeZone" in value ? value.timeZone : void 0) ?? (selectedDate != null && "timeZone" in selectedDate ? selectedDate.timeZone : void 0)
|
|
190
190
|
})
|
|
191
191
|
);
|
|
192
192
|
}
|
|
@@ -208,7 +208,8 @@ function shouldUseAriaAlert(variant) {
|
|
|
208
208
|
return false;
|
|
209
209
|
}
|
|
210
210
|
const DateField = ({
|
|
211
|
-
|
|
211
|
+
// normalize undefined to null so the field stays controlled and empty
|
|
212
|
+
selectedDate = null,
|
|
212
213
|
onChange,
|
|
213
214
|
label,
|
|
214
215
|
locale: customLocale,
|
|
@@ -555,7 +556,8 @@ const Calendar = ({
|
|
|
555
556
|
return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(_Calendar, { ...props }) });
|
|
556
557
|
};
|
|
557
558
|
const _Calendar = ({
|
|
558
|
-
|
|
559
|
+
// normalize undefined to null so the calendar stays controlled and empty
|
|
560
|
+
selectedDate = null,
|
|
559
561
|
onChange,
|
|
560
562
|
minDate,
|
|
561
563
|
maxDate,
|
|
@@ -716,7 +718,8 @@ const RangeCalendar = ({
|
|
|
716
718
|
return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(_RangeCalendar, { ...props }) });
|
|
717
719
|
};
|
|
718
720
|
const _RangeCalendar = ({
|
|
719
|
-
|
|
721
|
+
// normalize undefined to null so the calendar stays controlled and empty
|
|
722
|
+
value = null,
|
|
720
723
|
onChange,
|
|
721
724
|
minDate,
|
|
722
725
|
maxDate,
|
|
@@ -783,7 +786,8 @@ const _RangeCalendar = ({
|
|
|
783
786
|
);
|
|
784
787
|
};
|
|
785
788
|
const DatePicker = ({
|
|
786
|
-
|
|
789
|
+
// normalize undefined to null so the picker stays controlled and empty
|
|
790
|
+
selectedDate = null,
|
|
787
791
|
locale,
|
|
788
792
|
disabled,
|
|
789
793
|
readOnly,
|
|
@@ -1049,7 +1053,8 @@ const TimePickerArrowButton = ({
|
|
|
1049
1053
|
);
|
|
1050
1054
|
};
|
|
1051
1055
|
const TimePicker = ({
|
|
1052
|
-
|
|
1056
|
+
// normalize undefined to null so the picker stays controlled and empty
|
|
1057
|
+
selectedTime = null,
|
|
1053
1058
|
onChange,
|
|
1054
1059
|
disabled,
|
|
1055
1060
|
readOnly,
|
|
@@ -1281,7 +1286,8 @@ const SimpleTimePicker = ({
|
|
|
1281
1286
|
padding = "default",
|
|
1282
1287
|
prepend,
|
|
1283
1288
|
readOnly,
|
|
1284
|
-
|
|
1289
|
+
// normalize undefined to null so the picker stays controlled and empty
|
|
1290
|
+
selectedTime = null,
|
|
1285
1291
|
showSeconds,
|
|
1286
1292
|
style,
|
|
1287
1293
|
variant,
|