@tamagui/text 1.13.3 → 1.13.4
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/Headings.js +1 -79
- package/dist/cjs/Headings.js.map +2 -2
- package/dist/cjs/Paragraph.js +1 -36
- package/dist/cjs/Paragraph.js.map +2 -2
- package/dist/cjs/SizableText.js +1 -39
- package/dist/cjs/SizableText.js.map +2 -2
- package/dist/cjs/index.js +1 -22
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +1 -16
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/wrapChildrenInText.js +1 -103
- package/dist/cjs/wrapChildrenInText.js.map +2 -2
- package/dist/cjs/wrapChildrenInText.test.js +1 -30
- package/dist/cjs/wrapChildrenInText.test.js.map +2 -2
- package/dist/esm/Headings.js +1 -49
- package/dist/esm/Headings.js.map +2 -2
- package/dist/esm/Headings.mjs +1 -49
- package/dist/esm/Headings.mjs.map +2 -2
- package/dist/esm/Paragraph.js +1 -12
- package/dist/esm/Paragraph.js.map +2 -2
- package/dist/esm/Paragraph.mjs +1 -12
- package/dist/esm/Paragraph.mjs.map +2 -2
- package/dist/esm/SizableText.js +1 -15
- package/dist/esm/SizableText.js.map +2 -2
- package/dist/esm/SizableText.mjs +1 -15
- package/dist/esm/SizableText.mjs.map +2 -2
- package/dist/esm/index.js +1 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -5
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/wrapChildrenInText.js +1 -69
- package/dist/esm/wrapChildrenInText.js.map +2 -2
- package/dist/esm/wrapChildrenInText.mjs +1 -69
- package/dist/esm/wrapChildrenInText.mjs.map +2 -2
- package/dist/esm/wrapChildrenInText.test.js +1 -29
- package/dist/esm/wrapChildrenInText.test.js.map +2 -2
- package/dist/esm/wrapChildrenInText.test.mjs +1 -29
- package/dist/esm/wrapChildrenInText.test.mjs.map +2 -2
- package/dist/jsx/Headings.js +1 -49
- package/dist/jsx/Headings.js.map +2 -2
- package/dist/jsx/Headings.mjs +1 -49
- package/dist/jsx/Headings.mjs.map +2 -2
- package/dist/jsx/Paragraph.js +1 -12
- package/dist/jsx/Paragraph.js.map +2 -2
- package/dist/jsx/Paragraph.mjs +1 -12
- package/dist/jsx/Paragraph.mjs.map +2 -2
- package/dist/jsx/SizableText.js +1 -15
- package/dist/jsx/SizableText.js.map +2 -2
- package/dist/jsx/SizableText.mjs +1 -15
- package/dist/jsx/SizableText.mjs.map +2 -2
- package/dist/jsx/index.js +1 -5
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -5
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/wrapChildrenInText.js +1 -68
- package/dist/jsx/wrapChildrenInText.js.map +2 -2
- package/dist/jsx/wrapChildrenInText.mjs +1 -68
- package/dist/jsx/wrapChildrenInText.mjs.map +2 -2
- package/dist/jsx/wrapChildrenInText.test.js +1 -28
- package/dist/jsx/wrapChildrenInText.test.js.map +2 -2
- package/dist/jsx/wrapChildrenInText.test.mjs +1 -28
- package/dist/jsx/wrapChildrenInText.test.mjs.map +2 -2
- package/package.json +5 -5
package/dist/jsx/SizableText.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Text, styled } from "@tamagui/web";
|
|
3
|
-
const SizableText = styled(Text, {
|
|
4
|
-
name: "SizableText",
|
|
5
|
-
fontFamily: "$body",
|
|
6
|
-
variants: {
|
|
7
|
-
size: getFontSized
|
|
8
|
-
},
|
|
9
|
-
defaultVariants: {
|
|
10
|
-
size: "$true"
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
SizableText
|
|
15
|
-
};
|
|
1
|
+
import{getFontSized as e}from"@tamagui/get-font-sized";import{Text as t,styled as o}from"@tamagui/web";const s=o(t,{name:"SizableText",fontFamily:"$body",variants:{size:e},defaultVariants:{size:"$true"}});export{s as SizableText};
|
|
16
2
|
//# sourceMappingURL=SizableText.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SizableText.tsx"],
|
|
4
4
|
"sourcesContent": ["import { getFontSized } from '@tamagui/get-font-sized'\nimport { GetProps, Text, styled } from '@tamagui/web'\n\nexport const SizableText = styled(Text, {\n name: 'SizableText',\n fontFamily: '$body',\n\n variants: {\n size: getFontSized,\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\nexport type SizableTextProps = GetProps<typeof SizableText>\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,gBAAAA,MAAoB,0BAC7B,OAAmB,QAAAC,EAAM,UAAAC,MAAc,eAEhC,MAAMC,EAAcD,EAAOD,EAAM,CACtC,KAAM,cACN,WAAY,QAEZ,SAAU,CACR,KAAMD,CACR,EAEA,gBAAiB,CACf,KAAM,OACR,CACF,CAAC",
|
|
6
|
+
"names": ["getFontSized", "Text", "styled", "SizableText"]
|
|
7
7
|
}
|
package/dist/jsx/SizableText.mjs
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Text, styled } from "@tamagui/web";
|
|
3
|
-
const SizableText = styled(Text, {
|
|
4
|
-
name: "SizableText",
|
|
5
|
-
fontFamily: "$body",
|
|
6
|
-
variants: {
|
|
7
|
-
size: getFontSized
|
|
8
|
-
},
|
|
9
|
-
defaultVariants: {
|
|
10
|
-
size: "$true"
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
SizableText
|
|
15
|
-
};
|
|
1
|
+
import{getFontSized as e}from"@tamagui/get-font-sized";import{Text as t,styled as o}from"@tamagui/web";const s=o(t,{name:"SizableText",fontFamily:"$body",variants:{size:e},defaultVariants:{size:"$true"}});export{s as SizableText};
|
|
16
2
|
//# sourceMappingURL=SizableText.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SizableText.tsx"],
|
|
4
4
|
"sourcesContent": ["import { getFontSized } from '@tamagui/get-font-sized'\nimport { GetProps, Text, styled } from '@tamagui/web'\n\nexport const SizableText = styled(Text, {\n name: 'SizableText',\n fontFamily: '$body',\n\n variants: {\n size: getFontSized,\n } as const,\n\n defaultVariants: {\n size: '$true',\n },\n})\n\nexport type SizableTextProps = GetProps<typeof SizableText>\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,gBAAAA,MAAoB,0BAC7B,OAAmB,QAAAC,EAAM,UAAAC,MAAc,eAEhC,MAAMC,EAAcD,EAAOD,EAAM,CACtC,KAAM,cACN,WAAY,QAEZ,SAAU,CACR,KAAMD,CACR,EAEA,gBAAiB,CACf,KAAM,OACR,CACF,CAAC",
|
|
6
|
+
"names": ["getFontSized", "Text", "styled", "SizableText"]
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./Paragraph";
|
|
3
|
-
export * from "./Headings";
|
|
4
|
-
export * from "./wrapChildrenInText";
|
|
5
|
-
export * from "./types";
|
|
1
|
+
export*from"./SizableText";export*from"./Paragraph";export*from"./Headings";export*from"./wrapChildrenInText";export*from"./types";
|
|
6
2
|
//# sourceMappingURL=index.js.map
|
package/dist/jsx/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\nexport * from './Headings'\nexport * from './wrapChildrenInText'\nexport * from './types'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,WAAc,gBACd,WAAc,cACd,WAAc,aACd,WAAc,uBACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./Paragraph";
|
|
3
|
-
export * from "./Headings";
|
|
4
|
-
export * from "./wrapChildrenInText";
|
|
5
|
-
export * from "./types";
|
|
1
|
+
export*from"./SizableText";export*from"./Paragraph";export*from"./Headings";export*from"./wrapChildrenInText";export*from"./types";
|
|
6
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\nexport * from './Headings'\nexport * from './wrapChildrenInText'\nexport * from './types'\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
5
|
+
"mappings": "AAAA,WAAc,gBACd,WAAc,cACd,WAAc,aACd,WAAc,uBACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
function wrapChildrenInText(TextComponent, propsIn, extraProps) {
|
|
3
|
-
const {
|
|
4
|
-
children,
|
|
5
|
-
textProps,
|
|
6
|
-
size,
|
|
7
|
-
noTextWrap,
|
|
8
|
-
color,
|
|
9
|
-
fontFamily,
|
|
10
|
-
fontSize,
|
|
11
|
-
fontWeight,
|
|
12
|
-
letterSpacing,
|
|
13
|
-
textAlign,
|
|
14
|
-
fontStyle
|
|
15
|
-
} = propsIn;
|
|
16
|
-
if (noTextWrap || !children) {
|
|
17
|
-
return [children];
|
|
18
|
-
}
|
|
19
|
-
const allChildren = React.Children.toArray(children);
|
|
20
|
-
const nextChildren = [];
|
|
21
|
-
let lastIsString = false;
|
|
22
|
-
const props = {
|
|
23
|
-
...extraProps
|
|
24
|
-
};
|
|
25
|
-
if (color)
|
|
26
|
-
props.color = color;
|
|
27
|
-
if (fontFamily)
|
|
28
|
-
props.fontFamily = fontFamily;
|
|
29
|
-
if (fontSize)
|
|
30
|
-
props.fontSize = fontSize;
|
|
31
|
-
if (fontWeight)
|
|
32
|
-
props.fontWeight = fontWeight;
|
|
33
|
-
if (letterSpacing)
|
|
34
|
-
props.letterSpacing = letterSpacing;
|
|
35
|
-
if (textAlign)
|
|
36
|
-
props.textAlign = textAlign;
|
|
37
|
-
if (size)
|
|
38
|
-
props.size = size;
|
|
39
|
-
if (fontStyle)
|
|
40
|
-
props.fontStyle = fontStyle;
|
|
41
|
-
function concatStringChildren() {
|
|
42
|
-
if (!lastIsString)
|
|
43
|
-
return;
|
|
44
|
-
const index = nextChildren.length - 1;
|
|
45
|
-
const childrenStrings = nextChildren[index];
|
|
46
|
-
nextChildren[index] = <TextComponent key={index} {...props} {...textProps}>{childrenStrings}</TextComponent>;
|
|
47
|
-
}
|
|
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
|
-
export {
|
|
67
|
-
wrapChildrenInText
|
|
68
|
-
};
|
|
1
|
+
import W from"react";function I(T,C,P){const{children:i,textProps:R,size:s,noTextWrap:k,color:l,fontFamily:f,fontSize:c,fontWeight:a,letterSpacing:p,textAlign:h,fontStyle:g}=C;if(k||!i)return[i];const A=W.Children.toArray(i),e=[];let o=!1;const t={...P};l&&(t.color=l),f&&(t.fontFamily=f),c&&(t.fontSize=c),a&&(t.fontWeight=a),p&&(t.letterSpacing=p),h&&(t.textAlign=h),s&&(t.size=s),g&&(t.fontStyle=g);function y(){if(!o)return;const n=e.length-1,r=e[n];e[n]=<T key={n}{...t}{...R}>{r}</T>}for(const n of A){const r=e[e.length-1],S=typeof n=="string";S?o?r.push(n):e.push([n]):(y(),e.push(n)),o=S}return y(),e}export{I as wrapChildrenInText};
|
|
69
2
|
//# sourceMappingURL=wrapChildrenInText.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapChildrenInText.tsx"],
|
|
4
4
|
"sourcesContent": ["import type { SizeTokens } from '@tamagui/web'\nimport React from 'react'\n\nimport { TextParentStyles } from './types'\n\ntype Props = TextParentStyles & {\n children?: React.ReactNode\n size?: SizeTokens\n}\n\nexport function wrapChildrenInText(\n TextComponent: any,\n propsIn: Props & {\n unstyled?: boolean\n },\n extraProps?: Record<string, any>\n) {\n const {\n children,\n textProps,\n size,\n noTextWrap,\n color,\n fontFamily,\n fontSize,\n fontWeight,\n letterSpacing,\n textAlign,\n fontStyle,\n } = propsIn\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 const allChildren = React.Children.toArray(children)\n const nextChildren: any[] = []\n let lastIsString = false\n const props = {\n ...extraProps,\n }\n\n // to avoid setting undefined\n if (color) props.color = color\n if (fontFamily) props.fontFamily = fontFamily\n if (fontSize) props.fontSize = fontSize\n if (fontWeight) props.fontWeight = fontWeight\n if (letterSpacing) props.letterSpacing = letterSpacing\n if (textAlign) props.textAlign = textAlign\n if (size) props.size = size\n if (fontStyle) props.fontStyle = fontStyle\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} {...props} {...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,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAOA,MAAW,QASX,SAASC,EACdC,EACAC,EAGAC,EACA,CACA,KAAM,CACJ,SAAAC,EACA,UAAAC,EACA,KAAAC,EACA,WAAAC,EACA,MAAAC,EACA,WAAAC,EACA,SAAAC,EACA,WAAAC,EACA,cAAAC,EACA,UAAAC,EACA,UAAAC,CACF,EAAIZ,EAEJ,GAAIK,GAAc,CAACH,EACjB,MAAO,CAACA,CAAQ,EAQlB,MAAMW,EAAchB,EAAM,SAAS,QAAQK,CAAQ,EAC7CY,EAAsB,CAAC,EAC7B,IAAIC,EAAe,GACnB,MAAMC,EAAQ,CACZ,GAAGf,CACL,EAGIK,IAAOU,EAAM,MAAQV,GACrBC,IAAYS,EAAM,WAAaT,GAC/BC,IAAUQ,EAAM,SAAWR,GAC3BC,IAAYO,EAAM,WAAaP,GAC/BC,IAAeM,EAAM,cAAgBN,GACrCC,IAAWK,EAAM,UAAYL,GAC7BP,IAAMY,EAAM,KAAOZ,GACnBQ,IAAWI,EAAM,UAAYJ,GAEjC,SAASK,GAAuB,CAC9B,GAAI,CAACF,EAAc,OACnB,MAAMG,EAAQJ,EAAa,OAAS,EAC9BK,EAAkBL,EAAaI,CAAK,EAC1CJ,EAAaI,CAAK,EAChB,CAACnB,EAAc,KAAKmB,MAAWF,MAAWb,IACvCgB,EACH,EAFCpB,EAIL,CAEA,UAAWqB,KAASP,EAAa,CAC/B,MAAMQ,EAAOP,EAAaA,EAAa,OAAS,CAAC,EAC3CQ,EAAW,OAAOF,GAAU,SAC9BE,EACEP,EACFM,EAAK,KAAKD,CAAK,EAEfN,EAAa,KAAK,CAACM,CAAK,CAAC,GAG3BH,EAAqB,EACrBH,EAAa,KAAKM,CAAK,GAEzBL,EAAeO,CACjB,CACA,OAAAL,EAAqB,EAEdH,CACT",
|
|
6
|
+
"names": ["React", "wrapChildrenInText", "TextComponent", "propsIn", "extraProps", "children", "textProps", "size", "noTextWrap", "color", "fontFamily", "fontSize", "fontWeight", "letterSpacing", "textAlign", "fontStyle", "allChildren", "nextChildren", "lastIsString", "props", "concatStringChildren", "index", "childrenStrings", "child", "last", "isString"]
|
|
7
7
|
}
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
function wrapChildrenInText(TextComponent, propsIn, extraProps) {
|
|
3
|
-
const {
|
|
4
|
-
children,
|
|
5
|
-
textProps,
|
|
6
|
-
size,
|
|
7
|
-
noTextWrap,
|
|
8
|
-
color,
|
|
9
|
-
fontFamily,
|
|
10
|
-
fontSize,
|
|
11
|
-
fontWeight,
|
|
12
|
-
letterSpacing,
|
|
13
|
-
textAlign,
|
|
14
|
-
fontStyle
|
|
15
|
-
} = propsIn;
|
|
16
|
-
if (noTextWrap || !children) {
|
|
17
|
-
return [children];
|
|
18
|
-
}
|
|
19
|
-
const allChildren = React.Children.toArray(children);
|
|
20
|
-
const nextChildren = [];
|
|
21
|
-
let lastIsString = false;
|
|
22
|
-
const props = {
|
|
23
|
-
...extraProps
|
|
24
|
-
};
|
|
25
|
-
if (color)
|
|
26
|
-
props.color = color;
|
|
27
|
-
if (fontFamily)
|
|
28
|
-
props.fontFamily = fontFamily;
|
|
29
|
-
if (fontSize)
|
|
30
|
-
props.fontSize = fontSize;
|
|
31
|
-
if (fontWeight)
|
|
32
|
-
props.fontWeight = fontWeight;
|
|
33
|
-
if (letterSpacing)
|
|
34
|
-
props.letterSpacing = letterSpacing;
|
|
35
|
-
if (textAlign)
|
|
36
|
-
props.textAlign = textAlign;
|
|
37
|
-
if (size)
|
|
38
|
-
props.size = size;
|
|
39
|
-
if (fontStyle)
|
|
40
|
-
props.fontStyle = fontStyle;
|
|
41
|
-
function concatStringChildren() {
|
|
42
|
-
if (!lastIsString)
|
|
43
|
-
return;
|
|
44
|
-
const index = nextChildren.length - 1;
|
|
45
|
-
const childrenStrings = nextChildren[index];
|
|
46
|
-
nextChildren[index] = <TextComponent key={index} {...props} {...textProps}>{childrenStrings}</TextComponent>;
|
|
47
|
-
}
|
|
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
|
-
export {
|
|
67
|
-
wrapChildrenInText
|
|
68
|
-
};
|
|
1
|
+
import W from"react";function I(T,C,P){const{children:i,textProps:R,size:s,noTextWrap:k,color:l,fontFamily:f,fontSize:c,fontWeight:a,letterSpacing:p,textAlign:h,fontStyle:g}=C;if(k||!i)return[i];const A=W.Children.toArray(i),e=[];let o=!1;const t={...P};l&&(t.color=l),f&&(t.fontFamily=f),c&&(t.fontSize=c),a&&(t.fontWeight=a),p&&(t.letterSpacing=p),h&&(t.textAlign=h),s&&(t.size=s),g&&(t.fontStyle=g);function y(){if(!o)return;const n=e.length-1,r=e[n];e[n]=<T key={n}{...t}{...R}>{r}</T>}for(const n of A){const r=e[e.length-1],S=typeof n=="string";S?o?r.push(n):e.push([n]):(y(),e.push(n)),o=S}return y(),e}export{I as wrapChildrenInText};
|
|
69
2
|
//# sourceMappingURL=wrapChildrenInText.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapChildrenInText.tsx"],
|
|
4
4
|
"sourcesContent": ["import type { SizeTokens } from '@tamagui/web'\nimport React from 'react'\n\nimport { TextParentStyles } from './types'\n\ntype Props = TextParentStyles & {\n children?: React.ReactNode\n size?: SizeTokens\n}\n\nexport function wrapChildrenInText(\n TextComponent: any,\n propsIn: Props & {\n unstyled?: boolean\n },\n extraProps?: Record<string, any>\n) {\n const {\n children,\n textProps,\n size,\n noTextWrap,\n color,\n fontFamily,\n fontSize,\n fontWeight,\n letterSpacing,\n textAlign,\n fontStyle,\n } = propsIn\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 const allChildren = React.Children.toArray(children)\n const nextChildren: any[] = []\n let lastIsString = false\n const props = {\n ...extraProps,\n }\n\n // to avoid setting undefined\n if (color) props.color = color\n if (fontFamily) props.fontFamily = fontFamily\n if (fontSize) props.fontSize = fontSize\n if (fontWeight) props.fontWeight = fontWeight\n if (letterSpacing) props.letterSpacing = letterSpacing\n if (textAlign) props.textAlign = textAlign\n if (size) props.size = size\n if (fontStyle) props.fontStyle = fontStyle\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} {...props} {...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,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAOA,MAAW,QASX,SAASC,EACdC,EACAC,EAGAC,EACA,CACA,KAAM,CACJ,SAAAC,EACA,UAAAC,EACA,KAAAC,EACA,WAAAC,EACA,MAAAC,EACA,WAAAC,EACA,SAAAC,EACA,WAAAC,EACA,cAAAC,EACA,UAAAC,EACA,UAAAC,CACF,EAAIZ,EAEJ,GAAIK,GAAc,CAACH,EACjB,MAAO,CAACA,CAAQ,EAQlB,MAAMW,EAAchB,EAAM,SAAS,QAAQK,CAAQ,EAC7CY,EAAsB,CAAC,EAC7B,IAAIC,EAAe,GACnB,MAAMC,EAAQ,CACZ,GAAGf,CACL,EAGIK,IAAOU,EAAM,MAAQV,GACrBC,IAAYS,EAAM,WAAaT,GAC/BC,IAAUQ,EAAM,SAAWR,GAC3BC,IAAYO,EAAM,WAAaP,GAC/BC,IAAeM,EAAM,cAAgBN,GACrCC,IAAWK,EAAM,UAAYL,GAC7BP,IAAMY,EAAM,KAAOZ,GACnBQ,IAAWI,EAAM,UAAYJ,GAEjC,SAASK,GAAuB,CAC9B,GAAI,CAACF,EAAc,OACnB,MAAMG,EAAQJ,EAAa,OAAS,EAC9BK,EAAkBL,EAAaI,CAAK,EAC1CJ,EAAaI,CAAK,EAChB,CAACnB,EAAc,KAAKmB,MAAWF,MAAWb,IACvCgB,EACH,EAFCpB,EAIL,CAEA,UAAWqB,KAASP,EAAa,CAC/B,MAAMQ,EAAOP,EAAaA,EAAa,OAAS,CAAC,EAC3CQ,EAAW,OAAOF,GAAU,SAC9BE,EACEP,EACFM,EAAK,KAAKD,CAAK,EAEfN,EAAa,KAAK,CAACM,CAAK,CAAC,GAG3BH,EAAqB,EACrBH,EAAa,KAAKM,CAAK,GAEzBL,EAAeO,CACjB,CACA,OAAAL,EAAqB,EAEdH,CACT",
|
|
6
|
+
"names": ["React", "wrapChildrenInText", "TextComponent", "propsIn", "extraProps", "children", "textProps", "size", "noTextWrap", "color", "fontFamily", "fontSize", "fontWeight", "letterSpacing", "textAlign", "fontStyle", "allChildren", "nextChildren", "lastIsString", "props", "concatStringChildren", "index", "childrenStrings", "child", "last", "isString"]
|
|
7
7
|
}
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { wrapChildrenInText } from "./wrapChildrenInText";
|
|
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 = wrapChildrenInText(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 = wrapChildrenInText(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
|
-
});
|
|
1
|
+
import{expect as o,test as e}from"vitest";import{wrapChildrenInText as d}from"./wrapChildrenInText";const r=()=>{},a=<div data-id={Math.random()}/>,p=a.props["data-id"];e("should wrap all string children, not wrap others",()=>{const t=d(r,{children:[a,"a","b",a,"c",a,"d"]});o(t[0].props["data-id"]).toBe(p),o(t[1].type).toBe(r),o(t[1].props.children).toStrictEqual(["a","b"]),o(t[2].props["data-id"]).toBe(p),o(t[3].type).toBe(r),o(t[3].props.children).toStrictEqual(["c"]),o(t[4].props["data-id"]).toBe(p),o(t[5].type).toBe(r),o(t[5].props.children).toStrictEqual(["d"])}),e("should first child string",()=>{const t=d(r,{children:["a",a]});o(t[0].type).toBe(r),o(t[0].props.children).toStrictEqual(["a"]),o(t[1].props["data-id"]).toBe(p)});
|
|
29
2
|
//# sourceMappingURL=wrapChildrenInText.test.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapChildrenInText.test.tsx"],
|
|
4
4
|
"sourcesContent": ["import React from 'react'\nimport { expect, test } from 'vitest'\n\nimport { wrapChildrenInText } from './wrapChildrenInText'\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 = wrapChildrenInText(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 = wrapChildrenInText(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": "AACA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAS,UAAAA,EAAQ,QAAAC,MAAY,SAE7B,OAAS,sBAAAC,MAA0B,uBAEnC,MAAMC,EAAO,IAAM,CAAC,EACdC,EAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAG,GAClCC,EAAOD,EAAG,MAAM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
|
2
|
-
import { wrapChildrenInText } from "./wrapChildrenInText";
|
|
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 = wrapChildrenInText(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 = wrapChildrenInText(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
|
-
});
|
|
1
|
+
import{expect as o,test as e}from"vitest";import{wrapChildrenInText as d}from"./wrapChildrenInText";const r=()=>{},a=<div data-id={Math.random()}/>,p=a.props["data-id"];e("should wrap all string children, not wrap others",()=>{const t=d(r,{children:[a,"a","b",a,"c",a,"d"]});o(t[0].props["data-id"]).toBe(p),o(t[1].type).toBe(r),o(t[1].props.children).toStrictEqual(["a","b"]),o(t[2].props["data-id"]).toBe(p),o(t[3].type).toBe(r),o(t[3].props.children).toStrictEqual(["c"]),o(t[4].props["data-id"]).toBe(p),o(t[5].type).toBe(r),o(t[5].props.children).toStrictEqual(["d"])}),e("should first child string",()=>{const t=d(r,{children:["a",a]});o(t[0].type).toBe(r),o(t[0].props.children).toStrictEqual(["a"]),o(t[1].props["data-id"]).toBe(p)});
|
|
29
2
|
//# sourceMappingURL=wrapChildrenInText.test.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapChildrenInText.test.tsx"],
|
|
4
4
|
"sourcesContent": ["import React from 'react'\nimport { expect, test } from 'vitest'\n\nimport { wrapChildrenInText } from './wrapChildrenInText'\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 = wrapChildrenInText(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 = wrapChildrenInText(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": "AACA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAS,UAAAA,EAAQ,QAAAC,MAAY,SAE7B,OAAS,sBAAAC,MAA0B,uBAEnC,MAAMC,EAAO,IAAM,CAAC,EACdC,EAAK,CAAC,IAAI,SAAS,KAAK,OAAO,EAAG,GAClCC,EAAOD,EAAG,MAAM,SAAS,EAE/BH,EAAK,mDAAoD,IAAM,CAC7D,MAAMK,EAAMJ,EAAmBC,EAAM,CACnC,SAAU,C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",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/get-font-sized": "1.13.
|
|
35
|
-
"@tamagui/helpers-tamagui": "1.13.
|
|
36
|
-
"@tamagui/web": "1.13.
|
|
34
|
+
"@tamagui/get-font-sized": "1.13.4",
|
|
35
|
+
"@tamagui/helpers-tamagui": "1.13.4",
|
|
36
|
+
"@tamagui/web": "1.13.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.13.
|
|
42
|
+
"@tamagui/build": "1.13.4",
|
|
43
43
|
"react": "^18.2.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|