@tamagui/text 1.0.1-beta.20 → 1.0.1-beta.201
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 +80 -0
- package/dist/cjs/Headings.js.map +7 -0
- package/dist/cjs/Paragraph.js +1 -0
- package/dist/cjs/Paragraph.js.map +1 -1
- package/dist/cjs/SizableText.js +3 -1
- package/dist/cjs/SizableText.js.map +2 -2
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/wrapChildrenInText.js +99 -0
- package/dist/cjs/wrapChildrenInText.js.map +7 -0
- package/dist/cjs/wrapChildrenInText.test.js +33 -0
- package/dist/cjs/wrapChildrenInText.test.js.map +7 -0
- package/dist/esm/Headings.js +50 -0
- package/dist/esm/Headings.js.map +7 -0
- package/dist/esm/Paragraph.js +0 -0
- package/dist/esm/Paragraph.js.map +1 -1
- package/dist/esm/SizableText.js +3 -2
- package/dist/esm/SizableText.js.map +2 -2
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js +1 -0
- package/dist/{cjs/Texts.js.map → esm/types.js.map} +0 -0
- package/dist/esm/wrapChildrenInText.js +69 -0
- package/dist/esm/wrapChildrenInText.js.map +7 -0
- package/dist/esm/wrapChildrenInText.test.js +32 -0
- package/dist/esm/wrapChildrenInText.test.js.map +7 -0
- package/dist/jsx/.tamagui-dynamic-eval-Headings.js.js +42 -0
- package/dist/jsx/.tamagui-dynamic-eval-Paragraph.js.js +10 -0
- package/dist/jsx/.tamagui-dynamic-eval-SizableText.js.js +15 -0
- package/dist/jsx/Headings.js +50 -0
- package/dist/jsx/Headings.js.map +7 -0
- package/dist/jsx/Paragraph.js +1 -0
- package/dist/jsx/Paragraph.js.map +7 -0
- package/dist/jsx/SizableText.js +4 -2
- package/dist/jsx/SizableText.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/{esm/Texts.js.map → jsx/types.js.map} +0 -0
- package/dist/jsx/wrapChildrenInText.js +64 -0
- package/dist/jsx/wrapChildrenInText.js.map +7 -0
- package/dist/jsx/wrapChildrenInText.test.js +29 -0
- package/dist/jsx/wrapChildrenInText.test.js.map +7 -0
- package/package.json +18 -7
- package/src/Headings.tsx +48 -0
- package/src/Paragraph.tsx +12 -0
- package/src/SizableText.tsx +17 -0
- package/src/index.tsx +5 -0
- package/src/types.ts +13 -0
- package/src/wrapChildrenInText.test.tsx +40 -0
- package/src/wrapChildrenInText.tsx +76 -0
- package/types/Headings.d.ts +1452 -0
- package/types/Paragraph.d.ts +17 -15
- package/types/SizableText.d.ts +8 -8
- package/types/index.d.ts +3 -0
- package/types/types.d.ts +12 -0
- package/types/wrapChildrenInText.d.ts +10 -0
- package/types/wrapChildrenInText.test.d.ts +2 -0
- package/dist/cjs/Texts.js +0 -1
- package/dist/esm/Texts.js +0 -1
- package/dist/jsx/Texts.js +0 -0
- package/types/Paragraph.d.ts.map +0 -1
- package/types/SizableText.d.ts.map +0 -1
- package/types/Texts.d.ts +0 -1
- package/types/Texts.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Headings_exports = {};
|
|
20
|
+
__export(Headings_exports, {
|
|
21
|
+
H1: () => H1,
|
|
22
|
+
H2: () => H2,
|
|
23
|
+
H3: () => H3,
|
|
24
|
+
H4: () => H4,
|
|
25
|
+
H5: () => H5,
|
|
26
|
+
H6: () => H6,
|
|
27
|
+
Heading: () => Heading
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(Headings_exports);
|
|
30
|
+
var import_core = require("@tamagui/core");
|
|
31
|
+
var import_Paragraph = require("./Paragraph");
|
|
32
|
+
const Heading = (0, import_core.styled)(import_Paragraph.Paragraph, {
|
|
33
|
+
tag: "span",
|
|
34
|
+
name: "Heading",
|
|
35
|
+
accessibilityRole: "header",
|
|
36
|
+
fontFamily: "$heading",
|
|
37
|
+
size: "$8",
|
|
38
|
+
margin: 0
|
|
39
|
+
});
|
|
40
|
+
const H1 = (0, import_core.styled)(Heading, {
|
|
41
|
+
name: "H1",
|
|
42
|
+
tag: "h1",
|
|
43
|
+
size: "$10"
|
|
44
|
+
});
|
|
45
|
+
const H2 = (0, import_core.styled)(Heading, {
|
|
46
|
+
name: "H2",
|
|
47
|
+
tag: "h2",
|
|
48
|
+
size: "$9"
|
|
49
|
+
});
|
|
50
|
+
const H3 = (0, import_core.styled)(Heading, {
|
|
51
|
+
name: "H3",
|
|
52
|
+
tag: "h3",
|
|
53
|
+
size: "$8"
|
|
54
|
+
});
|
|
55
|
+
const H4 = (0, import_core.styled)(Heading, {
|
|
56
|
+
name: "H4",
|
|
57
|
+
tag: "h4",
|
|
58
|
+
size: "$7"
|
|
59
|
+
});
|
|
60
|
+
const H5 = (0, import_core.styled)(Heading, {
|
|
61
|
+
name: "H5",
|
|
62
|
+
tag: "h5",
|
|
63
|
+
size: "$6"
|
|
64
|
+
});
|
|
65
|
+
const H6 = (0, import_core.styled)(Heading, {
|
|
66
|
+
name: "H6",
|
|
67
|
+
tag: "h6",
|
|
68
|
+
size: "$5"
|
|
69
|
+
});
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
H1,
|
|
73
|
+
H2,
|
|
74
|
+
H3,
|
|
75
|
+
H4,
|
|
76
|
+
H5,
|
|
77
|
+
H6,
|
|
78
|
+
Heading
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=Headings.js.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AAEvB,uBAA0B;AAEnB,MAAM,cAAU,oBAAO,4BAAW;AAAA,EACvC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,QAAQ;AACV,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;AAEM,MAAM,SAAK,oBAAO,SAAS;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/Paragraph.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Paragraph.tsx"],
|
|
4
4
|
"sourcesContent": ["import { PropTypes, styled } from '@tamagui/core'\n\nimport { SizableText } from './SizableText'\n\nexport const Paragraph = styled(SizableText, {\n name: 'Paragraph',\n tag: 'p',\n selectable: true,\n cursor: 'text',\n})\n\nexport type ParagraphProps = PropTypes<typeof Paragraph>\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAElC,yBAA4B;AAErB,MAAM,gBAAY,oBAAO,gCAAa;AAAA,EAC3C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,QAAQ;AACV,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/SizableText.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -21,11 +22,12 @@ __export(SizableText_exports, {
|
|
|
21
22
|
});
|
|
22
23
|
module.exports = __toCommonJS(SizableText_exports);
|
|
23
24
|
var import_core = require("@tamagui/core");
|
|
25
|
+
var import_get_font_sized = require("@tamagui/get-font-sized");
|
|
24
26
|
const SizableText = (0, import_core.styled)(import_core.Text, {
|
|
25
27
|
name: "SizableText",
|
|
26
28
|
fontFamily: "$body",
|
|
27
29
|
variants: {
|
|
28
|
-
size:
|
|
30
|
+
size: import_get_font_sized.getFontSized
|
|
29
31
|
},
|
|
30
32
|
defaultVariants: {
|
|
31
33
|
size: "$4"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SizableText.tsx"],
|
|
4
|
-
"sourcesContent": ["import { GetProps, Text,
|
|
5
|
-
"mappings": "
|
|
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: '$4',\n },\n})\n\nexport type SizableTextProps = GetProps<typeof SizableText>\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuC;AACvC,4BAA6B;AAEtB,MAAM,kBAAc,oBAAO,kBAAM;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
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -16,4 +17,7 @@ var src_exports = {};
|
|
|
16
17
|
module.exports = __toCommonJS(src_exports);
|
|
17
18
|
__reExport(src_exports, require("./SizableText"), module.exports);
|
|
18
19
|
__reExport(src_exports, require("./Paragraph"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./Headings"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./wrapChildrenInText"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
19
23
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\nexport * from './Headings'\nexport * from './wrapChildrenInText'\nexport * from './types'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;AACA,wBAAc,wBADd;AAEA,wBAAc,uBAFd;AAGA,wBAAc,iCAHd;AAIA,wBAAc,oBAJd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import { SizableTextProps } from './SizableText'\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,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var wrapChildrenInText_exports = {};
|
|
26
|
+
__export(wrapChildrenInText_exports, {
|
|
27
|
+
wrapChildrenInText: () => wrapChildrenInText
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(wrapChildrenInText_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_react = __toESM(require("react"));
|
|
32
|
+
function wrapChildrenInText(TextComponent, propsIn) {
|
|
33
|
+
const {
|
|
34
|
+
children,
|
|
35
|
+
textProps,
|
|
36
|
+
size,
|
|
37
|
+
noTextWrap,
|
|
38
|
+
color,
|
|
39
|
+
fontFamily,
|
|
40
|
+
fontSize,
|
|
41
|
+
fontWeight,
|
|
42
|
+
letterSpacing,
|
|
43
|
+
textAlign
|
|
44
|
+
} = propsIn;
|
|
45
|
+
if (noTextWrap || !children) {
|
|
46
|
+
return children;
|
|
47
|
+
}
|
|
48
|
+
const allChildren = import_react.default.Children.toArray(children);
|
|
49
|
+
const nextChildren = [];
|
|
50
|
+
let lastIsString = false;
|
|
51
|
+
const props = {};
|
|
52
|
+
if (color)
|
|
53
|
+
props.color = color;
|
|
54
|
+
if (fontFamily)
|
|
55
|
+
props.fontFamily = fontFamily;
|
|
56
|
+
if (fontSize)
|
|
57
|
+
props.fontSize = fontSize;
|
|
58
|
+
if (fontWeight)
|
|
59
|
+
props.fontWeight = fontWeight;
|
|
60
|
+
if (letterSpacing)
|
|
61
|
+
props.letterSpacing = letterSpacing;
|
|
62
|
+
if (textAlign)
|
|
63
|
+
props.textAlign = textAlign;
|
|
64
|
+
if (size)
|
|
65
|
+
props.size = size;
|
|
66
|
+
function concatStringChildren() {
|
|
67
|
+
if (!lastIsString)
|
|
68
|
+
return;
|
|
69
|
+
const index = nextChildren.length - 1;
|
|
70
|
+
const childrenStrings = nextChildren[index];
|
|
71
|
+
nextChildren[index] = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextComponent, {
|
|
72
|
+
...props,
|
|
73
|
+
...textProps,
|
|
74
|
+
children: childrenStrings
|
|
75
|
+
}, index);
|
|
76
|
+
}
|
|
77
|
+
for (const child of allChildren) {
|
|
78
|
+
const last = nextChildren[nextChildren.length - 1];
|
|
79
|
+
const isString = typeof child === "string";
|
|
80
|
+
if (isString) {
|
|
81
|
+
if (lastIsString) {
|
|
82
|
+
last.push(child);
|
|
83
|
+
} else {
|
|
84
|
+
nextChildren.push([child]);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
concatStringChildren();
|
|
88
|
+
nextChildren.push(child);
|
|
89
|
+
}
|
|
90
|
+
lastIsString = isString;
|
|
91
|
+
}
|
|
92
|
+
concatStringChildren();
|
|
93
|
+
return nextChildren;
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
wrapChildrenInText
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=wrapChildrenInText.js.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(TextComponent: any, propsIn: Props) {\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: any = {}\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": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDM;AAlDN,mBAAkB;AASX,SAAS,mBAAmB,eAAoB,SAAgB;AACrE,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;AAAA,EACT;AAOA,QAAM,cAAc,aAAAA,QAAM,SAAS,QAAQ,QAAQ;AACnD,QAAM,eAAsB,CAAC;AAC7B,MAAI,eAAe;AACnB,QAAM,QAAa,CAAC;AAEpB,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;AACrC,iBAAa,SACX,4CAAC;AAAA,MAA2B,GAAG;AAAA,MAAQ,GAAG;AAAA,MACvC;AAAA,OADiB,KAEpB;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": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_wrapChildrenInText = require("./wrapChildrenInText");
|
|
5
|
+
const Comp = () => {
|
|
6
|
+
};
|
|
7
|
+
const re = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
8
|
+
"data-id": Math.random()
|
|
9
|
+
});
|
|
10
|
+
const reID = re.props["data-id"];
|
|
11
|
+
(0, import_vitest.test)("should wrap all string children, not wrap others", () => {
|
|
12
|
+
const out = (0, import_wrapChildrenInText.wrapChildrenInText)(Comp, {
|
|
13
|
+
children: [re, "a", "b", re, "c", re, "d"]
|
|
14
|
+
});
|
|
15
|
+
(0, import_vitest.expect)(out[0].props["data-id"]).toBe(reID);
|
|
16
|
+
(0, import_vitest.expect)(out[1].type).toBe(Comp);
|
|
17
|
+
(0, import_vitest.expect)(out[1].props.children).toStrictEqual(["a", "b"]);
|
|
18
|
+
(0, import_vitest.expect)(out[2].props["data-id"]).toBe(reID);
|
|
19
|
+
(0, import_vitest.expect)(out[3].type).toBe(Comp);
|
|
20
|
+
(0, import_vitest.expect)(out[3].props.children).toStrictEqual(["c"]);
|
|
21
|
+
(0, import_vitest.expect)(out[4].props["data-id"]).toBe(reID);
|
|
22
|
+
(0, import_vitest.expect)(out[5].type).toBe(Comp);
|
|
23
|
+
(0, import_vitest.expect)(out[5].props.children).toStrictEqual(["d"]);
|
|
24
|
+
});
|
|
25
|
+
(0, import_vitest.test)("should first child string", () => {
|
|
26
|
+
const out = (0, import_wrapChildrenInText.wrapChildrenInText)(Comp, {
|
|
27
|
+
children: ["a", re]
|
|
28
|
+
});
|
|
29
|
+
(0, import_vitest.expect)(out[0].type).toBe(Comp);
|
|
30
|
+
(0, import_vitest.expect)(out[0].props.children).toStrictEqual(["a"]);
|
|
31
|
+
(0, import_vitest.expect)(out[1].props["data-id"]).toBe(reID);
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=wrapChildrenInText.test.js.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,oBAA6B;AAE7B,gCAAmC;AAEnC,MAAM,OAAO,MAAM;AAAC;AACpB,MAAM,KAAK,4CAAC;AAAA,EAAI,WAAS,KAAK,OAAO;AAAA,CAAG;AACxC,MAAM,OAAO,GAAG,MAAM;AAAA,IAEtB,oBAAK,oDAAoD,MAAM;AAC7D,QAAM,UAAM,8CAAmB,MAAM;AAAA,IACnC,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;AAAA,IAED,oBAAK,6BAA6B,MAAM;AACtC,QAAM,UAAM,8CAAmB,MAAM;AAAA,IACnC,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,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.js.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
|
+
}
|
package/dist/esm/Paragraph.js
CHANGED
|
File without changes
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Paragraph.tsx"],
|
|
4
4
|
"sourcesContent": ["import { PropTypes, styled } from '@tamagui/core'\n\nimport { SizableText } from './SizableText'\n\nexport const Paragraph = styled(SizableText, {\n name: 'Paragraph',\n tag: 'p',\n selectable: true,\n cursor: 'text',\n})\n\nexport type ParagraphProps = PropTypes<typeof Paragraph>\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,SAAoB,cAAc;AAElC,SAAS,mBAAmB;AAErB,MAAM,YAAY,OAAO,aAAa;AAAA,EAC3C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,QAAQ;AACV,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/SizableText.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Text,
|
|
1
|
+
import { Text, styled } from "@tamagui/core";
|
|
2
|
+
import { getFontSized } from "@tamagui/get-font-sized";
|
|
2
3
|
const SizableText = styled(Text, {
|
|
3
4
|
name: "SizableText",
|
|
4
5
|
fontFamily: "$body",
|
|
5
6
|
variants: {
|
|
6
|
-
size:
|
|
7
|
+
size: getFontSized
|
|
7
8
|
},
|
|
8
9
|
defaultVariants: {
|
|
9
10
|
size: "$4"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SizableText.tsx"],
|
|
4
|
-
"sourcesContent": ["import { GetProps, Text,
|
|
5
|
-
"mappings": "AAAA;
|
|
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: '$4',\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
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["export * from './SizableText'\nexport * from './Paragraph'\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
function wrapChildrenInText(TextComponent, propsIn) {
|
|
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
|
+
if (color)
|
|
24
|
+
props.color = color;
|
|
25
|
+
if (fontFamily)
|
|
26
|
+
props.fontFamily = fontFamily;
|
|
27
|
+
if (fontSize)
|
|
28
|
+
props.fontSize = fontSize;
|
|
29
|
+
if (fontWeight)
|
|
30
|
+
props.fontWeight = fontWeight;
|
|
31
|
+
if (letterSpacing)
|
|
32
|
+
props.letterSpacing = letterSpacing;
|
|
33
|
+
if (textAlign)
|
|
34
|
+
props.textAlign = textAlign;
|
|
35
|
+
if (size)
|
|
36
|
+
props.size = size;
|
|
37
|
+
function concatStringChildren() {
|
|
38
|
+
if (!lastIsString)
|
|
39
|
+
return;
|
|
40
|
+
const index = nextChildren.length - 1;
|
|
41
|
+
const childrenStrings = nextChildren[index];
|
|
42
|
+
nextChildren[index] = /* @__PURE__ */ jsx(TextComponent, {
|
|
43
|
+
...props,
|
|
44
|
+
...textProps,
|
|
45
|
+
children: childrenStrings
|
|
46
|
+
}, index);
|
|
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
|
+
};
|
|
69
|
+
//# sourceMappingURL=wrapChildrenInText.js.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(TextComponent: any, propsIn: Props) {\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: any = {}\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": "AAmDM;AAlDN,OAAO,WAAW;AASX,SAAS,mBAAmB,eAAoB,SAAgB;AACrE,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;AAAA,EACT;AAOA,QAAM,cAAc,MAAM,SAAS,QAAQ,QAAQ;AACnD,QAAM,eAAsB,CAAC;AAC7B,MAAI,eAAe;AACnB,QAAM,QAAa,CAAC;AAEpB,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;AACrC,iBAAa,SACX,oBAAC;AAAA,MAA2B,GAAG;AAAA,MAAQ,GAAG;AAAA,MACvC;AAAA,OADiB,KAEpB;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,32 @@
|
|
|
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", {
|
|
7
|
+
"data-id": Math.random()
|
|
8
|
+
});
|
|
9
|
+
const reID = re.props["data-id"];
|
|
10
|
+
test("should wrap all string children, not wrap others", () => {
|
|
11
|
+
const out = wrapChildrenInText(Comp, {
|
|
12
|
+
children: [re, "a", "b", re, "c", re, "d"]
|
|
13
|
+
});
|
|
14
|
+
expect(out[0].props["data-id"]).toBe(reID);
|
|
15
|
+
expect(out[1].type).toBe(Comp);
|
|
16
|
+
expect(out[1].props.children).toStrictEqual(["a", "b"]);
|
|
17
|
+
expect(out[2].props["data-id"]).toBe(reID);
|
|
18
|
+
expect(out[3].type).toBe(Comp);
|
|
19
|
+
expect(out[3].props.children).toStrictEqual(["c"]);
|
|
20
|
+
expect(out[4].props["data-id"]).toBe(reID);
|
|
21
|
+
expect(out[5].type).toBe(Comp);
|
|
22
|
+
expect(out[5].props.children).toStrictEqual(["d"]);
|
|
23
|
+
});
|
|
24
|
+
test("should first child string", () => {
|
|
25
|
+
const out = wrapChildrenInText(Comp, {
|
|
26
|
+
children: ["a", re]
|
|
27
|
+
});
|
|
28
|
+
expect(out[0].type).toBe(Comp);
|
|
29
|
+
expect(out[0].props.children).toStrictEqual(["a"]);
|
|
30
|
+
expect(out[1].props["data-id"]).toBe(reID);
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=wrapChildrenInText.test.js.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;AAAA,EAAI,WAAS,KAAK,OAAO;AAAA,CAAG;AACxC,MAAM,OAAO,GAAG,MAAM;AAEtB,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,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,mBAAmB,MAAM;AAAA,IACnC,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,42 @@
|
|
|
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 { H1, H2, H3, H4, H5, H6, Heading };
|
|
42
|
+
//# sourceMappingURL=Headings.js.map
|