@instructure/ui-spinner 11.6.0 → 11.6.1-snapshot-129
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 +30 -282
- package/es/Spinner/{index.js → v1/index.js} +2 -2
- package/es/Spinner/v2/index.js +117 -0
- package/es/Spinner/v2/props.js +26 -0
- package/es/Spinner/v2/styles.js +191 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -3
- package/lib/Spinner/{index.js → v1/index.js} +4 -4
- package/lib/Spinner/v2/index.js +124 -0
- package/lib/Spinner/v2/props.js +31 -0
- package/lib/Spinner/v2/styles.js +197 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +41 -19
- package/src/Spinner/{index.tsx → v1/index.tsx} +2 -2
- package/src/Spinner/v2/README.md +63 -0
- package/src/Spinner/v2/index.tsx +134 -0
- package/src/Spinner/v2/props.ts +81 -0
- package/src/Spinner/v2/styles.ts +208 -0
- package/src/exports/a.ts +26 -0
- package/src/exports/b.ts +26 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Spinner/v1/index.d.ts.map +1 -0
- package/types/Spinner/v1/props.d.ts.map +1 -0
- package/types/Spinner/v1/styles.d.ts.map +1 -0
- package/types/Spinner/v1/theme.d.ts.map +1 -0
- package/types/Spinner/v2/index.d.ts +31 -0
- package/types/Spinner/v2/index.d.ts.map +1 -0
- package/types/Spinner/v2/props.d.ts +38 -0
- package/types/Spinner/v2/props.d.ts.map +1 -0
- package/types/Spinner/v2/styles.d.ts +20 -0
- package/types/Spinner/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Spinner/index.d.ts.map +0 -1
- package/types/Spinner/props.d.ts.map +0 -1
- package/types/Spinner/styles.d.ts.map +0 -1
- package/types/Spinner/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Spinner/{props.js → v1/props.js} +0 -0
- /package/es/Spinner/{styles.js → v1/styles.js} +0 -0
- /package/es/Spinner/{theme.js → v1/theme.js} +0 -0
- /package/lib/Spinner/{props.js → v1/props.js} +0 -0
- /package/lib/Spinner/{styles.js → v1/styles.js} +0 -0
- /package/lib/Spinner/{theme.js → v1/theme.js} +0 -0
- /package/src/Spinner/{README.md → v1/README.md} +0 -0
- /package/src/Spinner/{props.ts → v1/props.ts} +0 -0
- /package/src/Spinner/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Spinner/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Spinner/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Spinner/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Spinner/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Spinner/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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
|
+
|
|
26
|
+
import { useState, useEffect, forwardRef } from 'react';
|
|
27
|
+
import { useStyle } from '@instructure/emotion';
|
|
28
|
+
import { callRenderProp, omitProps, useDeterministicId } from '@instructure/ui-react-utils';
|
|
29
|
+
import { logError as error } from '@instructure/console';
|
|
30
|
+
import generateStyle from "./styles.js";
|
|
31
|
+
import { allowedProps } from "./props.js";
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
category: components
|
|
35
|
+
---
|
|
36
|
+
**/
|
|
37
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
38
|
+
const Spinner = /*#__PURE__*/forwardRef((props, ref) => {
|
|
39
|
+
const _props$size = props.size,
|
|
40
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
41
|
+
_props$variant = props.variant,
|
|
42
|
+
variant = _props$variant === void 0 ? 'default' : _props$variant,
|
|
43
|
+
delay = props.delay,
|
|
44
|
+
renderTitle = props.renderTitle,
|
|
45
|
+
margin = props.margin,
|
|
46
|
+
themeOverride = props.themeOverride;
|
|
47
|
+
const _useState = useState(!delay),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
shouldRender = _useState2[0],
|
|
50
|
+
setShouldRender = _useState2[1];
|
|
51
|
+
// Deterministic ID generation
|
|
52
|
+
const _useState3 = useState(),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
titleId = _useState4[0],
|
|
55
|
+
setTitleId = _useState4[1];
|
|
56
|
+
const getId = useDeterministicId('Spinner');
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setTitleId(getId());
|
|
59
|
+
}, []);
|
|
60
|
+
const styles = useStyle({
|
|
61
|
+
generateStyle,
|
|
62
|
+
themeOverride,
|
|
63
|
+
params: {
|
|
64
|
+
size,
|
|
65
|
+
variant,
|
|
66
|
+
margin
|
|
67
|
+
},
|
|
68
|
+
componentId: 'Spinner',
|
|
69
|
+
displayName: 'Spinner'
|
|
70
|
+
});
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (delay) {
|
|
73
|
+
const delayTimeout = setTimeout(() => {
|
|
74
|
+
setShouldRender(true);
|
|
75
|
+
}, delay);
|
|
76
|
+
return () => clearTimeout(delayTimeout);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}, [delay]);
|
|
80
|
+
const renderSpinner = () => {
|
|
81
|
+
error(!!renderTitle, '[Spinner] The `renderTitle` prop is necessary for screen reader support.');
|
|
82
|
+
const passthroughProps = omitProps(props, allowedProps);
|
|
83
|
+
return _jsx("div", {
|
|
84
|
+
...passthroughProps,
|
|
85
|
+
css: styles === null || styles === void 0 ? void 0 : styles.spinner,
|
|
86
|
+
ref: ref,
|
|
87
|
+
"data-cid": "Spinner",
|
|
88
|
+
children: _jsxs("svg", {
|
|
89
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circle,
|
|
90
|
+
role: "img",
|
|
91
|
+
"aria-labelledby": titleId,
|
|
92
|
+
focusable: "false",
|
|
93
|
+
children: [_jsx("title", {
|
|
94
|
+
id: titleId,
|
|
95
|
+
children: callRenderProp(renderTitle)
|
|
96
|
+
}), _jsxs("g", {
|
|
97
|
+
role: "presentation",
|
|
98
|
+
children: [variant !== 'inverse' && _jsx("circle", {
|
|
99
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circleTrack,
|
|
100
|
+
cx: "50%",
|
|
101
|
+
cy: "50%",
|
|
102
|
+
r: styles === null || styles === void 0 ? void 0 : styles.radius
|
|
103
|
+
}), _jsx("circle", {
|
|
104
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circleSpin,
|
|
105
|
+
cx: "50%",
|
|
106
|
+
cy: "50%",
|
|
107
|
+
r: styles === null || styles === void 0 ? void 0 : styles.radius
|
|
108
|
+
})]
|
|
109
|
+
})]
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return shouldRender ? renderSpinner() : null;
|
|
114
|
+
});
|
|
115
|
+
Spinner.displayName = 'Spinner';
|
|
116
|
+
export default Spinner;
|
|
117
|
+
export { Spinner };
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
25
|
+
const allowedProps = ['delay', 'renderTitle', 'size', 'variant', 'margin'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
|
|
25
|
+
import { keyframes, calcSpacingFromShorthand } from '@instructure/emotion';
|
|
26
|
+
// keyframes have to be outside of 'generateStyle',
|
|
27
|
+
// since it is causing problems in style recalculation
|
|
28
|
+
const rotate = keyframes`
|
|
29
|
+
to {
|
|
30
|
+
transform: rotate(360deg)
|
|
31
|
+
}`;
|
|
32
|
+
const morph = keyframes`
|
|
33
|
+
0% {
|
|
34
|
+
stroke-dashoffset: 190%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
50% {
|
|
38
|
+
stroke-dashoffset: 00%;
|
|
39
|
+
transform: rotate(90deg);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
100% {
|
|
43
|
+
stroke-dashoffset: 190%;
|
|
44
|
+
transform: rotate(360deg);
|
|
45
|
+
}`;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ---
|
|
49
|
+
* private: true
|
|
50
|
+
* ---
|
|
51
|
+
* Generates the style object from the theme and provided additional information
|
|
52
|
+
* @param {Object} componentTheme The theme variable object.
|
|
53
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
54
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
55
|
+
* @return {Object} The final style object, which will be used in the component
|
|
56
|
+
*/
|
|
57
|
+
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
58
|
+
const size = params.size,
|
|
59
|
+
variant = params.variant,
|
|
60
|
+
margin = params.margin;
|
|
61
|
+
const spinnerSizes = {
|
|
62
|
+
'x-small': {
|
|
63
|
+
width: componentTheme.containerSizeXs,
|
|
64
|
+
height: componentTheme.containerSizeXs
|
|
65
|
+
},
|
|
66
|
+
small: {
|
|
67
|
+
width: componentTheme.containerSizeSm,
|
|
68
|
+
height: componentTheme.containerSizeSm
|
|
69
|
+
},
|
|
70
|
+
medium: {
|
|
71
|
+
width: componentTheme.containerSizeMd,
|
|
72
|
+
height: componentTheme.containerSizeMd
|
|
73
|
+
},
|
|
74
|
+
large: {
|
|
75
|
+
width: componentTheme.containerSizeLg,
|
|
76
|
+
height: componentTheme.containerSizeLg
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const circleSizes = {
|
|
80
|
+
'x-small': {
|
|
81
|
+
width: componentTheme.spinnerSizeXs,
|
|
82
|
+
height: componentTheme.spinnerSizeXs
|
|
83
|
+
},
|
|
84
|
+
small: {
|
|
85
|
+
width: componentTheme.spinnerSizeSm,
|
|
86
|
+
height: componentTheme.spinnerSizeSm
|
|
87
|
+
},
|
|
88
|
+
medium: {
|
|
89
|
+
width: componentTheme.spinnerSizeMd,
|
|
90
|
+
height: componentTheme.spinnerSizeMd
|
|
91
|
+
},
|
|
92
|
+
large: {
|
|
93
|
+
width: componentTheme.spinnerSizeLg,
|
|
94
|
+
height: componentTheme.spinnerSizeLg
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const circleTrackSizes = {
|
|
98
|
+
'x-small': {
|
|
99
|
+
strokeWidth: componentTheme.strokeWidthXs
|
|
100
|
+
},
|
|
101
|
+
small: {
|
|
102
|
+
strokeWidth: componentTheme.strokeWidthSm
|
|
103
|
+
},
|
|
104
|
+
medium: {
|
|
105
|
+
strokeWidth: componentTheme.strokeWidthMd
|
|
106
|
+
},
|
|
107
|
+
large: {
|
|
108
|
+
strokeWidth: componentTheme.strokeWidthLg
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const radii = {
|
|
112
|
+
'x-small': `calc(50% - ${componentTheme.strokeWidthXs} / 2)`,
|
|
113
|
+
small: `calc(50% - ${componentTheme.strokeWidthSm} / 2)`,
|
|
114
|
+
medium: `calc(50% - ${componentTheme.strokeWidthMd} / 2)`,
|
|
115
|
+
large: `calc(50% - ${componentTheme.strokeWidthLg} / 2)`
|
|
116
|
+
};
|
|
117
|
+
const circleSpinSizes = {
|
|
118
|
+
'x-small': {
|
|
119
|
+
strokeWidth: componentTheme.strokeWidthXs,
|
|
120
|
+
transformOrigin: `calc(${componentTheme.spinnerSizeXs} / 2) calc(${componentTheme.spinnerSizeXs} / 2)`
|
|
121
|
+
},
|
|
122
|
+
small: {
|
|
123
|
+
strokeWidth: componentTheme.strokeWidthSm,
|
|
124
|
+
transformOrigin: `calc(${componentTheme.spinnerSizeSm} / 2) calc(${componentTheme.spinnerSizeSm} / 2)`
|
|
125
|
+
},
|
|
126
|
+
medium: {
|
|
127
|
+
strokeWidth: componentTheme.strokeWidthMd,
|
|
128
|
+
transformOrigin: `calc(${componentTheme.spinnerSizeMd} / 2) calc(${componentTheme.spinnerSizeMd} / 2)`
|
|
129
|
+
},
|
|
130
|
+
large: {
|
|
131
|
+
strokeWidth: componentTheme.strokeWidthLg,
|
|
132
|
+
transformOrigin: `calc(${componentTheme.spinnerSizeLg} / 2) calc(${componentTheme.spinnerSizeLg} / 2)` //7em
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const circleSpinVariant = {
|
|
136
|
+
default: {
|
|
137
|
+
stroke: componentTheme.color
|
|
138
|
+
},
|
|
139
|
+
inverse: {
|
|
140
|
+
stroke: componentTheme.inverseColor
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
spinner: {
|
|
145
|
+
label: 'spinner',
|
|
146
|
+
display: 'inline-flex',
|
|
147
|
+
justifyContent: 'center',
|
|
148
|
+
alignItems: 'center',
|
|
149
|
+
boxSizing: 'border-box',
|
|
150
|
+
overflow: 'hidden',
|
|
151
|
+
verticalAlign: 'middle',
|
|
152
|
+
...spinnerSizes[size],
|
|
153
|
+
// TODO handle the merging on tokens inside the util
|
|
154
|
+
margin: calcSpacingFromShorthand(margin, {
|
|
155
|
+
...sharedTokens.spacing,
|
|
156
|
+
...sharedTokens.legacy.spacing
|
|
157
|
+
})
|
|
158
|
+
},
|
|
159
|
+
circle: {
|
|
160
|
+
label: 'spinner__circle',
|
|
161
|
+
display: 'block',
|
|
162
|
+
animationName: rotate,
|
|
163
|
+
animationDuration: '2.25s',
|
|
164
|
+
animationIterationCount: 'infinite',
|
|
165
|
+
animationTimingFunction: 'linear',
|
|
166
|
+
...circleSizes[size]
|
|
167
|
+
},
|
|
168
|
+
circleTrack: {
|
|
169
|
+
label: 'spinner__circleTrack',
|
|
170
|
+
stroke: componentTheme.trackColor,
|
|
171
|
+
fill: 'none',
|
|
172
|
+
width: '100%',
|
|
173
|
+
height: '100%',
|
|
174
|
+
...circleTrackSizes[size]
|
|
175
|
+
},
|
|
176
|
+
circleSpin: {
|
|
177
|
+
label: 'spinner__circleSpin',
|
|
178
|
+
fill: 'none',
|
|
179
|
+
strokeLinecap: 'round',
|
|
180
|
+
animationName: morph,
|
|
181
|
+
animationDuration: '1.75s',
|
|
182
|
+
animationIterationCount: 'infinite',
|
|
183
|
+
animationTimingFunction: 'ease',
|
|
184
|
+
strokeDasharray: `calc(${radii[size]} * 2 * 3.14159 * 0.75) 1000px`,
|
|
185
|
+
...circleSpinSizes[size],
|
|
186
|
+
...circleSpinVariant[variant]
|
|
187
|
+
},
|
|
188
|
+
radius: radii[size]
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
export default generateStyle;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Spinner = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _v11_ = require("@instructure/ui-view/v11_6");
|
|
10
10
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
11
11
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
12
12
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
@@ -45,7 +45,7 @@ var _dec, _dec2, _class, _Spinner;
|
|
|
45
45
|
category: components
|
|
46
46
|
---
|
|
47
47
|
**/
|
|
48
|
-
let Spinner = exports.Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.
|
|
48
|
+
let Spinner = exports.Spinner = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Spinner = class Spinner extends _react.Component {
|
|
49
49
|
constructor(props) {
|
|
50
50
|
super(props);
|
|
51
51
|
this.ref = null;
|
|
@@ -96,10 +96,10 @@ let Spinner = exports.Spinner = (_dec = (0, _withDeterministicId.withDeterminist
|
|
|
96
96
|
}
|
|
97
97
|
renderSpinner() {
|
|
98
98
|
var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
99
|
-
const passthroughProps =
|
|
99
|
+
const passthroughProps = _v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, Spinner.allowedProps), Spinner);
|
|
100
100
|
const hasTitle = this.props.renderTitle;
|
|
101
101
|
(0, _console.logError)(!!hasTitle, '[Spinner] The renderTitle prop is necessary for screen reader support.');
|
|
102
|
-
return (0, _jsxRuntime.jsx)(
|
|
102
|
+
return (0, _jsxRuntime.jsx)(_v11_.View, {
|
|
103
103
|
...passthroughProps,
|
|
104
104
|
as: this.props.as,
|
|
105
105
|
elementRef: this.handleRef,
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.Spinner = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _emotion = require("@instructure/emotion");
|
|
11
|
+
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
12
|
+
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
|
+
var _useDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/useDeterministicId.js");
|
|
14
|
+
var _console = require("@instructure/console");
|
|
15
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
16
|
+
var _props = require("./props");
|
|
17
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
|
+
/*
|
|
19
|
+
* The MIT License (MIT)
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
22
|
+
*
|
|
23
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
* in the Software without restriction, including without limitation the rights
|
|
26
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
* furnished to do so, subject to the following conditions:
|
|
29
|
+
*
|
|
30
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
* copies or substantial portions of the Software.
|
|
32
|
+
*
|
|
33
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
* SOFTWARE.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
---
|
|
44
|
+
category: components
|
|
45
|
+
---
|
|
46
|
+
**/const Spinner = exports.Spinner = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
47
|
+
const _props$size = props.size,
|
|
48
|
+
size = _props$size === void 0 ? 'medium' : _props$size,
|
|
49
|
+
_props$variant = props.variant,
|
|
50
|
+
variant = _props$variant === void 0 ? 'default' : _props$variant,
|
|
51
|
+
delay = props.delay,
|
|
52
|
+
renderTitle = props.renderTitle,
|
|
53
|
+
margin = props.margin,
|
|
54
|
+
themeOverride = props.themeOverride;
|
|
55
|
+
const _useState = (0, _react.useState)(!delay),
|
|
56
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
57
|
+
shouldRender = _useState2[0],
|
|
58
|
+
setShouldRender = _useState2[1];
|
|
59
|
+
// Deterministic ID generation
|
|
60
|
+
const _useState3 = (0, _react.useState)(),
|
|
61
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
62
|
+
titleId = _useState4[0],
|
|
63
|
+
setTitleId = _useState4[1];
|
|
64
|
+
const getId = (0, _useDeterministicId.useDeterministicId)('Spinner');
|
|
65
|
+
(0, _react.useEffect)(() => {
|
|
66
|
+
setTitleId(getId());
|
|
67
|
+
}, []);
|
|
68
|
+
const styles = (0, _emotion.useStyle)({
|
|
69
|
+
generateStyle: _styles.default,
|
|
70
|
+
themeOverride,
|
|
71
|
+
params: {
|
|
72
|
+
size,
|
|
73
|
+
variant,
|
|
74
|
+
margin
|
|
75
|
+
},
|
|
76
|
+
componentId: 'Spinner',
|
|
77
|
+
displayName: 'Spinner'
|
|
78
|
+
});
|
|
79
|
+
(0, _react.useEffect)(() => {
|
|
80
|
+
if (delay) {
|
|
81
|
+
const delayTimeout = setTimeout(() => {
|
|
82
|
+
setShouldRender(true);
|
|
83
|
+
}, delay);
|
|
84
|
+
return () => clearTimeout(delayTimeout);
|
|
85
|
+
}
|
|
86
|
+
return void 0;
|
|
87
|
+
}, [delay]);
|
|
88
|
+
const renderSpinner = () => {
|
|
89
|
+
(0, _console.logError)(!!renderTitle, '[Spinner] The `renderTitle` prop is necessary for screen reader support.');
|
|
90
|
+
const passthroughProps = (0, _omitProps.omitProps)(props, _props.allowedProps);
|
|
91
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
92
|
+
...passthroughProps,
|
|
93
|
+
css: styles === null || styles === void 0 ? void 0 : styles.spinner,
|
|
94
|
+
ref: ref,
|
|
95
|
+
"data-cid": "Spinner",
|
|
96
|
+
children: (0, _jsxRuntime.jsxs)("svg", {
|
|
97
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circle,
|
|
98
|
+
role: "img",
|
|
99
|
+
"aria-labelledby": titleId,
|
|
100
|
+
focusable: "false",
|
|
101
|
+
children: [(0, _jsxRuntime.jsx)("title", {
|
|
102
|
+
id: titleId,
|
|
103
|
+
children: (0, _callRenderProp.callRenderProp)(renderTitle)
|
|
104
|
+
}), (0, _jsxRuntime.jsxs)("g", {
|
|
105
|
+
role: "presentation",
|
|
106
|
+
children: [variant !== 'inverse' && (0, _jsxRuntime.jsx)("circle", {
|
|
107
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circleTrack,
|
|
108
|
+
cx: "50%",
|
|
109
|
+
cy: "50%",
|
|
110
|
+
r: styles === null || styles === void 0 ? void 0 : styles.radius
|
|
111
|
+
}), (0, _jsxRuntime.jsx)("circle", {
|
|
112
|
+
css: styles === null || styles === void 0 ? void 0 : styles.circleSpin,
|
|
113
|
+
cx: "50%",
|
|
114
|
+
cy: "50%",
|
|
115
|
+
r: styles === null || styles === void 0 ? void 0 : styles.radius
|
|
116
|
+
})]
|
|
117
|
+
})]
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
return shouldRender ? renderSpinner() : null;
|
|
122
|
+
});
|
|
123
|
+
Spinner.displayName = 'Spinner';
|
|
124
|
+
var _default = exports.default = Spinner;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['delay', 'renderTitle', 'size', 'variant', 'margin'];
|