@entur/datepicker 11.1.0 → 11.1.1-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.
- package/dist/DatePicker/Calendar.d.ts +2 -0
- package/dist/DatePicker/CalendarCell.d.ts +2 -1
- package/dist/DatePicker/CalendarGrid.d.ts +2 -1
- package/dist/DatePicker/DatePicker.d.ts +1 -1
- package/dist/datepicker.cjs.development.js +45 -8
- 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 +45 -8
- package/dist/datepicker.esm.js.map +1 -1
- package/dist/styles.css +58 -58
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ type BaseCalendarProps<DateType extends DateValue> = {
|
|
|
13
13
|
/** Ekstra klassenavn */
|
|
14
14
|
className?: string;
|
|
15
15
|
onSelectedCellClick?: () => void;
|
|
16
|
+
onCellClick?: () => void;
|
|
16
17
|
/** Tidligste gyldige datovalg.
|
|
17
18
|
* Eks: today(getLocalTimeZone()) == i dag i lokal tidssone.
|
|
18
19
|
*
|
|
@@ -49,6 +50,7 @@ type BaseCalendarProps<DateType extends DateValue> = {
|
|
|
49
50
|
* @example (date) => isWeekend(date, 'no-NO') ? 'helgedag' : ''
|
|
50
51
|
*/
|
|
51
52
|
ariaLabelForDate?: (date: CalendarDate) => string;
|
|
53
|
+
disabled?: boolean;
|
|
52
54
|
locale?: string;
|
|
53
55
|
calendarRef?: React.MutableRefObject<HTMLDivElement | null>;
|
|
54
56
|
forcedReturnType?: DateFieldProps<DateType>['forcedReturnType'];
|
|
@@ -6,8 +6,9 @@ type CalendarCellProps = {
|
|
|
6
6
|
date: CalendarDate;
|
|
7
7
|
weekNumberString: string;
|
|
8
8
|
onSelectedCellClick?: () => void;
|
|
9
|
+
onCellClick?: () => void;
|
|
9
10
|
classNameForDate?: (date: CalendarDate) => string;
|
|
10
11
|
ariaLabelForDate?: (date: CalendarDate) => string;
|
|
11
12
|
};
|
|
12
|
-
export declare const CalendarCell: ({ state, date, onSelectedCellClick, weekNumberString, classNameForDate, ariaLabelForDate, ...rest }: CalendarCellProps) => React.JSX.Element;
|
|
13
|
+
export declare const CalendarCell: ({ state, date, onSelectedCellClick, onCellClick, weekNumberString, classNameForDate, ariaLabelForDate, ...rest }: CalendarCellProps) => React.JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -7,8 +7,9 @@ type CalendarGridProps = {
|
|
|
7
7
|
showWeekNumbers: boolean;
|
|
8
8
|
weekNumberHeader: string;
|
|
9
9
|
onSelectedCellClick?: () => void;
|
|
10
|
+
onCellClick?: () => void;
|
|
10
11
|
classNameForDate?: (date: CalendarDate) => string;
|
|
11
12
|
ariaLabelForDate?: (date: CalendarDate) => string;
|
|
12
13
|
};
|
|
13
|
-
export declare const CalendarGrid: ({ state, navigationDescription, onSelectedCellClick, showWeekNumbers, weekNumberHeader, classNameForDate, ariaLabelForDate, ...rest }: CalendarGridProps) => React.JSX.Element;
|
|
14
|
+
export declare const CalendarGrid: ({ state, navigationDescription, onSelectedCellClick, onCellClick, showWeekNumbers, weekNumberHeader, classNameForDate, ariaLabelForDate, ...rest }: CalendarGridProps) => React.JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -40,5 +40,5 @@ type BaseDatePickerProps = {
|
|
|
40
40
|
ariaLabelForDate?: (date: CalendarDate) => string;
|
|
41
41
|
};
|
|
42
42
|
export type DatePickerProps<DateType extends DateValue> = Omit<BaseDateFieldProps<DateType>, keyof BaseDatePickerProps | 'labelProps' | 'fieldProps' | 'groupProps' | 'dateFieldRef'> & BaseDatePickerProps & ExtendedDateFieldProps<DateType>;
|
|
43
|
-
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,
|
|
43
|
+
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, ariaLabelForDate, append, prepend, granularity, ...rest }: DatePickerProps<DateType>) => React.JSX.Element;
|
|
44
44
|
export {};
|
|
@@ -329,7 +329,7 @@ var CalendarButton = function CalendarButton(_ref) {
|
|
|
329
329
|
}), children);
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
var _excluded$8 = ["state", "date", "onSelectedCellClick", "weekNumberString", "classNameForDate", "ariaLabelForDate"];
|
|
332
|
+
var _excluded$8 = ["state", "date", "onSelectedCellClick", "onCellClick", "weekNumberString", "classNameForDate", "ariaLabelForDate"];
|
|
333
333
|
var CalendarCell = function CalendarCell(_ref) {
|
|
334
334
|
var _ariaLabelForDate, _classNameForDate, _state$timeZone, _classNames;
|
|
335
335
|
var state = _ref.state,
|
|
@@ -338,6 +338,10 @@ var CalendarCell = function CalendarCell(_ref) {
|
|
|
338
338
|
onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
|
|
339
339
|
return;
|
|
340
340
|
} : _ref$onSelectedCellCl,
|
|
341
|
+
_ref$onCellClick = _ref.onCellClick,
|
|
342
|
+
onCellClick = _ref$onCellClick === void 0 ? function () {
|
|
343
|
+
return;
|
|
344
|
+
} : _ref$onCellClick,
|
|
341
345
|
weekNumberString = _ref.weekNumberString,
|
|
342
346
|
classNameForDate = _ref.classNameForDate,
|
|
343
347
|
ariaLabelForDate = _ref.ariaLabelForDate,
|
|
@@ -354,6 +358,7 @@ var CalendarCell = function CalendarCell(_ref) {
|
|
|
354
358
|
isUnavailable = _useCalendarCell.isUnavailable,
|
|
355
359
|
formattedDate = _useCalendarCell.formattedDate;
|
|
356
360
|
var ariaLabel = "" + buttonProps['aria-label'] + weekNumberString + " " + ((_ariaLabelForDate = ariaLabelForDate == null ? void 0 : ariaLabelForDate(date$1)) != null ? _ariaLabelForDate : '');
|
|
361
|
+
var cellCanBeSelected = !(isOutsideVisibleRange || isDisabled || isUnavailable);
|
|
357
362
|
return React.createElement("td", _extends({}, cellProps, {
|
|
358
363
|
className: "eds-datepicker__calendar__grid__cell__td"
|
|
359
364
|
}), React.createElement("div", _extends({}, buttonProps, {
|
|
@@ -366,15 +371,19 @@ var CalendarCell = function CalendarCell(_ref) {
|
|
|
366
371
|
onClick: function onClick(e) {
|
|
367
372
|
buttonProps.onClick && buttonProps.onClick(e);
|
|
368
373
|
isSelected && onSelectedCellClick();
|
|
374
|
+
cellCanBeSelected && onCellClick();
|
|
369
375
|
},
|
|
370
376
|
onKeyDown: function onKeyDown(e) {
|
|
371
377
|
buttonProps.onKeyDown && buttonProps.onKeyDown(e);
|
|
372
|
-
if (e.key === 'Enter' || e.key === ' ')
|
|
378
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
379
|
+
isSelected && onSelectedCellClick();
|
|
380
|
+
cellCanBeSelected && onCellClick();
|
|
381
|
+
}
|
|
373
382
|
}
|
|
374
383
|
}), formattedDate));
|
|
375
384
|
};
|
|
376
385
|
|
|
377
|
-
var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick", "showWeekNumbers", "weekNumberHeader", "classNameForDate", "ariaLabelForDate"];
|
|
386
|
+
var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick", "onCellClick", "showWeekNumbers", "weekNumberHeader", "classNameForDate", "ariaLabelForDate"];
|
|
378
387
|
var CalendarGrid = function CalendarGrid(_ref) {
|
|
379
388
|
var state = _ref.state,
|
|
380
389
|
navigationDescription = _ref.navigationDescription,
|
|
@@ -382,6 +391,10 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
382
391
|
onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
|
|
383
392
|
return;
|
|
384
393
|
} : _ref$onSelectedCellCl,
|
|
394
|
+
_ref$onCellClick = _ref.onCellClick,
|
|
395
|
+
onCellClick = _ref$onCellClick === void 0 ? function () {
|
|
396
|
+
return;
|
|
397
|
+
} : _ref$onCellClick,
|
|
385
398
|
showWeekNumbers = _ref.showWeekNumbers,
|
|
386
399
|
weekNumberHeader = _ref.weekNumberHeader,
|
|
387
400
|
classNameForDate = _ref.classNameForDate,
|
|
@@ -435,6 +448,7 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
435
448
|
"aria-describedby": calendarGridId + 'description',
|
|
436
449
|
weekNumberString: showWeekNumbers ? ", " + weekNumberHeader + " " + weekNumber + "," : '',
|
|
437
450
|
onSelectedCellClick: onSelectedCellClick,
|
|
451
|
+
onCellClick: onCellClick,
|
|
438
452
|
classNameForDate: classNameForDate,
|
|
439
453
|
ariaLabelForDate: ariaLabelForDate
|
|
440
454
|
}) : React.createElement("td", {
|
|
@@ -447,15 +461,18 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
447
461
|
};
|
|
448
462
|
|
|
449
463
|
var _excluded$6 = ["locale"],
|
|
450
|
-
_excluded2$3 = ["selectedDate", "onChange", "minDate", "maxDate", "showWeekNumbers", "weekNumberHeader", "forcedReturnType", "style", "className", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate", "calendarRef"];
|
|
464
|
+
_excluded2$3 = ["selectedDate", "onChange", "minDate", "maxDate", "showWeekNumbers", "weekNumberHeader", "forcedReturnType", "style", "className", "navigationDescription", "onSelectedCellClick", "onCellClick", "classNameForDate", "ariaLabelForDate", "calendarRef"];
|
|
451
465
|
var Calendar = function Calendar(_ref) {
|
|
452
466
|
var localOverride = _ref.locale,
|
|
453
467
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
468
|
+
var props = _extends({
|
|
469
|
+
isDisabled: rest.disabled
|
|
470
|
+
}, rest);
|
|
454
471
|
var _useLocale = i18n.useLocale(),
|
|
455
472
|
locale = _useLocale.locale;
|
|
456
473
|
return React.createElement(i18n.I18nProvider, {
|
|
457
474
|
locale: localOverride != null ? localOverride : locale
|
|
458
|
-
}, React.createElement(CalendarBase, _extends({},
|
|
475
|
+
}, React.createElement(CalendarBase, _extends({}, props)));
|
|
459
476
|
};
|
|
460
477
|
var CalendarBase = function CalendarBase(_ref2) {
|
|
461
478
|
var selectedDate = _ref2.selectedDate,
|
|
@@ -474,6 +491,10 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
474
491
|
onSelectedCellClick = _ref2$onSelectedCellC === void 0 ? function () {
|
|
475
492
|
return;
|
|
476
493
|
} : _ref2$onSelectedCellC,
|
|
494
|
+
_ref2$onCellClick = _ref2.onCellClick,
|
|
495
|
+
onCellClick = _ref2$onCellClick === void 0 ? function () {
|
|
496
|
+
return;
|
|
497
|
+
} : _ref2$onCellClick,
|
|
477
498
|
classNameForDate = _ref2.classNameForDate,
|
|
478
499
|
ariaLabelForDate = _ref2.ariaLabelForDate,
|
|
479
500
|
calendarRef = _ref2.calendarRef,
|
|
@@ -519,6 +540,7 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
519
540
|
state: state,
|
|
520
541
|
navigationDescription: navigationDescription,
|
|
521
542
|
onSelectedCellClick: onSelectedCellClick,
|
|
543
|
+
onCellClick: onCellClick,
|
|
522
544
|
classNameForDate: classNameForDate,
|
|
523
545
|
ariaLabelForDate: ariaLabelForDate,
|
|
524
546
|
showWeekNumbers: showWeekNumbers,
|
|
@@ -526,7 +548,7 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
526
548
|
})));
|
|
527
549
|
};
|
|
528
550
|
|
|
529
|
-
var _excluded$5 = ["selectedDate", "locale", "disabled", "readOnly", "showTime", "showTimeZone", "classNameForDate", "className", "variant", "feedback", "validationVariant", "validationFeedback", "showWeekNumbers", "weekNumberHeader", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "
|
|
551
|
+
var _excluded$5 = ["selectedDate", "locale", "disabled", "readOnly", "showTime", "showTimeZone", "classNameForDate", "className", "variant", "feedback", "validationVariant", "validationFeedback", "showWeekNumbers", "weekNumberHeader", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "ariaLabelForDate", "append", "prepend", "granularity"];
|
|
530
552
|
var DatePicker = function DatePicker(_ref) {
|
|
531
553
|
var selectedDate = _ref.selectedDate,
|
|
532
554
|
locale = _ref.locale,
|
|
@@ -563,6 +585,14 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
563
585
|
var _useWindowDimensions = utils.useWindowDimensions(),
|
|
564
586
|
width = _useWindowDimensions.width;
|
|
565
587
|
var _props = _extends({}, rest, {
|
|
588
|
+
onChange: function onChange(value) {
|
|
589
|
+
return handleOnChange({
|
|
590
|
+
value: value,
|
|
591
|
+
selectedDate: selectedDate,
|
|
592
|
+
forcedReturnType: rest.forcedReturnType,
|
|
593
|
+
onChange: rest.onChange
|
|
594
|
+
});
|
|
595
|
+
},
|
|
566
596
|
minValue: minDate,
|
|
567
597
|
// this weird logic makes sure the entire day is included if no time is provided in maxDate
|
|
568
598
|
maxValue: 'hour' in (maxDate != null ? maxDate : {}) ? maxDate : maxDate !== undefined ? lastMillisecondOfDay(maxDate) : undefined,
|
|
@@ -594,18 +624,25 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
594
624
|
floatingStyles = _useFloating.floatingStyles,
|
|
595
625
|
update = _useFloating.update;
|
|
596
626
|
utils.useOnClickOutside([calendarRef], function () {
|
|
597
|
-
state.setOpen(false);
|
|
627
|
+
return state.setOpen(false);
|
|
598
628
|
});
|
|
599
629
|
utils.useOnEscape(calendarRef, function () {
|
|
600
|
-
state.setOpen(false);
|
|
630
|
+
return state.setOpen(false);
|
|
601
631
|
});
|
|
602
632
|
var calendarSharedProps = _extends({}, dialogProps, calendarProps, {
|
|
633
|
+
// We don't use handleOnChange here since it's handled internally by Calendar
|
|
603
634
|
onChange: rest.onChange,
|
|
635
|
+
forcedReturnType: rest.forcedReturnType,
|
|
604
636
|
disabled: disabled,
|
|
605
637
|
navigationDescription: navigationDescription,
|
|
606
638
|
onSelectedCellClick: function onSelectedCellClick() {
|
|
607
639
|
return state.setOpen(false);
|
|
608
640
|
},
|
|
641
|
+
// onCellClick is a temporary fix solving an issue where the
|
|
642
|
+
// calendar sometimes doesn't close on date selection
|
|
643
|
+
onCellClick: function onCellClick() {
|
|
644
|
+
return state.setOpen(false);
|
|
645
|
+
},
|
|
609
646
|
selectedDate: selectedDate,
|
|
610
647
|
minDate: minDate,
|
|
611
648
|
maxDate: maxDate,
|