@entur/datepicker 12.0.2 → 12.1.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.
@@ -85,5 +85,5 @@ export type BaseDateFieldProps<DateType extends DateValue> = {
85
85
  style?: React.CSSProperties;
86
86
  };
87
87
  export type DateFieldProps<DateType extends DateValue> = BaseDateFieldProps<DateType> & ExtendedDateFieldProps<DateType>;
88
- 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, onValidate, dateFieldRef: ref, ...rest }: DateFieldProps<DateType>) => import("react/jsx-runtime").JSX.Element;
88
+ 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, onValidate, dateFieldRef: ref, ariaAlertOnFeedback, feedbackProps, ...rest }: DateFieldProps<DateType>) => import("react/jsx-runtime").JSX.Element;
89
89
  export {};
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { FeedbackAnnouncementProps } from '../../../form';
2
3
  import { VariantType } from '../../../utils';
3
4
  /** @deprecated use variant="information" instead */
4
5
  declare const info = "info";
@@ -21,7 +22,7 @@ export type NativeDatePickerProps = {
21
22
  * @default <DateIcon />
22
23
  */
23
24
  prepend?: React.ReactNode;
24
- } & React.InputHTMLAttributes<HTMLInputElement>;
25
+ } & FeedbackAnnouncementProps & React.InputHTMLAttributes<HTMLInputElement>;
25
26
  export declare const NativeDatePicker: React.ForwardRefExoticComponent<{
26
27
  /** Ekstra klassenavn */
27
28
  className?: string;
@@ -39,5 +40,5 @@ export declare const NativeDatePicker: React.ForwardRefExoticComponent<{
39
40
  * @default <DateIcon />
40
41
  */
41
42
  prepend?: React.ReactNode;
42
- } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
43
+ } & FeedbackAnnouncementProps & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
43
44
  export {};
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { FeedbackAnnouncementProps } from '../../../form';
2
3
  import { VariantType } from '../../../utils';
3
4
  /** @deprecated use variant="information" instead */
4
5
  declare const info = "info";
@@ -15,7 +16,7 @@ export type NativeTimePickerProps = {
15
16
  variant?: VariantType | typeof error | typeof info;
16
17
  /** Tekst eller ikon som kommer før inputfelter */
17
18
  prepend?: React.ReactNode;
18
- } & React.InputHTMLAttributes<HTMLInputElement>;
19
+ } & FeedbackAnnouncementProps & React.InputHTMLAttributes<HTMLInputElement>;
19
20
  export declare const NativeTimePicker: React.ForwardRefExoticComponent<{
20
21
  /** Ekstra klassenavn */
21
22
  className?: string;
@@ -27,5 +28,5 @@ export declare const NativeTimePicker: React.ForwardRefExoticComponent<{
27
28
  variant?: VariantType | typeof error | typeof info;
28
29
  /** Tekst eller ikon som kommer før inputfelter */
29
30
  prepend?: React.ReactNode;
30
- } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
31
+ } & FeedbackAnnouncementProps & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
31
32
  export {};
@@ -44,5 +44,5 @@ type BaseSimpleTimePickerProps<TimeType extends TimeValue> = {
44
44
  style?: React.CSSProperties;
45
45
  };
46
46
  export type SimpleTimePickerProps<TimeType extends TimeValue> = BaseSimpleTimePickerProps<TimeType> & ExtendedSimpleTimePickerProps<TimeType>;
47
- export declare const SimpleTimePicker: <TimeType extends TimeValue>({ append, className, disabled, feedback, showClockIcon, inputRef, label, labelTooltip, onChange, padding, prepend, readOnly, selectedTime, showSeconds, style, variant, ...rest }: SimpleTimePickerProps<TimeType>) => import("react/jsx-runtime").JSX.Element;
47
+ export declare const SimpleTimePicker: <TimeType extends TimeValue>({ append, className, disabled, feedback, showClockIcon, inputRef, label, labelTooltip, onChange, padding, prepend, readOnly, selectedTime, showSeconds, style, variant, ariaAlertOnFeedback, feedbackProps, ...rest }: SimpleTimePickerProps<TimeType>) => import("react/jsx-runtime").JSX.Element;
48
48
  export {};
@@ -65,5 +65,5 @@ type BaseTimePickerProps<TimeType extends TimeValue> = {
65
65
  style?: React.CSSProperties;
66
66
  };
67
67
  export type TimePickerProps<TimeType extends TimeValue> = BaseTimePickerProps<TimeType> & ExtendedTimePickerProps<TimeType>;
68
- 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>) => import("react/jsx-runtime").JSX.Element;
68
+ 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, ariaAlertOnFeedback, feedbackProps, ...rest }: TimePickerProps<TimeType>) => import("react/jsx-runtime").JSX.Element;
69
69
  export {};
@@ -197,16 +197,6 @@ function getAdjustedMaxDate(maxDate) {
197
197
  if (maxDate !== void 0) return lastMillisecondOfDay(maxDate);
198
198
  return void 0;
199
199
  }
200
- function shouldUseAriaAlert(variant) {
201
- if (!variant) return false;
202
- if (variant === "negative" || variant === "error") {
203
- return "alert";
204
- }
205
- if (variant === "warning") {
206
- return "status";
207
- }
208
- return false;
209
- }
210
200
  const DateField = ({
211
201
  // normalize undefined to null so the field stays controlled and empty
212
202
  selectedDate = null,
@@ -234,6 +224,8 @@ const DateField = ({
234
224
  prepend,
235
225
  onValidate,
236
226
  dateFieldRef: ref,
227
+ ariaAlertOnFeedback,
228
+ feedbackProps,
237
229
  ...rest
238
230
  }) => {
239
231
  const { locale } = i18n.useLocale();
@@ -270,9 +262,8 @@ const DateField = ({
270
262
  form.BaseFormControl,
271
263
  {
272
264
  append,
273
- ariaAlertOnFeedback: shouldUseAriaAlert(
274
- variant ?? (state.isInvalid ? validationVariant : void 0)
275
- ),
265
+ ariaAlertOnFeedback,
266
+ feedbackProps,
276
267
  className: classNames("eds-datefield", className, {
277
268
  "eds-datefield--has-tooltip": labelTooltip !== void 0
278
269
  }),
@@ -950,6 +941,7 @@ const DatePicker = ({
950
941
  }
951
942
  );
952
943
  };
944
+ const error$1 = "error";
953
945
  const NativeDatePicker = React.forwardRef(
954
946
  ({
955
947
  className,
@@ -960,6 +952,8 @@ const NativeDatePicker = React.forwardRef(
960
952
  variant,
961
953
  disableLabelAnimation,
962
954
  prepend = /* @__PURE__ */ jsxRuntime.jsx(icons.DateIcon, { inline: true }),
955
+ ariaAlertOnFeedback,
956
+ feedbackProps,
963
957
  ...rest
964
958
  }, ref) => {
965
959
  const nativedatepickerId = `eds-nativetimepicker${React.useId()}`;
@@ -974,6 +968,8 @@ const NativeDatePicker = React.forwardRef(
974
968
  variant,
975
969
  labelId: nativedatepickerId,
976
970
  disableLabelAnimation,
971
+ ariaAlertOnFeedback,
972
+ feedbackProps,
977
973
  isFilled: true,
978
974
  children: /* @__PURE__ */ jsxRuntime.jsx(
979
975
  NativeDatePickerBase,
@@ -1017,7 +1013,7 @@ const NativeDatePickerBase = React.forwardRef(({ onChange, variant, value, ...re
1017
1013
  "input",
1018
1014
  {
1019
1015
  ref,
1020
- "aria-invalid": currentVariant === "error",
1016
+ "aria-invalid": currentVariant === "negative" || currentVariant === error$1,
1021
1017
  type: "date",
1022
1018
  className: "eds-form-control eds-native-date-picker",
1023
1019
  onChange: handleChange,
@@ -1076,6 +1072,8 @@ const TimePicker = ({
1076
1072
  forcedTimeZone,
1077
1073
  append,
1078
1074
  prepend,
1075
+ ariaAlertOnFeedback,
1076
+ feedbackProps,
1079
1077
  ...rest
1080
1078
  }) => {
1081
1079
  let { locale } = i18n.useLocale();
@@ -1152,7 +1150,8 @@ const TimePicker = ({
1152
1150
  }
1153
1151
  )
1154
1152
  ] }),
1155
- ariaAlertOnFeedback: shouldUseAriaAlert(variant),
1153
+ ariaAlertOnFeedback,
1154
+ feedbackProps,
1156
1155
  "aria-describedby": timePickerId + "description",
1157
1156
  className: classNames("eds-timepicker", className, {
1158
1157
  "eds-timepicker--disabled": disabled,
@@ -1209,8 +1208,20 @@ const TimePicker = ({
1209
1208
  }
1210
1209
  ) });
1211
1210
  };
1211
+ const error = "error";
1212
1212
  const NativeTimePicker = React.forwardRef(
1213
- ({ className, style, onChange, label, feedback, variant, prepend, ...rest }, ref) => {
1213
+ ({
1214
+ className,
1215
+ style,
1216
+ onChange,
1217
+ label,
1218
+ feedback,
1219
+ variant,
1220
+ prepend,
1221
+ ariaAlertOnFeedback,
1222
+ feedbackProps,
1223
+ ...rest
1224
+ }, ref) => {
1214
1225
  const nativetimepickerId = `eds-native-timepicker${React.useId()}`;
1215
1226
  return /* @__PURE__ */ jsxRuntime.jsx(
1216
1227
  form.BaseFormControl,
@@ -1223,6 +1234,8 @@ const NativeTimePicker = React.forwardRef(
1223
1234
  variant,
1224
1235
  labelId: nativetimepickerId,
1225
1236
  disableLabelAnimation: true,
1237
+ ariaAlertOnFeedback,
1238
+ feedbackProps,
1226
1239
  children: /* @__PURE__ */ jsxRuntime.jsx(
1227
1240
  NativeTimePickerBase,
1228
1241
  {
@@ -1264,7 +1277,7 @@ const NativeTimePickerBase = React.forwardRef(({ onChange, value, ...rest }, ref
1264
1277
  "input",
1265
1278
  {
1266
1279
  ref,
1267
- "aria-invalid": currentVariant === "error",
1280
+ "aria-invalid": currentVariant === "negative" || currentVariant === error,
1268
1281
  type: "time",
1269
1282
  className: "eds-form-control",
1270
1283
  onChange: handleChange,
@@ -1291,6 +1304,8 @@ const SimpleTimePicker = ({
1291
1304
  showSeconds,
1292
1305
  style,
1293
1306
  variant,
1307
+ ariaAlertOnFeedback,
1308
+ feedbackProps,
1294
1309
  ...rest
1295
1310
  }) => {
1296
1311
  const [inputText, setInputText] = React.useState("");
@@ -1427,6 +1442,8 @@ const SimpleTimePicker = ({
1427
1442
  disabled,
1428
1443
  disableLabelAnimation: true,
1429
1444
  feedback,
1445
+ ariaAlertOnFeedback,
1446
+ feedbackProps,
1430
1447
  label,
1431
1448
  labelProps,
1432
1449
  labelTooltip,
@@ -1492,6 +1509,5 @@ exports.lastMillisecondOfDay = lastMillisecondOfDay;
1492
1509
  exports.modulo = modulo;
1493
1510
  exports.nativeDateToDateValue = nativeDateToDateValue;
1494
1511
  exports.nativeDateToTimeValue = nativeDateToTimeValue;
1495
- exports.shouldUseAriaAlert = shouldUseAriaAlert;
1496
1512
  exports.timeOrDateValueToNativeDate = timeOrDateValueToNativeDate;
1497
1513
  //# sourceMappingURL=datepicker.cjs.map