@radix-ui/react-progress 0.1.1-rc.8 → 0.1.2-rc.2

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.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import * as Radix from "@radix-ui/react-primitive";
3
3
  import { Primitive } from "@radix-ui/react-primitive";
4
- type ProgressState = 'indeterminate' | 'complete' | 'loading';
4
+ export const createProgressScope: import("@radix-ui/react-context").CreateScope;
5
5
  type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
6
6
  export interface ProgressProps extends PrimitiveDivProps {
7
7
  value?: number | null | undefined;
@@ -12,7 +12,6 @@ export const Progress: React.ForwardRefExoticComponent<ProgressProps & React.Ref
12
12
  export interface ProgressIndicatorProps extends PrimitiveDivProps {
13
13
  }
14
14
  export const ProgressIndicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<HTMLDivElement>>;
15
- export function useProgressState(): ProgressState;
16
15
  export const Root: React.ForwardRefExoticComponent<ProgressProps & React.RefAttributes<HTMLDivElement>>;
17
16
  export const Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<HTMLDivElement>>;
18
17
 
@@ -1 +1 @@
1
- {"mappings":"A;A;A;AAaA,qBAAqB,eAAe,GAAG,UAAU,GAAG,SAAS,CAAC;AAK9D,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,8BAAwB,SAAQ,iBAAiB;IAC/C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACpD;AAED,OAAA,MAAM,8FA4BJ,CAAC;AA+BH,uCAAiC,SAAQ,iBAAiB;CAAG;AAE7D,OAAA,MAAM,gHAaL,CAAC;AAMF,kDAGC;AA+CD,OAAA,MAAM,0FAAe,CAAC;AACtB,OAAA,MAAM,wGAA6B,CAAC","sources":["./packages/react/progress/src/packages/react/progress/src/Progress.tsx","./packages/react/progress/src/packages/react/progress/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"A;A;A;AAeA,OAAA,0FAAsF,CAAC;AAQvF,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,8BAAwB,SAAQ,iBAAiB;IAC/C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACpD;AAED,OAAA,MAAM,8FA+BL,CAAC;AA+BF,uCAAiC,SAAQ,iBAAiB;CAAG;AAE7D,OAAA,MAAM,gHAcL,CAAC;AAmDF,OAAA,MAAM,0FAAe,CAAC;AACtB,OAAA,MAAM,wGAA6B,CAAC","sources":["./packages/react/progress/src/packages/react/progress/src/Progress.tsx","./packages/react/progress/src/packages/react/progress/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e,r,t,a=require("@radix-ui/react-primitive").Primitive,n=require("@radix-ui/react-context").createContext,u=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e),o=(t=require("@babel/runtime/helpers/extends"))&&t.__esModule?t.default:t;const[i,l]=n("Progress"),s=/*#__PURE__*/u.forwardRef(((e,r)=>{const{value:t,max:n,getValueLabel:l=c,...s}=e,d=p(n)?n:100,x=f(t,d)?t:null,g=m(x)?l(x,d):void 0;/*#__PURE__*/return u.createElement(i,{value:x,max:d},/*#__PURE__*/u.createElement(a.div,o({"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":m(x)?x:void 0,"aria-valuetext":g,role:"progressbar","data-state":v(x,d),"data-value":null!=x?x:void 0,"data-max":d},s,{ref:r})))}));exports.Progress=s,s.propTypes={max(e,r,t){const a=e[r],n=String(a);return a&&!p(a)?new Error(function(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}(n,t)):null},value(e,r,t){const a=e[r],n=String(a),u=p(e.max)?e.max:100;return null==a||f(a,u)?null:new Error(function(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(n,t))}};const d=/*#__PURE__*/u.forwardRef(((e,r)=>{var t;const n=l("ProgressIndicator");/*#__PURE__*/return u.createElement(a.div,o({"data-state":v(n.value,n.max),"data-value":null!==(t=n.value)&&void 0!==t?t:void 0,"data-max":n.max},e,{ref:r}))}));function c(e,r){return`${Math.round(e/r*100)}%`}function v(e,r){return null==e?"indeterminate":e===r?"complete":"loading"}function m(e){return"number"==typeof e}function p(e){return m(e)&&!isNaN(e)&&e>0}function f(e,r){return m(e)&&!isNaN(e)&&e<=r&&e>=0}exports.ProgressIndicator=d,exports.useProgressState=function(){const e=l("useProgressState");return v(e.value,e.max)};const x=s;exports.Root=x;const g=d;exports.Indicator=g;
1
+ var e,r,t,a=require("@radix-ui/react-primitive").Primitive,n=require("@radix-ui/react-context").createContextScope,o=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e),u=(t=require("@babel/runtime/helpers/extends"))&&t.__esModule?t.default:t;const[i,s]=n("Progress");exports.createProgressScope=s;const[l,c]=i("Progress"),d=/*#__PURE__*/o.forwardRef(((e,r)=>{const{__scopeProgress:t,value:n,max:i,getValueLabel:s=v,...c}=e,d=x(i)?i:100,p=g(n,d)?n:null,b=f(p)?s(p,d):void 0;/*#__PURE__*/return o.createElement(l,{scope:t,value:p,max:d},/*#__PURE__*/o.createElement(a.div,u({"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":f(p)?p:void 0,"aria-valuetext":b,role:"progressbar","data-state":m(p,d),"data-value":null!=p?p:void 0,"data-max":d},c,{ref:r})))}));exports.Progress=d,d.propTypes={max(e,r,t){const a=e[r],n=String(a);return a&&!x(a)?new Error(function(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}(n,t)):null},value(e,r,t){const a=e[r],n=String(a),o=x(e.max)?e.max:100;return null==a||g(a,o)?null:new Error(function(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(n,t))}};const p=/*#__PURE__*/o.forwardRef(((e,r)=>{var t;const{__scopeProgress:n,...i}=e,s=c("ProgressIndicator",n);/*#__PURE__*/return o.createElement(a.div,u({"data-state":m(s.value,s.max),"data-value":null!==(t=s.value)&&void 0!==t?t:void 0,"data-max":s.max},i,{ref:r}))}));function v(e,r){return`${Math.round(e/r*100)}%`}function m(e,r){return null==e?"indeterminate":e===r?"complete":"loading"}function f(e){return"number"==typeof e}function x(e){return f(e)&&!isNaN(e)&&e>0}function g(e,r){return f(e)&&!isNaN(e)&&e<=r&&e>=0}exports.ProgressIndicator=p;const b=d;exports.Root=b;const P=p;exports.Indicator=P;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"IAYgCA,EAAMC,EAZNC,yGAYAF,KAAMC,mBACpCE,OAAOC,KAAKH,GA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AC/C,MAAQ,qCAAoCC,qBAA6BD,mNA5EpDM,CAAqBJ,EAAQF,MAUpD,MAKMO,eAAoBlC,EAAMC,YAC9B,CAACC,EAAOC,KAAiB,IAAAgC,EACvB,MAAMC,EAAUvC,EAPG,kCAQnB,OACEmB,EAAAC,cAACE,EAAUC,IAAXC,EAAA,CACE,aAAYE,EAAiBa,EAAQhC,MAAOgC,EAAQ9B,KACpD,aAAA,QAAA6B,EAAYC,EAAQhC,aAApB,IAAA+B,EAAAA,OAA6BpB,EAC7B,WAAUqB,EAAQ9B,KACdJ,EAJN,CAKEsB,IAAKrB,QAeb,SAASM,EAAqBL,EAAeE,GAC3C,MAAQ,GAAE+B,KAAKC,MAAOlC,EAAQE,EAAO,QAGvC,SAASiB,EAAiBnB,EAAkCmC,GAC1D,OAAgB,MAATnC,EAAgB,gBAAkBA,IAAUmC,EAAW,WAAa,UAG7E,SAASzB,EAASV,GAChB,MAAwB,iBAAVA,EAGhB,SAASO,EAAiBL,GAExB,OACEQ,EAASR,KACRkC,MAAMlC,IACPA,EAAM,EAIV,SAASM,EAAmBR,EAAYE,GAEtC,OACEQ,EAASV,KACRoC,MAAMpC,IACPA,GAASE,GACTF,GAAS,uDAhCb,WACE,MAAMgC,EAAUvC,EAAmB,oBACnC,OAAO0B,EAAiBa,EAAQhC,MAAOgC,EAAQ9B,MAgDjD,MAAMmC,EAAO1C,iBACb,MAAM2C,EAAYR","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/progress/src/Progress.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] = createContext<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>((props, forwardedRef) => {\n const {\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 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\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, forwardedRef) => {\n const context = useProgressContext(INDICATOR_NAME);\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 {...props}\n ref={forwardedRef}\n />\n );\n }\n);\n\nProgressIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction useProgressState() {\n const context = useProgressContext('useProgressState');\n return getProgressState(context.value, context.max);\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 Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n //\n useProgressState,\n};\nexport type { ProgressProps, ProgressIndicatorProps };\n"],"names":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","ProgressProvider","useProgressContext","createContext","Progress","React","forwardRef","props","forwardedRef","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","_react","createElement","$b3fbbcf6ced69600a6d4c5fc151c3856$var$ProgressProvider","Primitive","div","_babelRuntimeHelpersExtends","role","getProgressState","ref","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","ProgressIndicator","_context$value","context","Math","round","maxValue","isNaN","Root","Indicator"],"version":3,"file":"index.js.map"}
1
+ {"mappings":"IAYgCA,EAAMC,EAZNC,8GAYAF,KAAMC,mBACpCE,OAAOC,KAAKH,GAAQI,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeP,EAAMM,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOR,EAAOK,SAKbN,MA1BuBE,8CAClBA,EAAEQ,WAAaR,EAAES,QAAUT,ECUzC,MAIOU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,IAAAkC,EAC5D,MAAMjC,gBAAEA,KAAoBkC,GAAmBpC,EACzCqC,EAAUzC,EARG,oBAQgCM,gBACnD,OACEa,EAAAC,cAACG,EAAUC,IAAXC,EAAA,CACE,aAAYE,EAAiBc,EAAQlC,MAAOkC,EAAQhC,KACpD,aAAA,QAAA8B,EAAYE,EAAQlC,aAApB,IAAAgC,EAAAA,OAA6BrB,EAC7B,WAAUuB,EAAQhC,KACd+B,EAJN,CAKEZ,IAAKvB,QAUb,SAASO,EAAqBL,EAAeE,GAC3C,MAAQ,GAAEiC,KAAKC,MAAOpC,EAAQE,EAAO,QAGvC,SAASkB,EAAiBpB,EAAkCqC,GAC1D,OAAgB,MAATrC,EAAgB,gBAAkBA,IAAUqC,EAAW,WAAa,UAG7E,SAAS3B,EAASV,GAChB,MAAwB,iBAAVA,EAGhB,SAASO,EAAiBL,GAExB,OACEQ,EAASR,KACRoC,MAAMpC,IACPA,EAAM,EAIV,SAASM,EAAmBR,EAAYE,GAEtC,OACEQ,EAASV,KACRsC,MAAMtC,IACPA,GAASE,GACTF,GAAS,8BAkBb,MAAMuC,EAAO7C,iBACb,MAAM8C,EAAYT","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/progress/src/Progress.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\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":["dest","source","a","Object","keys","forEach","key","defineProperty","enumerable","get","__esModule","default","createProgressContext","createProgressScope","createContextScope","ProgressProvider","useProgressContext","Progress","React","forwardRef","props","forwardedRef","__scopeProgress","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","_react","createElement","$b3fbbcf6ced69600a6d4c5fc151c3856$var$ProgressProvider","scope","Primitive","div","_babelRuntimeHelpersExtends","role","getProgressState","ref","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","ProgressIndicator","_context$value","indicatorProps","context","Math","round","maxValue","isNaN","Root","Indicator"],"version":3,"file":"index.js.map"}
@@ -1,2 +1,2 @@
1
- import{Primitive as e}from"@radix-ui/react-primitive";import{createContext as r}from"@radix-ui/react-context";import*as t from"react";import a from"@babel/runtime/helpers/esm/extends";const[n,o]=r("Progress");export const Progress=/*#__PURE__*/t.forwardRef(((r,o)=>{const{value:d,max:p,getValueLabel:v=u,...c}=r,f=l(p)?p:100,x=m(d,f)?d:null,g=s(x)?v(x,f):void 0;/*#__PURE__*/return t.createElement(n,{value:x,max:f},/*#__PURE__*/t.createElement(e.div,a({"aria-valuemax":f,"aria-valuemin":0,"aria-valuenow":s(x)?x:void 0,"aria-valuetext":g,role:"progressbar","data-state":i(x,f),"data-value":null!=x?x:void 0,"data-max":f},c,{ref:o})))}));/*#__PURE__*/Progress.propTypes={max(e,r,t){const a=e[r],n=String(a);return a&&!l(a)?new Error(function(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}(n,t)):null},value(e,r,t){const a=e[r],n=String(a),o=l(e.max)?e.max:100;return null==a||m(a,o)?null:new Error(function(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(n,t))}};export const ProgressIndicator=/*#__PURE__*/t.forwardRef(((r,n)=>{var u;const s=o("ProgressIndicator");/*#__PURE__*/return t.createElement(e.div,a({"data-state":i(s.value,s.max),"data-value":null!==(u=s.value)&&void 0!==u?u:void 0,"data-max":s.max},r,{ref:n}))}));/*#__PURE__*/export function useProgressState(){const e=o("useProgressState");return i(e.value,e.max)}function u(e,r){return`${Math.round(e/r*100)}%`}function i(e,r){return null==e?"indeterminate":e===r?"complete":"loading"}function s(e){return"number"==typeof e}function l(e){return s(e)&&!isNaN(e)&&e>0}function m(e,r){return s(e)&&!isNaN(e)&&e<=r&&e>=0}export const Root=Progress;export const Indicator=ProgressIndicator;
1
+ import{Primitive as e}from"@radix-ui/react-primitive";import{createContextScope as r}from"@radix-ui/react-context";import*as t from"react";import a from"@babel/runtime/helpers/esm/extends";const[n,o]=r("Progress");export{o as createProgressScope};const[s,i]=n("Progress");export const Progress=/*#__PURE__*/t.forwardRef(((r,n)=>{const{__scopeProgress:o,value:i,max:d,getValueLabel:v=u,...f}=r,x=p(d)?d:100,g=c(i,x)?i:null,P=m(g)?v(g,x):void 0;/*#__PURE__*/return t.createElement(s,{scope:o,value:g,max:x},/*#__PURE__*/t.createElement(e.div,a({"aria-valuemax":x,"aria-valuemin":0,"aria-valuenow":m(g)?g:void 0,"aria-valuetext":P,role:"progressbar","data-state":l(g,x),"data-value":null!=g?g:void 0,"data-max":x},f,{ref:n})))}));/*#__PURE__*/Progress.propTypes={max(e,r,t){const a=e[r],n=String(a);return a&&!p(a)?new Error(function(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}(n,t)):null},value(e,r,t){const a=e[r],n=String(a),o=p(e.max)?e.max:100;return null==a||c(a,o)?null:new Error(function(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(n,t))}};export const ProgressIndicator=/*#__PURE__*/t.forwardRef(((r,n)=>{var o;const{__scopeProgress:s,...u}=r,m=i("ProgressIndicator",s);/*#__PURE__*/return t.createElement(e.div,a({"data-state":l(m.value,m.max),"data-value":null!==(o=m.value)&&void 0!==o?o:void 0,"data-max":m.max},u,{ref:n}))}));/*#__PURE__*/function u(e,r){return`${Math.round(e/r*100)}%`}function l(e,r){return null==e?"indeterminate":e===r?"complete":"loading"}function m(e){return"number"==typeof e}function p(e){return m(e)&&!isNaN(e)&&e>0}function c(e,r){return m(e)&&!isNaN(e)&&e<=r&&e>=0}export const Root=Progress;export const Indicator=ProgressIndicator;
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":"wLAUA,MAKOA,EAAkBC,GAAsBC,EALzB,mBAetB,MAAMC,sBAAWC,EAAMC,YAA2C,CAACC,EAAOC,KACxE,MACEC,MAAOC,EACPC,IAAKC,EAFDC,cAGJA,EAA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OAA6BpB,EAC7B,WAAUqB,EAAQ9B,KACdJ,EAJN,CAKEsB,IAAKrB,4BAUb,SAASkC,mBACP,MAAMD,EAAUvC,EAAmB,oBACnC,OAAO0B,EAAiBa,EAAQhC,MAAOgC,EAAQ9B,KAGjD,SAASG,EAAqBL,EAAeE,GAC3C,MAAQ,GAAEgC,KAAKC,MAAOnC,EAAQE,EAAO,QAGvC,SAASiB,EAAiBnB,EAAkCoC,GAC1D,OAAgB,MAATpC,EAAgB,gBAAkBA,IAAUoC,EAAW,WAAa,UAG7E,SAAS1B,EAASV,GAChB,MAAwB,iBAAVA,EAGhB,SAASO,EAAiBL,GAExB,OACEQ,EAASR,KACRmC,MAAMnC,IACPA,EAAM,EAIV,SAASM,EAAmBR,EAAYE,GAEtC,OACEQ,EAASV,KACRqC,MAAMrC,IACPA,GAASE,GACTF,GAAS,SAkBb,MAAMsC,KAAO3C,gBACb,MAAM4C,UAAYT","sources":["./packages/react/progress/src/Progress.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createContext } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROGRESS_NAME = 'Progress';\nconst DEFAULT_MAX = 100;\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading';\ntype ProgressContextValue = { value: number | null; max: number };\nconst [ProgressProvider, useProgressContext] = createContext<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>((props, forwardedRef) => {\n const {\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 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\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, forwardedRef) => {\n const context = useProgressContext(INDICATOR_NAME);\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 {...props}\n ref={forwardedRef}\n />\n );\n }\n);\n\nProgressIndicator.displayName = INDICATOR_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction useProgressState() {\n const context = useProgressContext('useProgressState');\n return getProgressState(context.value, context.max);\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 Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n //\n useProgressState,\n};\nexport type { ProgressProps, ProgressIndicatorProps };\n"],"names":["ProgressProvider","useProgressContext","createContext","Progress","React","forwardRef","props","forwardedRef","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","_react","createElement","$fc61ea0f5d6587188592ef12afccad3f$var$ProgressProvider","Primitive","div","_babelRuntimeHelpersEsmExtends","role","getProgressState","ref","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","ProgressIndicator","_context$value","context","useProgressState","Math","round","maxValue","isNa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BJ,EAAQF,aAepD,MAAMO,+BAAoBpC,EAAMC,YAC9B,CAACC,EAA4CC,KAAiB,IAAAkC,EAC5D,MAAMjC,gBAAEA,KAAoBkC,GAAmBpC,EACzCqC,EAAUzC,EARG,oBAQgCM,gBACnD,OACEa,EAAAC,cAACG,EAAUC,IAAXC,EAAA,CACE,aAAYE,EAAiBc,EAAQlC,MAAOkC,EAAQhC,KACpD,aAAA,QAAA8B,EAAYE,EAAQlC,aAApB,IAAAgC,EAAAA,OAA6BrB,EAC7B,WAAUuB,EAAQhC,KACd+B,EAJN,CAKEZ,IAAKvB,qBAUb,SAASO,EAAqBL,EAAeE,GAC3C,MAAQ,GAAEiC,KAAKC,MAAOpC,EAAQE,EAAO,QAGvC,SAASkB,EAAiBpB,EAAkCqC,GAC1D,OAAgB,MAATrC,EAAgB,gBAAkBA,IAAUqC,EAAW,WAAa,UAG7E,SAAS3B,EAASV,GAChB,MAAwB,iBAAVA,EAGhB,SAASO,EAAiBL,GAExB,OACEQ,EAASR,KACRoC,MAAMpC,IACPA,EAAM,EAIV,SAASM,EAAmBR,EAAYE,GAEtC,OACEQ,EAASV,KACRsC,MAAMtC,IACPA,GAASE,GACTF,GAAS,SAkBb,MAAMuC,KAAO7C,gBACb,MAAM8C,UAAYT","sources":["./packages/react/progress/src/Progress.tsx"],"sourcesContent":["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":["createProgressContext","createProgressScope","createContextScope","ProgressProvider","useProgressContext","Progress","React","forwardRef","props","forwardedRef","__scopeProgress","value","valueProp","max","maxProp","getValueLabel","defaultGetValueLabel","progressProps","isValidMaxNumber","isValidValueNumber","valueLabel","isNumber","undefined","_react","createElement","$fc61ea0f5d6587188592ef12afccad3f$var$ProgressProvider","scope","Primitive","div","_babelRuntimeHelpersEsmExtends","role","getProgressState","ref","propTypes","propName","componentName","propValue","strVal","String","Error","getInvalidMaxError","getInvalidValueError","ProgressIndicator","_context$value","indicatorProps","context","Math","round","maxValue","isNaN","Root","Indicator"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-progress",
3
- "version": "0.1.1-rc.8",
3
+ "version": "0.1.2-rc.2",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.13.10",
20
- "@radix-ui/react-context": "0.1.0",
21
- "@radix-ui/react-primitive": "0.1.1-rc.8"
20
+ "@radix-ui/react-context": "0.1.1",
21
+ "@radix-ui/react-primitive": "0.1.2-rc.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^16.8 || ^17.0"
@@ -31,5 +31,5 @@
31
31
  "bugs": {
32
32
  "url": "https://github.com/radix-ui/primitives/issues"
33
33
  },
34
- "stableVersion": "0.1.0"
34
+ "stableVersion": "0.1.1"
35
35
  }