@radix-ui/react-progress 1.1.12 → 1.1.13-rc.1784074599772
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/index.js +16 -8
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
10
|
var __export = (target, all) => {
|
|
10
11
|
for (var name in all)
|
|
11
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -48,8 +49,9 @@ var PROGRESS_NAME = "Progress";
|
|
|
48
49
|
var DEFAULT_MAX = 100;
|
|
49
50
|
var [createProgressContext, createProgressScope] = (0, import_react_context.createContextScope)(PROGRESS_NAME);
|
|
50
51
|
var [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
51
|
-
var Progress = React.forwardRef(
|
|
52
|
-
|
|
52
|
+
var Progress = /* @__PURE__ */ React.forwardRef(
|
|
53
|
+
// blank line to reduce diff noise
|
|
54
|
+
/* @__PURE__ */ __name(function Progress2(props, forwardedRef) {
|
|
53
55
|
const {
|
|
54
56
|
__scopeProgress,
|
|
55
57
|
value: valueProp = null,
|
|
@@ -81,12 +83,12 @@ var Progress = React.forwardRef(
|
|
|
81
83
|
ref: forwardedRef
|
|
82
84
|
}
|
|
83
85
|
) });
|
|
84
|
-
}
|
|
86
|
+
}, "Progress")
|
|
85
87
|
);
|
|
86
|
-
Progress.displayName = PROGRESS_NAME;
|
|
87
88
|
var INDICATOR_NAME = "ProgressIndicator";
|
|
88
|
-
var ProgressIndicator = React.forwardRef(
|
|
89
|
-
|
|
89
|
+
var ProgressIndicator = /* @__PURE__ */ React.forwardRef(
|
|
90
|
+
// blank line to reduce diff noise
|
|
91
|
+
/* @__PURE__ */ __name(function ProgressIndicator2(props, forwardedRef) {
|
|
90
92
|
const { __scopeProgress, ...indicatorProps } = props;
|
|
91
93
|
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
92
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -99,27 +101,32 @@ var ProgressIndicator = React.forwardRef(
|
|
|
99
101
|
ref: forwardedRef
|
|
100
102
|
}
|
|
101
103
|
);
|
|
102
|
-
}
|
|
104
|
+
}, "ProgressIndicator")
|
|
103
105
|
);
|
|
104
|
-
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
105
106
|
function defaultGetValueLabel(value, max) {
|
|
106
107
|
return `${Math.round(value / max * 100)}%`;
|
|
107
108
|
}
|
|
109
|
+
__name(defaultGetValueLabel, "defaultGetValueLabel");
|
|
108
110
|
function getProgressState(value, maxValue) {
|
|
109
111
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
110
112
|
}
|
|
113
|
+
__name(getProgressState, "getProgressState");
|
|
111
114
|
function isNumber(value) {
|
|
112
115
|
return typeof value === "number";
|
|
113
116
|
}
|
|
117
|
+
__name(isNumber, "isNumber");
|
|
114
118
|
function isValidMaxNumber(max) {
|
|
115
119
|
return isNumber(max) && !isNaN(max) && max > 0;
|
|
116
120
|
}
|
|
121
|
+
__name(isValidMaxNumber, "isValidMaxNumber");
|
|
117
122
|
function isValidValueNumber(value, max) {
|
|
118
123
|
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
119
124
|
}
|
|
125
|
+
__name(isValidValueNumber, "isValidValueNumber");
|
|
120
126
|
function getInvalidMaxError(propValue, componentName) {
|
|
121
127
|
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
122
128
|
}
|
|
129
|
+
__name(getInvalidMaxError, "getInvalidMaxError");
|
|
123
130
|
function getInvalidValueError(propValue, componentName) {
|
|
124
131
|
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
125
132
|
- a positive number
|
|
@@ -128,6 +135,7 @@ function getInvalidValueError(propValue, componentName) {
|
|
|
128
135
|
|
|
129
136
|
Defaulting to \`null\`.`;
|
|
130
137
|
}
|
|
138
|
+
__name(getInvalidValueError, "getInvalidValueError");
|
|
131
139
|
var Root = Progress;
|
|
132
140
|
var Indicator = ProgressIndicator;
|
|
133
141
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/progress.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n} from './progress';\nexport type { ProgressProps, ProgressIndicatorProps } from './progress';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope };\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME);\n\ntype ProgressElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ProgressProps extends PrimitiveDivProps {\n value?: number | null | undefined;\n max?: number;\n getValueLabel?(value: number, max: number): string;\n}\n\nconst Progress = React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef)
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n} from './progress';\nexport type { ProgressProps, ProgressIndicatorProps } from './progress';\n", "import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope };\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME);\n\ntype ProgressElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ProgressProps extends PrimitiveDivProps {\n value?: number | null | undefined;\n max?: number;\n getValueLabel?(value: number, max: number): string;\n}\n\nconst Progress = /* @__PURE__ */ React.forwardRef<ProgressElement, ProgressProps>(\n // blank line to reduce diff noise\n function Progress(props: ScopedProps<ProgressProps>, forwardedRef) {\n const {\n __scopeProgress,\n value: valueProp = null,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n ...progressProps\n } = props;\n\n if ((maxProp || maxProp === 0) && !isValidMaxNumber(maxProp)) {\n console.error(getInvalidMaxError(`${maxProp}`, 'Progress'));\n }\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;\n\n if (valueProp !== null && !isValidValueNumber(valueProp, max)) {\n console.error(getInvalidValueError(`${valueProp}`, 'Progress'));\n }\n\n const value = isValidValueNumber(valueProp, max) ? valueProp : null;\n const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined;\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max}>\n <Primitive.div\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n ref={forwardedRef}\n />\n </ProgressProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator';\n\ntype ProgressIndicatorElement = React.ComponentRef<typeof Primitive.div>;\ninterface ProgressIndicatorProps extends PrimitiveDivProps {}\n\nconst ProgressIndicator = /* @__PURE__ */ React.forwardRef<\n ProgressIndicatorElement,\n ProgressIndicatorProps\n>(\n // blank line to reduce diff noise\n function ProgressIndicator(props: ScopedProps<ProgressIndicatorProps>, forwardedRef) {\n const { __scopeProgress, ...indicatorProps } = props;\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress);\n return (\n <Primitive.div\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n {...indicatorProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`;\n}\n\nfunction getProgressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading';\n}\n\nfunction isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nfunction isValidMaxNumber(max: any): max is number {\n // prettier-ignore\n return (\n isNumber(max) &&\n !isNaN(max) &&\n max > 0\n );\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n // prettier-ignore\n return (\n isNumber(value) &&\n !isNaN(value) &&\n value <= max &&\n value >= 0\n );\n}\n\n// Split this out for clearer readability of the error message.\nfunction getInvalidMaxError(propValue: string, componentName: string) {\n return `Invalid prop \\`max\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. Only numbers greater than 0 are valid max values. Defaulting to \\`${DEFAULT_MAX}\\`.`;\n}\n\nfunction getInvalidValueError(propValue: string, componentName: string) {\n return `Invalid prop \\`value\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. The \\`value\\` prop must be:\n - a positive number\n - less than the value passed to \\`max\\` (or ${DEFAULT_MAX} if no \\`max\\` prop is set)\n - \\`null\\` or \\`undefined\\` if the progress is indeterminate.\n\nDefaulting to \\`null\\`.`;\n}\n\nconst Root = Progress;\nconst Indicator = ProgressIndicator;\n\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n};\nexport type { ProgressProps, ProgressIndicatorProps };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,2BAAmC;AACnC,6BAA0B;AAqDlB;AA7CR,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAGpB,IAAM,CAAC,uBAAuB,mBAAmB,QAAI,yCAAmB,aAAa;AAIrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAU3D,IAAM,WAA2B,gBAAM;AAAA;AAAA,EAErC,gCAASA,UAAS,OAAmC,cAAc;AACjE,UAAM;AAAA,MACJ;AAAA,MACA,OAAO,YAAY;AAAA,MACnB,KAAK;AAAA,MACL,gBAAgB;AAAA,MAChB,GAAG;AAAA,IACL,IAAI;AAEJ,SAAK,WAAW,YAAY,MAAM,CAAC,iBAAiB,OAAO,GAAG;AAC5D,cAAQ,MAA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S,iBAAiB,OAAkC,UAAiC;AAC3F,SAAO,SAAS,OAAO,kBAAkB,UAAU,WAAW,aAAa;AAC7E;AAFS;AAIT,SAAS,SAAS,OAA6B;AAC7C,SAAO,OAAO,UAAU;AAC1B;AAFS;AAIT,SAAS,iBAAiB,KAAyB;AAEjD,SACE,SAAS,GAAG,KACZ,CAAC,MAAM,GAAG,KACV,MAAM;AAEV;AAPS;AAST,SAAS,mBAAmB,OAAY,KAA8B;AAEpE,SACE,SAAS,KAAK,KACd,CAAC,MAAM,KAAK,KACZ,SAAS,OACT,SAAS;AAEb;AARS;AAWT,SAAS,mBAAmB,WAAmB,eAAuB;AACpE,SAAO,mCAAmC,SAAS,oBAAoB,aAAa,yEAAyE,WAAW;AAC1K;AAFS;AAIT,SAAS,qBAAqB,WAAmB,eAAuB;AACtE,SAAO,qCAAqC,SAAS,oBAAoB,aAAa;AAAA;AAAA,gDAExC,WAAW;AAAA;AAAA;AAAA;AAI3D;AAPS;AAST,IAAM,OAAO;AACb,IAAM,YAAY;",
|
|
6
|
+
"names": ["Progress", "ProgressIndicator"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
2
4
|
|
|
3
5
|
// src/progress.tsx
|
|
4
6
|
import * as React from "react";
|
|
@@ -9,8 +11,9 @@ var PROGRESS_NAME = "Progress";
|
|
|
9
11
|
var DEFAULT_MAX = 100;
|
|
10
12
|
var [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
|
|
11
13
|
var [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
12
|
-
var Progress = React.forwardRef(
|
|
13
|
-
|
|
14
|
+
var Progress = /* @__PURE__ */ React.forwardRef(
|
|
15
|
+
// blank line to reduce diff noise
|
|
16
|
+
/* @__PURE__ */ __name(function Progress2(props, forwardedRef) {
|
|
14
17
|
const {
|
|
15
18
|
__scopeProgress,
|
|
16
19
|
value: valueProp = null,
|
|
@@ -42,12 +45,12 @@ var Progress = React.forwardRef(
|
|
|
42
45
|
ref: forwardedRef
|
|
43
46
|
}
|
|
44
47
|
) });
|
|
45
|
-
}
|
|
48
|
+
}, "Progress")
|
|
46
49
|
);
|
|
47
|
-
Progress.displayName = PROGRESS_NAME;
|
|
48
50
|
var INDICATOR_NAME = "ProgressIndicator";
|
|
49
|
-
var ProgressIndicator = React.forwardRef(
|
|
50
|
-
|
|
51
|
+
var ProgressIndicator = /* @__PURE__ */ React.forwardRef(
|
|
52
|
+
// blank line to reduce diff noise
|
|
53
|
+
/* @__PURE__ */ __name(function ProgressIndicator2(props, forwardedRef) {
|
|
51
54
|
const { __scopeProgress, ...indicatorProps } = props;
|
|
52
55
|
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
53
56
|
return /* @__PURE__ */ jsx(
|
|
@@ -60,27 +63,32 @@ var ProgressIndicator = React.forwardRef(
|
|
|
60
63
|
ref: forwardedRef
|
|
61
64
|
}
|
|
62
65
|
);
|
|
63
|
-
}
|
|
66
|
+
}, "ProgressIndicator")
|
|
64
67
|
);
|
|
65
|
-
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
66
68
|
function defaultGetValueLabel(value, max) {
|
|
67
69
|
return `${Math.round(value / max * 100)}%`;
|
|
68
70
|
}
|
|
71
|
+
__name(defaultGetValueLabel, "defaultGetValueLabel");
|
|
69
72
|
function getProgressState(value, maxValue) {
|
|
70
73
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
71
74
|
}
|
|
75
|
+
__name(getProgressState, "getProgressState");
|
|
72
76
|
function isNumber(value) {
|
|
73
77
|
return typeof value === "number";
|
|
74
78
|
}
|
|
79
|
+
__name(isNumber, "isNumber");
|
|
75
80
|
function isValidMaxNumber(max) {
|
|
76
81
|
return isNumber(max) && !isNaN(max) && max > 0;
|
|
77
82
|
}
|
|
83
|
+
__name(isValidMaxNumber, "isValidMaxNumber");
|
|
78
84
|
function isValidValueNumber(value, max) {
|
|
79
85
|
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
80
86
|
}
|
|
87
|
+
__name(isValidValueNumber, "isValidValueNumber");
|
|
81
88
|
function getInvalidMaxError(propValue, componentName) {
|
|
82
89
|
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
83
90
|
}
|
|
91
|
+
__name(getInvalidMaxError, "getInvalidMaxError");
|
|
84
92
|
function getInvalidValueError(propValue, componentName) {
|
|
85
93
|
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
86
94
|
- a positive number
|
|
@@ -89,6 +97,7 @@ function getInvalidValueError(propValue, componentName) {
|
|
|
89
97
|
|
|
90
98
|
Defaulting to \`null\`.`;
|
|
91
99
|
}
|
|
100
|
+
__name(getInvalidValueError, "getInvalidValueError");
|
|
92
101
|
var Root = Progress;
|
|
93
102
|
var Indicator = ProgressIndicator;
|
|
94
103
|
export {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/progress.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope };\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME);\n\ntype ProgressElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ProgressProps extends PrimitiveDivProps {\n value?: number | null | undefined;\n max?: number;\n getValueLabel?(value: number, max: number): string;\n}\n\nconst Progress = React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef)
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type { Scope } from '@radix-ui/react-context';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope };\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME);\n\ntype ProgressElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface ProgressProps extends PrimitiveDivProps {\n value?: number | null | undefined;\n max?: number;\n getValueLabel?(value: number, max: number): string;\n}\n\nconst Progress = /* @__PURE__ */ React.forwardRef<ProgressElement, ProgressProps>(\n // blank line to reduce diff noise\n function Progress(props: ScopedProps<ProgressProps>, forwardedRef) {\n const {\n __scopeProgress,\n value: valueProp = null,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n ...progressProps\n } = props;\n\n if ((maxProp || maxProp === 0) && !isValidMaxNumber(maxProp)) {\n console.error(getInvalidMaxError(`${maxProp}`, 'Progress'));\n }\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;\n\n if (valueProp !== null && !isValidValueNumber(valueProp, max)) {\n console.error(getInvalidValueError(`${valueProp}`, 'Progress'));\n }\n\n const value = isValidValueNumber(valueProp, max) ? valueProp : null;\n const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined;\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max}>\n <Primitive.div\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n ref={forwardedRef}\n />\n </ProgressProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator';\n\ntype ProgressIndicatorElement = React.ComponentRef<typeof Primitive.div>;\ninterface ProgressIndicatorProps extends PrimitiveDivProps {}\n\nconst ProgressIndicator = /* @__PURE__ */ React.forwardRef<\n ProgressIndicatorElement,\n ProgressIndicatorProps\n>(\n // blank line to reduce diff noise\n function ProgressIndicator(props: ScopedProps<ProgressIndicatorProps>, forwardedRef) {\n const { __scopeProgress, ...indicatorProps } = props;\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress);\n return (\n <Primitive.div\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n {...indicatorProps}\n ref={forwardedRef}\n />\n );\n },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`;\n}\n\nfunction getProgressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading';\n}\n\nfunction isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nfunction isValidMaxNumber(max: any): max is number {\n // prettier-ignore\n return (\n isNumber(max) &&\n !isNaN(max) &&\n max > 0\n );\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n // prettier-ignore\n return (\n isNumber(value) &&\n !isNaN(value) &&\n value <= max &&\n value >= 0\n );\n}\n\n// Split this out for clearer readability of the error message.\nfunction getInvalidMaxError(propValue: string, componentName: string) {\n return `Invalid prop \\`max\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. Only numbers greater than 0 are valid max values. Defaulting to \\`${DEFAULT_MAX}\\`.`;\n}\n\nfunction getInvalidValueError(propValue: string, componentName: string) {\n return `Invalid prop \\`value\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. The \\`value\\` prop must be:\n - a positive number\n - less than the value passed to \\`max\\` (or ${DEFAULT_MAX} if no \\`max\\` prop is set)\n - \\`null\\` or \\`undefined\\` if the progress is indeterminate.\n\nDefaulting to \\`null\\`.`;\n}\n\nconst Root = Progress;\nconst Indicator = ProgressIndicator;\n\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n};\nexport type { ProgressProps, ProgressIndicatorProps };\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAqDlB;AA7CR,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAGpB,IAAM,CAAC,uBAAuB,mBAAmB,IAAI,mBAAmB,aAAa;AAIrF,IAAM,CAAC,kBAAkB,kBAAkB,IACzC,sBAA4C,aAAa;AAU3D,IAAM,WAA2B,gBAAM;AAAA;AAAA,EAErC,gCAASA,UAAS,OAAmC,cAAc;AACjE,UAAM;AAAA,MACJ;AAAA,MACA,OAAO,YAAY;AAAA,MACnB,KAAK;AAAA,MACL,gBAAgB;AAAA,MAChB,GAAG;AAAA,IACL,IAAI;AAEJ,SAAK,WAAW,YAAY,MAAM,CAAC,iBAAiB,OAAO,GAAG;AAC5D,cAAQ,MAAM,mBAAmB,GAAG,OAAO,IA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C3F,SAAO,SAAS,OAAO,kBAAkB,UAAU,WAAW,aAAa;AAC7E;AAFS;AAIT,SAAS,SAAS,OAA6B;AAC7C,SAAO,OAAO,UAAU;AAC1B;AAFS;AAIT,SAAS,iBAAiB,KAAyB;AAEjD,SACE,SAAS,GAAG,KACZ,CAAC,MAAM,GAAG,KACV,MAAM;AAEV;AAPS;AAST,SAAS,mBAAmB,OAAY,KAA8B;AAEpE,SACE,SAAS,KAAK,KACd,CAAC,MAAM,KAAK,KACZ,SAAS,OACT,SAAS;AAEb;AARS;AAWT,SAAS,mBAAmB,WAAmB,eAAuB;AACpE,SAAO,mCAAmC,SAAS,oBAAoB,aAAa,yEAAyE,WAAW;AAC1K;AAFS;AAIT,SAAS,qBAAqB,WAAmB,eAAuB;AACtE,SAAO,qCAAqC,SAAS,oBAAoB,aAAa;AAAA;AAAA,gDAExC,WAAW;AAAA;AAAA;AAAA;AAI3D;AAPS;AAST,IAAM,OAAO;AACb,IAAM,YAAY;",
|
|
6
|
+
"names": ["Progress", "ProgressIndicator"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-progress",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13-rc.1784074599772",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"react": "^19.2.0",
|
|
21
21
|
"react-dom": "^19.2.0",
|
|
22
22
|
"typescript": "^5.9.3",
|
|
23
|
-
"@repo/builder": "0.0.
|
|
23
|
+
"@repo/builder": "0.0.1-rc.1784074599772",
|
|
24
24
|
"@repo/typescript-config": "0.0.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|