@hanzogui/progress 8.3.1 → 8.3.3

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.
@@ -1,178 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
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, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), 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_core = require("@hanzogui/core");
33
- var import_create_context = require("@hanzogui/create-context");
34
- var import_get_token = require("@hanzogui/get-token");
35
- var import_helpers = require("@hanzogui/helpers");
36
- var import_stacks = require("@hanzogui/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"
51
- }
52
- }
53
- },
54
- defaultVariants: {
55
- unstyled: process.env.GUI_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
89
- });
90
- });
91
- function defaultGetValueLabel(value, max) {
92
- return `${Math.round(value / max * 100)}%`;
93
- }
94
- function getProgressState(value, maxValue) {
95
- return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
96
- }
97
- function isNumber(value) {
98
- return typeof value === "number";
99
- }
100
- function isValidMaxNumber(max) {
101
- return isNumber(max) && !Number.isNaN(max) && max > 0;
102
- }
103
- function isValidValueNumber(value, max) {
104
- return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
105
- }
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"
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.GUI_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);
169
- }
170
- progressProps.onLayout?.(e);
171
- }
172
- }),
173
- ref: forwardedRef
174
- })
175
- });
176
- }), {
177
- Indicator: ProgressIndicator
178
- });
@@ -1,185 +0,0 @@
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", {
23
- value: true
24
- }), mod);
25
- var Progress_exports = {};
26
- __export(Progress_exports, {
27
- Progress: () => Progress,
28
- ProgressFrame: () => ProgressFrame,
29
- ProgressIndicator: () => ProgressIndicator,
30
- ProgressIndicatorFrame: () => ProgressIndicatorFrame,
31
- createProgressScope: () => createProgressScope
32
- });
33
- module.exports = __toCommonJS(Progress_exports);
34
- var import_jsx_runtime = require("react/jsx-runtime");
35
- var import_core = require("@hanzogui/core");
36
- var import_create_context = require("@hanzogui/create-context");
37
- var import_get_token = require("@hanzogui/get-token");
38
- var import_helpers = require("@hanzogui/helpers");
39
- var import_stacks = require("@hanzogui/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"
53
- }
54
- }
55
- },
56
- defaultVariants: {
57
- unstyled: process.env.GUI_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
93
- });
94
- });
95
- function defaultGetValueLabel(value, max) {
96
- return `${Math.round(value / max * 100)}%`;
97
- }
98
- function getProgressState(value, maxValue) {
99
- return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
100
- }
101
- function isNumber(value) {
102
- return typeof value === "number";
103
- }
104
- function isValidMaxNumber(max) {
105
- return isNumber(max) && !Number.isNaN(max) && max > 0;
106
- }
107
- function isValidValueNumber(value, max) {
108
- return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
109
- }
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"
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.GUI_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
184
- });
185
- //# sourceMappingURL=Progress.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Progress_exports","__export","Progress","ProgressFrame","ProgressIndicator","ProgressIndicatorFrame","createProgressScope","module","exports","import_jsx_runtime","require","import_core","import_create_context","import_get_token","import_helpers","import_stacks","import_react","PROGRESS_NAME","createProgressContext","createContextScope","ProgressProvider","useProgressContext","INDICATOR_NAME","styled","YStack","name","variants","unstyled","false","height","width","backgroundColor","defaultVariants","process","env","GUI_HEADLESS","styleable","ProgressIndicator2","props","forwardedRef","__scopeProgress","transition","indicatorProps","context","_context_value","progressRatio","max","x","isWeb","baseWidth","Math","ceil","_context_value1","jsx","getProgressState","animateOnly","opacity","ref","defaultGetValueLabel","round","maxValue","isNumber","isValidMaxNumber","Number","isNaN","isValidValueNumber","DEFAULT_MAX","borderRadius","overflow","size","...size","val","getVariableValue","getSize","minWidth","withStaticProperties","Progress2","valueProp","maxProp","getValueLabel","progressProps","valueLabel","setWidth","useState","scope","children","role","onLayout","e","_progressProps_onLayout","newWidth","nativeEvent","layout","call"],"sources":["../../src/Progress.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAIAC,MAAA,CAAAC,OAAA,GAAAb,YAAgD,CAAAK,gBAAA;AAEhD,IAAAS,kBA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E,QAAA;EAAA,OACC,eAAe,IAAA1E,kBAAA,CAAA4C,GAAA,EAAAjC,gBAAA;IAAAgE,KACf,EAAA5C,eAAe;IAAAzC,KACf;IAAyC+C,GAAA;IACzBhB,KAEhB;IAAKuD,QACL,iBAAY,IAAA5E,kBAA2B,CAAA4C,GAAA,EAAAlD,aAAA;MAAA,eACvC,EAAY2C,GAAA;MAAS,eACX;MAAA,eACL,EAAAe,QAAc,CAAA9D,KAAA,CAAa,GAAAA,KAAQ;MAAA,gBACtC,EAAAkF,UAAA;MAAA;MACFK,IACC,EAAG;MAAA,YACE,EAAAhC,gBAAS,CAAAvD,KAAA,EAAA+C,GAAA;MAAA,YACb,EAAU/C,KAAC,KAAM,QAAAA,KAAA,cAAAA,KAAA;MACf,YAAM+C,GAAA;MACN,IAAAkC,aAAI,CAAArD,QAAa,KAAO;QACtB0C;MAAiB;MAEnB,GAAAW,aAAA;MAA0B,KAC5BrE,WAAA,CAAAqC,KAAA;QACFuC,QAAA,WAAAA,CAAAC,CAAA;UACA,IAAKC,uBAAA;UAAA,IAAAC,QAAA,GAAAxC,IAAA,CAAAS,KAAA,CAAA6B,CAAA,CAAAG,WAAA,CAAAC,MAAA,CAAA9D,KAAA;UAET,IAAA4D,QAAA,KAAA5D,KAAA;YAEHoD,QAAA,CAAAQ,QAAA;UACD;UACE,CAAAD,uBAAW,GAAAT,aAAA,CAAAO,QAAA,cAAAE,uBAAA,uBAAAA,uBAAA,CAAAI,IAAA,CAAAb,aAAA,EAAAQ,CAAA;QACb;MACF","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
- get: () => from[key],
9
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
- });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: true
17
- }), mod);
18
- var index_exports = {};
19
- module.exports = __toCommonJS(index_exports);
20
- __reExport(index_exports, require("./Progress.cjs"), module.exports);
@@ -1,23 +0,0 @@
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 __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
15
- };
16
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
20
- var index_exports = {};
21
- module.exports = __toCommonJS(index_exports);
22
- __reExport(index_exports, require("./Progress.native.js"), module.exports);
23
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
@@ -1,149 +0,0 @@
1
- import { getVariableValue, isWeb, styled } from "@hanzogui/core";
2
- import { createContextScope } from "@hanzogui/create-context";
3
- import { getSize } from "@hanzogui/get-token";
4
- import { withStaticProperties } from "@hanzogui/helpers";
5
- import { YStack } from "@hanzogui/stacks";
6
- import { useState } from "react";
7
- import { jsx } from "react/jsx-runtime";
8
- const PROGRESS_NAME = "Progress";
9
- const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
10
- const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
11
- const INDICATOR_NAME = "ProgressIndicator";
12
- const ProgressIndicatorFrame = styled(YStack, {
13
- name: INDICATOR_NAME,
14
- variants: {
15
- unstyled: {
16
- false: {
17
- height: "100%",
18
- width: "100%",
19
- backgroundColor: "$background"
20
- }
21
- }
22
- },
23
- defaultVariants: {
24
- unstyled: process.env.GUI_HEADLESS === "1"
25
- }
26
- });
27
- const ProgressIndicator = ProgressIndicatorFrame.styleable(function ProgressIndicator2(props, forwardedRef) {
28
- const {
29
- __scopeProgress,
30
- transition,
31
- ...indicatorProps
32
- } = props;
33
- const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
34
- const progressRatio = (context.value ?? 0) / context.max;
35
- let x;
36
- if (isWeb) {
37
- x = `${-100 + progressRatio * 50}%`;
38
- } else {
39
- const baseWidth = context.width || 0;
40
- x = Math.ceil(-baseWidth * (2 - progressRatio));
41
- }
42
- return /* @__PURE__ */jsx(ProgressIndicatorFrame, {
43
- "data-state": getProgressState(context.value, context.max),
44
- "data-value": context.value ?? void 0,
45
- "data-max": context.max,
46
- x,
47
- width: "200%",
48
- ...(!props.unstyled && {
49
- animateOnly: ["transform"],
50
- // on native, hide until we have width measurement
51
- ...(!isWeb && context.width === 0 && {
52
- opacity: 0
53
- })
54
- }),
55
- ...indicatorProps,
56
- ref: forwardedRef,
57
- transition: !isWeb && !context.width ? null : transition
58
- });
59
- });
60
- function defaultGetValueLabel(value, max) {
61
- return `${Math.round(value / max * 100)}%`;
62
- }
63
- function getProgressState(value, maxValue) {
64
- return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
65
- }
66
- function isNumber(value) {
67
- return typeof value === "number";
68
- }
69
- function isValidMaxNumber(max) {
70
- return isNumber(max) && !Number.isNaN(max) && max > 0;
71
- }
72
- function isValidValueNumber(value, max) {
73
- return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
74
- }
75
- const DEFAULT_MAX = 100;
76
- const ProgressFrame = styled(YStack, {
77
- name: "Progress",
78
- variants: {
79
- unstyled: {
80
- false: {
81
- borderRadius: 1e5,
82
- overflow: "hidden",
83
- backgroundColor: "$background"
84
- }
85
- },
86
- size: {
87
- "...size": val => {
88
- const size = Math.round(getVariableValue(getSize(val)) * 0.25);
89
- return {
90
- height: size,
91
- minWidth: getVariableValue(size) * 20,
92
- width: "100%"
93
- };
94
- }
95
- }
96
- },
97
- defaultVariants: {
98
- unstyled: process.env.GUI_HEADLESS === "1"
99
- }
100
- });
101
- const Progress = withStaticProperties(ProgressFrame.styleable(function Progress2(props, forwardedRef) {
102
- const {
103
- // @ts-expect-error
104
- __scopeProgress,
105
- value: valueProp,
106
- max: maxProp,
107
- getValueLabel = defaultGetValueLabel,
108
- size = "$true",
109
- ...progressProps
110
- } = props;
111
- const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
112
- const value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null;
113
- const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
114
- const [width, setWidth] = useState(0);
115
- return /* @__PURE__ */jsx(ProgressProvider, {
116
- scope: __scopeProgress,
117
- value,
118
- max,
119
- width,
120
- children: /* @__PURE__ */jsx(ProgressFrame, {
121
- "aria-valuemax": max,
122
- "aria-valuemin": 0,
123
- "aria-valuenow": isNumber(value) ? value : void 0,
124
- "aria-valuetext": valueLabel,
125
- role: "progressbar",
126
- "data-state": getProgressState(value, max),
127
- "data-value": value ?? void 0,
128
- "data-max": max,
129
- ...(progressProps.unstyled !== true && {
130
- size
131
- }),
132
- ...progressProps,
133
- ...(!isWeb && {
134
- onLayout: e => {
135
- const newWidth = Math.round(e.nativeEvent.layout.width);
136
- if (newWidth !== width) {
137
- setWidth(newWidth);
138
- }
139
- progressProps.onLayout?.(e);
140
- }
141
- }),
142
- ref: forwardedRef
143
- })
144
- });
145
- }), {
146
- Indicator: ProgressIndicator
147
- });
148
- export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
149
- //# sourceMappingURL=Progress.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getVariableValue","isWeb","styled","createContextScope","getSize","withStaticProperties","YStack","useState","jsx","PROGRESS_NAME","createProgressContext","createProgressScope","ProgressProvider","useProgressContext","INDICATOR_NAME","ProgressIndicatorFrame","name","variants","unstyled","false","height","width","backgroundColor","defaultVariants","process","env","GUI_HEADLESS","ProgressIndicator","styleable","props","forwardedRef","__scopeProgress","transition","indicatorProps","context","progressRatio","value","max","x","baseWidth","Math","ceil","getProgressState","animateOnly","opacity","ref","defaultGetValueLabel","round","maxValue","isNumber","isValidMaxNumber","Number","isNaN","isValidValueNumber","DEFAULT_MAX","ProgressFrame","borderRadius","overflow","size","val","minWidth","Progress","Progress2","valueProp","maxProp","getValueLabel","progressProps","valueLabel","setWidth","scope","children","role","onLayout","e","newWidth","nativeEvent","layout","Indicator"],"sources":["../../src/Progress.tsx"],"sourcesContent":[null],"mappings":"AAIA,SAASA,gBAAA,EAAkBC,KAAA,EAAOC,MAAA,QAAc;AAEhD,SAASC,kBAAA,QAA0B;AACnC,SAASC,OAAA,QAAe;AACxB,SAASC,oBAAA,QAA4B;AACrC,SAASC,MAAA,QAAc;AACvB,SAASC,QAAA,QAAgB;AAoErB,SAAAC,GAAA;AAlEJ,MAAMC,aAAA,GAAgB;AAEtB,MAAM,CAACC,qBAAA,EAAuBC,mBAAmB,IAAIR,kBAAA,CAAmBM,aAAa;AAQrF,MAAM,CAACG,gB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