@entur/datepicker 11.1.0 → 11.1.1-beta.1
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 +49 -10
- 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 +49 -10
- package/dist/datepicker.esm.js.map +1 -1
- package/dist/styles.css +75 -75
- 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, {
|
|
@@ -365,16 +370,22 @@ var CalendarCell = function CalendarCell(_ref) {
|
|
|
365
370
|
}, rest, {
|
|
366
371
|
onClick: function onClick(e) {
|
|
367
372
|
buttonProps.onClick && buttonProps.onClick(e);
|
|
373
|
+
// Used to force close calendar on select
|
|
368
374
|
isSelected && onSelectedCellClick();
|
|
375
|
+
cellCanBeSelected && onCellClick();
|
|
369
376
|
},
|
|
370
|
-
|
|
371
|
-
buttonProps.
|
|
372
|
-
if (e.key === 'Enter'
|
|
377
|
+
onKeyUp: function onKeyUp(e) {
|
|
378
|
+
buttonProps.onKeyUp && buttonProps.onKeyUp(e);
|
|
379
|
+
if (e.key === 'Enter') {
|
|
380
|
+
// Used to force close calendar on select
|
|
381
|
+
isSelected && onSelectedCellClick();
|
|
382
|
+
cellCanBeSelected && onCellClick();
|
|
383
|
+
}
|
|
373
384
|
}
|
|
374
385
|
}), formattedDate));
|
|
375
386
|
};
|
|
376
387
|
|
|
377
|
-
var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick", "showWeekNumbers", "weekNumberHeader", "classNameForDate", "ariaLabelForDate"];
|
|
388
|
+
var _excluded$7 = ["state", "navigationDescription", "onSelectedCellClick", "onCellClick", "showWeekNumbers", "weekNumberHeader", "classNameForDate", "ariaLabelForDate"];
|
|
378
389
|
var CalendarGrid = function CalendarGrid(_ref) {
|
|
379
390
|
var state = _ref.state,
|
|
380
391
|
navigationDescription = _ref.navigationDescription,
|
|
@@ -382,6 +393,10 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
382
393
|
onSelectedCellClick = _ref$onSelectedCellCl === void 0 ? function () {
|
|
383
394
|
return;
|
|
384
395
|
} : _ref$onSelectedCellCl,
|
|
396
|
+
_ref$onCellClick = _ref.onCellClick,
|
|
397
|
+
onCellClick = _ref$onCellClick === void 0 ? function () {
|
|
398
|
+
return;
|
|
399
|
+
} : _ref$onCellClick,
|
|
385
400
|
showWeekNumbers = _ref.showWeekNumbers,
|
|
386
401
|
weekNumberHeader = _ref.weekNumberHeader,
|
|
387
402
|
classNameForDate = _ref.classNameForDate,
|
|
@@ -435,6 +450,7 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
435
450
|
"aria-describedby": calendarGridId + 'description',
|
|
436
451
|
weekNumberString: showWeekNumbers ? ", " + weekNumberHeader + " " + weekNumber + "," : '',
|
|
437
452
|
onSelectedCellClick: onSelectedCellClick,
|
|
453
|
+
onCellClick: onCellClick,
|
|
438
454
|
classNameForDate: classNameForDate,
|
|
439
455
|
ariaLabelForDate: ariaLabelForDate
|
|
440
456
|
}) : React.createElement("td", {
|
|
@@ -447,15 +463,18 @@ var CalendarGrid = function CalendarGrid(_ref) {
|
|
|
447
463
|
};
|
|
448
464
|
|
|
449
465
|
var _excluded$6 = ["locale"],
|
|
450
|
-
_excluded2$3 = ["selectedDate", "onChange", "minDate", "maxDate", "showWeekNumbers", "weekNumberHeader", "forcedReturnType", "style", "className", "navigationDescription", "onSelectedCellClick", "classNameForDate", "ariaLabelForDate", "calendarRef"];
|
|
466
|
+
_excluded2$3 = ["selectedDate", "onChange", "minDate", "maxDate", "showWeekNumbers", "weekNumberHeader", "forcedReturnType", "style", "className", "navigationDescription", "onSelectedCellClick", "onCellClick", "classNameForDate", "ariaLabelForDate", "calendarRef"];
|
|
451
467
|
var Calendar = function Calendar(_ref) {
|
|
452
468
|
var localOverride = _ref.locale,
|
|
453
469
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
470
|
+
var props = _extends({
|
|
471
|
+
isDisabled: rest.disabled
|
|
472
|
+
}, rest);
|
|
454
473
|
var _useLocale = i18n.useLocale(),
|
|
455
474
|
locale = _useLocale.locale;
|
|
456
475
|
return React.createElement(i18n.I18nProvider, {
|
|
457
476
|
locale: localOverride != null ? localOverride : locale
|
|
458
|
-
}, React.createElement(CalendarBase, _extends({},
|
|
477
|
+
}, React.createElement(CalendarBase, _extends({}, props)));
|
|
459
478
|
};
|
|
460
479
|
var CalendarBase = function CalendarBase(_ref2) {
|
|
461
480
|
var selectedDate = _ref2.selectedDate,
|
|
@@ -474,6 +493,10 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
474
493
|
onSelectedCellClick = _ref2$onSelectedCellC === void 0 ? function () {
|
|
475
494
|
return;
|
|
476
495
|
} : _ref2$onSelectedCellC,
|
|
496
|
+
_ref2$onCellClick = _ref2.onCellClick,
|
|
497
|
+
onCellClick = _ref2$onCellClick === void 0 ? function () {
|
|
498
|
+
return;
|
|
499
|
+
} : _ref2$onCellClick,
|
|
477
500
|
classNameForDate = _ref2.classNameForDate,
|
|
478
501
|
ariaLabelForDate = _ref2.ariaLabelForDate,
|
|
479
502
|
calendarRef = _ref2.calendarRef,
|
|
@@ -519,6 +542,7 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
519
542
|
state: state,
|
|
520
543
|
navigationDescription: navigationDescription,
|
|
521
544
|
onSelectedCellClick: onSelectedCellClick,
|
|
545
|
+
onCellClick: onCellClick,
|
|
522
546
|
classNameForDate: classNameForDate,
|
|
523
547
|
ariaLabelForDate: ariaLabelForDate,
|
|
524
548
|
showWeekNumbers: showWeekNumbers,
|
|
@@ -526,7 +550,7 @@ var CalendarBase = function CalendarBase(_ref2) {
|
|
|
526
550
|
})));
|
|
527
551
|
};
|
|
528
552
|
|
|
529
|
-
var _excluded$5 = ["selectedDate", "locale", "disabled", "readOnly", "showTime", "showTimeZone", "classNameForDate", "className", "variant", "feedback", "validationVariant", "validationFeedback", "showWeekNumbers", "weekNumberHeader", "disableModal", "labelTooltip", "navigationDescription", "minDate", "maxDate", "modalTreshold", "
|
|
553
|
+
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
554
|
var DatePicker = function DatePicker(_ref) {
|
|
531
555
|
var selectedDate = _ref.selectedDate,
|
|
532
556
|
locale = _ref.locale,
|
|
@@ -563,6 +587,14 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
563
587
|
var _useWindowDimensions = utils.useWindowDimensions(),
|
|
564
588
|
width = _useWindowDimensions.width;
|
|
565
589
|
var _props = _extends({}, rest, {
|
|
590
|
+
onChange: function onChange(value) {
|
|
591
|
+
return handleOnChange({
|
|
592
|
+
value: value,
|
|
593
|
+
selectedDate: selectedDate,
|
|
594
|
+
forcedReturnType: rest.forcedReturnType,
|
|
595
|
+
onChange: rest.onChange
|
|
596
|
+
});
|
|
597
|
+
},
|
|
566
598
|
minValue: minDate,
|
|
567
599
|
// this weird logic makes sure the entire day is included if no time is provided in maxDate
|
|
568
600
|
maxValue: 'hour' in (maxDate != null ? maxDate : {}) ? maxDate : maxDate !== undefined ? lastMillisecondOfDay(maxDate) : undefined,
|
|
@@ -594,18 +626,25 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
594
626
|
floatingStyles = _useFloating.floatingStyles,
|
|
595
627
|
update = _useFloating.update;
|
|
596
628
|
utils.useOnClickOutside([calendarRef], function () {
|
|
597
|
-
state.setOpen(false);
|
|
629
|
+
return state.setOpen(false);
|
|
598
630
|
});
|
|
599
631
|
utils.useOnEscape(calendarRef, function () {
|
|
600
|
-
state.setOpen(false);
|
|
632
|
+
return state.setOpen(false);
|
|
601
633
|
});
|
|
602
634
|
var calendarSharedProps = _extends({}, dialogProps, calendarProps, {
|
|
635
|
+
// We don't use handleOnChange here since it's handled internally by Calendar
|
|
603
636
|
onChange: rest.onChange,
|
|
637
|
+
forcedReturnType: rest.forcedReturnType,
|
|
604
638
|
disabled: disabled,
|
|
605
639
|
navigationDescription: navigationDescription,
|
|
606
640
|
onSelectedCellClick: function onSelectedCellClick() {
|
|
607
641
|
return state.setOpen(false);
|
|
608
642
|
},
|
|
643
|
+
// onCellClick is a temporary fix solving an issue where the
|
|
644
|
+
// calendar sometimes doesn't close on date selection
|
|
645
|
+
onCellClick: function onCellClick() {
|
|
646
|
+
return state.setOpen(false);
|
|
647
|
+
},
|
|
609
648
|
selectedDate: selectedDate,
|
|
610
649
|
minDate: minDate,
|
|
611
650
|
maxDate: maxDate,
|