@zendeskgarden/react-loaders 9.0.0-next.6 → 9.0.0-next.8
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/dist/esm/elements/Dots.js +93 -0
- package/dist/esm/elements/Inline.js +51 -0
- package/dist/esm/elements/Progress.js +59 -0
- package/dist/esm/elements/Skeleton.js +42 -0
- package/dist/esm/elements/Spinner.js +99 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/styled/StyledDots.js +52 -0
- package/dist/esm/styled/StyledInline.js +37 -0
- package/dist/esm/styled/StyledLoadingPlaceholder.js +23 -0
- package/dist/esm/styled/StyledProgress.js +47 -0
- package/dist/esm/styled/StyledSVG.js +26 -0
- package/dist/esm/styled/StyledSkeleton.js +52 -0
- package/dist/esm/styled/StyledSpinnerCircle.js +28 -0
- package/dist/esm/types/index.js +9 -0
- package/dist/esm/utils/animations.js +13 -0
- package/dist/esm/utils/spinner-coordinates.js +71 -0
- package/dist/index.cjs.js +17 -33
- package/package.json +5 -5
- package/dist/index.esm.js +0 -544
package/dist/index.esm.js
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright Zendesk, Inc.
|
|
3
|
-
*
|
|
4
|
-
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
-
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { forwardRef, useContext, useRef, useEffect } from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import styled, { keyframes, css, ThemeContext } from 'styled-components';
|
|
11
|
-
import { useSchedule } from '@zendeskgarden/container-schedule';
|
|
12
|
-
import { DEFAULT_THEME, retrieveComponentStyles, getColorV8, getLineHeight, useDocument, useText } from '@zendeskgarden/react-theming';
|
|
13
|
-
import { rgba } from 'polished';
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const dotOneKeyframes = keyframes(["0%{transform:translate(0,5px);}3%{transform:translate(1px,-5px);}6%{transform:translate(3px,-15px);}8%{transform:translate(5px,-18px);}9%{transform:translate(7px,-21px);}11%{transform:translate(8px,-22px);}13%{transform:translate(9px,-23px);}16%{transform:translate(12px,-25px);}18%{transform:translate(13px,-26px);}23%{transform:translate(18px,-26px);}24%{transform:translate(19px,-25px);}28%{transform:translate(22px,-23px);}31%{transform:translate(24px,-21px);}33%{transform:translate(26px,-18px);}34%{transform:translate(28px,-14px);}36%{transform:translate(29px,-12px);}38%{transform:translate(30px,-5px);}39%{transform:translate(31px,5px);}54%{transform:translate(31px,3px);}59%{transform:translate(33px);}61%{transform:translate(43px);}63%{transform:translate(48px);}64%{transform:translate(51px);}66%{transform:translate(53px);}68%{transform:translate(55px);}69%{transform:translate(57px);}76%{transform:translate(60px);}81%{transform:translate(61px);}83%,100%{transform:translate(62px);}"]);
|
|
31
|
-
const dotTwoKeyframes = keyframes(["4%{transform:translate(0);}6%{transform:translate(-1px);}8%{transform:translate(-2px);}9%{transform:translate(-5px);}11%{transform:translate(-7px);}13%{transform:translate(-12px);}14%{transform:translate(-17px);}16%{transform:translate(-19px);}18%{transform:translate(-22px);}19%{transform:translate(-25px);}21%{transform:translate(-26px);}23%{transform:translate(-27px);}24%{transform:translate(-28px);}26%{transform:translate(-29px);}29%{transform:translate(-30px);}33%,89%{transform:translate(-31px);}91%{transform:translate(-31px,1px);}94%{transform:translate(-31px,2px);}98%{transform:translate(-31px,3px);}99%{transform:translate(-31px,4px);}100%{transform:translate(-31px,5px);}"]);
|
|
32
|
-
const dotThreeKeyframes = keyframes(["39%{transform:translate(0);}44%{transform:translate(0,1px);}46%{transform:translate(0,2px);}48%{transform:translate(0,3px);}49%{transform:translate(0,4px);}51%{transform:translate(0,5px);}53%{transform:translate(-1px,-6px);}54%{transform:translate(-2px,-13px);}56%{transform:translate(-3px,-15px);}58%{transform:translate(-5px,-19px);}59%{transform:translate(-7px,-21px);}61%{transform:translate(-8px,-22px);}63%{transform:translate(-9px,-24px);}64%{transform:translate(-11px,-25px);}66%{transform:translate(-12px,-26px);}74%{transform:translate(-19px,-26px);}76%{transform:translate(-20px,-25px);}78%{transform:translate(-22px,-24px);}81%{transform:translate(-24px,-21px);}83%{transform:translate(-26px,-19px);}84%{transform:translate(-28px,-15px);}86%{transform:translate(-29px,-13px);}88%{transform:translate(-30px,-6px);}89%{transform:translate(-31px,5px);}91%{transform:translate(-31px,4px);}93%{transform:translate(-31px,3px);}94%{transform:translate(-31px,2px);}98%{transform:translate(-31px,1px);}100%{transform:translate(-31px);}"]);
|
|
33
|
-
|
|
34
|
-
const StyledDotsCircle = styled.circle.attrs({
|
|
35
|
-
cy: 36,
|
|
36
|
-
r: 9
|
|
37
|
-
}).withConfig({
|
|
38
|
-
displayName: "StyledDots__StyledDotsCircle",
|
|
39
|
-
componentId: "sc-1ltah7e-0"
|
|
40
|
-
})([""]);
|
|
41
|
-
StyledDotsCircle.defaultProps = {
|
|
42
|
-
theme: DEFAULT_THEME
|
|
43
|
-
};
|
|
44
|
-
const animationStyles = (animationName, props) => {
|
|
45
|
-
return css(["animation:", " ", "ms linear infinite;"], animationName, props.duration);
|
|
46
|
-
};
|
|
47
|
-
const StyledDotsCircleOne = styled(StyledDotsCircle).attrs({
|
|
48
|
-
cx: 9
|
|
49
|
-
}).withConfig({
|
|
50
|
-
displayName: "StyledDots__StyledDotsCircleOne",
|
|
51
|
-
componentId: "sc-1ltah7e-1"
|
|
52
|
-
})(["", ";"], props => animationStyles(dotOneKeyframes, props));
|
|
53
|
-
StyledDotsCircleOne.defaultProps = {
|
|
54
|
-
theme: DEFAULT_THEME
|
|
55
|
-
};
|
|
56
|
-
const StyledDotsCircleTwo = styled(StyledDotsCircle).attrs(() => ({
|
|
57
|
-
cx: 40
|
|
58
|
-
})).withConfig({
|
|
59
|
-
displayName: "StyledDots__StyledDotsCircleTwo",
|
|
60
|
-
componentId: "sc-1ltah7e-2"
|
|
61
|
-
})(["", ";"], props => animationStyles(dotTwoKeyframes, props));
|
|
62
|
-
StyledDotsCircleTwo.defaultProps = {
|
|
63
|
-
theme: DEFAULT_THEME
|
|
64
|
-
};
|
|
65
|
-
const StyledDotsCircleThree = styled(StyledDotsCircle).attrs(() => ({
|
|
66
|
-
cx: 71
|
|
67
|
-
})).withConfig({
|
|
68
|
-
displayName: "StyledDots__StyledDotsCircleThree",
|
|
69
|
-
componentId: "sc-1ltah7e-3"
|
|
70
|
-
})(["", ";"], props => animationStyles(dotThreeKeyframes, props));
|
|
71
|
-
StyledDotsCircleThree.defaultProps = {
|
|
72
|
-
theme: DEFAULT_THEME
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const COMPONENT_ID$5 = 'loaders.loading_placeholder';
|
|
76
|
-
const StyledLoadingPlaceholder = styled.div.attrs({
|
|
77
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
78
|
-
'data-garden-version': '9.0.0-next.6',
|
|
79
|
-
role: 'progressbar'
|
|
80
|
-
}).withConfig({
|
|
81
|
-
displayName: "StyledLoadingPlaceholder",
|
|
82
|
-
componentId: "sc-x3bwsx-0"
|
|
83
|
-
})(["display:inline-block;width:", ";height:", ";font-size:", ";", ""], props => props.width || '1em', props => props.height || '0.9em', props => props.fontSize, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
84
|
-
StyledLoadingPlaceholder.defaultProps = {
|
|
85
|
-
theme: DEFAULT_THEME
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const sizeToHeight = (size, theme) => {
|
|
89
|
-
switch (size) {
|
|
90
|
-
case 'small':
|
|
91
|
-
return theme.space.base / 2;
|
|
92
|
-
case 'medium':
|
|
93
|
-
return theme.space.base * 1.5;
|
|
94
|
-
default:
|
|
95
|
-
return theme.space.base * 3;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const sizeToBorderRadius = (size, theme) => sizeToHeight(size, theme) / 2;
|
|
99
|
-
const PROGRESS_BACKGROUND_COMPONENT_ID = 'loaders.progress_background';
|
|
100
|
-
const StyledProgressBackground = styled.div.attrs(props => ({
|
|
101
|
-
'data-garden-id': PROGRESS_BACKGROUND_COMPONENT_ID,
|
|
102
|
-
'data-garden-version': '9.0.0-next.6',
|
|
103
|
-
borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
|
|
104
|
-
})).withConfig({
|
|
105
|
-
displayName: "StyledProgress__StyledProgressBackground",
|
|
106
|
-
componentId: "sc-2g8w4s-0"
|
|
107
|
-
})(["margin:", "px 0;border-radius:", "px;background-color:", ";color:", ";", ""], props => props.theme.space.base * 2, props => props.borderRadius, props => getColorV8('neutralHue', 200, props.theme), props => props.color || getColorV8('successHue', 600, props.theme), props => retrieveComponentStyles(PROGRESS_BACKGROUND_COMPONENT_ID, props));
|
|
108
|
-
StyledProgressBackground.defaultProps = {
|
|
109
|
-
theme: DEFAULT_THEME
|
|
110
|
-
};
|
|
111
|
-
const PROGESS_INDICATOR_COMPONENT_ID = 'loaders.progress_indicator';
|
|
112
|
-
const StyledProgressIndicator = styled.div.attrs(props => ({
|
|
113
|
-
'data-garden-id': PROGESS_INDICATOR_COMPONENT_ID,
|
|
114
|
-
'data-garden-version': '9.0.0-next.6',
|
|
115
|
-
height: props.height || sizeToHeight(props.size, props.theme),
|
|
116
|
-
borderRadius: props.borderRadius || sizeToBorderRadius(props.size, props.theme)
|
|
117
|
-
})).withConfig({
|
|
118
|
-
displayName: "StyledProgress__StyledProgressIndicator",
|
|
119
|
-
componentId: "sc-2g8w4s-1"
|
|
120
|
-
})(["transition:width 0.1s ease-in-out;border-radius:", "px;background:currentcolor;width:", "%;height:", "px;", ""], props => props.borderRadius, props => props.value, props => props.height, props => retrieveComponentStyles(PROGESS_INDICATOR_COMPONENT_ID, props));
|
|
121
|
-
StyledProgressIndicator.defaultProps = {
|
|
122
|
-
theme: DEFAULT_THEME
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const COMPONENT_ID$4 = 'loaders.skeleton';
|
|
126
|
-
const fadeInAnimation = keyframes(["0%,60%{opacity:0;}100%{opacity:1;}"]);
|
|
127
|
-
const skeletonAnimation = keyframes(["0%{transform:translateX(-100%);}100%{transform:translateX(100%);}"]);
|
|
128
|
-
const skeletonRtlAnimation = keyframes(["0%{transform:translateX(100%);}100%{transform:translateX(-100%)}"]);
|
|
129
|
-
const retrieveSkeletonBackgroundColor = _ref => {
|
|
130
|
-
let {
|
|
131
|
-
theme,
|
|
132
|
-
isLight
|
|
133
|
-
} = _ref;
|
|
134
|
-
if (isLight) {
|
|
135
|
-
return css(["background-color:", ";"], rgba(getColorV8('background', 600 , theme), 0.2));
|
|
136
|
-
}
|
|
137
|
-
return css(["background-color:", ";"], getColorV8('neutralHue', 800, theme, 0.1));
|
|
138
|
-
};
|
|
139
|
-
const retrieveSkeletonAnimation = _ref2 => {
|
|
140
|
-
let {
|
|
141
|
-
theme
|
|
142
|
-
} = _ref2;
|
|
143
|
-
if (theme.rtl) {
|
|
144
|
-
return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonRtlAnimation);
|
|
145
|
-
}
|
|
146
|
-
return css(["animation:", " 1.5s ease-in-out 300ms infinite;"], skeletonAnimation);
|
|
147
|
-
};
|
|
148
|
-
const retrieveSkeletonGradient = _ref3 => {
|
|
149
|
-
let {
|
|
150
|
-
theme,
|
|
151
|
-
isLight
|
|
152
|
-
} = _ref3;
|
|
153
|
-
return css(["background-image:linear-gradient( ", ",transparent,", ",transparent );"], theme.rtl ? '-45deg' : '45deg', isLight ? getColorV8('chromeHue', 700, theme, 0.4) : rgba(getColorV8('background', 600 , theme), 0.6));
|
|
154
|
-
};
|
|
155
|
-
const StyledSkeleton = styled.div.attrs({
|
|
156
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
157
|
-
'data-garden-version': '9.0.0-next.6'
|
|
158
|
-
}).withConfig({
|
|
159
|
-
displayName: "StyledSkeleton",
|
|
160
|
-
componentId: "sc-1raozze-0"
|
|
161
|
-
})(["display:inline-block;position:relative;animation:", " 750ms linear;border-radius:", ";width:", ";height:", ";overflow:hidden;line-height:", ";", " &::before{position:absolute;top:0;width:1000px;height:100%;content:'';", " ", "}", ";"], fadeInAnimation, props => props.theme.borderRadii.md, props => props.customWidth, props => props.customHeight, props => getLineHeight(props.theme.fontSizes.sm, props.theme.space.base * 5), retrieveSkeletonBackgroundColor, retrieveSkeletonAnimation, retrieveSkeletonGradient, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
162
|
-
StyledSkeleton.defaultProps = {
|
|
163
|
-
theme: DEFAULT_THEME
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const StyledSpinnerCircle = styled.circle.attrs(props => ({
|
|
167
|
-
cx: 40,
|
|
168
|
-
cy: 40,
|
|
169
|
-
r: 34,
|
|
170
|
-
fill: 'none',
|
|
171
|
-
stroke: 'currentColor',
|
|
172
|
-
strokeLinecap: 'round',
|
|
173
|
-
strokeWidth: props.strokeWidthValue,
|
|
174
|
-
strokeDasharray: `${props.dasharrayValue} 250`,
|
|
175
|
-
transform: props.transform
|
|
176
|
-
})).withConfig({
|
|
177
|
-
displayName: "StyledSpinnerCircle",
|
|
178
|
-
componentId: "sc-o4kd70-0"
|
|
179
|
-
})([""]);
|
|
180
|
-
StyledSpinnerCircle.defaultProps = {
|
|
181
|
-
theme: DEFAULT_THEME
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const StyledSVG = styled.svg.attrs(props => ({
|
|
185
|
-
'data-garden-version': '9.0.0-next.6',
|
|
186
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
187
|
-
width: props.width,
|
|
188
|
-
height: props.height,
|
|
189
|
-
focusable: 'false',
|
|
190
|
-
viewBox: `0 0 ${props.width} ${props.height}`,
|
|
191
|
-
role: 'img'
|
|
192
|
-
})).withConfig({
|
|
193
|
-
displayName: "StyledSVG",
|
|
194
|
-
componentId: "sc-1xtc3kx-0"
|
|
195
|
-
})(["width:", ";height:", ";color:", ";font-size:", ";", ";"], props => props.containerWidth || '1em', props => props.containerHeight || '0.9em', props => props.color || 'inherit', props => props.fontSize || 'inherit', props => retrieveComponentStyles(props.dataGardenId, props));
|
|
196
|
-
StyledSVG.defaultProps = {
|
|
197
|
-
theme: DEFAULT_THEME
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const COMPONENT_ID$3 = 'loaders.inline';
|
|
201
|
-
const PULSE_ANIMATION = keyframes(["0%,100%{opacity:.2;}50%{opacity:.8;}"]);
|
|
202
|
-
const StyledCircle = styled.circle.attrs({
|
|
203
|
-
fill: 'currentColor',
|
|
204
|
-
cy: 2,
|
|
205
|
-
r: 2
|
|
206
|
-
}).withConfig({
|
|
207
|
-
displayName: "StyledInline__StyledCircle",
|
|
208
|
-
componentId: "sc-fxsb9l-0"
|
|
209
|
-
})([""]);
|
|
210
|
-
StyledCircle.defaultProps = {
|
|
211
|
-
theme: DEFAULT_THEME
|
|
212
|
-
};
|
|
213
|
-
const StyledInline = styled.svg.attrs(props => ({
|
|
214
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
215
|
-
'data-garden-version': '9.0.0-next.6',
|
|
216
|
-
viewBox: '0 0 16 4',
|
|
217
|
-
width: props.size,
|
|
218
|
-
height: props.size * 0.25
|
|
219
|
-
})).withConfig({
|
|
220
|
-
displayName: "StyledInline",
|
|
221
|
-
componentId: "sc-fxsb9l-1"
|
|
222
|
-
})(["color:", ";", "{opacity:0.2;&:nth-child(1){animation:", " 1s infinite;animation-delay:", ";}&:nth-child(2){animation:", " 1s infinite;animation-delay:0.2s;}&:nth-child(3){animation:", " 1s infinite;animation-delay:", ";}}", ""], props => props.color, StyledCircle, PULSE_ANIMATION, props => props.theme.rtl ? 'unset' : '0.4s', PULSE_ANIMATION, PULSE_ANIMATION, props => props.theme.rtl ? '0.4s' : 'unset', props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
223
|
-
StyledInline.defaultProps = {
|
|
224
|
-
theme: DEFAULT_THEME
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const COMPONENT_ID$2 = 'loaders.dots';
|
|
228
|
-
const Dots = forwardRef((_ref, ref) => {
|
|
229
|
-
let {
|
|
230
|
-
size,
|
|
231
|
-
color,
|
|
232
|
-
duration,
|
|
233
|
-
delayMS,
|
|
234
|
-
...other
|
|
235
|
-
} = _ref;
|
|
236
|
-
const theme = useContext(ThemeContext);
|
|
237
|
-
const environment = useDocument(theme);
|
|
238
|
-
const canTransformSVG = useRef(null);
|
|
239
|
-
if (environment && canTransformSVG.current === null) {
|
|
240
|
-
const svg = environment.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
241
|
-
canTransformSVG.current = 'transform' in svg;
|
|
242
|
-
}
|
|
243
|
-
const {
|
|
244
|
-
delayComplete
|
|
245
|
-
} = useSchedule({
|
|
246
|
-
duration,
|
|
247
|
-
delayMS,
|
|
248
|
-
loop: true
|
|
249
|
-
});
|
|
250
|
-
const dotOne = useRef(null);
|
|
251
|
-
const dotTwo = useRef(null);
|
|
252
|
-
const dotThree = useRef(null);
|
|
253
|
-
useEffect(() => {
|
|
254
|
-
if (!canTransformSVG.current && delayComplete) {
|
|
255
|
-
const transforms = [window.getComputedStyle(dotOne.current).getPropertyValue('transform'), window.getComputedStyle(dotTwo.current).getPropertyValue('transform'), window.getComputedStyle(dotThree.current).getPropertyValue('transform')];
|
|
256
|
-
dotOne.current.setAttribute('transform', transforms[0]);
|
|
257
|
-
dotTwo.current.setAttribute('transform', transforms[1]);
|
|
258
|
-
dotThree.current.setAttribute('transform', transforms[2]);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
if (!delayComplete && delayMS !== 0) {
|
|
262
|
-
return React.createElement(StyledLoadingPlaceholder, {
|
|
263
|
-
fontSize: size
|
|
264
|
-
}, "\xA0");
|
|
265
|
-
}
|
|
266
|
-
return React.createElement(StyledSVG, _extends({
|
|
267
|
-
ref: ref,
|
|
268
|
-
fontSize: size,
|
|
269
|
-
color: color,
|
|
270
|
-
width: "80",
|
|
271
|
-
height: "72",
|
|
272
|
-
dataGardenId: COMPONENT_ID$2
|
|
273
|
-
}, other), React.createElement("g", {
|
|
274
|
-
fill: "currentColor"
|
|
275
|
-
}, React.createElement(StyledDotsCircleOne, {
|
|
276
|
-
duration: duration,
|
|
277
|
-
ref: dotOne
|
|
278
|
-
}), React.createElement(StyledDotsCircleTwo, {
|
|
279
|
-
duration: duration,
|
|
280
|
-
ref: dotTwo
|
|
281
|
-
}), React.createElement(StyledDotsCircleThree, {
|
|
282
|
-
duration: duration,
|
|
283
|
-
ref: dotThree
|
|
284
|
-
})));
|
|
285
|
-
});
|
|
286
|
-
Dots.displayName = 'Dots';
|
|
287
|
-
Dots.propTypes = {
|
|
288
|
-
size: PropTypes.any,
|
|
289
|
-
duration: PropTypes.number,
|
|
290
|
-
color: PropTypes.string,
|
|
291
|
-
delayMS: PropTypes.number
|
|
292
|
-
};
|
|
293
|
-
Dots.defaultProps = {
|
|
294
|
-
size: 'inherit',
|
|
295
|
-
color: 'inherit',
|
|
296
|
-
duration: 1250,
|
|
297
|
-
delayMS: 750
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const SIZE = ['small', 'medium', 'large'];
|
|
301
|
-
|
|
302
|
-
const COMPONENT_ID$1 = 'loaders.progress';
|
|
303
|
-
const Progress = React.forwardRef((_ref, ref) => {
|
|
304
|
-
let {
|
|
305
|
-
value,
|
|
306
|
-
size,
|
|
307
|
-
'aria-label': label,
|
|
308
|
-
...other
|
|
309
|
-
} = _ref;
|
|
310
|
-
const percentage = Math.max(0, Math.min(100, value));
|
|
311
|
-
const ariaLabel = useText(Progress, {
|
|
312
|
-
'aria-label': label
|
|
313
|
-
}, 'aria-label', 'Progress');
|
|
314
|
-
return (
|
|
315
|
-
React.createElement(StyledProgressBackground, _extends({
|
|
316
|
-
"data-garden-id": COMPONENT_ID$1,
|
|
317
|
-
"data-garden-version": '9.0.0-next.6',
|
|
318
|
-
"aria-valuemax": 100,
|
|
319
|
-
"aria-valuemin": 0,
|
|
320
|
-
"aria-valuenow": percentage,
|
|
321
|
-
role: "progressbar",
|
|
322
|
-
size: size,
|
|
323
|
-
ref: ref,
|
|
324
|
-
"aria-label": ariaLabel
|
|
325
|
-
}, other), React.createElement(StyledProgressIndicator, {
|
|
326
|
-
value: percentage,
|
|
327
|
-
size: size
|
|
328
|
-
}))
|
|
329
|
-
);
|
|
330
|
-
});
|
|
331
|
-
Progress.displayName = 'Progress';
|
|
332
|
-
Progress.propTypes = {
|
|
333
|
-
color: PropTypes.string,
|
|
334
|
-
value: PropTypes.number.isRequired,
|
|
335
|
-
size: PropTypes.oneOf(SIZE)
|
|
336
|
-
};
|
|
337
|
-
Progress.defaultProps = {
|
|
338
|
-
value: 0,
|
|
339
|
-
size: 'medium'
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const Skeleton = forwardRef((_ref, ref) => {
|
|
343
|
-
let {
|
|
344
|
-
width,
|
|
345
|
-
height,
|
|
346
|
-
isLight,
|
|
347
|
-
...other
|
|
348
|
-
} = _ref;
|
|
349
|
-
return React.createElement(StyledSkeleton, _extends({
|
|
350
|
-
ref: ref,
|
|
351
|
-
isLight: isLight,
|
|
352
|
-
customWidth: width,
|
|
353
|
-
customHeight: height
|
|
354
|
-
}, other), "\xA0");
|
|
355
|
-
});
|
|
356
|
-
Skeleton.displayName = 'Skeleton';
|
|
357
|
-
Skeleton.propTypes = {
|
|
358
|
-
width: PropTypes.string,
|
|
359
|
-
height: PropTypes.string,
|
|
360
|
-
isLight: PropTypes.bool
|
|
361
|
-
};
|
|
362
|
-
Skeleton.defaultProps = {
|
|
363
|
-
width: '100%',
|
|
364
|
-
height: '100%'
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
const STROKE_WIDTH_FRAMES = {
|
|
368
|
-
0: 6,
|
|
369
|
-
14: 5,
|
|
370
|
-
26: 4,
|
|
371
|
-
36: 3,
|
|
372
|
-
46: 2,
|
|
373
|
-
58: 3,
|
|
374
|
-
70: 4,
|
|
375
|
-
80: 5,
|
|
376
|
-
91: 6
|
|
377
|
-
};
|
|
378
|
-
const ROTATION_FRAMES = {
|
|
379
|
-
0: -90,
|
|
380
|
-
8: -81,
|
|
381
|
-
36: -30,
|
|
382
|
-
41: -18,
|
|
383
|
-
44: -8,
|
|
384
|
-
48: 0,
|
|
385
|
-
55: 22,
|
|
386
|
-
63: 53,
|
|
387
|
-
64: 62,
|
|
388
|
-
66: 67,
|
|
389
|
-
68: 78,
|
|
390
|
-
69: 90,
|
|
391
|
-
71: 99,
|
|
392
|
-
73: 112,
|
|
393
|
-
74: 129,
|
|
394
|
-
76: 138,
|
|
395
|
-
78: 159,
|
|
396
|
-
79: 180,
|
|
397
|
-
81: 190,
|
|
398
|
-
83: 207,
|
|
399
|
-
84: 221,
|
|
400
|
-
86: 226,
|
|
401
|
-
88: 235,
|
|
402
|
-
90: 243,
|
|
403
|
-
99: 270
|
|
404
|
-
};
|
|
405
|
-
const DASHARRAY_FRAMES = {
|
|
406
|
-
0: 0,
|
|
407
|
-
13: 2,
|
|
408
|
-
26: 13,
|
|
409
|
-
53: 86,
|
|
410
|
-
58: 90,
|
|
411
|
-
63: 89,
|
|
412
|
-
64: 88,
|
|
413
|
-
66: 86,
|
|
414
|
-
68: 83,
|
|
415
|
-
69: 81,
|
|
416
|
-
71: 76,
|
|
417
|
-
73: 70,
|
|
418
|
-
74: 62,
|
|
419
|
-
76: 58,
|
|
420
|
-
78: 47,
|
|
421
|
-
79: 37,
|
|
422
|
-
81: 31,
|
|
423
|
-
83: 23,
|
|
424
|
-
84: 16,
|
|
425
|
-
88: 10,
|
|
426
|
-
89: 7,
|
|
427
|
-
98: 1,
|
|
428
|
-
99: 0
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const COMPONENT_ID = 'loaders.spinner';
|
|
432
|
-
const TOTAL_FRAMES = 100;
|
|
433
|
-
const computeFrames = (frames, duration) => {
|
|
434
|
-
return Object.entries(frames).reduce((acc, item, index, arr) => {
|
|
435
|
-
const [frame, value] = item;
|
|
436
|
-
const [nextFrame, nextValue] = arr[index + 1] || [TOTAL_FRAMES, arr[0][1]];
|
|
437
|
-
const diff = parseInt(nextFrame, 10) - parseInt(frame, 10);
|
|
438
|
-
const frameHz = 1000 / 60;
|
|
439
|
-
let subDuration = duration / (TOTAL_FRAMES - 1) * diff;
|
|
440
|
-
let lastValue = value;
|
|
441
|
-
acc[frame] = value;
|
|
442
|
-
for (let idx = 0; idx < diff; idx++) {
|
|
443
|
-
lastValue = lastValue + (nextValue - lastValue) * (frameHz / subDuration);
|
|
444
|
-
subDuration = duration / (TOTAL_FRAMES - 1) * (diff - idx);
|
|
445
|
-
acc[parseInt(frame, 10) + idx + 1] = lastValue;
|
|
446
|
-
}
|
|
447
|
-
acc[nextFrame] = nextValue;
|
|
448
|
-
return acc;
|
|
449
|
-
}, {});
|
|
450
|
-
};
|
|
451
|
-
const Spinner = forwardRef((_ref, ref) => {
|
|
452
|
-
let {
|
|
453
|
-
size,
|
|
454
|
-
duration,
|
|
455
|
-
color,
|
|
456
|
-
delayMS,
|
|
457
|
-
...other
|
|
458
|
-
} = _ref;
|
|
459
|
-
const strokeWidthValues = computeFrames(STROKE_WIDTH_FRAMES, duration);
|
|
460
|
-
const rotationValues = computeFrames(ROTATION_FRAMES, duration);
|
|
461
|
-
const dasharrayValues = computeFrames(DASHARRAY_FRAMES, duration);
|
|
462
|
-
const {
|
|
463
|
-
elapsed,
|
|
464
|
-
delayComplete
|
|
465
|
-
} = useSchedule({
|
|
466
|
-
duration,
|
|
467
|
-
delayMS
|
|
468
|
-
});
|
|
469
|
-
const frame = (elapsed * 100).toFixed(0);
|
|
470
|
-
const strokeWidthValue = strokeWidthValues[frame];
|
|
471
|
-
const rotationValue = rotationValues[frame];
|
|
472
|
-
const dasharrayValue = dasharrayValues[frame];
|
|
473
|
-
const WIDTH = 80;
|
|
474
|
-
const HEIGHT = 80;
|
|
475
|
-
if (!delayComplete && delayMS !== 0) {
|
|
476
|
-
return React.createElement(StyledLoadingPlaceholder, {
|
|
477
|
-
width: "1em",
|
|
478
|
-
height: "1em",
|
|
479
|
-
fontSize: size
|
|
480
|
-
}, "\xA0");
|
|
481
|
-
}
|
|
482
|
-
return React.createElement(StyledSVG, _extends({
|
|
483
|
-
ref: ref,
|
|
484
|
-
fontSize: size,
|
|
485
|
-
color: color,
|
|
486
|
-
width: WIDTH,
|
|
487
|
-
height: HEIGHT,
|
|
488
|
-
dataGardenId: COMPONENT_ID,
|
|
489
|
-
containerHeight: "1em",
|
|
490
|
-
containerWidth: "1em"
|
|
491
|
-
}, other), React.createElement(StyledSpinnerCircle, {
|
|
492
|
-
dasharrayValue: dasharrayValue,
|
|
493
|
-
strokeWidthValue: strokeWidthValue,
|
|
494
|
-
transform: `rotate(${rotationValue}, ${WIDTH / 2}, ${HEIGHT / 2})`
|
|
495
|
-
}));
|
|
496
|
-
});
|
|
497
|
-
Spinner.displayName = 'Spinner';
|
|
498
|
-
Spinner.propTypes = {
|
|
499
|
-
size: PropTypes.any,
|
|
500
|
-
duration: PropTypes.number,
|
|
501
|
-
color: PropTypes.string,
|
|
502
|
-
delayMS: PropTypes.number
|
|
503
|
-
};
|
|
504
|
-
Spinner.defaultProps = {
|
|
505
|
-
size: 'inherit',
|
|
506
|
-
duration: 1250,
|
|
507
|
-
color: 'inherit',
|
|
508
|
-
delayMS: 750
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
const Inline = forwardRef((_ref, ref) => {
|
|
512
|
-
let {
|
|
513
|
-
size,
|
|
514
|
-
color,
|
|
515
|
-
...other
|
|
516
|
-
} = _ref;
|
|
517
|
-
const ariaLabel = useText(Inline, other, 'aria-label', 'loading');
|
|
518
|
-
return (
|
|
519
|
-
React.createElement(StyledInline, _extends({
|
|
520
|
-
ref: ref,
|
|
521
|
-
size: size,
|
|
522
|
-
color: color,
|
|
523
|
-
"aria-label": ariaLabel,
|
|
524
|
-
role: "img"
|
|
525
|
-
}, other), React.createElement(StyledCircle, {
|
|
526
|
-
cx: "14"
|
|
527
|
-
}), React.createElement(StyledCircle, {
|
|
528
|
-
cx: "8"
|
|
529
|
-
}), React.createElement(StyledCircle, {
|
|
530
|
-
cx: "2"
|
|
531
|
-
}))
|
|
532
|
-
);
|
|
533
|
-
});
|
|
534
|
-
Inline.displayName = 'Inline';
|
|
535
|
-
Inline.propTypes = {
|
|
536
|
-
size: PropTypes.number,
|
|
537
|
-
color: PropTypes.string
|
|
538
|
-
};
|
|
539
|
-
Inline.defaultProps = {
|
|
540
|
-
size: 16,
|
|
541
|
-
color: 'inherit'
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
export { Dots, Inline, Progress, Skeleton, Spinner };
|