@react-spectrum/progress 3.0.0-nightly-641446f65-240905
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/README.md +3 -0
- package/dist/ProgressBar.main.js +54 -0
- package/dist/ProgressBar.main.js.map +1 -0
- package/dist/ProgressBar.mjs +49 -0
- package/dist/ProgressBar.module.js +49 -0
- package/dist/ProgressBar.module.js.map +1 -0
- package/dist/ProgressBarBase.main.js +74 -0
- package/dist/ProgressBarBase.main.js.map +1 -0
- package/dist/ProgressBarBase.mjs +69 -0
- package/dist/ProgressBarBase.module.js +69 -0
- package/dist/ProgressBarBase.module.js.map +1 -0
- package/dist/ProgressCircle.main.js +98 -0
- package/dist/ProgressCircle.main.js.map +1 -0
- package/dist/ProgressCircle.mjs +93 -0
- package/dist/ProgressCircle.module.js +93 -0
- package/dist/ProgressCircle.module.js.map +1 -0
- package/dist/barloader_vars_css.main.js +73 -0
- package/dist/barloader_vars_css.main.js.map +1 -0
- package/dist/barloader_vars_css.mjs +75 -0
- package/dist/barloader_vars_css.module.js +75 -0
- package/dist/barloader_vars_css.module.js.map +1 -0
- package/dist/circleloader_vars_css.main.js +80 -0
- package/dist/circleloader_vars_css.main.js.map +1 -0
- package/dist/circleloader_vars_css.mjs +82 -0
- package/dist/circleloader_vars_css.module.js +82 -0
- package/dist/circleloader_vars_css.module.js.map +1 -0
- package/dist/import.mjs +22 -0
- package/dist/main.js +29 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +22 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vars.596fab4e.css +288 -0
- package/dist/vars.596fab4e.css.map +1 -0
- package/dist/vars.c3d4124d.css +719 -0
- package/dist/vars.c3d4124d.css.map +1 -0
- package/package.json +57 -0
- package/src/ProgressBar.tsx +52 -0
- package/src/ProgressBarBase.tsx +102 -0
- package/src/ProgressCircle.tsx +109 -0
- package/src/index.ts +18 -0
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-spectrum/progress",
|
|
3
|
+
"version": "3.0.0-nightly-641446f65-240905",
|
|
4
|
+
"description": "Spectrum UI components in React",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/types.d.ts",
|
|
14
|
+
"source": "src/index.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"*.css"
|
|
21
|
+
],
|
|
22
|
+
"targets": {
|
|
23
|
+
"main": {
|
|
24
|
+
"includeNodeModules": [
|
|
25
|
+
"@adobe/spectrum-css-temp"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"module": {
|
|
29
|
+
"includeNodeModules": [
|
|
30
|
+
"@adobe/spectrum-css-temp"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@react-aria/progress": "^3.0.0-nightly-641446f65-240905",
|
|
40
|
+
"@react-aria/utils": "^3.0.0-nightly-641446f65-240905",
|
|
41
|
+
"@react-spectrum/utils": "^3.0.0-nightly-641446f65-240905",
|
|
42
|
+
"@react-types/progress": "^3.0.0-nightly-641446f65-240905",
|
|
43
|
+
"@react-types/shared": "^3.0.0-nightly-641446f65-240905",
|
|
44
|
+
"@swc/helpers": "^0.5.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@react-spectrum/provider": "^3.0.0-nightly-641446f65-240905",
|
|
51
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"stableVersion": "3.7.9"
|
|
57
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {classNames} from '@react-spectrum/utils';
|
|
14
|
+
import {DOMRef} from '@react-types/shared';
|
|
15
|
+
import {ProgressBarBase} from './ProgressBarBase';
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import {SpectrumProgressBarProps} from '@react-types/progress';
|
|
18
|
+
import styles from '@adobe/spectrum-css-temp/components/barloader/vars.css';
|
|
19
|
+
import {useProgressBar} from '@react-aria/progress';
|
|
20
|
+
|
|
21
|
+
function ProgressBar(props: SpectrumProgressBarProps, ref: DOMRef<HTMLDivElement>) {
|
|
22
|
+
let {staticColor, variant, ...otherProps} = props;
|
|
23
|
+
const {
|
|
24
|
+
progressBarProps,
|
|
25
|
+
labelProps
|
|
26
|
+
} = useProgressBar(props);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ProgressBarBase
|
|
30
|
+
{...otherProps}
|
|
31
|
+
ref={ref}
|
|
32
|
+
barProps={progressBarProps}
|
|
33
|
+
labelProps={labelProps}
|
|
34
|
+
barClassName={
|
|
35
|
+
classNames(
|
|
36
|
+
styles,
|
|
37
|
+
{
|
|
38
|
+
'spectrum-BarLoader--overBackground': variant === 'overBackground',
|
|
39
|
+
'spectrum-BarLoader--staticWhite': staticColor === 'white',
|
|
40
|
+
'spectrum-BarLoader--staticBlack': staticColor === 'black'
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
} />
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ProgressBars show the progression of a system operation: downloading, uploading, processing, etc., in a visual way.
|
|
49
|
+
* They can represent either determinate or indeterminate progress.
|
|
50
|
+
*/
|
|
51
|
+
let _ProgressBar = React.forwardRef(ProgressBar);
|
|
52
|
+
export {_ProgressBar as ProgressBar};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {clamp} from '@react-aria/utils';
|
|
14
|
+
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
|
|
15
|
+
import {DOMRef} from '@react-types/shared';
|
|
16
|
+
import {ProgressBarProps, SpectrumProgressBarBaseProps} from '@react-types/progress';
|
|
17
|
+
import React, {CSSProperties, HTMLAttributes} from 'react';
|
|
18
|
+
import styles from '@adobe/spectrum-css-temp/components/barloader/vars.css';
|
|
19
|
+
|
|
20
|
+
interface ProgressBarBaseProps extends SpectrumProgressBarBaseProps, ProgressBarProps {
|
|
21
|
+
barClassName?: string,
|
|
22
|
+
barProps?: HTMLAttributes<HTMLDivElement>,
|
|
23
|
+
labelProps?: HTMLAttributes<HTMLLabelElement>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Base ProgressBar component shared with Meter.
|
|
27
|
+
function ProgressBarBase(props: ProgressBarBaseProps, ref: DOMRef<HTMLDivElement>) {
|
|
28
|
+
let {
|
|
29
|
+
value = 0,
|
|
30
|
+
minValue = 0,
|
|
31
|
+
maxValue = 100,
|
|
32
|
+
size = 'L',
|
|
33
|
+
label,
|
|
34
|
+
barClassName,
|
|
35
|
+
showValueLabel = !!label,
|
|
36
|
+
labelPosition = 'top',
|
|
37
|
+
isIndeterminate = false,
|
|
38
|
+
barProps,
|
|
39
|
+
labelProps,
|
|
40
|
+
'aria-label': ariaLabel,
|
|
41
|
+
'aria-labelledby': ariaLabelledby,
|
|
42
|
+
...otherProps
|
|
43
|
+
} = props;
|
|
44
|
+
let domRef = useDOMRef(ref);
|
|
45
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
46
|
+
|
|
47
|
+
value = clamp(value, minValue, maxValue);
|
|
48
|
+
|
|
49
|
+
let barStyle: CSSProperties = {};
|
|
50
|
+
if (!isIndeterminate) {
|
|
51
|
+
let percentage = (value - minValue) / (maxValue - minValue);
|
|
52
|
+
barStyle.width = `${Math.round(percentage * 100)}%`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Ideally this should be in useProgressBar, but children
|
|
56
|
+
// are not supported in ProgressCircle which shares that hook...
|
|
57
|
+
if (!label && !ariaLabel && !ariaLabelledby) {
|
|
58
|
+
console.warn('If you do not provide a visible label via children, you must specify an aria-label or aria-labelledby attribute for accessibility');
|
|
59
|
+
}
|
|
60
|
+
// use inline style for fit-content because cssnano is too smart for us and will strip out the -moz prefix in css files
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
{...barProps}
|
|
64
|
+
ref={domRef}
|
|
65
|
+
className={
|
|
66
|
+
classNames(
|
|
67
|
+
styles,
|
|
68
|
+
'spectrum-BarLoader',
|
|
69
|
+
{
|
|
70
|
+
'spectrum-BarLoader--small': size === 'S',
|
|
71
|
+
'spectrum-BarLoader--large': size === 'L',
|
|
72
|
+
'spectrum-BarLoader--indeterminate': isIndeterminate,
|
|
73
|
+
'spectrum-BarLoader--sideLabel': labelPosition === 'side'
|
|
74
|
+
},
|
|
75
|
+
barClassName,
|
|
76
|
+
styleProps.className
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
style={{minWidth: '-moz-fit-content', ...styleProps.style}}>
|
|
80
|
+
{label &&
|
|
81
|
+
<span
|
|
82
|
+
{...labelProps}
|
|
83
|
+
className={classNames(styles, 'spectrum-BarLoader-label')}>
|
|
84
|
+
{label}
|
|
85
|
+
</span>
|
|
86
|
+
}
|
|
87
|
+
{showValueLabel && barProps &&
|
|
88
|
+
<div className={classNames(styles, 'spectrum-BarLoader-percentage')}>
|
|
89
|
+
{barProps['aria-valuetext']}
|
|
90
|
+
</div>
|
|
91
|
+
}
|
|
92
|
+
<div className={classNames(styles, 'spectrum-BarLoader-track')}>
|
|
93
|
+
<div
|
|
94
|
+
className={classNames(styles, 'spectrum-BarLoader-fill')}
|
|
95
|
+
style={barStyle} />
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let _ProgressBarBase = React.forwardRef(ProgressBarBase);
|
|
102
|
+
export {_ProgressBarBase as ProgressBarBase};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {clamp} from '@react-aria/utils';
|
|
14
|
+
import {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';
|
|
15
|
+
import {DOMRef} from '@react-types/shared';
|
|
16
|
+
import React, {CSSProperties} from 'react';
|
|
17
|
+
import {SpectrumProgressCircleProps} from '@react-types/progress';
|
|
18
|
+
import styles from '@adobe/spectrum-css-temp/components/circleloader/vars.css';
|
|
19
|
+
import {useProgressBar} from '@react-aria/progress';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function ProgressCircle(props: SpectrumProgressCircleProps, ref: DOMRef<HTMLDivElement>) {
|
|
23
|
+
let {
|
|
24
|
+
value = 0,
|
|
25
|
+
minValue = 0,
|
|
26
|
+
maxValue = 100,
|
|
27
|
+
size = 'M',
|
|
28
|
+
staticColor,
|
|
29
|
+
variant,
|
|
30
|
+
isIndeterminate = false,
|
|
31
|
+
'aria-label': ariaLabel,
|
|
32
|
+
'aria-labelledby': ariaLabelledby,
|
|
33
|
+
...otherProps
|
|
34
|
+
} = props;
|
|
35
|
+
let domRef = useDOMRef(ref);
|
|
36
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
37
|
+
|
|
38
|
+
value = clamp(value, minValue, maxValue);
|
|
39
|
+
let {progressBarProps} = useProgressBar({...props, value});
|
|
40
|
+
|
|
41
|
+
let subMask1Style: CSSProperties = {};
|
|
42
|
+
let subMask2Style: CSSProperties = {};
|
|
43
|
+
if (!isIndeterminate) {
|
|
44
|
+
let percentage = (value - minValue) / (maxValue - minValue) * 100;
|
|
45
|
+
let angle;
|
|
46
|
+
if (percentage > 0 && percentage <= 50) {
|
|
47
|
+
angle = -180 + (percentage / 50 * 180);
|
|
48
|
+
subMask1Style.transform = `rotate(${angle}deg)`;
|
|
49
|
+
subMask2Style.transform = 'rotate(-180deg)';
|
|
50
|
+
} else if (percentage > 50) {
|
|
51
|
+
angle = -180 + (percentage - 50) / 50 * 180;
|
|
52
|
+
subMask1Style.transform = 'rotate(0deg)';
|
|
53
|
+
subMask2Style.transform = `rotate(${angle}deg)`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!ariaLabel && !ariaLabelledby) {
|
|
58
|
+
console.warn('ProgressCircle requires an aria-label or aria-labelledby attribute for accessibility');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
{...styleProps}
|
|
64
|
+
{...progressBarProps}
|
|
65
|
+
ref={domRef}
|
|
66
|
+
className={
|
|
67
|
+
classNames(
|
|
68
|
+
styles,
|
|
69
|
+
'spectrum-CircleLoader',
|
|
70
|
+
{
|
|
71
|
+
'spectrum-CircleLoader--indeterminate': isIndeterminate,
|
|
72
|
+
'spectrum-CircleLoader--small': size === 'S',
|
|
73
|
+
'spectrum-CircleLoader--large': size === 'L',
|
|
74
|
+
'spectrum-CircleLoader--overBackground': variant === 'overBackground',
|
|
75
|
+
'spectrum-CircleLoader--staticWhite': staticColor === 'white',
|
|
76
|
+
'spectrum-CircleLoader--staticBlack': staticColor === 'black'
|
|
77
|
+
},
|
|
78
|
+
styleProps.className
|
|
79
|
+
)
|
|
80
|
+
}>
|
|
81
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-track')} />
|
|
82
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-fills')} >
|
|
83
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-fillMask1')} >
|
|
84
|
+
<div
|
|
85
|
+
className={classNames(styles, 'spectrum-CircleLoader-fillSubMask1')}
|
|
86
|
+
data-testid="fillSubMask1"
|
|
87
|
+
style={subMask1Style}>
|
|
88
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-fill')} />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-fillMask2')} >
|
|
92
|
+
<div
|
|
93
|
+
className={classNames(styles, 'spectrum-CircleLoader-fillSubMask2')}
|
|
94
|
+
data-testid="fillSubMask2"
|
|
95
|
+
style={subMask2Style} >
|
|
96
|
+
<div className={classNames(styles, 'spectrum-CircleLoader-fill')} />
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* ProgressCircles show the progression of a system operation such as downloading, uploading, or processing, in a visual way.
|
|
106
|
+
* They can represent determinate or indeterminate progress.
|
|
107
|
+
*/
|
|
108
|
+
let _ProgressCircle = React.forwardRef(ProgressCircle);
|
|
109
|
+
export {_ProgressCircle as ProgressCircle};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/// <reference types="css-module-types" />
|
|
14
|
+
|
|
15
|
+
export {ProgressBar} from './ProgressBar';
|
|
16
|
+
export {ProgressCircle} from './ProgressCircle';
|
|
17
|
+
export {ProgressBarBase} from './ProgressBarBase';
|
|
18
|
+
export type {SpectrumProgressBarProps, SpectrumProgressCircleProps} from '@react-types/progress';
|