@tamagui/progress 1.46.2 → 1.47.0
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/package.json +7 -7
- package/dist/jsx/Progress.mjs +0 -148
- package/dist/jsx/Progress.mjs.map +0 -6
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/progress",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/compose-refs": "1.
|
|
35
|
-
"@tamagui/core": "1.
|
|
36
|
-
"@tamagui/create-context": "1.
|
|
37
|
-
"@tamagui/get-token": "1.
|
|
38
|
-
"@tamagui/stacks": "1.
|
|
34
|
+
"@tamagui/compose-refs": "1.47.0",
|
|
35
|
+
"@tamagui/core": "1.47.0",
|
|
36
|
+
"@tamagui/create-context": "1.47.0",
|
|
37
|
+
"@tamagui/get-token": "1.47.0",
|
|
38
|
+
"@tamagui/stacks": "1.47.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "*",
|
|
42
42
|
"react-native": "*"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tamagui/build": "1.
|
|
45
|
+
"@tamagui/build": "1.47.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-native": "^0.72.1"
|
|
48
48
|
},
|
package/dist/jsx/Progress.mjs
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { getVariableValue, styled, withStaticProperties } from "@tamagui/core";
|
|
2
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
3
|
-
import { getSize } from "@tamagui/get-token";
|
|
4
|
-
import { ThemeableStack } from "@tamagui/stacks";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
const PROGRESS_NAME = "Progress";
|
|
7
|
-
const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
|
|
8
|
-
const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
9
|
-
const INDICATOR_NAME = "ProgressIndicator";
|
|
10
|
-
const ProgressIndicatorFrame = styled(ThemeableStack, {
|
|
11
|
-
name: INDICATOR_NAME,
|
|
12
|
-
height: "100%",
|
|
13
|
-
width: "100%",
|
|
14
|
-
backgrounded: true
|
|
15
|
-
});
|
|
16
|
-
const ProgressIndicator = ProgressIndicatorFrame.extractable(
|
|
17
|
-
React.forwardRef(
|
|
18
|
-
(props, forwardedRef) => {
|
|
19
|
-
const { __scopeProgress, ...indicatorProps } = props;
|
|
20
|
-
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
21
|
-
const pct = context.max - (context.value ?? 0);
|
|
22
|
-
const x = -context.width * (pct / 100);
|
|
23
|
-
return <ProgressIndicatorFrame
|
|
24
|
-
data-state={getProgressState(context.value, context.max)}
|
|
25
|
-
data-value={context.value ?? void 0}
|
|
26
|
-
data-max={context.max}
|
|
27
|
-
x={x}
|
|
28
|
-
width={context.width}
|
|
29
|
-
{...indicatorProps}
|
|
30
|
-
ref={forwardedRef}
|
|
31
|
-
/>;
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
);
|
|
35
|
-
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
36
|
-
function defaultGetValueLabel(value, max) {
|
|
37
|
-
return `${Math.round(value / max * 100)}%`;
|
|
38
|
-
}
|
|
39
|
-
function getProgressState(value, maxValue) {
|
|
40
|
-
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
41
|
-
}
|
|
42
|
-
function isNumber(value) {
|
|
43
|
-
return typeof value === "number";
|
|
44
|
-
}
|
|
45
|
-
function isValidMaxNumber(max) {
|
|
46
|
-
return isNumber(max) && !isNaN(max) && max > 0;
|
|
47
|
-
}
|
|
48
|
-
function isValidValueNumber(value, max) {
|
|
49
|
-
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
50
|
-
}
|
|
51
|
-
function getInvalidMaxError(propValue, componentName) {
|
|
52
|
-
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
53
|
-
}
|
|
54
|
-
function getInvalidValueError(propValue, componentName) {
|
|
55
|
-
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
56
|
-
- a positive number
|
|
57
|
-
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
58
|
-
- \`null\` if the progress is indeterminate.
|
|
59
|
-
|
|
60
|
-
Defaulting to \`null\`.`;
|
|
61
|
-
}
|
|
62
|
-
const DEFAULT_MAX = 100;
|
|
63
|
-
const ProgressFrame = styled(ThemeableStack, {
|
|
64
|
-
name: PROGRESS_NAME,
|
|
65
|
-
borderRadius: 1e5,
|
|
66
|
-
overflow: "hidden",
|
|
67
|
-
backgrounded: true,
|
|
68
|
-
variants: {
|
|
69
|
-
size: {
|
|
70
|
-
"...size": (val) => {
|
|
71
|
-
const size = Math.round(getVariableValue(getSize(val)) * 0.25);
|
|
72
|
-
return {
|
|
73
|
-
height: size,
|
|
74
|
-
minWidth: getVariableValue(size) * 20,
|
|
75
|
-
width: "100%"
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const Progress = withStaticProperties(
|
|
82
|
-
ProgressFrame.extractable(
|
|
83
|
-
React.forwardRef(
|
|
84
|
-
(props, forwardedRef) => {
|
|
85
|
-
const {
|
|
86
|
-
__scopeProgress,
|
|
87
|
-
value: valueProp,
|
|
88
|
-
max: maxProp,
|
|
89
|
-
getValueLabel = defaultGetValueLabel,
|
|
90
|
-
size = "$true",
|
|
91
|
-
...progressProps
|
|
92
|
-
} = props;
|
|
93
|
-
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
94
|
-
const value = isValidValueNumber(valueProp, max) ? valueProp : null;
|
|
95
|
-
const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
96
|
-
const [width, setWidth] = React.useState(0);
|
|
97
|
-
return <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}><ProgressFrame
|
|
98
|
-
size={size}
|
|
99
|
-
aria-valuemax={max}
|
|
100
|
-
aria-valuemin={0}
|
|
101
|
-
aria-valuenow={isNumber(value) ? value : void 0}
|
|
102
|
-
aria-valuetext={valueLabel}
|
|
103
|
-
role="progressbar"
|
|
104
|
-
data-state={getProgressState(value, max)}
|
|
105
|
-
data-value={value ?? void 0}
|
|
106
|
-
data-max={max}
|
|
107
|
-
{...progressProps}
|
|
108
|
-
onLayout={(e) => {
|
|
109
|
-
setWidth(e.nativeEvent.layout.width);
|
|
110
|
-
progressProps.onLayout?.(e);
|
|
111
|
-
}}
|
|
112
|
-
ref={forwardedRef}
|
|
113
|
-
/></ProgressProvider>;
|
|
114
|
-
}
|
|
115
|
-
)
|
|
116
|
-
),
|
|
117
|
-
{
|
|
118
|
-
Indicator: ProgressIndicator
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
Progress.displayName = PROGRESS_NAME;
|
|
122
|
-
Progress.propTypes = {
|
|
123
|
-
max(props, propName, componentName) {
|
|
124
|
-
const propValue = props[propName];
|
|
125
|
-
const strVal = String(propValue);
|
|
126
|
-
if (propValue && !isValidMaxNumber(propValue)) {
|
|
127
|
-
return new Error(getInvalidMaxError(strVal, componentName));
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
},
|
|
131
|
-
value(props, propName, componentName) {
|
|
132
|
-
const valueProp = props[propName];
|
|
133
|
-
const strVal = String(valueProp);
|
|
134
|
-
const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
|
|
135
|
-
if (valueProp != null && !isValidValueNumber(valueProp, max)) {
|
|
136
|
-
return new Error(getInvalidValueError(strVal, componentName));
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
export {
|
|
142
|
-
Progress,
|
|
143
|
-
ProgressFrame,
|
|
144
|
-
ProgressIndicator,
|
|
145
|
-
ProgressIndicatorFrame,
|
|
146
|
-
createProgressScope
|
|
147
|
-
};
|
|
148
|
-
//# sourceMappingURL=Progress.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Progress.tsx"],
|
|
4
|
-
"mappings": "AAGA,SAAmB,kBAAkB,QAAQ,4BAA4B;AACzE,SAAgB,0BAA0B;AAC1C,SAAS,eAAe;AACxB,SAAS,sBAAmC;AAC5C,YAAY,WAAW;AAGvB,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,mBAAmB,IAAI,mBAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,kBAAkB,IACzC,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;AAAA,EAC/C,MAAM;AAAA,IACJ,CAAC,OAA4C,iBAAiB;AAC5D,YAAM,EAAE,iBAAiB,GAAG,eAAe,IAAI;AAC/C,YAAM,UAAU,mBAAmB,gBAAgB,eAAe;AAClE,YAAM,MAAM,QAAQ,OAAO,QAAQ,SAAS;AAC5C,YAAM,IAAI,CAAC,QAAQ,SAAS,MAAM;AAClC,aACE,CAAC;AAAA,QACC,YAAY,iBAAiB,QAAQ,OAAO,QAAQ,GAAG;AAAA,QACvD,YAAY,QA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