@telus-uds/components-web 2.43.0 → 2.44.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/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-web
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 13 Nov 2024 17:18:39 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.44.0
|
|
8
|
+
|
|
9
|
+
Wed, 13 Nov 2024 17:18:39 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `DatePicker`: add initialVisibleMonth prop (guillermo.peitzner@telus.com)
|
|
14
|
+
|
|
7
15
|
## 2.43.0
|
|
8
16
|
|
|
9
|
-
Thu, 31 Oct 2024 05:
|
|
17
|
+
Thu, 31 Oct 2024 05:09:12 GMT
|
|
10
18
|
|
|
11
19
|
### Minor changes
|
|
12
20
|
|
|
@@ -71,6 +71,12 @@ const PortalPositionedContainer = /*#__PURE__*/_styledComponents.default.div.wit
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/;
|
|
74
|
+
const getInitialVisibleMonth = (initialVisibleMonth, inputDate) => {
|
|
75
|
+
if (initialVisibleMonth === '' || inputDate instanceof _moment.default) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return () => (0, _moment.default)(initialVisibleMonth);
|
|
79
|
+
};
|
|
74
80
|
|
|
75
81
|
/**
|
|
76
82
|
* Use DatePicker to select a date on a calendar.
|
|
@@ -114,6 +120,7 @@ const DatePicker = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
114
120
|
prevTestID = '',
|
|
115
121
|
nextTestID = '',
|
|
116
122
|
placeholder = 'DD / MM / YYYY',
|
|
123
|
+
initialVisibleMonth = '',
|
|
117
124
|
...rest
|
|
118
125
|
} = _ref3;
|
|
119
126
|
const [inputDate, setInputDate] = _react.default.useState(date instanceof _moment.default ? date : undefined);
|
|
@@ -337,7 +344,7 @@ const DatePicker = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
337
344
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DayPickerSingleDateController.default, {
|
|
338
345
|
date: inputDate,
|
|
339
346
|
onDateChange: onChange,
|
|
340
|
-
focused: inputDate ?? isFocused,
|
|
347
|
+
focused: (inputDate ?? isFocused) || initialVisibleMonth !== '',
|
|
341
348
|
onFocusChange: onFocusChange,
|
|
342
349
|
numberOfMonths: 1,
|
|
343
350
|
hideKeyboardShortcutsPanel: true,
|
|
@@ -347,6 +354,7 @@ const DatePicker = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
347
354
|
renderNavNextButton: renderNextButton,
|
|
348
355
|
isOutsideRange: isDayDisabled,
|
|
349
356
|
phrases: getCopy(),
|
|
357
|
+
initialVisibleMonth: getInitialVisibleMonth(initialVisibleMonth, inputDate),
|
|
350
358
|
renderMonthElement: _ref7 => {
|
|
351
359
|
let {
|
|
352
360
|
month
|
|
@@ -410,6 +418,7 @@ const DatePicker = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
410
418
|
phrases: getCopy(),
|
|
411
419
|
id: id,
|
|
412
420
|
renderNavNextButton: renderNextButton,
|
|
421
|
+
initialVisibleMonth: getInitialVisibleMonth(initialVisibleMonth, inputDate),
|
|
413
422
|
renderMonthElement: _ref8 => {
|
|
414
423
|
let {
|
|
415
424
|
month
|
|
@@ -506,7 +515,11 @@ DatePicker.propTypes = {
|
|
|
506
515
|
/**
|
|
507
516
|
* Optional placeholder for the date input. If not set the default value will be `DD / MM / YYYY`
|
|
508
517
|
*/
|
|
509
|
-
placeholder: _propTypes.default.string
|
|
518
|
+
placeholder: _propTypes.default.string,
|
|
519
|
+
/**
|
|
520
|
+
* The initial month to display when the calendar is opened. Expects a string in the format `YYYY-MM`
|
|
521
|
+
*/
|
|
522
|
+
initialVisibleMonth: _propTypes.default.string
|
|
510
523
|
};
|
|
511
524
|
var _default = DatePicker;
|
|
512
525
|
exports.default = _default;
|
|
@@ -66,6 +66,12 @@ const PortalPositionedContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/;
|
|
69
|
+
const getInitialVisibleMonth = (initialVisibleMonth, inputDate) => {
|
|
70
|
+
if (initialVisibleMonth === '' || inputDate instanceof moment) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return () => moment(initialVisibleMonth);
|
|
74
|
+
};
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
77
|
* Use DatePicker to select a date on a calendar.
|
|
@@ -109,6 +115,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
109
115
|
prevTestID = '',
|
|
110
116
|
nextTestID = '',
|
|
111
117
|
placeholder = 'DD / MM / YYYY',
|
|
118
|
+
initialVisibleMonth = '',
|
|
112
119
|
...rest
|
|
113
120
|
} = _ref3;
|
|
114
121
|
const [inputDate, setInputDate] = React.useState(date instanceof moment ? date : undefined);
|
|
@@ -332,7 +339,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
332
339
|
children: /*#__PURE__*/_jsx(DayPickerSingleDateController, {
|
|
333
340
|
date: inputDate,
|
|
334
341
|
onDateChange: onChange,
|
|
335
|
-
focused: inputDate ?? isFocused,
|
|
342
|
+
focused: (inputDate ?? isFocused) || initialVisibleMonth !== '',
|
|
336
343
|
onFocusChange: onFocusChange,
|
|
337
344
|
numberOfMonths: 1,
|
|
338
345
|
hideKeyboardShortcutsPanel: true,
|
|
@@ -342,6 +349,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
342
349
|
renderNavNextButton: renderNextButton,
|
|
343
350
|
isOutsideRange: isDayDisabled,
|
|
344
351
|
phrases: getCopy(),
|
|
352
|
+
initialVisibleMonth: getInitialVisibleMonth(initialVisibleMonth, inputDate),
|
|
345
353
|
renderMonthElement: _ref7 => {
|
|
346
354
|
let {
|
|
347
355
|
month
|
|
@@ -405,6 +413,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
405
413
|
phrases: getCopy(),
|
|
406
414
|
id: id,
|
|
407
415
|
renderNavNextButton: renderNextButton,
|
|
416
|
+
initialVisibleMonth: getInitialVisibleMonth(initialVisibleMonth, inputDate),
|
|
408
417
|
renderMonthElement: _ref8 => {
|
|
409
418
|
let {
|
|
410
419
|
month
|
|
@@ -501,6 +510,10 @@ DatePicker.propTypes = {
|
|
|
501
510
|
/**
|
|
502
511
|
* Optional placeholder for the date input. If not set the default value will be `DD / MM / YYYY`
|
|
503
512
|
*/
|
|
504
|
-
placeholder: PropTypes.string
|
|
513
|
+
placeholder: PropTypes.string,
|
|
514
|
+
/**
|
|
515
|
+
* The initial month to display when the calendar is opened. Expects a string in the format `YYYY-MM`
|
|
516
|
+
*/
|
|
517
|
+
initialVisibleMonth: PropTypes.string
|
|
505
518
|
};
|
|
506
519
|
export default DatePicker;
|
package/package.json
CHANGED
|
@@ -58,6 +58,13 @@ const PortalPositionedContainer = styled.div({
|
|
|
58
58
|
|
|
59
59
|
const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/
|
|
60
60
|
|
|
61
|
+
const getInitialVisibleMonth = (initialVisibleMonth, inputDate) => {
|
|
62
|
+
if (initialVisibleMonth === '' || inputDate instanceof moment) {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
return () => moment(initialVisibleMonth)
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* Use DatePicker to select a date on a calendar.
|
|
63
70
|
*
|
|
@@ -100,6 +107,7 @@ const DatePicker = React.forwardRef(
|
|
|
100
107
|
prevTestID = '',
|
|
101
108
|
nextTestID = '',
|
|
102
109
|
placeholder = 'DD / MM / YYYY',
|
|
110
|
+
initialVisibleMonth = '',
|
|
103
111
|
...rest
|
|
104
112
|
},
|
|
105
113
|
ref
|
|
@@ -321,7 +329,7 @@ const DatePicker = React.forwardRef(
|
|
|
321
329
|
<DayPickerSingleDateController
|
|
322
330
|
date={inputDate}
|
|
323
331
|
onDateChange={onChange}
|
|
324
|
-
focused={inputDate ?? isFocused}
|
|
332
|
+
focused={(inputDate ?? isFocused) || initialVisibleMonth !== ''}
|
|
325
333
|
onFocusChange={onFocusChange}
|
|
326
334
|
numberOfMonths={1}
|
|
327
335
|
hideKeyboardShortcutsPanel={true}
|
|
@@ -331,6 +339,7 @@ const DatePicker = React.forwardRef(
|
|
|
331
339
|
renderNavNextButton={renderNextButton}
|
|
332
340
|
isOutsideRange={isDayDisabled}
|
|
333
341
|
phrases={getCopy()}
|
|
342
|
+
initialVisibleMonth={getInitialVisibleMonth(initialVisibleMonth, inputDate)}
|
|
334
343
|
renderMonthElement={({ month }) => (
|
|
335
344
|
<MonthCenterContainer>
|
|
336
345
|
<div>
|
|
@@ -414,6 +423,7 @@ const DatePicker = React.forwardRef(
|
|
|
414
423
|
phrases={getCopy()}
|
|
415
424
|
id={id}
|
|
416
425
|
renderNavNextButton={renderNextButton}
|
|
426
|
+
initialVisibleMonth={getInitialVisibleMonth(initialVisibleMonth, inputDate)}
|
|
417
427
|
renderMonthElement={({ month }) => (
|
|
418
428
|
<MonthCenterContainer>
|
|
419
429
|
<div>
|
|
@@ -516,7 +526,11 @@ DatePicker.propTypes = {
|
|
|
516
526
|
/**
|
|
517
527
|
* Optional placeholder for the date input. If not set the default value will be `DD / MM / YYYY`
|
|
518
528
|
*/
|
|
519
|
-
placeholder: PropTypes.string
|
|
529
|
+
placeholder: PropTypes.string,
|
|
530
|
+
/**
|
|
531
|
+
* The initial month to display when the calendar is opened. Expects a string in the format `YYYY-MM`
|
|
532
|
+
*/
|
|
533
|
+
initialVisibleMonth: PropTypes.string
|
|
520
534
|
}
|
|
521
535
|
|
|
522
536
|
export default DatePicker
|