@tamagui/progress 1.0.1-beta.34

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.
@@ -0,0 +1,205 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ 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));
50
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
51
+ var Progress_exports = {};
52
+ __export(Progress_exports, {
53
+ Indicator: () => Indicator,
54
+ Progress: () => Progress,
55
+ ProgressIndicator: () => ProgressIndicator,
56
+ Root: () => Root,
57
+ createProgressScope: () => createProgressScope
58
+ });
59
+ module.exports = __toCommonJS(Progress_exports);
60
+ var import_core = require("@tamagui/core");
61
+ var import_create_context = require("@tamagui/create-context");
62
+ var import_stacks = require("@tamagui/stacks");
63
+ var React = __toESM(require("react"));
64
+ const PROGRESS_NAME = "Progress";
65
+ const [createProgressContext, createProgressScope] = (0, import_create_context.createContextScope)(PROGRESS_NAME);
66
+ const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
67
+ const INDICATOR_NAME = "ProgressIndicator";
68
+ const ProgressIndicatorFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
69
+ name: INDICATOR_NAME,
70
+ height: "100%",
71
+ width: "100%"
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 progress = context.max - (context.value ?? 0);
77
+ return /* @__PURE__ */ React.createElement(ProgressIndicatorFrame, __spreadProps(__spreadValues({
78
+ "data-state": getProgressState(context.value, context.max),
79
+ "data-value": context.value ?? void 0,
80
+ "data-max": context.max,
81
+ x: `${-progress}%`
82
+ }, indicatorProps), {
83
+ ref: forwardedRef
84
+ }));
85
+ }));
86
+ ProgressIndicator.displayName = INDICATOR_NAME;
87
+ function defaultGetValueLabel(value, max) {
88
+ return `${Math.round(value / max * 100)}%`;
89
+ }
90
+ __name(defaultGetValueLabel, "defaultGetValueLabel");
91
+ function getProgressState(value, maxValue) {
92
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
93
+ }
94
+ __name(getProgressState, "getProgressState");
95
+ function isNumber(value) {
96
+ return typeof value === "number";
97
+ }
98
+ __name(isNumber, "isNumber");
99
+ function isValidMaxNumber(max) {
100
+ return isNumber(max) && !isNaN(max) && max > 0;
101
+ }
102
+ __name(isValidMaxNumber, "isValidMaxNumber");
103
+ function isValidValueNumber(value, max) {
104
+ return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
105
+ }
106
+ __name(isValidValueNumber, "isValidValueNumber");
107
+ function getInvalidMaxError(propValue, componentName) {
108
+ return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
109
+ }
110
+ __name(getInvalidMaxError, "getInvalidMaxError");
111
+ function getInvalidValueError(propValue, componentName) {
112
+ return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
113
+ - a positive number
114
+ - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
115
+ - \`null\` if the progress is indeterminate.
116
+
117
+ Defaulting to \`null\`.`;
118
+ }
119
+ __name(getInvalidValueError, "getInvalidValueError");
120
+ const DEFAULT_MAX = 100;
121
+ const ProgressFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
122
+ name: PROGRESS_NAME,
123
+ borderRadius: 1e5,
124
+ overflow: "hidden",
125
+ variants: {
126
+ size: {
127
+ "...size": (val, extras) => {
128
+ const circleSize = (0, import_stacks.getCircleSize)(val, extras);
129
+ const size = circleSize / 3;
130
+ return {
131
+ height: size,
132
+ width: size * 20
133
+ };
134
+ }
135
+ }
136
+ }
137
+ });
138
+ const Progress = (0, import_core.withStaticProperties)(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
139
+ const _a = props, {
140
+ __scopeProgress,
141
+ value: valueProp,
142
+ max: maxProp,
143
+ getValueLabel = defaultGetValueLabel,
144
+ size = "$4"
145
+ } = _a, progressProps = __objRest(_a, [
146
+ "__scopeProgress",
147
+ "value",
148
+ "max",
149
+ "getValueLabel",
150
+ "size"
151
+ ]);
152
+ const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
153
+ const value = isValidValueNumber(valueProp, max) ? valueProp : null;
154
+ const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
155
+ return /* @__PURE__ */ React.createElement(ProgressProvider, {
156
+ scope: __scopeProgress,
157
+ value,
158
+ max
159
+ }, /* @__PURE__ */ React.createElement(ProgressFrame, __spreadProps(__spreadValues({
160
+ size,
161
+ "aria-valuemax": max,
162
+ "aria-valuemin": 0,
163
+ "aria-valuenow": isNumber(value) ? value : void 0,
164
+ "aria-valuetext": valueLabel,
165
+ role: "progressbar",
166
+ "data-state": getProgressState(value, max),
167
+ "data-value": value ?? void 0,
168
+ "data-max": max
169
+ }, progressProps), {
170
+ ref: forwardedRef
171
+ })));
172
+ })), {
173
+ Indicator: ProgressIndicator
174
+ });
175
+ Progress.displayName = PROGRESS_NAME;
176
+ Progress.propTypes = {
177
+ max(props, propName, componentName) {
178
+ const propValue = props[propName];
179
+ const strVal = String(propValue);
180
+ if (propValue && !isValidMaxNumber(propValue)) {
181
+ return new Error(getInvalidMaxError(strVal, componentName));
182
+ }
183
+ return null;
184
+ },
185
+ value(props, propName, componentName) {
186
+ const valueProp = props[propName];
187
+ const strVal = String(valueProp);
188
+ const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
189
+ if (valueProp != null && !isValidValueNumber(valueProp, max)) {
190
+ return new Error(getInvalidValueError(strVal, componentName));
191
+ }
192
+ return null;
193
+ }
194
+ };
195
+ const Root = Progress;
196
+ const Indicator = ProgressIndicator;
197
+ // Annotate the CommonJS export names for ESM import in node:
198
+ 0 && (module.exports = {
199
+ Indicator,
200
+ Progress,
201
+ ProgressIndicator,
202
+ Root,
203
+ createProgressScope
204
+ });
205
+ //# 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, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps, getCircleSize } 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 }\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\nconst ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\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 progress = context.max - (context.value ?? 0)\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={`${-progress}%`}\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\nconst ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n\n variants: {\n size: {\n '...size': (val, extras) => {\n const circleSize = getCircleSize(val, extras)\n const size = circleSize / 3\n return {\n height: size,\n width: size * 20,\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\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max}>\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 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\nconst Root = Progress\nconst Indicator = ProgressIndicator\n\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n}\nexport type { ProgressProps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AAQ;AAAA,IACzC,kBAAgB;AAAA,IAEhB,MAAK;AAAA,IACL,cAAY,iBAAiB,OAAO,GAAG;AAAA,IACvC,cAAY,SAAS;AAAA,IACrB,YAAU;AAAA,KACN,gBAXL;AAAA,IAYC,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;AAEA,MAAM,OAAO;AACb,MAAM,YAAY;",
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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Progress'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,143 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { styled, withStaticProperties } from "@tamagui/core";
4
+ import { createContextScope } from "@tamagui/create-context";
5
+ import { ThemeableStack, getCircleSize } from "@tamagui/stacks";
6
+ import * as React from "react";
7
+ const PROGRESS_NAME = "Progress";
8
+ const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
9
+ const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
10
+ const INDICATOR_NAME = "ProgressIndicator";
11
+ const ProgressIndicatorFrame = styled(ThemeableStack, {
12
+ name: INDICATOR_NAME,
13
+ height: "100%",
14
+ width: "100%"
15
+ });
16
+ const ProgressIndicator = ProgressIndicatorFrame.extractable(React.forwardRef((props, forwardedRef) => {
17
+ var _a, _b;
18
+ const { __scopeProgress, ...indicatorProps } = props;
19
+ const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
20
+ const progress = context.max - ((_a = context.value) != null ? _a : 0);
21
+ return /* @__PURE__ */ React.createElement(ProgressIndicatorFrame, {
22
+ "data-state": getProgressState(context.value, context.max),
23
+ "data-value": (_b = context.value) != null ? _b : void 0,
24
+ "data-max": context.max,
25
+ x: `${-progress}%`,
26
+ ...indicatorProps,
27
+ ref: forwardedRef
28
+ });
29
+ }));
30
+ ProgressIndicator.displayName = INDICATOR_NAME;
31
+ function defaultGetValueLabel(value, max) {
32
+ return `${Math.round(value / max * 100)}%`;
33
+ }
34
+ __name(defaultGetValueLabel, "defaultGetValueLabel");
35
+ function getProgressState(value, maxValue) {
36
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
37
+ }
38
+ __name(getProgressState, "getProgressState");
39
+ function isNumber(value) {
40
+ return typeof value === "number";
41
+ }
42
+ __name(isNumber, "isNumber");
43
+ function isValidMaxNumber(max) {
44
+ return isNumber(max) && !isNaN(max) && max > 0;
45
+ }
46
+ __name(isValidMaxNumber, "isValidMaxNumber");
47
+ function isValidValueNumber(value, max) {
48
+ return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
49
+ }
50
+ __name(isValidValueNumber, "isValidValueNumber");
51
+ function getInvalidMaxError(propValue, componentName) {
52
+ return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
53
+ }
54
+ __name(getInvalidMaxError, "getInvalidMaxError");
55
+ function getInvalidValueError(propValue, componentName) {
56
+ return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
57
+ - a positive number
58
+ - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
59
+ - \`null\` if the progress is indeterminate.
60
+
61
+ Defaulting to \`null\`.`;
62
+ }
63
+ __name(getInvalidValueError, "getInvalidValueError");
64
+ const DEFAULT_MAX = 100;
65
+ const ProgressFrame = styled(ThemeableStack, {
66
+ name: PROGRESS_NAME,
67
+ borderRadius: 1e5,
68
+ overflow: "hidden",
69
+ variants: {
70
+ size: {
71
+ "...size": (val, extras) => {
72
+ const circleSize = getCircleSize(val, extras);
73
+ const size = circleSize / 3;
74
+ return {
75
+ height: size,
76
+ width: size * 20
77
+ };
78
+ }
79
+ }
80
+ }
81
+ });
82
+ const Progress = withStaticProperties(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
83
+ const {
84
+ __scopeProgress,
85
+ value: valueProp,
86
+ max: maxProp,
87
+ getValueLabel = defaultGetValueLabel,
88
+ size = "$4",
89
+ ...progressProps
90
+ } = props;
91
+ const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
92
+ const value = isValidValueNumber(valueProp, max) ? valueProp : null;
93
+ const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
94
+ return /* @__PURE__ */ React.createElement(ProgressProvider, {
95
+ scope: __scopeProgress,
96
+ value,
97
+ max
98
+ }, /* @__PURE__ */ React.createElement(ProgressFrame, {
99
+ size,
100
+ "aria-valuemax": max,
101
+ "aria-valuemin": 0,
102
+ "aria-valuenow": isNumber(value) ? value : void 0,
103
+ "aria-valuetext": valueLabel,
104
+ role: "progressbar",
105
+ "data-state": getProgressState(value, max),
106
+ "data-value": value != null ? value : void 0,
107
+ "data-max": max,
108
+ ...progressProps,
109
+ ref: forwardedRef
110
+ }));
111
+ })), {
112
+ Indicator: ProgressIndicator
113
+ });
114
+ Progress.displayName = PROGRESS_NAME;
115
+ Progress.propTypes = {
116
+ max(props, propName, componentName) {
117
+ const propValue = props[propName];
118
+ const strVal = String(propValue);
119
+ if (propValue && !isValidMaxNumber(propValue)) {
120
+ return new Error(getInvalidMaxError(strVal, componentName));
121
+ }
122
+ return null;
123
+ },
124
+ value(props, propName, componentName) {
125
+ const valueProp = props[propName];
126
+ const strVal = String(valueProp);
127
+ const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
128
+ if (valueProp != null && !isValidValueNumber(valueProp, max)) {
129
+ return new Error(getInvalidValueError(strVal, componentName));
130
+ }
131
+ return null;
132
+ }
133
+ };
134
+ const Root = Progress;
135
+ const Indicator = ProgressIndicator;
136
+ export {
137
+ Indicator,
138
+ Progress,
139
+ ProgressIndicator,
140
+ Root,
141
+ createProgressScope
142
+ };
143
+ //# 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, styled, withStaticProperties } from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { ThemeableStack, YStackProps, getCircleSize } 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 }\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\nconst ProgressIndicatorFrame = styled(ThemeableStack, {\n name: INDICATOR_NAME,\n height: '100%',\n width: '100%',\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 progress = context.max - (context.value ?? 0)\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={`${-progress}%`}\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\nconst ProgressFrame = styled(ThemeableStack, {\n name: PROGRESS_NAME,\n borderRadius: 100_000,\n overflow: 'hidden',\n\n variants: {\n size: {\n '...size': (val, extras) => {\n const circleSize = getCircleSize(val, extras)\n const size = circleSize / 3\n return {\n height: size,\n width: size * 20,\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\n return (\n <ProgressProvider scope={__scopeProgress} value={value} max={max}>\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 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\nconst Root = Progress\nconst Indicator = ProgressIndicator\n\nexport {\n createProgressScope,\n //\n Progress,\n ProgressIndicator,\n //\n Root,\n Indicator,\n}\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;AAKvB,MAAM,yBAAyB,OAAO,gBAAgB;AAAA,EACpD,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,O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AAU,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;AAEA,MAAM,OAAO;AACb,MAAM,YAAY;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Progress";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Progress'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,119 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { styled, withStaticProperties } from "@tamagui/core";
4
+ import { createContextScope } from "@tamagui/create-context";
5
+ import { ThemeableStack, getCircleSize } from "@tamagui/stacks";
6
+ import * as React from "react";
7
+ const PROGRESS_NAME = "Progress";
8
+ const [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
9
+ const [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
10
+ const INDICATOR_NAME = "ProgressIndicator";
11
+ const ProgressIndicatorFrame = styled(ThemeableStack, {
12
+ name: INDICATOR_NAME,
13
+ height: "100%",
14
+ width: "100%"
15
+ });
16
+ const ProgressIndicator = ProgressIndicatorFrame.extractable(React.forwardRef((props, forwardedRef) => {
17
+ var _a, _b;
18
+ const { __scopeProgress, ...indicatorProps } = props;
19
+ const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
20
+ const progress = context.max - ((_a = context.value) != null ? _a : 0);
21
+ return <ProgressIndicatorFrame data-state={getProgressState(context.value, context.max)} data-value={(_b = context.value) != null ? _b : void 0} data-max={context.max} x={`${-progress}%`} {...indicatorProps} ref={forwardedRef} />;
22
+ }));
23
+ ProgressIndicator.displayName = INDICATOR_NAME;
24
+ function defaultGetValueLabel(value, max) {
25
+ return `${Math.round(value / max * 100)}%`;
26
+ }
27
+ __name(defaultGetValueLabel, "defaultGetValueLabel");
28
+ function getProgressState(value, maxValue) {
29
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
30
+ }
31
+ __name(getProgressState, "getProgressState");
32
+ function isNumber(value) {
33
+ return typeof value === "number";
34
+ }
35
+ __name(isNumber, "isNumber");
36
+ function isValidMaxNumber(max) {
37
+ return isNumber(max) && !isNaN(max) && max > 0;
38
+ }
39
+ __name(isValidMaxNumber, "isValidMaxNumber");
40
+ function isValidValueNumber(value, max) {
41
+ return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
42
+ }
43
+ __name(isValidValueNumber, "isValidValueNumber");
44
+ function getInvalidMaxError(propValue, componentName) {
45
+ return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
46
+ }
47
+ __name(getInvalidMaxError, "getInvalidMaxError");
48
+ function getInvalidValueError(propValue, componentName) {
49
+ return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
50
+ - a positive number
51
+ - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
52
+ - \`null\` if the progress is indeterminate.
53
+
54
+ Defaulting to \`null\`.`;
55
+ }
56
+ __name(getInvalidValueError, "getInvalidValueError");
57
+ const DEFAULT_MAX = 100;
58
+ const ProgressFrame = styled(ThemeableStack, {
59
+ name: PROGRESS_NAME,
60
+ borderRadius: 1e5,
61
+ overflow: "hidden",
62
+ variants: {
63
+ size: {
64
+ "...size": (val, extras) => {
65
+ const circleSize = getCircleSize(val, extras);
66
+ const size = circleSize / 3;
67
+ return {
68
+ height: size,
69
+ width: size * 20
70
+ };
71
+ }
72
+ }
73
+ }
74
+ });
75
+ const Progress = withStaticProperties(ProgressFrame.extractable(React.forwardRef((props, forwardedRef) => {
76
+ const {
77
+ __scopeProgress,
78
+ value: valueProp,
79
+ max: maxProp,
80
+ getValueLabel = defaultGetValueLabel,
81
+ size = "$4",
82
+ ...progressProps
83
+ } = props;
84
+ const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
85
+ const value = isValidValueNumber(valueProp, max) ? valueProp : null;
86
+ const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
87
+ return <ProgressProvider scope={__scopeProgress} value={value} max={max}><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} ref={forwardedRef} /></ProgressProvider>;
88
+ })), {
89
+ Indicator: ProgressIndicator
90
+ });
91
+ Progress.displayName = PROGRESS_NAME;
92
+ Progress.propTypes = {
93
+ max(props, propName, componentName) {
94
+ const propValue = props[propName];
95
+ const strVal = String(propValue);
96
+ if (propValue && !isValidMaxNumber(propValue)) {
97
+ return new Error(getInvalidMaxError(strVal, componentName));
98
+ }
99
+ return null;
100
+ },
101
+ value(props, propName, componentName) {
102
+ const valueProp = props[propName];
103
+ const strVal = String(valueProp);
104
+ const max = isValidMaxNumber(props.max) ? props.max : DEFAULT_MAX;
105
+ if (valueProp != null && !isValidValueNumber(valueProp, max)) {
106
+ return new Error(getInvalidValueError(strVal, componentName));
107
+ }
108
+ return null;
109
+ }
110
+ };
111
+ const Root = Progress;
112
+ const Indicator = ProgressIndicator;
113
+ export {
114
+ Indicator,
115
+ Progress,
116
+ ProgressIndicator,
117
+ Root,
118
+ createProgressScope
119
+ };
@@ -0,0 +1 @@
1
+ export * from "./Progress";
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@tamagui/progress",
3
+ "version": "1.0.1-beta.34",
4
+ "sideEffects": true,
5
+ "source": "src/index.ts",
6
+ "types": "./types/index.d.ts",
7
+ "main": "dist/cjs",
8
+ "module": "dist/esm",
9
+ "module:jsx": "dist/jsx",
10
+ "files": [
11
+ "types",
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tamagui-build",
16
+ "watch": "tamagui-build --watch",
17
+ "clean": "tamagui-build clean",
18
+ "clean:build": "tamagui-build clean:build"
19
+ },
20
+ "dependencies": {
21
+ "@tamagui/compose-refs": "^1.0.1-beta.34",
22
+ "@tamagui/core": "^1.0.1-beta.34",
23
+ "@tamagui/create-context": "^1.0.1-beta.34",
24
+ "@tamagui/stacks": "^1.0.1-beta.34"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "*",
28
+ "react-dom": "*",
29
+ "react-native": "*"
30
+ },
31
+ "devDependencies": {
32
+ "@tamagui/build": "^1.0.1-beta.34",
33
+ "@types/react-native": "^0.67.3",
34
+ "react": "*",
35
+ "react-dom": "*",
36
+ "react-native": "*"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }
@@ -0,0 +1,193 @@
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
+ declare const ProgressIndicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
9
+ declare type TamaguiElement = HTMLElement | View;
10
+ 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<{
11
+ fullscreen?: boolean | undefined;
12
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
13
+ } & {
14
+ fontFamily?: unknown;
15
+ hoverable?: boolean | undefined;
16
+ pressable?: boolean | undefined;
17
+ focusable?: boolean | undefined;
18
+ circular?: boolean | undefined;
19
+ pad?: boolean | undefined;
20
+ elevate?: boolean | undefined;
21
+ bordered?: number | boolean | undefined;
22
+ transparent?: boolean | undefined;
23
+ chromeless?: boolean | undefined;
24
+ }, "size"> & {
25
+ size?: import("@tamagui/core").SizeTokens | undefined;
26
+ } & 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<{
27
+ fullscreen?: boolean | undefined;
28
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
29
+ } & {
30
+ fontFamily?: unknown;
31
+ hoverable?: boolean | undefined;
32
+ pressable?: boolean | undefined;
33
+ focusable?: boolean | undefined;
34
+ circular?: boolean | undefined;
35
+ pad?: boolean | undefined;
36
+ elevate?: boolean | undefined;
37
+ bordered?: number | boolean | undefined;
38
+ transparent?: boolean | undefined;
39
+ chromeless?: boolean | undefined;
40
+ }, "size"> & {
41
+ size?: import("@tamagui/core").SizeTokens | undefined;
42
+ }>> & 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<{
43
+ fullscreen?: boolean | undefined;
44
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
45
+ } & {
46
+ fontFamily?: unknown;
47
+ hoverable?: boolean | undefined;
48
+ pressable?: boolean | undefined;
49
+ focusable?: boolean | undefined;
50
+ circular?: boolean | undefined;
51
+ pad?: boolean | undefined;
52
+ elevate?: boolean | undefined;
53
+ bordered?: number | boolean | undefined;
54
+ transparent?: boolean | undefined;
55
+ chromeless?: boolean | undefined;
56
+ }, "size"> & {
57
+ size?: import("@tamagui/core").SizeTokens | undefined;
58
+ }>>, any, import("@tamagui/core").StackPropsBase, {
59
+ fullscreen?: boolean | undefined;
60
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
61
+ } & {
62
+ fontFamily?: unknown;
63
+ hoverable?: boolean | undefined;
64
+ pressable?: boolean | undefined;
65
+ focusable?: boolean | undefined;
66
+ circular?: boolean | undefined;
67
+ pad?: boolean | undefined;
68
+ elevate?: boolean | undefined;
69
+ bordered?: number | boolean | undefined;
70
+ transparent?: boolean | undefined;
71
+ chromeless?: boolean | undefined;
72
+ } & {
73
+ size?: import("@tamagui/core").SizeTokens | undefined;
74
+ }>;
75
+ declare type ProgressProps = GetProps<typeof ProgressFrame> & {
76
+ value?: number | null | undefined;
77
+ max?: number;
78
+ getValueLabel?(value: number, max: number): string;
79
+ };
80
+ 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<{
81
+ fullscreen?: boolean | undefined;
82
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
83
+ } & {
84
+ fontFamily?: unknown;
85
+ hoverable?: boolean | undefined;
86
+ pressable?: boolean | undefined;
87
+ focusable?: boolean | undefined;
88
+ circular?: boolean | undefined;
89
+ pad?: boolean | undefined;
90
+ elevate?: boolean | undefined;
91
+ bordered?: number | boolean | undefined;
92
+ transparent?: boolean | undefined;
93
+ chromeless?: boolean | undefined;
94
+ }, "size"> & {
95
+ size?: import("@tamagui/core").SizeTokens | undefined;
96
+ } & 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<{
97
+ fullscreen?: boolean | undefined;
98
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
99
+ } & {
100
+ fontFamily?: unknown;
101
+ hoverable?: boolean | undefined;
102
+ pressable?: boolean | undefined;
103
+ focusable?: boolean | undefined;
104
+ circular?: boolean | undefined;
105
+ pad?: boolean | undefined;
106
+ elevate?: boolean | undefined;
107
+ bordered?: number | boolean | undefined;
108
+ transparent?: boolean | undefined;
109
+ chromeless?: boolean | undefined;
110
+ }, "size"> & {
111
+ size?: import("@tamagui/core").SizeTokens | undefined;
112
+ }>> & 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<{
113
+ fullscreen?: boolean | undefined;
114
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
115
+ } & {
116
+ fontFamily?: unknown;
117
+ hoverable?: boolean | undefined;
118
+ pressable?: boolean | undefined;
119
+ focusable?: boolean | undefined;
120
+ circular?: boolean | undefined;
121
+ pad?: boolean | undefined;
122
+ elevate?: boolean | undefined;
123
+ bordered?: number | boolean | undefined;
124
+ transparent?: boolean | undefined;
125
+ chromeless?: boolean | undefined;
126
+ }, "size"> & {
127
+ size?: import("@tamagui/core").SizeTokens | undefined;
128
+ }>> & {
129
+ value?: number | null | undefined;
130
+ max?: number | undefined;
131
+ getValueLabel?(value: number, max: number): string;
132
+ } & React.RefAttributes<TamaguiElement>> & {
133
+ Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
134
+ };
135
+ declare const Root: 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<{
136
+ fullscreen?: boolean | undefined;
137
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
138
+ } & {
139
+ fontFamily?: unknown;
140
+ hoverable?: boolean | undefined;
141
+ pressable?: boolean | undefined;
142
+ focusable?: boolean | undefined;
143
+ circular?: boolean | undefined;
144
+ pad?: boolean | undefined;
145
+ elevate?: boolean | undefined;
146
+ bordered?: number | boolean | undefined;
147
+ transparent?: boolean | undefined;
148
+ chromeless?: boolean | undefined;
149
+ }, "size"> & {
150
+ size?: import("@tamagui/core").SizeTokens | undefined;
151
+ } & 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<{
152
+ fullscreen?: boolean | undefined;
153
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
154
+ } & {
155
+ fontFamily?: unknown;
156
+ hoverable?: boolean | undefined;
157
+ pressable?: boolean | undefined;
158
+ focusable?: boolean | undefined;
159
+ circular?: boolean | undefined;
160
+ pad?: 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
+ fullscreen?: boolean | undefined;
169
+ elevation?: import("@tamagui/core").SizeTokens | undefined;
170
+ } & {
171
+ fontFamily?: unknown;
172
+ hoverable?: boolean | undefined;
173
+ pressable?: boolean | undefined;
174
+ focusable?: boolean | undefined;
175
+ circular?: boolean | undefined;
176
+ pad?: boolean | undefined;
177
+ elevate?: boolean | undefined;
178
+ bordered?: number | boolean | undefined;
179
+ transparent?: boolean | undefined;
180
+ chromeless?: boolean | undefined;
181
+ }, "size"> & {
182
+ size?: import("@tamagui/core").SizeTokens | undefined;
183
+ }>> & {
184
+ value?: number | null | undefined;
185
+ max?: number | undefined;
186
+ getValueLabel?(value: number, max: number): string;
187
+ } & React.RefAttributes<TamaguiElement>> & {
188
+ Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
189
+ };
190
+ declare const Indicator: React.ForwardRefExoticComponent<ProgressIndicatorProps & React.RefAttributes<TamaguiElement>>;
191
+ export { createProgressScope, Progress, ProgressIndicator, Root, Indicator, };
192
+ export type { ProgressProps, ProgressIndicatorProps };
193
+ //# 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,EAAgC,MAAM,eAAe,CAAA;AAEtE,OAAO,EAAkB,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AAC5E,OAAO,KAAK,KAAK,MAA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