@tamagui/progress 1.88.13 → 1.89.0-1706308641099

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,131 @@
1
+ import { getVariableValue, styled } from "@tamagui/core";
2
+ import { createContextScope } from "@tamagui/create-context";
3
+ import { getSize } from "@tamagui/get-token";
4
+ import { withStaticProperties } from "@tamagui/helpers";
5
+ import { ThemeableStack } from "@tamagui/stacks";
6
+ import * as React from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ const PROGRESS_NAME = "Progress",
9
+ [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME),
10
+ [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
11
+ INDICATOR_NAME = "ProgressIndicator",
12
+ ProgressIndicatorFrame = styled(ThemeableStack, {
13
+ name: INDICATOR_NAME,
14
+ variants: {
15
+ unstyled: {
16
+ false: {
17
+ height: "100%",
18
+ width: "100%",
19
+ backgrounded: !0
20
+ }
21
+ }
22
+ },
23
+ defaultVariants: {
24
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
25
+ }
26
+ }),
27
+ ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
28
+ const {
29
+ __scopeProgress,
30
+ ...indicatorProps
31
+ } = props,
32
+ context = useProgressContext(INDICATOR_NAME, __scopeProgress),
33
+ pct = context.max - (context.value ?? 0),
34
+ x = -(context.width === 0 ? 300 : context.width) * (pct / 100);
35
+ return /* @__PURE__ */jsx(ProgressIndicatorFrame, {
36
+ "data-state": getProgressState(context.value, context.max),
37
+ "data-value": context.value ?? void 0,
38
+ "data-max": context.max,
39
+ x,
40
+ width: context.width,
41
+ ...(!props.unstyled && {
42
+ animateOnly: ["transform"],
43
+ opacity: context.width === 0 ? 0 : 1
44
+ }),
45
+ ...indicatorProps,
46
+ ref: forwardedRef
47
+ });
48
+ });
49
+ function defaultGetValueLabel(value, max) {
50
+ return `${Math.round(value / max * 100)}%`;
51
+ }
52
+ function getProgressState(value, maxValue) {
53
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
54
+ }
55
+ function isNumber(value) {
56
+ return typeof value == "number";
57
+ }
58
+ function isValidMaxNumber(max) {
59
+ return isNumber(max) && !Number.isNaN(max) && max > 0;
60
+ }
61
+ function isValidValueNumber(value, max) {
62
+ return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
63
+ }
64
+ const DEFAULT_MAX = 100,
65
+ ProgressFrame = styled(ThemeableStack, {
66
+ name: "Progress",
67
+ variants: {
68
+ unstyled: {
69
+ false: {
70
+ borderRadius: 1e5,
71
+ overflow: "hidden",
72
+ backgrounded: !0
73
+ }
74
+ },
75
+ size: {
76
+ "...size": val => {
77
+ const size = Math.round(getVariableValue(getSize(val)) * 0.25);
78
+ return {
79
+ height: size,
80
+ minWidth: getVariableValue(size) * 20,
81
+ width: "100%"
82
+ };
83
+ }
84
+ }
85
+ },
86
+ defaultVariants: {
87
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
88
+ }
89
+ }),
90
+ Progress = withStaticProperties(ProgressFrame.styleable(function (props, forwardedRef) {
91
+ const {
92
+ // @ts-expect-error
93
+ __scopeProgress,
94
+ value: valueProp,
95
+ max: maxProp,
96
+ getValueLabel = defaultGetValueLabel,
97
+ size = "$true",
98
+ ...progressProps
99
+ } = props,
100
+ max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
101
+ value = isValidValueNumber(valueProp, max) ? valueProp : null,
102
+ valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
103
+ [width, setWidth] = React.useState(0);
104
+ return /* @__PURE__ */jsx(ProgressProvider, {
105
+ scope: __scopeProgress,
106
+ value,
107
+ max,
108
+ width,
109
+ children: /* @__PURE__ */jsx(ProgressFrame, {
110
+ "aria-valuemax": max,
111
+ "aria-valuemin": 0,
112
+ "aria-valuenow": isNumber(value) ? value : void 0,
113
+ "aria-valuetext": valueLabel,
114
+ role: "progressbar",
115
+ "data-state": getProgressState(value, max),
116
+ "data-value": value ?? void 0,
117
+ "data-max": max,
118
+ ...(progressProps.unstyled !== !0 && {
119
+ size
120
+ }),
121
+ ...progressProps,
122
+ onLayout: e => {
123
+ setWidth(e.nativeEvent.layout.width), progressProps.onLayout?.(e);
124
+ },
125
+ ref: forwardedRef
126
+ })
127
+ });
128
+ }), {
129
+ Indicator: ProgressIndicator
130
+ });
131
+ export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
@@ -0,0 +1 @@
1
+ export * from "./Progress.mjs";
@@ -0,0 +1,131 @@
1
+ import { getVariableValue, styled } from "@tamagui/core";
2
+ import { createContextScope } from "@tamagui/create-context";
3
+ import { getSize } from "@tamagui/get-token";
4
+ import { withStaticProperties } from "@tamagui/helpers";
5
+ import { ThemeableStack } from "@tamagui/stacks";
6
+ import * as React from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ const PROGRESS_NAME = "Progress",
9
+ [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME),
10
+ [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME),
11
+ INDICATOR_NAME = "ProgressIndicator",
12
+ ProgressIndicatorFrame = styled(ThemeableStack, {
13
+ name: INDICATOR_NAME,
14
+ variants: {
15
+ unstyled: {
16
+ false: {
17
+ height: "100%",
18
+ width: "100%",
19
+ backgrounded: !0
20
+ }
21
+ }
22
+ },
23
+ defaultVariants: {
24
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
25
+ }
26
+ }),
27
+ ProgressIndicator = ProgressIndicatorFrame.styleable(function (props, forwardedRef) {
28
+ const {
29
+ __scopeProgress,
30
+ ...indicatorProps
31
+ } = props,
32
+ context = useProgressContext(INDICATOR_NAME, __scopeProgress),
33
+ pct = context.max - (context.value ?? 0),
34
+ x = -(context.width === 0 ? 300 : context.width) * (pct / 100);
35
+ return /* @__PURE__ */jsx(ProgressIndicatorFrame, {
36
+ "data-state": getProgressState(context.value, context.max),
37
+ "data-value": context.value ?? void 0,
38
+ "data-max": context.max,
39
+ x,
40
+ width: context.width,
41
+ ...(!props.unstyled && {
42
+ animateOnly: ["transform"],
43
+ opacity: context.width === 0 ? 0 : 1
44
+ }),
45
+ ...indicatorProps,
46
+ ref: forwardedRef
47
+ });
48
+ });
49
+ function defaultGetValueLabel(value, max) {
50
+ return `${Math.round(value / max * 100)}%`;
51
+ }
52
+ function getProgressState(value, maxValue) {
53
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
54
+ }
55
+ function isNumber(value) {
56
+ return typeof value == "number";
57
+ }
58
+ function isValidMaxNumber(max) {
59
+ return isNumber(max) && !Number.isNaN(max) && max > 0;
60
+ }
61
+ function isValidValueNumber(value, max) {
62
+ return isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;
63
+ }
64
+ const DEFAULT_MAX = 100,
65
+ ProgressFrame = styled(ThemeableStack, {
66
+ name: "Progress",
67
+ variants: {
68
+ unstyled: {
69
+ false: {
70
+ borderRadius: 1e5,
71
+ overflow: "hidden",
72
+ backgrounded: !0
73
+ }
74
+ },
75
+ size: {
76
+ "...size": val => {
77
+ const size = Math.round(getVariableValue(getSize(val)) * 0.25);
78
+ return {
79
+ height: size,
80
+ minWidth: getVariableValue(size) * 20,
81
+ width: "100%"
82
+ };
83
+ }
84
+ }
85
+ },
86
+ defaultVariants: {
87
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
88
+ }
89
+ }),
90
+ Progress = withStaticProperties(ProgressFrame.styleable(function (props, forwardedRef) {
91
+ const {
92
+ // @ts-expect-error
93
+ __scopeProgress,
94
+ value: valueProp,
95
+ max: maxProp,
96
+ getValueLabel = defaultGetValueLabel,
97
+ size = "$true",
98
+ ...progressProps
99
+ } = props,
100
+ max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX,
101
+ value = isValidValueNumber(valueProp, max) ? valueProp : null,
102
+ valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0,
103
+ [width, setWidth] = React.useState(0);
104
+ return /* @__PURE__ */jsx(ProgressProvider, {
105
+ scope: __scopeProgress,
106
+ value,
107
+ max,
108
+ width,
109
+ children: /* @__PURE__ */jsx(ProgressFrame, {
110
+ "aria-valuemax": max,
111
+ "aria-valuemin": 0,
112
+ "aria-valuenow": isNumber(value) ? value : void 0,
113
+ "aria-valuetext": valueLabel,
114
+ role: "progressbar",
115
+ "data-state": getProgressState(value, max),
116
+ "data-value": value ?? void 0,
117
+ "data-max": max,
118
+ ...(progressProps.unstyled !== !0 && {
119
+ size
120
+ }),
121
+ ...progressProps,
122
+ onLayout: e => {
123
+ setWidth(e.nativeEvent.layout.width), progressProps.onLayout?.(e);
124
+ },
125
+ ref: forwardedRef
126
+ })
127
+ });
128
+ }), {
129
+ Indicator: ProgressIndicator
130
+ });
131
+ export { Progress, ProgressFrame, ProgressIndicator, ProgressIndicatorFrame, createProgressScope };
@@ -0,0 +1 @@
1
+ export * from "./Progress.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/progress",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -32,19 +32,19 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@tamagui/compose-refs": "1.88.13",
36
- "@tamagui/core": "1.88.13",
37
- "@tamagui/create-context": "1.88.13",
38
- "@tamagui/get-token": "1.88.13",
39
- "@tamagui/helpers": "1.88.13",
40
- "@tamagui/stacks": "1.88.13"
35
+ "@tamagui/compose-refs": "1.89.0-1706308641099",
36
+ "@tamagui/core": "1.89.0-1706308641099",
37
+ "@tamagui/create-context": "1.89.0-1706308641099",
38
+ "@tamagui/get-token": "1.89.0-1706308641099",
39
+ "@tamagui/helpers": "1.89.0-1706308641099",
40
+ "@tamagui/stacks": "1.89.0-1706308641099"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "*",
44
44
  "react-native": "*"
45
45
  },
46
46
  "devDependencies": {
47
- "@tamagui/build": "1.88.13",
47
+ "@tamagui/build": "1.89.0-1706308641099",
48
48
  "react": "^18.2.0",
49
49
  "react-native": "^0.72.6"
50
50
  },