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
package/drawer/drawer.js
CHANGED
|
@@ -342,7 +342,8 @@ var Drawer = /*#__PURE__*/function (_React$Component) {
|
|
|
342
342
|
return /*#__PURE__*/React.createElement(_index.LocaleContext.Consumer, null, function (locale) {
|
|
343
343
|
return /*#__PURE__*/React.createElement(_reactFocusLock.default, {
|
|
344
344
|
returnFocus: true,
|
|
345
|
-
autoFocus: autoFocus
|
|
345
|
+
autoFocus: autoFocus,
|
|
346
|
+
noFocusGuards: true
|
|
346
347
|
}, /*#__PURE__*/React.createElement(Root, _extends({
|
|
347
348
|
"data-baseweb": "drawer",
|
|
348
349
|
ref: _this3.getRef('Root')
|
package/drawer/drawer.js.flow
CHANGED
|
@@ -253,7 +253,7 @@ class Drawer extends React.Component<DrawerPropsT, DrawerStateT> {
|
|
|
253
253
|
<LocaleContext.Consumer>
|
|
254
254
|
{locale => {
|
|
255
255
|
return (
|
|
256
|
-
<FocusLock returnFocus autoFocus={autoFocus}>
|
|
256
|
+
<FocusLock returnFocus autoFocus={autoFocus} noFocusGuards={true}>
|
|
257
257
|
<Root
|
|
258
258
|
data-baseweb="drawer"
|
|
259
259
|
ref={this.getRef('Root')}
|
|
@@ -39,7 +39,7 @@ export const BaseButton = styled('button', ({
|
|
|
39
39
|
cursor: 'pointer',
|
|
40
40
|
':disabled': {
|
|
41
41
|
cursor: 'not-allowed',
|
|
42
|
-
backgroundColor: $theme.colors.buttonDisabledFill,
|
|
42
|
+
backgroundColor: $kind === KIND.minimal || $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
43
43
|
color: $theme.colors.buttonDisabledText
|
|
44
44
|
},
|
|
45
45
|
marginLeft: 0,
|
|
@@ -9,11 +9,12 @@ This source code is licensed under the MIT license found in the
|
|
|
9
9
|
LICENSE file in the root directory of this source tree.
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import ChevronRight from '../icon/chevron-right.js';
|
|
13
|
+
import ChevronLeft from '../icon/chevron-left.js';
|
|
14
|
+
import ChevronDown from '../icon/chevron-down.js';
|
|
15
15
|
import dateFnsAdapter from './utils/date-fns-adapter.js';
|
|
16
16
|
import DateHelpers from './utils/date-helpers.js';
|
|
17
|
+
import { getFilteredMonthItems } from './utils/calendar-header-helpers.js';
|
|
17
18
|
import { StatefulMenu } from '../menu/index.js';
|
|
18
19
|
import { Popover } from '../popover/index.js';
|
|
19
20
|
import { LocaleContext } from '../locale/index.js';
|
|
@@ -38,10 +39,6 @@ const DIRECTION = {
|
|
|
38
39
|
PREVIOUS: 'previous'
|
|
39
40
|
};
|
|
40
41
|
|
|
41
|
-
function yearMonthToId(year, month) {
|
|
42
|
-
return `${year}-${month}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
42
|
function idToYearMonth(id) {
|
|
46
43
|
return id.split('-').map(Number);
|
|
47
44
|
}
|
|
@@ -52,14 +49,13 @@ export default class CalendarHeader extends React.Component {
|
|
|
52
49
|
|
|
53
50
|
_defineProperty(this, "dateHelpers", void 0);
|
|
54
51
|
|
|
55
|
-
_defineProperty(this, "
|
|
52
|
+
_defineProperty(this, "monthItems", void 0);
|
|
56
53
|
|
|
57
|
-
_defineProperty(this, "
|
|
58
|
-
|
|
59
|
-
_defineProperty(this, "maxYear", void 0);
|
|
54
|
+
_defineProperty(this, "yearItems", void 0);
|
|
60
55
|
|
|
61
56
|
_defineProperty(this, "state", {
|
|
62
|
-
|
|
57
|
+
isMonthDropdownOpen: false,
|
|
58
|
+
isYearDropdownOpen: false,
|
|
63
59
|
isFocusVisible: false
|
|
64
60
|
});
|
|
65
61
|
|
|
@@ -67,17 +63,73 @@ export default class CalendarHeader extends React.Component {
|
|
|
67
63
|
return this.props.date || this.dateHelpers.date();
|
|
68
64
|
});
|
|
69
65
|
|
|
70
|
-
_defineProperty(this, "
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
_defineProperty(this, "getYearItems", () => {
|
|
67
|
+
const date = this.getDateProp();
|
|
68
|
+
const maxDate = this.props.maxDate;
|
|
69
|
+
const minDate = this.props.minDate;
|
|
70
|
+
const maxYear = maxDate ? this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
71
|
+
const minYear = minDate ? this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
72
|
+
const selectedMonth = this.dateHelpers.getMonth(date); // TODO: this logic can be optimized to only run when minDate / maxDate change
|
|
73
|
+
|
|
74
|
+
this.yearItems = Array.from({
|
|
75
|
+
length: maxYear - minYear + 1
|
|
76
|
+
}, (_, i) => minYear + i).map(year => ({
|
|
77
|
+
id: year.toString(),
|
|
78
|
+
label: year.toString()
|
|
79
|
+
}));
|
|
80
|
+
const monthOfMaxDate = maxDate ? this.dateHelpers.getMonth(maxDate) : MAX_MONTH;
|
|
81
|
+
const monthOfMinDate = minDate ? this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
82
|
+
|
|
83
|
+
const maxYearMonths = Array.from({
|
|
84
|
+
length: monthOfMaxDate + 1
|
|
85
|
+
}, (x, i) => i); // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
86
|
+
|
|
87
|
+
const minYearMonths = Array.from({
|
|
88
|
+
length: 12 - monthOfMinDate
|
|
89
|
+
}, (x, i) => i + monthOfMinDate);
|
|
90
|
+
|
|
91
|
+
if (selectedMonth > maxYearMonths[maxYearMonths.length - 1]) {
|
|
92
|
+
const lastIdx = this.yearItems.length - 1;
|
|
93
|
+
this.yearItems[lastIdx] = { ...this.yearItems[lastIdx],
|
|
94
|
+
disabled: true
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (selectedMonth < minYearMonths[0]) {
|
|
99
|
+
this.yearItems[0] = { ...this.yearItems[0],
|
|
100
|
+
disabled: true
|
|
101
|
+
};
|
|
78
102
|
}
|
|
79
103
|
});
|
|
80
104
|
|
|
105
|
+
_defineProperty(this, "getMonthItems", () => {
|
|
106
|
+
const date = this.getDateProp();
|
|
107
|
+
const year = this.dateHelpers.getYear(date);
|
|
108
|
+
const maxDate = this.props.maxDate;
|
|
109
|
+
const minDate = this.props.minDate;
|
|
110
|
+
const maxYear = maxDate ? this.dateHelpers.getYear(maxDate) : MAX_YEAR;
|
|
111
|
+
const minYear = minDate ? this.dateHelpers.getYear(minDate) : MIN_YEAR;
|
|
112
|
+
const monthOfMaxDate = maxDate ? this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... monthOfMaxDate]
|
|
113
|
+
|
|
114
|
+
const maxYearMonths = Array.from({
|
|
115
|
+
length: monthOfMaxDate + 1
|
|
116
|
+
}, (x, i) => i);
|
|
117
|
+
const monthOfMinDate = minDate ? this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [monthOfMinDate, ...., 10, 11]
|
|
118
|
+
|
|
119
|
+
const minYearMonths = Array.from({
|
|
120
|
+
length: 12 - monthOfMinDate
|
|
121
|
+
}, (x, i) => i + monthOfMinDate);
|
|
122
|
+
const maxMinYearMonthsIntersection = maxYearMonths.filter(year => minYearMonths.includes(year));
|
|
123
|
+
const filterMonthsList = year === maxYear && year === minYear ? maxMinYearMonthsIntersection : year === maxYear ? maxYearMonths : year === minYear ? minYearMonths : null;
|
|
124
|
+
|
|
125
|
+
const formatMonthLabel = month => this.dateHelpers.getMonthInLocale(month, this.props.locale);
|
|
126
|
+
|
|
127
|
+
this.monthItems = getFilteredMonthItems({
|
|
128
|
+
filterMonthsList,
|
|
129
|
+
formatMonthLabel
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
81
133
|
_defineProperty(this, "increaseMonth", () => {
|
|
82
134
|
if (this.props.onMonthChange) {
|
|
83
135
|
// $FlowFixMe
|
|
@@ -176,7 +228,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
176
228
|
}
|
|
177
229
|
|
|
178
230
|
const [PrevButton, prevButtonProps] = getOverrides(overrides.PrevButton, StyledPrevButton);
|
|
179
|
-
const [PrevButtonIcon, prevButtonIconProps] = getOverrides(overrides.PrevButtonIcon, theme.direction === 'rtl' ?
|
|
231
|
+
const [PrevButtonIcon, prevButtonIconProps] = getOverrides(overrides.PrevButtonIcon, theme.direction === 'rtl' ? ChevronRight : ChevronLeft);
|
|
180
232
|
let clickHandler = this.decreaseMonth;
|
|
181
233
|
|
|
182
234
|
if (allPrevDaysDisabled) {
|
|
@@ -231,7 +283,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
231
283
|
}
|
|
232
284
|
|
|
233
285
|
const [NextButton, nextButtonProps] = getOverrides(overrides.NextButton, StyledNextButton);
|
|
234
|
-
const [NextButtonIcon, nextButtonIconProps] = getOverrides(overrides.NextButtonIcon, theme.direction === 'rtl' ?
|
|
286
|
+
const [NextButtonIcon, nextButtonIconProps] = getOverrides(overrides.NextButtonIcon, theme.direction === 'rtl' ? ChevronLeft : ChevronRight);
|
|
235
287
|
let clickHandler = this.increaseMonth; // The other option is to always provide a click handler and let customers
|
|
236
288
|
// override its functionality based on the `$allPrevDaysDisabled` prop
|
|
237
289
|
// in a custom NextButton component override
|
|
@@ -262,7 +314,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
262
314
|
});
|
|
263
315
|
|
|
264
316
|
_defineProperty(this, "canArrowsOpenDropdown", event => {
|
|
265
|
-
if (!this.state.
|
|
317
|
+
if (!this.state.isMonthDropdownOpen && !this.state.isYearDropdownOpen) {
|
|
266
318
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
267
319
|
return true;
|
|
268
320
|
}
|
|
@@ -273,10 +325,10 @@ export default class CalendarHeader extends React.Component {
|
|
|
273
325
|
|
|
274
326
|
_defineProperty(this, "renderMonthYearDropdown", () => {
|
|
275
327
|
const date = this.getDateProp();
|
|
328
|
+
const month = this.dateHelpers.getMonth(date);
|
|
329
|
+
const year = this.dateHelpers.getYear(date);
|
|
276
330
|
const {
|
|
277
331
|
locale,
|
|
278
|
-
maxDate,
|
|
279
|
-
minDate,
|
|
280
332
|
overrides = {}
|
|
281
333
|
} = this.props;
|
|
282
334
|
const [MonthYearSelectButton, monthYearSelectButtonProps] = getOverrides(overrides.MonthYearSelectButton, StyledMonthYearSelectButton);
|
|
@@ -294,79 +346,38 @@ export default class CalendarHeader extends React.Component {
|
|
|
294
346
|
menuProps && menuProps.overrides); // $FlowFixMe
|
|
295
347
|
|
|
296
348
|
menuProps.overrides = menuOverrides;
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
const maxYearMonths = Array.from({
|
|
303
|
-
length: maxDateMonth + 1
|
|
304
|
-
}, (x, i) => i);
|
|
305
|
-
const minDateMonth = minDate ? this.dateHelpers.getMonth(minDate) : MIN_MONTH; // Generates array like [minDateMonth, ...., 10, 11]
|
|
306
|
-
|
|
307
|
-
const minYearMonths = Array.from({
|
|
308
|
-
length: 12 - minDateMonth
|
|
309
|
-
}, (x, i) => i + minDateMonth);
|
|
310
|
-
|
|
311
|
-
if (this.maxYear !== maxYear || this.minYear !== minYear) {
|
|
312
|
-
this.maxYear = maxYear;
|
|
313
|
-
this.minYear = minYear;
|
|
314
|
-
this.items = [];
|
|
315
|
-
|
|
316
|
-
for (let i = minYear; i <= maxYear; i++) {
|
|
317
|
-
let months;
|
|
318
|
-
|
|
319
|
-
if (i === minYear && i === maxYear) {
|
|
320
|
-
months = maxYearMonths.filter(month => minYearMonths.includes(month));
|
|
321
|
-
} else if (i === minYear) {
|
|
322
|
-
months = minYearMonths;
|
|
323
|
-
} else if (i === maxYear) {
|
|
324
|
-
months = maxYearMonths;
|
|
325
|
-
} else {
|
|
326
|
-
months = defaultMonths;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
months.forEach(month => {
|
|
330
|
-
this.items.push({
|
|
331
|
-
id: yearMonthToId(i, month),
|
|
332
|
-
label: `${this.dateHelpers.getMonthInLocale(month, locale)} ${i}`
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const initialIndex = this.items.findIndex(item => {
|
|
339
|
-
return item.id === yearMonthToId(this.dateHelpers.getYear(date), this.dateHelpers.getMonth(date));
|
|
340
|
-
});
|
|
341
|
-
const monthYearTitle = `${this.dateHelpers.getMonthInLocale(this.dateHelpers.getMonth(date), locale)} ${this.dateHelpers.getYear(date)}`;
|
|
342
|
-
return this.isMultiMonthHorizontal() ? /*#__PURE__*/React.createElement("div", null, monthYearTitle) : /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
349
|
+
const initialMonthIndex = this.monthItems.findIndex(month => month.id === this.dateHelpers.getMonth(date).toString());
|
|
350
|
+
const initialYearIndex = this.yearItems.findIndex(year => year.id === this.dateHelpers.getYear(date).toString());
|
|
351
|
+
const monthTitle = `${this.dateHelpers.getMonthInLocale(this.dateHelpers.getMonth(date), locale)}`;
|
|
352
|
+
const yearTitle = `${this.dateHelpers.getYear(date)}`;
|
|
353
|
+
return this.isMultiMonthHorizontal() ? /*#__PURE__*/React.createElement("div", null, `${monthTitle} ${yearTitle}`) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
343
354
|
placement: "bottom",
|
|
344
355
|
autoFocus: true,
|
|
345
356
|
focusLock: true,
|
|
346
|
-
isOpen: this.state.
|
|
357
|
+
isOpen: this.state.isMonthDropdownOpen,
|
|
347
358
|
onClick: () => {
|
|
348
359
|
this.setState(prev => ({
|
|
349
|
-
|
|
360
|
+
isMonthDropdownOpen: !prev.isMonthDropdownOpen
|
|
350
361
|
}));
|
|
351
362
|
},
|
|
352
363
|
onClickOutside: () => this.setState({
|
|
353
|
-
|
|
364
|
+
isMonthDropdownOpen: false
|
|
354
365
|
}),
|
|
355
366
|
onEsc: () => this.setState({
|
|
356
|
-
|
|
367
|
+
isMonthDropdownOpen: false
|
|
357
368
|
}),
|
|
358
369
|
content: () => /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
359
370
|
initialState: {
|
|
360
|
-
highlightedIndex:
|
|
371
|
+
highlightedIndex: initialMonthIndex,
|
|
361
372
|
isFocused: true
|
|
362
373
|
},
|
|
363
|
-
items: this.
|
|
374
|
+
items: this.monthItems,
|
|
364
375
|
onItemSelect: ({
|
|
365
376
|
item,
|
|
366
377
|
event
|
|
367
378
|
}) => {
|
|
368
379
|
event.preventDefault();
|
|
369
|
-
const
|
|
380
|
+
const month = idToYearMonth(item.id);
|
|
370
381
|
const updatedDate = this.dateHelpers.set(date, {
|
|
371
382
|
year,
|
|
372
383
|
month
|
|
@@ -374,11 +385,79 @@ export default class CalendarHeader extends React.Component {
|
|
|
374
385
|
this.props.onMonthChange && this.props.onMonthChange({
|
|
375
386
|
date: updatedDate
|
|
376
387
|
});
|
|
388
|
+
this.setState({
|
|
389
|
+
isMonthDropdownOpen: false
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}, menuProps))
|
|
393
|
+
}, popoverProps), /*#__PURE__*/React.createElement(MonthYearSelectButton, _extends({
|
|
394
|
+
"aria-live": "polite",
|
|
395
|
+
type: "button",
|
|
396
|
+
$isFocusVisible: this.state.isFocusVisible,
|
|
397
|
+
onKeyUp: event => {
|
|
398
|
+
if (this.canArrowsOpenDropdown(event)) {
|
|
399
|
+
this.setState({
|
|
400
|
+
isMonthDropdownOpen: true
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
onKeyDown: event => {
|
|
405
|
+
if (this.canArrowsOpenDropdown(event)) {
|
|
406
|
+
// disables page scroll
|
|
407
|
+
event.preventDefault();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (event.key === 'Tab') {
|
|
411
|
+
this.setState({
|
|
412
|
+
isMonthDropdownOpen: false
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}, monthYearSelectButtonProps), monthTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(ChevronDown, {
|
|
417
|
+
title: "",
|
|
418
|
+
overrides: {
|
|
419
|
+
Svg: {
|
|
420
|
+
props: {
|
|
421
|
+
role: 'presentation'
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
})))), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
|
|
426
|
+
placement: "bottom",
|
|
427
|
+
focusLock: true,
|
|
428
|
+
isOpen: this.state.isYearDropdownOpen,
|
|
429
|
+
onClick: () => {
|
|
430
|
+
this.setState(prev => ({
|
|
431
|
+
isYearDropdownOpen: !prev.isYearDropdownOpen
|
|
432
|
+
}));
|
|
433
|
+
},
|
|
434
|
+
onClickOutside: () => this.setState({
|
|
435
|
+
isYearDropdownOpen: false
|
|
436
|
+
}),
|
|
437
|
+
onEsc: () => this.setState({
|
|
438
|
+
isYearDropdownOpen: false
|
|
439
|
+
}),
|
|
440
|
+
content: () => /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
|
|
441
|
+
initialState: {
|
|
442
|
+
highlightedIndex: initialYearIndex,
|
|
443
|
+
isFocused: true
|
|
444
|
+
},
|
|
445
|
+
items: this.yearItems,
|
|
446
|
+
onItemSelect: ({
|
|
447
|
+
item,
|
|
448
|
+
event
|
|
449
|
+
}) => {
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
const year = idToYearMonth(item.id);
|
|
452
|
+
const updatedDate = this.dateHelpers.set(date, {
|
|
453
|
+
year,
|
|
454
|
+
month
|
|
455
|
+
});
|
|
377
456
|
this.props.onYearChange && this.props.onYearChange({
|
|
378
457
|
date: updatedDate
|
|
379
458
|
});
|
|
380
459
|
this.setState({
|
|
381
|
-
|
|
460
|
+
isYearDropdownOpen: false
|
|
382
461
|
});
|
|
383
462
|
}
|
|
384
463
|
}, menuProps))
|
|
@@ -389,7 +468,7 @@ export default class CalendarHeader extends React.Component {
|
|
|
389
468
|
onKeyUp: event => {
|
|
390
469
|
if (this.canArrowsOpenDropdown(event)) {
|
|
391
470
|
this.setState({
|
|
392
|
-
|
|
471
|
+
isYearDropdownOpen: true
|
|
393
472
|
});
|
|
394
473
|
}
|
|
395
474
|
},
|
|
@@ -401,11 +480,11 @@ export default class CalendarHeader extends React.Component {
|
|
|
401
480
|
|
|
402
481
|
if (event.key === 'Tab') {
|
|
403
482
|
this.setState({
|
|
404
|
-
|
|
483
|
+
isYearDropdownOpen: false
|
|
405
484
|
});
|
|
406
485
|
}
|
|
407
486
|
}
|
|
408
|
-
}, monthYearSelectButtonProps),
|
|
487
|
+
}, monthYearSelectButtonProps), yearTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(ChevronDown, {
|
|
409
488
|
title: "",
|
|
410
489
|
overrides: {
|
|
411
490
|
Svg: {
|
|
@@ -414,11 +493,32 @@ export default class CalendarHeader extends React.Component {
|
|
|
414
493
|
}
|
|
415
494
|
}
|
|
416
495
|
}
|
|
417
|
-
}))));
|
|
496
|
+
})))));
|
|
418
497
|
});
|
|
419
498
|
|
|
420
499
|
this.dateHelpers = new DateHelpers(props.adapter);
|
|
421
|
-
this.
|
|
500
|
+
this.monthItems = [];
|
|
501
|
+
this.yearItems = [];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
componentDidMount() {
|
|
505
|
+
this.getYearItems();
|
|
506
|
+
this.getMonthItems();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
componentDidUpdate(prevProps) {
|
|
510
|
+
const selectedMonthDidChange = this.dateHelpers.getMonth(this.props.date) !== this.dateHelpers.getMonth(prevProps.date);
|
|
511
|
+
const selectedYearDidChange = this.dateHelpers.getYear(this.props.date) !== this.dateHelpers.getYear(prevProps.date);
|
|
512
|
+
|
|
513
|
+
if (selectedMonthDidChange) {
|
|
514
|
+
// re-calculate yearItems
|
|
515
|
+
this.getYearItems();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (selectedYearDidChange) {
|
|
519
|
+
// re-calculate monthItems
|
|
520
|
+
this.getMonthItems();
|
|
521
|
+
}
|
|
422
522
|
}
|
|
423
523
|
|
|
424
524
|
render() {
|
|
@@ -20,4 +20,5 @@ export const STATE_CHANGE_TYPE = Object.freeze({
|
|
|
20
20
|
mouseOver: 'mouseOver',
|
|
21
21
|
mouseLeave: 'mouseLeave'
|
|
22
22
|
});
|
|
23
|
-
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
23
|
+
export const WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
|
|
24
|
+
export const DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
package/es/datepicker/day.js
CHANGED
|
@@ -292,6 +292,7 @@ export default class Day extends React.Component {
|
|
|
292
292
|
$isFocusVisible: this.state.isFocusVisible,
|
|
293
293
|
$startOfMonth: this.dateHelpers.isStartOfMonth(date),
|
|
294
294
|
$endOfMonth: this.dateHelpers.isEndOfMonth(date),
|
|
295
|
+
$month: this.getMonthProp(),
|
|
295
296
|
$outsideMonth,
|
|
296
297
|
$outsideMonthWithinRange,
|
|
297
298
|
$peekNextMonth: this.props.peekNextMonth,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_MONTHS } from '../constants.js';
|
|
8
|
+
|
|
9
|
+
const getDefaultMonthItems = formatMonthLabel => DEFAULT_MONTHS.map(month => ({
|
|
10
|
+
id: month.toString(),
|
|
11
|
+
label: formatMonthLabel(month)
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
export const filterMonthItems = (monthItems, filterList) => monthItems.map(month => {
|
|
15
|
+
if (!filterList.includes(Number(month.id))) {
|
|
16
|
+
return { ...month,
|
|
17
|
+
disabled: true
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return month;
|
|
22
|
+
});
|
|
23
|
+
export const getFilteredMonthItems = ({
|
|
24
|
+
filterMonthsList,
|
|
25
|
+
formatMonthLabel
|
|
26
|
+
}) => {
|
|
27
|
+
let monthItems = getDefaultMonthItems(formatMonthLabel);
|
|
28
|
+
|
|
29
|
+
if (filterMonthsList) {
|
|
30
|
+
monthItems = filterMonthItems(monthItems, filterMonthsList);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return monthItems;
|
|
34
|
+
};
|
package/es/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/es/drawer/drawer.js
CHANGED
|
@@ -252,7 +252,8 @@ class Drawer extends React.Component {
|
|
|
252
252
|
return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => {
|
|
253
253
|
return /*#__PURE__*/React.createElement(FocusLock, {
|
|
254
254
|
returnFocus: true,
|
|
255
|
-
autoFocus: autoFocus
|
|
255
|
+
autoFocus: autoFocus,
|
|
256
|
+
noFocusGuards: true
|
|
256
257
|
}, /*#__PURE__*/React.createElement(Root, _extends({
|
|
257
258
|
"data-baseweb": "drawer",
|
|
258
259
|
ref: this.getRef('Root')
|
|
@@ -144,7 +144,9 @@ class EmoticonRating extends React.Component {
|
|
|
144
144
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
145
145
|
"data-baseweb": "emoticon-rating",
|
|
146
146
|
role: "radiogroup",
|
|
147
|
-
onBlur:
|
|
147
|
+
onBlur: e => {
|
|
148
|
+
if (!e.currentTarget.contains(e.relatedTarget)) this.updatePreview(undefined);
|
|
149
|
+
},
|
|
148
150
|
onMouseLeave: () => this.updatePreview(undefined)
|
|
149
151
|
}, rootProps), this.renderRatingContents());
|
|
150
152
|
}
|
package/es/rating/star-rating.js
CHANGED
|
@@ -147,7 +147,9 @@ class StarRating extends React.Component {
|
|
|
147
147
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
148
148
|
"data-baseweb": "star-rating",
|
|
149
149
|
role: "radiogroup",
|
|
150
|
-
onBlur:
|
|
150
|
+
onBlur: e => {
|
|
151
|
+
if (!e.currentTarget.contains(e.relatedTarget)) this.updatePreview(undefined);
|
|
152
|
+
},
|
|
151
153
|
onMouseLeave: () => this.updatePreview(undefined)
|
|
152
154
|
}, rootProps), this.renderRatingContents());
|
|
153
155
|
}
|
|
@@ -105,7 +105,7 @@ class Select extends React.Component {
|
|
|
105
105
|
isPseudoFocused: false
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
_defineProperty(this, "
|
|
108
|
+
_defineProperty(this, "isItMounted", false);
|
|
109
109
|
|
|
110
110
|
_defineProperty(this, "handleTouchOutside", event => {
|
|
111
111
|
if (containsNode(this.dropdown.current, event.target)) return;
|
|
@@ -238,7 +238,7 @@ class Select extends React.Component {
|
|
|
238
238
|
this.props.onBlur(event);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
if (this.
|
|
241
|
+
if (this.isItMounted) {
|
|
242
242
|
this.setState({
|
|
243
243
|
isFocused: false,
|
|
244
244
|
isOpen: false,
|
|
@@ -565,7 +565,7 @@ class Select extends React.Component {
|
|
|
565
565
|
this.focus();
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
-
this.
|
|
568
|
+
this.isItMounted = true;
|
|
569
569
|
|
|
570
570
|
if (this.props.methodsRef) {
|
|
571
571
|
const {
|
|
@@ -601,7 +601,7 @@ class Select extends React.Component {
|
|
|
601
601
|
document.removeEventListener('click', this.handleClickOutside);
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
this.
|
|
604
|
+
this.isItMounted = false;
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
focus() {
|
|
@@ -797,7 +797,6 @@ class Select extends React.Component {
|
|
|
797
797
|
const [ClearIcon, clearIconProps] = getOverrides(overrides.ClearIcon, DeleteAlt);
|
|
798
798
|
const ariaLabel = this.props.multi ? 'Clear all' : 'Clear value';
|
|
799
799
|
return /*#__PURE__*/React.createElement(ClearIcon, _extends({
|
|
800
|
-
size: 16,
|
|
801
800
|
title: ariaLabel,
|
|
802
801
|
"aria-label": ariaLabel,
|
|
803
802
|
onClick: this.clearValue,
|
|
@@ -375,31 +375,61 @@ function getSvgStyles({
|
|
|
375
375
|
export const StyledSelectArrow = styled('svg', props => {
|
|
376
376
|
const {
|
|
377
377
|
$theme,
|
|
378
|
-
$disabled
|
|
378
|
+
$disabled,
|
|
379
|
+
$size
|
|
379
380
|
} = props;
|
|
380
381
|
const {
|
|
381
382
|
colors
|
|
382
383
|
} = $theme;
|
|
384
|
+
const sizes = {
|
|
385
|
+
[SIZE.mini]: 16,
|
|
386
|
+
[SIZE.compact]: 16,
|
|
387
|
+
[SIZE.default]: 20,
|
|
388
|
+
[SIZE.large]: 24
|
|
389
|
+
};
|
|
390
|
+
let size = sizes[SIZE.default];
|
|
391
|
+
|
|
392
|
+
if ($size) {
|
|
393
|
+
size = sizes[$size];
|
|
394
|
+
}
|
|
395
|
+
|
|
383
396
|
return { ...getSvgStyles({
|
|
384
397
|
$theme
|
|
385
398
|
}),
|
|
386
399
|
color: $disabled ? colors.inputTextDisabled : colors.contentPrimary,
|
|
387
|
-
cursor: $disabled ? 'not-allowed' : 'pointer'
|
|
400
|
+
cursor: $disabled ? 'not-allowed' : 'pointer',
|
|
401
|
+
height: `${size}px`,
|
|
402
|
+
width: `${size}px`
|
|
388
403
|
};
|
|
389
404
|
});
|
|
390
405
|
StyledSelectArrow.displayName = "StyledSelectArrow";
|
|
391
406
|
export const StyledClearIcon = styled('svg', props => {
|
|
392
407
|
const {
|
|
393
|
-
$theme
|
|
408
|
+
$theme,
|
|
409
|
+
$size
|
|
394
410
|
} = props;
|
|
395
411
|
const {
|
|
396
412
|
colors
|
|
397
413
|
} = $theme;
|
|
414
|
+
const sizes = {
|
|
415
|
+
[SIZE.mini]: 15,
|
|
416
|
+
[SIZE.compact]: 15,
|
|
417
|
+
[SIZE.default]: 18,
|
|
418
|
+
[SIZE.large]: 22
|
|
419
|
+
};
|
|
420
|
+
let size = sizes[SIZE.default];
|
|
421
|
+
|
|
422
|
+
if ($size) {
|
|
423
|
+
size = sizes[$size];
|
|
424
|
+
}
|
|
425
|
+
|
|
398
426
|
return { ...getSvgStyles({
|
|
399
427
|
$theme
|
|
400
428
|
}),
|
|
401
429
|
color: colors.contentPrimary,
|
|
402
|
-
cursor: 'pointer'
|
|
430
|
+
cursor: 'pointer',
|
|
431
|
+
height: `${size}px`,
|
|
432
|
+
width: `${size}px`
|
|
403
433
|
};
|
|
404
434
|
});
|
|
405
435
|
StyledClearIcon.displayName = "StyledClearIcon";
|