@tamagui/progress 1.0.1-beta.72 → 1.0.1-beta.75
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/cjs/Progress.js
CHANGED
|
@@ -21,7 +21,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
24
|
var __objRest = (source, exclude) => {
|
|
26
25
|
var target = {};
|
|
27
26
|
for (var prop in source)
|
|
@@ -90,27 +89,21 @@ ProgressIndicator.displayName = INDICATOR_NAME;
|
|
|
90
89
|
function defaultGetValueLabel(value, max) {
|
|
91
90
|
return `${Math.round(value / max * 100)}%`;
|
|
92
91
|
}
|
|
93
|
-
__name(defaultGetValueLabel, "defaultGetValueLabel");
|
|
94
92
|
function getProgressState(value, maxValue) {
|
|
95
93
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
96
94
|
}
|
|
97
|
-
__name(getProgressState, "getProgressState");
|
|
98
95
|
function isNumber(value) {
|
|
99
96
|
return typeof value === "number";
|
|
100
97
|
}
|
|
101
|
-
__name(isNumber, "isNumber");
|
|
102
98
|
function isValidMaxNumber(max) {
|
|
103
99
|
return isNumber(max) && !isNaN(max) && max > 0;
|
|
104
100
|
}
|
|
105
|
-
__name(isValidMaxNumber, "isValidMaxNumber");
|
|
106
101
|
function isValidValueNumber(value, max) {
|
|
107
102
|
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
108
103
|
}
|
|
109
|
-
__name(isValidValueNumber, "isValidValueNumber");
|
|
110
104
|
function getInvalidMaxError(propValue, componentName) {
|
|
111
105
|
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
112
106
|
}
|
|
113
|
-
__name(getInvalidMaxError, "getInvalidMaxError");
|
|
114
107
|
function getInvalidValueError(propValue, componentName) {
|
|
115
108
|
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
116
109
|
- a positive number
|
|
@@ -119,7 +112,6 @@ function getInvalidValueError(propValue, componentName) {
|
|
|
119
112
|
|
|
120
113
|
Defaulting to \`null\`.`;
|
|
121
114
|
}
|
|
122
|
-
__name(getInvalidValueError, "getInvalidValueError");
|
|
123
115
|
const DEFAULT_MAX = 100;
|
|
124
116
|
const ProgressFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
125
117
|
name: PROGRESS_NAME,
|
package/dist/cjs/Progress.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Progress.tsx"],
|
|
4
4
|
"sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx\n\nimport { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst PROGRESS_NAME = 'Progress'\n\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)\ntype ProgressContextValue = { value: number | null; max: number; width: number }\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator'\n\ntype ProgressIndicatorElement = TamaguiElement\ninterface ProgressIndicatorProps extends YStackProps {}\n\nexport const ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\n backgrounded: true,\n})\n\nconst ProgressIndicator = ProgressIndicatorFrame.extractable(\n React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {\n const { __scopeProgress, ...indicatorProps } = props\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress)\n const pct = context.max - (context.value ?? 0)\n const x = -context.width * (pct / 100)\n return (\n <ProgressIndicatorFrame\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n x={x}\n width={context.width}\n {...indicatorProps}\n ref={forwardedRef}\n />\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\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst DEFAULT_MAX = 100\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope }\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading'\n\ntype TamaguiElement = HTMLElement | View\n\ntype ProgressElement = TamaguiElement\n\nexport const ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n backgrounded: true,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = Math.round(getVariableValue(getSize(val)) * 0.25)\n return {\n height: size,\n minWidth: getVariableValue(size) * 20,\n width: '100%',\n }\n },\n },\n },\n})\n\ntype ProgressProps = GetProps<typeof ProgressFrame> & {\n value?: number | null | undefined\n max?: number\n getValueLabel?(value: number, max: number): string\n}\n\nconst Progress = withStaticProperties(\n ProgressFrame.extractable(\n React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n size = '$4',\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 const [width, setWidth] = React.useState(0)\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>\n <ProgressFrame\n size={size}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n // @ts-ignore\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n onLayout={(e) => {\n setWidth(e.nativeEvent.layout.width)\n progressProps.onLayout?.(e)\n }}\n ref={forwardedRef}\n />\n </ProgressProvider>\n )\n }\n )\n ),\n {\n Indicator: ProgressIndicator,\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\nexport { createProgressScope, Progress, ProgressIndicator }\nexport type { ProgressProps, ProgressIndicatorProps }\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAkF;AAClF,4BAA0C;AAC1C,oBAA4C;AAC5C,YAAuB;AAGvB,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,uBAAuB,8CAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,sBACvB,sBAA4C,aAAa;AAM3D,MAAM,iBAAiB;AAKhB,MAAM,yBAAyB,wBAAO,8BAAgB;AAAA,EAC3D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAChB,CAAC;AAED,MAAM,oBAAoB,uBAAuB,YAC/C,MAAM,WACJ,CAAC,OAA4C,iBAAiB;AAC5D,QAA+C,YAAvC,sBAAuC,IAAnB,2BAAmB,IAAnB,CAApB;AACR,QAAM,UAAU,mBAAmB,gBAAgB,eAAe;AAClE,QAAM,MAAM,QAAQ,MAAO,SAAQ,SAAS;AAC5C,QAAM,IAAI,CAAC,QAAQ,QAAS,OAAM;AAClC,SACE,oCAAC;AAAA,IACC,cAAY,iBAAiB,QAAQ,OAAO,QAAQ,GAAG;AAAA,IACvD,cAAY,QAAQ,SAAS;AAAA,IAC7B,YAAU,QAAQ;AAAA,IAClB;AAAA,IACA,OAAO,QAAQ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;AACtD,QAAI,aAAa,QAAQ,CAAC,mBAAmB,WAAW,GAAG,GAAG;AAC5D,aAAO,IAAI,MAAM,qBAAqB,QAAQ,aAAa,CAAC;AAAA,IAC9D;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/Progress.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { getSize, getVariableValue, styled, withStaticProperties } from "@tamagui/core";
|
|
4
2
|
import { createContextScope } from "@tamagui/create-context";
|
|
5
3
|
import { ThemeableStack } from "@tamagui/stacks";
|
|
@@ -34,27 +32,21 @@ ProgressIndicator.displayName = INDICATOR_NAME;
|
|
|
34
32
|
function defaultGetValueLabel(value, max) {
|
|
35
33
|
return `${Math.round(value / max * 100)}%`;
|
|
36
34
|
}
|
|
37
|
-
__name(defaultGetValueLabel, "defaultGetValueLabel");
|
|
38
35
|
function getProgressState(value, maxValue) {
|
|
39
36
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
40
37
|
}
|
|
41
|
-
__name(getProgressState, "getProgressState");
|
|
42
38
|
function isNumber(value) {
|
|
43
39
|
return typeof value === "number";
|
|
44
40
|
}
|
|
45
|
-
__name(isNumber, "isNumber");
|
|
46
41
|
function isValidMaxNumber(max) {
|
|
47
42
|
return isNumber(max) && !isNaN(max) && max > 0;
|
|
48
43
|
}
|
|
49
|
-
__name(isValidMaxNumber, "isValidMaxNumber");
|
|
50
44
|
function isValidValueNumber(value, max) {
|
|
51
45
|
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
52
46
|
}
|
|
53
|
-
__name(isValidValueNumber, "isValidValueNumber");
|
|
54
47
|
function getInvalidMaxError(propValue, componentName) {
|
|
55
48
|
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
56
49
|
}
|
|
57
|
-
__name(getInvalidMaxError, "getInvalidMaxError");
|
|
58
50
|
function getInvalidValueError(propValue, componentName) {
|
|
59
51
|
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
60
52
|
- a positive number
|
|
@@ -63,7 +55,6 @@ function getInvalidValueError(propValue, componentName) {
|
|
|
63
55
|
|
|
64
56
|
Defaulting to \`null\`.`;
|
|
65
57
|
}
|
|
66
|
-
__name(getInvalidValueError, "getInvalidValueError");
|
|
67
58
|
const DEFAULT_MAX = 100;
|
|
68
59
|
const ProgressFrame = styled(ThemeableStack, {
|
|
69
60
|
name: PROGRESS_NAME,
|
package/dist/esm/Progress.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Progress.tsx"],
|
|
4
4
|
"sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx\n\nimport { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst PROGRESS_NAME = 'Progress'\n\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)\ntype ProgressContextValue = { value: number | null; max: number; width: number }\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator'\n\ntype ProgressIndicatorElement = TamaguiElement\ninterface ProgressIndicatorProps extends YStackProps {}\n\nexport const ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\n backgrounded: true,\n})\n\nconst ProgressIndicator = ProgressIndicatorFrame.extractable(\n React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {\n const { __scopeProgress, ...indicatorProps } = props\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress)\n const pct = context.max - (context.value ?? 0)\n const x = -context.width * (pct / 100)\n return (\n <ProgressIndicatorFrame\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n x={x}\n width={context.width}\n {...indicatorProps}\n ref={forwardedRef}\n />\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\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst DEFAULT_MAX = 100\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope }\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading'\n\ntype TamaguiElement = HTMLElement | View\n\ntype ProgressElement = TamaguiElement\n\nexport const ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n backgrounded: true,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = Math.round(getVariableValue(getSize(val)) * 0.25)\n return {\n height: size,\n minWidth: getVariableValue(size) * 20,\n width: '100%',\n }\n },\n },\n },\n})\n\ntype ProgressProps = GetProps<typeof ProgressFrame> & {\n value?: number | null | undefined\n max?: number\n getValueLabel?(value: number, max: number): string\n}\n\nconst Progress = withStaticProperties(\n ProgressFrame.extractable(\n React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n size = '$4',\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 const [width, setWidth] = React.useState(0)\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>\n <ProgressFrame\n size={size}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n // @ts-ignore\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n onLayout={(e) => {\n setWidth(e.nativeEvent.layout.width)\n progressProps.onLayout?.(e)\n }}\n ref={forwardedRef}\n />\n </ProgressProvider>\n )\n }\n )\n ),\n {\n Indicator: ProgressIndicator,\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\nexport { createProgressScope, Progress, ProgressIndicator }\nexport type { ProgressProps, ProgressIndicatorProps }\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAGA;AACA;AACA;AACA;AAGA,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,uBAAuB,mBAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,sBACvB,sBAA4C,aAAa;AAM3D,MAAM,iBAAiB;AAKhB,MAAM,yBAAyB,OAAO,gBAAgB;AAAA,EAC3D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAChB,CAAC;AAED,MAAM,oBAAoB,uBAAuB,YAC/C,MAAM,WACJ,CAAC,OAA4C,iBAAiB;AAlClE;AAmCM,QAAM,EAAE,oBAAoB,mBAAmB;AAC/C,QAAM,UAAU,mBAAmB,gBAAgB,eAAe;AAClE,QAAM,MAAM,QAAQ,MAAO,eAAQ,UAAR,YAAiB;AAC5C,QAAM,IAAI,CAAC,QAAQ,QAAS,OAAM;AAClC,SACE,oCAAC;AAAA,IACC,cAAY,iBAAiB,QAAQ,OAAO,QAAQ,GAAG;AAAA,IACvD,cAAY,cAAQ,UAAR,YAAiB;AAAA,IAC7B,YAAU,QAAQ;AAAA,IAClB;AAAA,IACA,OAAO,QAAQ;AAAA,IACd,GAAG;AAAA,IACJ,KAAK;AAAA,GACP;AAEJ,CACF,CACF;AAEA,kBAAkB,cAAc;AAIhC,8BAA8B,OAAe,KAAa;AACxD,SA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|
package/dist/jsx/Progress.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { getSize, getVariableValue, styled, withStaticProperties } from "@tamagui/core";
|
|
4
2
|
import { createContextScope } from "@tamagui/create-context";
|
|
5
3
|
import { ThemeableStack } from "@tamagui/stacks";
|
|
@@ -26,27 +24,21 @@ ProgressIndicator.displayName = INDICATOR_NAME;
|
|
|
26
24
|
function defaultGetValueLabel(value, max) {
|
|
27
25
|
return `${Math.round(value / max * 100)}%`;
|
|
28
26
|
}
|
|
29
|
-
__name(defaultGetValueLabel, "defaultGetValueLabel");
|
|
30
27
|
function getProgressState(value, maxValue) {
|
|
31
28
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
32
29
|
}
|
|
33
|
-
__name(getProgressState, "getProgressState");
|
|
34
30
|
function isNumber(value) {
|
|
35
31
|
return typeof value === "number";
|
|
36
32
|
}
|
|
37
|
-
__name(isNumber, "isNumber");
|
|
38
33
|
function isValidMaxNumber(max) {
|
|
39
34
|
return isNumber(max) && !isNaN(max) && max > 0;
|
|
40
35
|
}
|
|
41
|
-
__name(isValidMaxNumber, "isValidMaxNumber");
|
|
42
36
|
function isValidValueNumber(value, max) {
|
|
43
37
|
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
44
38
|
}
|
|
45
|
-
__name(isValidValueNumber, "isValidValueNumber");
|
|
46
39
|
function getInvalidMaxError(propValue, componentName) {
|
|
47
40
|
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
48
41
|
}
|
|
49
|
-
__name(getInvalidMaxError, "getInvalidMaxError");
|
|
50
42
|
function getInvalidValueError(propValue, componentName) {
|
|
51
43
|
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
52
44
|
- a positive number
|
|
@@ -55,7 +47,6 @@ function getInvalidValueError(propValue, componentName) {
|
|
|
55
47
|
|
|
56
48
|
Defaulting to \`null\`.`;
|
|
57
49
|
}
|
|
58
|
-
__name(getInvalidValueError, "getInvalidValueError");
|
|
59
50
|
const DEFAULT_MAX = 100;
|
|
60
51
|
const ProgressFrame = styled(ThemeableStack, {
|
|
61
52
|
name: PROGRESS_NAME,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/progress",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.75",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"clean:build": "tamagui-build clean:build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
25
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
26
|
-
"@tamagui/create-context": "^1.0.1-beta.
|
|
27
|
-
"@tamagui/stacks": "^1.0.1-beta.
|
|
24
|
+
"@tamagui/compose-refs": "^1.0.1-beta.75",
|
|
25
|
+
"@tamagui/core": "^1.0.1-beta.75",
|
|
26
|
+
"@tamagui/create-context": "^1.0.1-beta.75",
|
|
27
|
+
"@tamagui/stacks": "^1.0.1-beta.75"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "*",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-native": "*"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
35
|
+
"@tamagui/build": "^1.0.1-beta.75",
|
|
36
36
|
"@types/react-native": "^0.67.3",
|
|
37
37
|
"react": "*",
|
|
38
38
|
"react-dom": "*",
|