@entur/datepicker 9.1.6 → 9.2.0-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.
@@ -290,15 +290,17 @@ var CalendarButton = function CalendarButton(_ref) {
290
290
  }), children);
291
291
  };
292
292
 
293
- var _excluded$8 = ["state", "date", "onSelectedCellClick"];
293
+ var _excluded$8 = ["state", "date", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"];
294
294
  var CalendarCell = function CalendarCell(_ref) {
295
- var _state$timeZone;
295
+ var _ariaLabelForDate, _classNameForDate, _state$timeZone;
296
296
  var state = _ref.state,
297
297
  date = _ref.date,
298
298
  _ref$onSelectedCellCl = _ref.onSelectedCellClick,
299
299
  onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
300
300
  return;
301
301
  } : _ref$onSelectedCellCl,
302
+ classNameForDate = _ref.classNameForDate,
303
+ ariaLabelForDate = _ref.ariaLabelForDate,
302
304
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
303
305
  var cellRef = useRef(null);
304
306
  var _useCalendarCell = useCalendarCell({
@@ -311,12 +313,14 @@ var CalendarCell = function CalendarCell(_ref) {
311
313
  isDisabled = _useCalendarCell.isDisabled,
312
314
  isUnavailable = _useCalendarCell.isUnavailable,
313
315
  formattedDate = _useCalendarCell.formattedDate;
316
+ var ariaLabel = buttonProps['aria-label'] + " " + ((_ariaLabelForDate = ariaLabelForDate == null ? void 0 : ariaLabelForDate(date)) != null ? _ariaLabelForDate : '');
314
317
  return React.createElement("td", _extends({}, cellProps, {
315
318
  className: "eds-datepicker__calendar__grid__cell__td"
316
319
  }), React.createElement("div", _extends({}, buttonProps, {
320
+ "aria-label": ariaLabel,
317
321
  ref: cellRef,
318
322
  hidden: isOutsideVisibleRange,
319
- className: classNames('eds-datepicker__calendar__grid__cell', {
323
+ className: classNames('eds-datepicker__calendar__grid__cell', [(_classNameForDate = classNameForDate == null ? void 0 : classNameForDate(date)) != null ? _classNameForDate : ''], {
320
324
  'eds-datepicker__calendar__grid__cell--selected': isSelected,
321
325
  'eds-datepicker__calendar__grid__cell--disabled': isDisabled || isUnavailable,
322
326
  'eds-datepicker__calendar__grid__cell--outside-month': isOutsideVisibleRange,
@@ -334,7 +338,7 @@ var CalendarCell = function CalendarCell(_ref) {
334
338
  }), formattedDate));
335
339
  };
336
340
 
337
- var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick"];
341
+ var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"];
338
342
  var CalendarGrid = function CalendarGrid(_ref) {
339
343
  var state = _ref.state,
340
344
  navigationDescription = _ref.navigationDescription,
@@ -342,6 +346,8 @@ var CalendarGrid = function CalendarGrid(_ref) {
342
346
  onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
343
347
  return;
344
348
  } : _ref$onSelectedCellCl,
349
+ classNameForDate = _ref.classNameForDate,
350
+ ariaLabelForDate = _ref.ariaLabelForDate,
345
351
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
346
352
  var calendarGridId = useRandomId('eds-calendar');
347
353
  var _useLocale = useLocale(),
@@ -383,7 +389,9 @@ var CalendarGrid = function CalendarGrid(_ref) {
383
389
  state: state,
384
390
  date: date,
385
391
  "aria-describedby": calendarGridId + 'description',
386
- onSelectedCellClick: onSelectedCellClick
392
+ onSelectedCellClick: onSelectedCellClick,
393
+ classNameForDate: classNameForDate,
394
+ ariaLabelForDate: ariaLabelForDate
387
395
  }) : React.createElement("td", {
388
396
  key: i
389
397
  });
@@ -393,7 +401,7 @@ var CalendarGrid = function CalendarGrid(_ref) {
393
401
  }, getNavigationDescription()));
394
402
  };
395
403
 
396
- var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "children", "navigationDescription", "onSelectedCellClick"];
404
+ var _excluded$6 = ["selectedDate", "onChange", "locale", "minDate", "maxDate", "style", "children", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate"];
397
405
  var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
398
406
  var selectedDate = _ref.selectedDate,
399
407
  onChange = _ref.onChange,
@@ -406,6 +414,8 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
406
414
  onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
407
415
  return;
408
416
  } : _ref$onSelectedCellCl,
417
+ classNameForDate = _ref.classNameForDate,
418
+ ariaLabelForDate = _ref.ariaLabelForDate,
409
419
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
410
420
  var _useLocale = useLocale(),
411
421
  locale = _useLocale.locale;
@@ -447,11 +457,13 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
447
457
  }))), React.createElement(CalendarGrid, {
448
458
  state: state,
449
459
  navigationDescription: navigationDescription,
450
- onSelectedCellClick: onSelectedCellClick
460
+ onSelectedCellClick: onSelectedCellClick,
461
+ classNameForDate: classNameForDate,
462
+ ariaLabelForDate: ariaLabelForDate
451
463
  })));
452
464
  });
453
465
 
454
- var _excluded$5 = ["selectedDate", "onChange", "locale", "disabled", "showTime", "showTimeZone", "className", "style", "variant", "feedback", "validationVariant", "validationFeedback", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "forcedReturnType"];
466
+ var _excluded$5 = ["selectedDate", "onChange", "locale", "disabled", "showTime", "showTimeZone", "classNameForDate", "className", "style", "variant", "feedback", "validationVariant", "validationFeedback", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "forcedReturnType", "ariaLabelForDate"];
455
467
  var DatePicker = function DatePicker(_ref) {
456
468
  var selectedDate = _ref.selectedDate,
457
469
  onChange = _ref.onChange,
@@ -460,6 +472,7 @@ var DatePicker = function DatePicker(_ref) {
460
472
  showTime = _ref.showTime,
461
473
  _ref$showTimeZone = _ref.showTimeZone,
462
474
  showTimeZone = _ref$showTimeZone === void 0 ? false : _ref$showTimeZone,
475
+ classNameForDate = _ref.classNameForDate,
463
476
  className = _ref.className,
464
477
  variant = _ref.variant,
465
478
  feedback = _ref.feedback,
@@ -474,6 +487,7 @@ var DatePicker = function DatePicker(_ref) {
474
487
  _ref$modalTreshold = _ref.modalTreshold,
475
488
  modalTreshold = _ref$modalTreshold === void 0 ? 1000 : _ref$modalTreshold,
476
489
  forcedReturnType = _ref.forcedReturnType,
490
+ ariaLabelForDate = _ref.ariaLabelForDate,
477
491
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
478
492
  var CALENDAR_MODAL_MAX_SCREEN_WIDTH = modalTreshold;
479
493
  var datePickerRef = useRef(null);
@@ -536,7 +550,9 @@ var DatePicker = function DatePicker(_ref) {
536
550
  onChange: handleOnChange,
537
551
  minDate: minDate,
538
552
  maxDate: maxDate,
539
- ref: calendarRef
553
+ ref: calendarRef,
554
+ classNameForDate: classNameForDate,
555
+ ariaLabelForDate: ariaLabelForDate
540
556
  });
541
557
  var useModal = typeof width !== 'undefined' && width <= CALENDAR_MODAL_MAX_SCREEN_WIDTH && !disableModal;
542
558
  var popoverCalendar = React.createElement("div", {