@tamagui/progress 2.0.0-rc.4 → 2.0.0-rc.40-1776053246040
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.cjs +138 -131
- package/dist/cjs/Progress.native.js +141 -134
- package/dist/cjs/Progress.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Progress.mjs +118 -113
- package/dist/esm/Progress.mjs.map +1 -1
- package/dist/esm/Progress.native.js +122 -117
- package/dist/esm/Progress.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/Progress.mjs +118 -113
- package/dist/jsx/Progress.mjs.map +1 -1
- package/dist/jsx/Progress.native.js +141 -134
- package/dist/jsx/Progress.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/package.json +12 -15
- package/dist/cjs/Progress.js +0 -146
- package/dist/cjs/Progress.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Progress.js +0 -136
- package/dist/esm/Progress.js.map +0 -6
- package/dist/jsx/Progress.js +0 -136
- package/dist/jsx/Progress.js.map +0 -6
package/dist/cjs/Progress.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var Progress_exports = {};
|
|
22
24
|
__export(Progress_exports, {
|
|
@@ -27,63 +29,65 @@ __export(Progress_exports, {
|
|
|
27
29
|
createProgressScope: () => createProgressScope
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(Progress_exports);
|
|
30
|
-
var import_core = require("@tamagui/core")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const PROGRESS_NAME = "Progress"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
32
|
+
var import_core = require("@tamagui/core");
|
|
33
|
+
var import_create_context = require("@tamagui/create-context");
|
|
34
|
+
var import_get_token = require("@tamagui/get-token");
|
|
35
|
+
var import_helpers = require("@tamagui/helpers");
|
|
36
|
+
var import_stacks = require("@tamagui/stacks");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
+
const PROGRESS_NAME = "Progress";
|
|
40
|
+
const [createProgressContext, createProgressScope] = (0, import_create_context.createContextScope)(PROGRESS_NAME);
|
|
41
|
+
const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
42
|
+
const INDICATOR_NAME = "ProgressIndicator";
|
|
43
|
+
const ProgressIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
44
|
+
name: INDICATOR_NAME,
|
|
45
|
+
variants: {
|
|
46
|
+
unstyled: {
|
|
47
|
+
false: {
|
|
48
|
+
height: "100%",
|
|
49
|
+
width: "100%",
|
|
50
|
+
backgroundColor: "$background"
|
|
50
51
|
}
|
|
51
|
-
},
|
|
52
|
-
defaultVariants: {
|
|
53
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
56
|
-
ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
|
|
57
|
-
const {
|
|
58
|
-
__scopeProgress,
|
|
59
|
-
transition,
|
|
60
|
-
...indicatorProps
|
|
61
|
-
} = props,
|
|
62
|
-
context = useProgressContext(INDICATOR_NAME, __scopeProgress),
|
|
63
|
-
progressRatio = (context.value ?? 0) / context.max;
|
|
64
|
-
let x;
|
|
65
|
-
if (import_core.isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
66
|
-
const baseWidth = context.width || 0;
|
|
67
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
68
52
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const ProgressIndicator = ProgressIndicatorFrame.styleable(function ProgressIndicator2(props, forwardedRef) {
|
|
59
|
+
const {
|
|
60
|
+
__scopeProgress,
|
|
61
|
+
transition,
|
|
62
|
+
...indicatorProps
|
|
63
|
+
} = props;
|
|
64
|
+
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
65
|
+
const progressRatio = (context.value ?? 0) / context.max;
|
|
66
|
+
let x;
|
|
67
|
+
if (import_core.isWeb) {
|
|
68
|
+
x = `${-100 + progressRatio * 50}%`;
|
|
69
|
+
} else {
|
|
70
|
+
const baseWidth = context.width || 0;
|
|
71
|
+
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressIndicatorFrame, {
|
|
74
|
+
"data-state": getProgressState(context.value, context.max),
|
|
75
|
+
"data-value": context.value ?? void 0,
|
|
76
|
+
"data-max": context.max,
|
|
77
|
+
x,
|
|
78
|
+
width: "200%",
|
|
79
|
+
...(!props.unstyled && {
|
|
80
|
+
animateOnly: ["transform"],
|
|
81
|
+
// on native, hide until we have width measurement
|
|
82
|
+
...(!import_core.isWeb && context.width === 0 && {
|
|
83
|
+
opacity: 0
|
|
84
|
+
})
|
|
85
|
+
}),
|
|
86
|
+
...indicatorProps,
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
transition: !import_core.isWeb && !context.width ? null : transition
|
|
86
89
|
});
|
|
90
|
+
});
|
|
87
91
|
function defaultGetValueLabel(value, max) {
|
|
88
92
|
return `${Math.round(value / max * 100)}%`;
|
|
89
93
|
}
|
|
@@ -91,7 +95,7 @@ function getProgressState(value, maxValue) {
|
|
|
91
95
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
92
96
|
}
|
|
93
97
|
function isNumber(value) {
|
|
94
|
-
return typeof value
|
|
98
|
+
return typeof value === "number";
|
|
95
99
|
}
|
|
96
100
|
function isValidMaxNumber(max) {
|
|
97
101
|
return isNumber(max) && !Number.isNaN(max) && max > 0;
|
|
@@ -99,73 +103,76 @@ function isValidMaxNumber(max) {
|
|
|
99
103
|
function isValidValueNumber(value, max) {
|
|
100
104
|
return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
|
|
101
105
|
}
|
|
102
|
-
const DEFAULT_MAX = 100
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
size: {
|
|
114
|
-
"...size": val => {
|
|
115
|
-
const size = Math.round((0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) * 0.25);
|
|
116
|
-
return {
|
|
117
|
-
height: size,
|
|
118
|
-
minWidth: (0, import_core.getVariableValue)(size) * 20,
|
|
119
|
-
width: "100%"
|
|
120
|
-
};
|
|
121
|
-
}
|
|
106
|
+
const DEFAULT_MAX = 100;
|
|
107
|
+
const ProgressFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
108
|
+
name: "Progress",
|
|
109
|
+
variants: {
|
|
110
|
+
unstyled: {
|
|
111
|
+
false: {
|
|
112
|
+
borderRadius: 1e5,
|
|
113
|
+
overflow: "hidden",
|
|
114
|
+
backgroundColor: "$background"
|
|
122
115
|
}
|
|
123
116
|
},
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
size: {
|
|
118
|
+
"...size": val => {
|
|
119
|
+
const size = Math.round((0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) * 0.25);
|
|
120
|
+
return {
|
|
121
|
+
height: size,
|
|
122
|
+
minWidth: (0, import_core.getVariableValue)(size) * 20,
|
|
123
|
+
width: "100%"
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
126
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
127
|
+
},
|
|
128
|
+
defaultVariants: {
|
|
129
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const Progress = (0, import_helpers.withStaticProperties)(ProgressFrame.styleable(function Progress2(props, forwardedRef) {
|
|
133
|
+
const {
|
|
134
|
+
// @ts-expect-error
|
|
135
|
+
__scopeProgress,
|
|
136
|
+
value: valueProp,
|
|
137
|
+
max: maxProp,
|
|
138
|
+
getValueLabel = defaultGetValueLabel,
|
|
139
|
+
size = "$true",
|
|
140
|
+
...progressProps
|
|
141
|
+
} = props;
|
|
142
|
+
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
143
|
+
const value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null;
|
|
144
|
+
const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
145
|
+
const [width, setWidth] = (0, import_react.useState)(0);
|
|
146
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressProvider, {
|
|
147
|
+
scope: __scopeProgress,
|
|
148
|
+
value,
|
|
149
|
+
max,
|
|
150
|
+
width,
|
|
151
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressFrame, {
|
|
152
|
+
"aria-valuemax": max,
|
|
153
|
+
"aria-valuemin": 0,
|
|
154
|
+
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
155
|
+
"aria-valuetext": valueLabel,
|
|
156
|
+
role: "progressbar",
|
|
157
|
+
"data-state": getProgressState(value, max),
|
|
158
|
+
"data-value": value ?? void 0,
|
|
159
|
+
"data-max": max,
|
|
160
|
+
...(progressProps.unstyled !== true && {
|
|
161
|
+
size
|
|
162
|
+
}),
|
|
163
|
+
...progressProps,
|
|
164
|
+
...(!import_core.isWeb && {
|
|
165
|
+
onLayout: e => {
|
|
166
|
+
const newWidth = Math.round(e.nativeEvent.layout.width);
|
|
167
|
+
if (newWidth !== width) {
|
|
168
|
+
setWidth(newWidth);
|
|
164
169
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
progressProps.onLayout?.(e);
|
|
171
|
+
}
|
|
172
|
+
}),
|
|
173
|
+
ref: forwardedRef
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
}), {
|
|
177
|
+
Indicator: ProgressIndicator
|
|
178
|
+
});
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var Progress_exports = {};
|
|
24
26
|
__export(Progress_exports, {
|
|
@@ -29,65 +31,67 @@ __export(Progress_exports, {
|
|
|
29
31
|
createProgressScope: () => createProgressScope
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(Progress_exports);
|
|
32
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_core = require("@tamagui/core");
|
|
36
|
+
var import_create_context = require("@tamagui/create-context");
|
|
37
|
+
var import_get_token = require("@tamagui/get-token");
|
|
38
|
+
var import_helpers = require("@tamagui/helpers");
|
|
39
|
+
var import_stacks = require("@tamagui/stacks");
|
|
40
|
+
var import_react = require("react");
|
|
41
|
+
var PROGRESS_NAME = "Progress";
|
|
42
|
+
var [createProgressContext, createProgressScope] = (0, import_create_context.createContextScope)(PROGRESS_NAME);
|
|
43
|
+
var [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
44
|
+
var INDICATOR_NAME = "ProgressIndicator";
|
|
45
|
+
var ProgressIndicatorFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
46
|
+
name: INDICATOR_NAME,
|
|
47
|
+
variants: {
|
|
48
|
+
unstyled: {
|
|
49
|
+
false: {
|
|
50
|
+
height: "100%",
|
|
51
|
+
width: "100%",
|
|
52
|
+
backgroundColor: "$background"
|
|
52
53
|
}
|
|
53
|
-
},
|
|
54
|
-
defaultVariants: {
|
|
55
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
|
|
59
|
-
var {
|
|
60
|
-
__scopeProgress,
|
|
61
|
-
transition,
|
|
62
|
-
...indicatorProps
|
|
63
|
-
} = props,
|
|
64
|
-
context = useProgressContext(INDICATOR_NAME, __scopeProgress),
|
|
65
|
-
_context_value,
|
|
66
|
-
progressRatio = ((_context_value = context.value) !== null && _context_value !== void 0 ? _context_value : 0) / context.max,
|
|
67
|
-
x;
|
|
68
|
-
if (import_core.isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
69
|
-
var baseWidth = context.width || 0;
|
|
70
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
71
54
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var ProgressIndicator = ProgressIndicatorFrame.styleable(function ProgressIndicator2(props, forwardedRef) {
|
|
61
|
+
var {
|
|
62
|
+
__scopeProgress,
|
|
63
|
+
transition,
|
|
64
|
+
...indicatorProps
|
|
65
|
+
} = props;
|
|
66
|
+
var context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
67
|
+
var _context_value;
|
|
68
|
+
var progressRatio = ((_context_value = context.value) !== null && _context_value !== void 0 ? _context_value : 0) / context.max;
|
|
69
|
+
var x;
|
|
70
|
+
if (import_core.isWeb) {
|
|
71
|
+
x = `${-100 + progressRatio * 50}%`;
|
|
72
|
+
} else {
|
|
73
|
+
var baseWidth = context.width || 0;
|
|
74
|
+
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
75
|
+
}
|
|
76
|
+
var _context_value1;
|
|
77
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressIndicatorFrame, {
|
|
78
|
+
"data-state": getProgressState(context.value, context.max),
|
|
79
|
+
"data-value": (_context_value1 = context.value) !== null && _context_value1 !== void 0 ? _context_value1 : void 0,
|
|
80
|
+
"data-max": context.max,
|
|
81
|
+
x,
|
|
82
|
+
width: "200%",
|
|
83
|
+
...(!props.unstyled && {
|
|
84
|
+
animateOnly: ["transform"],
|
|
85
|
+
// on native, hide until we have width measurement
|
|
86
|
+
...(!import_core.isWeb && context.width === 0 && {
|
|
87
|
+
opacity: 0
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
...indicatorProps,
|
|
91
|
+
ref: forwardedRef,
|
|
92
|
+
transition: !import_core.isWeb && !context.width ? null : transition
|
|
90
93
|
});
|
|
94
|
+
});
|
|
91
95
|
function defaultGetValueLabel(value, max) {
|
|
92
96
|
return `${Math.round(value / max * 100)}%`;
|
|
93
97
|
}
|
|
@@ -95,7 +99,7 @@ function getProgressState(value, maxValue) {
|
|
|
95
99
|
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
96
100
|
}
|
|
97
101
|
function isNumber(value) {
|
|
98
|
-
return typeof value
|
|
102
|
+
return typeof value === "number";
|
|
99
103
|
}
|
|
100
104
|
function isValidMaxNumber(max) {
|
|
101
105
|
return isNumber(max) && !Number.isNaN(max) && max > 0;
|
|
@@ -103,76 +107,79 @@ function isValidMaxNumber(max) {
|
|
|
103
107
|
function isValidValueNumber(value, max) {
|
|
104
108
|
return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
|
|
105
109
|
}
|
|
106
|
-
var DEFAULT_MAX = 100
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
size: {
|
|
118
|
-
"...size": function (val) {
|
|
119
|
-
var size = Math.round((0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) * 0.25);
|
|
120
|
-
return {
|
|
121
|
-
height: size,
|
|
122
|
-
minWidth: (0, import_core.getVariableValue)(size) * 20,
|
|
123
|
-
width: "100%"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
110
|
+
var DEFAULT_MAX = 100;
|
|
111
|
+
var ProgressFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
112
|
+
name: "Progress",
|
|
113
|
+
variants: {
|
|
114
|
+
unstyled: {
|
|
115
|
+
false: {
|
|
116
|
+
borderRadius: 1e5,
|
|
117
|
+
overflow: "hidden",
|
|
118
|
+
backgroundColor: "$background"
|
|
126
119
|
}
|
|
127
120
|
},
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
size: {
|
|
122
|
+
"...size": function (val) {
|
|
123
|
+
var size = Math.round((0, import_core.getVariableValue)((0, import_get_token.getSize)(val)) * 0.25);
|
|
124
|
+
return {
|
|
125
|
+
height: size,
|
|
126
|
+
minWidth: (0, import_core.getVariableValue)(size) * 20,
|
|
127
|
+
width: "100%"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
130
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
131
|
+
},
|
|
132
|
+
defaultVariants: {
|
|
133
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
var Progress = (0, import_helpers.withStaticProperties)(ProgressFrame.styleable(function Progress2(props, forwardedRef) {
|
|
137
|
+
var {
|
|
138
|
+
// @ts-expect-error
|
|
139
|
+
__scopeProgress,
|
|
140
|
+
value: valueProp,
|
|
141
|
+
max: maxProp,
|
|
142
|
+
getValueLabel = defaultGetValueLabel,
|
|
143
|
+
size = "$true",
|
|
144
|
+
...progressProps
|
|
145
|
+
} = props;
|
|
146
|
+
var max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
147
|
+
var value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null;
|
|
148
|
+
var valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
149
|
+
var [width, setWidth] = (0, import_react.useState)(0);
|
|
150
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressProvider, {
|
|
151
|
+
scope: __scopeProgress,
|
|
152
|
+
value,
|
|
153
|
+
max,
|
|
154
|
+
width,
|
|
155
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressFrame, {
|
|
156
|
+
"aria-valuemax": max,
|
|
157
|
+
"aria-valuemin": 0,
|
|
158
|
+
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
159
|
+
"aria-valuetext": valueLabel,
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
role: "progressbar",
|
|
162
|
+
"data-state": getProgressState(value, max),
|
|
163
|
+
"data-value": value !== null && value !== void 0 ? value : void 0,
|
|
164
|
+
"data-max": max,
|
|
165
|
+
...(progressProps.unstyled !== true && {
|
|
166
|
+
size
|
|
167
|
+
}),
|
|
168
|
+
...progressProps,
|
|
169
|
+
...(!import_core.isWeb && {
|
|
170
|
+
onLayout: function (e) {
|
|
171
|
+
var _progressProps_onLayout;
|
|
172
|
+
var newWidth = Math.round(e.nativeEvent.layout.width);
|
|
173
|
+
if (newWidth !== width) {
|
|
174
|
+
setWidth(newWidth);
|
|
170
175
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Indicator: ProgressIndicator
|
|
176
|
+
(_progressProps_onLayout = progressProps.onLayout) === null || _progressProps_onLayout === void 0 ? void 0 : _progressProps_onLayout.call(progressProps, e);
|
|
177
|
+
}
|
|
178
|
+
}),
|
|
179
|
+
ref: forwardedRef
|
|
180
|
+
})
|
|
177
181
|
});
|
|
182
|
+
}), {
|
|
183
|
+
Indicator: ProgressIndicator
|
|
184
|
+
});
|
|
178
185
|
//# sourceMappingURL=Progress.native.js.map
|