@tamagui/text 1.2.9 → 1.2.11

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.
@@ -0,0 +1,50 @@
1
+ import { styled } from "@tamagui/core";
2
+ import { Paragraph } from "./Paragraph";
3
+ const Heading = styled(Paragraph, {
4
+ tag: "span",
5
+ name: "Heading",
6
+ accessibilityRole: "header",
7
+ fontFamily: "$heading",
8
+ size: "$8",
9
+ margin: 0
10
+ });
11
+ const H1 = styled(Heading, {
12
+ name: "H1",
13
+ tag: "h1",
14
+ size: "$10"
15
+ });
16
+ const H2 = styled(Heading, {
17
+ name: "H2",
18
+ tag: "h2",
19
+ size: "$9"
20
+ });
21
+ const H3 = styled(Heading, {
22
+ name: "H3",
23
+ tag: "h3",
24
+ size: "$8"
25
+ });
26
+ const H4 = styled(Heading, {
27
+ name: "H4",
28
+ tag: "h4",
29
+ size: "$7"
30
+ });
31
+ const H5 = styled(Heading, {
32
+ name: "H5",
33
+ tag: "h5",
34
+ size: "$6"
35
+ });
36
+ const H6 = styled(Heading, {
37
+ name: "H6",
38
+ tag: "h6",
39
+ size: "$5"
40
+ });
41
+ export {
42
+ H1,
43
+ H2,
44
+ H3,
45
+ H4,
46
+ H5,
47
+ H6,
48
+ Heading
49
+ };
50
+ //# sourceMappingURL=Headings.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Headings.tsx"],
4
+ "sourcesContent": ["import { styled } from '@tamagui/core'\n\nimport { Paragraph } from './Paragraph'\n\nexport const Heading = styled(Paragraph, {\n tag: 'span',\n name: 'Heading',\n accessibilityRole: 'header',\n fontFamily: '$heading',\n size: '$8',\n margin: 0,\n})\n\nexport const H1 = styled(Heading, {\n name: 'H1',\n tag: 'h1',\n size: '$10',\n})\n\nexport const H2 = styled(Heading, {\n name: 'H2',\n tag: 'h2',\n size: '$9',\n})\n\nexport const H3 = styled(Heading, {\n name: 'H3',\n tag: 'h3',\n size: '$8',\n})\n\nexport const H4 = styled(Heading, {\n name: 'H4',\n tag: 'h4',\n size: '$7',\n})\n\nexport const H5 = styled(Heading, {\n name: 'H5',\n tag: 'h5',\n size: '$6',\n})\n\nexport const H6 = styled(Heading, {\n name: 'H6',\n tag: 'h6',\n size: '$5',\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,iBAAiB;AAEnB,MAAM,UAAU,OAAO,WAAW;AAAA,EACvC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import { styled } from "@tamagui/core";
2
+ import { SizableText } from "./SizableText";
3
+ const Paragraph = styled(SizableText, {
4
+ name: "Paragraph",
5
+ tag: "p",
6
+ userSelect: "auto",
7
+ color: "$color",
8
+ size: "$true"
9
+ });
10
+ export {
11
+ Paragraph
12
+ };
13
+ //# sourceMappingURL=Paragraph.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Paragraph.tsx"],
4
+ "sourcesContent": ["import { GetProps, styled } from '@tamagui/core'\n\nimport { SizableText } from './SizableText'\n\nexport const Paragraph = styled(SizableText, {\n name: 'Paragraph',\n tag: 'p',\n userSelect: 'auto',\n color: '$color',\n size: '$true',\n})\n\nexport type ParagraphProps = GetProps<typeof Paragraph>\n"],
5
+ "mappings": "AAAA,SAAmB,cAAc;AAEjC,SAAS,mBAAmB;AAErB,MAAM,YAAY,OAAO,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,MAAM;AACR,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import { Text, styled } from "@tamagui/core";
2
+ import { getFontSized } from "@tamagui/get-font-sized";
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
+ };
16
+ //# sourceMappingURL=SizableText.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SizableText.tsx"],
4
+ "sourcesContent": ["import { GetProps, Text, styled } from '@tamagui/core'\nimport { getFontSized } from '@tamagui/get-font-sized'\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,SAAmB,MAAM,cAAc;AACvC,SAAS,oBAAoB;AAEtB,MAAM,cAAc,OAAO,MAAM;AAAA,EACtC,MAAM;AAAA,EACN,YAAY;AAAA,EAEZ,UAAU;AAAA,IACR,MAAM;AAAA,EACR;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./SizableText";
2
+ export * from "./Paragraph";
3
+ export * from "./Headings";
4
+ export * from "./wrapChildrenInText";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\nexport * from './Headings'\nexport * from './wrapChildrenInText'\nexport * from './types'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,67 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ function wrapChildrenInText(TextComponent, propsIn, extraProps) {
4
+ const {
5
+ children,
6
+ textProps,
7
+ size,
8
+ noTextWrap,
9
+ color,
10
+ fontFamily,
11
+ fontSize,
12
+ fontWeight,
13
+ letterSpacing,
14
+ textAlign
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
+ function concatStringChildren() {
40
+ if (!lastIsString)
41
+ return;
42
+ const index = nextChildren.length - 1;
43
+ const childrenStrings = nextChildren[index];
44
+ nextChildren[index] = /* @__PURE__ */ jsx(TextComponent, { ...props, ...textProps, children: childrenStrings }, index);
45
+ }
46
+ for (const child of allChildren) {
47
+ const last = nextChildren[nextChildren.length - 1];
48
+ const isString = typeof child === "string";
49
+ if (isString) {
50
+ if (lastIsString) {
51
+ last.push(child);
52
+ } else {
53
+ nextChildren.push([child]);
54
+ }
55
+ } else {
56
+ concatStringChildren();
57
+ nextChildren.push(child);
58
+ }
59
+ lastIsString = isString;
60
+ }
61
+ concatStringChildren();
62
+ return nextChildren;
63
+ }
64
+ export {
65
+ wrapChildrenInText
66
+ };
67
+ //# sourceMappingURL=wrapChildrenInText.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapChildrenInText.tsx"],
4
+ "sourcesContent": ["import type { 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 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 } = 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 // 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\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": "AA2DM;AA1DN,OAAO,WAAW;AASX,SAAS,mBACd,eACA,SAGA,YACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,cAAc,CAAC,UAAU;AAC3B,WAAO,CAAC,QAAQ;AAAA,EAClB;AAOA,QAAM,cAAc,MAAM,SAAS,QAAQ,QAAQ;AACnD,QAAM,eAAsB,CAAC;AAC7B,MAAI,eAAe;AACnB,QAAM,QAAQ;AAAA,IACZ,GAAG;AAAA,EACL;AAEA,MAAI;AAAO,UAAM,QAAQ;AACzB,MAAI;AAAY,UAAM,aAAa;AACnC,MAAI;AAAU,UAAM,WAAW;AAC/B,MAAI;AAAY,UAAM,aAAa;AACnC,MAAI;AAAe,UAAM,gBAAgB;AACzC,MAAI;AAAW,UAAM,YAAY;AACjC,MAAI;AAAM,UAAM,OAAO;AAEvB,WAAS,uBAAuB;AAC9B,QAAI,CAAC;AAAc;AACnB,UAAM,QAAQ,aAAa,SAAS;AACpC,UAAM,kBAAkB,aAAa,KAAK;AAC1C,iBAAa,KAAK,IAChB,oBAAC,iBAA2B,GAAG,OAAQ,GAAG,WACvC,6BADiB,KAEpB;AAAA,EAEJ;AAEA,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,aAAa,aAAa,SAAS,CAAC;AACjD,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,30 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { expect, test } from "vitest";
3
+ import { wrapChildrenInText } from "./wrapChildrenInText";
4
+ const Comp = () => {
5
+ };
6
+ const re = /* @__PURE__ */ jsx("div", { "data-id": Math.random() });
7
+ const reID = re.props["data-id"];
8
+ test("should wrap all string children, not wrap others", () => {
9
+ const out = wrapChildrenInText(Comp, {
10
+ children: [re, "a", "b", re, "c", re, "d"]
11
+ });
12
+ expect(out[0].props["data-id"]).toBe(reID);
13
+ expect(out[1].type).toBe(Comp);
14
+ expect(out[1].props.children).toStrictEqual(["a", "b"]);
15
+ expect(out[2].props["data-id"]).toBe(reID);
16
+ expect(out[3].type).toBe(Comp);
17
+ expect(out[3].props.children).toStrictEqual(["c"]);
18
+ expect(out[4].props["data-id"]).toBe(reID);
19
+ expect(out[5].type).toBe(Comp);
20
+ expect(out[5].props.children).toStrictEqual(["d"]);
21
+ });
22
+ test("should first child string", () => {
23
+ const out = wrapChildrenInText(Comp, {
24
+ children: ["a", re]
25
+ });
26
+ expect(out[0].type).toBe(Comp);
27
+ expect(out[0].props.children).toStrictEqual(["a"]);
28
+ expect(out[1].props["data-id"]).toBe(reID);
29
+ });
30
+ //# sourceMappingURL=wrapChildrenInText.test.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapChildrenInText.test.tsx"],
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": "AAMW;AALX,SAAS,QAAQ,YAAY;AAE7B,SAAS,0BAA0B;AAEnC,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,oBAAC,SAAI,WAAS,KAAK,OAAO,GAAG;AACxC,MAAM,OAAO,GAAG,MAAM,SAAS;AAE/B,KAAK,oDAAoD,MAAM;AAC7D,QAAM,MAAM,mBAAmB,MAAM;AAAA,IACnC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC3C,CAAC;AAED,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC;AAEtD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,KAAK,6BAA6B,MAAM;AACtC,QAAM,MAAM,mBAAmB,MAAM;AAAA,IACnC,UAAU,CAAC,KAAK,EAAE;AAAA,EACpB,CAAC;AAED,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAC3C,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ import { styled } from "@tamagui/core";
2
+ import { Paragraph } from "./Paragraph";
3
+ const Heading = styled(Paragraph, {
4
+ tag: "span",
5
+ name: "Heading",
6
+ accessibilityRole: "header",
7
+ fontFamily: "$heading",
8
+ size: "$8",
9
+ margin: 0
10
+ });
11
+ const H1 = styled(Heading, {
12
+ name: "H1",
13
+ tag: "h1",
14
+ size: "$10"
15
+ });
16
+ const H2 = styled(Heading, {
17
+ name: "H2",
18
+ tag: "h2",
19
+ size: "$9"
20
+ });
21
+ const H3 = styled(Heading, {
22
+ name: "H3",
23
+ tag: "h3",
24
+ size: "$8"
25
+ });
26
+ const H4 = styled(Heading, {
27
+ name: "H4",
28
+ tag: "h4",
29
+ size: "$7"
30
+ });
31
+ const H5 = styled(Heading, {
32
+ name: "H5",
33
+ tag: "h5",
34
+ size: "$6"
35
+ });
36
+ const H6 = styled(Heading, {
37
+ name: "H6",
38
+ tag: "h6",
39
+ size: "$5"
40
+ });
41
+ export {
42
+ H1,
43
+ H2,
44
+ H3,
45
+ H4,
46
+ H5,
47
+ H6,
48
+ Heading
49
+ };
50
+ //# sourceMappingURL=Headings.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Headings.tsx"],
4
+ "sourcesContent": ["import { styled } from '@tamagui/core'\n\nimport { Paragraph } from './Paragraph'\n\nexport const Heading = styled(Paragraph, {\n tag: 'span',\n name: 'Heading',\n accessibilityRole: 'header',\n fontFamily: '$heading',\n size: '$8',\n margin: 0,\n})\n\nexport const H1 = styled(Heading, {\n name: 'H1',\n tag: 'h1',\n size: '$10',\n})\n\nexport const H2 = styled(Heading, {\n name: 'H2',\n tag: 'h2',\n size: '$9',\n})\n\nexport const H3 = styled(Heading, {\n name: 'H3',\n tag: 'h3',\n size: '$8',\n})\n\nexport const H4 = styled(Heading, {\n name: 'H4',\n tag: 'h4',\n size: '$7',\n})\n\nexport const H5 = styled(Heading, {\n name: 'H5',\n tag: 'h5',\n size: '$6',\n})\n\nexport const H6 = styled(Heading, {\n name: 'H6',\n tag: 'h6',\n size: '$5',\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,iBAAiB;AAEnB,MAAM,UAAU,OAAO,WAAW;AAAA,EACvC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,KAAK,OAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ import { styled } from "@tamagui/core";
2
+ import { SizableText } from "./SizableText";
3
+ const Paragraph = styled(SizableText, {
4
+ name: "Paragraph",
5
+ tag: "p",
6
+ userSelect: "auto",
7
+ color: "$color",
8
+ size: "$true"
9
+ });
10
+ export {
11
+ Paragraph
12
+ };
13
+ //# sourceMappingURL=Paragraph.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Paragraph.tsx"],
4
+ "sourcesContent": ["import { GetProps, styled } from '@tamagui/core'\n\nimport { SizableText } from './SizableText'\n\nexport const Paragraph = styled(SizableText, {\n name: 'Paragraph',\n tag: 'p',\n userSelect: 'auto',\n color: '$color',\n size: '$true',\n})\n\nexport type ParagraphProps = GetProps<typeof Paragraph>\n"],
5
+ "mappings": "AAAA,SAAmB,cAAc;AAEjC,SAAS,mBAAmB;AAErB,MAAM,YAAY,OAAO,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,MAAM;AACR,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import { Text, styled } from "@tamagui/core";
2
+ import { getFontSized } from "@tamagui/get-font-sized";
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
+ };
16
+ //# sourceMappingURL=SizableText.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SizableText.tsx"],
4
+ "sourcesContent": ["import { GetProps, Text, styled } from '@tamagui/core'\nimport { getFontSized } from '@tamagui/get-font-sized'\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,SAAmB,MAAM,cAAc;AACvC,SAAS,oBAAoB;AAEtB,MAAM,cAAc,OAAO,MAAM;AAAA,EACtC,MAAM;AAAA,EACN,YAAY;AAAA,EAEZ,UAAU;AAAA,IACR,MAAM;AAAA,EACR;AAAA,EAEA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./SizableText";
2
+ export * from "./Paragraph";
3
+ export * from "./Headings";
4
+ export * from "./wrapChildrenInText";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\nexport * from './Headings'\nexport * from './wrapChildrenInText'\nexport * from './types'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,66 @@
1
+ import React from "react";
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
+ } = propsIn;
15
+ if (noTextWrap || !children) {
16
+ return [children];
17
+ }
18
+ const allChildren = React.Children.toArray(children);
19
+ const nextChildren = [];
20
+ let lastIsString = false;
21
+ const props = {
22
+ ...extraProps
23
+ };
24
+ if (color)
25
+ props.color = color;
26
+ if (fontFamily)
27
+ props.fontFamily = fontFamily;
28
+ if (fontSize)
29
+ props.fontSize = fontSize;
30
+ if (fontWeight)
31
+ props.fontWeight = fontWeight;
32
+ if (letterSpacing)
33
+ props.letterSpacing = letterSpacing;
34
+ if (textAlign)
35
+ props.textAlign = textAlign;
36
+ if (size)
37
+ props.size = size;
38
+ function concatStringChildren() {
39
+ if (!lastIsString)
40
+ return;
41
+ const index = nextChildren.length - 1;
42
+ const childrenStrings = nextChildren[index];
43
+ nextChildren[index] = <TextComponent key={index} {...props} {...textProps}>{childrenStrings}</TextComponent>;
44
+ }
45
+ for (const child of allChildren) {
46
+ const last = nextChildren[nextChildren.length - 1];
47
+ const isString = typeof child === "string";
48
+ if (isString) {
49
+ if (lastIsString) {
50
+ last.push(child);
51
+ } else {
52
+ nextChildren.push([child]);
53
+ }
54
+ } else {
55
+ concatStringChildren();
56
+ nextChildren.push(child);
57
+ }
58
+ lastIsString = isString;
59
+ }
60
+ concatStringChildren();
61
+ return nextChildren;
62
+ }
63
+ export {
64
+ wrapChildrenInText
65
+ };
66
+ //# sourceMappingURL=wrapChildrenInText.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapChildrenInText.tsx"],
4
+ "sourcesContent": ["import type { 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 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 } = 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 // 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\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,OAAO,WAAW;AASX,SAAS,mBACd,eACA,SAGA,YACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,cAAc,CAAC,UAAU;AAC3B,WAAO,CAAC,QAAQ;AAAA,EAClB;AAOA,QAAM,cAAc,MAAM,SAAS,QAAQ,QAAQ;AACnD,QAAM,eAAsB,CAAC;AAC7B,MAAI,eAAe;AACnB,QAAM,QAAQ;AAAA,IACZ,GAAG;AAAA,EACL;AAEA,MAAI;AAAO,UAAM,QAAQ;AACzB,MAAI;AAAY,UAAM,aAAa;AACnC,MAAI;AAAU,UAAM,WAAW;AAC/B,MAAI;AAAY,UAAM,aAAa;AACnC,MAAI;AAAe,UAAM,gBAAgB;AACzC,MAAI;AAAW,UAAM,YAAY;AACjC,MAAI;AAAM,UAAM,OAAO;AAEvB,WAAS,uBAAuB;AAC9B,QAAI,CAAC;AAAc;AACnB,UAAM,QAAQ,aAAa,SAAS;AACpC,UAAM,kBAAkB,aAAa,KAAK;AAC1C,iBAAa,KAAK,IAChB,CAAC,cAAc,KAAK,WAAW,WAAW,YACvC,gBACH,EAFC;AAAA,EAIL;AAEA,aAAW,SAAS,aAAa;AAC/B,UAAM,OAAO,aAAa,aAAa,SAAS,CAAC;AACjD,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 { 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
+ });
29
+ //# sourceMappingURL=wrapChildrenInText.test.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/wrapChildrenInText.test.tsx"],
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,SAAS,QAAQ,YAAY;AAE7B,SAAS,0BAA0B;AAEnC,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,CAAC,IAAI,SAAS,KAAK,OAAO,GAAG;AACxC,MAAM,OAAO,GAAG,MAAM,SAAS;AAE/B,KAAK,oDAAoD,MAAM;AAC7D,QAAM,MAAM,mBAAmB,MAAM;AAAA,IACnC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC3C,CAAC;AAED,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC;AAEtD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAEzC,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,KAAK,6BAA6B,MAAM;AACtC,QAAM,MAAM,mBAAmB,MAAM;AAAA,IACnC,UAAU,CAAC,KAAK,EAAE;AAAA,EACpB,CAAC;AAED,SAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI;AAC7B,SAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC;AAEjD,SAAO,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAK,IAAI;AAC3C,CAAC;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/text",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -26,21 +26,21 @@
26
26
  "./package.json": "./package.json",
27
27
  ".": {
28
28
  "types": "./types/index.d.ts",
29
- "import": "./dist/esm/index.js",
29
+ "import": "./dist/esm/index.mjs",
30
30
  "require": "./dist/cjs/index.js"
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@tamagui/core": "^1.2.9",
35
- "@tamagui/get-font-sized": "^1.2.9",
36
- "@tamagui/helpers-tamagui": "^1.2.9"
34
+ "@tamagui/core": "^1.2.11",
35
+ "@tamagui/get-font-sized": "^1.2.11",
36
+ "@tamagui/helpers-tamagui": "^1.2.11"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "*",
40
40
  "react-dom": "*"
41
41
  },
42
42
  "devDependencies": {
43
- "@tamagui/build": "^1.2.9",
43
+ "@tamagui/build": "^1.2.11",
44
44
  "react": "^18.2.0",
45
45
  "react-dom": "^18.2.0"
46
46
  },