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.
Files changed (77) hide show
  1. package/button/styled-components.js +1 -1
  2. package/button/styled-components.js.flow +4 -1
  3. package/datepicker/calendar-header.js +227 -95
  4. package/datepicker/calendar-header.js.flow +270 -139
  5. package/datepicker/constants.js +4 -2
  6. package/datepicker/constants.js.flow +2 -0
  7. package/datepicker/day.js +1 -0
  8. package/datepicker/day.js.flow +1 -0
  9. package/datepicker/index.d.ts +1 -0
  10. package/datepicker/types.js.flow +1 -0
  11. package/datepicker/utils/calendar-header-helpers.js +51 -0
  12. package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
  13. package/dnd-list/index.js.flow +2 -1
  14. package/drawer/drawer.js +2 -1
  15. package/drawer/drawer.js.flow +1 -1
  16. package/es/button/styled-components.js +1 -1
  17. package/es/datepicker/calendar-header.js +184 -84
  18. package/es/datepicker/constants.js +2 -1
  19. package/es/datepicker/day.js +1 -0
  20. package/es/datepicker/utils/calendar-header-helpers.js +34 -0
  21. package/es/dnd-list/index.js +2 -1
  22. package/es/drawer/drawer.js +2 -1
  23. package/es/popover/stateful-container.js +4 -0
  24. package/es/rating/emoticon-rating.js +3 -1
  25. package/es/rating/star-rating.js +3 -1
  26. package/es/select/select-component.js +4 -5
  27. package/es/select/styled-components.js +34 -4
  28. package/es/snackbar/snackbar-context.js +16 -4
  29. package/es/table-semantic/styled-components.js +6 -4
  30. package/es/table-semantic/table-builder.js +3 -0
  31. package/es/themes/dark-theme/color-component-tokens.js +1 -1
  32. package/es/themes/light-theme/color-component-tokens.js +9 -9
  33. package/es/tooltip/styled-components.js +8 -0
  34. package/esm/button/styled-components.js +1 -1
  35. package/esm/datepicker/calendar-header.js +226 -95
  36. package/esm/datepicker/constants.js +2 -1
  37. package/esm/datepicker/day.js +1 -0
  38. package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
  39. package/esm/dnd-list/index.js +2 -1
  40. package/esm/drawer/drawer.js +2 -1
  41. package/esm/popover/stateful-container.js +4 -0
  42. package/esm/rating/emoticon-rating.js +2 -2
  43. package/esm/rating/star-rating.js +2 -2
  44. package/esm/select/select-component.js +4 -5
  45. package/esm/select/styled-components.js +28 -4
  46. package/esm/snackbar/snackbar-context.js +16 -4
  47. package/esm/table-semantic/styled-components.js +6 -4
  48. package/esm/table-semantic/table-builder.js +3 -0
  49. package/esm/themes/dark-theme/color-component-tokens.js +1 -1
  50. package/esm/themes/light-theme/color-component-tokens.js +9 -9
  51. package/esm/tooltip/styled-components.js +8 -0
  52. package/link/index.d.ts +1 -0
  53. package/menu/index.d.ts +7 -0
  54. package/menu/types.js.flow +12 -0
  55. package/package.json +2 -2
  56. package/popover/stateful-container.js +4 -0
  57. package/popover/stateful-container.js.flow +3 -0
  58. package/rating/emoticon-rating.js +2 -2
  59. package/rating/emoticon-rating.js.flow +4 -1
  60. package/rating/star-rating.js +2 -2
  61. package/rating/star-rating.js.flow +4 -1
  62. package/select/select-component.js +4 -5
  63. package/select/select-component.js.flow +4 -5
  64. package/select/styled-components.js +28 -4
  65. package/select/styled-components.js.flow +30 -2
  66. package/snackbar/snackbar-context.js +15 -4
  67. package/snackbar/snackbar-context.js.flow +15 -3
  68. package/table-semantic/styled-components.js +6 -4
  69. package/table-semantic/styled-components.js.flow +6 -4
  70. package/table-semantic/table-builder.js +3 -0
  71. package/table-semantic/table-builder.js.flow +3 -0
  72. package/themes/dark-theme/color-component-tokens.js +1 -1
  73. package/themes/dark-theme/color-component-tokens.js.flow +1 -1
  74. package/themes/light-theme/color-component-tokens.js +9 -9
  75. package/themes/light-theme/color-component-tokens.js.flow +9 -9
  76. package/tooltip/styled-components.js +8 -0
  77. 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')
@@ -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 ArrowRight from '../icon/arrow-right.js';
13
- import ArrowLeft from '../icon/arrow-left.js';
14
- import TriangleDown from '../icon/triangle-down.js';
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, "items", void 0);
52
+ _defineProperty(this, "monthItems", void 0);
56
53
 
57
- _defineProperty(this, "minYear", void 0);
58
-
59
- _defineProperty(this, "maxYear", void 0);
54
+ _defineProperty(this, "yearItems", void 0);
60
55
 
61
56
  _defineProperty(this, "state", {
62
- isMonthYearDropdownOpen: false,
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, "handleYearChange", ({
71
- value
72
- }) => {
73
- if (this.props.onYearChange) {
74
- // $FlowFixMe
75
- this.props.onYearChange({
76
- date: this.dateHelpers.setYear(this.getDateProp(), value[0].id)
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' ? ArrowRight : ArrowLeft);
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' ? ArrowLeft : ArrowRight);
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.isMonthYearDropdownOpen) {
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 defaultMonths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
298
- const maxYear = maxDate ? this.dateHelpers.getYear(maxDate) : MAX_YEAR;
299
- const minYear = minDate ? this.dateHelpers.getYear(minDate) : MIN_YEAR;
300
- const maxDateMonth = maxDate ? this.dateHelpers.getMonth(maxDate) : MAX_MONTH; // Generates array like [0,1,.... maxDateMonth]
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.isMonthYearDropdownOpen,
357
+ isOpen: this.state.isMonthDropdownOpen,
347
358
  onClick: () => {
348
359
  this.setState(prev => ({
349
- isMonthYearDropdownOpen: !prev.isMonthYearDropdownOpen
360
+ isMonthDropdownOpen: !prev.isMonthDropdownOpen
350
361
  }));
351
362
  },
352
363
  onClickOutside: () => this.setState({
353
- isMonthYearDropdownOpen: false
364
+ isMonthDropdownOpen: false
354
365
  }),
355
366
  onEsc: () => this.setState({
356
- isMonthYearDropdownOpen: false
367
+ isMonthDropdownOpen: false
357
368
  }),
358
369
  content: () => /*#__PURE__*/React.createElement(OverriddenStatefulMenu, _extends({
359
370
  initialState: {
360
- highlightedIndex: initialIndex,
371
+ highlightedIndex: initialMonthIndex,
361
372
  isFocused: true
362
373
  },
363
- items: this.items,
374
+ items: this.monthItems,
364
375
  onItemSelect: ({
365
376
  item,
366
377
  event
367
378
  }) => {
368
379
  event.preventDefault();
369
- const [year, month] = idToYearMonth(item.id);
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
- isMonthYearDropdownOpen: false
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
- isMonthYearDropdownOpen: true
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
- isMonthYearDropdownOpen: false
483
+ isYearDropdownOpen: false
405
484
  });
406
485
  }
407
486
  }
408
- }, monthYearSelectButtonProps), monthYearTitle, /*#__PURE__*/React.createElement(MonthYearSelectIconContainer, monthYearSelectIconContainerProps, /*#__PURE__*/React.createElement(TriangleDown, {
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.items = [];
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];
@@ -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
+ };
@@ -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
- export { arrayMove, arrayRemove } from 'react-movable';
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
@@ -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')
@@ -25,6 +25,10 @@ class StatefulContainer extends React.Component {
25
25
  this.props.onBlur(e);
26
26
  }
27
27
 
28
+ if (this.props.focusLock || this.props.autoFocus) {
29
+ return;
30
+ }
31
+
28
32
  this.close();
29
33
  });
30
34
 
@@ -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: () => this.updatePreview(undefined),
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
  }
@@ -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: () => this.updatePreview(undefined),
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, "isMounted", false);
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.isMounted) {
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.isMounted = true;
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.isMounted = false;
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";