@tamagui/helpers-tamagui 1.0.1-beta.43

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 (36) hide show
  1. package/dist/cjs/index.js +21 -0
  2. package/dist/cjs/index.js.map +7 -0
  3. package/dist/cjs/types.js +16 -0
  4. package/dist/cjs/types.js.map +7 -0
  5. package/dist/cjs/useCurrentColor.js +41 -0
  6. package/dist/cjs/useCurrentColor.js.map +7 -0
  7. package/dist/cjs/useGetThemedIcon.js +64 -0
  8. package/dist/cjs/useGetThemedIcon.js.map +7 -0
  9. package/dist/cjs/wrapStringChildrenInText.js +111 -0
  10. package/dist/cjs/wrapStringChildrenInText.js.map +7 -0
  11. package/dist/esm/index.js +5 -0
  12. package/dist/esm/index.js.map +7 -0
  13. package/dist/esm/types.js +1 -0
  14. package/dist/esm/types.js.map +7 -0
  15. package/dist/esm/useCurrentColor.js +19 -0
  16. package/dist/esm/useCurrentColor.js.map +7 -0
  17. package/dist/esm/useGetThemedIcon.js +23 -0
  18. package/dist/esm/useGetThemedIcon.js.map +7 -0
  19. package/dist/esm/wrapStringChildrenInText.js +70 -0
  20. package/dist/esm/wrapStringChildrenInText.js.map +7 -0
  21. package/dist/jsx/index.js +4 -0
  22. package/dist/jsx/types.js +0 -0
  23. package/dist/jsx/useCurrentColor.js +18 -0
  24. package/dist/jsx/useGetThemedIcon.js +22 -0
  25. package/dist/jsx/wrapStringChildrenInText.js +64 -0
  26. package/package.json +34 -0
  27. package/types/index.d.ts +5 -0
  28. package/types/index.d.ts.map +1 -0
  29. package/types/types.d.ts +12 -0
  30. package/types/types.d.ts.map +1 -0
  31. package/types/useCurrentColor.d.ts +5 -0
  32. package/types/useCurrentColor.d.ts.map +1 -0
  33. package/types/useGetThemedIcon.d.ts +6 -0
  34. package/types/useGetThemedIcon.d.ts.map +1 -0
  35. package/types/wrapStringChildrenInText.d.ts +10 -0
  36. package/types/wrapStringChildrenInText.d.ts.map +1 -0
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./useCurrentColor"), module.exports);
18
+ __reExport(src_exports, require("./useGetThemedIcon"), module.exports);
19
+ __reExport(src_exports, require("./wrapStringChildrenInText"), module.exports);
20
+ __reExport(src_exports, require("./types"), module.exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './useCurrentColor'\nexport * from './useGetThemedIcon'\nexport * from './wrapStringChildrenInText'\nexport * from './types'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,+BADd;AAEA,wBAAc,uCAFd;AAGA,wBAAc,oBAHd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.ts"],
4
+ "sourcesContent": ["import { SizableTextProps } from '@tamagui/text'\n\nexport type TextParentStyles = {\n color?: SizableTextProps['color']\n fontWeight?: SizableTextProps['fontWeight']\n fontSize?: SizableTextProps['fontSize']\n fontFamily?: SizableTextProps['fontFamily']\n letterSpacing?: SizableTextProps['letterSpacing']\n textAlign?: SizableTextProps['textAlign']\n // all the other text controls\n textProps?: Partial<SizableTextProps>\n noTextWrap?: boolean\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useCurrentColor_exports = {};
20
+ __export(useCurrentColor_exports, {
21
+ useCurrentColor: () => useCurrentColor
22
+ });
23
+ module.exports = __toCommonJS(useCurrentColor_exports);
24
+ var import_core = require("@tamagui/core");
25
+ const useCurrentColor = /* @__PURE__ */ __name((colorProp) => {
26
+ const theme = (0, import_core.useTheme)();
27
+ let color;
28
+ if (theme && colorProp && colorProp in theme) {
29
+ color = theme[colorProp];
30
+ } else if (colorProp) {
31
+ color = colorProp;
32
+ } else {
33
+ color = theme == null ? void 0 : theme.color;
34
+ }
35
+ return (color == null ? void 0 : color.toString()) || "";
36
+ }, "useCurrentColor");
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ useCurrentColor
40
+ });
41
+ //# sourceMappingURL=useCurrentColor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useCurrentColor.tsx"],
4
+ "sourcesContent": ["import { ColorTokens, ThemeValueFallback, useTheme } from '@tamagui/core'\nimport { TextStyle } from 'react-native'\n\nexport const useCurrentColor = (colorProp: ColorProp) => {\n const theme = useTheme()\n // get color from prop or theme\n let color: any\n // @ts-expect-error\n if (theme && colorProp && colorProp in theme) {\n // @ts-expect-error\n color = theme[colorProp]\n } else if (colorProp) {\n color = colorProp\n } else {\n color = theme?.color\n }\n return color?.toString() || ('' as string)\n}\n\nexport type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0D;AAGnD,MAAM,kBAAkB,wBAAC,cAAyB;AACvD,QAAM,QAAQ,0BAAS;AAEvB,MAAI;AAEJ,MAAI,SAAS,aAAa,aAAa,OAAO;AAE5C,YAAQ,MAAM;AAAA,EAChB,WAAW,WAAW;AACpB,YAAQ;AAAA,EACV,OAAO;AACL,YAAQ,+BAAO;AAAA,EACjB;AACA,SAAO,gCAAO,eAAe;AAC/B,GAd+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,64 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
38
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var useGetThemedIcon_exports = {};
40
+ __export(useGetThemedIcon_exports, {
41
+ useGetThemedIcon: () => useGetThemedIcon
42
+ });
43
+ module.exports = __toCommonJS(useGetThemedIcon_exports);
44
+ var import_react = __toESM(require("react"));
45
+ var import_useCurrentColor = require("./useCurrentColor");
46
+ const useGetThemedIcon = /* @__PURE__ */ __name((props) => {
47
+ const color = (0, import_useCurrentColor.useCurrentColor)(props.color);
48
+ return (el) => {
49
+ if ((0, import_react.isValidElement)(el)) {
50
+ return el;
51
+ }
52
+ if (el) {
53
+ return import_react.default.createElement(el, __spreadProps(__spreadValues({}, props), {
54
+ color
55
+ }));
56
+ }
57
+ return el;
58
+ };
59
+ }, "useGetThemedIcon");
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ useGetThemedIcon
63
+ });
64
+ //# sourceMappingURL=useGetThemedIcon.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useGetThemedIcon.tsx"],
4
+ "sourcesContent": ["import React, { isValidElement } from 'react'\n\nimport { ColorProp, useCurrentColor } from './useCurrentColor'\n\nexport const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {\n const color = useCurrentColor(props.color)\n return (el: any) => {\n if (isValidElement(el)) {\n return el\n }\n if (el) {\n return React.createElement(el, {\n ...props,\n color,\n })\n }\n return el\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AAEtC,6BAA2C;AAEpC,MAAM,mBAAmB,wBAAC,UAA8C;AAC7E,QAAM,QAAQ,4CAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,iCAAe,EAAE,GAAG;AACtB,aAAO;AAAA,IACT;AACA,QAAI,IAAI;AACN,aAAO,qBAAM,cAAc,IAAI,iCAC1B,QAD0B;AAAA,QAE7B;AAAA,MACF,EAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF,GAdgC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,111 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
38
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var wrapStringChildrenInText_exports = {};
40
+ __export(wrapStringChildrenInText_exports, {
41
+ wrapStringChildrenInText: () => wrapStringChildrenInText
42
+ });
43
+ module.exports = __toCommonJS(wrapStringChildrenInText_exports);
44
+ var import_react = __toESM(require("react"));
45
+ function wrapStringChildrenInText(TextComponent, {
46
+ children,
47
+ textProps,
48
+ size,
49
+ noTextWrap,
50
+ color,
51
+ fontFamily,
52
+ fontSize,
53
+ fontWeight,
54
+ letterSpacing,
55
+ textAlign
56
+ }) {
57
+ if (noTextWrap || !children) {
58
+ return children;
59
+ }
60
+ let allChildren = import_react.default.Children.toArray(children);
61
+ let nextChildren = [];
62
+ let lastIsString = false;
63
+ const directTextProps = {};
64
+ if (color)
65
+ directTextProps.color = color;
66
+ if (fontFamily)
67
+ directTextProps.fontFamily = fontFamily;
68
+ if (fontSize)
69
+ directTextProps.fontSize = fontSize;
70
+ if (fontWeight)
71
+ directTextProps.fontWeight = fontWeight;
72
+ if (letterSpacing)
73
+ directTextProps.letterSpacing = letterSpacing;
74
+ if (textAlign)
75
+ directTextProps.textAlign = textAlign;
76
+ function concatStringChildren() {
77
+ if (!lastIsString)
78
+ return;
79
+ const index = nextChildren.length - 1;
80
+ const childrenStrings = nextChildren[index];
81
+ nextChildren[index] = /* @__PURE__ */ import_react.default.createElement(TextComponent, __spreadValues(__spreadProps(__spreadValues({
82
+ key: index
83
+ }, directTextProps), {
84
+ size
85
+ }), textProps), childrenStrings);
86
+ }
87
+ __name(concatStringChildren, "concatStringChildren");
88
+ for (const child of allChildren) {
89
+ const last = nextChildren[nextChildren.length - 1];
90
+ const isString = typeof child === "string";
91
+ if (isString) {
92
+ if (lastIsString) {
93
+ last.push(child);
94
+ } else {
95
+ nextChildren.push([child]);
96
+ }
97
+ } else {
98
+ concatStringChildren();
99
+ nextChildren.push(child);
100
+ }
101
+ lastIsString = isString;
102
+ }
103
+ concatStringChildren();
104
+ return nextChildren;
105
+ }
106
+ __name(wrapStringChildrenInText, "wrapStringChildrenInText");
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ wrapStringChildrenInText
110
+ });
111
+ //# sourceMappingURL=wrapStringChildrenInText.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapStringChildrenInText.tsx"],
4
+ "sourcesContent": ["import { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport { TextParentStyles } from './types'\n\ntype Props = TextParentStyles & {\n children?: React.ReactNode\n size?: SizeTokens\n}\n\nexport function wrapStringChildrenInText(\n TextComponent: any,\n {\n children,\n textProps,\n size,\n noTextWrap,\n color,\n fontFamily,\n fontSize,\n fontWeight,\n letterSpacing,\n textAlign,\n }: Props\n) {\n if (noTextWrap || !children) {\n return children\n }\n\n // in the case of using variables, like so:\n // <ListItem>Hello, {name}</ListItem>\n // it gives us props.children as ['Hello, ', 'name']\n // but we don't want to wrap multiple SizableText around each part\n // so we group them\n let allChildren = React.Children.toArray(children)\n let nextChildren: any[] = []\n let lastIsString = false\n const directTextProps: any = {}\n // to avoid setting undefined\n if (color) directTextProps.color = color\n if (fontFamily) directTextProps.fontFamily = fontFamily\n if (fontSize) directTextProps.fontSize = fontSize\n if (fontWeight) directTextProps.fontWeight = fontWeight\n if (letterSpacing) directTextProps.letterSpacing = letterSpacing\n if (textAlign) directTextProps.textAlign = textAlign\n\n function concatStringChildren() {\n if (!lastIsString) return\n const index = nextChildren.length - 1\n const childrenStrings = nextChildren[index]\n nextChildren[index] = (\n <TextComponent key={index} {...directTextProps} size={size} {...textProps}>\n {childrenStrings}\n </TextComponent>\n )\n }\n\n for (const child of allChildren) {\n const last = nextChildren[nextChildren.length - 1]\n const isString = typeof child === 'string'\n if (isString) {\n if (lastIsString) {\n last.push(child)\n } else {\n nextChildren.push([child])\n }\n } else {\n concatStringChildren()\n nextChildren.push(child)\n }\n lastIsString = isString\n }\n concatStringChildren()\n\n return nextChildren\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AASX,kCACL,eACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAEF;AACA,MAAI,cAAc,CAAC,UAAU;AAC3B,WAAO;AAAA,EACT;AAOA,MAAI,cAAc,qBAAM,SAAS,QAAQ,QAAQ;AACjD,MAAI,eAAsB,CAAC;AAC3B,MAAI,eAAe;AACnB,QAAM,kBAAuB,CAAC;AAE9B,MAAI;AAAO,oBAAgB,QAAQ;AACnC,MAAI;AAAY,oBAAgB,aAAa;AAC7C,MAAI;AAAU,oBAAgB,WAAW;AACzC,MAAI;AAAY,oBAAgB,aAAa;AAC7C,MAAI;AAAe,oBAAgB,gBAAgB;AACnD,MAAI;AAAW,oBAAgB,YAAY;AAE3C,kCAAgC;AAC9B,QAAI,CAAC;AAAc;AACnB,UAAM,QAAQ,aAAa,SAAS;AACpC,UAAM,kBAAkB,aAAa;AACrC,iBAAa,SACX,mDAAC;AAAA,MAAc,KAAK;AAAA,OAAW,kBAA9B;AAAA,MAA+C;AAAA,QAAgB,YAC7D,eACH;AAAA,EAEJ;AATS;AAWT,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,aAAa,aAAa,SAAS;AAChD,UAAM,WAAW,OAAO,UAAU;AAClC,QAAI,UAAU;AACZ,UAAI,cAAc;AAChB,aAAK,KAAK,KAAK;AAAA,MACjB,OAAO;AACL,qBAAa,KAAK,CAAC,KAAK,CAAC;AAAA,MAC3B;AAAA,IACF,OAAO;AACL,2BAAqB;AACrB,mBAAa,KAAK,KAAK;AAAA,IACzB;AACA,mBAAe;AAAA,EACjB;AACA,uBAAqB;AAErB,SAAO;AACT;AAjEgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./useCurrentColor";
2
+ export * from "./useGetThemedIcon";
3
+ export * from "./wrapStringChildrenInText";
4
+ export * from "./types";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './useCurrentColor'\nexport * from './useGetThemedIcon'\nexport * from './wrapStringChildrenInText'\nexport * from './types'\n"],
5
+ "mappings": "AAAA;AACA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { useTheme } from "@tamagui/core";
4
+ const useCurrentColor = /* @__PURE__ */ __name((colorProp) => {
5
+ const theme = useTheme();
6
+ let color;
7
+ if (theme && colorProp && colorProp in theme) {
8
+ color = theme[colorProp];
9
+ } else if (colorProp) {
10
+ color = colorProp;
11
+ } else {
12
+ color = theme == null ? void 0 : theme.color;
13
+ }
14
+ return (color == null ? void 0 : color.toString()) || "";
15
+ }, "useCurrentColor");
16
+ export {
17
+ useCurrentColor
18
+ };
19
+ //# sourceMappingURL=useCurrentColor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useCurrentColor.tsx"],
4
+ "sourcesContent": ["import { ColorTokens, ThemeValueFallback, useTheme } from '@tamagui/core'\nimport { TextStyle } from 'react-native'\n\nexport const useCurrentColor = (colorProp: ColorProp) => {\n const theme = useTheme()\n // get color from prop or theme\n let color: any\n // @ts-expect-error\n if (theme && colorProp && colorProp in theme) {\n // @ts-expect-error\n color = theme[colorProp]\n } else if (colorProp) {\n color = colorProp\n } else {\n color = theme?.color\n }\n return color?.toString() || ('' as string)\n}\n\nexport type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined\n"],
5
+ "mappings": ";;AAAA;AAGO,MAAM,kBAAkB,wBAAC,cAAyB;AACvD,QAAM,QAAQ,SAAS;AAEvB,MAAI;AAEJ,MAAI,SAAS,aAAa,aAAa,OAAO;AAE5C,YAAQ,MAAM;AAAA,EAChB,WAAW,WAAW;AACpB,YAAQ;AAAA,EACV,OAAO;AACL,YAAQ,+BAAO;AAAA,EACjB;AACA,SAAO,gCAAO,eAAe;AAC/B,GAd+B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import React, { isValidElement } from "react";
4
+ import { useCurrentColor } from "./useCurrentColor";
5
+ const useGetThemedIcon = /* @__PURE__ */ __name((props) => {
6
+ const color = useCurrentColor(props.color);
7
+ return (el) => {
8
+ if (isValidElement(el)) {
9
+ return el;
10
+ }
11
+ if (el) {
12
+ return React.createElement(el, {
13
+ ...props,
14
+ color
15
+ });
16
+ }
17
+ return el;
18
+ };
19
+ }, "useGetThemedIcon");
20
+ export {
21
+ useGetThemedIcon
22
+ };
23
+ //# sourceMappingURL=useGetThemedIcon.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useGetThemedIcon.tsx"],
4
+ "sourcesContent": ["import React, { isValidElement } from 'react'\n\nimport { ColorProp, useCurrentColor } from './useCurrentColor'\n\nexport const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {\n const color = useCurrentColor(props.color)\n return (el: any) => {\n if (isValidElement(el)) {\n return el\n }\n if (el) {\n return React.createElement(el, {\n ...props,\n color,\n })\n }\n return el\n }\n}\n"],
5
+ "mappings": ";;AAAA;AAEA;AAEO,MAAM,mBAAmB,wBAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,eAAe,EAAE,GAAG;AACtB,aAAO;AAAA,IACT;AACA,QAAI,IAAI;AACN,aAAO,MAAM,cAAc,IAAI;AAAA,WAC1B;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF,GAdgC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,70 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import React from "react";
4
+ function wrapStringChildrenInText(TextComponent, {
5
+ children,
6
+ textProps,
7
+ size,
8
+ noTextWrap,
9
+ color,
10
+ fontFamily,
11
+ fontSize,
12
+ fontWeight,
13
+ letterSpacing,
14
+ textAlign
15
+ }) {
16
+ if (noTextWrap || !children) {
17
+ return children;
18
+ }
19
+ let allChildren = React.Children.toArray(children);
20
+ let nextChildren = [];
21
+ let lastIsString = false;
22
+ const directTextProps = {};
23
+ if (color)
24
+ directTextProps.color = color;
25
+ if (fontFamily)
26
+ directTextProps.fontFamily = fontFamily;
27
+ if (fontSize)
28
+ directTextProps.fontSize = fontSize;
29
+ if (fontWeight)
30
+ directTextProps.fontWeight = fontWeight;
31
+ if (letterSpacing)
32
+ directTextProps.letterSpacing = letterSpacing;
33
+ if (textAlign)
34
+ directTextProps.textAlign = textAlign;
35
+ function concatStringChildren() {
36
+ if (!lastIsString)
37
+ return;
38
+ const index = nextChildren.length - 1;
39
+ const childrenStrings = nextChildren[index];
40
+ nextChildren[index] = /* @__PURE__ */ React.createElement(TextComponent, {
41
+ key: index,
42
+ ...directTextProps,
43
+ size,
44
+ ...textProps
45
+ }, childrenStrings);
46
+ }
47
+ __name(concatStringChildren, "concatStringChildren");
48
+ for (const child of allChildren) {
49
+ const last = nextChildren[nextChildren.length - 1];
50
+ const isString = typeof child === "string";
51
+ if (isString) {
52
+ if (lastIsString) {
53
+ last.push(child);
54
+ } else {
55
+ nextChildren.push([child]);
56
+ }
57
+ } else {
58
+ concatStringChildren();
59
+ nextChildren.push(child);
60
+ }
61
+ lastIsString = isString;
62
+ }
63
+ concatStringChildren();
64
+ return nextChildren;
65
+ }
66
+ __name(wrapStringChildrenInText, "wrapStringChildrenInText");
67
+ export {
68
+ wrapStringChildrenInText
69
+ };
70
+ //# sourceMappingURL=wrapStringChildrenInText.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapStringChildrenInText.tsx"],
4
+ "sourcesContent": ["import { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport { TextParentStyles } from './types'\n\ntype Props = TextParentStyles & {\n children?: React.ReactNode\n size?: SizeTokens\n}\n\nexport function wrapStringChildrenInText(\n TextComponent: any,\n {\n children,\n textProps,\n size,\n noTextWrap,\n color,\n fontFamily,\n fontSize,\n fontWeight,\n letterSpacing,\n textAlign,\n }: Props\n) {\n if (noTextWrap || !children) {\n return children\n }\n\n // in the case of using variables, like so:\n // <ListItem>Hello, {name}</ListItem>\n // it gives us props.children as ['Hello, ', 'name']\n // but we don't want to wrap multiple SizableText around each part\n // so we group them\n let allChildren = React.Children.toArray(children)\n let nextChildren: any[] = []\n let lastIsString = false\n const directTextProps: any = {}\n // to avoid setting undefined\n if (color) directTextProps.color = color\n if (fontFamily) directTextProps.fontFamily = fontFamily\n if (fontSize) directTextProps.fontSize = fontSize\n if (fontWeight) directTextProps.fontWeight = fontWeight\n if (letterSpacing) directTextProps.letterSpacing = letterSpacing\n if (textAlign) directTextProps.textAlign = textAlign\n\n function concatStringChildren() {\n if (!lastIsString) return\n const index = nextChildren.length - 1\n const childrenStrings = nextChildren[index]\n nextChildren[index] = (\n <TextComponent key={index} {...directTextProps} size={size} {...textProps}>\n {childrenStrings}\n </TextComponent>\n )\n }\n\n for (const child of allChildren) {\n const last = nextChildren[nextChildren.length - 1]\n const isString = typeof child === 'string'\n if (isString) {\n if (lastIsString) {\n last.push(child)\n } else {\n nextChildren.push([child])\n }\n } else {\n concatStringChildren()\n nextChildren.push(child)\n }\n lastIsString = isString\n }\n concatStringChildren()\n\n return nextChildren\n}\n"],
5
+ "mappings": ";;AACA;AASO,kCACL,eACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAEF;AACA,MAAI,cAAc,CAAC,UAAU;AAC3B,WAAO;AAAA,EACT;AAOA,MAAI,cAAc,MAAM,SAAS,QAAQ,QAAQ;AACjD,MAAI,eAAsB,CAAC;AAC3B,MAAI,eAAe;AACnB,QAAM,kBAAuB,CAAC;AAE9B,MAAI;AAAO,oBAAgB,QAAQ;AACnC,MAAI;AAAY,oBAAgB,aAAa;AAC7C,MAAI;AAAU,oBAAgB,WAAW;AACzC,MAAI;AAAY,oBAAgB,aAAa;AAC7C,MAAI;AAAe,oBAAgB,gBAAgB;AACnD,MAAI;AAAW,oBAAgB,YAAY;AAE3C,kCAAgC;AAC9B,QAAI,CAAC;AAAc;AACnB,UAAM,QAAQ,aAAa,SAAS;AACpC,UAAM,kBAAkB,aAAa;AACrC,iBAAa,SACX,oCAAC;AAAA,MAAc,KAAK;AAAA,SAAW;AAAA,MAAiB;AAAA,SAAgB;AAAA,OAC7D,eACH;AAAA,EAEJ;AATS;AAWT,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,aAAa,aAAa,SAAS;AAChD,UAAM,WAAW,OAAO,UAAU;AAClC,QAAI,UAAU;AACZ,UAAI,cAAc;AAChB,aAAK,KAAK,KAAK;AAAA,MACjB,OAAO;AACL,qBAAa,KAAK,CAAC,KAAK,CAAC;AAAA,MAC3B;AAAA,IACF,OAAO;AACL,2BAAqB;AACrB,mBAAa,KAAK,KAAK;AAAA,IACzB;AACA,mBAAe;AAAA,EACjB;AACA,uBAAqB;AAErB,SAAO;AACT;AAjEgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./useCurrentColor";
2
+ export * from "./useGetThemedIcon";
3
+ export * from "./wrapStringChildrenInText";
4
+ export * from "./types";
File without changes
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { useTheme } from "@tamagui/core";
4
+ const useCurrentColor = /* @__PURE__ */ __name((colorProp) => {
5
+ const theme = useTheme();
6
+ let color;
7
+ if (theme && colorProp && colorProp in theme) {
8
+ color = theme[colorProp];
9
+ } else if (colorProp) {
10
+ color = colorProp;
11
+ } else {
12
+ color = theme == null ? void 0 : theme.color;
13
+ }
14
+ return (color == null ? void 0 : color.toString()) || "";
15
+ }, "useCurrentColor");
16
+ export {
17
+ useCurrentColor
18
+ };
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import React, { isValidElement } from "react";
4
+ import { useCurrentColor } from "./useCurrentColor";
5
+ const useGetThemedIcon = /* @__PURE__ */ __name((props) => {
6
+ const color = useCurrentColor(props.color);
7
+ return (el) => {
8
+ if (isValidElement(el)) {
9
+ return el;
10
+ }
11
+ if (el) {
12
+ return React.createElement(el, {
13
+ ...props,
14
+ color
15
+ });
16
+ }
17
+ return el;
18
+ };
19
+ }, "useGetThemedIcon");
20
+ export {
21
+ useGetThemedIcon
22
+ };
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import React from "react";
4
+ function wrapStringChildrenInText(TextComponent, {
5
+ children,
6
+ textProps,
7
+ size,
8
+ noTextWrap,
9
+ color,
10
+ fontFamily,
11
+ fontSize,
12
+ fontWeight,
13
+ letterSpacing,
14
+ textAlign
15
+ }) {
16
+ if (noTextWrap || !children) {
17
+ return children;
18
+ }
19
+ let allChildren = React.Children.toArray(children);
20
+ let nextChildren = [];
21
+ let lastIsString = false;
22
+ const directTextProps = {};
23
+ if (color)
24
+ directTextProps.color = color;
25
+ if (fontFamily)
26
+ directTextProps.fontFamily = fontFamily;
27
+ if (fontSize)
28
+ directTextProps.fontSize = fontSize;
29
+ if (fontWeight)
30
+ directTextProps.fontWeight = fontWeight;
31
+ if (letterSpacing)
32
+ directTextProps.letterSpacing = letterSpacing;
33
+ if (textAlign)
34
+ directTextProps.textAlign = textAlign;
35
+ function concatStringChildren() {
36
+ if (!lastIsString)
37
+ return;
38
+ const index = nextChildren.length - 1;
39
+ const childrenStrings = nextChildren[index];
40
+ nextChildren[index] = <TextComponent key={index} {...directTextProps} size={size} {...textProps}>{childrenStrings}</TextComponent>;
41
+ }
42
+ __name(concatStringChildren, "concatStringChildren");
43
+ for (const child of allChildren) {
44
+ const last = nextChildren[nextChildren.length - 1];
45
+ const isString = typeof child === "string";
46
+ if (isString) {
47
+ if (lastIsString) {
48
+ last.push(child);
49
+ } else {
50
+ nextChildren.push([child]);
51
+ }
52
+ } else {
53
+ concatStringChildren();
54
+ nextChildren.push(child);
55
+ }
56
+ lastIsString = isString;
57
+ }
58
+ concatStringChildren();
59
+ return nextChildren;
60
+ }
61
+ __name(wrapStringChildrenInText, "wrapStringChildrenInText");
62
+ export {
63
+ wrapStringChildrenInText
64
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tamagui/helpers-tamagui",
3
+ "version": "1.0.1-beta.43",
4
+ "source": "src/index.ts",
5
+ "types": "./types/index.d.ts",
6
+ "main": "dist/cjs",
7
+ "module": "dist/esm",
8
+ "module:jsx": "dist/jsx",
9
+ "files": [
10
+ "types",
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tamagui-build",
15
+ "watch": "tamagui-build --watch",
16
+ "clean": "tamagui-build clean",
17
+ "clean:build": "tamagui-build clean:build"
18
+ },
19
+ "dependencies": {
20
+ "@tamagui/text": "^1.0.1-beta.43"
21
+ },
22
+ "devDependencies": {
23
+ "@tamagui/build": "^1.0.1-beta.43",
24
+ "react": "*",
25
+ "react-native": "*"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "*",
29
+ "react-native": "*"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
34
+ }
@@ -0,0 +1,5 @@
1
+ export * from './useCurrentColor';
2
+ export * from './useGetThemedIcon';
3
+ export * from './wrapStringChildrenInText';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { SizableTextProps } from '@tamagui/text';
2
+ export declare type TextParentStyles = {
3
+ color?: SizableTextProps['color'];
4
+ fontWeight?: SizableTextProps['fontWeight'];
5
+ fontSize?: SizableTextProps['fontSize'];
6
+ fontFamily?: SizableTextProps['fontFamily'];
7
+ letterSpacing?: SizableTextProps['letterSpacing'];
8
+ textAlign?: SizableTextProps['textAlign'];
9
+ textProps?: Partial<SizableTextProps>;
10
+ noTextWrap?: boolean;
11
+ };
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEhD,oBAAY,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IAC3C,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IACvC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IAC3C,aAAa,CAAC,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAA;IACjD,SAAS,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IAEzC,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ColorTokens, ThemeValueFallback } from '@tamagui/core';
2
+ import { TextStyle } from 'react-native';
3
+ export declare const useCurrentColor: (colorProp: ColorProp) => any;
4
+ export declare type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined;
5
+ //# sourceMappingURL=useCurrentColor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentColor.d.ts","sourceRoot":"","sources":["../src/useCurrentColor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAY,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,eAAO,MAAM,eAAe,cAAe,SAAS,QAcnD,CAAA;AAED,oBAAY,SAAS,GAAG,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { ColorProp } from './useCurrentColor';
2
+ export declare const useGetThemedIcon: (props: {
3
+ color: ColorProp;
4
+ size: number;
5
+ }) => (el: any) => any;
6
+ //# sourceMappingURL=useGetThemedIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetThemedIcon.d.ts","sourceRoot":"","sources":["../src/useGetThemedIcon.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAA;AAE9D,eAAO,MAAM,gBAAgB,UAAW;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,UAE5D,GAAG,QAYhB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { SizeTokens } from '@tamagui/core';
2
+ import React from 'react';
3
+ import { TextParentStyles } from './types';
4
+ declare type Props = TextParentStyles & {
5
+ children?: React.ReactNode;
6
+ size?: SizeTokens;
7
+ };
8
+ export declare function wrapStringChildrenInText(TextComponent: any, { children, textProps, size, noTextWrap, color, fontFamily, fontSize, fontWeight, letterSpacing, textAlign, }: Props): React.ReactNode;
9
+ export {};
10
+ //# sourceMappingURL=wrapStringChildrenInText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapStringChildrenInText.d.ts","sourceRoot":"","sources":["../src/wrapStringChildrenInText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,aAAK,KAAK,GAAG,gBAAgB,GAAG;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,GAAG,EAClB,EACE,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,UAAU,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,SAAS,GACV,EAAE,KAAK,mBAoDT"}