baseui 10.5.0 → 10.6.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/button/styled-components.js +1 -1
- package/button/styled-components.js.flow +4 -1
- package/datepicker/calendar-header.js +227 -95
- package/datepicker/calendar-header.js.flow +270 -139
- package/datepicker/constants.js +4 -2
- package/datepicker/constants.js.flow +2 -0
- package/datepicker/day.js +1 -0
- package/datepicker/day.js.flow +1 -0
- package/datepicker/index.d.ts +1 -0
- package/datepicker/types.js.flow +1 -0
- package/datepicker/utils/calendar-header-helpers.js +51 -0
- package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
- package/dnd-list/index.js.flow +2 -1
- package/drawer/drawer.js +2 -1
- package/drawer/drawer.js.flow +1 -1
- package/es/button/styled-components.js +1 -1
- package/es/datepicker/calendar-header.js +184 -84
- package/es/datepicker/constants.js +2 -1
- package/es/datepicker/day.js +1 -0
- package/es/datepicker/utils/calendar-header-helpers.js +34 -0
- package/es/dnd-list/index.js +2 -1
- package/es/drawer/drawer.js +2 -1
- package/es/popover/stateful-container.js +4 -0
- package/es/rating/emoticon-rating.js +3 -1
- package/es/rating/star-rating.js +3 -1
- package/es/select/select-component.js +4 -5
- package/es/select/styled-components.js +34 -4
- package/es/snackbar/snackbar-context.js +16 -4
- package/es/table-semantic/styled-components.js +6 -4
- package/es/table-semantic/table-builder.js +3 -0
- package/es/themes/dark-theme/color-component-tokens.js +1 -1
- package/es/themes/light-theme/color-component-tokens.js +9 -9
- package/es/tooltip/styled-components.js +8 -0
- package/esm/button/styled-components.js +1 -1
- package/esm/datepicker/calendar-header.js +226 -95
- package/esm/datepicker/constants.js +2 -1
- package/esm/datepicker/day.js +1 -0
- package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
- package/esm/dnd-list/index.js +2 -1
- package/esm/drawer/drawer.js +2 -1
- package/esm/popover/stateful-container.js +4 -0
- package/esm/rating/emoticon-rating.js +2 -2
- package/esm/rating/star-rating.js +2 -2
- package/esm/select/select-component.js +4 -5
- package/esm/select/styled-components.js +28 -4
- package/esm/snackbar/snackbar-context.js +16 -4
- package/esm/table-semantic/styled-components.js +6 -4
- package/esm/table-semantic/table-builder.js +3 -0
- package/esm/themes/dark-theme/color-component-tokens.js +1 -1
- package/esm/themes/light-theme/color-component-tokens.js +9 -9
- package/esm/tooltip/styled-components.js +8 -0
- package/link/index.d.ts +1 -0
- package/menu/index.d.ts +7 -0
- package/menu/types.js.flow +12 -0
- package/package.json +2 -2
- package/popover/stateful-container.js +4 -0
- package/popover/stateful-container.js.flow +3 -0
- package/rating/emoticon-rating.js +2 -2
- package/rating/emoticon-rating.js.flow +4 -1
- package/rating/star-rating.js +2 -2
- package/rating/star-rating.js.flow +4 -1
- package/select/select-component.js +4 -5
- package/select/select-component.js.flow +4 -5
- package/select/styled-components.js +28 -4
- package/select/styled-components.js.flow +30 -2
- package/snackbar/snackbar-context.js +15 -4
- package/snackbar/snackbar-context.js.flow +15 -3
- package/table-semantic/styled-components.js +6 -4
- package/table-semantic/styled-components.js.flow +6 -4
- package/table-semantic/table-builder.js +3 -0
- package/table-semantic/table-builder.js.flow +3 -0
- package/themes/dark-theme/color-component-tokens.js +1 -1
- package/themes/dark-theme/color-component-tokens.js.flow +1 -1
- package/themes/light-theme/color-component-tokens.js +9 -9
- package/themes/light-theme/color-component-tokens.js.flow +9 -9
- package/tooltip/styled-components.js +8 -0
- package/tooltip/styled-components.js.flow +8 -0
|
@@ -14,6 +14,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
14
14
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
20
|
+
|
|
17
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
22
|
|
|
19
23
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -43,11 +47,12 @@ This source code is licensed under the MIT license found in the
|
|
|
43
47
|
LICENSE file in the root directory of this source tree.
|
|
44
48
|
*/
|
|
45
49
|
import * as React from 'react';
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
50
|
+
import ChevronRight from '../icon/chevron-right.js';
|
|
51
|
+
import ChevronLeft from '../icon/chevron-left.js';
|
|
52
|
+
import ChevronDown from '../icon/chevron-down.js';
|
|
49
53
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
50
54
|
import DateHelpers from './utils/date-helpers.js';
|
|
55
|
+
import { getFilteredMonthItems } from './utils/calendar-header-helpers.js';
|
|
51
56
|
import { StatefulMenu } from '../menu/index.js';
|
|
52
57
|
import { Popover } from '../popover/index.js';
|
|
53
58
|
import { LocaleContext } from '../locale/index.js';
|
|
@@ -73,10 +78,6 @@ var DIRECTION = {
|
|
|
73
78
|
PREVIOUS: 'previous'
|
|
74
79
|
};
|
|
75
80
|
|
|
76
|
-
function yearMonthToId(year, month) {
|
|
77
|
-
return "".concat(year, "-").concat(month);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
81
|
function idToYearMonth(id) {
|
|
81
82
|
return id.split('-').map(Number);
|
|
82
83
|
}
|
|
@@ -95,14 +96,13 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
95
96
|
|
|
96
97
|
_defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
|
|
97
98
|
|
|
98
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
99
|
-
|
|
100
|
-
_defineProperty(_assertThisInitialized(_this), "minYear", void 0);
|
|
99
|
+
_defineProperty(_assertThisInitialized(_this), "monthItems", void 0);
|
|
101
100
|
|
|
102
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "yearItems", void 0);
|
|
103
102
|
|
|
104
103
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
105
|
-
|
|
104
|
+
isMonthDropdownOpen: false,
|
|
105
|
+
isYearDropdownOpen: false,
|
|
106
106
|
isFocusVisible: false
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -110,17 +110,94 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
110
110
|
return _this.props.date || _this.dateHelpers.date();
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
114
|
-
var
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "getYearItems", function () {
|
|
114
|
+
var date = _this.getDateProp();
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
var maxDate = _this.props.maxDate;
|
|
117
|
+
var minDate = _this.props.minDate;
|
|
118
|
+
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
119
|
+
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
120
|
+
|
|
121
|
+
var selectedMonth = _this.dateHelpers.getMonth(date); // TODO: this logic can be optimized to only run when minDate / maxDate change
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
_this.yearItems = Array.from({
|
|
125
|
+
length: maxYear - minYear + 1
|
|
126
|
+
}, function (_, i) {
|
|
127
|
+
return minYear + i;
|
|
128
|
+
}).map(function (year) {
|
|
129
|
+
return {
|
|
130
|
+
id: year.toString(),
|
|
131
|
+
label: year.toString()
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
var monthOfMaxDate = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH;
|
|
135
|
+
var monthOfMinDate = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
136
|
+
|
|
137
|
+
var maxYearMonths = Array.from({
|
|
138
|
+
length: monthOfMaxDate + 1
|
|
139
|
+
}, function (x, i) {
|
|
140
|
+
return i;
|
|
141
|
+
}); // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
142
|
+
|
|
143
|
+
var minYearMonths = Array.from({
|
|
144
|
+
length: 12 - monthOfMinDate
|
|
145
|
+
}, function (x, i) {
|
|
146
|
+
return i + monthOfMinDate;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (selectedMonth > maxYearMonths[maxYearMonths.length - 1]) {
|
|
150
|
+
var lastIdx = _this.yearItems.length - 1;
|
|
151
|
+
_this.yearItems[lastIdx] = _objectSpread(_objectSpread({}, _this.yearItems[lastIdx]), {}, {
|
|
152
|
+
disabled: true
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (selectedMonth < minYearMonths[0]) {
|
|
157
|
+
_this.yearItems[0] = _objectSpread(_objectSpread({}, _this.yearItems[0]), {}, {
|
|
158
|
+
disabled: true
|
|
120
159
|
});
|
|
121
160
|
}
|
|
122
161
|
});
|
|
123
162
|
|
|
163
|
+
_defineProperty(_assertThisInitialized(_this), "getMonthItems", function () {
|
|
164
|
+
var date = _this.getDateProp();
|
|
165
|
+
|
|
166
|
+
var year = _this.dateHelpers.getYear(date);
|
|
167
|
+
|
|
168
|
+
var maxDate = _this.props.maxDate;
|
|
169
|
+
var minDate = _this.props.minDate;
|
|
170
|
+
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
171
|
+
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
172
|
+
var monthOfMaxDate = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
173
|
+
|
|
174
|
+
var maxYearMonths = Array.from({
|
|
175
|
+
length: monthOfMaxDate + 1
|
|
176
|
+
}, function (x, i) {
|
|
177
|
+
return i;
|
|
178
|
+
});
|
|
179
|
+
var monthOfMinDate = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
180
|
+
|
|
181
|
+
var minYearMonths = Array.from({
|
|
182
|
+
length: 12 - monthOfMinDate
|
|
183
|
+
}, function (x, i) {
|
|
184
|
+
return i + monthOfMinDate;
|
|
185
|
+
});
|
|
186
|
+
var maxMinYearMonthsIntersection = maxYearMonths.filter(function (year) {
|
|
187
|
+
return minYearMonths.includes(year);
|
|
188
|
+
});
|
|
189
|
+
var filterMonthsList = year === maxYear && year === minYear ? maxMinYearMonthsIntersection : year === maxYear ? maxYearMonths : year === minYear ? minYearMonths : null;
|
|
190
|
+
|
|
191
|
+
var formatMonthLabel = function formatMonthLabel(month) {
|
|
192
|
+
return _this.dateHelpers.getMonthInLocale(month, _this.props.locale);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
_this.monthItems = getFilteredMonthItems({
|
|
196
|
+
filterMonthsList: filterMonthsList,
|
|
197
|
+
formatMonthLabel: formatMonthLabel
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
124
201
|
_defineProperty(_assertThisInitialized(_this), "increaseMonth", function () {
|
|
125
202
|
if (_this.props.onMonthChange) {
|
|
126
203
|
// $FlowFixMe
|
|
@@ -188,9 +265,9 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
188
265
|
}
|
|
189
266
|
});
|
|
190
267
|
|
|
191
|
-
_defineProperty(_assertThisInitialized(_this), "renderPreviousMonthButton", function (
|
|
192
|
-
var locale =
|
|
193
|
-
theme =
|
|
268
|
+
_defineProperty(_assertThisInitialized(_this), "renderPreviousMonthButton", function (_ref2) {
|
|
269
|
+
var locale = _ref2.locale,
|
|
270
|
+
theme = _ref2.theme;
|
|
194
271
|
|
|
195
272
|
var date = _this.getDateProp();
|
|
196
273
|
|
|
@@ -224,7 +301,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
224
301
|
PrevButton = _getOverrides2[0],
|
|
225
302
|
prevButtonProps = _getOverrides2[1];
|
|
226
303
|
|
|
227
|
-
var _getOverrides3 = getOverrides(overrides.PrevButtonIcon, theme.direction === 'rtl' ?
|
|
304
|
+
var _getOverrides3 = getOverrides(overrides.PrevButtonIcon, theme.direction === 'rtl' ? ChevronRight : ChevronLeft),
|
|
228
305
|
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
229
306
|
PrevButtonIcon = _getOverrides4[0],
|
|
230
307
|
prevButtonIconProps = _getOverrides4[1];
|
|
@@ -254,9 +331,9 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
254
331
|
}, prevButtonIconProps)));
|
|
255
332
|
});
|
|
256
333
|
|
|
257
|
-
_defineProperty(_assertThisInitialized(_this), "renderNextMonthButton", function (
|
|
258
|
-
var locale =
|
|
259
|
-
theme =
|
|
334
|
+
_defineProperty(_assertThisInitialized(_this), "renderNextMonthButton", function (_ref3) {
|
|
335
|
+
var locale = _ref3.locale,
|
|
336
|
+
theme = _ref3.theme;
|
|
260
337
|
|
|
261
338
|
var date = _this.getDateProp();
|
|
262
339
|
|
|
@@ -290,7 +367,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
290
367
|
NextButton = _getOverrides6[0],
|
|
291
368
|
nextButtonProps = _getOverrides6[1];
|
|
292
369
|
|
|
293
|
-
var _getOverrides7 = getOverrides(overrides.NextButtonIcon, theme.direction === 'rtl' ?
|
|
370
|
+
var _getOverrides7 = getOverrides(overrides.NextButtonIcon, theme.direction === 'rtl' ? ChevronLeft : ChevronRight),
|
|
294
371
|
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
295
372
|
NextButtonIcon = _getOverrides8[0],
|
|
296
373
|
nextButtonIconProps = _getOverrides8[1];
|
|
@@ -325,7 +402,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
325
402
|
});
|
|
326
403
|
|
|
327
404
|
_defineProperty(_assertThisInitialized(_this), "canArrowsOpenDropdown", function (event) {
|
|
328
|
-
if (!_this.state.
|
|
405
|
+
if (!_this.state.isMonthDropdownOpen && !_this.state.isYearDropdownOpen) {
|
|
329
406
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
330
407
|
return true;
|
|
331
408
|
}
|
|
@@ -337,10 +414,12 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
337
414
|
_defineProperty(_assertThisInitialized(_this), "renderMonthYearDropdown", function () {
|
|
338
415
|
var date = _this.getDateProp();
|
|
339
416
|
|
|
417
|
+
var month = _this.dateHelpers.getMonth(date);
|
|
418
|
+
|
|
419
|
+
var year = _this.dateHelpers.getYear(date);
|
|
420
|
+
|
|
340
421
|
var _this$props3 = _this.props,
|
|
341
422
|
locale = _this$props3.locale,
|
|
342
|
-
maxDate = _this$props3.maxDate,
|
|
343
|
-
minDate = _this$props3.minDate,
|
|
344
423
|
_this$props3$override = _this$props3.overrides,
|
|
345
424
|
overrides = _this$props3$override === void 0 ? {} : _this$props3$override;
|
|
346
425
|
|
|
@@ -375,115 +454,144 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
375
454
|
menuProps && menuProps.overrides); // $FlowFixMe
|
|
376
455
|
|
|
377
456
|
menuProps.overrides = menuOverrides;
|
|
378
|
-
var defaultMonths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
379
|
-
var maxYear = maxDate ? _this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
380
|
-
var minYear = minDate ? _this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
381
|
-
var maxDateMonth = maxDate ? _this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... maxDateMonth]
|
|
382
457
|
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
}, function (x, i) {
|
|
386
|
-
return i;
|
|
458
|
+
var initialMonthIndex = _this.monthItems.findIndex(function (month) {
|
|
459
|
+
return month.id === _this.dateHelpers.getMonth(date).toString();
|
|
387
460
|
});
|
|
388
|
-
var minDateMonth = minDate ? _this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [minDateMonth, ...., 10, 11]
|
|
389
461
|
|
|
390
|
-
var
|
|
391
|
-
|
|
392
|
-
}, function (x, i) {
|
|
393
|
-
return i + minDateMonth;
|
|
462
|
+
var initialYearIndex = _this.yearItems.findIndex(function (year) {
|
|
463
|
+
return year.id === _this.dateHelpers.getYear(date).toString();
|
|
394
464
|
});
|
|
395
465
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
466
|
+
var monthTitle = "".concat(_this.dateHelpers.getMonthInLocale(_this.dateHelpers.getMonth(date), locale));
|
|
467
|
+
var yearTitle = "".concat(_this.dateHelpers.getYear(date));
|
|
468
|
+
return _this.isMultiMonthHorizontal() ? /*#__PURE__*/React.createElement("div", null, "".concat(monthTitle, " ").concat(yearTitle)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
469
|
+
placement: "bottom",
|
|
470
|
+
autoFocus: true,
|
|
471
|
+
focusLock: true,
|
|
472
|
+
isOpen: _this.state.isMonthDropdownOpen,
|
|
473
|
+
onClick: function onClick() {
|
|
474
|
+
_this.setState(function (prev) {
|
|
475
|
+
return {
|
|
476
|
+
isMonthDropdownOpen: !prev.isMonthDropdownOpen
|
|
477
|
+
};
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
onClickOutside: function onClickOutside() {
|
|
481
|
+
return _this.setState({
|
|
482
|
+
isMonthDropdownOpen: false
|
|
483
|
+
});
|
|
484
|
+
},
|
|
485
|
+
onEsc: function onEsc() {
|
|
486
|
+
return _this.setState({
|
|
487
|
+
isMonthDropdownOpen: false
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
content: function content() {
|
|
491
|
+
return /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
492
|
+
initialState: {
|
|
493
|
+
highlightedIndex: initialMonthIndex,
|
|
494
|
+
isFocused: true
|
|
495
|
+
},
|
|
496
|
+
items: _this.monthItems,
|
|
497
|
+
onItemSelect: function onItemSelect(_ref4) {
|
|
498
|
+
var item = _ref4.item,
|
|
499
|
+
event = _ref4.event;
|
|
500
|
+
event.preventDefault();
|
|
501
|
+
var month = idToYearMonth(item.id);
|
|
502
|
+
|
|
503
|
+
var updatedDate = _this.dateHelpers.set(date, {
|
|
504
|
+
year: year,
|
|
505
|
+
month: month
|
|
506
|
+
});
|
|
400
507
|
|
|
401
|
-
|
|
402
|
-
|
|
508
|
+
_this.props.onMonthChange && _this.props.onMonthChange({
|
|
509
|
+
date: updatedDate
|
|
510
|
+
});
|
|
403
511
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
512
|
+
_this.setState({
|
|
513
|
+
isMonthDropdownOpen: false
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
}, menuProps));
|
|
517
|
+
}
|
|
518
|
+
}, popoverProps), /*#__PURE__*/React.createElement(MonthYearSelectButton, _extends({
|
|
519
|
+
"aria-live": "polite",
|
|
520
|
+
type: "button",
|
|
521
|
+
$isFocusVisible: _this.state.isFocusVisible,
|
|
522
|
+
onKeyUp: function onKeyUp(event) {
|
|
523
|
+
if (_this.canArrowsOpenDropdown(event)) {
|
|
524
|
+
_this.setState({
|
|
525
|
+
isMonthDropdownOpen: true
|
|
407
526
|
});
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
onKeyDown: function onKeyDown(event) {
|
|
530
|
+
if (_this.canArrowsOpenDropdown(event)) {
|
|
531
|
+
// disables page scroll
|
|
532
|
+
event.preventDefault();
|
|
414
533
|
}
|
|
415
534
|
|
|
416
|
-
|
|
417
|
-
_this.
|
|
418
|
-
|
|
419
|
-
label: "".concat(_this.dateHelpers.getMonthInLocale(month, locale), " ").concat(i)
|
|
535
|
+
if (event.key === 'Tab') {
|
|
536
|
+
_this.setState({
|
|
537
|
+
isMonthDropdownOpen: false
|
|
420
538
|
});
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
for (var i = minYear; i <= maxYear; i++) {
|
|
425
|
-
_loop(i);
|
|
539
|
+
}
|
|
426
540
|
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
541
|
+
}, monthYearSelectButtonProps), monthTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(ChevronDown, {
|
|
542
|
+
title: "",
|
|
543
|
+
overrides: {
|
|
544
|
+
Svg: {
|
|
545
|
+
props: {
|
|
546
|
+
role: 'presentation'
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
})))), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
435
551
|
placement: "bottom",
|
|
436
|
-
autoFocus: true,
|
|
437
552
|
focusLock: true,
|
|
438
|
-
isOpen: _this.state.
|
|
553
|
+
isOpen: _this.state.isYearDropdownOpen,
|
|
439
554
|
onClick: function onClick() {
|
|
440
555
|
_this.setState(function (prev) {
|
|
441
556
|
return {
|
|
442
|
-
|
|
557
|
+
isYearDropdownOpen: !prev.isYearDropdownOpen
|
|
443
558
|
};
|
|
444
559
|
});
|
|
445
560
|
},
|
|
446
561
|
onClickOutside: function onClickOutside() {
|
|
447
562
|
return _this.setState({
|
|
448
|
-
|
|
563
|
+
isYearDropdownOpen: false
|
|
449
564
|
});
|
|
450
565
|
},
|
|
451
566
|
onEsc: function onEsc() {
|
|
452
567
|
return _this.setState({
|
|
453
|
-
|
|
568
|
+
isYearDropdownOpen: false
|
|
454
569
|
});
|
|
455
570
|
},
|
|
456
571
|
content: function content() {
|
|
457
572
|
return /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
458
573
|
initialState: {
|
|
459
|
-
highlightedIndex:
|
|
574
|
+
highlightedIndex: initialYearIndex,
|
|
460
575
|
isFocused: true
|
|
461
576
|
},
|
|
462
|
-
items: _this.
|
|
577
|
+
items: _this.yearItems,
|
|
463
578
|
onItemSelect: function onItemSelect(_ref5) {
|
|
464
579
|
var item = _ref5.item,
|
|
465
580
|
event = _ref5.event;
|
|
466
581
|
event.preventDefault();
|
|
467
|
-
|
|
468
|
-
var _idToYearMonth = idToYearMonth(item.id),
|
|
469
|
-
_idToYearMonth2 = _slicedToArray(_idToYearMonth, 2),
|
|
470
|
-
year = _idToYearMonth2[0],
|
|
471
|
-
month = _idToYearMonth2[1];
|
|
582
|
+
var year = idToYearMonth(item.id);
|
|
472
583
|
|
|
473
584
|
var updatedDate = _this.dateHelpers.set(date, {
|
|
474
585
|
year: year,
|
|
475
586
|
month: month
|
|
476
587
|
});
|
|
477
588
|
|
|
478
|
-
_this.props.onMonthChange && _this.props.onMonthChange({
|
|
479
|
-
date: updatedDate
|
|
480
|
-
});
|
|
481
589
|
_this.props.onYearChange && _this.props.onYearChange({
|
|
482
590
|
date: updatedDate
|
|
483
591
|
});
|
|
484
592
|
|
|
485
593
|
_this.setState({
|
|
486
|
-
|
|
594
|
+
isYearDropdownOpen: false
|
|
487
595
|
});
|
|
488
596
|
}
|
|
489
597
|
}, menuProps));
|
|
@@ -495,7 +603,7 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
495
603
|
onKeyUp: function onKeyUp(event) {
|
|
496
604
|
if (_this.canArrowsOpenDropdown(event)) {
|
|
497
605
|
_this.setState({
|
|
498
|
-
|
|
606
|
+
isYearDropdownOpen: true
|
|
499
607
|
});
|
|
500
608
|
}
|
|
501
609
|
},
|
|
@@ -507,11 +615,11 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
507
615
|
|
|
508
616
|
if (event.key === 'Tab') {
|
|
509
617
|
_this.setState({
|
|
510
|
-
|
|
618
|
+
isYearDropdownOpen: false
|
|
511
619
|
});
|
|
512
620
|
}
|
|
513
621
|
}
|
|
514
|
-
}, monthYearSelectButtonProps),
|
|
622
|
+
}, monthYearSelectButtonProps), yearTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(ChevronDown, {
|
|
515
623
|
title: "",
|
|
516
624
|
overrides: {
|
|
517
625
|
Svg: {
|
|
@@ -520,15 +628,38 @@ var CalendarHeader = /*#__PURE__*/function (_React$Component) {
|
|
|
520
628
|
}
|
|
521
629
|
}
|
|
522
630
|
}
|
|
523
|
-
}))));
|
|
631
|
+
})))));
|
|
524
632
|
});
|
|
525
633
|
|
|
526
634
|
_this.dateHelpers = new DateHelpers(props.adapter);
|
|
527
|
-
_this.
|
|
635
|
+
_this.monthItems = [];
|
|
636
|
+
_this.yearItems = [];
|
|
528
637
|
return _this;
|
|
529
638
|
}
|
|
530
639
|
|
|
531
640
|
_createClass(CalendarHeader, [{
|
|
641
|
+
key: "componentDidMount",
|
|
642
|
+
value: function componentDidMount() {
|
|
643
|
+
this.getYearItems();
|
|
644
|
+
this.getMonthItems();
|
|
645
|
+
}
|
|
646
|
+
}, {
|
|
647
|
+
key: "componentDidUpdate",
|
|
648
|
+
value: function componentDidUpdate(prevProps) {
|
|
649
|
+
var selectedMonthDidChange = this.dateHelpers.getMonth(this.props.date) !== this.dateHelpers.getMonth(prevProps.date);
|
|
650
|
+
var selectedYearDidChange = this.dateHelpers.getYear(this.props.date) !== this.dateHelpers.getYear(prevProps.date);
|
|
651
|
+
|
|
652
|
+
if (selectedMonthDidChange) {
|
|
653
|
+
// re-calculate yearItems
|
|
654
|
+
this.getYearItems();
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (selectedYearDidChange) {
|
|
658
|
+
// re-calculate monthItems
|
|
659
|
+
this.getMonthItems();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}, {
|
|
532
663
|
key: "render",
|
|
533
664
|
value: function render() {
|
|
534
665
|
var _this2 = this;
|
|
@@ -20,4 +20,5 @@ export var STATE_CHANGE_TYPE = Object.freeze({
|
|
|
20
20
|
mouseOver: 'mouseOver',
|
|
21
21
|
mouseLeave: 'mouseLeave'
|
|
22
22
|
});
|
|
23
|
-
export var WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
23
|
+
export var WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
24
|
+
export var DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
package/esm/datepicker/day.js
CHANGED
|
@@ -344,6 +344,7 @@ var Day = /*#__PURE__*/function (_React$Component) {
|
|
|
344
344
|
$isFocusVisible: this.state.isFocusVisible,
|
|
345
345
|
$startOfMonth: this.dateHelpers.isStartOfMonth(date),
|
|
346
346
|
$endOfMonth: this.dateHelpers.isEndOfMonth(date),
|
|
347
|
+
$month: this.getMonthProp(),
|
|
347
348
|
$outsideMonth: $outsideMonth,
|
|
348
349
|
$outsideMonthWithinRange: $outsideMonthWithinRange,
|
|
349
350
|
$peekNextMonth: this.props.peekNextMonth,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Copyright (c) Uber Technologies, Inc.
|
|
9
|
+
|
|
10
|
+
This source code is licensed under the MIT license found in the
|
|
11
|
+
LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
import { DEFAULT_MONTHS } from '../constants.js';
|
|
14
|
+
|
|
15
|
+
var getDefaultMonthItems = function getDefaultMonthItems(formatMonthLabel) {
|
|
16
|
+
return DEFAULT_MONTHS.map(function (month) {
|
|
17
|
+
return {
|
|
18
|
+
id: month.toString(),
|
|
19
|
+
label: formatMonthLabel(month)
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export var filterMonthItems = function filterMonthItems(monthItems, filterList) {
|
|
25
|
+
return monthItems.map(function (month) {
|
|
26
|
+
if (!filterList.includes(Number(month.id))) {
|
|
27
|
+
return _objectSpread(_objectSpread({}, month), {}, {
|
|
28
|
+
disabled: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return month;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export var getFilteredMonthItems = function getFilteredMonthItems(_ref) {
|
|
36
|
+
var filterMonthsList = _ref.filterMonthsList,
|
|
37
|
+
formatMonthLabel = _ref.formatMonthLabel;
|
|
38
|
+
var monthItems = getDefaultMonthItems(formatMonthLabel);
|
|
39
|
+
|
|
40
|
+
if (filterMonthsList) {
|
|
41
|
+
monthItems = filterMonthItems(monthItems, filterMonthsList);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return monthItems;
|
|
45
|
+
};
|
package/esm/dnd-list/index.js
CHANGED
|
@@ -4,7 +4,8 @@ Copyright (c) Uber Technologies, Inc.
|
|
|
4
4
|
This source code is licensed under the MIT license found in the
|
|
5
5
|
LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import { arrayMove, arrayRemove } from 'react-movable';
|
|
8
|
+
export { arrayMove, arrayRemove };
|
|
8
9
|
export { default as StatefulList } from './stateful-list.js';
|
|
9
10
|
export { default as StatefulListContainer } from './stateful-list-container.js';
|
|
10
11
|
export { default as List } from './list.js'; // Constants
|
package/esm/drawer/drawer.js
CHANGED
|
@@ -331,7 +331,8 @@ var Drawer = /*#__PURE__*/function (_React$Component) {
|
|
|
331
331
|
return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
|
|
332
332
|
return /*#__PURE__*/React.createElement(FocusLock, {
|
|
333
333
|
returnFocus: true,
|
|
334
|
-
autoFocus: autoFocus
|
|
334
|
+
autoFocus: autoFocus,
|
|
335
|
+
noFocusGuards: true
|
|
335
336
|
}, /*#__PURE__*/React.createElement(Root, _extends({
|
|
336
337
|
"data-baseweb": "drawer",
|
|
337
338
|
ref: _this3.getRef('Root')
|
|
@@ -213,8 +213,8 @@ var EmoticonRating = /*#__PURE__*/function (_React$Component) {
|
|
|
213
213
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
214
214
|
"data-baseweb": "emoticon-rating",
|
|
215
215
|
role: "radiogroup",
|
|
216
|
-
onBlur: function onBlur() {
|
|
217
|
-
|
|
216
|
+
onBlur: function onBlur(e) {
|
|
217
|
+
if (!e.currentTarget.contains(e.relatedTarget)) _this2.updatePreview(undefined);
|
|
218
218
|
},
|
|
219
219
|
onMouseLeave: function onMouseLeave() {
|
|
220
220
|
return _this2.updatePreview(undefined);
|
|
@@ -216,8 +216,8 @@ var StarRating = /*#__PURE__*/function (_React$Component) {
|
|
|
216
216
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
217
217
|
"data-baseweb": "star-rating",
|
|
218
218
|
role: "radiogroup",
|
|
219
|
-
onBlur: function onBlur() {
|
|
220
|
-
|
|
219
|
+
onBlur: function onBlur(e) {
|
|
220
|
+
if (!e.currentTarget.contains(e.relatedTarget)) _this2.updatePreview(undefined);
|
|
221
221
|
},
|
|
222
222
|
onMouseLeave: function onMouseLeave() {
|
|
223
223
|
return _this2.updatePreview(undefined);
|
|
@@ -159,7 +159,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
159
159
|
isPseudoFocused: false
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
162
|
+
_defineProperty(_assertThisInitialized(_this), "isItMounted", false);
|
|
163
163
|
|
|
164
164
|
_defineProperty(_assertThisInitialized(_this), "handleTouchOutside", function (event) {
|
|
165
165
|
if (containsNode(_this.dropdown.current, event.target)) return;
|
|
@@ -307,7 +307,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
307
307
|
_this.props.onBlur(event);
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
if (_this.
|
|
310
|
+
if (_this.isItMounted) {
|
|
311
311
|
_this.setState({
|
|
312
312
|
isFocused: false,
|
|
313
313
|
isOpen: false,
|
|
@@ -661,7 +661,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
661
661
|
this.focus();
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
this.
|
|
664
|
+
this.isItMounted = true;
|
|
665
665
|
|
|
666
666
|
if (this.props.methodsRef) {
|
|
667
667
|
var methodsRef = this.props.methodsRef;
|
|
@@ -697,7 +697,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
697
697
|
document.removeEventListener('click', this.handleClickOutside);
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
-
this.
|
|
700
|
+
this.isItMounted = false;
|
|
701
701
|
}
|
|
702
702
|
}, {
|
|
703
703
|
key: "focus",
|
|
@@ -926,7 +926,6 @@ var Select = /*#__PURE__*/function (_React$Component) {
|
|
|
926
926
|
|
|
927
927
|
var ariaLabel = this.props.multi ? 'Clear all' : 'Clear value';
|
|
928
928
|
return /*#__PURE__*/React.createElement(ClearIcon, _extends({
|
|
929
|
-
size: 16,
|
|
930
929
|
title: ariaLabel,
|
|
931
930
|
"aria-label": ariaLabel,
|
|
932
931
|
onClick: this.clearValue,
|