@skedulo/sked-ui 19.19.2 → 19.20.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/components/calendar-controls/CalendarControls-utils.d.ts +3 -2
- package/dist/components/calendar-controls/CalendarControls.d.ts +2 -3
- package/dist/components/calendar-controls/elements/DateSelector.d.ts +14 -0
- package/dist/components/calendar-controls/elements/NavigationButtons.d.ts +1 -4
- package/dist/index.js +20 -8
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RangeType } from './elements/RangePicker';
|
|
2
2
|
export declare type DateDirection = 'forward' | 'backward';
|
|
3
|
+
export declare type DateFormat = 'MonthDayYear' | 'DayMonthYear';
|
|
3
4
|
export declare const moveDate: (selected: Date, days: RangeType, direction: DateDirection) => Date;
|
|
4
5
|
export declare const endOfPeriod: (selected: Date, selectedRange: RangeType) => Date;
|
|
5
|
-
export declare const formatLongDate: (date: Date) => string;
|
|
6
|
-
export declare const formatShortDate: (date: Date) => string;
|
|
6
|
+
export declare const formatLongDate: (date: Date, dateFormat?: DateFormat) => string;
|
|
7
|
+
export declare const formatShortDate: (date: Date, dateFormat?: DateFormat) => string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IDateSelectorProps } from './elements/DateSelector';
|
|
3
|
-
import { INavigationButtonProps } from './elements/NavigationButtons';
|
|
4
3
|
import { IRangeProps, RangePicker, RangeType } from './elements/RangePicker';
|
|
5
4
|
import { ValidationProps } from '../forms/elements/FormElements';
|
|
6
5
|
export interface IBaseCalendarControlProps extends ValidationProps {
|
|
@@ -13,7 +12,7 @@ export interface IBaseCalendarControlProps extends ValidationProps {
|
|
|
13
12
|
*/
|
|
14
13
|
selected?: Date;
|
|
15
14
|
}
|
|
16
|
-
export interface ICalendarControlProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
15
|
+
export interface ICalendarControlProps extends React.HTMLAttributes<HTMLDivElement>, IBaseCalendarControlProps, IDateSelectorProps, IRangeProps {
|
|
17
16
|
/**
|
|
18
17
|
* Whenever the user clicks the `Today` button this callback is triggered
|
|
19
18
|
*/
|
|
@@ -23,7 +22,7 @@ export declare function useCalendarControlsContext(): ICalendarControlProps;
|
|
|
23
22
|
declare function CalendarControls(props: ICalendarControlProps): JSX.Element;
|
|
24
23
|
declare namespace CalendarControls {
|
|
25
24
|
var TodayButton: React.FC<import("./elements/TodayButton").ITodayButtonProps>;
|
|
26
|
-
var NavigationButtons:
|
|
25
|
+
var NavigationButtons: (props: import("./elements/DateSelector").IBaseDateSelectorProps) => JSX.Element;
|
|
27
26
|
var DateSelector: React.FC<IDateSelectorProps>;
|
|
28
27
|
var RangePicker: React.FC<IRangeProps>;
|
|
29
28
|
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import { ReactDatePickerProps } from 'react-datepicker';
|
|
2
3
|
import { ButtonTypes } from '../../..';
|
|
3
4
|
import { IBaseCalendarControlProps } from '../CalendarControls';
|
|
5
|
+
import { DateFormat } from '../CalendarControls-utils';
|
|
4
6
|
export declare type SelectDateHandler = (date: Date) => void;
|
|
5
7
|
export interface IBaseDateSelectorProps extends IBaseCalendarControlProps {
|
|
6
8
|
/**
|
|
7
9
|
* Whenever the date is changed, either through direct select, clicking to or navigating, the new date is provided to this function
|
|
8
10
|
*/
|
|
9
11
|
onDateSelect?: SelectDateHandler;
|
|
12
|
+
/**
|
|
13
|
+
* Minimum date allowed to be selected. This will also affect the month navigation
|
|
14
|
+
*/
|
|
15
|
+
minDate?: ReactDatePickerProps['minDate'];
|
|
16
|
+
/**
|
|
17
|
+
* Latest date allowed to be selected. This will also affect the month navigation
|
|
18
|
+
*/
|
|
19
|
+
maxDate?: ReactDatePickerProps['maxDate'];
|
|
10
20
|
}
|
|
11
21
|
export interface IDateSelectorProps extends IBaseDateSelectorProps, HTMLAttributes<HTMLDivElement> {
|
|
12
22
|
/**
|
|
@@ -29,5 +39,9 @@ export interface IDateSelectorProps extends IBaseDateSelectorProps, HTMLAttribut
|
|
|
29
39
|
* The type of Datepicker custom input button to be displayed. Primary | Secondary | Transparent
|
|
30
40
|
*/
|
|
31
41
|
buttonType?: ButtonTypes;
|
|
42
|
+
/**
|
|
43
|
+
* User preferred date format
|
|
44
|
+
*/
|
|
45
|
+
dateFormat?: DateFormat;
|
|
32
46
|
}
|
|
33
47
|
export declare const DateSelector: React.FC<IDateSelectorProps>;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { IBaseDateSelectorProps } from './DateSelector';
|
|
3
|
-
export
|
|
4
|
-
}
|
|
5
|
-
export declare const NavigationButtons: React.FC<INavigationButtonProps>;
|
|
2
|
+
export declare const NavigationButtons: (props: IBaseDateSelectorProps) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -14560,7 +14560,11 @@ var DateSelector = function DateSelector(props) {
|
|
|
14560
14560
|
selected = _calendarControlProps.selected,
|
|
14561
14561
|
_calendarControlProps3 = _calendarControlProps.buttonType,
|
|
14562
14562
|
buttonType = _calendarControlProps3 === void 0 ? 'transparent' : _calendarControlProps3,
|
|
14563
|
-
validation = _calendarControlProps.validation
|
|
14563
|
+
validation = _calendarControlProps.validation,
|
|
14564
|
+
_calendarControlProps4 = _calendarControlProps.dateFormat,
|
|
14565
|
+
dateFormat = _calendarControlProps4 === void 0 ? 'MonthDayYear' : _calendarControlProps4,
|
|
14566
|
+
minDate = _calendarControlProps.minDate,
|
|
14567
|
+
maxDate = _calendarControlProps.maxDate;
|
|
14564
14568
|
|
|
14565
14569
|
var className = props.className;
|
|
14566
14570
|
|
|
@@ -14575,9 +14579,9 @@ var DateSelector = function DateSelector(props) {
|
|
|
14575
14579
|
|
|
14576
14580
|
var startDate = selected !== null && selected !== void 0 ? selected : new Date();
|
|
14577
14581
|
var endDate = Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["endOfPeriod"])(selected, selectedRange);
|
|
14578
|
-
var formattedStartDate = startDate.getFullYear() === endDate.getFullYear() ? Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatShortDate"])(startDate) : Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(startDate);
|
|
14579
|
-
var formattedEndDate = Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(endDate);
|
|
14580
|
-
var formattedDate = selectedRange === 'day' ? Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(selected) : "".concat(formattedStartDate, " - ").concat(formattedEndDate);
|
|
14582
|
+
var formattedStartDate = startDate.getFullYear() === endDate.getFullYear() ? Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatShortDate"])(startDate, dateFormat) : Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(startDate, dateFormat);
|
|
14583
|
+
var formattedEndDate = Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(endDate, dateFormat);
|
|
14584
|
+
var formattedDate = selectedRange === 'day' ? Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_6__["formatLongDate"])(selected, dateFormat) : "".concat(formattedStartDate, " - ").concat(formattedEndDate);
|
|
14581
14585
|
var buttonClasses = className !== null && className !== void 0 ? className : 'hover:sk-bg-neutral-250 sk-text-base sk-mr-3 sk-text-neutral-850 sk-px-3 sk-py-1 sk-leading-normal sk-border-none';
|
|
14582
14586
|
|
|
14583
14587
|
var onChange = function onChange(date) {
|
|
@@ -14626,7 +14630,9 @@ var DateSelector = function DateSelector(props) {
|
|
|
14626
14630
|
selectedRange: selectedRange,
|
|
14627
14631
|
onClickOutside: toggleExpanded,
|
|
14628
14632
|
clearable: false,
|
|
14629
|
-
onCalendarClose: toggleExpanded
|
|
14633
|
+
onCalendarClose: toggleExpanded,
|
|
14634
|
+
minDate: minDate,
|
|
14635
|
+
maxDate: maxDate
|
|
14630
14636
|
});
|
|
14631
14637
|
};
|
|
14632
14638
|
|
|
@@ -14675,10 +14681,12 @@ var endOfPeriod = function endOfPeriod(selected, selectedRange) {
|
|
|
14675
14681
|
return moveDate(nextPeriod, 'day', 'backward');
|
|
14676
14682
|
};
|
|
14677
14683
|
var formatLongDate = function formatLongDate(date) {
|
|
14678
|
-
|
|
14684
|
+
var dateFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'MonthDayYear';
|
|
14685
|
+
return Object(date_fns_format__WEBPACK_IMPORTED_MODULE_0__["default"])(date, dateFormat === 'MonthDayYear' ? 'MMM d, yyyy' : 'd MMM, yyyy');
|
|
14679
14686
|
};
|
|
14680
14687
|
var formatShortDate = function formatShortDate(date) {
|
|
14681
|
-
|
|
14688
|
+
var dateFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'MonthDayYear';
|
|
14689
|
+
return Object(date_fns_format__WEBPACK_IMPORTED_MODULE_0__["default"])(date, dateFormat === 'MonthDayYear' ? 'MMM d' : 'd MMM');
|
|
14682
14690
|
};
|
|
14683
14691
|
|
|
14684
14692
|
/***/ }),
|
|
@@ -17438,7 +17446,9 @@ var NavigationButtons = function NavigationButtons(props) {
|
|
|
17438
17446
|
_calendarControlProps2 = _calendarControlProps.selectedRange,
|
|
17439
17447
|
selectedRange = _calendarControlProps2 === void 0 ? 'day' : _calendarControlProps2,
|
|
17440
17448
|
onDateSelect = _calendarControlProps.onDateSelect,
|
|
17441
|
-
selected = _calendarControlProps.selected
|
|
17449
|
+
selected = _calendarControlProps.selected,
|
|
17450
|
+
minDate = _calendarControlProps.minDate,
|
|
17451
|
+
maxDate = _calendarControlProps.maxDate;
|
|
17442
17452
|
|
|
17443
17453
|
var backwardsHandler = function backwardsHandler() {
|
|
17444
17454
|
return onDateSelect(Object(_CalendarControls_utils__WEBPACK_IMPORTED_MODULE_4__["moveDate"])(selected, selectedRange, 'backward'));
|
|
@@ -17457,6 +17467,7 @@ var NavigationButtons = function NavigationButtons(props) {
|
|
|
17457
17467
|
icon: "chevronLeft",
|
|
17458
17468
|
"data-sk-name": "navigate-backwards",
|
|
17459
17469
|
onClick: backwardsHandler,
|
|
17470
|
+
disabled: minDate && selected <= minDate,
|
|
17460
17471
|
compact: true,
|
|
17461
17472
|
tooltipContent: previousTooltip
|
|
17462
17473
|
}), react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(___WEBPACK_IMPORTED_MODULE_3__["IconButton"], {
|
|
@@ -17464,6 +17475,7 @@ var NavigationButtons = function NavigationButtons(props) {
|
|
|
17464
17475
|
icon: "chevronRight",
|
|
17465
17476
|
"data-sk-name": "navigate-forwards",
|
|
17466
17477
|
onClick: forwardsHandler,
|
|
17478
|
+
disabled: maxDate && selected >= maxDate,
|
|
17467
17479
|
compact: true,
|
|
17468
17480
|
tooltipContent: nextTooltip
|
|
17469
17481
|
}));
|