@tamagui/linear-gradient 3.0.0-beta.755.1 → 3.0.0-beta.804.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.
@@ -29,8 +29,8 @@ __export(linear_gradient_exports, { LinearGradient: () => LinearGradient });
29
29
  module.exports = __toCommonJS(linear_gradient_exports);
30
30
  var import_core = require("@tamagui/core");
31
31
  var React = __toESM(require("react"), 1);
32
- var import_react_native = require("react-native-web");
33
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
+ const WebView = import_core.View;
34
34
  function needsDimensionAwareAngle(start, end) {
35
35
  if (!start && !end) return false;
36
36
  const startX = start?.[0] ?? .5;
@@ -56,13 +56,13 @@ function LinearGradient({ colors, locations, start, end, ...props }) {
56
56
  height
57
57
  ]);
58
58
  if (!needsLayout) {
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WebView, {
60
60
  ...props,
61
61
  onLayout: props.onLayout,
62
62
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }]
63
63
  });
64
64
  }
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
65
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WebView, {
66
66
  ...props,
67
67
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }],
68
68
  onLayout: (event) => {
@@ -1,8 +1,8 @@
1
- import { normalizeColor } from "@tamagui/core";
1
+ import { View, normalizeColor } from "@tamagui/core";
2
2
  import * as React from "react";
3
- import { View } from "react-native-web";
4
3
  import { jsx } from "react/jsx-runtime";
5
4
 
5
+ const WebView = View;
6
6
  function needsDimensionAwareAngle(start, end) {
7
7
  if (!start && !end) return false;
8
8
  const startX = start?.[0] ?? .5;
@@ -28,13 +28,13 @@ function LinearGradient({ colors, locations, start, end, ...props }) {
28
28
  height
29
29
  ]);
30
30
  if (!needsLayout) {
31
- return /* @__PURE__ */ jsx(View, {
31
+ return /* @__PURE__ */ jsx(WebView, {
32
32
  ...props,
33
33
  onLayout: props.onLayout,
34
34
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }]
35
35
  });
36
36
  }
37
- return /* @__PURE__ */ jsx(View, {
37
+ return /* @__PURE__ */ jsx(WebView, {
38
38
  ...props,
39
39
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }],
40
40
  onLayout: (event) => {
@@ -1 +1 @@
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":";;;;;;AAIA,SAAS,yBAAyB,OAAO,KAAK;CAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,OAAO;CAC3B,MAAM,SAAS,QAAQ,MAAM;CAC7B,MAAM,OAAO,MAAM,MAAM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Q;CACtE,OAAO,mBAAmB,MAAM,OAAO,eAAe,KAAK,IAAI,EAAE;AACnE;AACA,SAAS,qBAAqB,OAAO,QAAQ,YAAY,UAAU;CACjE,MAAM,yBAAyB;EAC7B,IAAI,sBAAsB,CAAC,GAAG,CAAC;EAC/B,IAAI,MAAM,QAAQ,UAAU,GAAG;GAC7B,sBAAsB,CACpB,WAAW,MAAM,OAAO,WAAW,KAAK,GACxC,WAAW,MAAM,OAAO,WAAW,KAAK,CAC1C;EACF;EACA,IAAI,oBAAoB,CAAC,GAAG,CAAC;EAC7B,IAAI,MAAM,QAAQ,QAAQ,GAAG;GAC3B,oBAAoB,CAClB,SAAS,MAAM,OAAO,SAAS,KAAK,GACpC,SAAS,MAAM,OAAO,SAAS,KAAK,CACtC;EACF;EACA,OAAO,CAAC,qBAAqB,iBAAiB;CAChD;CACA,MAAM,CAAC,OAAO,OAAO,iBAAiB;CACtC,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,OAAO,KAAK,KAAK,MAAM,IAAI,EAAE,IAAI,MAAM,KAAK;AAC9C;AACA,SAAS,wBAAwB,QAAQ,WAAW;CAClD,OAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,SAAS,eAAe,KAAK;EACnC,IAAI,aAAa,UAAU,WAAW,KAAK,GAAG;GAC5C,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,UAAU,MAAM,CAAC;GAC1D,MAAM,aAAa,WAAW;GAC9B,OAAO,GAAG,OAAO,GAAG,WAAW;EACjC;EACA,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"linear-gradient.js","names":[],"sources":["esm/linear-gradient.js"],"sourcesContent":["import { View, normalizeColor } from \"@tamagui/core\";\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst WebView = View;\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 WebView,\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 WebView,\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":";;;;;AAGA,MAAM,UAAU;AAChB,SAAS,yBAAyB,OAAO,KAAK;CAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,OAAO;CAC3B,MAAM,SAAS,QAAQ,MAAM;CAC7B,MAAM,OAAO,MAAM,MAAM;CACzB,OAAO,WAAW;AACpB;AACA,SAAS,eAAe,EACtB,QACA,WACA,OACA,KACA,GAAG,SACF;CACD,MAAM,kBAAkB,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK;CACzF,MAAM,gBAAgB,MAAM,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK;CAC7E,MAAM,cAAc,yBAClB,iBACA,aACF;CACA,MAAM,CAAC,EAAE,QAAQ,SAAS,aAAa,MAAM,SAAS;EACpD,QAAQ;EACR,OAAO;CACT,CAAC;CACD,M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S,MAAM,OAAO,SAAS,KAAK,GACpC,SAAS,MAAM,OAAO,SAAS,KAAK,CACtC;EACF;EACA,OAAO,CAAC,qBAAqB,iBAAiB;CAChD;CACA,MAAM,CAAC,OAAO,OAAO,iBAAiB;CACtC,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,OAAO,KAAK,KAAK,MAAM,IAAI,EAAE,IAAI,MAAM,KAAK;AAC9C;AACA,SAAS,wBAAwB,QAAQ,WAAW;CAClD,OAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,SAAS,eAAe,KAAK;EACnC,IAAI,aAAa,UAAU,WAAW,KAAK,GAAG;GAC5C,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,UAAU,MAAM,CAAC;GAC1D,MAAM,aAAa,WAAW;GAC9B,OAAO,GAAG,OAAO,GAAG,WAAW;EACjC;EACA,OAAO;CACT,CAAC;AACH"}
@@ -1,8 +1,8 @@
1
- import { normalizeColor } from "@tamagui/core";
1
+ import { View, normalizeColor } from "@tamagui/core";
2
2
  import * as React from "react";
3
- import { View } from "react-native-web";
4
3
  import { jsx } from "react/jsx-runtime";
5
4
 
5
+ const WebView = View;
6
6
  function needsDimensionAwareAngle(start, end) {
7
7
  if (!start && !end) return false;
8
8
  const startX = start?.[0] ?? .5;
@@ -28,13 +28,13 @@ function LinearGradient({ colors, locations, start, end, ...props }) {
28
28
  height
29
29
  ]);
30
30
  if (!needsLayout) {
31
- return /* @__PURE__ */ jsx(View, {
31
+ return /* @__PURE__ */ jsx(WebView, {
32
32
  ...props,
33
33
  onLayout: props.onLayout,
34
34
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }]
35
35
  });
36
36
  }
37
- return /* @__PURE__ */ jsx(View, {
37
+ return /* @__PURE__ */ jsx(WebView, {
38
38
  ...props,
39
39
  style: [props.style, { backgroundImage: linearGradientBackgroundImage }],
40
40
  onLayout: (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"linear-gradient.js","names":[],"sources":["jsx/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":";;;;;;AAIA,SAAS,yBAAyB,OAAO,KAAK;CAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,OAAO;CAC3B,MAAM,SAAS,QAAQ,MAAM;CAC7B,MAAM,OAAO,MAAM,MAAM;CACzB,OAAO,WAAW;AACpB;AACA,SAAS,eAAe,EACtB,QACA,WACA,OACA,KACA,GAAG,SACF;CACD,MAAM,kBAAkB,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK;CACzF,MAAM,gBAAgB,MAAM,MAA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GAC7B,sBAAsB,CACpB,WAAW,MAAM,OAAO,WAAW,KAAK,GACxC,WAAW,MAAM,OAAO,WAAW,KAAK,CAC1C;EACF;EACA,IAAI,oBAAoB,CAAC,GAAG,CAAC;EAC7B,IAAI,MAAM,QAAQ,QAAQ,GAAG;GAC3B,oBAAoB,CAClB,SAAS,MAAM,OAAO,SAAS,KAAK,GACpC,SAAS,MAAM,OAAO,SAAS,KAAK,CACtC;EACF;EACA,OAAO,CAAC,qBAAqB,iBAAiB;CAChD;CACA,MAAM,CAAC,OAAO,OAAO,iBAAiB;CACtC,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,MAAM;CACZ,IAAI,MAAM;CACV,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,OAAO,KAAK,KAAK,MAAM,IAAI,EAAE,IAAI,MAAM,KAAK;AAC9C;AACA,SAAS,wBAAwB,QAAQ,WAAW;CAClD,OAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,SAAS,eAAe,KAAK;EACnC,IAAI,aAAa,UAAU,WAAW,KAAK,GAAG;GAC5C,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,UAAU,MAAM,CAAC;GAC1D,MAAM,aAAa,WAAW;GAC9B,OAAO,GAAG,OAAO,GAAG,WAAW;EACjC;EACA,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"linear-gradient.js","names":[],"sources":["jsx/linear-gradient.js"],"sourcesContent":["import { View, normalizeColor } from \"@tamagui/core\";\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nconst WebView = View;\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 WebView,\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 WebView,\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":";;;;;AAGA,MAAM,UAAU;AAChB,SAAS,yBAAyB,OAAO,KAAK;CAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,OAAO;CAC3B,MAAM,SAAS,QAAQ,MAAM;CAC7B,MAAM,OAAO,MAAM,MAAM;CACzB,OAAO,WAAW;AACpB;AACA,SAAS,eAAe,EACtB,QACA,WACA,OACA,KACA,GAAG,SACF;CACD,MAAM,kBAAkB,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK;CACzF,MAAM,gBAAgB,MAAM,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK;CAC7E,MAAM,cAAc,yBAClB,iBACA,aACF;CACA,MAAM,CAAC,EAAE,QAAQ,SAAS,aAAa,MAAM,SAAS;EACpD,QAAQ;EACR,OAAO;CACT,CAAC;CACD,MAAM,gCAAgC,MAAM,cAAc;EACxD,OAAO,iCAEL,QACA,WACA,iBACA,eACA,OACA,MACF;CACF,GAAG;EAAC;EAAQ;EAAW;EAAiB;EAAe;EAAO;CAAM,CAAC;CACrE,IAAI,CAAC,aAAa;EAChB,OAAuB,oBACrB,SACA;GACE,GAAG;GACH,UAAU,M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,IAAI,MAAM;CACV,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,MAAM,KAAK,IAAI,KAAK,MAAM;CAC1B,OAAO,KAAK,KAAK,MAAM,IAAI,EAAE,IAAI,MAAM,KAAK;AAC9C;AACA,SAAS,wBAAwB,QAAQ,WAAW;CAClD,OAAO,OAAO,KAAK,OAAO,UAAU;EAClC,MAAM,SAAS,eAAe,KAAK;EACnC,IAAI,aAAa,UAAU,WAAW,KAAK,GAAG;GAC5C,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,UAAU,MAAM,CAAC;GAC1D,MAAM,aAAa,WAAW;GAC9B,OAAO,GAAG,OAAO,GAAG,WAAW;EACjC;EACA,OAAO;CACT,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/linear-gradient",
3
- "version": "3.0.0-beta.755.1",
3
+ "version": "3.0.0-beta.804.1",
4
4
  "source": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -34,12 +34,12 @@
34
34
  "clean:build": "tamagui-build clean:build"
35
35
  },
36
36
  "dependencies": {
37
- "@tamagui/core": "3.0.0-beta.755.1",
38
- "@tamagui/native": "3.0.0-beta.755.1",
39
- "@tamagui/stacks": "3.0.0-beta.755.1"
37
+ "@tamagui/core": "3.0.0-beta.804.1",
38
+ "@tamagui/native": "3.0.0-beta.804.1",
39
+ "@tamagui/stacks": "3.0.0-beta.804.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "3.0.0-beta.755.1",
42
+ "@tamagui/build": "3.0.0-beta.804.1",
43
43
  "expo-linear-gradient": "~57.0.1",
44
44
  "react": "19.2.3",
45
45
  "react-native": "0.86.2"
@@ -6,7 +6,7 @@
6
6
  * Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
7
7
  */
8
8
 
9
- import { normalizeColor } from '@tamagui/core'
9
+ import { View, normalizeColor } from '@tamagui/core'
10
10
  import type {
11
11
  LinearGradientPoint,
12
12
  LinearGradientProps,
@@ -16,7 +16,8 @@ import type {
16
16
  export type { LinearGradientPoint, LinearGradientProps } from 'expo-linear-gradient'
17
17
 
18
18
  import * as React from 'react'
19
- import { View } from 'react-native'
19
+
20
+ const WebView = View as React.ComponentType<any>
20
21
 
21
22
  // check if start/end points require dimension-aware angle calculation
22
23
  function needsDimensionAwareAngle(
@@ -74,7 +75,7 @@ export function LinearGradient({
74
75
  // if we don't need dimension-aware angles, skip the onLayout overhead
75
76
  if (!needsLayout) {
76
77
  return (
77
- <View
78
+ <WebView
78
79
  {...props}
79
80
  onLayout={props.onLayout}
80
81
  style={[
@@ -87,7 +88,7 @@ export function LinearGradient({
87
88
  }
88
89
 
89
90
  return (
90
- <View
91
+ <WebView
91
92
  {...props}
92
93
  style={[
93
94
  props.style,
@@ -1 +1 @@
1
- {"version":3,"file":"linear-gradient.d.ts","sourceRoot":"","sources":["../src/linear-gradient.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAEV,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAE7B,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEpF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAoB9B,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,mBAAmB,qBAuErB"}
1
+ {"version":3,"file":"linear-gradient.d.ts","sourceRoot":"","sources":["../src/linear-gradient.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAEV,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAE7B,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEpF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAqB9B,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,mBAAmB,qBAuErB"}