@react-aria/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 ADDED
@@ -0,0 +1,3 @@
1
+ # @react-aria/progress
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,17 @@
1
+ import {useProgressBar as $204d9ebcedfb8806$export$ed5abd763a836edc} from "./useProgressBar.mjs";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$204d9ebcedfb8806$export$ed5abd763a836edc as useProgressBar};
17
+ //# sourceMappingURL=module.js.map
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ var $c6bb999a3b4eb4f3$exports = require("./useProgressBar.main.js");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useProgressBar", () => $c6bb999a3b4eb4f3$exports.useProgressBar);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/progress/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useProgressBar} from './useProgressBar';\nexport type {AriaProgressBarProps} from '@react-types/progress';\nexport type {ProgressBarAria} from './useProgressBar';\n"],"names":[],"version":3,"file":"index.js.map"}
package/dist/module.js ADDED
@@ -0,0 +1,17 @@
1
+ import {useProgressBar as $204d9ebcedfb8806$export$ed5abd763a836edc} from "./useProgressBar.module.js";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$204d9ebcedfb8806$export$ed5abd763a836edc as useProgressBar};
17
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/progress/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useProgressBar} from './useProgressBar';\nexport type {AriaProgressBarProps} from '@react-types/progress';\nexport type {ProgressBarAria} from './useProgressBar';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,17 @@
1
+ import { AriaProgressBarProps } from "@react-types/progress";
2
+ import { DOMAttributes } from "@react-types/shared";
3
+ export interface ProgressBarAria {
4
+ /** Props for the progress bar container element. */
5
+ progressBarProps: DOMAttributes;
6
+ /** Props for the progress bar's visual label element (if any). */
7
+ labelProps: DOMAttributes;
8
+ }
9
+ /**
10
+ * Provides the accessibility implementation for a progress bar component.
11
+ * Progress bars show either determinate or indeterminate progress of an operation
12
+ * over time.
13
+ */
14
+ export function useProgressBar(props: AriaProgressBarProps): ProgressBarAria;
15
+ export type { AriaProgressBarProps } from '@react-types/progress';
16
+
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAkBA;IACE,oDAAoD;IACpD,gBAAgB,EAAE,aAAa,CAAC;IAChC,kEAAkE;IAClE,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;;GAIG;AACH,+BAA+B,KAAK,EAAE,oBAAoB,GAAG,eAAe,CAwC3E;AC1DD,YAAY,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-aria/progress/src/packages/@react-aria/progress/src/useProgressBar.ts","packages/@react-aria/progress/src/packages/@react-aria/progress/src/index.ts","packages/@react-aria/progress/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useProgressBar} from './useProgressBar';\nexport type {AriaProgressBarProps} from '@react-types/progress';\nexport type {ProgressBarAria} from './useProgressBar';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,58 @@
1
+ var $dNefm$reactariautils = require("@react-aria/utils");
2
+ var $dNefm$reactarialabel = require("@react-aria/label");
3
+ var $dNefm$reactariai18n = require("@react-aria/i18n");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useProgressBar", () => $c6bb999a3b4eb4f3$export$ed5abd763a836edc);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $c6bb999a3b4eb4f3$export$ed5abd763a836edc(props) {
25
+ let { value: value = 0, minValue: minValue = 0, maxValue: maxValue = 100, valueLabel: valueLabel, isIndeterminate: isIndeterminate, formatOptions: formatOptions = {
26
+ style: 'percent'
27
+ } } = props;
28
+ let domProps = (0, $dNefm$reactariautils.filterDOMProps)(props, {
29
+ labelable: true
30
+ });
31
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $dNefm$reactarialabel.useLabel)({
32
+ ...props,
33
+ // Progress bar is not an HTML input element so it
34
+ // shouldn't be labeled by a <label> element.
35
+ labelElementType: 'span'
36
+ });
37
+ value = (0, $dNefm$reactariautils.clamp)(value, minValue, maxValue);
38
+ let percentage = (value - minValue) / (maxValue - minValue);
39
+ let formatter = (0, $dNefm$reactariai18n.useNumberFormatter)(formatOptions);
40
+ if (!isIndeterminate && !valueLabel) {
41
+ let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
42
+ valueLabel = formatter.format(valueToFormat);
43
+ }
44
+ return {
45
+ progressBarProps: (0, $dNefm$reactariautils.mergeProps)(domProps, {
46
+ ...fieldProps,
47
+ 'aria-valuenow': isIndeterminate ? undefined : value,
48
+ 'aria-valuemin': minValue,
49
+ 'aria-valuemax': maxValue,
50
+ 'aria-valuetext': isIndeterminate ? undefined : valueLabel,
51
+ role: 'progressbar'
52
+ }),
53
+ labelProps: labelProps
54
+ };
55
+ }
56
+
57
+
58
+ //# sourceMappingURL=useProgressBar.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAoBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,SACF,QAAQ,aACR,WAAW,aACX,WAAW,iBACX,UAAU,mBACV,eAAe,iBACf,gBAAgB;QACd,OAAO;IACT,GACD,GAAG;IAEJ,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QACtC,GAAG,KAAK;QACR,kDAAkD;QAClD,6CAA6C;QAC7C,kBAAkB;IACpB;IAEA,QAAQ,CAAA,GAAA,2BAAI,EAAE,OAAO,UAAU;IAC/B,IAAI,aAAa,AAAC,CAAA,QAAQ,QAAO,IAAM,CAAA,WAAW,QAAO;IACzD,IAAI,YAAY,CAAA,GAAA,uCAAiB,EAAE;IAEnC,IAAI,CAAC,mBAAmB,CAAC,YAAY;QACnC,IAAI,gBAAgB,cAAc,KAAK,KAAK,YAAY,aAAa;QACrE,aAAa,UAAU,MAAM,CAAC;IAChC;IAEA,OAAO;QACL,kBAAkB,CAAA,GAAA,gCAAS,EAAE,UAAU;YACrC,GAAG,UAAU;YACb,iBAAiB,kBAAkB,YAAY;YAC/C,iBAAiB;YACjB,iBAAiB;YACjB,kBAAkB,kBAAkB,YAAY;YAChD,MAAM;QACR;oBACA;IACF;AACF","sources":["packages/@react-aria/progress/src/useProgressBar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps} from '@react-types/progress';\nimport {clamp, filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {useLabel} from '@react-aria/label';\nimport {useNumberFormatter} from '@react-aria/i18n';\n\nexport interface ProgressBarAria {\n /** Props for the progress bar container element. */\n progressBarProps: DOMAttributes,\n /** Props for the progress bar's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a progress bar component.\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport function useProgressBar(props: AriaProgressBarProps): ProgressBarAria {\n let {\n value = 0,\n minValue = 0,\n maxValue = 100,\n valueLabel,\n isIndeterminate,\n formatOptions = {\n style: 'percent'\n }\n } = props;\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {labelProps, fieldProps} = useLabel({\n ...props,\n // Progress bar is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n value = clamp(value, minValue, maxValue);\n let percentage = (value - minValue) / (maxValue - minValue);\n let formatter = useNumberFormatter(formatOptions);\n\n if (!isIndeterminate && !valueLabel) {\n let valueToFormat = formatOptions.style === 'percent' ? percentage : value;\n valueLabel = formatter.format(valueToFormat);\n }\n\n return {\n progressBarProps: mergeProps(domProps, {\n ...fieldProps,\n 'aria-valuenow': isIndeterminate ? undefined : value,\n 'aria-valuemin': minValue,\n 'aria-valuemax': maxValue,\n 'aria-valuetext': isIndeterminate ? undefined : valueLabel as string,\n role: 'progressbar'\n }),\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"useProgressBar.main.js.map"}
@@ -0,0 +1,53 @@
1
+ import {filterDOMProps as $2xLm1$filterDOMProps, clamp as $2xLm1$clamp, mergeProps as $2xLm1$mergeProps} from "@react-aria/utils";
2
+ import {useLabel as $2xLm1$useLabel} from "@react-aria/label";
3
+ import {useNumberFormatter as $2xLm1$useNumberFormatter} from "@react-aria/i18n";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $204d9ebcedfb8806$export$ed5abd763a836edc(props) {
19
+ let { value: value = 0, minValue: minValue = 0, maxValue: maxValue = 100, valueLabel: valueLabel, isIndeterminate: isIndeterminate, formatOptions: formatOptions = {
20
+ style: 'percent'
21
+ } } = props;
22
+ let domProps = (0, $2xLm1$filterDOMProps)(props, {
23
+ labelable: true
24
+ });
25
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $2xLm1$useLabel)({
26
+ ...props,
27
+ // Progress bar is not an HTML input element so it
28
+ // shouldn't be labeled by a <label> element.
29
+ labelElementType: 'span'
30
+ });
31
+ value = (0, $2xLm1$clamp)(value, minValue, maxValue);
32
+ let percentage = (value - minValue) / (maxValue - minValue);
33
+ let formatter = (0, $2xLm1$useNumberFormatter)(formatOptions);
34
+ if (!isIndeterminate && !valueLabel) {
35
+ let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
36
+ valueLabel = formatter.format(valueToFormat);
37
+ }
38
+ return {
39
+ progressBarProps: (0, $2xLm1$mergeProps)(domProps, {
40
+ ...fieldProps,
41
+ 'aria-valuenow': isIndeterminate ? undefined : value,
42
+ 'aria-valuemin': minValue,
43
+ 'aria-valuemax': maxValue,
44
+ 'aria-valuetext': isIndeterminate ? undefined : valueLabel,
45
+ role: 'progressbar'
46
+ }),
47
+ labelProps: labelProps
48
+ };
49
+ }
50
+
51
+
52
+ export {$204d9ebcedfb8806$export$ed5abd763a836edc as useProgressBar};
53
+ //# sourceMappingURL=useProgressBar.module.js.map
@@ -0,0 +1,53 @@
1
+ import {filterDOMProps as $2xLm1$filterDOMProps, clamp as $2xLm1$clamp, mergeProps as $2xLm1$mergeProps} from "@react-aria/utils";
2
+ import {useLabel as $2xLm1$useLabel} from "@react-aria/label";
3
+ import {useNumberFormatter as $2xLm1$useNumberFormatter} from "@react-aria/i18n";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $204d9ebcedfb8806$export$ed5abd763a836edc(props) {
19
+ let { value: value = 0, minValue: minValue = 0, maxValue: maxValue = 100, valueLabel: valueLabel, isIndeterminate: isIndeterminate, formatOptions: formatOptions = {
20
+ style: 'percent'
21
+ } } = props;
22
+ let domProps = (0, $2xLm1$filterDOMProps)(props, {
23
+ labelable: true
24
+ });
25
+ let { labelProps: labelProps, fieldProps: fieldProps } = (0, $2xLm1$useLabel)({
26
+ ...props,
27
+ // Progress bar is not an HTML input element so it
28
+ // shouldn't be labeled by a <label> element.
29
+ labelElementType: 'span'
30
+ });
31
+ value = (0, $2xLm1$clamp)(value, minValue, maxValue);
32
+ let percentage = (value - minValue) / (maxValue - minValue);
33
+ let formatter = (0, $2xLm1$useNumberFormatter)(formatOptions);
34
+ if (!isIndeterminate && !valueLabel) {
35
+ let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
36
+ valueLabel = formatter.format(valueToFormat);
37
+ }
38
+ return {
39
+ progressBarProps: (0, $2xLm1$mergeProps)(domProps, {
40
+ ...fieldProps,
41
+ 'aria-valuenow': isIndeterminate ? undefined : value,
42
+ 'aria-valuemin': minValue,
43
+ 'aria-valuemax': maxValue,
44
+ 'aria-valuetext': isIndeterminate ? undefined : valueLabel,
45
+ role: 'progressbar'
46
+ }),
47
+ labelProps: labelProps
48
+ };
49
+ }
50
+
51
+
52
+ export {$204d9ebcedfb8806$export$ed5abd763a836edc as useProgressBar};
53
+ //# sourceMappingURL=useProgressBar.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAoBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,SACF,QAAQ,aACR,WAAW,aACX,WAAW,iBACX,UAAU,mBACV,eAAe,iBACf,gBAAgB;QACd,OAAO;IACT,GACD,GAAG;IAEJ,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACtC,GAAG,KAAK;QACR,kDAAkD;QAClD,6CAA6C;QAC7C,kBAAkB;IACpB;IAEA,QAAQ,CAAA,GAAA,YAAI,EAAE,OAAO,UAAU;IAC/B,IAAI,aAAa,AAAC,CAAA,QAAQ,QAAO,IAAM,CAAA,WAAW,QAAO;IACzD,IAAI,YAAY,CAAA,GAAA,yBAAiB,EAAE;IAEnC,IAAI,CAAC,mBAAmB,CAAC,YAAY;QACnC,IAAI,gBAAgB,cAAc,KAAK,KAAK,YAAY,aAAa;QACrE,aAAa,UAAU,MAAM,CAAC;IAChC;IAEA,OAAO;QACL,kBAAkB,CAAA,GAAA,iBAAS,EAAE,UAAU;YACrC,GAAG,UAAU;YACb,iBAAiB,kBAAkB,YAAY;YAC/C,iBAAiB;YACjB,iBAAiB;YACjB,kBAAkB,kBAAkB,YAAY;YAChD,MAAM;QACR;oBACA;IACF;AACF","sources":["packages/@react-aria/progress/src/useProgressBar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps} from '@react-types/progress';\nimport {clamp, filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {DOMAttributes} from '@react-types/shared';\nimport {useLabel} from '@react-aria/label';\nimport {useNumberFormatter} from '@react-aria/i18n';\n\nexport interface ProgressBarAria {\n /** Props for the progress bar container element. */\n progressBarProps: DOMAttributes,\n /** Props for the progress bar's visual label element (if any). */\n labelProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a progress bar component.\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport function useProgressBar(props: AriaProgressBarProps): ProgressBarAria {\n let {\n value = 0,\n minValue = 0,\n maxValue = 100,\n valueLabel,\n isIndeterminate,\n formatOptions = {\n style: 'percent'\n }\n } = props;\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {labelProps, fieldProps} = useLabel({\n ...props,\n // Progress bar is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n\n value = clamp(value, minValue, maxValue);\n let percentage = (value - minValue) / (maxValue - minValue);\n let formatter = useNumberFormatter(formatOptions);\n\n if (!isIndeterminate && !valueLabel) {\n let valueToFormat = formatOptions.style === 'percent' ? percentage : value;\n valueLabel = formatter.format(valueToFormat);\n }\n\n return {\n progressBarProps: mergeProps(domProps, {\n ...fieldProps,\n 'aria-valuenow': isIndeterminate ? undefined : value,\n 'aria-valuemin': minValue,\n 'aria-valuemax': maxValue,\n 'aria-valuetext': isIndeterminate ? undefined : valueLabel as string,\n role: 'progressbar'\n }),\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"useProgressBar.module.js.map"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@react-aria/progress",
3
+ "version": "3.0.0-nightly-641446f65-240905",
4
+ "description": "Spectrum UI components in React",
5
+ "license": "Apache-2.0",
6
+ "main": "dist/index.js",
7
+ "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "types": "dist/types.d.ts",
14
+ "source": "src/index.ts",
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "sideEffects": false,
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/adobe/react-spectrum"
23
+ },
24
+ "dependencies": {
25
+ "@react-aria/i18n": "^3.0.0-nightly-641446f65-240905",
26
+ "@react-aria/label": "^3.0.0-nightly-641446f65-240905",
27
+ "@react-aria/utils": "^3.0.0-nightly-641446f65-240905",
28
+ "@react-types/progress": "^3.0.0-nightly-641446f65-240905",
29
+ "@react-types/shared": "^3.0.0-nightly-641446f65-240905",
30
+ "@swc/helpers": "^0.5.0"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "stableVersion": "3.4.16"
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,14 @@
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
+ export {useProgressBar} from './useProgressBar';
13
+ export type {AriaProgressBarProps} from '@react-types/progress';
14
+ export type {ProgressBarAria} from './useProgressBar';
@@ -0,0 +1,71 @@
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 {AriaProgressBarProps} from '@react-types/progress';
14
+ import {clamp, filterDOMProps, mergeProps} from '@react-aria/utils';
15
+ import {DOMAttributes} from '@react-types/shared';
16
+ import {useLabel} from '@react-aria/label';
17
+ import {useNumberFormatter} from '@react-aria/i18n';
18
+
19
+ export interface ProgressBarAria {
20
+ /** Props for the progress bar container element. */
21
+ progressBarProps: DOMAttributes,
22
+ /** Props for the progress bar's visual label element (if any). */
23
+ labelProps: DOMAttributes
24
+ }
25
+
26
+ /**
27
+ * Provides the accessibility implementation for a progress bar component.
28
+ * Progress bars show either determinate or indeterminate progress of an operation
29
+ * over time.
30
+ */
31
+ export function useProgressBar(props: AriaProgressBarProps): ProgressBarAria {
32
+ let {
33
+ value = 0,
34
+ minValue = 0,
35
+ maxValue = 100,
36
+ valueLabel,
37
+ isIndeterminate,
38
+ formatOptions = {
39
+ style: 'percent'
40
+ }
41
+ } = props;
42
+
43
+ let domProps = filterDOMProps(props, {labelable: true});
44
+ let {labelProps, fieldProps} = useLabel({
45
+ ...props,
46
+ // Progress bar is not an HTML input element so it
47
+ // shouldn't be labeled by a <label> element.
48
+ labelElementType: 'span'
49
+ });
50
+
51
+ value = clamp(value, minValue, maxValue);
52
+ let percentage = (value - minValue) / (maxValue - minValue);
53
+ let formatter = useNumberFormatter(formatOptions);
54
+
55
+ if (!isIndeterminate && !valueLabel) {
56
+ let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
57
+ valueLabel = formatter.format(valueToFormat);
58
+ }
59
+
60
+ return {
61
+ progressBarProps: mergeProps(domProps, {
62
+ ...fieldProps,
63
+ 'aria-valuenow': isIndeterminate ? undefined : value,
64
+ 'aria-valuemin': minValue,
65
+ 'aria-valuemax': maxValue,
66
+ 'aria-valuetext': isIndeterminate ? undefined : valueLabel as string,
67
+ role: 'progressbar'
68
+ }),
69
+ labelProps
70
+ };
71
+ }