@tamagui/progress 1.0.1-beta.100
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.js +206 -0
- package/dist/cjs/Progress.js.map +7 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/Progress.js +178 -0
- package/dist/esm/Progress.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/jsx/Progress.js +117 -0
- package/dist/jsx/Progress.js.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +7 -0
- package/package.json +44 -0
- package/src/Progress.tsx +215 -0
- package/src/index.ts +1 -0
- package/types/Progress.d.ts +272 -0
- package/types/Progress.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
+
var Progress_exports = {};
|
|
51
|
+
__export(Progress_exports, {
|
|
52
|
+
Progress: () => Progress,
|
|
53
|
+
ProgressFrame: () => ProgressFrame,
|
|
54
|
+
ProgressIndicator: () => ProgressIndicator,
|
|
55
|
+
ProgressIndicatorFrame: () => ProgressIndicatorFrame,
|
|
56
|
+
createProgressScope: () => createProgressScope
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(Progress_exports);
|
|
59
|
+
var import_core = require("@tamagui/core");
|
|
60
|
+
var import_create_context = require("@tamagui/create-context");
|
|
61
|
+
var import_stacks = require("@tamagui/stacks");
|
|
62
|
+
var React = __toESM(require("react"));
|
|
63
|
+
const PROGRESS_NAME = "Progress";
|
|
64
|
+
const [createProgressContext, createProgressScope] = (0, import_create_context.createContextScope)(PROGRESS_NAME);
|
|
65
|
+
const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
66
|
+
const INDICATOR_NAME = "ProgressIndicator";
|
|
67
|
+
const ProgressIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
68
|
+
name: INDICATOR_NAME,
|
|
69
|
+
height: "100%",
|
|
70
|
+
width: "100%",
|
|
71
|
+
backgrounded: true
|
|
72
|
+
});
|
|
73
|
+
const ProgressIndicator = ProgressIndicatorFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
74
|
+
const _a = props, { __scopeProgress } = _a, indicatorProps = __objRest(_a, ["__scopeProgress"]);
|
|
75
|
+
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
76
|
+
const pct = context.max - (context.value ?? 0);
|
|
77
|
+
const x = -context.width * (pct / 100);
|
|
78
|
+
return /* @__PURE__ */ React.createElement(ProgressIndicatorFrame, __spreadProps(__spreadValues({
|
|
79
|
+
"data-state": getProgressState(context.value, context.max),
|
|
80
|
+
"data-value": context.value ?? void 0,
|
|
81
|
+
"data-max": context.max,
|
|
82
|
+
x,
|
|
83
|
+
width: context.width
|
|
84
|
+
}, indicatorProps), {
|
|
85
|
+
ref: forwardedRef
|
|
86
|
+
}));
|
|
87
|
+
}));
|
|
88
|
+
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
89
|
+
function defaultGetValueLabel(value, max) {
|
|
90
|
+
return `${Math.round(value / max * 100)}%`;
|
|
91
|
+
}
|
|
92
|
+
function getProgressState(value, maxValue) {
|
|
93
|
+
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
94
|
+
}
|
|
95
|
+
function isNumber(value) {
|
|
96
|
+
return typeof value === "number";
|
|
97
|
+
}
|
|
98
|
+
function isValidMaxNumber(max) {
|
|
99
|
+
return isNumber(max) && !isNaN(max) && max > 0;
|
|
100
|
+
}
|
|
101
|
+
function isValidValueNumber(value, max) {
|
|
102
|
+
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
103
|
+
}
|
|
104
|
+
function getInvalidMaxError(propValue, componentName) {
|
|
105
|
+
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
106
|
+
}
|
|
107
|
+
function getInvalidValueError(propValue, componentName) {
|
|
108
|
+
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
109
|
+
- a positive number
|
|
110
|
+
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
111
|
+
- \`null\` if the progress is indeterminate.
|
|
112
|
+
|
|
113
|
+
Defaulting to \`null\`.`;
|
|
114
|
+
}
|
|
115
|
+
const DEFAULT_MAX = 100;
|
|
116
|
+
const ProgressFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
117
|
+
name: PROGRESS_NAME,
|
|
118
|
+
borderRadius: 1e5,
|
|
119
|
+
overflow: "hidden",
|
|
120
|
+
backgrounded: true,
|
|
121
|
+
variants: {
|
|
122
|
+
size: {
|
|
123
|
+
"...size": (val) => {
|
|
124
|
+
const size = Math.round((0, import_core.getVariableValue)((0, import_core.getSize)(val)) * 0.25);
|
|
125
|
+
return {
|
|
126
|
+
height: size,
|
|
127
|
+
minWidth: (0, import_core.getVariableValue)(size) * 20,
|
|
128
|
+
width: "100%"
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const Progress = (0, import_core.withStaticProperties)(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
135
|
+
const _a = props, {
|
|
136
|
+
__scopeProgress,
|
|
137
|
+
value: valueProp,
|
|
138
|
+
max: maxProp,
|
|
139
|
+
getValueLabel = defaultGetValueLabel,
|
|
140
|
+
size = "$4"
|
|
141
|
+
} = _a, progressProps = __objRest(_a, [
|
|
142
|
+
"__scopeProgress",
|
|
143
|
+
"value",
|
|
144
|
+
"max",
|
|
145
|
+
"getValueLabel",
|
|
146
|
+
"size"
|
|
147
|
+
]);
|
|
148
|
+
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
149
|
+
const value = isValidValueNumber(valueProp, max) ? valueProp : null;
|
|
150
|
+
const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
151
|
+
const [width, setWidth] = React.useState(0);
|
|
152
|
+
return /* @__PURE__ */ React.createElement(ProgressProvider, {
|
|
153
|
+
scope: __scopeProgress,
|
|
154
|
+
value,
|
|
155
|
+
max,
|
|
156
|
+
width
|
|
157
|
+
}, /* @__PURE__ */ React.createElement(ProgressFrame, __spreadProps(__spreadValues({
|
|
158
|
+
size,
|
|
159
|
+
"aria-valuemax": max,
|
|
160
|
+
"aria-valuemin": 0,
|
|
161
|
+
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
162
|
+
"aria-valuetext": valueLabel,
|
|
163
|
+
role: "progressbar",
|
|
164
|
+
"data-state": getProgressState(value, max),
|
|
165
|
+
"data-value": value ?? void 0,
|
|
166
|
+
"data-max": max
|
|
167
|
+
}, progressProps), {
|
|
168
|
+
onLayout: (e) => {
|
|
169
|
+
var _a2;
|
|
170
|
+
setWidth(e.nativeEvent.layout.width);
|
|
171
|
+
(_a2 = progressProps.onLayout) == null ? void 0 : _a2.call(progressProps, e);
|
|
172
|
+
},
|
|
173
|
+
ref: forwardedRef
|
|
174
|
+
})));
|
|
175
|
+
})), {
|
|
176
|
+
Indicator: ProgressIndicator
|
|
177
|
+
});
|
|
178
|
+
Progress.displayName = PROGRESS_NAME;
|
|
179
|
+
Progress.propTypes = {
|
|
180
|
+
max(props, propName, componentName) {
|
|
181
|
+
const propValue = props[propName];
|
|
182
|
+
const strVal = String(propValue);
|
|
183
|
+
if (propValue && !isValidMaxNumber(propValue)) {
|
|
184
|
+
return new Error(getInvalidMaxError(strVal, componentName));
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
188
|
+
value(props, propName, componentName) {
|
|
189
|
+
const valueProp = props[propName];
|
|
190
|
+
const strVal = String(valueProp);
|
|
191
|
+
const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
|
|
192
|
+
if (valueProp != null && !isValidValueNumber(valueProp, max)) {
|
|
193
|
+
return new Error(getInvalidValueError(strVal, componentName));
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
199
|
+
0 && (module.exports = {
|
|
200
|
+
Progress,
|
|
201
|
+
ProgressFrame,
|
|
202
|
+
ProgressIndicator,
|
|
203
|
+
ProgressIndicatorFrame,
|
|
204
|
+
createProgressScope
|
|
205
|
+
});
|
|
206
|
+
//# sourceMappingURL=Progress.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Progress.tsx"],
|
|
4
|
+
"sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx\n\nimport { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst PROGRESS_NAME = 'Progress'\n\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)\ntype ProgressContextValue = { value: number | null; max: number; width: number }\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator'\n\ntype ProgressIndicatorElement = TamaguiElement\ninterface ProgressIndicatorProps extends YStackProps {}\n\nexport const ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\n backgrounded: true,\n})\n\nconst ProgressIndicator = ProgressIndicatorFrame.extractable(\n React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {\n const { __scopeProgress, ...indicatorProps } = props\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress)\n const pct = context.max - (context.value ?? 0)\n const x = -context.width * (pct / 100)\n return (\n <ProgressIndicatorFrame\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n x={x}\n width={context.width}\n {...indicatorProps}\n ref={forwardedRef}\n />\n )\n }\n )\n)\n\nProgressIndicator.displayName = INDICATOR_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`\n}\n\nfunction getProgressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading'\n}\n\nfunction isNumber(value: any): value is number {\n return typeof value === 'number'\n}\n\nfunction isValidMaxNumber(max: any): max is number {\n // prettier-ignore\n return (\n isNumber(max) &&\n !isNaN(max) &&\n max > 0\n );\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n // prettier-ignore\n return (\n isNumber(value) &&\n !isNaN(value) &&\n value <= max &&\n value >= 0\n );\n}\n\n// Split this out for clearer readability of the error message.\nfunction getInvalidMaxError(propValue: string, componentName: string) {\n return `Invalid prop \\`max\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. Only numbers greater than 0 are valid max values. Defaulting to \\`${DEFAULT_MAX}\\`.`\n}\n\nfunction getInvalidValueError(propValue: string, componentName: string) {\n return `Invalid prop \\`value\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. The \\`value\\` prop must be:\n - a positive number\n - less than the value passed to \\`max\\` (or ${DEFAULT_MAX} if no \\`max\\` prop is set)\n - \\`null\\` if the progress is indeterminate.\n\nDefaulting to \\`null\\`.`\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst DEFAULT_MAX = 100\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope }\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading'\n\ntype TamaguiElement = HTMLElement | View\n\ntype ProgressElement = TamaguiElement\n\nexport const ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n backgrounded: true,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = Math.round(getVariableValue(getSize(val)) * 0.25)\n return {\n height: size,\n minWidth: getVariableValue(size) * 20,\n width: '100%',\n }\n },\n },\n },\n})\n\ntype ProgressProps = GetProps<typeof ProgressFrame> & {\n value?: number | null | undefined\n max?: number\n getValueLabel?(value: number, max: number): string\n}\n\nconst Progress = withStaticProperties(\n ProgressFrame.extractable(\n React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n size = '$4',\n ...progressProps\n } = props\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX\n const value = isValidValueNumber(valueProp, max) ? valueProp : null\n const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined\n const [width, setWidth] = React.useState(0)\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>\n <ProgressFrame\n size={size}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n // @ts-ignore\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n onLayout={(e) => {\n setWidth(e.nativeEvent.layout.width)\n progressProps.onLayout?.(e)\n }}\n ref={forwardedRef}\n />\n </ProgressProvider>\n )\n }\n )\n ),\n {\n Indicator: ProgressIndicator,\n }\n)\n\nProgress.displayName = PROGRESS_NAME\n\nProgress.propTypes = {\n max(props, propName, componentName) {\n const propValue = props[propName]\n const strVal = String(propValue)\n if (propValue && !isValidMaxNumber(propValue)) {\n return new Error(getInvalidMaxError(strVal, componentName))\n }\n return null\n },\n value(props, propName, componentName) {\n const valueProp = props[propName]\n const strVal = String(valueProp)\n const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX\n if (valueProp != null && !isValidValueNumber(valueProp, max)) {\n return new Error(getInvalidValueError(strVal, componentName))\n }\n return null\n },\n}\n\nexport { createProgressScope, Progress, ProgressIndicator }\nexport type { ProgressProps, ProgressIndicatorProps }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAkF;AAClF,4BAA0C;AAC1C,oBAA4C;AAC5C,YAAuB;AAGvB,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,uBAAuB,8CAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,sBACvB,sBAA4C,aAAa;AAM3D,MAAM,iBAAiB;AAKhB,MAAM,yBAAyB,wBAAO,8BAAgB;AAAA,EAC3D,MAA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A,IACA,KAAK;AAAA,IACP,CACF;AAEJ,CACF,CACF,GACA;AAAA,EACE,WAAW;AACb,CACF;AAEA,SAAS,cAAc;AAEvB,SAAS,YAAY;AAAA,EACnB,IAAI,OAAO,UAAU,eAAe;AAClC,UAAM,YAAY,MAAM;AACxB,UAAM,SAAS,OAAO,SAAS;AAC/B,QAAI,aAAa,CAAC,iBAAiB,SAAS,GAAG;AAC7C,aAAO,IAAI,MAAM,mBAAmB,QAAQ,aAAa,CAAC;AAAA,IAC5D;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,OAAO,UAAU,eAAe;AACpC,UAAM,YAAY,MAAM;AACxB,UAAM,SAAS,OAAO,SAAS;AAC/B,UAAM,MAAM,iBAAiB,MAAM,GAAG,IAAI,MAAM,MAAM;AACtD,QAAI,aAAa,QAAQ,CAAC,mBAAmB,WAAW,GAAG,GAAG;AAC5D,aAAO,IAAI,MAAM,qBAAqB,QAAQ,aAAa,CAAC;AAAA,IAC9D;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./Progress"), module.exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { getSize, getVariableValue, styled, withStaticProperties } from "@tamagui/core";
|
|
33
|
+
import { createContextScope } from "@tamagui/create-context";
|
|
34
|
+
import { ThemeableStack } from "@tamagui/stacks";
|
|
35
|
+
import * as React from "react";
|
|
36
|
+
const PROGRESS_NAME = "Progress";
|
|
37
|
+
const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
|
|
38
|
+
const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
39
|
+
const INDICATOR_NAME = "ProgressIndicator";
|
|
40
|
+
const ProgressIndicatorFrame = styled(ThemeableStack, {
|
|
41
|
+
name: INDICATOR_NAME,
|
|
42
|
+
height: "100%",
|
|
43
|
+
width: "100%",
|
|
44
|
+
backgrounded: true
|
|
45
|
+
});
|
|
46
|
+
const ProgressIndicator = ProgressIndicatorFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
47
|
+
const _a = props, { __scopeProgress } = _a, indicatorProps = __objRest(_a, ["__scopeProgress"]);
|
|
48
|
+
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
49
|
+
const pct = context.max - (context.value ?? 0);
|
|
50
|
+
const x = -context.width * (pct / 100);
|
|
51
|
+
return /* @__PURE__ */ React.createElement(ProgressIndicatorFrame, __spreadProps(__spreadValues({
|
|
52
|
+
"data-state": getProgressState(context.value, context.max),
|
|
53
|
+
"data-value": context.value ?? void 0,
|
|
54
|
+
"data-max": context.max,
|
|
55
|
+
x,
|
|
56
|
+
width: context.width
|
|
57
|
+
}, indicatorProps), {
|
|
58
|
+
ref: forwardedRef
|
|
59
|
+
}));
|
|
60
|
+
}));
|
|
61
|
+
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
62
|
+
function defaultGetValueLabel(value, max) {
|
|
63
|
+
return `${Math.round(value / max * 100)}%`;
|
|
64
|
+
}
|
|
65
|
+
function getProgressState(value, maxValue) {
|
|
66
|
+
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
67
|
+
}
|
|
68
|
+
function isNumber(value) {
|
|
69
|
+
return typeof value === "number";
|
|
70
|
+
}
|
|
71
|
+
function isValidMaxNumber(max) {
|
|
72
|
+
return isNumber(max) && !isNaN(max) && max > 0;
|
|
73
|
+
}
|
|
74
|
+
function isValidValueNumber(value, max) {
|
|
75
|
+
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
76
|
+
}
|
|
77
|
+
function getInvalidMaxError(propValue, componentName) {
|
|
78
|
+
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
79
|
+
}
|
|
80
|
+
function getInvalidValueError(propValue, componentName) {
|
|
81
|
+
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
82
|
+
- a positive number
|
|
83
|
+
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
84
|
+
- \`null\` if the progress is indeterminate.
|
|
85
|
+
|
|
86
|
+
Defaulting to \`null\`.`;
|
|
87
|
+
}
|
|
88
|
+
const DEFAULT_MAX = 100;
|
|
89
|
+
const ProgressFrame = styled(ThemeableStack, {
|
|
90
|
+
name: PROGRESS_NAME,
|
|
91
|
+
borderRadius: 1e5,
|
|
92
|
+
overflow: "hidden",
|
|
93
|
+
backgrounded: true,
|
|
94
|
+
variants: {
|
|
95
|
+
size: {
|
|
96
|
+
"...size": (val) => {
|
|
97
|
+
const size = Math.round(getVariableValue(getSize(val)) * 0.25);
|
|
98
|
+
return {
|
|
99
|
+
height: size,
|
|
100
|
+
minWidth: getVariableValue(size) * 20,
|
|
101
|
+
width: "100%"
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const Progress = withStaticProperties(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
108
|
+
const _a = props, {
|
|
109
|
+
__scopeProgress,
|
|
110
|
+
value: valueProp,
|
|
111
|
+
max: maxProp,
|
|
112
|
+
getValueLabel = defaultGetValueLabel,
|
|
113
|
+
size = "$4"
|
|
114
|
+
} = _a, progressProps = __objRest(_a, [
|
|
115
|
+
"__scopeProgress",
|
|
116
|
+
"value",
|
|
117
|
+
"max",
|
|
118
|
+
"getValueLabel",
|
|
119
|
+
"size"
|
|
120
|
+
]);
|
|
121
|
+
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
122
|
+
const value = isValidValueNumber(valueProp, max) ? valueProp : null;
|
|
123
|
+
const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
124
|
+
const [width, setWidth] = React.useState(0);
|
|
125
|
+
return /* @__PURE__ */ React.createElement(ProgressProvider, {
|
|
126
|
+
scope: __scopeProgress,
|
|
127
|
+
value,
|
|
128
|
+
max,
|
|
129
|
+
width
|
|
130
|
+
}, /* @__PURE__ */ React.createElement(ProgressFrame, __spreadProps(__spreadValues({
|
|
131
|
+
size,
|
|
132
|
+
"aria-valuemax": max,
|
|
133
|
+
"aria-valuemin": 0,
|
|
134
|
+
"aria-valuenow": isNumber(value) ? value : void 0,
|
|
135
|
+
"aria-valuetext": valueLabel,
|
|
136
|
+
role: "progressbar",
|
|
137
|
+
"data-state": getProgressState(value, max),
|
|
138
|
+
"data-value": value ?? void 0,
|
|
139
|
+
"data-max": max
|
|
140
|
+
}, progressProps), {
|
|
141
|
+
onLayout: (e) => {
|
|
142
|
+
var _a2;
|
|
143
|
+
setWidth(e.nativeEvent.layout.width);
|
|
144
|
+
(_a2 = progressProps.onLayout) == null ? void 0 : _a2.call(progressProps, e);
|
|
145
|
+
},
|
|
146
|
+
ref: forwardedRef
|
|
147
|
+
})));
|
|
148
|
+
})), {
|
|
149
|
+
Indicator: ProgressIndicator
|
|
150
|
+
});
|
|
151
|
+
Progress.displayName = PROGRESS_NAME;
|
|
152
|
+
Progress.propTypes = {
|
|
153
|
+
max(props, propName, componentName) {
|
|
154
|
+
const propValue = props[propName];
|
|
155
|
+
const strVal = String(propValue);
|
|
156
|
+
if (propValue && !isValidMaxNumber(propValue)) {
|
|
157
|
+
return new Error(getInvalidMaxError(strVal, componentName));
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
},
|
|
161
|
+
value(props, propName, componentName) {
|
|
162
|
+
const valueProp = props[propName];
|
|
163
|
+
const strVal = String(valueProp);
|
|
164
|
+
const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
|
|
165
|
+
if (valueProp != null && !isValidValueNumber(valueProp, max)) {
|
|
166
|
+
return new Error(getInvalidValueError(strVal, componentName));
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
export {
|
|
172
|
+
Progress,
|
|
173
|
+
ProgressFrame,
|
|
174
|
+
ProgressIndicator,
|
|
175
|
+
ProgressIndicatorFrame,
|
|
176
|
+
createProgressScope
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=Progress.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Progress.tsx"],
|
|
4
|
+
"sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx\n\nimport { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst PROGRESS_NAME = 'Progress'\n\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)\ntype ProgressContextValue = { value: number | null; max: number; width: number }\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator'\n\ntype ProgressIndicatorElement = TamaguiElement\ninterface ProgressIndicatorProps extends YStackProps {}\n\nexport const ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\n backgrounded: true,\n})\n\nconst ProgressIndicator = ProgressIndicatorFrame.extractable(\n React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {\n const { __scopeProgress, ...indicatorProps } = props\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress)\n const pct = context.max - (context.value ?? 0)\n const x = -context.width * (pct / 100)\n return (\n <ProgressIndicatorFrame\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n x={x}\n width={context.width}\n {...indicatorProps}\n ref={forwardedRef}\n />\n )\n }\n )\n)\n\nProgressIndicator.displayName = INDICATOR_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`\n}\n\nfunction getProgressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading'\n}\n\nfunction isNumber(value: any): value is number {\n return typeof value === 'number'\n}\n\nfunction isValidMaxNumber(max: any): max is number {\n // prettier-ignore\n return (\n isNumber(max) &&\n !isNaN(max) &&\n max > 0\n );\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n // prettier-ignore\n return (\n isNumber(value) &&\n !isNaN(value) &&\n value <= max &&\n value >= 0\n );\n}\n\n// Split this out for clearer readability of the error message.\nfunction getInvalidMaxError(propValue: string, componentName: string) {\n return `Invalid prop \\`max\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. Only numbers greater than 0 are valid max values. Defaulting to \\`${DEFAULT_MAX}\\`.`\n}\n\nfunction getInvalidValueError(propValue: string, componentName: string) {\n return `Invalid prop \\`value\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. The \\`value\\` prop must be:\n - a positive number\n - less than the value passed to \\`max\\` (or ${DEFAULT_MAX} if no \\`max\\` prop is set)\n - \\`null\\` if the progress is indeterminate.\n\nDefaulting to \\`null\\`.`\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst DEFAULT_MAX = 100\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope }\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading'\n\ntype TamaguiElement = HTMLElement | View\n\ntype ProgressElement = TamaguiElement\n\nexport const ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n backgrounded: true,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = Math.round(getVariableValue(getSize(val)) * 0.25)\n return {\n height: size,\n minWidth: getVariableValue(size) * 20,\n width: '100%',\n }\n },\n },\n },\n})\n\ntype ProgressProps = GetProps<typeof ProgressFrame> & {\n value?: number | null | undefined\n max?: number\n getValueLabel?(value: number, max: number): string\n}\n\nconst Progress = withStaticProperties(\n ProgressFrame.extractable(\n React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n size = '$4',\n ...progressProps\n } = props\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX\n const value = isValidValueNumber(valueProp, max) ? valueProp : null\n const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined\n const [width, setWidth] = React.useState(0)\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>\n <ProgressFrame\n size={size}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n // @ts-ignore\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n onLayout={(e) => {\n setWidth(e.nativeEvent.layout.width)\n progressProps.onLayout?.(e)\n }}\n ref={forwardedRef}\n />\n </ProgressProvider>\n )\n }\n )\n ),\n {\n Indicator: ProgressIndicator,\n }\n)\n\nProgress.displayName = PROGRESS_NAME\n\nProgress.propTypes = {\n max(props, propName, componentName) {\n const propValue = props[propName]\n const strVal = String(propValue)\n if (propValue && !isValidMaxNumber(propValue)) {\n return new Error(getInvalidMaxError(strVal, componentName))\n }\n return null\n },\n value(props, propName, componentName) {\n const valueProp = props[propName]\n const strVal = String(valueProp)\n const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX\n if (valueProp != null && !isValidValueNumber(valueProp, max)) {\n return new Error(getInvalidValueError(strVal, componentName))\n }\n return null\n },\n}\n\nexport { createProgressScope, Progress, ProgressIndicator }\nexport type { ProgressProps, ProgressIndicatorProps }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AAGA,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,uBAAuB,mBAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,sBACvB,sBAA4C,aAAa;AAM3D,MAAM,iBAAiB;AAKhB,MAAM,yBAAyB,OAAO,gBAAgB;AAAA,EAC3D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAChB,CAAC;AAED,MAAM,oBAAoB,uBAAuB,YAC/C,MAAM,WACJ,CAAC,OAA4C,iBAAiB;AAC5D,QAA+C,YAAvC,sBAAuC,IAAnB,2BAAmB,IAAnB,CAApB;AACR,QAAM,UAAU,mBAAmB,gBAAgB,eAAe;AAClE,QAAM,MAAM,QAAQ,MAAO,SAAQ,SAAS;AAC5C,QAAM,IAAI,CAAC,QAAQ,QAAS,OAAM;AAClC,SACE,oCAAC;AAAA,IACC,cAAY,iBAAiB,QAA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;AACpC,UAAM,YAAY,MAAM;AACxB,UAAM,SAAS,OAAO,SAAS;AAC/B,UAAM,MAAM,iBAAiB,MAAM,GAAG,IAAI,MAAM,MAAM;AACtD,QAAI,aAAa,QAAQ,CAAC,mBAAmB,WAAW,GAAG,GAAG;AAC5D,aAAO,IAAI,MAAM,qBAAqB,QAAQ,aAAa,CAAC;AAAA,IAC9D;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getSize, getVariableValue, styled, withStaticProperties } from "@tamagui/core";
|
|
2
|
+
import { createContextScope } from "@tamagui/create-context";
|
|
3
|
+
import { ThemeableStack } from "@tamagui/stacks";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
const PROGRESS_NAME = "Progress";
|
|
6
|
+
const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
|
|
7
|
+
const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
|
|
8
|
+
const INDICATOR_NAME = "ProgressIndicator";
|
|
9
|
+
const ProgressIndicatorFrame = styled(ThemeableStack, {
|
|
10
|
+
name: INDICATOR_NAME,
|
|
11
|
+
height: "100%",
|
|
12
|
+
width: "100%",
|
|
13
|
+
backgrounded: true
|
|
14
|
+
});
|
|
15
|
+
const ProgressIndicator = ProgressIndicatorFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const { __scopeProgress, ...indicatorProps } = props;
|
|
18
|
+
const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
|
|
19
|
+
const pct = context.max - ((_a = context.value) != null ? _a : 0);
|
|
20
|
+
const x = -context.width * (pct / 100);
|
|
21
|
+
return <ProgressIndicatorFrame data-state={getProgressState(context.value, context.max)} data-value={(_b = context.value) != null ? _b : void 0} data-max={context.max} x={x} width={context.width} {...indicatorProps} ref={forwardedRef} />;
|
|
22
|
+
}));
|
|
23
|
+
ProgressIndicator.displayName = INDICATOR_NAME;
|
|
24
|
+
function defaultGetValueLabel(value, max) {
|
|
25
|
+
return `${Math.round(value / max * 100)}%`;
|
|
26
|
+
}
|
|
27
|
+
function getProgressState(value, maxValue) {
|
|
28
|
+
return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
|
|
29
|
+
}
|
|
30
|
+
function isNumber(value) {
|
|
31
|
+
return typeof value === "number";
|
|
32
|
+
}
|
|
33
|
+
function isValidMaxNumber(max) {
|
|
34
|
+
return isNumber(max) && !isNaN(max) && max > 0;
|
|
35
|
+
}
|
|
36
|
+
function isValidValueNumber(value, max) {
|
|
37
|
+
return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
|
|
38
|
+
}
|
|
39
|
+
function getInvalidMaxError(propValue, componentName) {
|
|
40
|
+
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
|
|
41
|
+
}
|
|
42
|
+
function getInvalidValueError(propValue, componentName) {
|
|
43
|
+
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
44
|
+
- a positive number
|
|
45
|
+
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
46
|
+
- \`null\` if the progress is indeterminate.
|
|
47
|
+
|
|
48
|
+
Defaulting to \`null\`.`;
|
|
49
|
+
}
|
|
50
|
+
const DEFAULT_MAX = 100;
|
|
51
|
+
const ProgressFrame = styled(ThemeableStack, {
|
|
52
|
+
name: PROGRESS_NAME,
|
|
53
|
+
borderRadius: 1e5,
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
backgrounded: true,
|
|
56
|
+
variants: {
|
|
57
|
+
size: {
|
|
58
|
+
"...size": (val) => {
|
|
59
|
+
const size = Math.round(getVariableValue(getSize(val)) * 0.25);
|
|
60
|
+
return {
|
|
61
|
+
height: size,
|
|
62
|
+
minWidth: getVariableValue(size) * 20,
|
|
63
|
+
width: "100%"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const Progress = withStaticProperties(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
70
|
+
const {
|
|
71
|
+
__scopeProgress,
|
|
72
|
+
value: valueProp,
|
|
73
|
+
max: maxProp,
|
|
74
|
+
getValueLabel = defaultGetValueLabel,
|
|
75
|
+
size = "$4",
|
|
76
|
+
...progressProps
|
|
77
|
+
} = props;
|
|
78
|
+
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
|
|
79
|
+
const value = isValidValueNumber(valueProp, max) ? valueProp : null;
|
|
80
|
+
const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
|
|
81
|
+
const [width, setWidth] = React.useState(0);
|
|
82
|
+
return <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}><ProgressFrame size={size} aria-valuemax={max} aria-valuemin={0} aria-valuenow={isNumber(value) ? value : void 0} aria-valuetext={valueLabel} role="progressbar" data-state={getProgressState(value, max)} data-value={value != null ? value : void 0} data-max={max} {...progressProps} onLayout={(e) => {
|
|
83
|
+
var _a;
|
|
84
|
+
setWidth(e.nativeEvent.layout.width);
|
|
85
|
+
(_a = progressProps.onLayout) == null ? void 0 : _a.call(progressProps, e);
|
|
86
|
+
}} ref={forwardedRef} /></ProgressProvider>;
|
|
87
|
+
})), {
|
|
88
|
+
Indicator: ProgressIndicator
|
|
89
|
+
});
|
|
90
|
+
Progress.displayName = PROGRESS_NAME;
|
|
91
|
+
Progress.propTypes = {
|
|
92
|
+
max(props, propName, componentName) {
|
|
93
|
+
const propValue = props[propName];
|
|
94
|
+
const strVal = String(propValue);
|
|
95
|
+
if (propValue && !isValidMaxNumber(propValue)) {
|
|
96
|
+
return new Error(getInvalidMaxError(strVal, componentName));
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
},
|
|
100
|
+
value(props, propName, componentName) {
|
|
101
|
+
const valueProp = props[propName];
|
|
102
|
+
const strVal = String(valueProp);
|
|
103
|
+
const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
|
|
104
|
+
if (valueProp != null && !isValidValueNumber(valueProp, max)) {
|
|
105
|
+
return new Error(getInvalidValueError(strVal, componentName));
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export {
|
|
111
|
+
Progress,
|
|
112
|
+
ProgressFrame,
|
|
113
|
+
ProgressIndicator,
|
|
114
|
+
ProgressIndicatorFrame,
|
|
115
|
+
createProgressScope
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=Progress.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Progress.tsx"],
|
|
4
|
+
"sourcesContent": ["// forked from Radix UI\n// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx\n\nimport { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst PROGRESS_NAME = 'Progress'\n\nconst [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)\ntype ProgressContextValue = { value: number | null; max: number; width: number }\nconst [ProgressProvider, useProgressContext] =\n createProgressContext<ProgressContextValue>(PROGRESS_NAME)\n\n/* -------------------------------------------------------------------------------------------------\n * ProgressIndicator\n * -----------------------------------------------------------------------------------------------*/\n\nconst INDICATOR_NAME = 'ProgressIndicator'\n\ntype ProgressIndicatorElement = TamaguiElement\ninterface ProgressIndicatorProps extends YStackProps {}\n\nexport const ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\n backgrounded: true,\n})\n\nconst ProgressIndicator = ProgressIndicatorFrame.extractable(\n React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(\n (props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {\n const { __scopeProgress, ...indicatorProps } = props\n const context = useProgressContext(INDICATOR_NAME, __scopeProgress)\n const pct = context.max - (context.value ?? 0)\n const x = -context.width * (pct / 100)\n return (\n <ProgressIndicatorFrame\n data-state={getProgressState(context.value, context.max)}\n data-value={context.value ?? undefined}\n data-max={context.max}\n x={x}\n width={context.width}\n {...indicatorProps}\n ref={forwardedRef}\n />\n )\n }\n )\n)\n\nProgressIndicator.displayName = INDICATOR_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction defaultGetValueLabel(value: number, max: number) {\n return `${Math.round((value / max) * 100)}%`\n}\n\nfunction getProgressState(value: number | undefined | null, maxValue: number): ProgressState {\n return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading'\n}\n\nfunction isNumber(value: any): value is number {\n return typeof value === 'number'\n}\n\nfunction isValidMaxNumber(max: any): max is number {\n // prettier-ignore\n return (\n isNumber(max) &&\n !isNaN(max) &&\n max > 0\n );\n}\n\nfunction isValidValueNumber(value: any, max: number): value is number {\n // prettier-ignore\n return (\n isNumber(value) &&\n !isNaN(value) &&\n value <= max &&\n value >= 0\n );\n}\n\n// Split this out for clearer readability of the error message.\nfunction getInvalidMaxError(propValue: string, componentName: string) {\n return `Invalid prop \\`max\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. Only numbers greater than 0 are valid max values. Defaulting to \\`${DEFAULT_MAX}\\`.`\n}\n\nfunction getInvalidValueError(propValue: string, componentName: string) {\n return `Invalid prop \\`value\\` of value \\`${propValue}\\` supplied to \\`${componentName}\\`. The \\`value\\` prop must be:\n - a positive number\n - less than the value passed to \\`max\\` (or ${DEFAULT_MAX} if no \\`max\\` prop is set)\n - \\`null\\` if the progress is indeterminate.\n\nDefaulting to \\`null\\`.`\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Progress\n * -----------------------------------------------------------------------------------------------*/\n\nconst DEFAULT_MAX = 100\n\ntype ScopedProps<P> = P & { __scopeProgress?: Scope }\n\ntype ProgressState = 'indeterminate' | 'complete' | 'loading'\n\ntype TamaguiElement = HTMLElement | View\n\ntype ProgressElement = TamaguiElement\n\nexport const ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n backgrounded: true,\n\n variants: {\n size: {\n '...size': (val) => {\n const size = Math.round(getVariableValue(getSize(val)) * 0.25)\n return {\n height: size,\n minWidth: getVariableValue(size) * 20,\n width: '100%',\n }\n },\n },\n },\n})\n\ntype ProgressProps = GetProps<typeof ProgressFrame> & {\n value?: number | null | undefined\n max?: number\n getValueLabel?(value: number, max: number): string\n}\n\nconst Progress = withStaticProperties(\n ProgressFrame.extractable(\n React.forwardRef<ProgressElement, ProgressProps>(\n (props: ScopedProps<ProgressProps>, forwardedRef) => {\n const {\n __scopeProgress,\n value: valueProp,\n max: maxProp,\n getValueLabel = defaultGetValueLabel,\n size = '$4',\n ...progressProps\n } = props\n\n const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX\n const value = isValidValueNumber(valueProp, max) ? valueProp : null\n const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined\n const [width, setWidth] = React.useState(0)\n\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>\n <ProgressFrame\n size={size}\n aria-valuemax={max}\n aria-valuemin={0}\n aria-valuenow={isNumber(value) ? value : undefined}\n aria-valuetext={valueLabel}\n // @ts-ignore\n role=\"progressbar\"\n data-state={getProgressState(value, max)}\n data-value={value ?? undefined}\n data-max={max}\n {...progressProps}\n onLayout={(e) => {\n setWidth(e.nativeEvent.layout.width)\n progressProps.onLayout?.(e)\n }}\n ref={forwardedRef}\n />\n </ProgressProvider>\n )\n }\n )\n ),\n {\n Indicator: ProgressIndicator,\n }\n)\n\nProgress.displayName = PROGRESS_NAME\n\nProgress.propTypes = {\n max(props, propName, componentName) {\n const propValue = props[propName]\n const strVal = String(propValue)\n if (propValue && !isValidMaxNumber(propValue)) {\n return new Error(getInvalidMaxError(strVal, componentName))\n }\n return null\n },\n value(props, propName, componentName) {\n const valueProp = props[propName]\n const strVal = String(valueProp)\n const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX\n if (valueProp != null && !isValidValueNumber(valueProp, max)) {\n return new Error(getInvalidValueError(strVal, componentName))\n }\n return null\n },\n}\n\nexport { createProgressScope, Progress, ProgressIndicator }\nexport type { ProgressProps, ProgressIndicatorProps }\n"],
|
|
5
|
+
"mappings": "AAGA;AACA;AACA;AACA;AAGA,MAAM,gBAAgB;AAEtB,MAAM,CAAC,uBAAuB,uBAAuB,mBAAmB,aAAa;AAErF,MAAM,CAAC,kBAAkB,sBACvB,sBAA4C,aAAa;AAM3D,MAAM,iBAAiB;AAKhB,MAAM,yBAAyB,OAAO,gBAAgB;AAAA,EAC3D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,cAAc;AAChB,CAAC;AAED,MAAM,oBAAoB,uBAAuB,YAC/C,MAAM,WACJ,CAAC,OAA4C,iBAAiB;AAlClE;AAmCM,QAAM,EAAE,oBAAoB,mBAAmB;AAC/C,QAAM,UAAU,mBAAmB,gBAAgB,eAAe;AAClE,QAAM,MAAM,QAAQ,MAAO,eAAQ,UAAR,YAAiB;AAC5C,QAAM,IAAI,CAAC,QAAQ,QAAS,OAAM;AAClC,SACE,CAAC,uBACC,YAAY,iBAAiB,QAAQ,OAAO,QAAQ,GAAG,GACvD,YAAY,cAAQ,UAAR,YAAiB,QAC7B,UAAU,QAAQ,KAClB,GAAG,GACH,OAAO,QAAQ,WACX,gBACJ,KAAK,cACP;AAEJ,CACF,CACF;AAEA,kBAAkB,cAAc;AAIhC,8BAA8B,OAAe,KAAa;AACxD,SAAO,GAAG,KAAK,MAAO,QAAQ,MAAO,GAAG;AAC1C;AAEA,0BAA0B,OAAkC,UAAiC;AAC3F,SAAO,SAAS,OAAO,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/index.ts",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"main": "dist/cjs",
|
|
10
|
+
"module": "dist/esm",
|
|
11
|
+
"module:jsx": "dist/jsx",
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"types",
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tamagui-build",
|
|
19
|
+
"watch": "tamagui-build --watch",
|
|
20
|
+
"clean": "tamagui-build clean",
|
|
21
|
+
"clean:build": "tamagui-build clean:build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@tamagui/compose-refs": "^1.0.1-beta.100",
|
|
25
|
+
"@tamagui/core": "^1.0.1-beta.100",
|
|
26
|
+
"@tamagui/create-context": "^1.0.1-beta.100",
|
|
27
|
+
"@tamagui/stacks": "^1.0.1-beta.100"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "*",
|
|
31
|
+
"react-dom": "*",
|
|
32
|
+
"react-native": "*"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tamagui/build": "^1.0.1-beta.100",
|
|
36
|
+
"@types/react-native": "^0.67.3",
|
|
37
|
+
"react": "*",
|
|
38
|
+
"react-dom": "*",
|
|
39
|
+
"react-native": "*"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/Progress.tsx
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// forked from Radix UI
|
|
2
|
+
// https://github.com/radix-ui/primitives/blob/main/packages/react/progress/src/Progress.tsx
|
|
3
|
+
|
|
4
|
+
import { GetProps, getSize, getVariableValue, styled, withStaticProperties } from '@tamagui/core'
|
|
5
|
+
import { Scope, createContextScope } from '@tamagui/create-context'
|
|
6
|
+
import { ThemeableStack, YStackProps } from '@tamagui/stacks'
|
|
7
|
+
import * as React from 'react'
|
|
8
|
+
import { View } from 'react-native'
|
|
9
|
+
|
|
10
|
+
const PROGRESS_NAME = 'Progress'
|
|
11
|
+
|
|
12
|
+
const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME)
|
|
13
|
+
type ProgressContextValue = { value: number | null; max: number; width: number }
|
|
14
|
+
const [ProgressProvider, useProgressContext] =
|
|
15
|
+
createProgressContext<ProgressContextValue>(PROGRESS_NAME)
|
|
16
|
+
|
|
17
|
+
/* -------------------------------------------------------------------------------------------------
|
|
18
|
+
* ProgressIndicator
|
|
19
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
const INDICATOR_NAME = 'ProgressIndicator'
|
|
22
|
+
|
|
23
|
+
type ProgressIndicatorElement = TamaguiElement
|
|
24
|
+
interface ProgressIndicatorProps extends YStackProps {}
|
|
25
|
+
|
|
26
|
+
export const ProgressIndicatorFrame = styled(ThemeableStack, {
|
|
27
|
+
name: INDICATOR_NAME,
|
|
28
|
+
height: '100%',
|
|
29
|
+
width: '100%',
|
|
30
|
+
backgrounded: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const ProgressIndicator = ProgressIndicatorFrame.extractable(
|
|
34
|
+
React.forwardRef<ProgressIndicatorElement, ProgressIndicatorProps>(
|
|
35
|
+
(props: ScopedProps<ProgressIndicatorProps>, forwardedRef) => {
|
|
36
|
+
const { __scopeProgress, ...indicatorProps } = props
|
|
37
|
+
const context = useProgressContext(INDICATOR_NAME, __scopeProgress)
|
|
38
|
+
const pct = context.max - (context.value ?? 0)
|
|
39
|
+
const x = -context.width * (pct / 100)
|
|
40
|
+
return (
|
|
41
|
+
<ProgressIndicatorFrame
|
|
42
|
+
data-state={getProgressState(context.value, context.max)}
|
|
43
|
+
data-value={context.value ?? undefined}
|
|
44
|
+
data-max={context.max}
|
|
45
|
+
x={x}
|
|
46
|
+
width={context.width}
|
|
47
|
+
{...indicatorProps}
|
|
48
|
+
ref={forwardedRef}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
ProgressIndicator.displayName = INDICATOR_NAME
|
|
56
|
+
|
|
57
|
+
/* ---------------------------------------------------------------------------------------------- */
|
|
58
|
+
|
|
59
|
+
function defaultGetValueLabel(value: number, max: number) {
|
|
60
|
+
return `${Math.round((value / max) * 100)}%`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getProgressState(value: number | undefined | null, maxValue: number): ProgressState {
|
|
64
|
+
return value == null ? 'indeterminate' : value === maxValue ? 'complete' : 'loading'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isNumber(value: any): value is number {
|
|
68
|
+
return typeof value === 'number'
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isValidMaxNumber(max: any): max is number {
|
|
72
|
+
// prettier-ignore
|
|
73
|
+
return (
|
|
74
|
+
isNumber(max) &&
|
|
75
|
+
!isNaN(max) &&
|
|
76
|
+
max > 0
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isValidValueNumber(value: any, max: number): value is number {
|
|
81
|
+
// prettier-ignore
|
|
82
|
+
return (
|
|
83
|
+
isNumber(value) &&
|
|
84
|
+
!isNaN(value) &&
|
|
85
|
+
value <= max &&
|
|
86
|
+
value >= 0
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Split this out for clearer readability of the error message.
|
|
91
|
+
function getInvalidMaxError(propValue: string, componentName: string) {
|
|
92
|
+
return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getInvalidValueError(propValue: string, componentName: string) {
|
|
96
|
+
return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
|
|
97
|
+
- a positive number
|
|
98
|
+
- less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
|
|
99
|
+
- \`null\` if the progress is indeterminate.
|
|
100
|
+
|
|
101
|
+
Defaulting to \`null\`.`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* -------------------------------------------------------------------------------------------------
|
|
105
|
+
* Progress
|
|
106
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
107
|
+
|
|
108
|
+
const DEFAULT_MAX = 100
|
|
109
|
+
|
|
110
|
+
type ScopedProps<P> = P & { __scopeProgress?: Scope }
|
|
111
|
+
|
|
112
|
+
type ProgressState = 'indeterminate' | 'complete' | 'loading'
|
|
113
|
+
|
|
114
|
+
type TamaguiElement = HTMLElement | View
|
|
115
|
+
|
|
116
|
+
type ProgressElement = TamaguiElement
|
|
117
|
+
|
|
118
|
+
export const ProgressFrame = styled(ThemeableStack, {
|
|
119
|
+
name: PROGRESS_NAME,
|
|
120
|
+
borderRadius: 100_000,
|
|
121
|
+
overflow: 'hidden',
|
|
122
|
+
backgrounded: true,
|
|
123
|
+
|
|
124
|
+
variants: {
|
|
125
|
+
size: {
|
|
126
|
+
'...size': (val) => {
|
|
127
|
+
const size = Math.round(getVariableValue(getSize(val)) * 0.25)
|
|
128
|
+
return {
|
|
129
|
+
height: size,
|
|
130
|
+
minWidth: getVariableValue(size) * 20,
|
|
131
|
+
width: '100%',
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
type ProgressProps = GetProps<typeof ProgressFrame> & {
|
|
139
|
+
value?: number | null | undefined
|
|
140
|
+
max?: number
|
|
141
|
+
getValueLabel?(value: number, max: number): string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const Progress = withStaticProperties(
|
|
145
|
+
ProgressFrame.extractable(
|
|
146
|
+
React.forwardRef<ProgressElement, ProgressProps>(
|
|
147
|
+
(props: ScopedProps<ProgressProps>, forwardedRef) => {
|
|
148
|
+
const {
|
|
149
|
+
__scopeProgress,
|
|
150
|
+
value: valueProp,
|
|
151
|
+
max: maxProp,
|
|
152
|
+
getValueLabel = defaultGetValueLabel,
|
|
153
|
+
size = '$4',
|
|
154
|
+
...progressProps
|
|
155
|
+
} = props
|
|
156
|
+
|
|
157
|
+
const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX
|
|
158
|
+
const value = isValidValueNumber(valueProp, max) ? valueProp : null
|
|
159
|
+
const valueLabel = isNumber(value) ? getValueLabel(value, max) : undefined
|
|
160
|
+
const [width, setWidth] = React.useState(0)
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<ProgressProvider scope={__scopeProgress} value={value} max={max} width={width}>
|
|
164
|
+
<ProgressFrame
|
|
165
|
+
size={size}
|
|
166
|
+
aria-valuemax={max}
|
|
167
|
+
aria-valuemin={0}
|
|
168
|
+
aria-valuenow={isNumber(value) ? value : undefined}
|
|
169
|
+
aria-valuetext={valueLabel}
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
role="progressbar"
|
|
172
|
+
data-state={getProgressState(value, max)}
|
|
173
|
+
data-value={value ?? undefined}
|
|
174
|
+
data-max={max}
|
|
175
|
+
{...progressProps}
|
|
176
|
+
onLayout={(e) => {
|
|
177
|
+
setWidth(e.nativeEvent.layout.width)
|
|
178
|
+
progressProps.onLayout?.(e)
|
|
179
|
+
}}
|
|
180
|
+
ref={forwardedRef}
|
|
181
|
+
/>
|
|
182
|
+
</ProgressProvider>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
),
|
|
187
|
+
{
|
|
188
|
+
Indicator: ProgressIndicator,
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
Progress.displayName = PROGRESS_NAME
|
|
193
|
+
|
|
194
|
+
Progress.propTypes = {
|
|
195
|
+
max(props, propName, componentName) {
|
|
196
|
+
const propValue = props[propName]
|
|
197
|
+
const strVal = String(propValue)
|
|
198
|
+
if (propValue && !isValidMaxNumber(propValue)) {
|
|
199
|
+
return new Error(getInvalidMaxError(strVal, componentName))
|
|
200
|
+
}
|
|
201
|
+
return null
|
|
202
|
+
},
|
|
203
|
+
value(props, propName, componentName) {
|
|
204
|
+
const valueProp = props[propName]
|
|
205
|
+
const strVal = String(valueProp)
|
|
206
|
+
const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX
|
|
207
|
+
if (valueProp != null && !isValidValueNumber(valueProp, max)) {
|
|
208
|
+
return new Error(getInvalidValueError(strVal, componentName))
|
|
209
|
+
}
|
|
210
|
+
return null
|
|
211
|
+
},
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { createProgressScope, Progress, ProgressIndicator }
|
|
215
|
+
export type { ProgressProps, ProgressIndicatorProps }
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Progress'
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { GetProps } from '@tamagui/core';
|
|
2
|
+
import { YStackProps } from '@tamagui/stacks';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
declare const createProgressScope: import("@tamagui/create-context").CreateScope;
|
|
6
|
+
interface ProgressIndicatorProps extends YStackProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const ProgressIndicatorFrame: import("@tamagui/core").TamaguiComponent<(Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
9
|
+
readonly fullscreen?: boolean | undefined;
|
|
10
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
11
|
+
}, "fontFamily" | "hoverTheme" | "pressTheme" | "focusTheme" | "circular" | "elevate" | "bordered" | "transparent" | "backgrounded" | "radiused" | "padded" | "chromeless"> & {
|
|
12
|
+
fontFamily?: unknown;
|
|
13
|
+
backgrounded?: boolean | undefined;
|
|
14
|
+
radiused?: boolean | undefined;
|
|
15
|
+
hoverTheme?: boolean | undefined;
|
|
16
|
+
pressTheme?: boolean | undefined;
|
|
17
|
+
focusTheme?: boolean | undefined;
|
|
18
|
+
circular?: boolean | undefined;
|
|
19
|
+
padded?: boolean | undefined;
|
|
20
|
+
elevate?: boolean | undefined;
|
|
21
|
+
bordered?: number | boolean | undefined;
|
|
22
|
+
transparent?: boolean | undefined;
|
|
23
|
+
chromeless?: boolean | undefined;
|
|
24
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
25
|
+
readonly fullscreen?: boolean | undefined;
|
|
26
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
27
|
+
}, "fontFamily" | "hoverTheme" | "pressTheme" | "focusTheme" | "circular" | "elevate" | "bordered" | "transparent" | "backgrounded" | "radiused" | "padded" | "chromeless"> & {
|
|
28
|
+
fontFamily?: unknown;
|
|
29
|
+
backgrounded?: boolean | undefined;
|
|
30
|
+
radiused?: boolean | undefined;
|
|
31
|
+
hoverTheme?: boolean | undefined;
|
|
32
|
+
pressTheme?: boolean | undefined;
|
|
33
|
+
focusTheme?: boolean | undefined;
|
|
34
|
+
circular?: boolean | undefined;
|
|
35
|
+
padded?: boolean | undefined;
|
|
36
|
+
elevate?: boolean | undefined;
|
|
37
|
+
bordered?: number | boolean | undefined;
|
|
38
|
+
transparent?: boolean | undefined;
|
|
39
|
+
chromeless?: boolean | undefined;
|
|
40
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
41
|
+
readonly fullscreen?: boolean | undefined;
|
|
42
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
43
|
+
}, "fontFamily" | "hoverTheme" | "pressTheme" | "focusTheme" | "circular" | "elevate" | "bordered" | "transparent" | "backgrounded" | "radiused" | "padded" | "chromeless"> & {
|
|
44
|
+
fontFamily?: unknown;
|
|
45
|
+
backgrounded?: boolean | undefined;
|
|
46
|
+
radiused?: boolean | undefined;
|
|
47
|
+
hoverTheme?: boolean | undefined;
|
|
48
|
+
pressTheme?: boolean | undefined;
|
|
49
|
+
focusTheme?: boolean | undefined;
|
|
50
|
+
circular?: boolean | undefined;
|
|
51
|
+
padded?: boolean | undefined;
|
|
52
|
+
elevate?: boolean | undefined;
|
|
53
|
+
bordered?: number | boolean | undefined;
|
|
54
|
+
transparent?: boolean | undefined;
|
|
55
|
+
chromeless?: boolean | undefined;
|
|
56
|
+
}>>) | (Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
57
|
+
readonly fullscreen?: boolean | undefined;
|
|
58
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
59
|
+
} & {
|
|
60
|
+
fontFamily?: unknown;
|
|
61
|
+
backgrounded?: boolean | undefined;
|
|
62
|
+
radiused?: boolean | undefined;
|
|
63
|
+
hoverTheme?: boolean | undefined;
|
|
64
|
+
pressTheme?: boolean | undefined;
|
|
65
|
+
focusTheme?: boolean | undefined;
|
|
66
|
+
circular?: boolean | undefined;
|
|
67
|
+
padded?: boolean | undefined;
|
|
68
|
+
elevate?: boolean | undefined;
|
|
69
|
+
bordered?: number | boolean | undefined;
|
|
70
|
+
transparent?: boolean | undefined;
|
|
71
|
+
chromeless?: boolean | undefined;
|
|
72
|
+
}, string | number> & {
|
|
73
|
+
[x: string]: undefined;
|
|
74
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
75
|
+
readonly fullscreen?: boolean | undefined;
|
|
76
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
77
|
+
} & {
|
|
78
|
+
fontFamily?: unknown;
|
|
79
|
+
backgrounded?: boolean | undefined;
|
|
80
|
+
radiused?: boolean | undefined;
|
|
81
|
+
hoverTheme?: boolean | undefined;
|
|
82
|
+
pressTheme?: boolean | undefined;
|
|
83
|
+
focusTheme?: boolean | undefined;
|
|
84
|
+
circular?: boolean | undefined;
|
|
85
|
+
padded?: boolean | undefined;
|
|
86
|
+
elevate?: boolean | undefined;
|
|
87
|
+
bordered?: number | boolean | undefined;
|
|
88
|
+
transparent?: boolean | undefined;
|
|
89
|
+
chromeless?: boolean | undefined;
|
|
90
|
+
}, string | number> & {
|
|
91
|
+
[x: string]: undefined;
|
|
92
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
93
|
+
readonly fullscreen?: boolean | undefined;
|
|
94
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
95
|
+
} & {
|
|
96
|
+
fontFamily?: unknown;
|
|
97
|
+
backgrounded?: boolean | undefined;
|
|
98
|
+
radiused?: boolean | undefined;
|
|
99
|
+
hoverTheme?: boolean | undefined;
|
|
100
|
+
pressTheme?: boolean | undefined;
|
|
101
|
+
focusTheme?: boolean | undefined;
|
|
102
|
+
circular?: boolean | undefined;
|
|
103
|
+
padded?: boolean | undefined;
|
|
104
|
+
elevate?: boolean | undefined;
|
|
105
|
+
bordered?: number | boolean | undefined;
|
|
106
|
+
transparent?: boolean | undefined;
|
|
107
|
+
chromeless?: boolean | undefined;
|
|
108
|
+
}, string | number> & {
|
|
109
|
+
[x: string]: undefined;
|
|
110
|
+
}>>), any, import("@tamagui/core").StackPropsBase, {
|
|
111
|
+
readonly fullscreen?: boolean | undefined;
|
|
112
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
113
|
+
} & {
|
|
114
|
+
fontFamily?: unknown;
|
|
115
|
+
backgrounded?: boolean | undefined;
|
|
116
|
+
radiused?: boolean | undefined;
|
|
117
|
+
hoverTheme?: boolean | undefined;
|
|
118
|
+
pressTheme?: boolean | undefined;
|
|
119
|
+
focusTheme?: boolean | undefined;
|
|
120
|
+
circular?: boolean | undefined;
|
|
121
|
+
padded?: boolean | undefined;
|
|
122
|
+
elevate?: boolean | undefined;
|
|
123
|
+
bordered?: number | boolean | undefined;
|
|
124
|
+
transparent?: boolean | undefined;
|
|
125
|
+
chromeless?: boolean | undefined;
|
|
126
|
+
} & ({} | {
|
|
127
|
+
[x: string]: undefined;
|
|
128
|
+
})>;
|
|
129
|
+
declare const ProgressIndicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
|
|
130
|
+
declare type TamaguiElement = HTMLElement | View;
|
|
131
|
+
export declare const ProgressFrame: import("@tamagui/core").TamaguiComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
132
|
+
readonly fullscreen?: boolean | undefined;
|
|
133
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
134
|
+
} & {
|
|
135
|
+
fontFamily?: unknown;
|
|
136
|
+
backgrounded?: boolean | undefined;
|
|
137
|
+
radiused?: boolean | undefined;
|
|
138
|
+
hoverTheme?: boolean | undefined;
|
|
139
|
+
pressTheme?: boolean | undefined;
|
|
140
|
+
focusTheme?: boolean | undefined;
|
|
141
|
+
circular?: boolean | undefined;
|
|
142
|
+
padded?: boolean | undefined;
|
|
143
|
+
elevate?: boolean | undefined;
|
|
144
|
+
bordered?: number | boolean | undefined;
|
|
145
|
+
transparent?: boolean | undefined;
|
|
146
|
+
chromeless?: boolean | undefined;
|
|
147
|
+
}, "size"> & {
|
|
148
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
149
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
150
|
+
readonly fullscreen?: boolean | undefined;
|
|
151
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
152
|
+
} & {
|
|
153
|
+
fontFamily?: unknown;
|
|
154
|
+
backgrounded?: boolean | undefined;
|
|
155
|
+
radiused?: boolean | undefined;
|
|
156
|
+
hoverTheme?: boolean | undefined;
|
|
157
|
+
pressTheme?: boolean | undefined;
|
|
158
|
+
focusTheme?: boolean | undefined;
|
|
159
|
+
circular?: boolean | undefined;
|
|
160
|
+
padded?: boolean | undefined;
|
|
161
|
+
elevate?: boolean | undefined;
|
|
162
|
+
bordered?: number | boolean | undefined;
|
|
163
|
+
transparent?: boolean | undefined;
|
|
164
|
+
chromeless?: boolean | undefined;
|
|
165
|
+
}, "size"> & {
|
|
166
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
167
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
168
|
+
readonly fullscreen?: boolean | undefined;
|
|
169
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
170
|
+
} & {
|
|
171
|
+
fontFamily?: unknown;
|
|
172
|
+
backgrounded?: boolean | undefined;
|
|
173
|
+
radiused?: boolean | undefined;
|
|
174
|
+
hoverTheme?: boolean | undefined;
|
|
175
|
+
pressTheme?: boolean | undefined;
|
|
176
|
+
focusTheme?: boolean | undefined;
|
|
177
|
+
circular?: boolean | undefined;
|
|
178
|
+
padded?: boolean | undefined;
|
|
179
|
+
elevate?: boolean | undefined;
|
|
180
|
+
bordered?: number | boolean | undefined;
|
|
181
|
+
transparent?: boolean | undefined;
|
|
182
|
+
chromeless?: boolean | undefined;
|
|
183
|
+
}, "size"> & {
|
|
184
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
185
|
+
}>>, any, import("@tamagui/core").StackPropsBase, {
|
|
186
|
+
readonly fullscreen?: boolean | undefined;
|
|
187
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
188
|
+
} & {
|
|
189
|
+
fontFamily?: unknown;
|
|
190
|
+
backgrounded?: boolean | undefined;
|
|
191
|
+
radiused?: boolean | undefined;
|
|
192
|
+
hoverTheme?: boolean | undefined;
|
|
193
|
+
pressTheme?: boolean | undefined;
|
|
194
|
+
focusTheme?: boolean | undefined;
|
|
195
|
+
circular?: boolean | undefined;
|
|
196
|
+
padded?: boolean | undefined;
|
|
197
|
+
elevate?: boolean | undefined;
|
|
198
|
+
bordered?: number | boolean | undefined;
|
|
199
|
+
transparent?: boolean | undefined;
|
|
200
|
+
chromeless?: boolean | undefined;
|
|
201
|
+
} & {
|
|
202
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
203
|
+
}>;
|
|
204
|
+
declare type ProgressProps = GetProps<typeof ProgressFrame> & {
|
|
205
|
+
value?: number | null | undefined;
|
|
206
|
+
max?: number;
|
|
207
|
+
getValueLabel?(value: number, max: number): string;
|
|
208
|
+
};
|
|
209
|
+
declare const Progress: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
210
|
+
readonly fullscreen?: boolean | undefined;
|
|
211
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
212
|
+
} & {
|
|
213
|
+
fontFamily?: unknown;
|
|
214
|
+
backgrounded?: boolean | undefined;
|
|
215
|
+
radiused?: boolean | undefined;
|
|
216
|
+
hoverTheme?: boolean | undefined;
|
|
217
|
+
pressTheme?: boolean | undefined;
|
|
218
|
+
focusTheme?: boolean | undefined;
|
|
219
|
+
circular?: boolean | undefined;
|
|
220
|
+
padded?: boolean | undefined;
|
|
221
|
+
elevate?: boolean | undefined;
|
|
222
|
+
bordered?: number | boolean | undefined;
|
|
223
|
+
transparent?: boolean | undefined;
|
|
224
|
+
chromeless?: boolean | undefined;
|
|
225
|
+
}, "size"> & {
|
|
226
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
227
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
228
|
+
readonly fullscreen?: boolean | undefined;
|
|
229
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
230
|
+
} & {
|
|
231
|
+
fontFamily?: unknown;
|
|
232
|
+
backgrounded?: boolean | undefined;
|
|
233
|
+
radiused?: boolean | undefined;
|
|
234
|
+
hoverTheme?: boolean | undefined;
|
|
235
|
+
pressTheme?: boolean | undefined;
|
|
236
|
+
focusTheme?: boolean | undefined;
|
|
237
|
+
circular?: boolean | undefined;
|
|
238
|
+
padded?: boolean | undefined;
|
|
239
|
+
elevate?: boolean | undefined;
|
|
240
|
+
bordered?: number | boolean | undefined;
|
|
241
|
+
transparent?: boolean | undefined;
|
|
242
|
+
chromeless?: boolean | undefined;
|
|
243
|
+
}, "size"> & {
|
|
244
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
245
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "display" | "children"> & import("@tamagui/core").RNWViewProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & Omit<{
|
|
246
|
+
readonly fullscreen?: boolean | undefined;
|
|
247
|
+
readonly elevation?: import("@tamagui/core").SizeTokens | undefined;
|
|
248
|
+
} & {
|
|
249
|
+
fontFamily?: unknown;
|
|
250
|
+
backgrounded?: boolean | undefined;
|
|
251
|
+
radiused?: boolean | undefined;
|
|
252
|
+
hoverTheme?: boolean | undefined;
|
|
253
|
+
pressTheme?: boolean | undefined;
|
|
254
|
+
focusTheme?: boolean | undefined;
|
|
255
|
+
circular?: boolean | undefined;
|
|
256
|
+
padded?: boolean | undefined;
|
|
257
|
+
elevate?: boolean | undefined;
|
|
258
|
+
bordered?: number | boolean | undefined;
|
|
259
|
+
transparent?: boolean | undefined;
|
|
260
|
+
chromeless?: boolean | undefined;
|
|
261
|
+
}, "size"> & {
|
|
262
|
+
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
263
|
+
}>> & {
|
|
264
|
+
value?: number | null | undefined;
|
|
265
|
+
max?: number | undefined;
|
|
266
|
+
getValueLabel?(value: number, max: number): string;
|
|
267
|
+
} & React.RefAttributes<TamaguiElement>> & {
|
|
268
|
+
Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
|
|
269
|
+
};
|
|
270
|
+
export { createProgressScope, Progress, ProgressIndicator };
|
|
271
|
+
export type { ProgressProps, ProgressIndicatorProps };
|
|
272
|
+
//# sourceMappingURL=Progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../src/Progress.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAA2D,MAAM,eAAe,CAAA;AAEjG,OAAO,EAAkB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,QAAA,MAA8B,mBAAmB,+CAAqC,CAAA;AAYtF,UAAU,sBAAuB,SAAQ,WAAW;CAAG;AAEvD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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