baseui 10.8.0 → 10.9.2

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 (160) hide show
  1. package/a11y/a11y.js +2 -2
  2. package/a11y/a11y.js.flow +3 -3
  3. package/button/styled-components.js +47 -18
  4. package/button/styled-components.js.flow +25 -5
  5. package/combobox/combobox.js +6 -3
  6. package/combobox/combobox.js.flow +4 -2
  7. package/combobox/types.js.flow +2 -0
  8. package/data-table/column-categorical.js +1 -1
  9. package/data-table/column-categorical.js.flow +2 -2
  10. package/data-table/column-numerical.js +1 -1
  11. package/data-table/column-numerical.js.flow +3 -3
  12. package/datepicker/styled-components.js +1 -1
  13. package/datepicker/styled-components.js.flow +4 -1
  14. package/drawer/drawer.js +3 -1
  15. package/drawer/drawer.js.flow +7 -1
  16. package/es/a11y/a11y.js +2 -2
  17. package/es/button/styled-components.js +32 -2
  18. package/es/combobox/combobox.js +6 -3
  19. package/es/data-table/column-categorical.js +2 -2
  20. package/es/data-table/column-numerical.js +2 -2
  21. package/es/datepicker/styled-components.js +1 -1
  22. package/es/drawer/drawer.js +3 -1
  23. package/es/form-control/form-control.js +58 -7
  24. package/es/form-control/styled-components.js +27 -6
  25. package/es/index.js +1 -1
  26. package/es/map-marker/badge-enhancer.js +61 -0
  27. package/es/map-marker/constants.js +146 -2
  28. package/es/map-marker/drag-shadow.js +32 -0
  29. package/es/map-marker/fixed-marker.js +54 -48
  30. package/es/map-marker/floating-marker.js +21 -12
  31. package/es/map-marker/index.js +1 -1
  32. package/es/map-marker/label-enhancer.js +39 -0
  33. package/es/map-marker/needle.js +26 -0
  34. package/es/map-marker/pin-head.js +42 -40
  35. package/es/map-marker/styled-components.js +177 -32
  36. package/es/map-marker/types.js +1 -1
  37. package/es/menu/maybe-child-menu.js +0 -2
  38. package/es/menu/nested-menus.js +49 -3
  39. package/es/menu/stateful-container.js +13 -12
  40. package/es/modal/modal.js +3 -1
  41. package/es/popover/popover.js +4 -2
  42. package/es/progress-bar/index.js +1 -1
  43. package/es/progress-bar/progressbar.js +25 -10
  44. package/es/progress-bar/styled-components.js +9 -5
  45. package/es/select/select-component.js +2 -10
  46. package/es/spinner/styled-components.js +34 -16
  47. package/es/table/filter.js +3 -1
  48. package/es/themes/dark-theme/color-component-tokens.js +4 -0
  49. package/es/themes/light-theme/color-component-tokens.js +4 -0
  50. package/es/timezonepicker/timezone-picker.js +55 -36
  51. package/es/timezonepicker/tzdata.js +2 -0
  52. package/es/timezonepicker/update-tzdata.js +69 -0
  53. package/esm/a11y/a11y.js +3 -3
  54. package/esm/button/styled-components.js +47 -18
  55. package/esm/combobox/combobox.js +6 -3
  56. package/esm/data-table/column-categorical.js +2 -2
  57. package/esm/data-table/column-numerical.js +2 -2
  58. package/esm/datepicker/styled-components.js +1 -1
  59. package/esm/drawer/drawer.js +3 -1
  60. package/esm/form-control/form-control.js +60 -9
  61. package/esm/form-control/styled-components.js +23 -3
  62. package/esm/index.js +1 -1
  63. package/esm/map-marker/badge-enhancer.js +79 -0
  64. package/esm/map-marker/constants.js +94 -4
  65. package/esm/map-marker/drag-shadow.js +53 -0
  66. package/esm/map-marker/fixed-marker.js +84 -80
  67. package/esm/map-marker/floating-marker.js +22 -13
  68. package/esm/map-marker/index.js +1 -1
  69. package/esm/map-marker/label-enhancer.js +60 -0
  70. package/esm/map-marker/needle.js +43 -0
  71. package/esm/map-marker/pin-head.js +77 -66
  72. package/esm/map-marker/styled-components.js +182 -51
  73. package/esm/map-marker/types.js +1 -1
  74. package/esm/menu/maybe-child-menu.js +0 -2
  75. package/esm/menu/nested-menus.js +66 -5
  76. package/esm/menu/stateful-container.js +15 -13
  77. package/esm/modal/modal.js +3 -1
  78. package/esm/popover/popover.js +4 -2
  79. package/esm/progress-bar/index.js +1 -1
  80. package/esm/progress-bar/progressbar.js +32 -10
  81. package/esm/progress-bar/styled-components.js +9 -4
  82. package/esm/select/select-component.js +2 -11
  83. package/esm/spinner/styled-components.js +35 -16
  84. package/esm/table/filter.js +3 -1
  85. package/esm/themes/dark-theme/color-component-tokens.js +4 -0
  86. package/esm/themes/light-theme/color-component-tokens.js +4 -0
  87. package/esm/timezonepicker/timezone-picker.js +66 -36
  88. package/esm/timezonepicker/tzdata.js +2 -0
  89. package/esm/timezonepicker/update-tzdata.js +160 -0
  90. package/form-control/form-control.js +61 -8
  91. package/form-control/form-control.js.flow +82 -10
  92. package/form-control/index.d.ts +1 -0
  93. package/form-control/styled-components.js +27 -5
  94. package/form-control/styled-components.js.flow +25 -3
  95. package/form-control/types.js.flow +20 -8
  96. package/index.js +6 -0
  97. package/index.js.flow +1 -1
  98. package/map-marker/badge-enhancer.js +90 -0
  99. package/map-marker/badge-enhancer.js.flow +86 -0
  100. package/map-marker/constants.js +103 -5
  101. package/map-marker/constants.js.flow +152 -0
  102. package/map-marker/drag-shadow.js +64 -0
  103. package/map-marker/drag-shadow.js.flow +52 -0
  104. package/map-marker/fixed-marker.js +84 -78
  105. package/map-marker/fixed-marker.js.flow +78 -66
  106. package/map-marker/floating-marker.js +22 -13
  107. package/map-marker/floating-marker.js.flow +30 -17
  108. package/map-marker/index.d.ts +125 -24
  109. package/map-marker/index.js +18 -0
  110. package/map-marker/index.js.flow +3 -0
  111. package/map-marker/label-enhancer.js +71 -0
  112. package/map-marker/label-enhancer.js.flow +63 -0
  113. package/map-marker/needle.js +54 -0
  114. package/map-marker/needle.js.flow +29 -0
  115. package/map-marker/pin-head.js +80 -69
  116. package/map-marker/pin-head.js.flow +122 -84
  117. package/map-marker/styled-components.js +200 -62
  118. package/map-marker/styled-components.js.flow +172 -22
  119. package/map-marker/types.js.flow +69 -20
  120. package/menu/index.d.ts +9 -4
  121. package/menu/maybe-child-menu.js +0 -2
  122. package/menu/maybe-child-menu.js.flow +0 -2
  123. package/menu/nested-menus.js +66 -5
  124. package/menu/nested-menus.js.flow +50 -5
  125. package/menu/stateful-container.js +15 -13
  126. package/menu/stateful-container.js.flow +19 -13
  127. package/menu/types.js.flow +7 -1
  128. package/modal/modal.js +3 -1
  129. package/modal/modal.js.flow +2 -0
  130. package/package.json +4 -4
  131. package/popover/popover.js +4 -2
  132. package/popover/popover.js.flow +3 -1
  133. package/progress-bar/index.d.ts +2 -0
  134. package/progress-bar/index.js +6 -0
  135. package/progress-bar/index.js.flow +1 -0
  136. package/progress-bar/progressbar.js +32 -10
  137. package/progress-bar/progressbar.js.flow +35 -9
  138. package/progress-bar/styled-components.js +9 -4
  139. package/progress-bar/styled-components.js.flow +15 -4
  140. package/progress-bar/types.js.flow +12 -2
  141. package/select/select-component.js +2 -11
  142. package/select/select-component.js.flow +5 -7
  143. package/spinner/styled-components.js +35 -16
  144. package/spinner/styled-components.js.flow +37 -19
  145. package/spinner/types.js.flow +10 -0
  146. package/styles/index.js.flow +1 -1
  147. package/table/filter.js +3 -1
  148. package/table/filter.js.flow +5 -1
  149. package/themes/dark-theme/color-component-tokens.js +4 -0
  150. package/themes/dark-theme/color-component-tokens.js.flow +4 -0
  151. package/themes/light-theme/color-component-tokens.js +4 -0
  152. package/themes/light-theme/color-component-tokens.js.flow +4 -0
  153. package/themes/types.js.flow +4 -0
  154. package/timezonepicker/timezone-picker.js +71 -41
  155. package/timezonepicker/timezone-picker.js.flow +55 -46
  156. package/timezonepicker/types.js.flow +6 -1
  157. package/timezonepicker/tzdata.js +10 -0
  158. package/timezonepicker/tzdata.js.flow +347 -0
  159. package/timezonepicker/update-tzdata.js +164 -0
  160. package/timezonepicker/update-tzdata.js.flow +70 -0
@@ -32,10 +32,16 @@ class ProgressBar extends React.Component {
32
32
  size,
33
33
  steps,
34
34
  successValue,
35
+ minValue,
36
+ maxValue,
35
37
  showLabel,
36
38
  infinite,
37
- errorMessage
38
- } = this.props;
39
+ errorMessage,
40
+ forwardedRef,
41
+ ...restProps
42
+ } = this.props; // fallback on successValue (and it's default) if maxValue is not set by user
43
+
44
+ const maximumValue = maxValue !== 100 ? maxValue : successValue;
39
45
  const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
40
46
  const [BarContainer, barContainerProps] = getOverrides(overrides.BarContainer, StyledBarContainer);
41
47
  const [Bar, barProps] = getOverrides(overrides.Bar, StyledBar);
@@ -46,7 +52,9 @@ class ProgressBar extends React.Component {
46
52
  $infinite: infinite,
47
53
  $size: size,
48
54
  $steps: steps,
49
- $successValue: successValue,
55
+ $successValue: maximumValue,
56
+ $minValue: minValue,
57
+ $maxValue: maximumValue,
50
58
  $value: value
51
59
  };
52
60
 
@@ -68,34 +76,41 @@ class ProgressBar extends React.Component {
68
76
  /*#__PURE__*/
69
77
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
70
78
  React.createElement(Root, _extends({
79
+ ref: forwardedRef,
71
80
  "data-baseweb": "progress-bar",
72
81
  role: "progressbar",
73
- "aria-label": ariaLabel || getProgressLabel(value, successValue),
82
+ "aria-label": ariaLabel || getProgressLabel(value, maximumValue, minValue),
74
83
  "aria-valuenow": infinite ? null : value,
75
- "aria-valuemin": infinite ? null : 0,
76
- "aria-valuemax": infinite ? null : successValue,
84
+ "aria-valuemin": infinite ? null : minValue,
85
+ "aria-valuemax": infinite ? null : maximumValue,
77
86
  "aria-invalid": errorMessage ? true : null,
78
87
  "aria-errormessage": errorMessage
79
- }, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
88
+ }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
80
89
  $isLeft: true,
81
90
  $size: sharedProps.$size
82
91
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
83
92
  $size: sharedProps.$size
84
- }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, successValue)))
93
+ }, infiniteBarProps))) : renderProgressBar()), showLabel && /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), getProgressLabel(value, maximumValue, minValue)))
85
94
  );
86
95
  }
87
96
 
88
97
  }
89
98
 
90
99
  _defineProperty(ProgressBar, "defaultProps", {
91
- getProgressLabel: (value, successValue) => `${Math.round(value / successValue * 100)}% Loaded`,
100
+ getProgressLabel: (value, maxValue, minValue) => `${Math.round((value - minValue) / (maxValue - minValue) * 100)}% Loaded`,
92
101
  infinite: false,
93
102
  overrides: {},
94
103
  showLabel: false,
95
104
  size: SIZE.medium,
96
105
  steps: 1,
97
106
  successValue: 100,
107
+ minValue: 0,
108
+ maxValue: 100,
98
109
  value: 0
99
110
  });
100
111
 
101
- export default ProgressBar;
112
+ const ForwardedProgressBar = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(ProgressBar, _extends({
113
+ forwardedRef: ref
114
+ }, props)));
115
+ ForwardedProgressBar.displayName = 'ProgressBar';
116
+ export default ForwardedProgressBar;
@@ -76,14 +76,18 @@ export const StyledBarProgress = styled('div', props => {
76
76
  $value,
77
77
  $successValue,
78
78
  $steps,
79
- $index
80
- } = props;
79
+ $index,
80
+ $maxValue,
81
+ $minValue = 0
82
+ } = props; // making sure this doesn't break existing use that use StyledBarProgress directly
83
+
84
+ const maxValue = $maxValue ? $maxValue : $successValue;
81
85
  const {
82
86
  colors,
83
87
  sizing,
84
88
  borders
85
89
  } = $theme;
86
- const width = `${100 - $value / $successValue * 100}%`;
90
+ const width = `${100 - ($value - $minValue) * 100 / (maxValue - $minValue)}%`;
87
91
  const stepStates = {
88
92
  default: 'default',
89
93
  awaits: 'awaits',
@@ -93,8 +97,8 @@ export const StyledBarProgress = styled('div', props => {
93
97
  let stepState = stepStates.default;
94
98
 
95
99
  if ($steps > 1) {
96
- const stepValue = $successValue / $steps;
97
- const currentValue = $value / $successValue * 100;
100
+ const stepValue = (maxValue - $minValue) / $steps;
101
+ const currentValue = ($value - $minValue) / (maxValue - $minValue) * 100;
98
102
  const completedSteps = Math.floor(currentValue / stepValue);
99
103
 
100
104
  if ($index < completedSteps) {
@@ -124,11 +124,6 @@ class Select extends React.Component {
124
124
  this.handleClick(event);
125
125
  });
126
126
 
127
- _defineProperty(this, "handleTouchEndClearValue", event => {
128
- if (this.dragging) return;
129
- this.clearValue(event);
130
- });
131
-
132
127
  _defineProperty(this, "handleClick", event => {
133
128
  if (this.props.disabled || !isClick(event) && !isLeftClick(event)) {
134
129
  return;
@@ -741,7 +736,7 @@ class Select extends React.Component {
741
736
  "aria-required": this.props.required || null,
742
737
  onFocus: this.handleInputFocus,
743
738
  tabIndex: 0
744
- }, sharedProps, inputContainerProps), /*#__PURE__*/React.createElement("input", {
739
+ }, sharedProps, inputContainerProps), /*#__PURE__*/React.createElement("input", _extends({
745
740
  "aria-hidden": true,
746
741
  id: this.props.id || null,
747
742
  ref: this.handleInputRef,
@@ -753,7 +748,7 @@ class Select extends React.Component {
753
748
  padding: 0
754
749
  },
755
750
  tabIndex: -1
756
- }));
751
+ }, overrides.Input ? overrides.Input.props ? overrides.Input.props : {} : {})));
757
752
  }
758
753
 
759
754
  return /*#__PURE__*/React.createElement(InputContainer, _extends({}, sharedProps, inputContainerProps), /*#__PURE__*/React.createElement(AutosizeInput, _extends({
@@ -800,9 +795,6 @@ class Select extends React.Component {
800
795
  title: ariaLabel,
801
796
  "aria-label": ariaLabel,
802
797
  onClick: this.clearValue,
803
- onTouchEnd: this.handleTouchEndClearValue,
804
- onTouchMove: this.handleTouchMove,
805
- onTouchStart: this.handleTouchStart,
806
798
  role: "button",
807
799
  overrides: {
808
800
  Svg: {
@@ -46,13 +46,39 @@ export const StyledActivePath = styled('path', props => ({
46
46
  StyledActivePath.displayName = "StyledActivePath";
47
47
  export const StyledSpinnerNext = styled('i', ({
48
48
  $theme,
49
+ $color = $theme.colors.contentAccent,
50
+ $borderWidth,
49
51
  $size = SIZE.medium
50
52
  }) => {
51
- const borderWidth = {
53
+ //$FlowFixMe
54
+ let borderSize = {
52
55
  large: $theme.sizing.scale300,
53
56
  medium: $theme.sizing.scale100,
54
57
  small: $theme.sizing.scale0
58
+ }[$borderWidth || $size];
59
+ let boxSize = {
60
+ large: $theme.sizing.scale1000,
61
+ medium: $theme.sizing.scale900,
62
+ small: $theme.sizing.scale800
55
63
  }[$size];
64
+
65
+ if (!borderSize) {
66
+ borderSize = $theme.sizing[$borderWidth];
67
+
68
+ if (!borderSize) {
69
+ borderSize = `${parseInt($borderWidth)}px`;
70
+ }
71
+ }
72
+
73
+ if (!boxSize) {
74
+ //$FlowFixMe
75
+ boxSize = $theme.sizing[$size];
76
+
77
+ if (!boxSize) {
78
+ boxSize = `${parseInt($size)}px`;
79
+ }
80
+ }
81
+
56
82
  return {
57
83
  display: 'block',
58
84
  animationName: spin,
@@ -64,24 +90,16 @@ export const StyledSpinnerNext = styled('i', ({
64
90
  borderTopStyle: 'solid',
65
91
  borderBottomStyle: 'solid',
66
92
  borderRadius: '50%',
67
- borderTopColor: $theme.colors.contentAccent,
93
+ borderTopColor: $color,
68
94
  borderRightColor: $theme.colors.backgroundTertiary,
69
95
  borderBottomColor: $theme.colors.backgroundTertiary,
70
96
  borderLeftColor: $theme.colors.backgroundTertiary,
71
- borderLeftWidth: borderWidth,
72
- borderRightWidth: borderWidth,
73
- borderTopWidth: borderWidth,
74
- borderBottomWidth: borderWidth,
75
- width: {
76
- large: $theme.sizing.scale1000,
77
- medium: $theme.sizing.scale900,
78
- small: $theme.sizing.scale800
79
- }[$size],
80
- height: {
81
- large: $theme.sizing.scale1000,
82
- medium: $theme.sizing.scale900,
83
- small: $theme.sizing.scale800
84
- }[$size],
97
+ borderLeftWidth: borderSize,
98
+ borderRightWidth: borderSize,
99
+ borderTopWidth: borderSize,
100
+ borderBottomWidth: borderSize,
101
+ width: boxSize,
102
+ height: boxSize,
85
103
  cursor: 'wait'
86
104
  };
87
105
  });
@@ -39,7 +39,9 @@ export default function Filter(props) {
39
39
  content: ({
40
40
  close
41
41
  }) => /*#__PURE__*/React.createElement(FocusLock, {
42
- autoFocus: false
42
+ autoFocus: false // Allow focus to escape when UI is within an iframe
43
+ ,
44
+ crossFrame: false
43
45
  }, /*#__PURE__*/React.createElement(Heading, headingProps, "Filter Column"), /*#__PURE__*/React.createElement(Content, contentProps, props.children), /*#__PURE__*/React.createElement(Footer, footerProps, /*#__PURE__*/React.createElement(Button, {
44
46
  kind: KIND.minimal,
45
47
  size: SIZE.compact,
@@ -36,6 +36,8 @@ export default ((themePrimitives = colorTokens) => ({
36
36
  buttonTertiaryActive: themePrimitives.primary600,
37
37
  buttonTertiarySelectedText: themePrimitives.primary,
38
38
  buttonTertiarySelectedFill: themePrimitives.primary600,
39
+ buttonTertiaryDisabledActiveFill: themePrimitives.primary700,
40
+ buttonTertiaryDisabledActiveText: themePrimitives.mono300,
39
41
  buttonTertiarySpinnerForeground: themePrimitives.primary50,
40
42
  buttonTertiarySpinnerBackground: themePrimitives.primary500,
41
43
  buttonMinimalFill: 'transparent',
@@ -48,6 +50,8 @@ export default ((themePrimitives = colorTokens) => ({
48
50
  buttonMinimalSpinnerBackground: themePrimitives.primary500,
49
51
  buttonDisabledFill: themePrimitives.mono600,
50
52
  buttonDisabledText: themePrimitives.mono300,
53
+ buttonDisabledActiveFill: themePrimitives.mono200,
54
+ buttonDisabledActiveText: themePrimitives.primary500,
51
55
  buttonDisabledSpinnerForeground: themePrimitives.mono200,
52
56
  buttonDisabledSpinnerBackground: themePrimitives.mono400,
53
57
  // Breadcrumbs
@@ -36,6 +36,8 @@ export default ((themePrimitives = colorTokens) => ({
36
36
  buttonTertiaryActive: themePrimitives.primary100,
37
37
  buttonTertiarySelectedFill: themePrimitives.primary100,
38
38
  buttonTertiarySelectedText: themePrimitives.primary,
39
+ buttonTertiaryDisabledActiveFill: themePrimitives.primary50,
40
+ buttonTertiaryDisabledActiveText: themePrimitives.mono600,
39
41
  buttonTertiarySpinnerForeground: themePrimitives.accent,
40
42
  buttonTertiarySpinnerBackground: themePrimitives.primary100,
41
43
  buttonMinimalFill: 'transparent',
@@ -48,6 +50,8 @@ export default ((themePrimitives = colorTokens) => ({
48
50
  buttonMinimalSpinnerBackground: themePrimitives.primary100,
49
51
  buttonDisabledFill: themePrimitives.mono200,
50
52
  buttonDisabledText: themePrimitives.mono600,
53
+ buttonDisabledActiveFill: themePrimitives.mono700,
54
+ buttonDisabledActiveText: themePrimitives.mono100,
51
55
  buttonDisabledSpinnerForeground: themePrimitives.mono600,
52
56
  buttonDisabledSpinnerBackground: themePrimitives.mono400,
53
57
  // Breadcrumbs
@@ -10,11 +10,11 @@ LICENSE file in the root directory of this source tree.
10
10
  */
11
11
  // global Intl
12
12
  import * as React from 'react';
13
- import { findTimeZone, getZonedTime, listTimeZones } from 'timezone-support/dist/index-1900-2050.js';
14
- import { formatZonedTime } from 'timezone-support/dist/parse-format.js';
13
+ import { format, getTimezoneOffset } from 'date-fns-tz';
15
14
  import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
16
15
  import { LocaleContext } from '../locale/index.js';
17
16
  import { Select } from '../select/index.js';
17
+ import { zones } from './tzdata.js';
18
18
 
19
19
  class TimezonePicker extends React.Component {
20
20
  constructor(...args) {
@@ -25,42 +25,51 @@ class TimezonePicker extends React.Component {
25
25
  value: null
26
26
  });
27
27
 
28
- _defineProperty(this, "buildTimezones", compareDate => listTimeZones().map(zone => {
29
- const timezone = findTimeZone(zone);
30
- const zonedTime = getZonedTime(compareDate, timezone);
31
- const offsetTime = (zonedTime.zone.offset < 0 ? '+' : '-') + Math.abs(zonedTime.zone.offset / 60);
32
- const abbreviation = formatZonedTime(zonedTime, 'z');
33
- const formatted = `(GMT ${offsetTime}) ${zone}${this.props.includeAbbreviations ? ` - ${abbreviation}` : ''}`.replace('_', ' ');
34
- const option = {
35
- id: zone,
36
- label: formatted,
37
- offset: zonedTime.zone.offset
38
- };
39
-
40
- if (this.props.mapLabels) {
41
- option.label = this.props.mapLabels(option);
42
- }
28
+ _defineProperty(this, "buildTimezones", compareDate => {
29
+ const timezones = [];
30
+
31
+ for (const zoneName of zones) {
32
+ try {
33
+ const offset = getTimezoneOffset(zoneName, compareDate) / 3_600_000;
34
+ const offsetFormatted = `${offset >= 0 ? '+' : '-'}${Math.abs(offset)}`;
35
+ let label = `(GMT${offsetFormatted}) ${zoneName.replace('_', ' ')}`;
36
+
37
+ if (this.props.includeAbbreviations) {
38
+ const abbreviation = format(compareDate, 'zzz', {
39
+ timeZone: zoneName
40
+ });
41
+
42
+ if (abbreviation) {
43
+ label += ` - ${abbreviation}`;
44
+ }
45
+ }
46
+
47
+ const offsetMinutes = offset * 60;
48
+ timezones.push({
49
+ id: zoneName,
50
+ label,
51
+ // offset output is in minutes, difference of UTC and this zone (negative for hours ahead of UTC, positive for hours behind)
52
+ offset: offsetMinutes === 0 ? 0 : offsetMinutes * -1
53
+ });
54
+ } catch (error) {
55
+ // Ignores timezones that are not available within a user's browser/operating system
56
+ console.error(`failed to format zone name ${zoneName}`);
57
+ }
58
+ } // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
43
59
 
44
- return option;
45
- }) // Formats 'noisy' timezones without a letter acronym.
46
- .map(option => {
47
- const rgx = /(\s-\s(\+|-)\d\d\d?\d?)$/;
48
- const matches = option.label.match(rgx);
49
60
 
50
- if (matches) {
51
- const prefix = matches[0];
52
- option.label = option.label.split(prefix)[0];
53
- }
61
+ return timezones.sort((a, b) => {
62
+ const offsetDelta = b.offset - a.offset;
63
+ if (offsetDelta !== 0) return offsetDelta;
64
+
65
+ if (typeof a.label === 'string' && typeof b.label === 'string') {
66
+ if (a.label < b.label) return -1;
67
+ if (a.label > b.label) return 1;
68
+ }
54
69
 
55
- return option;
56
- }) // Sorts W -> E, prioritizes america. could be more nuanced based on system tz but simple for now
57
- .sort((a, b) => {
58
- const offsetDelta = b.offset - a.offset;
59
- if (offsetDelta !== 0) return offsetDelta;
60
- if (a.label < b.label) return -1;
61
- if (a.label > b.label) return 1;
62
- return 0;
63
- }));
70
+ return 0;
71
+ });
72
+ });
64
73
  }
65
74
 
66
75
  componentDidMount() {
@@ -116,9 +125,19 @@ class TimezonePicker extends React.Component {
116
125
  selectProps.overrides); // $FlowFixMe
117
126
 
118
127
  selectProps.overrides = selectOverrides;
128
+ let options = this.state.timezones;
129
+
130
+ if (this.props.mapLabels) {
131
+ options = options.map(option => {
132
+ // $FlowFixMe - TimezoneT.label is a string, but mapLabels can return a React.Node
133
+ option.label = this.props.mapLabels(option);
134
+ return option;
135
+ });
136
+ }
137
+
119
138
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(OverriddenSelect, _extends({
120
139
  "aria-label": locale.datepicker.timezonePickerAriaLabel,
121
- options: this.state.timezones,
140
+ options: options,
122
141
  clearable: false,
123
142
  disabled: this.props.disabled,
124
143
  error: this.props.error,
@@ -0,0 +1,2 @@
1
+ /* eslint-disable header/header */
2
+ export const zones = ['Europe/Andorra', 'Asia/Dubai', 'Asia/Kabul', 'Europe/Tirane', 'Asia/Yerevan', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/Mawson', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/Troll', 'Antarctica/Vostok', 'America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Salta', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/San_Luis', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuaia', 'Pacific/Pago_Pago', 'Europe/Vienna', 'Australia/Lord_Howe', 'Antarctica/Macquarie', 'Australia/Hobart', 'Australia/Melbourne', 'Australia/Sydney', 'Australia/Broken_Hill', 'Australia/Brisbane', 'Australia/Lindeman', 'Australia/Adelaide', 'Australia/Darwin', 'Australia/Perth', 'Australia/Eucla', 'Asia/Baku', 'America/Barbados', 'Asia/Dhaka', 'Europe/Brussels', 'Europe/Sofia', 'Atlantic/Bermuda', 'Asia/Brunei', 'America/La_Paz', 'America/Noronha', 'America/Belem', 'America/Fortaleza', 'America/Recife', 'America/Araguaina', 'America/Maceio', 'America/Bahia', 'America/Sao_Paulo', 'America/Campo_Grande', 'America/Cuiaba', 'America/Santarem', 'America/Porto_Velho', 'America/Boa_Vista', 'America/Manaus', 'America/Eirunepe', 'America/Rio_Branco', 'Asia/Thimphu', 'Europe/Minsk', 'America/Belize', 'America/St_Johns', 'America/Halifax', 'America/Glace_Bay', 'America/Moncton', 'America/Goose_Bay', 'America/Toronto', 'America/Nipigon', 'America/Thunder_Bay', 'America/Iqaluit', 'America/Pangnirtung', 'America/Winnipeg', 'America/Rainy_River', 'America/Resolute', 'America/Rankin_Inlet', 'America/Regina', 'America/Swift_Current', 'America/Edmonton', 'America/Cambridge_Bay', 'America/Yellowknife', 'America/Inuvik', 'America/Dawson_Creek', 'America/Fort_Nelson', 'America/Whitehorse', 'America/Dawson', 'America/Vancouver', 'Indian/Cocos', 'Europe/Zurich', 'Africa/Abidjan', 'Pacific/Rarotonga', 'America/Santiago', 'America/Punta_Arenas', 'Pacific/Easter', 'Asia/Shanghai', 'Asia/Urumqi', 'America/Bogota', 'America/Costa_Rica', 'America/Havana', 'Atlantic/Cape_Verde', 'Indian/Christmas', 'Asia/Nicosia', 'Asia/Famagusta', 'Europe/Prague', 'Europe/Berlin', 'Europe/Copenhagen', 'America/Santo_Domingo', 'Africa/Algiers', 'America/Guayaquil', 'Pacific/Galapagos', 'Europe/Tallinn', 'Africa/Cairo', 'Africa/El_Aaiun', 'Europe/Madrid', 'Africa/Ceuta', 'Atlantic/Canary', 'Europe/Helsinki', 'Pacific/Fiji', 'Atlantic/Stanley', 'Pacific/Chuuk', 'Pacific/Pohnpei', 'Pacific/Kosrae', 'Atlantic/Faroe', 'Europe/Paris', 'Europe/London', 'Asia/Tbilisi', 'America/Cayenne', 'Europe/Gibraltar', 'America/Nuuk', 'America/Danmarkshavn', 'America/Scoresbysund', 'America/Thule', 'Europe/Athens', 'Atlantic/South_Georgia', 'America/Guatemala', 'Pacific/Guam', 'Africa/Bissau', 'America/Guyana', 'Asia/Hong_Kong', 'America/Tegucigalpa', 'America/Port-au-Prince', 'Europe/Budapest', 'Asia/Jakarta', 'Asia/Pontianak', 'Asia/Makassar', 'Asia/Jayapura', 'Europe/Dublin', 'Asia/Jerusalem', 'Asia/Kolkata', 'Indian/Chagos', 'Asia/Baghdad', 'Asia/Tehran', 'Atlantic/Reykjavik', 'Europe/Rome', 'America/Jamaica', 'Asia/Amman', 'Asia/Tokyo', 'Africa/Nairobi', 'Asia/Bishkek', 'Pacific/Tarawa', 'Pacific/Kanton', 'Pacific/Kiritimati', 'Asia/Pyongyang', 'Asia/Seoul', 'Asia/Almaty', 'Asia/Qyzylorda', 'Asia/Qostanay', 'Asia/Aqtobe', 'Asia/Aqtau', 'Asia/Atyrau', 'Asia/Oral', 'Asia/Beirut', 'Asia/Colombo', 'Africa/Monrovia', 'Europe/Vilnius', 'Europe/Luxembourg', 'Europe/Riga', 'Africa/Tripoli', 'Africa/Casablanca', 'Europe/Monaco', 'Europe/Chisinau', 'Pacific/Majuro', 'Pacific/Kwajalein', 'Asia/Yangon', 'Asia/Ulaanbaatar', 'Asia/Hovd', 'Asia/Choibalsan', 'Asia/Macau', 'America/Martinique', 'Europe/Malta', 'Indian/Mauritius', 'Indian/Maldives', 'America/Mexico_City', 'America/Cancun', 'America/Merida', 'America/Monterrey', 'America/Matamoros', 'America/Mazatlan', 'America/Chihuahua', 'America/Ojinaga', 'America/Hermosillo', 'America/Tijuana', 'America/Bahia_Banderas', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Africa/Maputo', 'Africa/Windhoek', 'Pacific/Noumea', 'Pacific/Norfolk', 'Africa/Lagos', 'America/Managua', 'Europe/Amsterdam', 'Europe/Oslo', 'Asia/Kathmandu', 'Pacific/Nauru', 'Pacific/Niue', 'Pacific/Auckland', 'Pacific/Chatham', 'America/Panama', 'America/Lima', 'Pacific/Tahiti', 'Pacific/Marquesas', 'Pacific/Gambier', 'Pacific/Port_Moresby', 'Pacific/Bougainville', 'Asia/Manila', 'Asia/Karachi', 'Europe/Warsaw', 'America/Miquelon', 'Pacific/Pitcairn', 'America/Puerto_Rico', 'Asia/Gaza', 'Asia/Hebron', 'Europe/Lisbon', 'Atlantic/Madeira', 'Atlantic/Azores', 'Pacific/Palau', 'America/Asuncion', 'Asia/Qatar', 'Indian/Reunion', 'Europe/Bucharest', 'Europe/Belgrade', 'Europe/Kaliningrad', 'Europe/Moscow', 'Europe/Simferopol', 'Europe/Kirov', 'Europe/Volgograd', 'Europe/Astrakhan', 'Europe/Saratov', 'Europe/Ulyanovsk', 'Europe/Samara', 'Asia/Yekaterinburg', 'Asia/Omsk', 'Asia/Novosibirsk', 'Asia/Barnaul', 'Asia/Tomsk', 'Asia/Novokuznetsk', 'Asia/Krasnoyarsk', 'Asia/Irkutsk', 'Asia/Chita', 'Asia/Yakutsk', 'Asia/Khandyga', 'Asia/Vladivostok', 'Asia/Ust-Nera', 'Asia/Magadan', 'Asia/Sakhalin', 'Asia/Srednekolymsk', 'Asia/Kamchatka', 'Asia/Anadyr', 'Asia/Riyadh', 'Pacific/Guadalcanal', 'Indian/Mahe', 'Africa/Khartoum', 'Europe/Stockholm', 'Asia/Singapore', 'America/Paramaribo', 'Africa/Juba', 'Africa/Sao_Tome', 'America/El_Salvador', 'Asia/Damascus', 'America/Grand_Turk', 'Africa/Ndjamena', 'Indian/Kerguelen', 'Asia/Bangkok', 'Asia/Dushanbe', 'Pacific/Fakaofo', 'Asia/Dili', 'Asia/Ashgabat', 'Africa/Tunis', 'Pacific/Tongatapu', 'Europe/Istanbul', 'Pacific/Funafuti', 'Asia/Taipei', 'Europe/Kiev', 'Europe/Uzhgorod', 'Europe/Zaporozhye', 'Pacific/Wake', 'America/New_York', 'America/Detroit', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Indiana/Indianapolis', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Vevay', 'America/Chicago', 'America/Indiana/Tell_City', 'America/Indiana/Knox', 'America/Menominee', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/North_Dakota/Beulah', 'America/Denver', 'America/Boise', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'America/Juneau', 'America/Sitka', 'America/Metlakatla', 'America/Yakutat', 'America/Nome', 'America/Adak', 'Pacific/Honolulu', 'America/Montevideo', 'Asia/Samarkand', 'Asia/Tashkent', 'America/Caracas', 'Asia/Ho_Chi_Minh', 'Pacific/Efate', 'Pacific/Wallis', 'Pacific/Apia', 'Africa/Johannesburg'];
@@ -0,0 +1,69 @@
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
+
8
+ /* eslint-env node */
9
+ const fs = require('fs');
10
+
11
+ const path = require('path');
12
+
13
+ const util = require('util');
14
+
15
+ const exec = util.promisify(require('child_process').exec); // Download tzdata and collect a list of timezones. Baseui previously used a library
16
+ // to do this, but it grew stale and unmaintained. This approach is straightforward
17
+ // enough to update whenever necessary, but future improvements could include building
18
+ // this data set before baseui is published so that the data is always fresh.
19
+
20
+ async function main() {
21
+ try {
22
+ const tmpDir = path.join(__dirname, 'tmp'); // $FlowFixMe - flow is not aware of recursive option
23
+
24
+ await fs.promises.rmdir(tmpDir, {
25
+ recursive: true
26
+ });
27
+ await fs.promises.mkdir(tmpDir);
28
+ const src = `https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz`;
29
+ await exec(`curl -L ${src} | gzip -dc | tar -xf - --directory ${tmpDir}`);
30
+ const zoneTabPath = path.join(tmpDir, 'zone1970.tab');
31
+ const content = await fs.promises.readFile(zoneTabPath, 'utf-8');
32
+ const lines = content.split('\n');
33
+ const zones = [];
34
+
35
+ for (const line of lines) {
36
+ if (line[0] === '#') {
37
+ continue;
38
+ }
39
+
40
+ const parts = line.split(/\s+/);
41
+
42
+ if (parts.length >= 3) {
43
+ zones.push(parts[2]);
44
+ }
45
+ }
46
+
47
+ const file = [];
48
+ file.push('/* eslint-disable header/header */');
49
+ file.push('// @flow');
50
+ file.push('');
51
+ file.push('export const zones = [');
52
+
53
+ for (const zone of zones) {
54
+ file.push(` '${zone}',`);
55
+ }
56
+
57
+ file.push('];');
58
+ const tzdataPath = path.join(__dirname, 'tzdata.js');
59
+ await fs.promises.writeFile(tzdataPath, file.join('\n')); // $FlowFixMe - flow is not aware of recursive option
60
+
61
+ await fs.promises.rmdir(tmpDir, {
62
+ recursive: true
63
+ });
64
+ } catch (error) {
65
+ console.error(error);
66
+ }
67
+ }
68
+
69
+ main();
package/esm/a11y/a11y.js CHANGED
@@ -21,7 +21,7 @@ LICENSE file in the root directory of this source tree.
21
21
  import * as React from 'react';
22
22
  import axe from 'axe-core';
23
23
  import { Layer, TetherBehavior, TETHER_PLACEMENT } from '../layer/index.js';
24
- import { Paragraph3, Caption1 } from '../typography/index.js';
24
+ import { ParagraphSmall, ParagraphXSmall } from '../typography/index.js';
25
25
  import { styled } from '../styles/index.js';
26
26
  import { ThemeContext } from '../styles/theme-provider.js';
27
27
 
@@ -128,8 +128,8 @@ function Violation(props) {
128
128
  ref: setPopper,
129
129
  $top: "".concat(offset.top, "px") || '0px',
130
130
  $left: "".concat(offset.left, "px") || '0px'
131
- }, /*#__PURE__*/React.createElement(Caption1, null, props.target), props.violations.map(function (violation, index) {
132
- return /*#__PURE__*/React.createElement(Paragraph3, {
131
+ }, /*#__PURE__*/React.createElement(ParagraphXSmall, null, props.target), props.violations.map(function (violation, index) {
132
+ return /*#__PURE__*/React.createElement(ParagraphSmall, {
133
133
  key: index
134
134
  }, violation.description);
135
135
  }))));
@@ -43,11 +43,14 @@ export var BaseButton = styled('button', function (_ref) {
43
43
  transitionDuration: $theme.animation.timing200,
44
44
  transitionTimingFunction: $theme.animation.linearCurve,
45
45
  cursor: 'pointer',
46
- ':disabled': {
47
- cursor: 'not-allowed',
48
- backgroundColor: $kind === KIND.minimal || $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
49
- color: $theme.colors.buttonDisabledText
50
- },
46
+ ':disabled': _objectSpread({
47
+ cursor: 'not-allowed'
48
+ }, getDisabledStyles({
49
+ $theme: $theme,
50
+ $kind: $kind,
51
+ $disabled: $disabled,
52
+ $isSelected: $isSelected
53
+ })),
51
54
  marginLeft: 0,
52
55
  marginTop: 0,
53
56
  marginRight: 0,
@@ -267,10 +270,36 @@ function getFontStyles(_ref10) {
267
270
  }
268
271
  }
269
272
 
270
- function getPaddingStyles(_ref11) {
273
+ function getDisabledStyles(_ref11) {
271
274
  var $theme = _ref11.$theme,
272
- $size = _ref11.$size,
273
- $shape = _ref11.$shape;
275
+ $kind = _ref11.$kind,
276
+ $isSelected = _ref11.$isSelected,
277
+ $disabled = _ref11.$disabled;
278
+
279
+ if ($disabled && $isSelected) {
280
+ if ($kind === KIND.primary || $kind === KIND.secondary) {
281
+ return {
282
+ color: $theme.colors.buttonDisabledActiveText,
283
+ backgroundColor: $theme.colors.buttonDisabledActiveFill
284
+ };
285
+ } else if ($kind === KIND.minimal || $kind === KIND.tertiary) {
286
+ return {
287
+ backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
288
+ color: $theme.colors.buttonTertiaryDisabledActiveText
289
+ };
290
+ }
291
+ }
292
+
293
+ return {
294
+ backgroundColor: $kind === KIND.minimal || $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
295
+ color: $theme.colors.buttonDisabledText
296
+ };
297
+ }
298
+
299
+ function getPaddingStyles(_ref12) {
300
+ var $theme = _ref12.$theme,
301
+ $size = _ref12.$size,
302
+ $shape = _ref12.$shape;
274
303
  var iconShape = $shape === SHAPE.square || $shape === SHAPE.circle || $shape === SHAPE.round;
275
304
 
276
305
  switch ($size) {
@@ -308,12 +337,12 @@ function getPaddingStyles(_ref11) {
308
337
  }
309
338
  }
310
339
 
311
- function getKindStyles(_ref12) {
312
- var $theme = _ref12.$theme,
313
- $isLoading = _ref12.$isLoading,
314
- $isSelected = _ref12.$isSelected,
315
- $kind = _ref12.$kind,
316
- $disabled = _ref12.$disabled;
340
+ function getKindStyles(_ref13) {
341
+ var $theme = _ref13.$theme,
342
+ $isLoading = _ref13.$isLoading,
343
+ $isSelected = _ref13.$isSelected,
344
+ $kind = _ref13.$kind,
345
+ $disabled = _ref13.$disabled;
317
346
 
318
347
  if ($disabled) {
319
348
  return Object.freeze({});
@@ -401,10 +430,10 @@ function getKindStyles(_ref12) {
401
430
  }
402
431
  }
403
432
 
404
- function getShapeStyles(_ref13) {
405
- var $theme = _ref13.$theme,
406
- $shape = _ref13.$shape,
407
- $size = _ref13.$size;
433
+ function getShapeStyles(_ref14) {
434
+ var $theme = _ref14.$theme,
435
+ $shape = _ref14.$shape,
436
+ $size = _ref14.$size;
408
437
 
409
438
  if ($shape === SHAPE.circle || $shape === SHAPE.square) {
410
439
  var height, width;
@@ -46,6 +46,7 @@ function Combobox(props) {
46
46
  onChange = props.onChange,
47
47
  onFocus = props.onFocus,
48
48
  onSubmit = props.onSubmit,
49
+ listBoxLabel = props.listBoxLabel,
49
50
  mapOptionToNode = props.mapOptionToNode,
50
51
  mapOptionToString = props.mapOptionToString,
51
52
  id = props.id,
@@ -308,6 +309,7 @@ function Combobox(props) {
308
309
  ,
309
310
  ref: listboxRef,
310
311
  role: "listbox",
312
+ "aria-label": listBoxLabel,
311
313
  $width: listboxWidth
312
314
  }, listBoxProps), options.map(function (option, index) {
313
315
  var isSelected = selectionIndex === index;
@@ -346,9 +348,8 @@ function Combobox(props) {
346
348
  role: "combobox"
347
349
  }, inputContainerProps), /*#__PURE__*/React.createElement(OverriddenInput, _extends({
348
350
  inputRef: handleInputRef,
349
- "aria-activedescendant": selectionIndex >= 0 ? activeDescendantId : undefined,
351
+ "aria-activedescendant": isOpen && selectionIndex >= 0 ? activeDescendantId : undefined,
350
352
  "aria-autocomplete": "list",
351
- "aria-controls": listboxId,
352
353
  disabled: disabled,
353
354
  error: error,
354
355
  name: name,
@@ -361,7 +362,9 @@ function Combobox(props) {
361
362
  positive: positive,
362
363
  size: size,
363
364
  value: tempValue ? tempValue : value
364
- }, restInputProps)))));
365
+ }, isOpen ? {
366
+ 'aria-controls': listboxId
367
+ } : {}, restInputProps)))));
365
368
  }
366
369
 
367
370
  export default Combobox;
@@ -29,7 +29,7 @@ import { Checkbox, StyledLabel } from '../checkbox/index.js';
29
29
  import Search from '../icon/search.js';
30
30
  import { Input, SIZE as INPUT_SIZE } from '../input/index.js';
31
31
  import { useStyletron, withStyle } from '../styles/index.js';
32
- import { Label3 } from '../typography/index.js';
32
+ import { LabelSmall } from '../typography/index.js';
33
33
  import Column from './column.js';
34
34
  import { COLUMNS } from './constants.js';
35
35
  import { LocaleContext } from '../locale/index.js';
@@ -186,7 +186,7 @@ export function CategoricalFilter(props) {
186
186
  overflowY: 'auto',
187
187
  marginTop: theme.sizing.scale600
188
188
  })
189
- }, !filteredCategories.length && /*#__PURE__*/React.createElement(Label3, null, locale.datatable.categoricalFilterEmpty), Boolean(filteredCategories.length) && filteredCategories.map(function (category, i) {
189
+ }, !filteredCategories.length && /*#__PURE__*/React.createElement(LabelSmall, null, locale.datatable.categoricalFilterEmpty), Boolean(filteredCategories.length) && filteredCategories.map(function (category, i) {
190
190
  return /*#__PURE__*/React.createElement("div", {
191
191
  className: checkboxStyles,
192
192
  key: i