@hanzogui/progress 3.0.2 → 7.0.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 +13 -13
- package/src/Progress.tsx +2 -2
- package/types/Progress.d.ts +36 -36
- package/dist/cjs/Progress.cjs +0 -171
- package/dist/cjs/Progress.native.js +0 -178
- package/dist/cjs/Progress.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -18
- package/dist/cjs/index.native.js +0 -21
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/esm/Progress.mjs +0 -144
- package/dist/esm/Progress.mjs.map +0 -1
- package/dist/esm/Progress.native.js +0 -148
- package/dist/esm/Progress.native.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -2
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/Progress.mjs +0 -144
- package/dist/jsx/Progress.mjs.map +0 -1
- package/dist/jsx/Progress.native.js +0 -178
- package/dist/jsx/Progress.native.js.map +0 -1
- package/dist/jsx/index.js +0 -2
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/index.native.js +0 -21
- package/dist/jsx/index.native.js.map +0 -1
package/dist/esm/Progress.mjs
DELETED
|
@@ -1,144 +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
|
-
[createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME),
|
|
10
|
-
[ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
|
|
11
|
-
INDICATOR_NAME = "ProgressIndicator",
|
|
12
|
-
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.HANZO_GUI_HEADLESS === "1"
|
|
25
|
-
}
|
|
26
|
-
}),
|
|
27
|
-
ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
|
|
28
|
-
const {
|
|
29
|
-
__scopeProgress,
|
|
30
|
-
transition,
|
|
31
|
-
...indicatorProps
|
|
32
|
-
} = props,
|
|
33
|
-
context = useProgressContext(INDICATOR_NAME, __scopeProgress),
|
|
34
|
-
progressRatio = (context.value ?? 0) / context.max;
|
|
35
|
-
let x;
|
|
36
|
-
if (isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
37
|
-
const baseWidth = context.width || 0;
|
|
38
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
39
|
-
}
|
|
40
|
-
return /* @__PURE__ */jsx(ProgressIndicatorFrame, {
|
|
41
|
-
"data-state": getProgressState(context.value, context.max),
|
|
42
|
-
"data-value": context.value ?? void 0,
|
|
43
|
-
"data-max": context.max,
|
|
44
|
-
x,
|
|
45
|
-
width: "200%",
|
|
46
|
-
...(!props.unstyled && {
|
|
47
|
-
animateOnly: ["transform"],
|
|
48
|
-
// on native, hide until we have width measurement
|
|
49
|
-
...(!isWeb && context.width === 0 && {
|
|
50
|
-
opacity: 0
|
|
51
|
-
})
|
|
52
|
-
}),
|
|
53
|
-
...indicatorProps,
|
|
54
|
-
ref: forwardedRef,
|
|
55
|
-
transition: !isWeb && !context.width ? null : transition
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
function defaultGetValueLabel(value, max) {
|
|
59
|
-
return `${Math.round(value / max * 100)}%`;
|
|
60
|
-
}
|
|
61
|
-
function getProgressState(value, maxValue) {
|
|
62
|
-
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
63
|
-
}
|
|
64
|
-
function isNumber(value) {
|
|
65
|
-
return typeof value == "number";
|
|
66
|
-
}
|
|
67
|
-
function isValidMaxNumber(max) {
|
|
68
|
-
return isNumber(max) && !Number.isNaN(max) && max > 0;
|
|
69
|
-
}
|
|
70
|
-
function isValidValueNumber(value, max) {
|
|
71
|
-
return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
|
|
72
|
-
}
|
|
73
|
-
const DEFAULT_MAX = 100,
|
|
74
|
-
ProgressFrame = styled(YStack, {
|
|
75
|
-
name: "Progress",
|
|
76
|
-
variants: {
|
|
77
|
-
unstyled: {
|
|
78
|
-
false: {
|
|
79
|
-
borderRadius: 1e5,
|
|
80
|
-
overflow: "hidden",
|
|
81
|
-
backgroundColor: "$background"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
size: {
|
|
85
|
-
"...size": val => {
|
|
86
|
-
const size = Math.round(getVariableValue(getSize(val)) * 0.25);
|
|
87
|
-
return {
|
|
88
|
-
height: size,
|
|
89
|
-
minWidth: getVariableValue(size) * 20,
|
|
90
|
-
width: "100%"
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
defaultVariants: {
|
|
96
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
Progress = withStaticProperties(ProgressFrame.styleable(function (props, forwardedRef) {
|
|
100
|
-
const {
|
|
101
|
-
// @ts-expect-error
|
|
102
|
-
__scopeProgress,
|
|
103
|
-
value: valueProp,
|
|
104
|
-
max: maxProp,
|
|
105
|
-
getValueLabel = defaultGetValueLabel,
|
|
106
|
-
size = "$true",
|
|
107
|
-
...progressProps
|
|
108
|
-
} = props,
|
|
109
|
-
max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
|
|
110
|
-
value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null,
|
|
111
|
-
valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
|
|
112
|
-
[width, setWidth] = useState(0);
|
|
113
|
-
return /* @__PURE__ */jsx(ProgressProvider, {
|
|
114
|
-
scope: __scopeProgress,
|
|
115
|
-
value,
|
|
116
|
-
max,
|
|
117
|
-
width,
|
|
118
|
-
children: /* @__PURE__ */jsx(ProgressFrame, {
|
|
119
|
-
"aria-valuemax": max,
|
|
120
|
-
"aria-valuemin": 0,
|
|
121
|
-
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
122
|
-
"aria-valuetext": valueLabel,
|
|
123
|
-
role: "progressbar",
|
|
124
|
-
"data-state": getProgressState(value, max),
|
|
125
|
-
"data-value": value ?? void 0,
|
|
126
|
-
"data-max": max,
|
|
127
|
-
...(progressProps.unstyled !== !0 && {
|
|
128
|
-
size
|
|
129
|
-
}),
|
|
130
|
-
...progressProps,
|
|
131
|
-
...(!isWeb && {
|
|
132
|
-
onLayout: e => {
|
|
133
|
-
const newWidth = Math.round(e.nativeEvent.layout.width);
|
|
134
|
-
newWidth !== width && setWidth(newWidth), progressProps.onLayout?.(e);
|
|
135
|
-
}
|
|
136
|
-
}),
|
|
137
|
-
ref: forwardedRef
|
|
138
|
-
})
|
|
139
|
-
});
|
|
140
|
-
}), {
|
|
141
|
-
Indicator: ProgressIndicator
|
|
142
|
-
});
|
|
143
|
-
export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
|
|
144
|
-
//# 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","HANZO_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","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;EAEhB,CAACC,qBAAA,EAAuBC,mBAAmB,IAAIR,kBAAA,CAAmBM,aAAa;EAQ/E,CAACG,gBAAA,EAAkBC,kBAAkB,IACzCH,qBAAA,CAA4CD,aAAa;EAMrDK,cAAA,GAAiB;EAEVC,sBAAA,GAAyBb,MAAA,CAAOI,MAAA,EAAQ;IACnDU,IAAA,EAAMF,cAAA;IAENG,QAAA,EAAU;MACRC,QAAA,EAAU;QACRC,KAAA,EAAO;UACLC,MAAA,EAAQ;UACRC,KAAA,EAAO;UACPC,eAAA,EAAiB;QACnB;MACF;IACF;IAEAC,eAAA,EAAiB;MACfL,QAAA,EAAUM,OAAA,CAAQC,GAAA,CAAIC,kBAAA,KAAuB;IAC/C;EACF,CAAC;EAIKC,iBAAA,GAAoBZ,sBAAA,CAAuBa,SAAA,CAAU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@ -1,148 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getVariableValue, isWeb, styled } from "@hanzogui/core";
|
|
3
|
-
import { createContextScope } from "@hanzogui/create-context";
|
|
4
|
-
import { getSize } from "@hanzogui/get-token";
|
|
5
|
-
import { withStaticProperties } from "@hanzogui/helpers";
|
|
6
|
-
import { YStack } from "@hanzogui/stacks";
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
var PROGRESS_NAME = "Progress",
|
|
9
|
-
[createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME),
|
|
10
|
-
[ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
|
|
11
|
-
INDICATOR_NAME = "ProgressIndicator",
|
|
12
|
-
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.HANZO_GUI_HEADLESS === "1"
|
|
25
|
-
}
|
|
26
|
-
}),
|
|
27
|
-
ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
|
|
28
|
-
var {
|
|
29
|
-
__scopeProgress,
|
|
30
|
-
transition,
|
|
31
|
-
...indicatorProps
|
|
32
|
-
} = props,
|
|
33
|
-
context = useProgressContext(INDICATOR_NAME, __scopeProgress),
|
|
34
|
-
_context_value,
|
|
35
|
-
progressRatio = ((_context_value = context.value) !== null && _context_value !== void 0 ? _context_value : 0) / context.max,
|
|
36
|
-
x;
|
|
37
|
-
if (isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
38
|
-
var baseWidth = context.width || 0;
|
|
39
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
40
|
-
}
|
|
41
|
-
var _context_value1;
|
|
42
|
-
return /* @__PURE__ */_jsx(ProgressIndicatorFrame, {
|
|
43
|
-
"data-state": getProgressState(context.value, context.max),
|
|
44
|
-
"data-value": (_context_value1 = context.value) !== null && _context_value1 !== void 0 ? _context_value1 : 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
|
-
var DEFAULT_MAX = 100,
|
|
76
|
-
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": function (val) {
|
|
88
|
-
var 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.HANZO_GUI_HEADLESS === "1"
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
Progress = withStaticProperties(ProgressFrame.styleable(function (props, forwardedRef) {
|
|
102
|
-
var {
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
__scopeProgress,
|
|
105
|
-
value: valueProp,
|
|
106
|
-
max: maxProp,
|
|
107
|
-
getValueLabel = defaultGetValueLabel,
|
|
108
|
-
size = "$true",
|
|
109
|
-
...progressProps
|
|
110
|
-
} = props,
|
|
111
|
-
max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
|
|
112
|
-
value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null,
|
|
113
|
-
valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
|
|
114
|
-
[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
|
-
// @ts-ignore
|
|
126
|
-
role: "progressbar",
|
|
127
|
-
"data-state": getProgressState(value, max),
|
|
128
|
-
"data-value": value ?? void 0,
|
|
129
|
-
"data-max": max,
|
|
130
|
-
...(progressProps.unstyled !== !0 && {
|
|
131
|
-
size
|
|
132
|
-
}),
|
|
133
|
-
...progressProps,
|
|
134
|
-
...(!isWeb && {
|
|
135
|
-
onLayout: function (e) {
|
|
136
|
-
var _progressProps_onLayout,
|
|
137
|
-
newWidth = Math.round(e.nativeEvent.layout.width);
|
|
138
|
-
newWidth !== width && setWidth(newWidth), (_progressProps_onLayout = progressProps.onLayout) === null || _progressProps_onLayout === void 0 || _progressProps_onLayout.call(progressProps, e);
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
141
|
-
ref: forwardedRef
|
|
142
|
-
})
|
|
143
|
-
});
|
|
144
|
-
}), {
|
|
145
|
-
Indicator: ProgressIndicator
|
|
146
|
-
});
|
|
147
|
-
export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
|
|
148
|
-
//# sourceMappingURL=Progress.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","getVariableValue","isWeb","styled","createContextScope","getSize","withStaticProperties","YStack","useState","PROGRESS_NAME","createProgressContext","createProgressScope","ProgressProvider","useProgressContext","INDICATOR_NAME","ProgressIndicatorFrame","name","variants","unstyled","false","height","width","backgroundColor","defaultVariants","process","env","HANZO_GUI_HEADLESS","ProgressIndicator","styleable","props","forwardedRef","__scopeProgress","transition","indicatorProps","context","_context_value","progressRatio","value","max","x","baseWidth","Math","ceil","_context_value1","getProgressState","animateOnly","opacity","ref","defaultGetValueLabel","round","maxValue","isNumber","isValidMaxNumber","Number","isNaN","isValidValueNumber","DEFAULT_MAX","ProgressFrame","borderRadius","overflow","size","...size","val","minWidth","Progress","valueProp","maxProp","getValueLabel","progressProps","valueLabel","setWidth","scope","children","role","onLayout","e","_progressProps_onLayout","newWidth","nativeEvent","layout","call"],"sources":["../../src/Progress.tsx"],"sourcesContent":[null],"mappings":"AAIA,SAASA,GAAA,IAAAC,IAAA,QAAkB,mBAAO;AAElC,SAASC,gBAAA,EAAAC,KAAA,EAAAC,MAA0B;AACnC,SAASC,kBAAe;AACxB,SAASC,OAAA,8BAA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ACF,EAAAD,KAAA;QAAA,UACI,EAAAC,GAAA;QAAA,IACH8B,aAAc,CAAAlD,QAAA;UAAA0C;QAEX;QACA,GAAAQ,aAAI;QAGsB,KAC5BlE,KAAA;UACFwE,QAAA,WAAAA,CAAAC,CAAA;YACA,IAAKC,uBAAA;cAAAC,QAAA,GAAApC,IAAA,CAAAQ,KAAA,CAAA0B,CAAA,CAAAG,WAAA,CAAAC,MAAA,CAAA1D,KAAA;YAAAwD,QAAA,KAAAxD,KAAA,IAAAiD,QAAA,CAAAO,QAAA,IAAAD,uBAAA,GAAAR,aAAA,CAAAM,QAAA,cAAAE,uBAAA,eAAAA,uBAAA,CAAAI,IAAA,CAAAZ,aAAA,EAAAO,CAAA;UAET;QAEH;QACD5B,GAAA,EAAAjB;MACE;IACF;EACF","ignoreList":[]}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/dist/esm/index.mjs
DELETED
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/dist/esm/index.native.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/dist/jsx/Progress.mjs
DELETED
|
@@ -1,144 +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
|
-
[createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME),
|
|
10
|
-
[ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
|
|
11
|
-
INDICATOR_NAME = "ProgressIndicator",
|
|
12
|
-
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.HANZO_GUI_HEADLESS === "1"
|
|
25
|
-
}
|
|
26
|
-
}),
|
|
27
|
-
ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
|
|
28
|
-
const {
|
|
29
|
-
__scopeProgress,
|
|
30
|
-
transition,
|
|
31
|
-
...indicatorProps
|
|
32
|
-
} = props,
|
|
33
|
-
context = useProgressContext(INDICATOR_NAME, __scopeProgress),
|
|
34
|
-
progressRatio = (context.value ?? 0) / context.max;
|
|
35
|
-
let x;
|
|
36
|
-
if (isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
37
|
-
const baseWidth = context.width || 0;
|
|
38
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
39
|
-
}
|
|
40
|
-
return /* @__PURE__ */jsx(ProgressIndicatorFrame, {
|
|
41
|
-
"data-state": getProgressState(context.value, context.max),
|
|
42
|
-
"data-value": context.value ?? void 0,
|
|
43
|
-
"data-max": context.max,
|
|
44
|
-
x,
|
|
45
|
-
width: "200%",
|
|
46
|
-
...(!props.unstyled && {
|
|
47
|
-
animateOnly: ["transform"],
|
|
48
|
-
// on native, hide until we have width measurement
|
|
49
|
-
...(!isWeb && context.width === 0 && {
|
|
50
|
-
opacity: 0
|
|
51
|
-
})
|
|
52
|
-
}),
|
|
53
|
-
...indicatorProps,
|
|
54
|
-
ref: forwardedRef,
|
|
55
|
-
transition: !isWeb && !context.width ? null : transition
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
function defaultGetValueLabel(value, max) {
|
|
59
|
-
return `${Math.round(value / max * 100)}%`;
|
|
60
|
-
}
|
|
61
|
-
function getProgressState(value, maxValue) {
|
|
62
|
-
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
63
|
-
}
|
|
64
|
-
function isNumber(value) {
|
|
65
|
-
return typeof value == "number";
|
|
66
|
-
}
|
|
67
|
-
function isValidMaxNumber(max) {
|
|
68
|
-
return isNumber(max) && !Number.isNaN(max) && max > 0;
|
|
69
|
-
}
|
|
70
|
-
function isValidValueNumber(value, max) {
|
|
71
|
-
return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
|
|
72
|
-
}
|
|
73
|
-
const DEFAULT_MAX = 100,
|
|
74
|
-
ProgressFrame = styled(YStack, {
|
|
75
|
-
name: "Progress",
|
|
76
|
-
variants: {
|
|
77
|
-
unstyled: {
|
|
78
|
-
false: {
|
|
79
|
-
borderRadius: 1e5,
|
|
80
|
-
overflow: "hidden",
|
|
81
|
-
backgroundColor: "$background"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
size: {
|
|
85
|
-
"...size": val => {
|
|
86
|
-
const size = Math.round(getVariableValue(getSize(val)) * 0.25);
|
|
87
|
-
return {
|
|
88
|
-
height: size,
|
|
89
|
-
minWidth: getVariableValue(size) * 20,
|
|
90
|
-
width: "100%"
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
defaultVariants: {
|
|
96
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
Progress = withStaticProperties(ProgressFrame.styleable(function (props, forwardedRef) {
|
|
100
|
-
const {
|
|
101
|
-
// @ts-expect-error
|
|
102
|
-
__scopeProgress,
|
|
103
|
-
value: valueProp,
|
|
104
|
-
max: maxProp,
|
|
105
|
-
getValueLabel = defaultGetValueLabel,
|
|
106
|
-
size = "$true",
|
|
107
|
-
...progressProps
|
|
108
|
-
} = props,
|
|
109
|
-
max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
|
|
110
|
-
value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null,
|
|
111
|
-
valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
|
|
112
|
-
[width, setWidth] = useState(0);
|
|
113
|
-
return /* @__PURE__ */jsx(ProgressProvider, {
|
|
114
|
-
scope: __scopeProgress,
|
|
115
|
-
value,
|
|
116
|
-
max,
|
|
117
|
-
width,
|
|
118
|
-
children: /* @__PURE__ */jsx(ProgressFrame, {
|
|
119
|
-
"aria-valuemax": max,
|
|
120
|
-
"aria-valuemin": 0,
|
|
121
|
-
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
122
|
-
"aria-valuetext": valueLabel,
|
|
123
|
-
role: "progressbar",
|
|
124
|
-
"data-state": getProgressState(value, max),
|
|
125
|
-
"data-value": value ?? void 0,
|
|
126
|
-
"data-max": max,
|
|
127
|
-
...(progressProps.unstyled !== !0 && {
|
|
128
|
-
size
|
|
129
|
-
}),
|
|
130
|
-
...progressProps,
|
|
131
|
-
...(!isWeb && {
|
|
132
|
-
onLayout: e => {
|
|
133
|
-
const newWidth = Math.round(e.nativeEvent.layout.width);
|
|
134
|
-
newWidth !== width && setWidth(newWidth), progressProps.onLayout?.(e);
|
|
135
|
-
}
|
|
136
|
-
}),
|
|
137
|
-
ref: forwardedRef
|
|
138
|
-
})
|
|
139
|
-
});
|
|
140
|
-
}), {
|
|
141
|
-
Indicator: ProgressIndicator
|
|
142
|
-
});
|
|
143
|
-
export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
|
|
144
|
-
//# 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","HANZO_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","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;EAEhB,CAACC,qBAAA,EAAuBC,mBAAmB,IAAIR,kBAAA,CAAmBM,aAAa;EAQ/E,CAACG,gBAAA,EAAkBC,kBAAkB,IACzCH,qBAAA,CAA4CD,aAAa;EAMrDK,cAAA,GAAiB;EAEVC,sBAAA,GAAyBb,MAAA,CAAOI,MAAA,EAAQ;IACnDU,IAAA,EAAMF,cAAA;IAENG,QAAA,EAAU;MACRC,QAAA,EAAU;QACRC,KAAA,EAAO;UACLC,MAAA,EAAQ;UACRC,KAAA,EAAO;UACPC,eAAA,EAAiB;QACnB;MACF;IACF;IAEAC,eAAA,EAAiB;MACfL,QAAA,EAAUM,OAAA,CAAQ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A,EAAKf;MAAA,CACP;IAAA,CACF;EAEJ,CAAC,GACD;IACE8C,SAAA,EAAWjD;EACb,CACF","ignoreList":[]}
|
|
@@ -1,178 +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: !0
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: !0
|
|
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_jsx_runtime = require("react/jsx-runtime"),
|
|
33
|
-
import_gui_core = require("@hanzogui/core"),
|
|
34
|
-
import_gui_create_context = require("@hanzogui/create-context"),
|
|
35
|
-
import_gui_get_token = require("@hanzogui/get-token"),
|
|
36
|
-
import_gui_helpers = require("@hanzogui/helpers"),
|
|
37
|
-
import_gui_stacks = require("@hanzogui/stacks"),
|
|
38
|
-
import_react = require("react"),
|
|
39
|
-
PROGRESS_NAME = "Progress",
|
|
40
|
-
[createProgressContext, createProgressScope] = (0, import_gui_create_context.createContextScope)(PROGRESS_NAME),
|
|
41
|
-
[ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
|
|
42
|
-
INDICATOR_NAME = "ProgressIndicator",
|
|
43
|
-
ProgressIndicatorFrame = (0, import_gui_core.styled)(import_gui_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.HANZO_GUI_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_gui_core.isWeb) x = `${-100 + progressRatio * 50}%`;else {
|
|
69
|
-
var baseWidth = context.width || 0;
|
|
70
|
-
x = Math.ceil(-baseWidth * (2 - progressRatio));
|
|
71
|
-
}
|
|
72
|
-
var _context_value1;
|
|
73
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ProgressIndicatorFrame, {
|
|
74
|
-
"data-state": getProgressState(context.value, context.max),
|
|
75
|
-
"data-value": (_context_value1 = context.value) !== null && _context_value1 !== void 0 ? _context_value1 : 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_gui_core.isWeb && context.width === 0 && {
|
|
83
|
-
opacity: 0
|
|
84
|
-
})
|
|
85
|
-
}),
|
|
86
|
-
...indicatorProps,
|
|
87
|
-
ref: forwardedRef,
|
|
88
|
-
transition: !import_gui_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
|
-
var DEFAULT_MAX = 100,
|
|
107
|
-
ProgressFrame = (0, import_gui_core.styled)(import_gui_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": function (val) {
|
|
119
|
-
var size = Math.round((0, import_gui_core.getVariableValue)((0, import_gui_get_token.getSize)(val)) * 0.25);
|
|
120
|
-
return {
|
|
121
|
-
height: size,
|
|
122
|
-
minWidth: (0, import_gui_core.getVariableValue)(size) * 20,
|
|
123
|
-
width: "100%"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
defaultVariants: {
|
|
129
|
-
unstyled: process.env.HANZO_GUI_HEADLESS === "1"
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
|
-
Progress = (0, import_gui_helpers.withStaticProperties)(ProgressFrame.styleable(function (props, forwardedRef) {
|
|
133
|
-
var {
|
|
134
|
-
// @ts-expect-error
|
|
135
|
-
__scopeProgress,
|
|
136
|
-
value: valueProp,
|
|
137
|
-
max: maxProp,
|
|
138
|
-
getValueLabel = defaultGetValueLabel,
|
|
139
|
-
size = "$true",
|
|
140
|
-
...progressProps
|
|
141
|
-
} = props,
|
|
142
|
-
max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
|
|
143
|
-
value = isValidValueNumber(valueProp, max) ? Math.round(valueProp) : null,
|
|
144
|
-
valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
|
|
145
|
-
[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
|
-
// @ts-ignore
|
|
157
|
-
role: "progressbar",
|
|
158
|
-
"data-state": getProgressState(value, max),
|
|
159
|
-
"data-value": value ?? void 0,
|
|
160
|
-
"data-max": max,
|
|
161
|
-
...(progressProps.unstyled !== !0 && {
|
|
162
|
-
size
|
|
163
|
-
}),
|
|
164
|
-
...progressProps,
|
|
165
|
-
...(!import_gui_core.isWeb && {
|
|
166
|
-
onLayout: function (e) {
|
|
167
|
-
var _progressProps_onLayout,
|
|
168
|
-
newWidth = Math.round(e.nativeEvent.layout.width);
|
|
169
|
-
newWidth !== width && setWidth(newWidth), (_progressProps_onLayout = progressProps.onLayout) === null || _progressProps_onLayout === void 0 || _progressProps_onLayout.call(progressProps, e);
|
|
170
|
-
}
|
|
171
|
-
}),
|
|
172
|
-
ref: forwardedRef
|
|
173
|
-
})
|
|
174
|
-
});
|
|
175
|
-
}), {
|
|
176
|
-
Indicator: ProgressIndicator
|
|
177
|
-
});
|
|
178
|
-
//# sourceMappingURL=Progress.native.js.map
|