@radix-ui/react-progress 1.0.3-rc.5 → 1.0.3-rc.7
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.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as Radix from "@radix-ui/react-primitive";
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
export const createProgressScope: import("@radix-ui/react-context").CreateScope;
|
|
5
|
+
type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
6
|
+
export interface ProgressProps extends PrimitiveDivProps {
|
|
7
|
+
value?: number | null | undefined;
|
|
8
|
+
max?: number;
|
|
9
|
+
getValueLabel?(value: number, max: number): string;
|
|
10
|
+
}
|
|
11
|
+
export const Progress: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export interface ProgressIndicatorProps extends PrimitiveDivProps {
|
|
13
|
+
}
|
|
14
|
+
export const ProgressIndicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export const Root: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export const Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -106,4 +106,4 @@ const $67824d98245208a0$export$adb584737d712b70 = $67824d98245208a0$export$2b776
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
export {$67824d98245208a0$export$388eb2d8f6d3261f as createProgressScope, $67824d98245208a0$export$b25a304ec7d746bb as Progress, $67824d98245208a0$export$2b776f7e7ee60dbd as ProgressIndicator, $67824d98245208a0$export$be92b6f5f03c0fe9 as Root, $67824d98245208a0$export$adb584737d712b70 as Indicator};
|
|
109
|
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D;AAED,SAASU,sCAAT,CAA0BZ,KAA1B,EAA4D2B,QAA5D,EAA6F;IAC3F,OAAO3B,KAAK,IAAI,IAAT,GAAgB,eAAhB,GAAkCA,KAAK,KAAK2B,QAAV,GAAqB,UAArB,GAAkC,SAA3E,CAAA;CACD;AAED,SAASjB,8BAAT,CAAkBV,KAAlB,EAA+C;IAC7C,OAAO,OAAOA,KAAP,KAAiB,QAAxB,CAAA;CACD;AAED,SAASO,sCAAT,CAA0BL,GAA1B,EAAmD;IACjD,kBAAA;IACA,OACEQ,8BAAQ,CAACR,GAAD,CAAR,IACA,CAAC0B,KAAK,CAAC1B,GAAD,CADN,IAEAA,GAAG,GAAG,CAHR,CAAA;CAKD;AAED,SAASM,wCAAT,CAA4BR,KAA5B,EAAwCE,GAAxC,EAAsE;IACpE,kBAAA;IACA,OACEQ,8BAAQ,CAACV,KAAD,CAAR,IACA,CAAC4B,KAAK,CAAC5B,KAAD,CADN,IAEAA,KAAK,IAAIE,GAFT,IAGAF,KAAK,IAAI,CAJX,CAAA;C,CAQF,+DAFC;AAGD,SAASoB,wCAAT,CAA4BJ,SAA5B,EAA+CD,aAA/C,EAAsE;IACpE,OAAQ,CAAA,gCAAA,EAAkCC,SAAU,CAAA,iBAAA,EAAmBD,aAAc,CAAA,sEAAA,EAAwEvB,iCAAY,CAAA,GAAA,CAAzK,CAAA;CACD;AAED,SAAS6B,0CAAT,CAA8BL,SAA9B,EAAiDD,aAAjD,EAAwE;IACtE,OAAQ,CAAA,kCAAA,EAAoCC,SAAU,CAAA,iBAAA,EAAmBD,aAAc,CAAvF;;8CAEF,EAAgDvB,iCAAY,CAA5D;;;uBAGA,CALE,CAKF;CACC;AAED,MAAMN,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAS,GAAGF,yCAAlB,AAAA;;ADhKA","sources":["packages/react/progress/src/index.ts","packages/react/progress/src/Progress.tsx"],"sourcesContent":["export {\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 * as Radix from '@radix-ui/react-primitive';\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.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.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) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n ...progressProps\n } = props;\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;\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\nProgress.displayName = PROGRESS_NAME;\n\nProgress.propTypes = {\n max(props, propName, componentName) {\n const propValue = props[propName];\n const strVal = String(propValue);\n if (propValue && !isValidMaxNumber(propValue)) {\n return new Error(getInvalidMaxError(strVal, componentName));\n }\n return null;\n },\n value(props, propName, componentName) {\n const valueProp = props[propName];\n const strVal = String(valueProp);\n const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;\n if (valueProp != null && !isValidValueNumber(valueProp, max)) {\n return new Error(getInvalidValueError(strVal, componentName));\n }\n return null;\n },\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator';\n\ntype ProgressIndicatorElement = React.ElementRef<typeof Primitive.div>;\ninterface ProgressIndicatorProps extends PrimitiveDivProps {}\n\nconst ProgressIndicator = React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (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\nProgressIndicator.displayName = INDICATOR_NAME;\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\\` 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"],"names":["createProgressScope","Progress","ProgressIndicator","Root","Indicator","React","createContextScope","Primitive","PROGRESS_NAME","DEFAULT_MAX","createProgressContext","ProgressProvider","useProgressContext","forwardRef","props","forwardedRef","__scopeProgress","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","getProgressState","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","INDICATOR_NAME","indicatorProps","context","Math","round","maxValue","isNaN"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;A;;;;ACOA;;oGAEA,CAEA,MAAMQ,mCAAa,GAAG,UAAtB,AAAA;AACA,MAAMC,iCAAW,GAAG,GAApB,AAAA;AAGA,MAAM,CAACC,2CAAD,EAAwBV,yCAAxB,CAAA,GAA+CM,yBAAkB,CAACE,mCAAD,CAAvE,AAAA;AAIA,MAAM,CAACG,sCAAD,EAAmBC,wCAAnB,CAAA,GACJF,2CAAqB,CAAuBF,mCAAvB,CADvB,AAAA;AAWA,MAAMP,yCAAQ,GAAA,aAAGI,CAAAA,iBAAA,CAC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AKD;AAED,SAASM,wCAAT,CAA4BR,KAA5B,EAAwCE,GAAxC,EAAsE;IACpE,kBAAA;IACA,OACEQ,8BAAQ,CAACV,KAAD,CAAR,IACA,CAAC4B,KAAK,CAAC5B,KAAD,CADN,IAEAA,KAAK,IAAIE,GAFT,IAGAF,KAAK,IAAI,CAJX,CAAA;C,CAQF,+DAFC;AAGD,SAASoB,wCAAT,CAA4BJ,SAA5B,EAA+CD,aAA/C,EAAsE;IACpE,OAAQ,CAAA,gCAAA,EAAkCC,SAAU,CAAA,iBAAA,EAAmBD,aAAc,CAAA,sEAAA,EAAwEvB,iCAAY,CAAA,GAAA,CAAzK,CAAA;CACD;AAED,SAAS6B,0CAAT,CAA8BL,SAA9B,EAAiDD,aAAjD,EAAwE;IACtE,OAAQ,CAAA,kCAAA,EAAoCC,SAAU,CAAA,iBAAA,EAAmBD,aAAc,CAAvF;;8CAEF,EAAgDvB,iCAAY,CAA5D;;;uBAGA,CALE,CAKF;CACC;AAED,MAAMN,yCAAI,GAAGF,yCAAb,AAAA;AACA,MAAMG,yCAAS,GAAGF,yCAAlB,AAAA;;ADhKA","sources":["packages/react/progress/src/index.ts","packages/react/progress/src/Progress.tsx"],"sourcesContent":["export {\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 * as Radix from '@radix-ui/react-primitive';\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.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.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) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n ...progressProps\n } = props;\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;\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\nProgress.displayName = PROGRESS_NAME;\n\nProgress.propTypes = {\n max(props, propName, componentName) {\n const propValue = props[propName];\n const strVal = String(propValue);\n if (propValue && !isValidMaxNumber(propValue)) {\n return new Error(getInvalidMaxError(strVal, componentName));\n }\n return null;\n },\n value(props, propName, componentName) {\n const valueProp = props[propName];\n const strVal = String(valueProp);\n const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;\n if (valueProp != null && !isValidValueNumber(valueProp, max)) {\n return new Error(getInvalidValueError(strVal, componentName));\n }\n return null;\n },\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator';\n\ntype ProgressIndicatorElement = React.ElementRef<typeof Primitive.div>;\ninterface ProgressIndicatorProps extends PrimitiveDivProps {}\n\nconst ProgressIndicator = React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (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\nProgressIndicator.displayName = INDICATOR_NAME;\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\\` 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"],"names":["createProgressScope","Progress","ProgressIndicator","Root","Indicator","React","createContextScope","Primitive","PROGRESS_NAME","DEFAULT_MAX","createProgressContext","ProgressProvider","useProgressContext","forwardRef","props","forwardedRef","__scopeProgress","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","getProgressState","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","INDICATOR_NAME","indicatorProps","context","Math","round","maxValue","isNaN"],"version":3,"file":"index.mjs.map"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-progress",
|
|
3
|
-
"version": "1.0.3-rc.
|
|
3
|
+
"version": "1.0.3-rc.7",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": {
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"default": "./dist/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"source": "./src/index.ts",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
9
21
|
"files": [
|
|
10
22
|
"dist",
|
|
11
23
|
"README.md"
|
|
@@ -17,8 +29,8 @@
|
|
|
17
29
|
},
|
|
18
30
|
"dependencies": {
|
|
19
31
|
"@babel/runtime": "^7.13.10",
|
|
20
|
-
"@radix-ui/react-context": "1.0.
|
|
21
|
-
"@radix-ui/react-primitive": "1.0.3-rc.
|
|
32
|
+
"@radix-ui/react-context": "1.0.1-rc.2",
|
|
33
|
+
"@radix-ui/react-primitive": "1.0.3-rc.7"
|
|
22
34
|
},
|
|
23
35
|
"peerDependencies": {
|
|
24
36
|
"react": "^16.8 || ^17.0 || ^18.0",
|