@tamagui/linear-gradient 2.7.7 → 3.0.0-beta.643.1
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/LinearGradient.cjs +53 -63
- package/dist/cjs/LinearGradient.native.cjs +76 -0
- package/dist/cjs/LinearGradient.native.js +56 -65
- package/dist/cjs/LinearGradient.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -18
- package/dist/cjs/index.native.cjs +27 -0
- package/dist/cjs/index.native.js +15 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/linear-gradient.cjs +97 -122
- package/dist/cjs/linear-gradient.native.cjs +37 -0
- package/dist/cjs/linear-gradient.native.js +22 -26
- package/dist/cjs/linear-gradient.native.js.map +1 -1
- package/dist/esm/LinearGradient.mjs +42 -47
- package/dist/esm/LinearGradient.mjs.map +1 -1
- package/dist/esm/LinearGradient.native.js +46 -51
- package/dist/esm/LinearGradient.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/linear-gradient.mjs +81 -96
- package/dist/esm/linear-gradient.mjs.map +1 -1
- package/dist/esm/linear-gradient.native.js +10 -10
- package/dist/esm/linear-gradient.native.js.map +1 -1
- package/dist/jsx/LinearGradient.mjs +42 -47
- package/dist/jsx/LinearGradient.mjs.map +1 -1
- package/dist/jsx/LinearGradient.native.cjs +76 -0
- package/dist/jsx/LinearGradient.native.js +56 -65
- package/dist/jsx/LinearGradient.native.js.map +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/index.mjs +2 -2
- package/dist/jsx/index.native.cjs +27 -0
- package/dist/jsx/index.native.js +15 -17
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/linear-gradient.mjs +81 -96
- package/dist/jsx/linear-gradient.mjs.map +1 -1
- package/dist/jsx/linear-gradient.native.cjs +37 -0
- package/dist/jsx/linear-gradient.native.js +22 -26
- package/dist/jsx/linear-gradient.native.js.map +1 -1
- package/package.json +9 -8
- package/src/LinearGradient.tsx +16 -5
- package/types/LinearGradient.d.ts +7 -5
- package/types/LinearGradient.d.ts.map +1 -1
- package/types/linear-gradient.d.ts +2 -1
- package/types/linear-gradient.d.ts.map +1 -1
- package/types/linear-gradient.native.d.ts +1 -1
- package/types/linear-gradient.native.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/esm/index.native.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LinearGradient } from "./LinearGradient.native.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export { LinearGradient };
|
|
@@ -2,110 +2,95 @@ import { normalizeColor } from "@tamagui/core";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { View } from "react-native-web";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
5
6
|
function needsDimensionAwareAngle(start, end) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!start && !end) return false;
|
|
8
|
+
const startX = start?.[0] ?? .5;
|
|
9
|
+
const endX = end?.[0] ?? .5;
|
|
10
|
+
return startX !== endX;
|
|
10
11
|
}
|
|
11
|
-
function LinearGradient({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = event.nativeEvent.layout;
|
|
56
|
-
setLayout(oldLayout => {
|
|
57
|
-
if (width2 !== oldLayout.width || height2 !== oldLayout.height) {
|
|
58
|
-
return {
|
|
59
|
-
height: height2,
|
|
60
|
-
width: width2
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return oldLayout;
|
|
64
|
-
});
|
|
65
|
-
if (props.onLayout) {
|
|
66
|
-
props.onLayout(event);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
12
|
+
function LinearGradient({ colors, locations, start, end, ...props }) {
|
|
13
|
+
const normalizedStart = start ? Array.isArray(start) ? start : [start.x, start.y] : void 0;
|
|
14
|
+
const normalizedEnd = end ? Array.isArray(end) ? end : [end.x, end.y] : void 0;
|
|
15
|
+
const needsLayout = needsDimensionAwareAngle(normalizedStart, normalizedEnd);
|
|
16
|
+
const [{ height, width }, setLayout] = React.useState({
|
|
17
|
+
height: 1,
|
|
18
|
+
width: 1
|
|
19
|
+
});
|
|
20
|
+
const linearGradientBackgroundImage = React.useMemo(() => {
|
|
21
|
+
return getLinearGradientBackgroundImage(colors, locations, normalizedStart, normalizedEnd, width, height);
|
|
22
|
+
}, [
|
|
23
|
+
colors,
|
|
24
|
+
locations,
|
|
25
|
+
normalizedStart,
|
|
26
|
+
normalizedEnd,
|
|
27
|
+
width,
|
|
28
|
+
height
|
|
29
|
+
]);
|
|
30
|
+
if (!needsLayout) {
|
|
31
|
+
return /* @__PURE__ */ jsx(View, {
|
|
32
|
+
...props,
|
|
33
|
+
onLayout: props.onLayout,
|
|
34
|
+
style: [props.style, { backgroundImage: linearGradientBackgroundImage }]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ jsx(View, {
|
|
38
|
+
...props,
|
|
39
|
+
style: [props.style, { backgroundImage: linearGradientBackgroundImage }],
|
|
40
|
+
onLayout: (event) => {
|
|
41
|
+
const { width: width2, height: height2 } = event.nativeEvent.layout;
|
|
42
|
+
setLayout((oldLayout) => {
|
|
43
|
+
if (width2 !== oldLayout.width || height2 !== oldLayout.height) {
|
|
44
|
+
return {
|
|
45
|
+
height: height2,
|
|
46
|
+
width: width2
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return oldLayout;
|
|
50
|
+
});
|
|
51
|
+
if (props.onLayout) {
|
|
52
|
+
props.onLayout(event);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
70
56
|
}
|
|
71
57
|
function getLinearGradientBackgroundImage(colors, locations, startPoint, endPoint, width = 1, height = 1) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const angle = calculatePseudoAngle(width, height, startPoint, endPoint);
|
|
76
|
-
return `linear-gradient(${angle}deg, ${gradientColors.join(", ")})`;
|
|
58
|
+
const gradientColors = calculateGradientColors(colors, locations);
|
|
59
|
+
const angle = calculatePseudoAngle(width, height, startPoint, endPoint);
|
|
60
|
+
return `linear-gradient(${angle}deg, ${gradientColors.join(", ")})`;
|
|
77
61
|
}
|
|
78
62
|
function calculatePseudoAngle(width, height, startPoint, endPoint) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
const getControlPoints = () => {
|
|
64
|
+
let correctedStartPoint = [0, 0];
|
|
65
|
+
if (Array.isArray(startPoint)) {
|
|
66
|
+
correctedStartPoint = [startPoint[0] != null ? startPoint[0] : 0, startPoint[1] != null ? startPoint[1] : 0];
|
|
67
|
+
}
|
|
68
|
+
let correctedEndPoint = [0, 1];
|
|
69
|
+
if (Array.isArray(endPoint)) {
|
|
70
|
+
correctedEndPoint = [endPoint[0] != null ? endPoint[0] : 0, endPoint[1] != null ? endPoint[1] : 1];
|
|
71
|
+
}
|
|
72
|
+
return [correctedStartPoint, correctedEndPoint];
|
|
73
|
+
};
|
|
74
|
+
const [start, end] = getControlPoints();
|
|
75
|
+
start[0] *= width;
|
|
76
|
+
end[0] *= width;
|
|
77
|
+
start[1] *= height;
|
|
78
|
+
end[1] *= height;
|
|
79
|
+
const py = end[1] - start[1];
|
|
80
|
+
const px = end[0] - start[0];
|
|
81
|
+
return 90 + Math.atan2(py, px) * 180 / Math.PI;
|
|
98
82
|
}
|
|
99
83
|
function calculateGradientColors(colors, locations) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
84
|
+
return colors.map((color, index) => {
|
|
85
|
+
const output = normalizeColor(color);
|
|
86
|
+
if (locations && locations[index] !== void 0) {
|
|
87
|
+
const location = Math.max(0, Math.min(1, locations[index]));
|
|
88
|
+
const percentage = location * 100;
|
|
89
|
+
return `${output} ${percentage}%`;
|
|
90
|
+
}
|
|
91
|
+
return output;
|
|
92
|
+
});
|
|
109
93
|
}
|
|
94
|
+
|
|
110
95
|
export { LinearGradient };
|
|
111
96
|
//# sourceMappingURL=linear-gradient.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"linear-gradient.js","names":[],"sources":["esm/linear-gradient.js"],"sourcesContent":["import { normalizeColor } from \"@tamagui/core\";\nimport * as React from \"react\";\nimport { View } from \"react-native-web\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction needsDimensionAwareAngle(start, end) {\n if (!start && !end) return false;\n const startX = start?.[0] ?? 0.5;\n const endX = end?.[0] ?? 0.5;\n return startX !== endX;\n}\nfunction LinearGradient({\n colors,\n locations,\n start,\n end,\n ...props\n}) {\n const normalizedStart = start ? Array.isArray(start) ? start : [start.x, start.y] : void 0;\n const normalizedEnd = end ? Array.isArray(end) ? end : [end.x, end.y] : void 0;\n const needsLayout = needsDimensionAwareAngle(\n normalizedStart,\n normalizedEnd\n );\n const [{ height, width }, setLayout] = React.useState({\n height: 1,\n width: 1\n });\n const linearGradientBackgroundImage = React.useMemo(() => {\n return getLinearGradientBackgroundImage(\n // @ts-expect-error ok\n colors,\n locations,\n normalizedStart,\n normalizedEnd,\n width,\n height\n );\n }, [colors, locations, normalizedStart, normalizedEnd, width, height]);\n if (!needsLayout) {\n return /* @__PURE__ */ jsx(\n View,\n {\n ...props,\n onLayout: props.onLayout,\n style: [\n props.style,\n // @ts-ignore: [ts] Property 'backgroundImage' does not exist on type 'ViewStyle'.\n { backgroundImage: linearGradientBackgroundImage }\n ]\n }\n );\n }\n return /* @__PURE__ */ jsx(\n View,\n {\n ...props,\n style: [\n props.style,\n // @ts-ignore: [ts] Property 'backgroundImage' does not exist on type 'ViewStyle'.\n { backgroundImage: linearGradientBackgroundImage }\n ],\n onLayout: (event) => {\n const { width: width2, height: height2 } = event.nativeEvent.layout;\n setLayout((oldLayout) => {\n if (width2 !== oldLayout.width || height2 !== oldLayout.height) {\n return { height: height2, width: width2 };\n }\n return oldLayout;\n });\n if (props.onLayout) {\n props.onLayout(event);\n }\n }\n }\n );\n}\nfunction getLinearGradientBackgroundImage(colors, locations, startPoint, endPoint, width = 1, height = 1) {\n const gradientColors = calculateGradientColors(\n // @ts-expect-error TODO fix numbers\n colors,\n locations\n );\n const angle = calculatePseudoAngle(width, height, startPoint, endPoint);\n return `linear-gradient(${angle}deg, ${gradientColors.join(\", \")})`;\n}\nfunction calculatePseudoAngle(width, height, startPoint, endPoint) {\n const getControlPoints = () => {\n let correctedStartPoint = [0, 0];\n if (Array.isArray(startPoint)) {\n correctedStartPoint = [\n startPoint[0] != null ? startPoint[0] : 0,\n startPoint[1] != null ? startPoint[1] : 0\n ];\n }\n let correctedEndPoint = [0, 1];\n if (Array.isArray(endPoint)) {\n correctedEndPoint = [\n endPoint[0] != null ? endPoint[0] : 0,\n endPoint[1] != null ? endPoint[1] : 1\n ];\n }\n return [correctedStartPoint, correctedEndPoint];\n };\n const [start, end] = getControlPoints();\n start[0] *= width;\n end[0] *= width;\n start[1] *= height;\n end[1] *= height;\n const py = end[1] - start[1];\n const px = end[0] - start[0];\n return 90 + Math.atan2(py, px) * 180 / Math.PI;\n}\nfunction calculateGradientColors(colors, locations) {\n return colors.map((color, index) => {\n const output = normalizeColor(color);\n if (locations && locations[index] !== void 0) {\n const location = Math.max(0, Math.min(1, locations[index]));\n const percentage = location * 100;\n return `${output} ${percentage}%`;\n }\n return output;\n });\n}\nexport {\n LinearGradient\n};\n//# sourceMappingURL=linear-gradient.js.map\n"],"mappings":"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"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getLinearGradient } from "@tamagui/native";
|
|
3
|
+
|
|
3
4
|
function LinearGradient(props) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
console.warn(`Warning: Must call import '@tamagui/native/setup-expo-linear-gradient' at root`);
|
|
12
|
-
return;
|
|
5
|
+
var state = getLinearGradient().state;
|
|
6
|
+
if (state.enabled && state.Component) {
|
|
7
|
+
var ExpoLinearGradient = state.Component;
|
|
8
|
+
return /* @__PURE__ */ jsx(ExpoLinearGradient, { ...props });
|
|
9
|
+
}
|
|
10
|
+
console.warn(`Warning: Must call import '@tamagui/native/setup-expo-linear-gradient' at root`);
|
|
11
|
+
return;
|
|
13
12
|
}
|
|
13
|
+
|
|
14
14
|
export { LinearGradient };
|
|
15
15
|
//# sourceMappingURL=linear-gradient.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"linear-gradient.native.js","names":[],"sources":["esm/linear-gradient.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { getLinearGradient } from \"@tamagui/native\";\nfunction LinearGradient(props) {\n var state = getLinearGradient().state;\n if (state.enabled && state.Component) {\n var ExpoLinearGradient = state.Component;\n return /* @__PURE__ */ _jsx(ExpoLinearGradient, {\n ...props\n });\n }\n console.warn(`Warning: Must call import '@tamagui/native/setup-expo-linear-gradient' at root`);\n return;\n}\nexport {\n LinearGradient\n};\n//# sourceMappingURL=linear-gradient.native.js.map\n"],"mappings":";;;;AAEA,SAAS,eAAe,OAAO;CAC7B,IAAI,QAAQ,kBAAkB,EAAE;CAChC,IAAI,MAAM,WAAW,MAAM,WAAW;EACpC,IAAI,qBAAqB,MAAM;EAC/B,OAAuB,oBAAK,oBAAoB,EAC9C,GAAG,MACL,CAAC;CACH;CACA,QAAQ,KAAK,gFAAgF;CAC7F;AACF"}
|
|
@@ -1,56 +1,51 @@
|
|
|
1
|
-
import { normalizeColor, styled, useProps, useTheme } from "@tamagui/core";
|
|
1
|
+
import { createStyledHOC, normalizeColor, styled, useProps, useTheme } from "@tamagui/core";
|
|
2
2
|
import { YStack } from "@tamagui/stacks";
|
|
3
|
-
import { LinearGradient as
|
|
3
|
+
import { LinearGradient as LinearGradient$1 } from "./linear-gradient.mjs";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
5
6
|
const LinearGradientFrame = styled(YStack, {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
displayName: "LinearGradient",
|
|
8
|
+
overflow: "hidden",
|
|
9
|
+
position: "relative"
|
|
9
10
|
});
|
|
10
|
-
const LinearGradient = LinearGradientFrame
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
start,
|
|
40
|
-
end,
|
|
41
|
-
colors,
|
|
42
|
-
locations,
|
|
43
|
-
style: gradientStyle
|
|
44
|
-
}), children]
|
|
45
|
-
});
|
|
11
|
+
const LinearGradient = createStyledHOC(LinearGradientFrame, (propsIn, ref) => {
|
|
12
|
+
const props = useProps(propsIn);
|
|
13
|
+
const { start, end, colors: colorsProp, locations, children, ...stackProps } = props;
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
let colors = props.colors?.map((c) => {
|
|
16
|
+
return theme[c]?.get("web") ?? c;
|
|
17
|
+
}) || [];
|
|
18
|
+
if (process.env.NODE_ENV !== "production") {
|
|
19
|
+
if (colors.some((c) => {
|
|
20
|
+
const normalized = normalizeColor(c);
|
|
21
|
+
if (!normalized) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
})) {
|
|
25
|
+
console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`);
|
|
26
|
+
colors = ["#000", "#fff"];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ jsxs(LinearGradientFrame, {
|
|
30
|
+
ref,
|
|
31
|
+
...stackProps,
|
|
32
|
+
children: [/* @__PURE__ */ jsx(LinearGradient$1, {
|
|
33
|
+
start,
|
|
34
|
+
end,
|
|
35
|
+
colors,
|
|
36
|
+
locations,
|
|
37
|
+
style: gradientStyle
|
|
38
|
+
}), children]
|
|
39
|
+
});
|
|
46
40
|
});
|
|
47
41
|
const gradientStyle = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
position: "absolute",
|
|
43
|
+
top: 0,
|
|
44
|
+
left: 0,
|
|
45
|
+
right: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
zIndex: 0
|
|
54
48
|
};
|
|
49
|
+
|
|
55
50
|
export { LinearGradient };
|
|
56
51
|
//# sourceMappingURL=LinearGradient.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"LinearGradient.js","names":["ExpoLinearGradient"],"sources":["jsx/LinearGradient.js"],"sourcesContent":["import {\n createStyledHOC,\n normalizeColor,\n styled,\n useProps,\n useTheme\n} from \"@tamagui/core\";\nimport { YStack } from \"@tamagui/stacks\";\nimport { LinearGradient as ExpoLinearGradient } from \"./linear-gradient\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nconst LinearGradientFrame = styled(YStack, {\n displayName: \"LinearGradient\",\n overflow: \"hidden\",\n position: \"relative\"\n});\nconst LinearGradient = createStyledHOC(\n LinearGradientFrame,\n (propsIn, ref) => {\n const props = useProps(propsIn);\n const { start, end, colors: colorsProp, locations, children, ...stackProps } = props;\n const theme = useTheme();\n let colors = props.colors?.map((c) => {\n return theme[c]?.get(\"web\") ?? c;\n }) || [];\n if (process.env.NODE_ENV !== \"production\") {\n if (colors.some((c) => {\n const normalized = normalizeColor(c);\n if (!normalized) {\n return true;\n }\n })) {\n console.error(\n `LinearGradient: \"colors\" prop contains invalid color tokens: ${colors} fallback to default colors: [\"#000\", \"#fff\"]`\n );\n colors = [\"#000\", \"#fff\"];\n }\n }\n return /* @__PURE__ */ jsxs(LinearGradientFrame, { ref, ...stackProps, children: [\n /* @__PURE__ */ jsx(\n ExpoLinearGradient,\n {\n start,\n end,\n colors,\n locations,\n style: gradientStyle\n }\n ),\n children\n ] });\n }\n);\nconst gradientStyle = {\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 0\n};\nexport {\n LinearGradient\n};\n//# sourceMappingURL=LinearGradient.js.map\n"],"mappings":";;;;;;AAUA,MAAM,sBAAsB,OAAO,QAAQ;CACzC,aAAa;CACb,UAAU;CACV,UAAU;AACZ,CAAC;AACD,MAAM,iBAAiB,gBACrB,sBACC,SAAS,QAAQ;CAChB,MAAM,QAAQ,SAAS,OAAO;CAC9B,MAAM,EAAE,OAAO,KAAK,QAAQ,YAAY,WAAW,UAAU,GAAG,eAAe;CAC/E,MAAM,QAAQ,SAAS;CACvB,IAAI,SAAS,MAAM,QAAQ,KAAK,MAAM;EACpC,OAAO,MAAM,IAAI,IAAI,KAAK,KAAK;CACjC,CAAC,KAAK,CAAC;CACP,IAAI,QAAQ,IAAI,aAAa,cAAc;EACzC,IAAI,OAAO,MAAM,MAAM;GACrB,MAAM,aAAa,eAAe,CAAC;GACnC,IAAI,CAAC,YAAY;IACf,OAAO;GACT;EACF,CAAC,GAAG;GACF,QAAQ,MACN,gEAAgE,OAAO,8CACzE;GACA,SAAS,CAAC,QAAQ,MAAM;EAC1B;CACF;CACA,OAAuB,qBAAK,qBAAqB;EAAE;EAAK,GAAG;EAAY,UAAU,CAC/D,oBACdA,kBACA;GACE;GACA;GACA;GACA;GACA,OAAO;EACT,CACF,GACA,QACF;CAAE,CAAC;AACL,CACF;AACA,MAAM,gBAAgB;CACpB,UAAU;CACV,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,QAAQ;AACV"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var LinearGradient_exports = {};
|
|
25
|
+
__export(LinearGradient_exports, { LinearGradient: () => LinearGradient });
|
|
26
|
+
module.exports = __toCommonJS(LinearGradient_exports);
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var import_core = require("@tamagui/core");
|
|
29
|
+
var import_stacks = require("@tamagui/stacks");
|
|
30
|
+
var import_linear_gradient = require("./linear-gradient.native.js");
|
|
31
|
+
var LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
32
|
+
displayName: "LinearGradient",
|
|
33
|
+
overflow: "hidden",
|
|
34
|
+
position: "relative"
|
|
35
|
+
});
|
|
36
|
+
var LinearGradient = (0, import_core.createStyledHOC)(LinearGradientFrame, function(propsIn, ref) {
|
|
37
|
+
var _props_colors;
|
|
38
|
+
var props = (0, import_core.useProps)(propsIn);
|
|
39
|
+
var { start, end, colors: colorsProp, locations, children, ...stackProps } = props;
|
|
40
|
+
var theme = (0, import_core.useTheme)();
|
|
41
|
+
var colors = ((_props_colors = props.colors) === null || _props_colors === void 0 ? void 0 : _props_colors.map(function(c) {
|
|
42
|
+
var _theme_c;
|
|
43
|
+
var _theme_c_get;
|
|
44
|
+
return (_theme_c_get = (_theme_c = theme[c]) === null || _theme_c === void 0 ? void 0 : _theme_c.get("web")) !== null && _theme_c_get !== void 0 ? _theme_c_get : c;
|
|
45
|
+
})) || [];
|
|
46
|
+
if (process.env.NODE_ENV !== "production") {
|
|
47
|
+
if (colors.some(function(c) {
|
|
48
|
+
var normalized = (0, import_core.normalizeColor)(c);
|
|
49
|
+
if (!normalized) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
})) {
|
|
53
|
+
console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`);
|
|
54
|
+
colors = ["#000", "#fff"];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
|
|
58
|
+
ref,
|
|
59
|
+
...stackProps,
|
|
60
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
|
|
61
|
+
start,
|
|
62
|
+
end,
|
|
63
|
+
colors,
|
|
64
|
+
locations,
|
|
65
|
+
style: gradientStyle
|
|
66
|
+
}), children]
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
var gradientStyle = {
|
|
70
|
+
position: "absolute",
|
|
71
|
+
top: 0,
|
|
72
|
+
left: 0,
|
|
73
|
+
right: 0,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
zIndex: 0
|
|
76
|
+
};
|
|
@@ -1,87 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var LinearGradient_exports = {};
|
|
26
|
-
__export(LinearGradient_exports, {
|
|
27
|
-
LinearGradient: () => LinearGradient
|
|
28
|
-
});
|
|
25
|
+
__export(LinearGradient_exports, { LinearGradient: () => LinearGradient });
|
|
29
26
|
module.exports = __toCommonJS(LinearGradient_exports);
|
|
30
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
28
|
var import_core = require("@tamagui/core");
|
|
32
29
|
var import_stacks = require("@tamagui/stacks");
|
|
33
30
|
var import_linear_gradient = require("./linear-gradient.native.js");
|
|
34
31
|
var LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
displayName: "LinearGradient",
|
|
33
|
+
overflow: "hidden",
|
|
34
|
+
position: "relative"
|
|
38
35
|
});
|
|
39
|
-
var LinearGradient =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
start,
|
|
72
|
-
end,
|
|
73
|
-
colors,
|
|
74
|
-
locations,
|
|
75
|
-
style: gradientStyle
|
|
76
|
-
}), children]
|
|
77
|
-
});
|
|
36
|
+
var LinearGradient = (0, import_core.createStyledHOC)(LinearGradientFrame, function(propsIn, ref) {
|
|
37
|
+
var _props_colors;
|
|
38
|
+
var props = (0, import_core.useProps)(propsIn);
|
|
39
|
+
var { start, end, colors: colorsProp, locations, children, ...stackProps } = props;
|
|
40
|
+
var theme = (0, import_core.useTheme)();
|
|
41
|
+
var colors = ((_props_colors = props.colors) === null || _props_colors === void 0 ? void 0 : _props_colors.map(function(c) {
|
|
42
|
+
var _theme_c;
|
|
43
|
+
var _theme_c_get;
|
|
44
|
+
return (_theme_c_get = (_theme_c = theme[c]) === null || _theme_c === void 0 ? void 0 : _theme_c.get("web")) !== null && _theme_c_get !== void 0 ? _theme_c_get : c;
|
|
45
|
+
})) || [];
|
|
46
|
+
if (process.env.NODE_ENV !== "production") {
|
|
47
|
+
if (colors.some(function(c) {
|
|
48
|
+
var normalized = (0, import_core.normalizeColor)(c);
|
|
49
|
+
if (!normalized) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
})) {
|
|
53
|
+
console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`);
|
|
54
|
+
colors = ["#000", "#fff"];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
|
|
58
|
+
ref,
|
|
59
|
+
...stackProps,
|
|
60
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
|
|
61
|
+
start,
|
|
62
|
+
end,
|
|
63
|
+
colors,
|
|
64
|
+
locations,
|
|
65
|
+
style: gradientStyle
|
|
66
|
+
}), children]
|
|
67
|
+
});
|
|
78
68
|
});
|
|
79
69
|
var gradientStyle = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
70
|
+
position: "absolute",
|
|
71
|
+
top: 0,
|
|
72
|
+
left: 0,
|
|
73
|
+
right: 0,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
zIndex: 0
|
|
86
76
|
};
|
|
77
|
+
|
|
87
78
|
//# sourceMappingURL=LinearGradient.native.js.map
|