@tamagui/helpers-tamagui 1.0.1-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/useCurrentColor.js +40 -0
- package/dist/cjs/useCurrentColor.js.map +7 -0
- package/dist/cjs/useGetThemedIcon.js +65 -0
- package/dist/cjs/useGetThemedIcon.js.map +7 -0
- package/dist/cjs/wrapStringChildrenInText.js +108 -0
- package/dist/cjs/wrapStringChildrenInText.js.map +7 -0
- package/dist/cjs/wrapStringChildrenInText.test.js +31 -0
- package/dist/cjs/wrapStringChildrenInText.test.js.map +7 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/useCurrentColor.js +17 -0
- package/dist/esm/useCurrentColor.js.map +7 -0
- package/dist/esm/useGetThemedIcon.js +41 -0
- package/dist/esm/useGetThemedIcon.js.map +7 -0
- package/dist/esm/wrapStringChildrenInText.js +84 -0
- package/dist/esm/wrapStringChildrenInText.js.map +7 -0
- package/dist/esm/wrapStringChildrenInText.test.js +31 -0
- package/dist/esm/wrapStringChildrenInText.test.js.map +7 -0
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/dist/jsx/useCurrentColor.js +17 -0
- package/dist/jsx/useCurrentColor.js.map +7 -0
- package/dist/jsx/useGetThemedIcon.js +25 -0
- package/dist/jsx/useGetThemedIcon.js.map +7 -0
- package/dist/jsx/wrapStringChildrenInText.js +61 -0
- package/dist/jsx/wrapStringChildrenInText.js.map +7 -0
- package/dist/jsx/wrapStringChildrenInText.test.js +29 -0
- package/dist/jsx/wrapStringChildrenInText.test.js.map +7 -0
- package/package.json +37 -0
- package/src/index.ts +3 -0
- package/src/types.ts +13 -0
- package/src/useCurrentColor.tsx +20 -0
- package/src/useGetThemedIcon.tsx +24 -0
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +12 -0
- package/types/types.d.ts.map +1 -0
- package/types/useCurrentColor.d.ts +5 -0
- package/types/useCurrentColor.d.ts.map +1 -0
- package/types/useGetThemedIcon.d.ts +6 -0
- package/types/useGetThemedIcon.d.ts.map +1 -0
- package/types/wrapStringChildrenInText.d.ts +10 -0
- package/types/wrapStringChildrenInText.d.ts.map +1 -0
- package/types/wrapStringChildrenInText.test.d.ts +2 -0
- package/types/wrapStringChildrenInText.test.d.ts.map +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
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("./types"), module.exports);
|
|
20
|
+
//# 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 './types'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,+BADd;AAEA,wBAAc,oBAFd;",
|
|
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,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useCurrentColor_exports = {};
|
|
19
|
+
__export(useCurrentColor_exports, {
|
|
20
|
+
useCurrentColor: () => useCurrentColor
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useCurrentColor_exports);
|
|
23
|
+
var import_core = require("@tamagui/core");
|
|
24
|
+
const useCurrentColor = (colorProp) => {
|
|
25
|
+
const theme = (0, import_core.useTheme)();
|
|
26
|
+
let color;
|
|
27
|
+
if (theme && colorProp && colorProp in theme) {
|
|
28
|
+
color = theme[colorProp];
|
|
29
|
+
} else if (colorProp) {
|
|
30
|
+
color = colorProp;
|
|
31
|
+
} else {
|
|
32
|
+
color = theme == null ? void 0 : theme.color;
|
|
33
|
+
}
|
|
34
|
+
return (color == null ? void 0 : color.toString()) || "";
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
useCurrentColor
|
|
39
|
+
});
|
|
40
|
+
//# 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 type { 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,CAAC,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
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));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var useGetThemedIcon_exports = {};
|
|
39
|
+
__export(useGetThemedIcon_exports, {
|
|
40
|
+
useGetThemedIcon: () => useGetThemedIcon
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(useGetThemedIcon_exports);
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
var import_useCurrentColor = require("./useCurrentColor");
|
|
45
|
+
const useGetThemedIcon = (props) => {
|
|
46
|
+
const color = (0, import_useCurrentColor.useCurrentColor)(props.color);
|
|
47
|
+
return (el) => {
|
|
48
|
+
if (el) {
|
|
49
|
+
if ((0, import_react.isValidElement)(el)) {
|
|
50
|
+
return import_react.default.cloneElement(el, __spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
51
|
+
color
|
|
52
|
+
}), el.props));
|
|
53
|
+
}
|
|
54
|
+
return import_react.default.createElement(el, __spreadProps(__spreadValues({}, props), {
|
|
55
|
+
color
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
return el;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
useGetThemedIcon
|
|
64
|
+
});
|
|
65
|
+
//# 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 (el) {\n if (isValidElement(el)) {\n return React.cloneElement(el as any, {\n ...props,\n color,\n // @ts-ignore\n ...el.props,\n })\n }\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,CAAC,UAA8C;AAC7E,QAAM,QAAQ,4CAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,IAAI;AACN,UAAI,iCAAe,EAAE,GAAG;AACtB,eAAO,qBAAM,aAAa,IAAW,gDAChC,QADgC;AAAA,UAEnC;AAAA,YAEG,GAAG,MACP;AAAA,MACH;AACA,aAAO,qBAAM,cAAc,IAAI,iCAC1B,QAD0B;AAAA,QAE7B;AAAA,MACF,EAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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 __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
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));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var wrapStringChildrenInText_exports = {};
|
|
39
|
+
__export(wrapStringChildrenInText_exports, {
|
|
40
|
+
wrapStringChildrenInText: () => wrapStringChildrenInText
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(wrapStringChildrenInText_exports);
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
function wrapStringChildrenInText(TextComponent, {
|
|
45
|
+
children,
|
|
46
|
+
textProps,
|
|
47
|
+
size,
|
|
48
|
+
noTextWrap,
|
|
49
|
+
color,
|
|
50
|
+
fontFamily,
|
|
51
|
+
fontSize,
|
|
52
|
+
fontWeight,
|
|
53
|
+
letterSpacing,
|
|
54
|
+
textAlign
|
|
55
|
+
}) {
|
|
56
|
+
if (noTextWrap || !children) {
|
|
57
|
+
return children;
|
|
58
|
+
}
|
|
59
|
+
let allChildren = import_react.default.Children.toArray(children);
|
|
60
|
+
let nextChildren = [];
|
|
61
|
+
let lastIsString = false;
|
|
62
|
+
const directTextProps = {};
|
|
63
|
+
if (color)
|
|
64
|
+
directTextProps.color = color;
|
|
65
|
+
if (fontFamily)
|
|
66
|
+
directTextProps.fontFamily = fontFamily;
|
|
67
|
+
if (fontSize)
|
|
68
|
+
directTextProps.fontSize = fontSize;
|
|
69
|
+
if (fontWeight)
|
|
70
|
+
directTextProps.fontWeight = fontWeight;
|
|
71
|
+
if (letterSpacing)
|
|
72
|
+
directTextProps.letterSpacing = letterSpacing;
|
|
73
|
+
if (textAlign)
|
|
74
|
+
directTextProps.textAlign = textAlign;
|
|
75
|
+
function concatStringChildren() {
|
|
76
|
+
if (!lastIsString)
|
|
77
|
+
return;
|
|
78
|
+
const index = nextChildren.length - 1;
|
|
79
|
+
const childrenStrings = nextChildren[index];
|
|
80
|
+
nextChildren[index] = /* @__PURE__ */ import_react.default.createElement(TextComponent, __spreadValues(__spreadProps(__spreadValues({
|
|
81
|
+
key: index
|
|
82
|
+
}, directTextProps), {
|
|
83
|
+
size
|
|
84
|
+
}), textProps), childrenStrings);
|
|
85
|
+
}
|
|
86
|
+
for (const child of allChildren) {
|
|
87
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
88
|
+
const isString = typeof child === "string";
|
|
89
|
+
if (isString) {
|
|
90
|
+
if (lastIsString) {
|
|
91
|
+
last.push(child);
|
|
92
|
+
} else {
|
|
93
|
+
nextChildren.push([child]);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
concatStringChildren();
|
|
97
|
+
nextChildren.push(child);
|
|
98
|
+
}
|
|
99
|
+
lastIsString = isString;
|
|
100
|
+
}
|
|
101
|
+
concatStringChildren();
|
|
102
|
+
return nextChildren;
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
wrapStringChildrenInText
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=wrapStringChildrenInText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport type { 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;AAEA,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_wrapStringChildrenInText = require("./wrapStringChildrenInText");
|
|
3
|
+
const Comp = () => {
|
|
4
|
+
};
|
|
5
|
+
const re = /* @__PURE__ */ React.createElement("div", {
|
|
6
|
+
"data-id": Math.random()
|
|
7
|
+
});
|
|
8
|
+
const reID = re.props["data-id"];
|
|
9
|
+
(0, import_vitest.test)("should wrap all string children, not wrap others", () => {
|
|
10
|
+
const out = (0, import_wrapStringChildrenInText.wrapStringChildrenInText)(Comp, {
|
|
11
|
+
children: [re, "a", "b", re, "c", re, "d"]
|
|
12
|
+
});
|
|
13
|
+
(0, import_vitest.expect)(out[0].props["data-id"]).toBe(reID);
|
|
14
|
+
(0, import_vitest.expect)(out[1].type).toBe(Comp);
|
|
15
|
+
(0, import_vitest.expect)(out[1].props.children).toStrictEqual(["a", "b"]);
|
|
16
|
+
(0, import_vitest.expect)(out[2].props["data-id"]).toBe(reID);
|
|
17
|
+
(0, import_vitest.expect)(out[3].type).toBe(Comp);
|
|
18
|
+
(0, import_vitest.expect)(out[3].props.children).toStrictEqual(["c"]);
|
|
19
|
+
(0, import_vitest.expect)(out[4].props["data-id"]).toBe(reID);
|
|
20
|
+
(0, import_vitest.expect)(out[5].type).toBe(Comp);
|
|
21
|
+
(0, import_vitest.expect)(out[5].props.children).toStrictEqual(["d"]);
|
|
22
|
+
});
|
|
23
|
+
(0, import_vitest.test)("should first child string", () => {
|
|
24
|
+
const out = (0, import_wrapStringChildrenInText.wrapStringChildrenInText)(Comp, {
|
|
25
|
+
children: ["a", re]
|
|
26
|
+
});
|
|
27
|
+
(0, import_vitest.expect)(out[0].type).toBe(Comp);
|
|
28
|
+
(0, import_vitest.expect)(out[0].props.children).toStrictEqual(["a"]);
|
|
29
|
+
(0, import_vitest.expect)(out[1].props["data-id"]).toBe(reID);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=wrapStringChildrenInText.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.test.tsx"],
|
|
4
|
+
"sourcesContent": ["import { expect, test } from 'vitest'\n\nimport { wrapStringChildrenInText } from './wrapStringChildrenInText'\n\nconst Comp = () => {}\nconst re = <div data-id={Math.random()} />\nconst reID = re.props['data-id']\n\ntest('should wrap all string children, not wrap others', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: [re, 'a', 'b', re, 'c', re, 'd'],\n }) as any\n\n expect(out[0].props['data-id']).toBe(reID)\n\n expect(out[1].type).toBe(Comp)\n expect(out[1].props.children).toStrictEqual(['a', 'b'])\n\n expect(out[2].props['data-id']).toBe(reID)\n\n expect(out[3].type).toBe(Comp)\n expect(out[3].props.children).toStrictEqual(['c'])\n\n expect(out[4].props['data-id']).toBe(reID)\n\n expect(out[5].type).toBe(Comp)\n expect(out[5].props.children).toStrictEqual(['d'])\n})\n\ntest('should first child string', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: ['a', re],\n }) as any\n\n expect(out[0].type).toBe(Comp)\n expect(out[0].props.children).toStrictEqual(['a'])\n\n expect(out[1].props['data-id']).toBe(reID)\n})\n"],
|
|
5
|
+
"mappings": "AAAA,oBAA6B;AAE7B,sCAAyC;AAEzC,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,oCAAC;AAAA,EAAI,WAAS,KAAK,OAAO;AAAA,CAAG;AACxC,MAAM,OAAO,GAAG,MAAM;AAEtB,wBAAK,oDAAoD,MAAM;AAC7D,QAAM,MAAM,8DAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC3C,CAAC;AAED,4BAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,4BAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,4BAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC;AAEtD,4BAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,4BAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,4BAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,4BAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,4BAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,4BAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,wBAAK,6BAA6B,MAAM;AACtC,QAAM,MAAM,8DAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,KAAK,EAAE;AAAA,EACpB,CAAC;AAED,4BAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,4BAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,4BAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAC3C,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useTheme } from "@tamagui/core";
|
|
2
|
+
const useCurrentColor = (colorProp) => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
let color;
|
|
5
|
+
if (theme && colorProp && colorProp in theme) {
|
|
6
|
+
color = theme[colorProp];
|
|
7
|
+
} else if (colorProp) {
|
|
8
|
+
color = colorProp;
|
|
9
|
+
} else {
|
|
10
|
+
color = theme == null ? void 0 : theme.color;
|
|
11
|
+
}
|
|
12
|
+
return (color == null ? void 0 : color.toString()) || "";
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useCurrentColor
|
|
16
|
+
};
|
|
17
|
+
//# 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 type { 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,CAAC,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import React, { isValidElement } from "react";
|
|
21
|
+
import { useCurrentColor } from "./useCurrentColor";
|
|
22
|
+
const useGetThemedIcon = (props) => {
|
|
23
|
+
const color = useCurrentColor(props.color);
|
|
24
|
+
return (el) => {
|
|
25
|
+
if (el) {
|
|
26
|
+
if (isValidElement(el)) {
|
|
27
|
+
return React.cloneElement(el, __spreadValues(__spreadProps(__spreadValues({}, props), {
|
|
28
|
+
color
|
|
29
|
+
}), el.props));
|
|
30
|
+
}
|
|
31
|
+
return React.createElement(el, __spreadProps(__spreadValues({}, props), {
|
|
32
|
+
color
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
return el;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
useGetThemedIcon
|
|
40
|
+
};
|
|
41
|
+
//# 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 (el) {\n if (isValidElement(el)) {\n return React.cloneElement(el as any, {\n ...props,\n color,\n // @ts-ignore\n ...el.props,\n })\n }\n return React.createElement(el, {\n ...props,\n color,\n })\n }\n return el\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAEA;AAEO,MAAM,mBAAmB,CAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,IAAI;AACN,UAAI,eAAe,EAAE,GAAG;AACtB,eAAO,MAAM,aAAa,IAAW,gDAChC,QADgC;AAAA,UAEnC;AAAA,YAEG,GAAG,MACP;AAAA,MACH;AACA,aAAO,MAAM,cAAc,IAAI,iCAC1B,QAD0B;AAAA,QAE7B;AAAA,MACF,EAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import React from "react";
|
|
21
|
+
function wrapStringChildrenInText(TextComponent, {
|
|
22
|
+
children,
|
|
23
|
+
textProps,
|
|
24
|
+
size,
|
|
25
|
+
noTextWrap,
|
|
26
|
+
color,
|
|
27
|
+
fontFamily,
|
|
28
|
+
fontSize,
|
|
29
|
+
fontWeight,
|
|
30
|
+
letterSpacing,
|
|
31
|
+
textAlign
|
|
32
|
+
}) {
|
|
33
|
+
if (noTextWrap || !children) {
|
|
34
|
+
return children;
|
|
35
|
+
}
|
|
36
|
+
let allChildren = React.Children.toArray(children);
|
|
37
|
+
let nextChildren = [];
|
|
38
|
+
let lastIsString = false;
|
|
39
|
+
const directTextProps = {};
|
|
40
|
+
if (color)
|
|
41
|
+
directTextProps.color = color;
|
|
42
|
+
if (fontFamily)
|
|
43
|
+
directTextProps.fontFamily = fontFamily;
|
|
44
|
+
if (fontSize)
|
|
45
|
+
directTextProps.fontSize = fontSize;
|
|
46
|
+
if (fontWeight)
|
|
47
|
+
directTextProps.fontWeight = fontWeight;
|
|
48
|
+
if (letterSpacing)
|
|
49
|
+
directTextProps.letterSpacing = letterSpacing;
|
|
50
|
+
if (textAlign)
|
|
51
|
+
directTextProps.textAlign = textAlign;
|
|
52
|
+
function concatStringChildren() {
|
|
53
|
+
if (!lastIsString)
|
|
54
|
+
return;
|
|
55
|
+
const index = nextChildren.length - 1;
|
|
56
|
+
const childrenStrings = nextChildren[index];
|
|
57
|
+
nextChildren[index] = /* @__PURE__ */ React.createElement(TextComponent, __spreadValues(__spreadProps(__spreadValues({
|
|
58
|
+
key: index
|
|
59
|
+
}, directTextProps), {
|
|
60
|
+
size
|
|
61
|
+
}), textProps), childrenStrings);
|
|
62
|
+
}
|
|
63
|
+
for (const child of allChildren) {
|
|
64
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
65
|
+
const isString = typeof child === "string";
|
|
66
|
+
if (isString) {
|
|
67
|
+
if (lastIsString) {
|
|
68
|
+
last.push(child);
|
|
69
|
+
} else {
|
|
70
|
+
nextChildren.push([child]);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
concatStringChildren();
|
|
74
|
+
nextChildren.push(child);
|
|
75
|
+
}
|
|
76
|
+
lastIsString = isString;
|
|
77
|
+
}
|
|
78
|
+
concatStringChildren();
|
|
79
|
+
return nextChildren;
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
wrapStringChildrenInText
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=wrapStringChildrenInText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport type { 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,OAAW,kBAA9B;AAAA,MAA+C;AAAA,QAAgB,YAC7D,eACH;AAAA,EAEJ;AAEA,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { wrapStringChildrenInText } from "./wrapStringChildrenInText";
|
|
3
|
+
const Comp = () => {
|
|
4
|
+
};
|
|
5
|
+
const re = /* @__PURE__ */ React.createElement("div", {
|
|
6
|
+
"data-id": Math.random()
|
|
7
|
+
});
|
|
8
|
+
const reID = re.props["data-id"];
|
|
9
|
+
test("should wrap all string children, not wrap others", () => {
|
|
10
|
+
const out = wrapStringChildrenInText(Comp, {
|
|
11
|
+
children: [re, "a", "b", re, "c", re, "d"]
|
|
12
|
+
});
|
|
13
|
+
expect(out[0].props["data-id"]).toBe(reID);
|
|
14
|
+
expect(out[1].type).toBe(Comp);
|
|
15
|
+
expect(out[1].props.children).toStrictEqual(["a", "b"]);
|
|
16
|
+
expect(out[2].props["data-id"]).toBe(reID);
|
|
17
|
+
expect(out[3].type).toBe(Comp);
|
|
18
|
+
expect(out[3].props.children).toStrictEqual(["c"]);
|
|
19
|
+
expect(out[4].props["data-id"]).toBe(reID);
|
|
20
|
+
expect(out[5].type).toBe(Comp);
|
|
21
|
+
expect(out[5].props.children).toStrictEqual(["d"]);
|
|
22
|
+
});
|
|
23
|
+
test("should first child string", () => {
|
|
24
|
+
const out = wrapStringChildrenInText(Comp, {
|
|
25
|
+
children: ["a", re]
|
|
26
|
+
});
|
|
27
|
+
expect(out[0].type).toBe(Comp);
|
|
28
|
+
expect(out[0].props.children).toStrictEqual(["a"]);
|
|
29
|
+
expect(out[1].props["data-id"]).toBe(reID);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=wrapStringChildrenInText.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.test.tsx"],
|
|
4
|
+
"sourcesContent": ["import { expect, test } from 'vitest'\n\nimport { wrapStringChildrenInText } from './wrapStringChildrenInText'\n\nconst Comp = () => {}\nconst re = <div data-id={Math.random()} />\nconst reID = re.props['data-id']\n\ntest('should wrap all string children, not wrap others', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: [re, 'a', 'b', re, 'c', re, 'd'],\n }) as any\n\n expect(out[0].props['data-id']).toBe(reID)\n\n expect(out[1].type).toBe(Comp)\n expect(out[1].props.children).toStrictEqual(['a', 'b'])\n\n expect(out[2].props['data-id']).toBe(reID)\n\n expect(out[3].type).toBe(Comp)\n expect(out[3].props.children).toStrictEqual(['c'])\n\n expect(out[4].props['data-id']).toBe(reID)\n\n expect(out[5].type).toBe(Comp)\n expect(out[5].props.children).toStrictEqual(['d'])\n})\n\ntest('should first child string', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: ['a', re],\n }) as any\n\n expect(out[0].type).toBe(Comp)\n expect(out[0].props.children).toStrictEqual(['a'])\n\n expect(out[1].props['data-id']).toBe(reID)\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAEA;AAEA,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,oCAAC;AAAA,EAAI,WAAS,KAAK,OAAO;AAAA,CAAG;AACxC,MAAM,OAAO,GAAG,MAAM;AAEtB,KAAK,oDAAoD,MAAM;AAC7D,QAAM,MAAM,yBAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC3C,CAAC;AAED,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC;AAEtD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,KAAK,6BAA6B,MAAM;AACtC,QAAM,MAAM,yBAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,KAAK,EAAE;AAAA,EACpB,CAAC;AAED,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAC3C,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useTheme } from "@tamagui/core";
|
|
2
|
+
const useCurrentColor = (colorProp) => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
let color;
|
|
5
|
+
if (theme && colorProp && colorProp in theme) {
|
|
6
|
+
color = theme[colorProp];
|
|
7
|
+
} else if (colorProp) {
|
|
8
|
+
color = colorProp;
|
|
9
|
+
} else {
|
|
10
|
+
color = theme == null ? void 0 : theme.color;
|
|
11
|
+
}
|
|
12
|
+
return (color == null ? void 0 : color.toString()) || "";
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useCurrentColor
|
|
16
|
+
};
|
|
17
|
+
//# 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 type { 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,CAAC,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { isValidElement } from "react";
|
|
2
|
+
import { useCurrentColor } from "./useCurrentColor";
|
|
3
|
+
const useGetThemedIcon = (props) => {
|
|
4
|
+
const color = useCurrentColor(props.color);
|
|
5
|
+
return (el) => {
|
|
6
|
+
if (el) {
|
|
7
|
+
if (isValidElement(el)) {
|
|
8
|
+
return React.cloneElement(el, {
|
|
9
|
+
...props,
|
|
10
|
+
color,
|
|
11
|
+
...el.props
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return React.createElement(el, {
|
|
15
|
+
...props,
|
|
16
|
+
color
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return el;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
useGetThemedIcon
|
|
24
|
+
};
|
|
25
|
+
//# 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 (el) {\n if (isValidElement(el)) {\n return React.cloneElement(el as any, {\n ...props,\n color,\n // @ts-ignore\n ...el.props,\n })\n }\n return React.createElement(el, {\n ...props,\n color,\n })\n }\n return el\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAEA;AAEO,MAAM,mBAAmB,CAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,IAAI;AACN,UAAI,eAAe,EAAE,GAAG;AACtB,eAAO,MAAM,aAAa,IAAW;AAAA,UACnC,GAAG;AAAA,UACH;AAAA,UAEA,GAAG,GAAG;AAAA,QACR,CAAC;AAAA,MACH;AACA,aAAO,MAAM,cAAc,IAAI;AAAA,QAC7B,GAAG;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
function wrapStringChildrenInText(TextComponent, {
|
|
3
|
+
children,
|
|
4
|
+
textProps,
|
|
5
|
+
size,
|
|
6
|
+
noTextWrap,
|
|
7
|
+
color,
|
|
8
|
+
fontFamily,
|
|
9
|
+
fontSize,
|
|
10
|
+
fontWeight,
|
|
11
|
+
letterSpacing,
|
|
12
|
+
textAlign
|
|
13
|
+
}) {
|
|
14
|
+
if (noTextWrap || !children) {
|
|
15
|
+
return children;
|
|
16
|
+
}
|
|
17
|
+
let allChildren = React.Children.toArray(children);
|
|
18
|
+
let nextChildren = [];
|
|
19
|
+
let lastIsString = false;
|
|
20
|
+
const directTextProps = {};
|
|
21
|
+
if (color)
|
|
22
|
+
directTextProps.color = color;
|
|
23
|
+
if (fontFamily)
|
|
24
|
+
directTextProps.fontFamily = fontFamily;
|
|
25
|
+
if (fontSize)
|
|
26
|
+
directTextProps.fontSize = fontSize;
|
|
27
|
+
if (fontWeight)
|
|
28
|
+
directTextProps.fontWeight = fontWeight;
|
|
29
|
+
if (letterSpacing)
|
|
30
|
+
directTextProps.letterSpacing = letterSpacing;
|
|
31
|
+
if (textAlign)
|
|
32
|
+
directTextProps.textAlign = textAlign;
|
|
33
|
+
function concatStringChildren() {
|
|
34
|
+
if (!lastIsString)
|
|
35
|
+
return;
|
|
36
|
+
const index = nextChildren.length - 1;
|
|
37
|
+
const childrenStrings = nextChildren[index];
|
|
38
|
+
nextChildren[index] = <TextComponent key={index} {...directTextProps} size={size} {...textProps}>{childrenStrings}</TextComponent>;
|
|
39
|
+
}
|
|
40
|
+
for (const child of allChildren) {
|
|
41
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
42
|
+
const isString = typeof child === "string";
|
|
43
|
+
if (isString) {
|
|
44
|
+
if (lastIsString) {
|
|
45
|
+
last.push(child);
|
|
46
|
+
} else {
|
|
47
|
+
nextChildren.push([child]);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
concatStringChildren();
|
|
51
|
+
nextChildren.push(child);
|
|
52
|
+
}
|
|
53
|
+
lastIsString = isString;
|
|
54
|
+
}
|
|
55
|
+
concatStringChildren();
|
|
56
|
+
return nextChildren;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
wrapStringChildrenInText
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=wrapStringChildrenInText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { SizeTokens } from '@tamagui/core'\nimport React from 'react'\n\nimport type { 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,CAAC,cAAc,KAAK,WAAW,iBAAiB,MAAM,UAAU,YAC7D,gBACH,EAFC;AAAA,EAIL;AAEA,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { wrapStringChildrenInText } from "./wrapStringChildrenInText";
|
|
3
|
+
const Comp = () => {
|
|
4
|
+
};
|
|
5
|
+
const re = <div data-id={Math.random()} />;
|
|
6
|
+
const reID = re.props["data-id"];
|
|
7
|
+
test("should wrap all string children, not wrap others", () => {
|
|
8
|
+
const out = wrapStringChildrenInText(Comp, {
|
|
9
|
+
children: [re, "a", "b", re, "c", re, "d"]
|
|
10
|
+
});
|
|
11
|
+
expect(out[0].props["data-id"]).toBe(reID);
|
|
12
|
+
expect(out[1].type).toBe(Comp);
|
|
13
|
+
expect(out[1].props.children).toStrictEqual(["a", "b"]);
|
|
14
|
+
expect(out[2].props["data-id"]).toBe(reID);
|
|
15
|
+
expect(out[3].type).toBe(Comp);
|
|
16
|
+
expect(out[3].props.children).toStrictEqual(["c"]);
|
|
17
|
+
expect(out[4].props["data-id"]).toBe(reID);
|
|
18
|
+
expect(out[5].type).toBe(Comp);
|
|
19
|
+
expect(out[5].props.children).toStrictEqual(["d"]);
|
|
20
|
+
});
|
|
21
|
+
test("should first child string", () => {
|
|
22
|
+
const out = wrapStringChildrenInText(Comp, {
|
|
23
|
+
children: ["a", re]
|
|
24
|
+
});
|
|
25
|
+
expect(out[0].type).toBe(Comp);
|
|
26
|
+
expect(out[0].props.children).toStrictEqual(["a"]);
|
|
27
|
+
expect(out[1].props["data-id"]).toBe(reID);
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=wrapStringChildrenInText.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapStringChildrenInText.test.tsx"],
|
|
4
|
+
"sourcesContent": ["import { expect, test } from 'vitest'\n\nimport { wrapStringChildrenInText } from './wrapStringChildrenInText'\n\nconst Comp = () => {}\nconst re = <div data-id={Math.random()} />\nconst reID = re.props['data-id']\n\ntest('should wrap all string children, not wrap others', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: [re, 'a', 'b', re, 'c', re, 'd'],\n }) as any\n\n expect(out[0].props['data-id']).toBe(reID)\n\n expect(out[1].type).toBe(Comp)\n expect(out[1].props.children).toStrictEqual(['a', 'b'])\n\n expect(out[2].props['data-id']).toBe(reID)\n\n expect(out[3].type).toBe(Comp)\n expect(out[3].props.children).toStrictEqual(['c'])\n\n expect(out[4].props['data-id']).toBe(reID)\n\n expect(out[5].type).toBe(Comp)\n expect(out[5].props.children).toStrictEqual(['d'])\n})\n\ntest('should first child string', () => {\n const out = wrapStringChildrenInText(Comp, {\n children: ['a', re],\n }) as any\n\n expect(out[0].type).toBe(Comp)\n expect(out[0].props.children).toStrictEqual(['a'])\n\n expect(out[1].props['data-id']).toBe(reID)\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAEA;AAEA,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,GAAG;AACxC,MAAM,OAAO,GAAG,MAAM;AAEtB,KAAK,oDAAoD,MAAM;AAC7D,QAAM,MAAM,yBAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC3C,CAAC;AAED,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC;AAEtD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,KAAK,6BAA6B,MAAM;AACtC,QAAM,MAAM,yBAAyB,MAAM;AAAA,IACzC,UAAU,CAAC,KAAK,EAAE;AAAA,EACpB,CAAC;AAED,SAAO,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,GAAG,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,GAAG,MAAM,UAAU,EAAE,KAAK,IAAI;AAC3C,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/helpers-tamagui",
|
|
3
|
+
"version": "1.0.1-beta.100",
|
|
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
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tamagui-build",
|
|
16
|
+
"watch": "tamagui-build --watch",
|
|
17
|
+
"clean": "tamagui-build clean",
|
|
18
|
+
"clean:build": "tamagui-build clean:build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@tamagui/core": "^1.0.1-beta.100"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@tamagui/build": "^1.0.1-beta.100",
|
|
25
|
+
"@tamagui/vite-plugin-internal": "^1.0.1-beta.100",
|
|
26
|
+
"react": "*",
|
|
27
|
+
"react-native": "*",
|
|
28
|
+
"vitest": "^0.17.1"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "*",
|
|
32
|
+
"react-native": "*"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SizableTextProps } from '@tamagui/text'
|
|
2
|
+
|
|
3
|
+
export type TextParentStyles = {
|
|
4
|
+
color?: SizableTextProps['color']
|
|
5
|
+
fontWeight?: SizableTextProps['fontWeight']
|
|
6
|
+
fontSize?: SizableTextProps['fontSize']
|
|
7
|
+
fontFamily?: SizableTextProps['fontFamily']
|
|
8
|
+
letterSpacing?: SizableTextProps['letterSpacing']
|
|
9
|
+
textAlign?: SizableTextProps['textAlign']
|
|
10
|
+
// all the other text controls
|
|
11
|
+
textProps?: Partial<SizableTextProps>
|
|
12
|
+
noTextWrap?: boolean
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColorTokens, ThemeValueFallback, useTheme } from '@tamagui/core'
|
|
2
|
+
import type { TextStyle } from 'react-native'
|
|
3
|
+
|
|
4
|
+
export const useCurrentColor = (colorProp: ColorProp) => {
|
|
5
|
+
const theme = useTheme()
|
|
6
|
+
// get color from prop or theme
|
|
7
|
+
let color: any
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
if (theme && colorProp && colorProp in theme) {
|
|
10
|
+
// @ts-expect-error
|
|
11
|
+
color = theme[colorProp]
|
|
12
|
+
} else if (colorProp) {
|
|
13
|
+
color = colorProp
|
|
14
|
+
} else {
|
|
15
|
+
color = theme?.color
|
|
16
|
+
}
|
|
17
|
+
return color?.toString() || ('' as string)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { isValidElement } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ColorProp, useCurrentColor } from './useCurrentColor'
|
|
4
|
+
|
|
5
|
+
export const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {
|
|
6
|
+
const color = useCurrentColor(props.color)
|
|
7
|
+
return (el: any) => {
|
|
8
|
+
if (el) {
|
|
9
|
+
if (isValidElement(el)) {
|
|
10
|
+
return React.cloneElement(el as any, {
|
|
11
|
+
...props,
|
|
12
|
+
color,
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
...el.props,
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
return React.createElement(el, {
|
|
18
|
+
...props,
|
|
19
|
+
color,
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
return el
|
|
23
|
+
}
|
|
24
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -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,SAAS,CAAA"}
|
package/types/types.d.ts
ADDED
|
@@ -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 type { 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,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,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 @@
|
|
|
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,QAiBhB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SizeTokens } from '@tamagui/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { 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): string | number | boolean | any[] | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | null | undefined;
|
|
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,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,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,mJAoDT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapStringChildrenInText.test.d.ts","sourceRoot":"","sources":["../src/wrapStringChildrenInText.test.tsx"],"names":[],"mappings":""}
|