@tamagui/progress 2.7.7-1788328229285 → 3.0.0-beta.1091.1

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