baseui 0.0.0-next-0688aa9 → 0.0.0-next-9a8ac53

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.
@@ -60,6 +60,7 @@ function Combobox(props) {
60
60
  onChange = props.onChange,
61
61
  onFocus = props.onFocus,
62
62
  onSubmit = props.onSubmit,
63
+ listBoxLabel = props.listBoxLabel,
63
64
  mapOptionToNode = props.mapOptionToNode,
64
65
  mapOptionToString = props.mapOptionToString,
65
66
  id = props.id,
@@ -322,6 +323,7 @@ function Combobox(props) {
322
323
  ,
323
324
  ref: listboxRef,
324
325
  role: "listbox",
326
+ "aria-label": listBoxLabel,
325
327
  $width: listboxWidth
326
328
  }, listBoxProps), options.map(function (option, index) {
327
329
  var isSelected = selectionIndex === index;
@@ -360,9 +362,8 @@ function Combobox(props) {
360
362
  role: "combobox"
361
363
  }, inputContainerProps), /*#__PURE__*/React.createElement(OverriddenInput, _extends({
362
364
  inputRef: handleInputRef,
363
- "aria-activedescendant": selectionIndex >= 0 ? activeDescendantId : undefined,
365
+ "aria-activedescendant": isOpen && selectionIndex >= 0 ? activeDescendantId : undefined,
364
366
  "aria-autocomplete": "list",
365
- "aria-controls": listboxId,
366
367
  disabled: disabled,
367
368
  error: error,
368
369
  name: name,
@@ -375,7 +376,9 @@ function Combobox(props) {
375
376
  positive: positive,
376
377
  size: size,
377
378
  value: tempValue ? tempValue : value
378
- }, restInputProps)))));
379
+ }, isOpen ? {
380
+ 'aria-controls': listboxId
381
+ } : {}, restInputProps)))));
379
382
  }
380
383
 
381
384
  var _default = Combobox;
@@ -38,6 +38,7 @@ function Combobox<OptionT>(props: PropsT<OptionT>) {
38
38
  onChange,
39
39
  onFocus,
40
40
  onSubmit,
41
+ listBoxLabel,
41
42
  mapOptionToNode,
42
43
  mapOptionToString,
43
44
  id,
@@ -274,6 +275,7 @@ function Combobox<OptionT>(props: PropsT<OptionT>) {
274
275
  // eslint-disable-next-line flowtype/no-weak-types
275
276
  ref={(listboxRef: any)}
276
277
  role="listbox"
278
+ aria-label={listBoxLabel}
277
279
  $width={listboxWidth}
278
280
  {...listBoxProps}
279
281
  >
@@ -322,10 +324,9 @@ function Combobox<OptionT>(props: PropsT<OptionT>) {
322
324
  <OverriddenInput
323
325
  inputRef={handleInputRef}
324
326
  aria-activedescendant={
325
- selectionIndex >= 0 ? activeDescendantId : undefined
327
+ isOpen && selectionIndex >= 0 ? activeDescendantId : undefined
326
328
  }
327
329
  aria-autocomplete="list"
328
- aria-controls={listboxId}
329
330
  disabled={disabled}
330
331
  error={error}
331
332
  name={name}
@@ -338,6 +339,7 @@ function Combobox<OptionT>(props: PropsT<OptionT>) {
338
339
  positive={positive}
339
340
  size={size}
340
341
  value={tempValue ? tempValue : value}
342
+ {...(isOpen ? {'aria-controls': listboxId} : {})}
341
343
  {...restInputProps}
342
344
  />
343
345
  </InputContainer>
@@ -18,6 +18,8 @@ export type PropsT<OptionT = mixed> = {|
18
18
  disabled?: boolean,
19
19
  // Proxies value through to Input component.
20
20
  error?: boolean,
21
+ // Label used for the listbox/popup with options
22
+ listBoxLabel?: string,
21
23
  // Used to render a custom node besides the default.
22
24
  mapOptionToNode?: React.AbstractComponent<{|
23
25
  isSelected: boolean,
@@ -502,7 +502,7 @@ var StyledDay = (0, _index.styled)('div', function (props) {
502
502
  content: '""',
503
503
  boxSizing: 'border-box',
504
504
  display: 'inline-block',
505
- boxShadow: $isFocusVisible ? "0 0 0 3px ".concat(colors.accent) : 'none',
505
+ boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? "0 0 0 3px ".concat(colors.accent) : 'none',
506
506
  backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
507
507
  height: $hasDateLabel ? '100%' : $density === _constants.DENSITY.high ? '42px' : '50px',
508
508
  width: '100%',
@@ -496,7 +496,10 @@ export const StyledDay = styled<SharedStylePropsT>('div', props => {
496
496
  content: '""',
497
497
  boxSizing: 'border-box',
498
498
  display: 'inline-block',
499
- boxShadow: $isFocusVisible ? `0 0 0 3px ${colors.accent}` : 'none',
499
+ boxShadow:
500
+ $isFocusVisible && (!$outsideMonth || $peekNextMonth)
501
+ ? `0 0 0 3px ${colors.accent}`
502
+ : 'none',
500
503
  backgroundColor: $selected
501
504
  ? colors.calendarDayBackgroundSelectedHighlighted
502
505
  : $pseudoSelected && $isHighlighted
@@ -28,6 +28,7 @@ function Combobox(props) {
28
28
  onChange,
29
29
  onFocus,
30
30
  onSubmit,
31
+ listBoxLabel,
31
32
  mapOptionToNode,
32
33
  mapOptionToString,
33
34
  id,
@@ -251,6 +252,7 @@ function Combobox(props) {
251
252
  ,
252
253
  ref: listboxRef,
253
254
  role: "listbox",
255
+ "aria-label": listBoxLabel,
254
256
  $width: listboxWidth
255
257
  }, listBoxProps), options.map((option, index) => {
256
258
  const isSelected = selectionIndex === index;
@@ -287,9 +289,8 @@ function Combobox(props) {
287
289
  role: "combobox"
288
290
  }, inputContainerProps), /*#__PURE__*/React.createElement(OverriddenInput, _extends({
289
291
  inputRef: handleInputRef,
290
- "aria-activedescendant": selectionIndex >= 0 ? activeDescendantId : undefined,
292
+ "aria-activedescendant": isOpen && selectionIndex >= 0 ? activeDescendantId : undefined,
291
293
  "aria-autocomplete": "list",
292
- "aria-controls": listboxId,
293
294
  disabled: disabled,
294
295
  error: error,
295
296
  name: name,
@@ -302,7 +303,9 @@ function Combobox(props) {
302
303
  positive: positive,
303
304
  size: size,
304
305
  value: tempValue ? tempValue : value
305
- }, restInputProps)))));
306
+ }, isOpen ? {
307
+ 'aria-controls': listboxId
308
+ } : {}, restInputProps)))));
306
309
  }
307
310
 
308
311
  export default Combobox;
@@ -503,7 +503,7 @@ export const StyledDay = styled('div', props => {
503
503
  content: '""',
504
504
  boxSizing: 'border-box',
505
505
  display: 'inline-block',
506
- boxShadow: $isFocusVisible ? `0 0 0 3px ${colors.accent}` : 'none',
506
+ boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? `0 0 0 3px ${colors.accent}` : 'none',
507
507
  backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
508
508
  height: $hasDateLabel ? '100%' : $density === DENSITY.high ? '42px' : '50px',
509
509
  width: '100%',
@@ -34,7 +34,9 @@ class ProgressBar extends React.Component {
34
34
  successValue,
35
35
  showLabel,
36
36
  infinite,
37
- errorMessage
37
+ errorMessage,
38
+ forwardedRef,
39
+ ...restProps
38
40
  } = this.props;
39
41
  const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
40
42
  const [BarContainer, barContainerProps] = getOverrides(overrides.BarContainer, StyledBarContainer);
@@ -68,6 +70,7 @@ class ProgressBar extends React.Component {
68
70
  /*#__PURE__*/
69
71
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
70
72
  React.createElement(Root, _extends({
73
+ ref: forwardedRef,
71
74
  "data-baseweb": "progress-bar",
72
75
  role: "progressbar",
73
76
  "aria-label": ariaLabel || getProgressLabel(value, successValue),
@@ -76,7 +79,7 @@ class ProgressBar extends React.Component {
76
79
  "aria-valuemax": infinite ? null : successValue,
77
80
  "aria-invalid": errorMessage ? true : null,
78
81
  "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({
82
+ }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
80
83
  $isLeft: true,
81
84
  $size: sharedProps.$size
82
85
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
@@ -98,4 +101,8 @@ _defineProperty(ProgressBar, "defaultProps", {
98
101
  value: 0
99
102
  });
100
103
 
101
- export default ProgressBar;
104
+ const ForwardedProgressBar = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(ProgressBar, _extends({
105
+ forwardedRef: ref
106
+ }, props)));
107
+ ForwardedProgressBar.displayName = 'ProgressBar';
108
+ export default ForwardedProgressBar;
@@ -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
  });
@@ -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;
@@ -481,7 +481,7 @@ export var StyledDay = styled('div', function (props) {
481
481
  content: '""',
482
482
  boxSizing: 'border-box',
483
483
  display: 'inline-block',
484
- boxShadow: $isFocusVisible ? "0 0 0 3px ".concat(colors.accent) : 'none',
484
+ boxShadow: $isFocusVisible && (!$outsideMonth || $peekNextMonth) ? "0 0 0 3px ".concat(colors.accent) : 'none',
485
485
  backgroundColor: $selected ? colors.calendarDayBackgroundSelectedHighlighted : $pseudoSelected && $isHighlighted ? colors.calendarDayBackgroundPseudoSelectedHighlighted : colors.calendarBackground,
486
486
  height: $hasDateLabel ? '100%' : $density === DENSITY.high ? '42px' : '50px',
487
487
  width: '100%',
@@ -14,6 +14,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
14
14
 
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
 
17
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
+
19
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
+
17
21
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
22
 
19
23
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -82,7 +86,9 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
82
86
  successValue = _this$props.successValue,
83
87
  showLabel = _this$props.showLabel,
84
88
  infinite = _this$props.infinite,
85
- errorMessage = _this$props.errorMessage;
89
+ errorMessage = _this$props.errorMessage,
90
+ forwardedRef = _this$props.forwardedRef,
91
+ restProps = _objectWithoutProperties(_this$props, ["ariaLabel", "overrides", "getProgressLabel", "value", "size", "steps", "successValue", "showLabel", "infinite", "errorMessage", "forwardedRef"]);
86
92
 
87
93
  var _getOverrides = getOverrides(overrides.Root, StyledRoot),
88
94
  _getOverrides2 = _slicedToArray(_getOverrides, 2),
@@ -140,6 +146,7 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
140
146
  /*#__PURE__*/
141
147
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
142
148
  React.createElement(Root, _extends({
149
+ ref: forwardedRef,
143
150
  "data-baseweb": "progress-bar",
144
151
  role: "progressbar",
145
152
  "aria-label": ariaLabel || getProgressLabel(value, successValue),
@@ -148,7 +155,7 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
148
155
  "aria-valuemax": infinite ? null : successValue,
149
156
  "aria-invalid": errorMessage ? true : null,
150
157
  "aria-errormessage": errorMessage
151
- }, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
158
+ }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
152
159
  $isLeft: true,
153
160
  $size: sharedProps.$size
154
161
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
@@ -174,4 +181,10 @@ _defineProperty(ProgressBar, "defaultProps", {
174
181
  value: 0
175
182
  });
176
183
 
177
- export default ProgressBar;
184
+ var ForwardedProgressBar = /*#__PURE__*/React.forwardRef(function (props, ref) {
185
+ return /*#__PURE__*/React.createElement(ProgressBar, _extends({
186
+ forwardedRef: ref
187
+ }, props));
188
+ });
189
+ ForwardedProgressBar.displayName = 'ProgressBar';
190
+ export default ForwardedProgressBar;
@@ -54,13 +54,40 @@ export var StyledActivePath = styled('path', function (props) {
54
54
  StyledActivePath.displayName = "StyledActivePath";
55
55
  export var StyledSpinnerNext = styled('i', function (_ref) {
56
56
  var $theme = _ref.$theme,
57
+ _ref$$color = _ref.$color,
58
+ $color = _ref$$color === void 0 ? $theme.colors.contentAccent : _ref$$color,
59
+ $borderWidth = _ref.$borderWidth,
57
60
  _ref$$size = _ref.$size,
58
61
  $size = _ref$$size === void 0 ? SIZE.medium : _ref$$size;
59
- var borderWidth = {
62
+ //$FlowFixMe
63
+ var borderSize = {
60
64
  large: $theme.sizing.scale300,
61
65
  medium: $theme.sizing.scale100,
62
66
  small: $theme.sizing.scale0
67
+ }[$borderWidth || $size];
68
+ var boxSize = {
69
+ large: $theme.sizing.scale1000,
70
+ medium: $theme.sizing.scale900,
71
+ small: $theme.sizing.scale800
63
72
  }[$size];
73
+
74
+ if (!borderSize) {
75
+ borderSize = $theme.sizing[$borderWidth];
76
+
77
+ if (!borderSize) {
78
+ borderSize = "".concat(parseInt($borderWidth), "px");
79
+ }
80
+ }
81
+
82
+ if (!boxSize) {
83
+ //$FlowFixMe
84
+ boxSize = $theme.sizing[$size];
85
+
86
+ if (!boxSize) {
87
+ boxSize = "".concat(parseInt($size), "px");
88
+ }
89
+ }
90
+
64
91
  return {
65
92
  display: 'block',
66
93
  animationName: spin,
@@ -72,24 +99,16 @@ export var StyledSpinnerNext = styled('i', function (_ref) {
72
99
  borderTopStyle: 'solid',
73
100
  borderBottomStyle: 'solid',
74
101
  borderRadius: '50%',
75
- borderTopColor: $theme.colors.contentAccent,
102
+ borderTopColor: $color,
76
103
  borderRightColor: $theme.colors.backgroundTertiary,
77
104
  borderBottomColor: $theme.colors.backgroundTertiary,
78
105
  borderLeftColor: $theme.colors.backgroundTertiary,
79
- borderLeftWidth: borderWidth,
80
- borderRightWidth: borderWidth,
81
- borderTopWidth: borderWidth,
82
- borderBottomWidth: borderWidth,
83
- width: {
84
- large: $theme.sizing.scale1000,
85
- medium: $theme.sizing.scale900,
86
- small: $theme.sizing.scale800
87
- }[$size],
88
- height: {
89
- large: $theme.sizing.scale1000,
90
- medium: $theme.sizing.scale900,
91
- small: $theme.sizing.scale800
92
- }[$size],
106
+ borderLeftWidth: borderSize,
107
+ borderRightWidth: borderSize,
108
+ borderTopWidth: borderSize,
109
+ borderBottomWidth: borderSize,
110
+ width: boxSize,
111
+ height: boxSize,
93
112
  cursor: 'wait'
94
113
  };
95
114
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-next-0688aa9",
3
+ "version": "0.0.0-next-9a8ac53",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -33,6 +33,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
33
33
 
34
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
35
 
36
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
37
+
38
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
39
+
36
40
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
41
 
38
42
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -90,7 +94,9 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
90
94
  successValue = _this$props.successValue,
91
95
  showLabel = _this$props.showLabel,
92
96
  infinite = _this$props.infinite,
93
- errorMessage = _this$props.errorMessage;
97
+ errorMessage = _this$props.errorMessage,
98
+ forwardedRef = _this$props.forwardedRef,
99
+ restProps = _objectWithoutProperties(_this$props, ["ariaLabel", "overrides", "getProgressLabel", "value", "size", "steps", "successValue", "showLabel", "infinite", "errorMessage", "forwardedRef"]);
94
100
 
95
101
  var _getOverrides = (0, _overrides.getOverrides)(overrides.Root, _styledComponents.StyledRoot),
96
102
  _getOverrides2 = _slicedToArray(_getOverrides, 2),
@@ -148,6 +154,7 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
148
154
  /*#__PURE__*/
149
155
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
150
156
  React.createElement(Root, _extends({
157
+ ref: forwardedRef,
151
158
  "data-baseweb": "progress-bar",
152
159
  role: "progressbar",
153
160
  "aria-label": ariaLabel || getProgressLabel(value, successValue),
@@ -156,7 +163,7 @@ var ProgressBar = /*#__PURE__*/function (_React$Component) {
156
163
  "aria-valuemax": infinite ? null : successValue,
157
164
  "aria-invalid": errorMessage ? true : null,
158
165
  "aria-errormessage": errorMessage
159
- }, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
166
+ }, restProps, sharedProps, rootProps), /*#__PURE__*/React.createElement(BarContainer, _extends({}, sharedProps, barContainerProps), infinite ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfiniteBar, _extends({
160
167
  $isLeft: true,
161
168
  $size: sharedProps.$size
162
169
  }, infiniteBarProps)), /*#__PURE__*/React.createElement(InfiniteBar, _extends({
@@ -182,5 +189,11 @@ _defineProperty(ProgressBar, "defaultProps", {
182
189
  value: 0
183
190
  });
184
191
 
185
- var _default = ProgressBar;
192
+ var ForwardedProgressBar = /*#__PURE__*/React.forwardRef(function (props, ref) {
193
+ return /*#__PURE__*/React.createElement(ProgressBar, _extends({
194
+ forwardedRef: ref
195
+ }, props));
196
+ });
197
+ ForwardedProgressBar.displayName = 'ProgressBar';
198
+ var _default = ForwardedProgressBar;
186
199
  exports.default = _default;
@@ -19,7 +19,10 @@ import {
19
19
 
20
20
  import type {ProgressBarPropsT} from './types.js';
21
21
 
22
- class ProgressBar extends React.Component<ProgressBarPropsT> {
22
+ class ProgressBar extends React.Component<
23
+ // eslint-disable-next-line flowtype/no-weak-types
24
+ ProgressBarPropsT & {forwardedRef: any},
25
+ > {
23
26
  static defaultProps = {
24
27
  getProgressLabel: (value: number, successValue: number) =>
25
28
  `${Math.round((value / successValue) * 100)}% Loaded`,
@@ -55,6 +58,8 @@ class ProgressBar extends React.Component<ProgressBarPropsT> {
55
58
  showLabel,
56
59
  infinite,
57
60
  errorMessage,
61
+ forwardedRef,
62
+ ...restProps
58
63
  } = this.props;
59
64
  const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
60
65
  const [BarContainer, barContainerProps] = getOverrides(
@@ -92,6 +97,7 @@ class ProgressBar extends React.Component<ProgressBarPropsT> {
92
97
  return (
93
98
  // eslint-disable-next-line jsx-a11y/role-supports-aria-props
94
99
  <Root
100
+ ref={forwardedRef}
95
101
  data-baseweb="progress-bar"
96
102
  role="progressbar"
97
103
  aria-label={ariaLabel || getProgressLabel(value, successValue)}
@@ -100,6 +106,7 @@ class ProgressBar extends React.Component<ProgressBarPropsT> {
100
106
  aria-valuemax={infinite ? null : successValue}
101
107
  aria-invalid={errorMessage ? true : null}
102
108
  aria-errormessage={errorMessage}
109
+ {...restProps}
103
110
  {...sharedProps}
104
111
  {...rootProps}
105
112
  >
@@ -127,7 +134,14 @@ class ProgressBar extends React.Component<ProgressBarPropsT> {
127
134
  }
128
135
  }
129
136
 
130
- export default ProgressBar;
137
+ const ForwardedProgressBar = React.forwardRef<
138
+ $Shape<ProgressBarPropsT>,
139
+ HTMLDivElement,
140
+ >((props: ProgressBarPropsT, ref) => (
141
+ <ProgressBar forwardedRef={ref} {...props} />
142
+ ));
143
+ ForwardedProgressBar.displayName = 'ProgressBar';
144
+ export default ForwardedProgressBar;
131
145
 
132
146
  declare var __DEV__: boolean;
133
147
  declare var __NODE__: boolean;
@@ -61,13 +61,40 @@ exports.StyledActivePath = StyledActivePath;
61
61
  StyledActivePath.displayName = "StyledActivePath";
62
62
  var StyledSpinnerNext = (0, _index.styled)('i', function (_ref) {
63
63
  var $theme = _ref.$theme,
64
+ _ref$$color = _ref.$color,
65
+ $color = _ref$$color === void 0 ? $theme.colors.contentAccent : _ref$$color,
66
+ $borderWidth = _ref.$borderWidth,
64
67
  _ref$$size = _ref.$size,
65
68
  $size = _ref$$size === void 0 ? _constants.SIZE.medium : _ref$$size;
66
- var borderWidth = {
69
+ //$FlowFixMe
70
+ var borderSize = {
67
71
  large: $theme.sizing.scale300,
68
72
  medium: $theme.sizing.scale100,
69
73
  small: $theme.sizing.scale0
74
+ }[$borderWidth || $size];
75
+ var boxSize = {
76
+ large: $theme.sizing.scale1000,
77
+ medium: $theme.sizing.scale900,
78
+ small: $theme.sizing.scale800
70
79
  }[$size];
80
+
81
+ if (!borderSize) {
82
+ borderSize = $theme.sizing[$borderWidth];
83
+
84
+ if (!borderSize) {
85
+ borderSize = "".concat(parseInt($borderWidth), "px");
86
+ }
87
+ }
88
+
89
+ if (!boxSize) {
90
+ //$FlowFixMe
91
+ boxSize = $theme.sizing[$size];
92
+
93
+ if (!boxSize) {
94
+ boxSize = "".concat(parseInt($size), "px");
95
+ }
96
+ }
97
+
71
98
  return {
72
99
  display: 'block',
73
100
  animationName: spin,
@@ -79,24 +106,16 @@ var StyledSpinnerNext = (0, _index.styled)('i', function (_ref) {
79
106
  borderTopStyle: 'solid',
80
107
  borderBottomStyle: 'solid',
81
108
  borderRadius: '50%',
82
- borderTopColor: $theme.colors.contentAccent,
109
+ borderTopColor: $color,
83
110
  borderRightColor: $theme.colors.backgroundTertiary,
84
111
  borderBottomColor: $theme.colors.backgroundTertiary,
85
112
  borderLeftColor: $theme.colors.backgroundTertiary,
86
- borderLeftWidth: borderWidth,
87
- borderRightWidth: borderWidth,
88
- borderTopWidth: borderWidth,
89
- borderBottomWidth: borderWidth,
90
- width: {
91
- large: $theme.sizing.scale1000,
92
- medium: $theme.sizing.scale900,
93
- small: $theme.sizing.scale800
94
- }[$size],
95
- height: {
96
- large: $theme.sizing.scale1000,
97
- medium: $theme.sizing.scale900,
98
- small: $theme.sizing.scale800
99
- }[$size],
113
+ borderLeftWidth: borderSize,
114
+ borderRightWidth: borderSize,
115
+ borderTopWidth: borderSize,
116
+ borderBottomWidth: borderSize,
117
+ width: boxSize,
118
+ height: boxSize,
100
119
  cursor: 'wait'
101
120
  };
102
121
  });
@@ -7,8 +7,8 @@ LICENSE file in the root directory of this source tree.
7
7
  // @flow
8
8
  import {styled} from '../styles/index.js';
9
9
  import {getSvgStyles} from '../icon/styled-components.js';
10
- import type {SizeT} from './types.js';
11
10
  import {SIZE} from './constants.js';
11
+ import type {StyledSpinnerNextPropsT} from './types.js';
12
12
 
13
13
  type StylePropsT = {
14
14
  $size?: number | string,
@@ -50,14 +50,40 @@ export const StyledActivePath = styled<StylePropsT>('path', props => ({
50
50
  }));
51
51
 
52
52
  // TODO(v11): Replace Spinner with SpinnerNext
53
- export const StyledSpinnerNext = styled<{$size?: SizeT}>(
53
+ export const StyledSpinnerNext = styled<StyledSpinnerNextPropsT>(
54
54
  'i',
55
- ({$theme, $size = SIZE.medium}) => {
56
- const borderWidth = {
55
+ ({
56
+ $theme,
57
+ $color = $theme.colors.contentAccent,
58
+ $borderWidth,
59
+ $size = SIZE.medium,
60
+ }) => {
61
+ //$FlowFixMe
62
+ let borderSize = {
57
63
  large: $theme.sizing.scale300,
58
64
  medium: $theme.sizing.scale100,
59
65
  small: $theme.sizing.scale0,
66
+ }[$borderWidth || $size];
67
+ let boxSize = {
68
+ large: $theme.sizing.scale1000,
69
+ medium: $theme.sizing.scale900,
70
+ small: $theme.sizing.scale800,
60
71
  }[$size];
72
+
73
+ if (!borderSize) {
74
+ borderSize = $theme.sizing[$borderWidth];
75
+ if (!borderSize) {
76
+ borderSize = `${parseInt($borderWidth)}px`;
77
+ }
78
+ }
79
+ if (!boxSize) {
80
+ //$FlowFixMe
81
+ boxSize = $theme.sizing[$size];
82
+ if (!boxSize) {
83
+ boxSize = `${parseInt($size)}px`;
84
+ }
85
+ }
86
+
61
87
  return {
62
88
  display: 'block',
63
89
  animationName: spin,
@@ -69,24 +95,16 @@ export const StyledSpinnerNext = styled<{$size?: SizeT}>(
69
95
  borderTopStyle: 'solid',
70
96
  borderBottomStyle: 'solid',
71
97
  borderRadius: '50%',
72
- borderTopColor: $theme.colors.contentAccent,
98
+ borderTopColor: $color,
73
99
  borderRightColor: $theme.colors.backgroundTertiary,
74
100
  borderBottomColor: $theme.colors.backgroundTertiary,
75
101
  borderLeftColor: $theme.colors.backgroundTertiary,
76
- borderLeftWidth: borderWidth,
77
- borderRightWidth: borderWidth,
78
- borderTopWidth: borderWidth,
79
- borderBottomWidth: borderWidth,
80
- width: {
81
- large: $theme.sizing.scale1000,
82
- medium: $theme.sizing.scale900,
83
- small: $theme.sizing.scale800,
84
- }[$size],
85
- height: {
86
- large: $theme.sizing.scale1000,
87
- medium: $theme.sizing.scale900,
88
- small: $theme.sizing.scale800,
89
- }[$size],
102
+ borderLeftWidth: borderSize,
103
+ borderRightWidth: borderSize,
104
+ borderTopWidth: borderSize,
105
+ borderBottomWidth: borderSize,
106
+ width: boxSize,
107
+ height: boxSize,
90
108
  cursor: 'wait',
91
109
  };
92
110
  },
@@ -8,6 +8,7 @@ LICENSE file in the root directory of this source tree.
8
8
 
9
9
  import {SIZE} from './constants.js';
10
10
  import type {OverrideT} from '../helpers/overrides.js';
11
+ import type {SizingT} from '../themes/types.js';
11
12
 
12
13
  export type SizeT = $Keys<typeof SIZE>;
13
14
  export type SpinnerPropsT = {
@@ -28,6 +29,15 @@ export type SpinnerPropsT = {
28
29
  },
29
30
  };
30
31
 
32
+ export type StyledSpinnerNextPropsT = {
33
+ /** Color of progress indicator */
34
+ $color?: string,
35
+ /** Width of the progress indicator "stroke". */
36
+ $borderWidth?: number | string | $Keys<SizingT> | SizeT,
37
+ /** Height/width of the box the indicator will appear in. */
38
+ $size?: number | string | $Keys<SizingT> | SizeT,
39
+ };
40
+
31
41
  declare var __DEV__: boolean;
32
42
  declare var __NODE__: boolean;
33
43
  declare var __BROWSER__: boolean;