@helsenorge/datepicker 14.1.0 → 14.2.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.
@@ -147,7 +147,6 @@ var BaseDayPicker = (props) => {
147
147
  const mergedLabels = {
148
148
  labelNext: () => mergedResources.nextMonth,
149
149
  labelPrevious: () => mergedResources.previousMonth,
150
- labelDayButton: () => mergedResources.dayButtonBase,
151
150
  labelMonthDropdown: () => mergedResources.monthDropdown,
152
151
  labelYearDropdown: () => mergedResources.yearDropdown,
153
152
  ...labelsForCalendar
@@ -234,6 +233,13 @@ var BaseDayPicker = (props) => {
234
233
  const handleClick = () => {
235
234
  handleDayButtonClick(day, modifiers$1);
236
235
  };
236
+ const ariaLabel = () => {
237
+ const dateString = format(day.date, "PPPP", { locale: localeForCalendar });
238
+ let label = mergedResources.dayButtonBase.replace("{date}", dateString);
239
+ if (modifiers$1.today && mergedResources.dayButtonToday) label = mergedResources.dayButtonToday.replace("{date}", dateString);
240
+ if (modifiers$1.selected && mergedResources.dayButtonSelected) label = mergedResources.dayButtonSelected.replace("{date}", dateString);
241
+ return label;
242
+ };
237
243
  React.useEffect(() => {
238
244
  if (modifiers$1.focused) buttonRef.current?.focus();
239
245
  }, [modifiers$1.focused]);
@@ -242,7 +248,8 @@ var BaseDayPicker = (props) => {
242
248
  disabled: buttonProps.disabled,
243
249
  className: classNames(rdpClassnames["day_button"], customstyles["custom_day_button"]),
244
250
  ref: buttonRef,
245
- onClick: handleClick
251
+ onClick: handleClick,
252
+ "aria-label": ariaLabel()
246
253
  }) });
247
254
  },
248
255
  NextMonthButton: (props$1) => /* @__PURE__ */ jsx(CustomNextButton, { ...props$1 }),