@tamagui/linear-gradient 2.0.0-rc.4 → 2.0.0-rc.40

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.
Files changed (45) hide show
  1. package/dist/cjs/LinearGradient.cjs +64 -52
  2. package/dist/cjs/LinearGradient.native.js +68 -57
  3. package/dist/cjs/LinearGradient.native.js.map +1 -1
  4. package/dist/cjs/index.cjs +12 -10
  5. package/dist/cjs/index.native.js +12 -10
  6. package/dist/cjs/index.native.js.map +1 -1
  7. package/dist/cjs/linear-gradient.cjs +90 -65
  8. package/dist/cjs/linear-gradient.native.js +16 -13
  9. package/dist/cjs/linear-gradient.native.js.map +1 -1
  10. package/dist/esm/LinearGradient.mjs +48 -38
  11. package/dist/esm/LinearGradient.mjs.map +1 -1
  12. package/dist/esm/LinearGradient.native.js +51 -42
  13. package/dist/esm/LinearGradient.native.js.map +1 -1
  14. package/dist/esm/index.js +2 -6
  15. package/dist/esm/index.js.map +1 -6
  16. package/dist/esm/linear-gradient.mjs +62 -39
  17. package/dist/esm/linear-gradient.mjs.map +1 -1
  18. package/dist/esm/linear-gradient.native.js +2 -1
  19. package/dist/esm/linear-gradient.native.js.map +1 -1
  20. package/dist/jsx/LinearGradient.mjs +48 -38
  21. package/dist/jsx/LinearGradient.mjs.map +1 -1
  22. package/dist/jsx/LinearGradient.native.js +68 -57
  23. package/dist/jsx/LinearGradient.native.js.map +1 -1
  24. package/dist/jsx/index.js +2 -6
  25. package/dist/jsx/index.js.map +1 -6
  26. package/dist/jsx/index.native.js +12 -10
  27. package/dist/jsx/linear-gradient.mjs +62 -39
  28. package/dist/jsx/linear-gradient.mjs.map +1 -1
  29. package/dist/jsx/linear-gradient.native.js +16 -13
  30. package/dist/jsx/linear-gradient.native.js.map +1 -1
  31. package/package.json +10 -13
  32. package/dist/cjs/LinearGradient.js +0 -57
  33. package/dist/cjs/LinearGradient.js.map +0 -6
  34. package/dist/cjs/index.js +0 -21
  35. package/dist/cjs/index.js.map +0 -6
  36. package/dist/cjs/linear-gradient.js +0 -118
  37. package/dist/cjs/linear-gradient.js.map +0 -6
  38. package/dist/esm/LinearGradient.js +0 -44
  39. package/dist/esm/LinearGradient.js.map +0 -6
  40. package/dist/esm/linear-gradient.js +0 -97
  41. package/dist/esm/linear-gradient.js.map +0 -6
  42. package/dist/jsx/LinearGradient.js +0 -44
  43. package/dist/jsx/LinearGradient.js.map +0 -6
  44. package/dist/jsx/linear-gradient.js +0 -97
  45. package/dist/jsx/linear-gradient.js.map +0 -6
@@ -3,67 +3,79 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var LinearGradient_exports = {};
22
24
  __export(LinearGradient_exports, {
23
25
  LinearGradient: () => LinearGradient
24
26
  });
25
27
  module.exports = __toCommonJS(LinearGradient_exports);
26
- var import_core = require("@tamagui/core"),
27
- import_stacks = require("@tamagui/stacks"),
28
- import_linear_gradient = require("./linear-gradient.cjs"),
29
- 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.cjs");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
30
32
  const LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
31
- name: "LinearGradient",
32
- overflow: "hidden",
33
- position: "relative"
34
- }),
35
- LinearGradient = LinearGradientFrame.styleable((propsIn, ref) => {
36
- const props = (0, import_core.useProps)(propsIn),
37
- {
38
- start,
39
- end,
40
- colors: colorsProp,
41
- locations,
42
- children,
43
- ...stackProps
44
- } = props,
45
- theme = (0, import_core.useTheme)();
46
- let colors = props.colors?.map(c => theme[c]?.get("web") ?? c) || [];
47
- return process.env.NODE_ENV !== "production" && colors.some(c => {
33
+ name: "LinearGradient",
34
+ overflow: "hidden",
35
+ position: "relative"
36
+ });
37
+ const LinearGradient = LinearGradientFrame.styleable((propsIn, ref) => {
38
+ const props = (0, import_core.useProps)(propsIn);
39
+ const {
40
+ start,
41
+ end,
42
+ colors: colorsProp,
43
+ locations,
44
+ children,
45
+ ...stackProps
46
+ } = props;
47
+ const theme = (0, import_core.useTheme)();
48
+ let colors = props.colors?.map(c => {
49
+ return theme[c]?.get("web") ?? c;
50
+ }) || [];
51
+ if (process.env.NODE_ENV !== "production") {
52
+ if (colors.some(c => {
48
53
  const normalized = (0, import_core.normalizeColor)(c);
49
- if (!normalized || normalized.startsWith("$")) return !0;
50
- }) && (console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`), colors = ["#000", "#fff"]), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
51
- ref,
52
- ...stackProps,
53
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
54
- start,
55
- end,
56
- colors,
57
- locations,
58
- style: gradientStyle
59
- }), children]
60
- });
61
- }),
62
- gradientStyle = {
63
- position: "absolute",
64
- top: 0,
65
- left: 0,
66
- right: 0,
67
- bottom: 0,
68
- zIndex: 0
69
- };
54
+ if (!normalized || normalized.startsWith("$")) {
55
+ return true;
56
+ }
57
+ })) {
58
+ console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`);
59
+ colors = ["#000", "#fff"];
60
+ }
61
+ }
62
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
63
+ ref,
64
+ ...stackProps,
65
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
66
+ start,
67
+ end,
68
+ colors,
69
+ locations,
70
+ style: gradientStyle
71
+ }), children]
72
+ });
73
+ });
74
+ const gradientStyle = {
75
+ position: "absolute",
76
+ top: 0,
77
+ left: 0,
78
+ right: 0,
79
+ bottom: 0,
80
+ zIndex: 0
81
+ };
@@ -5,72 +5,83 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var LinearGradient_exports = {};
24
26
  __export(LinearGradient_exports, {
25
27
  LinearGradient: () => LinearGradient
26
28
  });
27
29
  module.exports = __toCommonJS(LinearGradient_exports);
28
- var import_jsx_runtime = require("react/jsx-runtime"),
29
- import_core = require("@tamagui/core"),
30
- import_stacks = require("@tamagui/stacks"),
31
- import_linear_gradient = require("./linear-gradient.native.js"),
32
- LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
33
- name: "LinearGradient",
34
- overflow: "hidden",
35
- position: "relative"
36
- }),
37
- LinearGradient = LinearGradientFrame.styleable(function (propsIn, ref) {
38
- var _props_colors,
39
- props = (0, import_core.useProps)(propsIn),
40
- {
41
- start,
42
- end,
43
- colors: colorsProp,
44
- locations,
45
- children,
46
- ...stackProps
47
- } = props,
48
- theme = (0, import_core.useTheme)(),
49
- colors = ((_props_colors = props.colors) === null || _props_colors === void 0 ? void 0 : _props_colors.map(function (c) {
50
- var _theme_c, _theme_c_get;
51
- 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;
52
- })) || [];
53
- return process.env.NODE_ENV !== "production" && colors.some(function (c) {
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var import_core = require("@tamagui/core");
32
+ var import_stacks = require("@tamagui/stacks");
33
+ var import_linear_gradient = require("./linear-gradient.native.js");
34
+ var LinearGradientFrame = (0, import_core.styled)(import_stacks.YStack, {
35
+ name: "LinearGradient",
36
+ overflow: "hidden",
37
+ position: "relative"
38
+ });
39
+ var LinearGradient = LinearGradientFrame.styleable(function (propsIn, ref) {
40
+ var _props_colors;
41
+ var props = (0, import_core.useProps)(propsIn);
42
+ var {
43
+ start,
44
+ end,
45
+ colors: colorsProp,
46
+ locations,
47
+ children,
48
+ ...stackProps
49
+ } = props;
50
+ var theme = (0, import_core.useTheme)();
51
+ var colors = ((_props_colors = props.colors) === null || _props_colors === void 0 ? void 0 : _props_colors.map(function (c) {
52
+ var _theme_c;
53
+ var _theme_c_get;
54
+ 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;
55
+ })) || [];
56
+ if (process.env.NODE_ENV !== "production") {
57
+ if (colors.some(function (c) {
54
58
  var normalized = (0, import_core.normalizeColor)(c);
55
- if (!normalized || normalized.startsWith("$")) return !0;
56
- }) && (console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`), colors = ["#000", "#fff"]), /* @__PURE__ */(0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
57
- ref,
58
- ...stackProps,
59
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
60
- start,
61
- end,
62
- colors,
63
- locations,
64
- style: gradientStyle
65
- }), children]
66
- });
67
- }),
68
- gradientStyle = {
69
- position: "absolute",
70
- top: 0,
71
- left: 0,
72
- right: 0,
73
- bottom: 0,
74
- zIndex: 0
75
- };
59
+ if (!normalized || normalized.startsWith("$")) {
60
+ return true;
61
+ }
62
+ })) {
63
+ console.error(`LinearGradient: "colors" prop contains invalid color tokens: ${colors} fallback to default colors: ["#000", "#fff"]`);
64
+ colors = ["#000", "#fff"];
65
+ }
66
+ }
67
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(LinearGradientFrame, {
68
+ ref,
69
+ ...stackProps,
70
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_linear_gradient.LinearGradient, {
71
+ start,
72
+ end,
73
+ colors,
74
+ locations,
75
+ style: gradientStyle
76
+ }), children]
77
+ });
78
+ });
79
+ var gradientStyle = {
80
+ position: "absolute",
81
+ top: 0,
82
+ left: 0,
83
+ right: 0,
84
+ bottom: 0,
85
+ zIndex: 0
86
+ };
76
87
  //# sourceMappingURL=LinearGradient.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","LinearGradient_exports","__export","LinearGradient","module","exports","import_jsx_runtime","require","import_core","import_stacks","import_linear_gradient","LinearGradientFrame","styled","YStack","name","overflow","position","styleable","propsIn","ref","_props_colors","props","useProps","start","end","colors","colorsProp","locations","children","stackProps","theme","useTheme","map","c","_theme_c","_theme_c_get","get","process","env","NODE_ENV","some","normalized","normalizeColor","startsWith","console","error","jsxs","jsx","style","gradientStyle","top","left","right","bottom"],"sources":["../../src/LinearGradient.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAA2D,CAAAK,sBAC3D;AAcA,IAAAK,kBAAM,GAAAC,OAAsB,oBAAO;EAAAC,WAAA,GAAAD,OAAQ;EAAAE,aAAA,GAAAF,OAAA;EAAAG,sBAAA,GAAAH,OAAA;EAAAI,mBAAA,OAAAH,WAAA,CAAAI,MAAA,EAAAH,aAAA,CAAAI,MAAA;IACzCC,IAAA,EAAM;IACNC,QAAA,EAAU;IACVC,QAAA,EAAU;EACZ,CAAC;EAEYb,cAAA,GAAiBQ,mBAAA,CAAoBM,SAAA,WAAAC,OAAA,EAAAC,GAAA;IAChD,IAACC,aAAS;MAAQC,KAAA,OAAAb,WAAA,CAAAc,QAAA,EAAAJ,OAAA;MAAA;QAAAK,KAAA;QAAAC,GAAA;QAAAC,MAAA,EAAAC,UAAA;QAAAC,SAAA;QAAAC,QAAA;QAAA,GAAAC;MAAA,IAAAR,KAAA;MAAAS,KAAA,OAAAtB,WAAA,CAAAuB,QAAA;MAAAN,MAAA,KAAAL,aAAA,GAAAC,KAAA,CAAAI,MAAA,cAAAL,aAAA,uBAAAA,aAAA,CAAAY,GAAA,WAAAC,CAAA;QAChB,IAAAC,QAAM,EAAAC,YAAQ;QAKd,OAAI,CAAAA,YACI,IAAAD,QAAa,GAAAJ,KACT,CAAAG,CAAA,OAAU,IAAI,IAAKC,QAC5B,KAAM,kBAAAA,QAAA,CAAAE,GAAA,qBAAAD,YAAA,cAAAA,YAAA,GAAAF,CAAA;MAET,SAAI;IAGE,OAAAI,OAAM,CAAAC,GAAA,CAAAC,QAAa,qBAAAd,MAAA,CAAee,IAAC,WAAAP,CAAA;MACnC,IAAAQ,UAAK,OAAcjC,WAAW,CAAAkC,cAAc,EAAAT,CAAA;MAC1C,KAAAQ,UAAO,IAAAA,UAAA,CAAAE,UAAA,OAEV,OAED;IAAQ,OACNC,OAAA,CAAAC,KAAA,iEAAsEpB,MAAA,kDAAAA,MAAA,IACxE,MACA,EAMA,yBAAC,IAAAnB,kBAAA,CAAAwC,IAAA,EAAAnC,mBAAA;MAAAQ,GAAA;MAAA,GAAAU,UACC;MAAAD,QACA,kBACA,IAAAtB,kBAAA,CAAAyC,GAAA,EAAArC,sBAAA,CAAAP,cAAA;QAAAoB,KACA;QAAAC,GACA;QAAOC,MAAA;QACTE,SAAA;QACCqB,KAAA,EAAAC;MAAA,CACH,GAEJrB,QAAA;IAMA;EAAU,EACV;EAAAqB,aAAK;IACLjC,QAAM;IACNkC,GAAA;IACAC,IAAA;IACAC,KAAA,GAAQ;IACVC,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","LinearGradient_exports","__export","LinearGradient","module","exports","import_jsx_runtime","require","import_core","import_stacks","import_linear_gradient","LinearGradientFrame","styled","YStack","name","overflow","position","styleable","propsIn","ref","_props_colors","props","useProps","start","end","colors","colorsProp","locations","children","stackProps","theme","useTheme","map","c","_theme_c","_theme_c_get","get","process","env","NODE_ENV","some","normalized","normalizeColor","startsWith","console","error","jsxs","jsx","style","gradientStyle","top","left"],"sources":["../../src/LinearGradient.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAA2D,CAAAK,sBAAA;AAC3D,IAAAK,kBAAuB,GAAAC,OAAA;AAIvB,IAAAC,WAAA,GAAAD,OAAA,gBAAqD;AA6C/C,IAAAE,aAAA,GAAAF,OAAA;AAnCN,IAAAG,sBAAM,GAAAH,OAAsB,8BAAO;AAAQ,IACzCI,mBAAM,OAAAH,WAAA,CAAAI,MAAA,EAAAH,aAAA,CAAAI,MAAA;EACNC,IAAA,kBAAU;EACVC,QAAA,EAAU;EACXC,QAAA;AAEM;AAA2C,IAC/Cb,cAAS,GAAQQ,mBAAA,CAAAM,SAAA,WAAAC,OAAA,EAAAC,GAAA;EAChB,IAAAC,aAAM;EAEN,IAAAC,KAAM,GAAE,IAAAb,WAAY,CAAAc,QAAQ,EAAAJ,OAAY;EACxC;IAAAK,KAAM;IAAAC,GAAA;IAAAC,MAAQ,EAAAC,UAAA;IAAAC,SAAS;IAAAC,QAAA;IAAA,GAAAC;EAAA,IAAAR,KAAA;EAEvB,IAAAS,KAAI,OACFtB,WAAM,CAAAuB,QAAa;EACjB,IAAAN,MAAA,GAAQ,EAAAL,aAAc,GAAKC,KAAgB,CAAAI,MAAA,cAAAL,aAAA,uBAAAA,aAAA,CAAAY,GAAA,WAAAC,CAAA;IAC7C,IAACC,QAAM;IAET,IAAIC,YAAY;IACd,OACE,CAAAA,YAAa,IAAAD,QAAM,GAAAJ,KAAA,CAAAG,CAAA,eAAAC,QAAA,uBAAAA,QAAA,CAAAE,GAAA,qBAAAD,YAAA,cAAAA,YAAA,GAAAF,CAAA;EACjB;EACA,IAAAI,OAAK,CAAAC,GAAA,CAAAC,QAAA,KAAc,YAAW;IAC5B,IAAAd,MAAA,CAAAe,IAAO,WAAAP,CAAA;MAAA,IACTQ,UAAA,OAAAjC,WAAA,CAAAkC,cAAA,EAAAT,CAAA;MACF,IACA,CAAAQ,UAAA,IAAAA,UAAA,CAAAE,UAAA;QACA,WAAQ;MAAA;IACgE,IACxE;MACAC,OAAA,CAAAC,KAAU,iEAAcpB,MAAA;MAC1BA,MAAA,IACF,QAEA,MACE,CACE;IAAA;EAAC;EAAA,sBACC,IAAAnB,kBAAA,CAAAwC,IAAA,EAAAnC,mBAAA;IAAAQ,GAAA;IACA,GAAAU,UACA;IAAAD,QACA,kBACO,IAAAtB,kBAAA,CAAAyC,GAAA,EAAArC,sBAAA,CAAAP,cAAA;MAAAoB,KAAA;MACTC,GAAA;MACCC,MAAA;MACHE,SAAA;MAEJqB,KAAA,EAAAC;IACF,IAIMrB,QAAA;EAEJ;AAAK,EACL;AAAM,IACNqB,aAAO;EACPjC,QAAQ;EACRkC,GAAA;EACFC,IAAA","ignoreList":[]}
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var index_exports = {};
22
24
  __export(index_exports, {
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var index_exports = {};
24
26
  __export(index_exports, {
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","LinearGradient","import_LinearGradient","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAC,qBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAV,YAIO,CAAAK,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","LinearGradient","import_LinearGradient","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAC,qBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAV,YAIO,CAAAK,aAAA","ignoreList":[]}
@@ -2,46 +2,48 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var linear_gradient_exports = {};
33
35
  __export(linear_gradient_exports, {
34
36
  LinearGradient: () => LinearGradient
35
37
  });
36
38
  module.exports = __toCommonJS(linear_gradient_exports);
37
- var import_core = require("@tamagui/core"),
38
- React = __toESM(require("react"), 1),
39
- import_react_native = require("react-native-web"),
40
- import_jsx_runtime = require("react/jsx-runtime");
39
+ var import_core = require("@tamagui/core");
40
+ var React = __toESM(require("react"), 1);
41
+ var import_react_native = require("react-native-web");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
41
43
  function needsDimensionAwareAngle(start, end) {
42
- if (!start && !end) return !1;
43
- const startX = start?.[0] ?? 0.5,
44
- endX = end?.[0] ?? 0.5;
44
+ if (!start && !end) return false;
45
+ const startX = start?.[0] ?? 0.5;
46
+ const endX = end?.[0] ?? 0.5;
45
47
  return startX !== endX;
46
48
  }
47
49
  function LinearGradient({
@@ -51,20 +53,33 @@ function LinearGradient({
51
53
  end,
52
54
  ...props
53
55
  }) {
54
- const normalizedStart = start ? Array.isArray(start) ? start : [start.x, start.y] : void 0,
55
- normalizedEnd = end ? Array.isArray(end) ? end : [end.x, end.y] : void 0,
56
- needsLayout = needsDimensionAwareAngle(normalizedStart, normalizedEnd),
57
- [{
58
- height,
59
- width
60
- }, setLayout] = React.useState({
61
- height: 1,
62
- width: 1
63
- }),
64
- linearGradientBackgroundImage = React.useMemo(() => getLinearGradientBackgroundImage(
56
+ const normalizedStart = start ? Array.isArray(start) ? start : [start.x, start.y] : void 0;
57
+ const normalizedEnd = end ? Array.isArray(end) ? end : [end.x, end.y] : void 0;
58
+ const needsLayout = needsDimensionAwareAngle(normalizedStart, normalizedEnd);
59
+ const [{
60
+ height,
61
+ width
62
+ }, setLayout] = React.useState({
63
+ height: 1,
64
+ width: 1
65
+ });
66
+ const linearGradientBackgroundImage = React.useMemo(() => {
67
+ return getLinearGradientBackgroundImage(
65
68
  // @ts-expect-error ok
66
- colors, locations, normalizedStart, normalizedEnd, width, height), [colors, locations, normalizedStart, normalizedEnd, width, height]);
67
- return needsLayout ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
69
+ colors, locations, normalizedStart, normalizedEnd, width, height);
70
+ }, [colors, locations, normalizedStart, normalizedEnd, width, height]);
71
+ if (!needsLayout) {
72
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
73
+ ...props,
74
+ onLayout: props.onLayout,
75
+ style: [props.style,
76
+ // @ts-ignore: [ts] Property 'backgroundImage' does not exist on type 'ViewStyle'.
77
+ {
78
+ backgroundImage: linearGradientBackgroundImage
79
+ }]
80
+ });
81
+ }
82
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
68
83
  ...props,
69
84
  style: [props.style,
70
85
  // @ts-ignore: [ts] Property 'backgroundImage' does not exist on type 'ViewStyle'.
@@ -76,45 +91,55 @@ function LinearGradient({
76
91
  width: width2,
77
92
  height: height2
78
93
  } = event.nativeEvent.layout;
79
- setLayout(oldLayout => width2 !== oldLayout.width || height2 !== oldLayout.height ? {
80
- height: height2,
81
- width: width2
82
- } : oldLayout), props.onLayout && props.onLayout(event);
94
+ setLayout(oldLayout => {
95
+ if (width2 !== oldLayout.width || height2 !== oldLayout.height) {
96
+ return {
97
+ height: height2,
98
+ width: width2
99
+ };
100
+ }
101
+ return oldLayout;
102
+ });
103
+ if (props.onLayout) {
104
+ props.onLayout(event);
105
+ }
83
106
  }
84
- }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
85
- ...props,
86
- onLayout: props.onLayout,
87
- style: [props.style,
88
- // @ts-ignore: [ts] Property 'backgroundImage' does not exist on type 'ViewStyle'.
89
- {
90
- backgroundImage: linearGradientBackgroundImage
91
- }]
92
107
  });
93
108
  }
94
109
  function getLinearGradientBackgroundImage(colors, locations, startPoint, endPoint, width = 1, height = 1) {
95
110
  const gradientColors = calculateGradientColors(
96
111
  // @ts-expect-error TODO fix numbers
97
112
  colors, locations);
98
- return `linear-gradient(${calculatePseudoAngle(width, height, startPoint, endPoint)}deg, ${gradientColors.join(", ")})`;
113
+ const angle = calculatePseudoAngle(width, height, startPoint, endPoint);
114
+ return `linear-gradient(${angle}deg, ${gradientColors.join(", ")})`;
99
115
  }
100
116
  function calculatePseudoAngle(width, height, startPoint, endPoint) {
101
117
  const getControlPoints = () => {
102
- let correctedStartPoint = [0, 0];
103
- Array.isArray(startPoint) && (correctedStartPoint = [startPoint[0] != null ? startPoint[0] : 0, startPoint[1] != null ? startPoint[1] : 0]);
104
- let correctedEndPoint = [0, 1];
105
- return Array.isArray(endPoint) && (correctedEndPoint = [endPoint[0] != null ? endPoint[0] : 0, endPoint[1] != null ? endPoint[1] : 1]), [correctedStartPoint, correctedEndPoint];
106
- },
107
- [start, end] = getControlPoints();
108
- start[0] *= width, end[0] *= width, start[1] *= height, end[1] *= height;
109
- const py = end[1] - start[1],
110
- px = end[0] - start[0];
118
+ let correctedStartPoint = [0, 0];
119
+ if (Array.isArray(startPoint)) {
120
+ correctedStartPoint = [startPoint[0] != null ? startPoint[0] : 0, startPoint[1] != null ? startPoint[1] : 0];
121
+ }
122
+ let correctedEndPoint = [0, 1];
123
+ if (Array.isArray(endPoint)) {
124
+ correctedEndPoint = [endPoint[0] != null ? endPoint[0] : 0, endPoint[1] != null ? endPoint[1] : 1];
125
+ }
126
+ return [correctedStartPoint, correctedEndPoint];
127
+ };
128
+ const [start, end] = getControlPoints();
129
+ start[0] *= width;
130
+ end[0] *= width;
131
+ start[1] *= height;
132
+ end[1] *= height;
133
+ const py = end[1] - start[1];
134
+ const px = end[0] - start[0];
111
135
  return 90 + Math.atan2(py, px) * 180 / Math.PI;
112
136
  }
113
137
  function calculateGradientColors(colors, locations) {
114
138
  return colors.map((color, index) => {
115
139
  const output = (0, import_core.normalizeColor)(color);
116
140
  if (locations && locations[index] !== void 0) {
117
- const percentage = Math.max(0, Math.min(1, locations[index])) * 100;
141
+ const location = Math.max(0, Math.min(1, locations[index]));
142
+ const percentage = location * 100;
118
143
  return `${output} ${percentage}%`;
119
144
  }
120
145
  return output;
@@ -5,28 +5,30 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var linear_gradient_native_exports = {};
24
26
  __export(linear_gradient_native_exports, {
25
27
  LinearGradient: () => LinearGradient
26
28
  });
27
29
  module.exports = __toCommonJS(linear_gradient_native_exports);
28
- var import_jsx_runtime = require("react/jsx-runtime"),
29
- import_native = require("@tamagui/native");
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ var import_native = require("@tamagui/native");
30
32
  function LinearGradient(props) {
31
33
  var state = (0, import_native.getLinearGradient)().state;
32
34
  if (state.enabled && state.Component) {
@@ -35,6 +37,7 @@ function LinearGradient(props) {
35
37
  ...props
36
38
  });
37
39
  }
38
- console.warn("Warning: Must call import '@tamagui/native/setup-expo-linear-gradient' at root");
40
+ console.warn(`Warning: Must call import '@tamagui/native/setup-expo-linear-gradient' at root`);
41
+ return;
39
42
  }
40
43
  //# sourceMappingURL=linear-gradient.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["linear_gradient_native_exports","__export","LinearGradient","module","exports","__toCommonJS","import_jsx_runtime","require","import_native","props","state","getLinearGradient","enabled","Component","ExpoLinearGradient","jsx","console","warn"],"sources":["../../src/linear-gradient.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,8BAAA;AAAAC,QAAA,CAAAD,8BAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,8BAAA;AAAA,IAAAM,kBAAA,GAA4BC,OAAA;EAC5BC,aAAA,GAAkCD,OAAA;AAC3B,SAASL,eAAeO,KAAA,EAAO;EAClC,IAAIC,KAAA,OAAQF,aAAA,CAAAG,iBAAA,EAAkB,EAAED,KAAA;EAChC,IAAIA,KAAA,CAAME,OAAA,IAAWF,KAAA,CAAMG,SAAA,EAAW;IAClC,IAAIC,kBAAA,GAAqBJ,KAAA,CAAMG,SAAA;IAC/B,OAAqB,mBAAAP,kBAAA,CAAAS,GAAA,EAAKD,kBAAA,EAAoB;MAC1C,GAAGL;IACP,CAAC;EACL;EACAO,OAAA,CAAQC,IAAA,CAAK,gFAAgF;AAEjG","ignoreList":[]}
1
+ {"version":3,"names":["linear_gradient_native_exports","__export","LinearGradient","module","exports","__toCommonJS","import_jsx_runtime","require","import_native","props","state","getLinearGradient","enabled","Component","ExpoLinearGradient","jsx","console","warn"],"sources":["../../src/linear-gradient.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,8BAAA;AAAAC,QAAA,CAAAD,8BAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,8BAAA;AAAA,IAAAM,kBAAA,GAA4BC,OAAA;AAC5B,IAAAC,aAAA,GAAkCD,OAAA;AAC3B,SAASL,eAAeO,KAAA,EAAO;EAClC,IAAIC,KAAA,OAAQF,aAAA,CAAAG,iBAAA,EAAkB,EAAED,KAAA;EAChC,IAAIA,KAAA,CAAME,OAAA,IAAWF,KAAA,CAAMG,SAAA,EAAW;IAClC,IAAIC,kBAAA,GAAqBJ,KAAA,CAAMG,SAAA;IAC/B,OAAqB,mBAAAP,kBAAA,CAAAS,GAAA,EAAKD,kBAAA,EAAoB;MAC1C,GAAGL;IACP,CAAC;EACL;EACAO,OAAA,CAAQC,IAAA,CAAK,gFAAgF;EAC7F;AACJ","ignoreList":[]}