@instructure/ui-spinner 8.45.1-snapshot-3 → 8.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.45.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v8.45.0...v8.45.1-snapshot-3) (2023-10-06)
6
+ # [8.46.0](https://github.com/instructure/instructure-ui/compare/v8.45.0...v8.46.0) (2023-10-11)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-spinner
8
+
9
+ ### Features
10
+
11
+ * **ui-spinner): feat(ui-spinner:** add delay prop and functionality to the Spinner ([1f44e5d](https://github.com/instructure/instructure-ui/commit/1f44e5dc81cd5a209ac9d05b87a361f63a0ead9f))
9
12
 
10
13
 
11
14
 
@@ -0,0 +1,46 @@
1
+ var _Spinner;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import React from 'react';
26
+ import { render, waitFor } from '@testing-library/react';
27
+ import '@testing-library/jest-dom/extend-expect';
28
+ import Spinner from '../index';
29
+ describe('<Spinner />', () => {
30
+ describe('with the delay prop', () => {
31
+ it('should delay rendering', async () => {
32
+ const _render = render(_Spinner || (_Spinner = /*#__PURE__*/React.createElement(Spinner, {
33
+ delay: 300
34
+ }))),
35
+ container = _render.container;
36
+ const spinnerElements = container.querySelectorAll('[data-cid="Spinner"]');
37
+ expect(spinnerElements.length).toBe(0);
38
+ await waitFor(() => {
39
+ const spinnerElements = container.querySelectorAll('[data-cid="Spinner"]');
40
+ expect(spinnerElements.length).toBe(1);
41
+ }, {
42
+ timeout: 400
43
+ });
44
+ });
45
+ });
46
+ });
@@ -44,6 +44,7 @@ let Spinner = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
44
44
  super(props);
45
45
  this.ref = null;
46
46
  this.titleId = void 0;
47
+ this.delayTimeout = void 0;
47
48
  this.handleRef = el => {
48
49
  const elementRef = this.props.elementRef;
49
50
  this.ref = el;
@@ -52,15 +53,29 @@ let Spinner = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
52
53
  }
53
54
  };
54
55
  this.titleId = props.deterministicId();
56
+ this.state = {
57
+ shouldRender: !props.delay
58
+ };
55
59
  }
56
60
  componentDidMount() {
57
61
  var _this$props$makeStyle, _this$props;
58
62
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
63
+ const delay = this.props.delay;
64
+ if (delay) {
65
+ this.delayTimeout = setTimeout(() => {
66
+ this.setState({
67
+ shouldRender: true
68
+ });
69
+ }, delay);
70
+ }
59
71
  }
60
72
  componentDidUpdate() {
61
73
  var _this$props$makeStyle2, _this$props2;
62
74
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
63
75
  }
76
+ componentWillUnmount() {
77
+ clearTimeout(this.delayTimeout);
78
+ }
64
79
  radius() {
65
80
  switch (this.props.size) {
66
81
  case 'x-small':
@@ -73,7 +88,7 @@ let Spinner = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
73
88
  return '1.75em';
74
89
  }
75
90
  }
76
- render() {
91
+ renderSpinner() {
77
92
  var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
78
93
  const passthroughProps = View.omitViewProps(omitProps(this.props, Spinner.allowedProps), Spinner);
79
94
  const hasTitle = this.props.renderTitle;
@@ -104,6 +119,9 @@ let Spinner = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, ge
104
119
  r: this.radius()
105
120
  }))));
106
121
  }
122
+ render() {
123
+ return this.state.shouldRender ? this.renderSpinner() : null;
124
+ }
107
125
  }, _class2.displayName = "Spinner", _class2.componentId = 'Spinner', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
108
126
  as: 'div',
109
127
  size: 'medium',
@@ -24,6 +24,7 @@
24
24
  import PropTypes from 'prop-types';
25
25
  import { ThemeablePropTypes } from '@instructure/emotion';
26
26
  const propTypes = {
27
+ delay: PropTypes.number,
27
28
  renderTitle: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
28
29
  size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
29
30
  variant: PropTypes.oneOf(['default', 'inverse']),
@@ -31,5 +32,5 @@ const propTypes = {
31
32
  elementRef: PropTypes.func,
32
33
  as: PropTypes.elementType
33
34
  };
34
- const allowedProps = ['renderTitle', 'size', 'variant', 'margin', 'elementRef', 'as'];
35
+ const allowedProps = ['delay', 'renderTitle', 'size', 'variant', 'margin', 'elementRef', 'as'];
35
36
  export { propTypes, allowedProps };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom/extend-expect");
7
+ var _index = _interopRequireDefault(require("../index"));
8
+ var _Spinner;
9
+ /*
10
+ * The MIT License (MIT)
11
+ *
12
+ * Copyright (c) 2015 - present Instructure, Inc.
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in all
22
+ * copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ * SOFTWARE.
31
+ */
32
+ describe('<Spinner />', () => {
33
+ describe('with the delay prop', () => {
34
+ it('should delay rendering', async () => {
35
+ const _render = (0, _react2.render)(_Spinner || (_Spinner = /*#__PURE__*/_react.default.createElement(_index.default, {
36
+ delay: 300
37
+ }))),
38
+ container = _render.container;
39
+ const spinnerElements = container.querySelectorAll('[data-cid="Spinner"]');
40
+ expect(spinnerElements.length).toBe(0);
41
+ await (0, _react2.waitFor)(() => {
42
+ const spinnerElements = container.querySelectorAll('[data-cid="Spinner"]');
43
+ expect(spinnerElements.length).toBe(1);
44
+ }, {
45
+ timeout: 400
46
+ });
47
+ });
48
+ });
49
+ });
@@ -52,6 +52,7 @@ let Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
52
52
  super(props);
53
53
  this.ref = null;
54
54
  this.titleId = void 0;
55
+ this.delayTimeout = void 0;
55
56
  this.handleRef = el => {
56
57
  const elementRef = this.props.elementRef;
57
58
  this.ref = el;
@@ -60,15 +61,29 @@ let Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
60
61
  }
61
62
  };
62
63
  this.titleId = props.deterministicId();
64
+ this.state = {
65
+ shouldRender: !props.delay
66
+ };
63
67
  }
64
68
  componentDidMount() {
65
69
  var _this$props$makeStyle, _this$props;
66
70
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
71
+ const delay = this.props.delay;
72
+ if (delay) {
73
+ this.delayTimeout = setTimeout(() => {
74
+ this.setState({
75
+ shouldRender: true
76
+ });
77
+ }, delay);
78
+ }
67
79
  }
68
80
  componentDidUpdate() {
69
81
  var _this$props$makeStyle2, _this$props2;
70
82
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
71
83
  }
84
+ componentWillUnmount() {
85
+ clearTimeout(this.delayTimeout);
86
+ }
72
87
  radius() {
73
88
  switch (this.props.size) {
74
89
  case 'x-small':
@@ -81,7 +96,7 @@ let Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
81
96
  return '1.75em';
82
97
  }
83
98
  }
84
- render() {
99
+ renderSpinner() {
85
100
  var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
86
101
  const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Spinner.allowedProps), Spinner);
87
102
  const hasTitle = this.props.renderTitle;
@@ -112,6 +127,9 @@ let Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
112
127
  r: this.radius()
113
128
  }))));
114
129
  }
130
+ render() {
131
+ return this.state.shouldRender ? this.renderSpinner() : null;
132
+ }
115
133
  }, _class2.displayName = "Spinner", _class2.componentId = 'Spinner', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
116
134
  as: 'div',
117
135
  size: 'medium',
@@ -32,6 +32,7 @@ var _emotion = require("@instructure/emotion");
32
32
  */
33
33
 
34
34
  const propTypes = {
35
+ delay: _propTypes.default.number,
35
36
  renderTitle: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
36
37
  size: _propTypes.default.oneOf(['x-small', 'small', 'medium', 'large']),
37
38
  variant: _propTypes.default.oneOf(['default', 'inverse']),
@@ -40,5 +41,5 @@ const propTypes = {
40
41
  as: _propTypes.default.elementType
41
42
  };
42
43
  exports.propTypes = propTypes;
43
- const allowedProps = ['renderTitle', 'size', 'variant', 'margin', 'elementRef', 'as'];
44
+ const allowedProps = ['delay', 'renderTitle', 'size', 'variant', 'margin', 'elementRef', 'as'];
44
45
  exports.allowedProps = allowedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-spinner",
3
- "version": "8.45.1-snapshot-3",
3
+ "version": "8.46.0",
4
4
  "description": "A spinner/loading component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,22 +24,24 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.22.15",
27
- "@instructure/console": "8.45.1-snapshot-3",
28
- "@instructure/emotion": "8.45.1-snapshot-3",
29
- "@instructure/shared-types": "8.45.1-snapshot-3",
30
- "@instructure/ui-color-utils": "8.45.1-snapshot-3",
31
- "@instructure/ui-react-utils": "8.45.1-snapshot-3",
32
- "@instructure/ui-testable": "8.45.1-snapshot-3",
33
- "@instructure/ui-utils": "8.45.1-snapshot-3",
34
- "@instructure/ui-view": "8.45.1-snapshot-3",
35
- "@instructure/uid": "8.45.1-snapshot-3",
27
+ "@instructure/console": "8.46.0",
28
+ "@instructure/emotion": "8.46.0",
29
+ "@instructure/shared-types": "8.46.0",
30
+ "@instructure/ui-color-utils": "8.46.0",
31
+ "@instructure/ui-react-utils": "8.46.0",
32
+ "@instructure/ui-testable": "8.46.0",
33
+ "@instructure/ui-utils": "8.46.0",
34
+ "@instructure/ui-view": "8.46.0",
35
+ "@instructure/uid": "8.46.0",
36
36
  "prop-types": "^15.8.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.45.1-snapshot-3",
40
- "@instructure/ui-test-locator": "8.45.1-snapshot-3",
41
- "@instructure/ui-test-utils": "8.45.1-snapshot-3",
42
- "@instructure/ui-themes": "8.45.1-snapshot-3"
39
+ "@instructure/ui-babel-preset": "8.46.0",
40
+ "@instructure/ui-test-locator": "8.46.0",
41
+ "@instructure/ui-test-utils": "8.46.0",
42
+ "@instructure/ui-themes": "8.46.0",
43
+ "@testing-library/jest-dom": "^5.17.0",
44
+ "@testing-library/react": "^14.0.0"
43
45
  },
44
46
  "peerDependencies": {
45
47
  "react": ">=16.8 <=18"
@@ -12,7 +12,7 @@ The `size` prop allows you to select from `x-small`, `small`, `medium` and `larg
12
12
  example: true
13
13
  ---
14
14
  <div>
15
- <Spinner renderTitle="Loading" size="x-small" />
15
+ <Spinner renderTitle="Loading" size="x-small"/>
16
16
  <Spinner renderTitle="Loading" size="small" margin="0 0 0 medium" />
17
17
  <Spinner renderTitle="Loading" margin="0 0 0 medium" />
18
18
  <Spinner renderTitle="Loading" size="large" margin="0 0 0 medium" />
@@ -33,6 +33,22 @@ example: true
33
33
  </View>
34
34
  ```
35
35
 
36
+ ### Delay rendering
37
+
38
+ The `delay` prop allows you to delay the rendering of the spinner a desired time to prevent flickering in cases of very fast load times.
39
+
40
+ ```js
41
+ ---
42
+ example: true
43
+ ---
44
+ <div>
45
+ <Spinner renderTitle="Loading" size="x-small" delay={1000} />
46
+ <Spinner renderTitle="Loading" size="small" margin="0 0 0 medium" delay={2000} />
47
+ <Spinner renderTitle="Loading" margin="0 0 0 medium" delay={3000} />
48
+ <Spinner renderTitle="Loading" size="large" margin="0 0 0 medium" delay={4000} />
49
+ </div>
50
+ ```
51
+
36
52
  ### Screen reader support
37
53
 
38
54
  The `renderTitle` prop is read to screen readers.
@@ -0,0 +1,52 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import React from 'react'
25
+ import { render, waitFor } from '@testing-library/react'
26
+
27
+ import '@testing-library/jest-dom/extend-expect'
28
+ import Spinner from '../index'
29
+
30
+ describe('<Spinner />', () => {
31
+ describe('with the delay prop', () => {
32
+ it('should delay rendering', async () => {
33
+ const { container } = render(<Spinner delay={300} />)
34
+
35
+ const spinnerElements = container.querySelectorAll('[data-cid="Spinner"]')
36
+
37
+ expect(spinnerElements.length).toBe(0)
38
+
39
+ await waitFor(
40
+ () => {
41
+ const spinnerElements = container.querySelectorAll(
42
+ '[data-cid="Spinner"]'
43
+ )
44
+ expect(spinnerElements.length).toBe(1)
45
+ },
46
+ {
47
+ timeout: 400
48
+ }
49
+ )
50
+ })
51
+ })
52
+ })
@@ -37,7 +37,7 @@ import { withStyle, jsx } from '@instructure/emotion'
37
37
 
38
38
  import generateStyle from './styles'
39
39
  import generateComponentTheme from './theme'
40
- import type { SpinnerProps } from './props'
40
+ import type { SpinnerProps, SpinnerState } from './props'
41
41
  import { allowedProps, propTypes } from './props'
42
42
 
43
43
  /**
@@ -49,7 +49,7 @@ category: components
49
49
  @withDeterministicId()
50
50
  @withStyle(generateStyle, generateComponentTheme)
51
51
  @testable()
52
- class Spinner extends Component<SpinnerProps> {
52
+ class Spinner extends Component<SpinnerProps, SpinnerState> {
53
53
  static readonly componentId = 'Spinner'
54
54
  static allowedProps = allowedProps
55
55
  static propTypes = propTypes
@@ -61,6 +61,7 @@ class Spinner extends Component<SpinnerProps> {
61
61
 
62
62
  ref: Element | null = null
63
63
  private readonly titleId?: string
64
+ private delayTimeout?: NodeJS.Timeout
64
65
 
65
66
  handleRef = (el: Element | null) => {
66
67
  const { elementRef } = this.props
@@ -76,16 +77,31 @@ class Spinner extends Component<SpinnerProps> {
76
77
  super(props)
77
78
 
78
79
  this.titleId = props.deterministicId!()
80
+
81
+ this.state = {
82
+ shouldRender: !props.delay
83
+ }
79
84
  }
80
85
 
81
86
  componentDidMount() {
82
87
  this.props.makeStyles?.()
88
+ const { delay } = this.props
89
+
90
+ if (delay) {
91
+ this.delayTimeout = setTimeout(() => {
92
+ this.setState({ shouldRender: true })
93
+ }, delay)
94
+ }
83
95
  }
84
96
 
85
97
  componentDidUpdate() {
86
98
  this.props.makeStyles?.()
87
99
  }
88
100
 
101
+ componentWillUnmount() {
102
+ clearTimeout(this.delayTimeout)
103
+ }
104
+
89
105
  radius() {
90
106
  switch (this.props.size) {
91
107
  case 'x-small':
@@ -99,7 +115,7 @@ class Spinner extends Component<SpinnerProps> {
99
115
  }
100
116
  }
101
117
 
102
- render() {
118
+ renderSpinner() {
103
119
  const passthroughProps = View.omitViewProps(
104
120
  omitProps(this.props, Spinner.allowedProps),
105
121
  Spinner
@@ -148,6 +164,10 @@ class Spinner extends Component<SpinnerProps> {
148
164
  </View>
149
165
  )
150
166
  }
167
+
168
+ render() {
169
+ return this.state.shouldRender ? this.renderSpinner() : null
170
+ }
151
171
  }
152
172
 
153
173
  export default Spinner
@@ -41,17 +41,17 @@ import { Renderable } from '@instructure/shared-types'
41
41
 
42
42
  type SpinnerOwnProps = {
43
43
  /**
44
- * Give the spinner a title to be read by screenreaders
44
+ * Render Spinner "as" another HTML element
45
45
  */
46
- renderTitle?: Renderable
46
+ as?: AsElementType
47
47
  /**
48
- * Different-sized spinners
48
+ * delay spinner rendering for a time (in ms). Used to prevent flickering in case of very fast load times
49
49
  */
50
- size?: 'x-small' | 'small' | 'medium' | 'large'
50
+ delay?: number
51
51
  /**
52
- * Different color schemes for use with light or dark backgrounds
52
+ * provides a reference to the underlying html root element
53
53
  */
54
- variant?: 'default' | 'inverse'
54
+ elementRef?: (element: Element | null) => void
55
55
  /**
56
56
  * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
57
57
  * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
@@ -59,10 +59,17 @@ type SpinnerOwnProps = {
59
59
  */
60
60
  margin?: Spacing
61
61
  /**
62
- * provides a reference to the underlying html root element
62
+ * Give the spinner a title to be read by screenreaders
63
63
  */
64
- elementRef?: (element: Element | null) => void
65
- as?: AsElementType
64
+ renderTitle?: Renderable
65
+ /**
66
+ * Different-sized spinners
67
+ */
68
+ size?: 'x-small' | 'small' | 'medium' | 'large'
69
+ /**
70
+ * Different color schemes for use with light or dark backgrounds
71
+ */
72
+ variant?: 'default' | 'inverse'
66
73
  }
67
74
 
68
75
  type PropKeys = keyof SpinnerOwnProps
@@ -74,11 +81,16 @@ type SpinnerProps = SpinnerOwnProps &
74
81
  OtherHTMLAttributes<SpinnerOwnProps> &
75
82
  WithDeterministicIdProps
76
83
 
84
+ type SpinnerState = {
85
+ shouldRender: boolean
86
+ }
87
+
77
88
  type SpinnerStyle = ComponentStyle<
78
89
  'spinner' | 'circle' | 'circleTrack' | 'circleSpin'
79
90
  >
80
91
 
81
92
  const propTypes: PropValidators<PropKeys> = {
93
+ delay: PropTypes.number,
82
94
  renderTitle: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
83
95
  size: PropTypes.oneOf(['x-small', 'small', 'medium', 'large']),
84
96
  variant: PropTypes.oneOf(['default', 'inverse']),
@@ -88,6 +100,7 @@ const propTypes: PropValidators<PropKeys> = {
88
100
  }
89
101
 
90
102
  const allowedProps: AllowedPropKeys = [
103
+ 'delay',
91
104
  'renderTitle',
92
105
  'size',
93
106
  'variant',
@@ -96,5 +109,5 @@ const allowedProps: AllowedPropKeys = [
96
109
  'as'
97
110
  ]
98
111
 
99
- export type { SpinnerProps, SpinnerStyle }
112
+ export type { SpinnerProps, SpinnerState, SpinnerStyle }
100
113
  export { propTypes, allowedProps }