@transferwise/components 0.0.0-experimental-1a3a746 → 0.0.0-experimental-65c6e3a
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/build/index.js +239 -107
- package/build/index.js.map +1 -1
- package/build/index.mjs +239 -107
- package/build/index.mjs.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +28 -80
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +63 -42
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +22 -9
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +31 -13
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +2 -19
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +2 -12
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
- package/build/types/dateLookup/index.d.ts +1 -2
- package/build/types/dateLookup/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +2 -17
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +26 -10
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +2 -15
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +26 -10
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +0 -21
- package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
- package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +2 -11
- package/src/dateLookup/{DateLookup.tsx → DateLookup.js} +69 -114
- package/src/dateLookup/DateLookup.state.spec.js +0 -7
- package/src/dateLookup/{DateLookup.story.tsx → DateLookup.story.js} +14 -13
- package/src/dateLookup/dateHeader/{DateHeader.tsx → DateHeader.js} +15 -15
- package/src/dateLookup/dateTrigger/{DateTrigger.tsx → DateTrigger.js} +32 -15
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +22 -0
- package/src/dateLookup/dayCalendar/{DayCalendar.tsx → DayCalendar.js} +21 -14
- package/src/dateLookup/dayCalendar/table/{DayCalendarTable.tsx → DayCalendarTable.js} +37 -26
- package/src/dateLookup/getStartOfDay/{getStartOfDay.tsx → getStartOfDay.js} +1 -1
- package/src/dateLookup/index.js +1 -0
- package/src/dateLookup/monthCalendar/{MonthCalendar.tsx → MonthCalendar.js} +22 -19
- package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.tsx → MonthCalendarTable.js} +30 -31
- package/src/dateLookup/yearCalendar/{YearCalendar.tsx → YearCalendar.js} +21 -18
- package/src/dateLookup/yearCalendar/table/{YearCalendarTable.tsx → YearCalendarTable.js} +28 -26
- package/src/index.ts +0 -1
- package/src/dateLookup/DateLookup.tests.story.tsx +0 -71
- package/src/dateLookup/index.ts +0 -2
- /package/src/dateLookup/{DateLookup.messages.ts → DateLookup.messages.js} +0 -0
- /package/src/dateLookup/dateHeader/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dateTrigger/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dayCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dayCalendar/table/{index.ts → index.js} +0 -0
- /package/src/dateLookup/getStartOfDay/{index.ts → index.js} +0 -0
- /package/src/dateLookup/monthCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/monthCalendar/table/{index.ts → index.js} +0 -0
- /package/src/dateLookup/yearCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/yearCalendar/table/{index.ts → index.js} +0 -0
package/build/index.mjs
CHANGED
|
@@ -15,10 +15,10 @@ import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, Floa
|
|
|
15
15
|
import { FocusScope } from '@react-aria/focus';
|
|
16
16
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
17
17
|
import { CSSTransition } from 'react-transition-group';
|
|
18
|
-
import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
19
|
-
import { createPortal } from 'react-dom';
|
|
20
18
|
import { usePopper } from 'react-popper';
|
|
21
19
|
import throttle from 'lodash.throttle';
|
|
20
|
+
import { createPortal } from 'react-dom';
|
|
21
|
+
import { isUndefined, isKey, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
22
22
|
import commonmark from 'commonmark';
|
|
23
23
|
import { Flag, Illustration } from '@wise/art';
|
|
24
24
|
import clamp$2 from 'lodash.clamp';
|
|
@@ -2665,20 +2665,11 @@ function getDayNames(locale, format = 'short') {
|
|
|
2665
2665
|
|
|
2666
2666
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2667
2667
|
function moveToWithinRange(date, min, max) {
|
|
2668
|
-
|
|
2669
|
-
return date;
|
|
2670
|
-
}
|
|
2671
|
-
if (min && date < min) {
|
|
2672
|
-
return new Date(min);
|
|
2673
|
-
}
|
|
2674
|
-
if (max && date > max) {
|
|
2675
|
-
return new Date(max);
|
|
2676
|
-
}
|
|
2677
|
-
return null;
|
|
2668
|
+
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
2678
2669
|
}
|
|
2679
2670
|
|
|
2680
2671
|
function isWithinRange(date, min, max) {
|
|
2681
|
-
return (!min || date >= min) && (!max || date <= max);
|
|
2672
|
+
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2682
2673
|
}
|
|
2683
2674
|
|
|
2684
2675
|
const getMonthNames = (locale, format = 'long') => {
|
|
@@ -3202,7 +3193,7 @@ var dateTriggerMessages = defineMessages({
|
|
|
3202
3193
|
|
|
3203
3194
|
const DateTrigger = ({
|
|
3204
3195
|
selectedDate,
|
|
3205
|
-
size
|
|
3196
|
+
size,
|
|
3206
3197
|
placeholder,
|
|
3207
3198
|
label,
|
|
3208
3199
|
monthFormat,
|
|
@@ -3214,6 +3205,19 @@ const DateTrigger = ({
|
|
|
3214
3205
|
locale,
|
|
3215
3206
|
formatMessage
|
|
3216
3207
|
} = useIntl();
|
|
3208
|
+
const handleKeyDown = event => {
|
|
3209
|
+
if (isKey({
|
|
3210
|
+
keyType: 'Space',
|
|
3211
|
+
event: event
|
|
3212
|
+
}) || isKey({
|
|
3213
|
+
keyType: 'Enter',
|
|
3214
|
+
event: event
|
|
3215
|
+
})) {
|
|
3216
|
+
event.stopPropagation();
|
|
3217
|
+
event.preventDefault();
|
|
3218
|
+
onClear();
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3217
3221
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3218
3222
|
children: [/*#__PURE__*/jsxs("button", {
|
|
3219
3223
|
className: `btn btn-${size} btn-input np-date-trigger`,
|
|
@@ -3250,12 +3254,29 @@ const DateTrigger = ({
|
|
|
3250
3254
|
event.stopPropagation();
|
|
3251
3255
|
event.preventDefault();
|
|
3252
3256
|
onClear();
|
|
3253
|
-
}
|
|
3257
|
+
},
|
|
3258
|
+
onKeyPress: handleKeyDown
|
|
3254
3259
|
})
|
|
3255
3260
|
})]
|
|
3256
3261
|
}) : null]
|
|
3257
3262
|
});
|
|
3258
3263
|
};
|
|
3264
|
+
DateTrigger.propTypes = {
|
|
3265
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3266
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
3267
|
+
placeholder: PropTypes.string.isRequired,
|
|
3268
|
+
label: PropTypes.string.isRequired,
|
|
3269
|
+
monthFormat: PropTypes.oneOf(['short', 'long']).isRequired,
|
|
3270
|
+
disabled: PropTypes.bool.isRequired,
|
|
3271
|
+
onClick: PropTypes.func,
|
|
3272
|
+
onClear: PropTypes.func
|
|
3273
|
+
};
|
|
3274
|
+
DateTrigger.defaultProps = {
|
|
3275
|
+
selectedDate: null,
|
|
3276
|
+
size: Size.MEDIUM,
|
|
3277
|
+
onClear: undefined
|
|
3278
|
+
};
|
|
3279
|
+
var DateTrigger$1 = DateTrigger;
|
|
3259
3280
|
|
|
3260
3281
|
var messages$8 = defineMessages({
|
|
3261
3282
|
next: {
|
|
@@ -3337,6 +3358,18 @@ const DateHeader = ({
|
|
|
3337
3358
|
})]
|
|
3338
3359
|
});
|
|
3339
3360
|
};
|
|
3361
|
+
DateHeader.propTypes = {
|
|
3362
|
+
label: PropTypes.string,
|
|
3363
|
+
onLabelClick: PropTypes.func,
|
|
3364
|
+
onPreviousClick: PropTypes.func.isRequired,
|
|
3365
|
+
onNextClick: PropTypes.func.isRequired,
|
|
3366
|
+
dateMode: PropTypes.string
|
|
3367
|
+
};
|
|
3368
|
+
DateHeader.defaultProps = {
|
|
3369
|
+
label: null,
|
|
3370
|
+
onLabelClick: () => {}
|
|
3371
|
+
};
|
|
3372
|
+
var DateHeader$1 = DateHeader;
|
|
3340
3373
|
|
|
3341
3374
|
function getFocusableTime(props) {
|
|
3342
3375
|
return props.timeSpan.find(time => props.isActive(time)) || props.timeSpan.find(time => props.isNow(time) && !props.isDisabled(time)) || props.timeSpan.find(time => !props.isDisabled(time));
|
|
@@ -3422,9 +3455,10 @@ class DayCalendarTable extends PureComponent {
|
|
|
3422
3455
|
let week = [];
|
|
3423
3456
|
const weeks = [];
|
|
3424
3457
|
let i;
|
|
3458
|
+
|
|
3425
3459
|
// Pad first week
|
|
3426
3460
|
for (i = 1; i < firstDayOfMonth; i += 1) {
|
|
3427
|
-
week.push(
|
|
3461
|
+
week.push(false);
|
|
3428
3462
|
}
|
|
3429
3463
|
// Fill in days
|
|
3430
3464
|
for (i = 1; i <= daysInMonth; i += 1) {
|
|
@@ -3437,7 +3471,7 @@ class DayCalendarTable extends PureComponent {
|
|
|
3437
3471
|
if (week.length > 0) {
|
|
3438
3472
|
// Pad last week
|
|
3439
3473
|
for (i = week.length; i < 7; i += 1) {
|
|
3440
|
-
week.push(
|
|
3474
|
+
week.push(false);
|
|
3441
3475
|
}
|
|
3442
3476
|
weeks.push(week);
|
|
3443
3477
|
}
|
|
@@ -3492,10 +3526,12 @@ class DayCalendarTable extends PureComponent {
|
|
|
3492
3526
|
const {
|
|
3493
3527
|
viewMonth,
|
|
3494
3528
|
viewYear,
|
|
3495
|
-
intl
|
|
3529
|
+
intl: {
|
|
3530
|
+
locale
|
|
3531
|
+
}
|
|
3496
3532
|
} = this.props;
|
|
3497
3533
|
const weeks = this.getTableStructure();
|
|
3498
|
-
|
|
3534
|
+
let autoFocusDay = this.getAutofocusDay(weeks, viewMonth, viewYear);
|
|
3499
3535
|
return /*#__PURE__*/jsxs("table", {
|
|
3500
3536
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3501
3537
|
children: [/*#__PURE__*/jsx("thead", {
|
|
@@ -3521,12 +3557,12 @@ class DayCalendarTable extends PureComponent {
|
|
|
3521
3557
|
children: weeks.map((week, weekIndex) => /*#__PURE__*/jsx("tr", {
|
|
3522
3558
|
children: week.map((day, dayIndex) => /*#__PURE__*/jsx("td", {
|
|
3523
3559
|
className: dayIndex > 4 ? 'weekend' : '',
|
|
3524
|
-
children: day
|
|
3560
|
+
children: day && /*#__PURE__*/jsx(TableLink, {
|
|
3525
3561
|
item: day,
|
|
3526
3562
|
type: "day",
|
|
3527
|
-
title: formatDate(new Date(viewYear, viewMonth, day),
|
|
3563
|
+
title: formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3528
3564
|
autofocus: day === autoFocusDay,
|
|
3529
|
-
longTitle: formatDate(new Date(viewYear, viewMonth, day),
|
|
3565
|
+
longTitle: formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3530
3566
|
active: this.isActive(day),
|
|
3531
3567
|
disabled: this.isDisabled(day),
|
|
3532
3568
|
today: this.isToday(day),
|
|
@@ -3538,6 +3574,19 @@ class DayCalendarTable extends PureComponent {
|
|
|
3538
3574
|
});
|
|
3539
3575
|
}
|
|
3540
3576
|
}
|
|
3577
|
+
DayCalendarTable.propTypes = {
|
|
3578
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3579
|
+
min: PropTypes.instanceOf(Date),
|
|
3580
|
+
max: PropTypes.instanceOf(Date),
|
|
3581
|
+
viewMonth: PropTypes.number.isRequired,
|
|
3582
|
+
viewYear: PropTypes.number.isRequired,
|
|
3583
|
+
onSelect: PropTypes.func.isRequired
|
|
3584
|
+
};
|
|
3585
|
+
DayCalendarTable.defaultProps = {
|
|
3586
|
+
selectedDate: null,
|
|
3587
|
+
min: null,
|
|
3588
|
+
max: null
|
|
3589
|
+
};
|
|
3541
3590
|
var DayCalendarTable$1 = injectIntl(DayCalendarTable);
|
|
3542
3591
|
|
|
3543
3592
|
class DayCalendar extends PureComponent {
|
|
@@ -3577,7 +3626,7 @@ class DayCalendar extends PureComponent {
|
|
|
3577
3626
|
onSelect
|
|
3578
3627
|
} = this.props;
|
|
3579
3628
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3580
|
-
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3629
|
+
children: [/*#__PURE__*/jsx(DateHeader$1, {
|
|
3581
3630
|
label: formatDate(new Date(viewYear, viewMonth), locale, {
|
|
3582
3631
|
month: monthFormat,
|
|
3583
3632
|
year: 'numeric'
|
|
@@ -3597,6 +3646,22 @@ class DayCalendar extends PureComponent {
|
|
|
3597
3646
|
});
|
|
3598
3647
|
}
|
|
3599
3648
|
}
|
|
3649
|
+
DayCalendar.propTypes = {
|
|
3650
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3651
|
+
min: PropTypes.instanceOf(Date),
|
|
3652
|
+
max: PropTypes.instanceOf(Date),
|
|
3653
|
+
viewMonth: PropTypes.number.isRequired,
|
|
3654
|
+
viewYear: PropTypes.number.isRequired,
|
|
3655
|
+
monthFormat: PropTypes.oneOf([MonthFormat.LONG, MonthFormat.SHORT]).isRequired,
|
|
3656
|
+
onSelect: PropTypes.func.isRequired,
|
|
3657
|
+
onLabelClick: PropTypes.func.isRequired,
|
|
3658
|
+
onViewDateUpdate: PropTypes.func.isRequired
|
|
3659
|
+
};
|
|
3660
|
+
DayCalendar.defaultProps = {
|
|
3661
|
+
selectedDate: null,
|
|
3662
|
+
min: null,
|
|
3663
|
+
max: null
|
|
3664
|
+
};
|
|
3600
3665
|
var DayCalendar$1 = injectIntl(DayCalendar);
|
|
3601
3666
|
|
|
3602
3667
|
const ROWS$1 = 3;
|
|
@@ -3628,7 +3693,7 @@ const MonthCalendarTable = ({
|
|
|
3628
3693
|
});
|
|
3629
3694
|
};
|
|
3630
3695
|
const isActive = month => {
|
|
3631
|
-
return
|
|
3696
|
+
return selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear();
|
|
3632
3697
|
};
|
|
3633
3698
|
const isThisMonth = month => {
|
|
3634
3699
|
return viewYear === new Date().getFullYear() && month === new Date().getMonth();
|
|
@@ -3652,23 +3717,33 @@ const MonthCalendarTable = ({
|
|
|
3652
3717
|
className: "sr-only",
|
|
3653
3718
|
children: /*#__PURE__*/jsx("tr", {
|
|
3654
3719
|
children: /*#__PURE__*/jsx("th", {
|
|
3655
|
-
colSpan:
|
|
3720
|
+
colSpan: "3",
|
|
3656
3721
|
children: placeholder
|
|
3657
3722
|
})
|
|
3658
3723
|
})
|
|
3659
3724
|
}), /*#__PURE__*/jsx("tbody", {
|
|
3660
|
-
children: Array.
|
|
3661
|
-
|
|
3662
|
-
}, (_, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3663
|
-
children: Array.from({
|
|
3664
|
-
length: COLS$1
|
|
3665
|
-
}, (_, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3725
|
+
children: [...new Array(ROWS$1)].map((row, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3726
|
+
children: [...new Array(COLS$1)].map((col, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3666
3727
|
children: getLink(rowIndex * COLS$1 + colIndex)
|
|
3667
3728
|
}, colIndex))
|
|
3668
3729
|
}, rowIndex))
|
|
3669
3730
|
})]
|
|
3670
3731
|
});
|
|
3671
3732
|
};
|
|
3733
|
+
MonthCalendarTable.propTypes = {
|
|
3734
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3735
|
+
min: PropTypes.instanceOf(Date),
|
|
3736
|
+
max: PropTypes.instanceOf(Date),
|
|
3737
|
+
viewYear: PropTypes.number.isRequired,
|
|
3738
|
+
placeholder: PropTypes.string.isRequired,
|
|
3739
|
+
onSelect: PropTypes.func.isRequired
|
|
3740
|
+
};
|
|
3741
|
+
MonthCalendarTable.defaultProps = {
|
|
3742
|
+
selectedDate: null,
|
|
3743
|
+
min: null,
|
|
3744
|
+
max: null
|
|
3745
|
+
};
|
|
3746
|
+
var MonthCalendarTable$1 = MonthCalendarTable;
|
|
3672
3747
|
|
|
3673
3748
|
class MonthCalendar extends PureComponent {
|
|
3674
3749
|
onMonthSelect = month => {
|
|
@@ -3701,7 +3776,7 @@ class MonthCalendar extends PureComponent {
|
|
|
3701
3776
|
onLabelClick
|
|
3702
3777
|
} = this.props;
|
|
3703
3778
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3704
|
-
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3779
|
+
children: [/*#__PURE__*/jsx(DateHeader$1, {
|
|
3705
3780
|
dateMode: formatMessage(messages$8.year),
|
|
3706
3781
|
label: formatDate(new Date(viewYear, 0), locale, {
|
|
3707
3782
|
year: 'numeric'
|
|
@@ -3709,17 +3784,32 @@ class MonthCalendar extends PureComponent {
|
|
|
3709
3784
|
onLabelClick: onLabelClick,
|
|
3710
3785
|
onPreviousClick: this.selectPreviousYear,
|
|
3711
3786
|
onNextClick: this.selectNextYear
|
|
3712
|
-
}), /*#__PURE__*/jsx(MonthCalendarTable, {
|
|
3713
|
-
selectedDate
|
|
3714
|
-
min
|
|
3715
|
-
max
|
|
3716
|
-
viewYear
|
|
3717
|
-
placeholder
|
|
3787
|
+
}), /*#__PURE__*/jsx(MonthCalendarTable$1, {
|
|
3788
|
+
selectedDate,
|
|
3789
|
+
min,
|
|
3790
|
+
max,
|
|
3791
|
+
viewYear,
|
|
3792
|
+
placeholder,
|
|
3718
3793
|
onSelect: this.onMonthSelect
|
|
3719
3794
|
})]
|
|
3720
3795
|
});
|
|
3721
3796
|
}
|
|
3722
3797
|
}
|
|
3798
|
+
MonthCalendar.propTypes = {
|
|
3799
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3800
|
+
min: PropTypes.instanceOf(Date),
|
|
3801
|
+
max: PropTypes.instanceOf(Date),
|
|
3802
|
+
viewYear: PropTypes.number.isRequired,
|
|
3803
|
+
placeholder: PropTypes.string.isRequired,
|
|
3804
|
+
onSelect: PropTypes.func.isRequired,
|
|
3805
|
+
onLabelClick: PropTypes.func.isRequired,
|
|
3806
|
+
onViewDateUpdate: PropTypes.func.isRequired
|
|
3807
|
+
};
|
|
3808
|
+
MonthCalendar.defaultProps = {
|
|
3809
|
+
selectedDate: null,
|
|
3810
|
+
min: null,
|
|
3811
|
+
max: null
|
|
3812
|
+
};
|
|
3723
3813
|
var MonthCalendar$1 = injectIntl(MonthCalendar);
|
|
3724
3814
|
|
|
3725
3815
|
const ROWS = 5;
|
|
@@ -3775,23 +3865,33 @@ const YearCalendarTable = ({
|
|
|
3775
3865
|
className: "sr-only",
|
|
3776
3866
|
children: /*#__PURE__*/jsx("tr", {
|
|
3777
3867
|
children: /*#__PURE__*/jsx("th", {
|
|
3778
|
-
colSpan:
|
|
3868
|
+
colSpan: "4",
|
|
3779
3869
|
children: placeholder
|
|
3780
3870
|
})
|
|
3781
3871
|
})
|
|
3782
3872
|
}), /*#__PURE__*/jsx("tbody", {
|
|
3783
|
-
children: Array.
|
|
3784
|
-
|
|
3785
|
-
}, (_, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3786
|
-
children: Array.from({
|
|
3787
|
-
length: COLS
|
|
3788
|
-
}, (_, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3873
|
+
children: [...new Array(ROWS)].map((row, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3874
|
+
children: [...new Array(COLS)].map((col, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3789
3875
|
children: getLink(startYear + rowIndex * COLS + colIndex)
|
|
3790
3876
|
}, colIndex))
|
|
3791
3877
|
}, rowIndex))
|
|
3792
3878
|
})]
|
|
3793
3879
|
});
|
|
3794
3880
|
};
|
|
3881
|
+
YearCalendarTable.propTypes = {
|
|
3882
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3883
|
+
min: PropTypes.instanceOf(Date),
|
|
3884
|
+
max: PropTypes.instanceOf(Date),
|
|
3885
|
+
viewYear: PropTypes.number.isRequired,
|
|
3886
|
+
placeholder: PropTypes.string.isRequired,
|
|
3887
|
+
onSelect: PropTypes.func.isRequired
|
|
3888
|
+
};
|
|
3889
|
+
YearCalendarTable.defaultProps = {
|
|
3890
|
+
selectedDate: null,
|
|
3891
|
+
min: null,
|
|
3892
|
+
max: null
|
|
3893
|
+
};
|
|
3894
|
+
var YearCalendarTable$1 = YearCalendarTable;
|
|
3795
3895
|
|
|
3796
3896
|
class YearCalendar extends PureComponent {
|
|
3797
3897
|
onYearSelect = year => {
|
|
@@ -3822,21 +3922,35 @@ class YearCalendar extends PureComponent {
|
|
|
3822
3922
|
}
|
|
3823
3923
|
} = this.props;
|
|
3824
3924
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3825
|
-
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3925
|
+
children: [/*#__PURE__*/jsx(DateHeader$1, {
|
|
3826
3926
|
dateMode: formatMessage(messages$8.twentyYears),
|
|
3827
3927
|
onPreviousClick: this.selectPreviousYears,
|
|
3828
3928
|
onNextClick: this.selectNextYears
|
|
3829
|
-
}), /*#__PURE__*/jsx(YearCalendarTable, {
|
|
3830
|
-
selectedDate
|
|
3831
|
-
min
|
|
3832
|
-
max
|
|
3833
|
-
viewYear
|
|
3834
|
-
placeholder
|
|
3929
|
+
}), /*#__PURE__*/jsx(YearCalendarTable$1, {
|
|
3930
|
+
selectedDate,
|
|
3931
|
+
min,
|
|
3932
|
+
max,
|
|
3933
|
+
viewYear,
|
|
3934
|
+
placeholder,
|
|
3835
3935
|
onSelect: this.onYearSelect
|
|
3836
3936
|
})]
|
|
3837
3937
|
});
|
|
3838
3938
|
}
|
|
3839
3939
|
}
|
|
3940
|
+
YearCalendar.propTypes = {
|
|
3941
|
+
selectedDate: PropTypes.instanceOf(Date),
|
|
3942
|
+
min: PropTypes.instanceOf(Date),
|
|
3943
|
+
max: PropTypes.instanceOf(Date),
|
|
3944
|
+
viewYear: PropTypes.number.isRequired,
|
|
3945
|
+
placeholder: PropTypes.string.isRequired,
|
|
3946
|
+
onSelect: PropTypes.func.isRequired,
|
|
3947
|
+
onViewDateUpdate: PropTypes.func.isRequired
|
|
3948
|
+
};
|
|
3949
|
+
YearCalendar.defaultProps = {
|
|
3950
|
+
selectedDate: null,
|
|
3951
|
+
min: null,
|
|
3952
|
+
max: null
|
|
3953
|
+
};
|
|
3840
3954
|
var YearCalendar$1 = injectIntl(YearCalendar);
|
|
3841
3955
|
|
|
3842
3956
|
const MODE = {
|
|
@@ -3845,17 +3959,6 @@ const MODE = {
|
|
|
3845
3959
|
YEAR: 'year'
|
|
3846
3960
|
};
|
|
3847
3961
|
class DateLookup extends PureComponent {
|
|
3848
|
-
static defaultProps = {
|
|
3849
|
-
value: null,
|
|
3850
|
-
min: null,
|
|
3851
|
-
max: null,
|
|
3852
|
-
size: Size.MEDIUM,
|
|
3853
|
-
placeholder: '',
|
|
3854
|
-
label: '',
|
|
3855
|
-
monthFormat: MonthFormat.LONG,
|
|
3856
|
-
disabled: false,
|
|
3857
|
-
clearable: false
|
|
3858
|
-
};
|
|
3859
3962
|
element = /*#__PURE__*/createRef();
|
|
3860
3963
|
dropdown = /*#__PURE__*/createRef();
|
|
3861
3964
|
constructor(props) {
|
|
@@ -3863,8 +3966,8 @@ class DateLookup extends PureComponent {
|
|
|
3863
3966
|
this.state = {
|
|
3864
3967
|
selectedDate: getStartOfDay(props.value),
|
|
3865
3968
|
originalDate: null,
|
|
3866
|
-
min: getStartOfDay(props.min
|
|
3867
|
-
max: getStartOfDay(props.max
|
|
3969
|
+
min: getStartOfDay(props.min),
|
|
3970
|
+
max: getStartOfDay(props.max),
|
|
3868
3971
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
3869
3972
|
viewYear: (props.value || new Date()).getFullYear(),
|
|
3870
3973
|
open: false,
|
|
@@ -3874,22 +3977,22 @@ class DateLookup extends PureComponent {
|
|
|
3874
3977
|
}
|
|
3875
3978
|
static getDerivedStateFromProps(props, state) {
|
|
3876
3979
|
const propsSelected = getStartOfDay(props.value);
|
|
3877
|
-
const propsMin = getStartOfDay(props.min
|
|
3878
|
-
const propsMax = getStartOfDay(props.max
|
|
3879
|
-
const hasSelectedChanged = state.selectedDate
|
|
3880
|
-
const hasMinChanged = state.min
|
|
3881
|
-
const hasMaxChanged = state.max
|
|
3980
|
+
const propsMin = getStartOfDay(props.min);
|
|
3981
|
+
const propsMax = getStartOfDay(props.max);
|
|
3982
|
+
const hasSelectedChanged = +state.selectedDate !== +propsSelected;
|
|
3983
|
+
const hasMinChanged = +state.min !== +propsMin;
|
|
3984
|
+
const hasMaxChanged = +state.max !== +propsMax;
|
|
3882
3985
|
if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {
|
|
3883
3986
|
const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;
|
|
3884
3987
|
const min = hasMinChanged ? propsMin : state.min;
|
|
3885
3988
|
const max = hasMaxChanged ? propsMax : state.max;
|
|
3886
|
-
|
|
3989
|
+
// make sure that selected date is within allowed range
|
|
3990
|
+
if (!isWithinRange(selectedDate, min, max)) {
|
|
3887
3991
|
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
3888
3992
|
return null;
|
|
3889
3993
|
}
|
|
3890
|
-
const
|
|
3891
|
-
const
|
|
3892
|
-
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
3994
|
+
const viewMonth = (selectedDate || new Date()).getMonth();
|
|
3995
|
+
const viewYear = (selectedDate || new Date()).getFullYear();
|
|
3893
3996
|
return {
|
|
3894
3997
|
selectedDate,
|
|
3895
3998
|
min,
|
|
@@ -3901,12 +4004,12 @@ class DateLookup extends PureComponent {
|
|
|
3901
4004
|
return null;
|
|
3902
4005
|
}
|
|
3903
4006
|
componentDidUpdate(previousProps) {
|
|
3904
|
-
if (this.props.value
|
|
4007
|
+
if (+this.props.value !== +previousProps.value && this.state.open) {
|
|
3905
4008
|
this.focusOn('.active');
|
|
3906
4009
|
}
|
|
3907
|
-
|
|
4010
|
+
this.mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);
|
|
3908
4011
|
this.setState({
|
|
3909
|
-
isMobile: mediaQuery.matches
|
|
4012
|
+
isMobile: this.mediaQuery.matches
|
|
3910
4013
|
});
|
|
3911
4014
|
}
|
|
3912
4015
|
componentWillUnmount() {
|
|
@@ -4012,15 +4115,13 @@ class DateLookup extends PureComponent {
|
|
|
4012
4115
|
} else {
|
|
4013
4116
|
date = getStartOfDay(new Date());
|
|
4014
4117
|
}
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
}
|
|
4018
|
-
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
4118
|
+
date = moveToWithinRange(date, min, max);
|
|
4119
|
+
if (+date !== +selectedDate) {
|
|
4019
4120
|
this.props.onChange(date);
|
|
4020
4121
|
}
|
|
4021
4122
|
};
|
|
4022
4123
|
focusOn = (preferredElement, fallbackElement) => {
|
|
4023
|
-
const element = this.element.current
|
|
4124
|
+
const element = this.element.current.querySelector(preferredElement);
|
|
4024
4125
|
if (element) {
|
|
4025
4126
|
element.focus();
|
|
4026
4127
|
} else if (fallbackElement) {
|
|
@@ -4074,30 +4175,30 @@ class DateLookup extends PureComponent {
|
|
|
4074
4175
|
'p-a-1': !isMobile
|
|
4075
4176
|
}),
|
|
4076
4177
|
children: [mode === MODE.DAY && /*#__PURE__*/jsx(DayCalendar$1, {
|
|
4077
|
-
selectedDate
|
|
4078
|
-
min
|
|
4079
|
-
max
|
|
4080
|
-
viewMonth
|
|
4081
|
-
viewYear
|
|
4082
|
-
monthFormat
|
|
4178
|
+
selectedDate,
|
|
4179
|
+
min,
|
|
4180
|
+
max,
|
|
4181
|
+
viewMonth,
|
|
4182
|
+
viewYear,
|
|
4183
|
+
monthFormat,
|
|
4083
4184
|
onSelect: this.handleSelectedDateUpdate,
|
|
4084
4185
|
onLabelClick: this.switchToYears,
|
|
4085
4186
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4086
4187
|
}), mode === MODE.MONTH && /*#__PURE__*/jsx(MonthCalendar$1, {
|
|
4087
|
-
selectedDate
|
|
4088
|
-
min
|
|
4089
|
-
max
|
|
4090
|
-
viewYear
|
|
4091
|
-
placeholder
|
|
4188
|
+
selectedDate,
|
|
4189
|
+
min,
|
|
4190
|
+
max,
|
|
4191
|
+
viewYear,
|
|
4192
|
+
placeholder,
|
|
4092
4193
|
onSelect: this.switchToDays,
|
|
4093
4194
|
onLabelClick: this.switchToYears,
|
|
4094
4195
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4095
4196
|
}), mode === MODE.YEAR && /*#__PURE__*/jsx(YearCalendar$1, {
|
|
4096
|
-
selectedDate
|
|
4097
|
-
min
|
|
4098
|
-
max
|
|
4099
|
-
viewYear
|
|
4100
|
-
placeholder
|
|
4197
|
+
selectedDate,
|
|
4198
|
+
min,
|
|
4199
|
+
max,
|
|
4200
|
+
viewYear,
|
|
4201
|
+
placeholder,
|
|
4101
4202
|
onSelect: this.switchToMonths,
|
|
4102
4203
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4103
4204
|
})]
|
|
@@ -4123,20 +4224,21 @@ class DateLookup extends PureComponent {
|
|
|
4123
4224
|
value
|
|
4124
4225
|
} = this.props;
|
|
4125
4226
|
return /*#__PURE__*/jsxs("div", {
|
|
4227
|
+
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4126
4228
|
ref: this.element,
|
|
4127
4229
|
id: this.props.id,
|
|
4128
4230
|
"aria-labelledby": ariaLabelledBy,
|
|
4129
4231
|
className: "input-group",
|
|
4130
4232
|
onKeyDown: this.handleKeyDown,
|
|
4131
|
-
children: [/*#__PURE__*/jsx(DateTrigger, {
|
|
4132
|
-
selectedDate
|
|
4133
|
-
size
|
|
4134
|
-
placeholder
|
|
4135
|
-
label
|
|
4136
|
-
monthFormat
|
|
4137
|
-
disabled
|
|
4233
|
+
children: [/*#__PURE__*/jsx(DateTrigger$1, {
|
|
4234
|
+
selectedDate,
|
|
4235
|
+
size,
|
|
4236
|
+
placeholder,
|
|
4237
|
+
label,
|
|
4238
|
+
monthFormat,
|
|
4239
|
+
disabled,
|
|
4138
4240
|
onClick: this.open,
|
|
4139
|
-
onClear: !disabled && clearable && value ? this.handleClear :
|
|
4241
|
+
onClear: !disabled && clearable && value ? this.handleClear : null
|
|
4140
4242
|
}), /*#__PURE__*/jsx(ResponsivePanel$1, {
|
|
4141
4243
|
anchorRef: this.element,
|
|
4142
4244
|
open: open,
|
|
@@ -4148,6 +4250,36 @@ class DateLookup extends PureComponent {
|
|
|
4148
4250
|
});
|
|
4149
4251
|
}
|
|
4150
4252
|
}
|
|
4253
|
+
DateLookup.propTypes = {
|
|
4254
|
+
id: PropTypes.string,
|
|
4255
|
+
value: PropTypes.instanceOf(Date),
|
|
4256
|
+
min: PropTypes.instanceOf(Date),
|
|
4257
|
+
max: PropTypes.instanceOf(Date),
|
|
4258
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
4259
|
+
placeholder: PropTypes.string,
|
|
4260
|
+
label: PropTypes.string,
|
|
4261
|
+
'aria-labelledby': PropTypes.string,
|
|
4262
|
+
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
4263
|
+
disabled: PropTypes.bool,
|
|
4264
|
+
onChange: PropTypes.func.isRequired,
|
|
4265
|
+
onFocus: PropTypes.func,
|
|
4266
|
+
onBlur: PropTypes.func,
|
|
4267
|
+
clearable: PropTypes.bool
|
|
4268
|
+
};
|
|
4269
|
+
DateLookup.defaultProps = {
|
|
4270
|
+
value: null,
|
|
4271
|
+
min: null,
|
|
4272
|
+
max: null,
|
|
4273
|
+
size: Size.MEDIUM,
|
|
4274
|
+
placeholder: '',
|
|
4275
|
+
label: '',
|
|
4276
|
+
monthFormat: MonthFormat.LONG,
|
|
4277
|
+
disabled: false,
|
|
4278
|
+
onFocus: null,
|
|
4279
|
+
onBlur: null,
|
|
4280
|
+
clearable: false
|
|
4281
|
+
};
|
|
4282
|
+
var DateLookup$1 = DateLookup;
|
|
4151
4283
|
|
|
4152
4284
|
const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
4153
4285
|
as: component = 'button',
|
|
@@ -15007,5 +15139,5 @@ const translations = {
|
|
|
15007
15139
|
'zh-HK': zhHK
|
|
15008
15140
|
};
|
|
15009
15141
|
|
|
15010
|
-
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
15142
|
+
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
15011
15143
|
//# sourceMappingURL=index.mjs.map
|