@tamagui/get-font-sized 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +62 -98
- package/dist/cjs/index.native.cjs +85 -0
- package/dist/cjs/index.native.js +66 -109
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.js +49 -82
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +49 -82
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +52 -93
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +11 -42
- package/types/index.d.ts +11 -3
- package/types/index.d.ts.map +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,115 +1,79 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var index_exports = {};
|
|
24
23
|
__export(index_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
SizableText: () => SizableText,
|
|
25
|
+
getFontSized: () => getFontSized
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(index_exports);
|
|
29
28
|
var import_constants = require("@tamagui/constants");
|
|
29
|
+
var import_size = require("@tamagui/size");
|
|
30
30
|
var import_web = require("@tamagui/web");
|
|
31
|
-
const getFontSized = (sizeTokenIn =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
console.groupEnd();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return style;
|
|
31
|
+
const getFontSized = (sizeTokenIn = true, { font, fontFamily, props }) => {
|
|
32
|
+
if (!font) {
|
|
33
|
+
return { fontSize: sizeTokenIn };
|
|
34
|
+
}
|
|
35
|
+
const sizeToken = (0, import_size.resolveSizeToken)(sizeTokenIn, "fontSize");
|
|
36
|
+
const style = {};
|
|
37
|
+
if (typeof sizeToken === "number") {
|
|
38
|
+
style.fontSize = sizeToken;
|
|
39
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
40
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
41
|
+
if (props.color) style.color = props.color;
|
|
42
|
+
return style;
|
|
43
|
+
}
|
|
44
|
+
const fontSize = font.size[sizeToken];
|
|
45
|
+
const lineHeight = font.lineHeight?.[sizeToken];
|
|
46
|
+
const fontWeight = font.weight?.[sizeToken];
|
|
47
|
+
const letterSpacing = font.letterSpacing?.[sizeToken];
|
|
48
|
+
const textTransform = font.transform?.[sizeToken];
|
|
49
|
+
const fontStyle = props.fontStyle ?? font.style?.[sizeToken];
|
|
50
|
+
const color = props.color ?? font.color?.[sizeToken];
|
|
51
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
52
|
+
if (textTransform) style.textTransform = textTransform;
|
|
53
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
54
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
55
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
56
|
+
if (fontSize) style.fontSize = fontSize;
|
|
57
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
58
|
+
if (color) style.color = color;
|
|
59
|
+
if (process.env.NODE_ENV === "development") {
|
|
60
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
61
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
62
|
+
if (import_constants.isClient) {
|
|
63
|
+
console.info({
|
|
64
|
+
style,
|
|
65
|
+
props,
|
|
66
|
+
font
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
console.groupEnd();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return style;
|
|
79
73
|
};
|
|
80
74
|
const SizableText = (0, import_web.styled)(import_web.Text, {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"...fontSize": getFontSized
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
defaultVariants: {
|
|
89
|
-
size: "$true"
|
|
90
|
-
}
|
|
75
|
+
displayName: "SizableText",
|
|
76
|
+
fontFamily: "body",
|
|
77
|
+
variants: { size: { FontSize: getFontSized } },
|
|
78
|
+
defaultVariants: { size: true }
|
|
91
79
|
});
|
|
92
|
-
const cache = /* @__PURE__ */new WeakMap();
|
|
93
|
-
function getDefaultSizeToken(font) {
|
|
94
|
-
if (typeof font === "object" && cache.has(font)) {
|
|
95
|
-
return cache.get(font);
|
|
96
|
-
}
|
|
97
|
-
const tokens = (0, import_web.getTokens)();
|
|
98
|
-
const sizeTokens = "$true" in font.size ? font.size : tokens?.size;
|
|
99
|
-
if (!sizeTokens) {
|
|
100
|
-
return Object.keys(font.size)[3];
|
|
101
|
-
}
|
|
102
|
-
const sizeDefault = sizeTokens["$true"];
|
|
103
|
-
const sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(x => x !== "$true" && sizeTokens[x]["val"] === sizeDefault["val"]) : null;
|
|
104
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
105
|
-
if (process.env.NODE_ENV === "development") {
|
|
106
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
107
|
-
|
|
108
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
109
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`);
|
|
110
|
-
}
|
|
111
|
-
return Object.keys(font.size)[3];
|
|
112
|
-
}
|
|
113
|
-
cache.set(font, sizeDefaultSpecific);
|
|
114
|
-
return sizeDefaultSpecific;
|
|
115
|
-
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__export(index_exports, {
|
|
26
|
+
SizableText: () => SizableText,
|
|
27
|
+
getFontSized: () => getFontSized
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
var import_constants = require("@tamagui/constants");
|
|
31
|
+
var import_size = require("@tamagui/size");
|
|
32
|
+
var import_web = require("@tamagui/web");
|
|
33
|
+
var getFontSized = function() {
|
|
34
|
+
var sizeTokenIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, { font, fontFamily, props } = arguments.length > 1 ? arguments[1] : void 0;
|
|
35
|
+
var _font_lineHeight, _font_weight, _font_letterSpacing, _font_transform, _font_style, _font_color;
|
|
36
|
+
if (!font) {
|
|
37
|
+
return { fontSize: sizeTokenIn };
|
|
38
|
+
}
|
|
39
|
+
var sizeToken = (0, import_size.resolveSizeToken)(sizeTokenIn, "fontSize");
|
|
40
|
+
var style = {};
|
|
41
|
+
if (typeof sizeToken === "number") {
|
|
42
|
+
style.fontSize = sizeToken;
|
|
43
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
44
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
45
|
+
if (props.color) style.color = props.color;
|
|
46
|
+
return style;
|
|
47
|
+
}
|
|
48
|
+
var fontSize = font.size[sizeToken];
|
|
49
|
+
var lineHeight = (_font_lineHeight = font.lineHeight) === null || _font_lineHeight === void 0 ? void 0 : _font_lineHeight[sizeToken];
|
|
50
|
+
var fontWeight = (_font_weight = font.weight) === null || _font_weight === void 0 ? void 0 : _font_weight[sizeToken];
|
|
51
|
+
var letterSpacing = (_font_letterSpacing = font.letterSpacing) === null || _font_letterSpacing === void 0 ? void 0 : _font_letterSpacing[sizeToken];
|
|
52
|
+
var textTransform = (_font_transform = font.transform) === null || _font_transform === void 0 ? void 0 : _font_transform[sizeToken];
|
|
53
|
+
var _props_fontStyle;
|
|
54
|
+
var fontStyle = (_props_fontStyle = props.fontStyle) !== null && _props_fontStyle !== void 0 ? _props_fontStyle : (_font_style = font.style) === null || _font_style === void 0 ? void 0 : _font_style[sizeToken];
|
|
55
|
+
var _props_color;
|
|
56
|
+
var color = (_props_color = props.color) !== null && _props_color !== void 0 ? _props_color : (_font_color = font.color) === null || _font_color === void 0 ? void 0 : _font_color[sizeToken];
|
|
57
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
58
|
+
if (textTransform) style.textTransform = textTransform;
|
|
59
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
60
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
61
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
62
|
+
if (fontSize) style.fontSize = fontSize;
|
|
63
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
64
|
+
if (color) style.color = color;
|
|
65
|
+
if (process.env.NODE_ENV === "development") {
|
|
66
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
67
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
68
|
+
if (import_constants.isClient) {
|
|
69
|
+
console.info({
|
|
70
|
+
style,
|
|
71
|
+
props,
|
|
72
|
+
font
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
console.groupEnd();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return style;
|
|
79
|
+
};
|
|
80
|
+
var SizableText = (0, import_web.styled)(import_web.Text, {
|
|
81
|
+
displayName: "SizableText",
|
|
82
|
+
fontFamily: "body",
|
|
83
|
+
variants: { size: { FontSize: getFontSized } },
|
|
84
|
+
defaultVariants: { size: true }
|
|
85
|
+
});
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,130 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var index_exports = {};
|
|
26
25
|
__export(index_exports, {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
SizableText: () => SizableText,
|
|
27
|
+
getFontSized: () => getFontSized
|
|
29
28
|
});
|
|
30
29
|
module.exports = __toCommonJS(index_exports);
|
|
31
30
|
var import_constants = require("@tamagui/constants");
|
|
31
|
+
var import_size = require("@tamagui/size");
|
|
32
32
|
var import_web = require("@tamagui/web");
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.groupCollapsed(" \u{1F539} getFontSized", sizeTokenIn, sizeToken);
|
|
80
|
-
if (import_constants.isClient) {
|
|
81
|
-
console.info({
|
|
82
|
-
style,
|
|
83
|
-
props,
|
|
84
|
-
font
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
console.groupEnd();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return style;
|
|
33
|
+
var getFontSized = function() {
|
|
34
|
+
var sizeTokenIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, { font, fontFamily, props } = arguments.length > 1 ? arguments[1] : void 0;
|
|
35
|
+
var _font_lineHeight, _font_weight, _font_letterSpacing, _font_transform, _font_style, _font_color;
|
|
36
|
+
if (!font) {
|
|
37
|
+
return { fontSize: sizeTokenIn };
|
|
38
|
+
}
|
|
39
|
+
var sizeToken = (0, import_size.resolveSizeToken)(sizeTokenIn, "fontSize");
|
|
40
|
+
var style = {};
|
|
41
|
+
if (typeof sizeToken === "number") {
|
|
42
|
+
style.fontSize = sizeToken;
|
|
43
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
44
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
45
|
+
if (props.color) style.color = props.color;
|
|
46
|
+
return style;
|
|
47
|
+
}
|
|
48
|
+
var fontSize = font.size[sizeToken];
|
|
49
|
+
var lineHeight = (_font_lineHeight = font.lineHeight) === null || _font_lineHeight === void 0 ? void 0 : _font_lineHeight[sizeToken];
|
|
50
|
+
var fontWeight = (_font_weight = font.weight) === null || _font_weight === void 0 ? void 0 : _font_weight[sizeToken];
|
|
51
|
+
var letterSpacing = (_font_letterSpacing = font.letterSpacing) === null || _font_letterSpacing === void 0 ? void 0 : _font_letterSpacing[sizeToken];
|
|
52
|
+
var textTransform = (_font_transform = font.transform) === null || _font_transform === void 0 ? void 0 : _font_transform[sizeToken];
|
|
53
|
+
var _props_fontStyle;
|
|
54
|
+
var fontStyle = (_props_fontStyle = props.fontStyle) !== null && _props_fontStyle !== void 0 ? _props_fontStyle : (_font_style = font.style) === null || _font_style === void 0 ? void 0 : _font_style[sizeToken];
|
|
55
|
+
var _props_color;
|
|
56
|
+
var color = (_props_color = props.color) !== null && _props_color !== void 0 ? _props_color : (_font_color = font.color) === null || _font_color === void 0 ? void 0 : _font_color[sizeToken];
|
|
57
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
58
|
+
if (textTransform) style.textTransform = textTransform;
|
|
59
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
60
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
61
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
62
|
+
if (fontSize) style.fontSize = fontSize;
|
|
63
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
64
|
+
if (color) style.color = color;
|
|
65
|
+
if (process.env.NODE_ENV === "development") {
|
|
66
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
67
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
68
|
+
if (import_constants.isClient) {
|
|
69
|
+
console.info({
|
|
70
|
+
style,
|
|
71
|
+
props,
|
|
72
|
+
font
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
console.groupEnd();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return style;
|
|
91
79
|
};
|
|
92
80
|
var SizableText = (0, import_web.styled)(import_web.Text, {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"...fontSize": getFontSized
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
defaultVariants: {
|
|
101
|
-
size: "$true"
|
|
102
|
-
}
|
|
81
|
+
displayName: "SizableText",
|
|
82
|
+
fontFamily: "body",
|
|
83
|
+
variants: { size: { FontSize: getFontSized } },
|
|
84
|
+
defaultVariants: { size: true }
|
|
103
85
|
});
|
|
104
|
-
var cache = /* @__PURE__ */new WeakMap();
|
|
105
|
-
function getDefaultSizeToken(font) {
|
|
106
|
-
if ((typeof font === "undefined" ? "undefined" : _type_of(font)) === "object" && cache.has(font)) {
|
|
107
|
-
return cache.get(font);
|
|
108
|
-
}
|
|
109
|
-
var tokens = (0, import_web.getTokens)();
|
|
110
|
-
var sizeTokens = "$true" in font.size ? font.size : tokens === null || tokens === void 0 ? void 0 : tokens.size;
|
|
111
|
-
if (!sizeTokens) {
|
|
112
|
-
return Object.keys(font.size)[3];
|
|
113
|
-
}
|
|
114
|
-
var sizeDefault = sizeTokens["$true"];
|
|
115
|
-
var sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(function (x) {
|
|
116
|
-
return x !== "$true" && sizeTokens[x]["val"] === sizeDefault["val"];
|
|
117
|
-
}) : null;
|
|
118
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
119
|
-
if (process.env.NODE_ENV === "development") {
|
|
120
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
121
86
|
|
|
122
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
123
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`);
|
|
124
|
-
}
|
|
125
|
-
return Object.keys(font.size)[3];
|
|
126
|
-
}
|
|
127
|
-
cache.set(font, sizeDefaultSpecific);
|
|
128
|
-
return sizeDefaultSpecific;
|
|
129
|
-
}
|
|
130
87
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n SizableText: () => SizableText,\n getFontSized: () => getFontSized\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_constants = require(\"@tamagui/constants\");\nvar import_size = require(\"@tamagui/size\");\nvar import_web = require(\"@tamagui/web\");\nvar getFontSized = function() {\n var sizeTokenIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, { font, fontFamily, props } = arguments.length > 1 ? arguments[1] : void 0;\n var _font_lineHeight, _font_weight, _font_letterSpacing, _font_transform, _font_style, _font_color;\n if (!font) {\n return {\n fontSize: sizeTokenIn\n };\n }\n var sizeToken = (0, import_size.resolveSizeToken)(sizeTokenIn, \"fontSize\");\n var style = {};\n if (typeof sizeToken === \"number\") {\n style.fontSize = sizeToken;\n if (fontFamily) style.fontFamily = fontFamily;\n if (props.fontStyle) style.fontStyle = props.fontStyle;\n if (props.color) style.color = props.color;\n return style;\n }\n var fontSize = font.size[sizeToken];\n var lineHeight = (_font_lineHeight = font.lineHeight) === null || _font_lineHeight === void 0 ? void 0 : _font_lineHeight[sizeToken];\n var fontWeight = (_font_weight = font.weight) === null || _font_weight === void 0 ? void 0 : _font_weight[sizeToken];\n var letterSpacing = (_font_letterSpacing = font.letterSpacing) === null || _font_letterSpacing === void 0 ? void 0 : _font_letterSpacing[sizeToken];\n var textTransform = (_font_transform = font.transform) === null || _font_transform === void 0 ? void 0 : _font_transform[sizeToken];\n var _props_fontStyle;\n var fontStyle = (_props_fontStyle = props.fontStyle) !== null && _props_fontStyle !== void 0 ? _props_fontStyle : (_font_style = font.style) === null || _font_style === void 0 ? void 0 : _font_style[sizeToken];\n var _props_color;\n var color = (_props_color = props.color) !== null && _props_color !== void 0 ? _props_color : (_font_color = font.color) === null || _font_color === void 0 ? void 0 : _font_color[sizeToken];\n if (fontStyle) style.fontStyle = fontStyle;\n if (textTransform) style.textTransform = textTransform;\n if (fontFamily) style.fontFamily = fontFamily;\n if (fontWeight) style.fontWeight = fontWeight;\n if (letterSpacing) style.letterSpacing = letterSpacing;\n if (fontSize) style.fontSize = fontSize;\n if (lineHeight) style.lineHeight = lineHeight;\n if (color) style.color = color;\n if (process.env.NODE_ENV === \"development\") {\n if (props[\"debug\"] && props[\"debug\"] === \"verbose\") {\n console.groupCollapsed(\" \\u{1F539} getFontSized\", sizeTokenIn, sizeToken);\n if (import_constants.isClient) {\n console.info({\n style,\n props,\n font\n });\n }\n console.groupEnd();\n }\n }\n return style;\n};\nvar SizableText = (0, import_web.styled)(import_web.Text, {\n displayName: \"SizableText\",\n fontFamily: \"body\",\n variants: {\n size: {\n FontSize: getFontSized\n }\n },\n defaultVariants: {\n size: true\n }\n});\n//# sourceMappingURL=index.js.map\n"],"mappings":"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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,89 +1,56 @@
|
|
|
1
1
|
import { isClient } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.groupEnd();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return style;
|
|
2
|
+
import { resolveSizeToken } from "@tamagui/size";
|
|
3
|
+
import { Text, styled } from "@tamagui/web";
|
|
4
|
+
|
|
5
|
+
const getFontSized = (sizeTokenIn = true, { font, fontFamily, props }) => {
|
|
6
|
+
if (!font) {
|
|
7
|
+
return { fontSize: sizeTokenIn };
|
|
8
|
+
}
|
|
9
|
+
const sizeToken = resolveSizeToken(sizeTokenIn, "fontSize");
|
|
10
|
+
const style = {};
|
|
11
|
+
if (typeof sizeToken === "number") {
|
|
12
|
+
style.fontSize = sizeToken;
|
|
13
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
14
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
15
|
+
if (props.color) style.color = props.color;
|
|
16
|
+
return style;
|
|
17
|
+
}
|
|
18
|
+
const fontSize = font.size[sizeToken];
|
|
19
|
+
const lineHeight = font.lineHeight?.[sizeToken];
|
|
20
|
+
const fontWeight = font.weight?.[sizeToken];
|
|
21
|
+
const letterSpacing = font.letterSpacing?.[sizeToken];
|
|
22
|
+
const textTransform = font.transform?.[sizeToken];
|
|
23
|
+
const fontStyle = props.fontStyle ?? font.style?.[sizeToken];
|
|
24
|
+
const color = props.color ?? font.color?.[sizeToken];
|
|
25
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
26
|
+
if (textTransform) style.textTransform = textTransform;
|
|
27
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
28
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
29
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
30
|
+
if (fontSize) style.fontSize = fontSize;
|
|
31
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
32
|
+
if (color) style.color = color;
|
|
33
|
+
if (process.env.NODE_ENV === "development") {
|
|
34
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
35
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
36
|
+
if (isClient) {
|
|
37
|
+
console.info({
|
|
38
|
+
style,
|
|
39
|
+
props,
|
|
40
|
+
font
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
console.groupEnd();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return style;
|
|
51
47
|
};
|
|
52
48
|
const SizableText = styled(Text, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"...fontSize": getFontSized
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
defaultVariants: {
|
|
61
|
-
size: "$true"
|
|
62
|
-
}
|
|
49
|
+
displayName: "SizableText",
|
|
50
|
+
fontFamily: "body",
|
|
51
|
+
variants: { size: { FontSize: getFontSized } },
|
|
52
|
+
defaultVariants: { size: true }
|
|
63
53
|
});
|
|
64
|
-
const cache = /* @__PURE__ */new WeakMap();
|
|
65
|
-
function getDefaultSizeToken(font) {
|
|
66
|
-
if (typeof font === "object" && cache.has(font)) {
|
|
67
|
-
return cache.get(font);
|
|
68
|
-
}
|
|
69
|
-
const tokens = getTokens();
|
|
70
|
-
const sizeTokens = "$true" in font.size ? font.size : tokens?.size;
|
|
71
|
-
if (!sizeTokens) {
|
|
72
|
-
return Object.keys(font.size)[3];
|
|
73
|
-
}
|
|
74
|
-
const sizeDefault = sizeTokens["$true"];
|
|
75
|
-
const sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(x => x !== "$true" && sizeTokens[x]["val"] === sizeDefault["val"]) : null;
|
|
76
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
77
|
-
if (process.env.NODE_ENV === "development") {
|
|
78
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
79
54
|
|
|
80
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
81
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`);
|
|
82
|
-
}
|
|
83
|
-
return Object.keys(font.size)[3];
|
|
84
|
-
}
|
|
85
|
-
cache.set(font, sizeDefaultSpecific);
|
|
86
|
-
return sizeDefaultSpecific;
|
|
87
|
-
}
|
|
88
55
|
export { SizableText, getFontSized };
|
|
89
56
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isClient } from \"@tamagui/constants\";\nimport { resolveSizeToken } from \"@tamagui/size\";\nimport { styled, Text } from \"@tamagui/web\";\nconst getFontSized = (sizeTokenIn = true, { font, fontFamily, props }) => {\n if (!font) {\n return {\n fontSize: sizeTokenIn\n };\n }\n const sizeToken = resolveSizeToken(sizeTokenIn, \"fontSize\");\n const style = {};\n if (typeof sizeToken === \"number\") {\n style.fontSize = sizeToken;\n if (fontFamily) style.fontFamily = fontFamily;\n if (props.fontStyle) style.fontStyle = props.fontStyle;\n if (props.color) style.color = props.color;\n return style;\n }\n const fontSize = font.size[sizeToken];\n const lineHeight = font.lineHeight?.[sizeToken];\n const fontWeight = font.weight?.[sizeToken];\n const letterSpacing = font.letterSpacing?.[sizeToken];\n const textTransform = font.transform?.[sizeToken];\n const fontStyle = props.fontStyle ?? font.style?.[sizeToken];\n const color = props.color ?? font.color?.[sizeToken];\n if (fontStyle) style.fontStyle = fontStyle;\n if (textTransform) style.textTransform = textTransform;\n if (fontFamily) style.fontFamily = fontFamily;\n if (fontWeight) style.fontWeight = fontWeight;\n if (letterSpacing) style.letterSpacing = letterSpacing;\n if (fontSize) style.fontSize = fontSize;\n if (lineHeight) style.lineHeight = lineHeight;\n if (color) style.color = color;\n if (process.env.NODE_ENV === \"development\") {\n if (props[\"debug\"] && props[\"debug\"] === \"verbose\") {\n console.groupCollapsed(\" \\u{1F539} getFontSized\", sizeTokenIn, sizeToken);\n if (isClient) {\n console.info({ style, props, font });\n }\n console.groupEnd();\n }\n }\n return style;\n};\nconst SizableText = styled(Text, {\n displayName: \"SizableText\",\n fontFamily: \"body\",\n variants: {\n size: {\n FontSize: getFontSized\n }\n },\n defaultVariants: {\n size: true\n }\n});\nexport {\n SizableText,\n getFontSized\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,MAAM,gBAAgB,cAAc,MAAM,EAAE,MAAM,YAAY,YAAY;CACxE,IAAI,CAAC,MAAM;EACT,OAAO,EACL,UAAU,YACZ;CACF;CACA,MAAM,YAAY,iBAAiB,aAAa,UAAU;CAC1D,MAAM,QAAQ,CAAC;CACf,IAAI,OAAO,cAAc,UAAU;EACjC,MAAM,WAAW;EACjB,IAAI,YAAY,MAAM,aAAa;EACnC,IAAI,MAAM,WAAW,MAAM,YAAY,MAAM;EAC7C,IAAI,MAAM,OAAO,MAAM,QAAQ,MAAM;EACrC,OAAO;CACT;CACA,MAAM,WAAW,KAAK,KAAK;CAC3B,MAAM,aAAa,KAAK,aAAa;CACrC,MAAM,aAAa,KAAK,SAAS;CACjC,MAAM,gBAAgB,KAAK,gBAAgB;CAC3C,MAAM,gBAAgB,KAAK,YAAY;CACvC,MAAM,YAAY,MAAM,aAAa,KAAK,QAAQ;CAClD,MAAM,QAAQ,MAAM,SAAS,KAAK,QAAQ;CAC1C,IAAI,WAAW,MAAM,YAAY;CACjC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,UAAU,MAAM,WAAW;CAC/B,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,OAAO,MAAM,QAAQ;CACzB,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,MAAM,YAAY,MAAM,aAAa,WAAW;GAClD,QAAQ,eAAe,qBAA4B,aAAa,SAAS;GACzE,IAAI,UAAU;IACZ,QAAQ,KAAK;KAAE;KAAO;KAAO;IAAK,CAAC;GACrC;GACA,QAAQ,SAAS;EACnB;CACF;CACA,OAAO;AACT;AACA,MAAM,cAAc,OAAO,MAAM;CAC/B,aAAa;CACb,YAAY;CACZ,UAAU,EACR,MAAM,EACJ,UAAU,aACZ,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,89 +1,56 @@
|
|
|
1
1
|
import { isClient } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.groupEnd();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return style;
|
|
2
|
+
import { resolveSizeToken } from "@tamagui/size";
|
|
3
|
+
import { Text, styled } from "@tamagui/web";
|
|
4
|
+
|
|
5
|
+
const getFontSized = (sizeTokenIn = true, { font, fontFamily, props }) => {
|
|
6
|
+
if (!font) {
|
|
7
|
+
return { fontSize: sizeTokenIn };
|
|
8
|
+
}
|
|
9
|
+
const sizeToken = resolveSizeToken(sizeTokenIn, "fontSize");
|
|
10
|
+
const style = {};
|
|
11
|
+
if (typeof sizeToken === "number") {
|
|
12
|
+
style.fontSize = sizeToken;
|
|
13
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
14
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
15
|
+
if (props.color) style.color = props.color;
|
|
16
|
+
return style;
|
|
17
|
+
}
|
|
18
|
+
const fontSize = font.size[sizeToken];
|
|
19
|
+
const lineHeight = font.lineHeight?.[sizeToken];
|
|
20
|
+
const fontWeight = font.weight?.[sizeToken];
|
|
21
|
+
const letterSpacing = font.letterSpacing?.[sizeToken];
|
|
22
|
+
const textTransform = font.transform?.[sizeToken];
|
|
23
|
+
const fontStyle = props.fontStyle ?? font.style?.[sizeToken];
|
|
24
|
+
const color = props.color ?? font.color?.[sizeToken];
|
|
25
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
26
|
+
if (textTransform) style.textTransform = textTransform;
|
|
27
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
28
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
29
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
30
|
+
if (fontSize) style.fontSize = fontSize;
|
|
31
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
32
|
+
if (color) style.color = color;
|
|
33
|
+
if (process.env.NODE_ENV === "development") {
|
|
34
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
35
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
36
|
+
if (isClient) {
|
|
37
|
+
console.info({
|
|
38
|
+
style,
|
|
39
|
+
props,
|
|
40
|
+
font
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
console.groupEnd();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return style;
|
|
51
47
|
};
|
|
52
48
|
const SizableText = styled(Text, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"...fontSize": getFontSized
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
defaultVariants: {
|
|
61
|
-
size: "$true"
|
|
62
|
-
}
|
|
49
|
+
displayName: "SizableText",
|
|
50
|
+
fontFamily: "body",
|
|
51
|
+
variants: { size: { FontSize: getFontSized } },
|
|
52
|
+
defaultVariants: { size: true }
|
|
63
53
|
});
|
|
64
|
-
const cache = /* @__PURE__ */new WeakMap();
|
|
65
|
-
function getDefaultSizeToken(font) {
|
|
66
|
-
if (typeof font === "object" && cache.has(font)) {
|
|
67
|
-
return cache.get(font);
|
|
68
|
-
}
|
|
69
|
-
const tokens = getTokens();
|
|
70
|
-
const sizeTokens = "$true" in font.size ? font.size : tokens?.size;
|
|
71
|
-
if (!sizeTokens) {
|
|
72
|
-
return Object.keys(font.size)[3];
|
|
73
|
-
}
|
|
74
|
-
const sizeDefault = sizeTokens["$true"];
|
|
75
|
-
const sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(x => x !== "$true" && sizeTokens[x]["val"] === sizeDefault["val"]) : null;
|
|
76
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
77
|
-
if (process.env.NODE_ENV === "development") {
|
|
78
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
79
54
|
|
|
80
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
81
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`);
|
|
82
|
-
}
|
|
83
|
-
return Object.keys(font.size)[3];
|
|
84
|
-
}
|
|
85
|
-
cache.set(font, sizeDefaultSpecific);
|
|
86
|
-
return sizeDefaultSpecific;
|
|
87
|
-
}
|
|
88
55
|
export { SizableText, getFontSized };
|
|
89
56
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { isClient } from \"@tamagui/constants\";\nimport { resolveSizeToken } from \"@tamagui/size\";\nimport { styled, Text } from \"@tamagui/web\";\nconst getFontSized = (sizeTokenIn = true, { font, fontFamily, props }) => {\n if (!font) {\n return {\n fontSize: sizeTokenIn\n };\n }\n const sizeToken = resolveSizeToken(sizeTokenIn, \"fontSize\");\n const style = {};\n if (typeof sizeToken === \"number\") {\n style.fontSize = sizeToken;\n if (fontFamily) style.fontFamily = fontFamily;\n if (props.fontStyle) style.fontStyle = props.fontStyle;\n if (props.color) style.color = props.color;\n return style;\n }\n const fontSize = font.size[sizeToken];\n const lineHeight = font.lineHeight?.[sizeToken];\n const fontWeight = font.weight?.[sizeToken];\n const letterSpacing = font.letterSpacing?.[sizeToken];\n const textTransform = font.transform?.[sizeToken];\n const fontStyle = props.fontStyle ?? font.style?.[sizeToken];\n const color = props.color ?? font.color?.[sizeToken];\n if (fontStyle) style.fontStyle = fontStyle;\n if (textTransform) style.textTransform = textTransform;\n if (fontFamily) style.fontFamily = fontFamily;\n if (fontWeight) style.fontWeight = fontWeight;\n if (letterSpacing) style.letterSpacing = letterSpacing;\n if (fontSize) style.fontSize = fontSize;\n if (lineHeight) style.lineHeight = lineHeight;\n if (color) style.color = color;\n if (process.env.NODE_ENV === \"development\") {\n if (props[\"debug\"] && props[\"debug\"] === \"verbose\") {\n console.groupCollapsed(\" \\u{1F539} getFontSized\", sizeTokenIn, sizeToken);\n if (isClient) {\n console.info({ style, props, font });\n }\n console.groupEnd();\n }\n }\n return style;\n};\nconst SizableText = styled(Text, {\n displayName: \"SizableText\",\n fontFamily: \"body\",\n variants: {\n size: {\n FontSize: getFontSized\n }\n },\n defaultVariants: {\n size: true\n }\n});\nexport {\n SizableText,\n getFontSized\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,MAAM,gBAAgB,cAAc,MAAM,EAAE,MAAM,YAAY,YAAY;CACxE,IAAI,CAAC,MAAM;EACT,OAAO,EACL,UAAU,YACZ;CACF;CACA,MAAM,YAAY,iBAAiB,aAAa,UAAU;CAC1D,MAAM,QAAQ,CAAC;CACf,IAAI,OAAO,cAAc,UAAU;EACjC,MAAM,WAAW;EACjB,IAAI,YAAY,MAAM,aAAa;EACnC,IAAI,MAAM,WAAW,MAAM,YAAY,MAAM;EAC7C,IAAI,MAAM,OAAO,MAAM,QAAQ,MAAM;EACrC,OAAO;CACT;CACA,MAAM,WAAW,KAAK,KAAK;CAC3B,MAAM,aAAa,KAAK,aAAa;CACrC,MAAM,aAAa,KAAK,SAAS;CACjC,MAAM,gBAAgB,KAAK,gBAAgB;CAC3C,MAAM,gBAAgB,KAAK,YAAY;CACvC,MAAM,YAAY,MAAM,aAAa,KAAK,QAAQ;CAClD,MAAM,QAAQ,MAAM,SAAS,KAAK,QAAQ;CAC1C,IAAI,WAAW,MAAM,YAAY;CACjC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,UAAU,MAAM,WAAW;CAC/B,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,OAAO,MAAM,QAAQ;CACzB,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,MAAM,YAAY,MAAM,aAAa,WAAW;GAClD,QAAQ,eAAe,qBAA4B,aAAa,SAAS;GACzE,IAAI,UAAU;IACZ,QAAQ,KAAK;KAAE;KAAO;KAAO;IAAK,CAAC;GACrC;GACA,QAAQ,SAAS;EACnB;CACF;CACA,OAAO;AACT;AACA,MAAM,cAAc,OAAO,MAAM;CAC/B,aAAa;CACb,YAAY;CACZ,UAAU,EACR,MAAM,EACJ,UAAU,aACZ,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC"}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,101 +1,60 @@
|
|
|
1
1
|
import { isClient } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
"@swc/helpers - typeof";
|
|
2
|
+
import { resolveSizeToken } from "@tamagui/size";
|
|
3
|
+
import { Text, styled } from "@tamagui/web";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
style,
|
|
53
|
-
props,
|
|
54
|
-
font
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
console.groupEnd();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return style;
|
|
5
|
+
var getFontSized = function() {
|
|
6
|
+
var sizeTokenIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, { font, fontFamily, props } = arguments.length > 1 ? arguments[1] : void 0;
|
|
7
|
+
var _font_lineHeight, _font_weight, _font_letterSpacing, _font_transform, _font_style, _font_color;
|
|
8
|
+
if (!font) {
|
|
9
|
+
return { fontSize: sizeTokenIn };
|
|
10
|
+
}
|
|
11
|
+
var sizeToken = resolveSizeToken(sizeTokenIn, "fontSize");
|
|
12
|
+
var style = {};
|
|
13
|
+
if (typeof sizeToken === "number") {
|
|
14
|
+
style.fontSize = sizeToken;
|
|
15
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
16
|
+
if (props.fontStyle) style.fontStyle = props.fontStyle;
|
|
17
|
+
if (props.color) style.color = props.color;
|
|
18
|
+
return style;
|
|
19
|
+
}
|
|
20
|
+
var fontSize = font.size[sizeToken];
|
|
21
|
+
var lineHeight = (_font_lineHeight = font.lineHeight) === null || _font_lineHeight === void 0 ? void 0 : _font_lineHeight[sizeToken];
|
|
22
|
+
var fontWeight = (_font_weight = font.weight) === null || _font_weight === void 0 ? void 0 : _font_weight[sizeToken];
|
|
23
|
+
var letterSpacing = (_font_letterSpacing = font.letterSpacing) === null || _font_letterSpacing === void 0 ? void 0 : _font_letterSpacing[sizeToken];
|
|
24
|
+
var textTransform = (_font_transform = font.transform) === null || _font_transform === void 0 ? void 0 : _font_transform[sizeToken];
|
|
25
|
+
var _props_fontStyle;
|
|
26
|
+
var fontStyle = (_props_fontStyle = props.fontStyle) !== null && _props_fontStyle !== void 0 ? _props_fontStyle : (_font_style = font.style) === null || _font_style === void 0 ? void 0 : _font_style[sizeToken];
|
|
27
|
+
var _props_color;
|
|
28
|
+
var color = (_props_color = props.color) !== null && _props_color !== void 0 ? _props_color : (_font_color = font.color) === null || _font_color === void 0 ? void 0 : _font_color[sizeToken];
|
|
29
|
+
if (fontStyle) style.fontStyle = fontStyle;
|
|
30
|
+
if (textTransform) style.textTransform = textTransform;
|
|
31
|
+
if (fontFamily) style.fontFamily = fontFamily;
|
|
32
|
+
if (fontWeight) style.fontWeight = fontWeight;
|
|
33
|
+
if (letterSpacing) style.letterSpacing = letterSpacing;
|
|
34
|
+
if (fontSize) style.fontSize = fontSize;
|
|
35
|
+
if (lineHeight) style.lineHeight = lineHeight;
|
|
36
|
+
if (color) style.color = color;
|
|
37
|
+
if (process.env.NODE_ENV === "development") {
|
|
38
|
+
if (props["debug"] && props["debug"] === "verbose") {
|
|
39
|
+
console.groupCollapsed(" 🔹 getFontSized", sizeTokenIn, sizeToken);
|
|
40
|
+
if (isClient) {
|
|
41
|
+
console.info({
|
|
42
|
+
style,
|
|
43
|
+
props,
|
|
44
|
+
font
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
console.groupEnd();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return style;
|
|
61
51
|
};
|
|
62
52
|
var SizableText = styled(Text, {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"...fontSize": getFontSized
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
defaultVariants: {
|
|
71
|
-
size: "$true"
|
|
72
|
-
}
|
|
53
|
+
displayName: "SizableText",
|
|
54
|
+
fontFamily: "body",
|
|
55
|
+
variants: { size: { FontSize: getFontSized } },
|
|
56
|
+
defaultVariants: { size: true }
|
|
73
57
|
});
|
|
74
|
-
var cache = /* @__PURE__ */new WeakMap();
|
|
75
|
-
function getDefaultSizeToken(font) {
|
|
76
|
-
if ((typeof font === "undefined" ? "undefined" : _type_of(font)) === "object" && cache.has(font)) {
|
|
77
|
-
return cache.get(font);
|
|
78
|
-
}
|
|
79
|
-
var tokens = getTokens();
|
|
80
|
-
var sizeTokens = "$true" in font.size ? font.size : tokens === null || tokens === void 0 ? void 0 : tokens.size;
|
|
81
|
-
if (!sizeTokens) {
|
|
82
|
-
return Object.keys(font.size)[3];
|
|
83
|
-
}
|
|
84
|
-
var sizeDefault = sizeTokens["$true"];
|
|
85
|
-
var sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(function (x) {
|
|
86
|
-
return x !== "$true" && sizeTokens[x]["val"] === sizeDefault["val"];
|
|
87
|
-
}) : null;
|
|
88
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
89
|
-
if (process.env.NODE_ENV === "development") {
|
|
90
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
91
58
|
|
|
92
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
93
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`);
|
|
94
|
-
}
|
|
95
|
-
return Object.keys(font.size)[3];
|
|
96
|
-
}
|
|
97
|
-
cache.set(font, sizeDefaultSpecific);
|
|
98
|
-
return sizeDefaultSpecific;
|
|
99
|
-
}
|
|
100
59
|
export { SizableText, getFontSized };
|
|
101
60
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { isClient } from \"@tamagui/constants\";\nimport { resolveSizeToken } from \"@tamagui/size\";\nimport { styled, Text } from \"@tamagui/web\";\nvar getFontSized = function() {\n var sizeTokenIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, { font, fontFamily, props } = arguments.length > 1 ? arguments[1] : void 0;\n var _font_lineHeight, _font_weight, _font_letterSpacing, _font_transform, _font_style, _font_color;\n if (!font) {\n return {\n fontSize: sizeTokenIn\n };\n }\n var sizeToken = resolveSizeToken(sizeTokenIn, \"fontSize\");\n var style = {};\n if (typeof sizeToken === \"number\") {\n style.fontSize = sizeToken;\n if (fontFamily) style.fontFamily = fontFamily;\n if (props.fontStyle) style.fontStyle = props.fontStyle;\n if (props.color) style.color = props.color;\n return style;\n }\n var fontSize = font.size[sizeToken];\n var lineHeight = (_font_lineHeight = font.lineHeight) === null || _font_lineHeight === void 0 ? void 0 : _font_lineHeight[sizeToken];\n var fontWeight = (_font_weight = font.weight) === null || _font_weight === void 0 ? void 0 : _font_weight[sizeToken];\n var letterSpacing = (_font_letterSpacing = font.letterSpacing) === null || _font_letterSpacing === void 0 ? void 0 : _font_letterSpacing[sizeToken];\n var textTransform = (_font_transform = font.transform) === null || _font_transform === void 0 ? void 0 : _font_transform[sizeToken];\n var _props_fontStyle;\n var fontStyle = (_props_fontStyle = props.fontStyle) !== null && _props_fontStyle !== void 0 ? _props_fontStyle : (_font_style = font.style) === null || _font_style === void 0 ? void 0 : _font_style[sizeToken];\n var _props_color;\n var color = (_props_color = props.color) !== null && _props_color !== void 0 ? _props_color : (_font_color = font.color) === null || _font_color === void 0 ? void 0 : _font_color[sizeToken];\n if (fontStyle) style.fontStyle = fontStyle;\n if (textTransform) style.textTransform = textTransform;\n if (fontFamily) style.fontFamily = fontFamily;\n if (fontWeight) style.fontWeight = fontWeight;\n if (letterSpacing) style.letterSpacing = letterSpacing;\n if (fontSize) style.fontSize = fontSize;\n if (lineHeight) style.lineHeight = lineHeight;\n if (color) style.color = color;\n if (process.env.NODE_ENV === \"development\") {\n if (props[\"debug\"] && props[\"debug\"] === \"verbose\") {\n console.groupCollapsed(\" \\u{1F539} getFontSized\", sizeTokenIn, sizeToken);\n if (isClient) {\n console.info({\n style,\n props,\n font\n });\n }\n console.groupEnd();\n }\n }\n return style;\n};\nvar SizableText = styled(Text, {\n displayName: \"SizableText\",\n fontFamily: \"body\",\n variants: {\n size: {\n FontSize: getFontSized\n }\n },\n defaultVariants: {\n size: true\n }\n});\nexport {\n SizableText,\n getFontSized\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;AAGA,IAAI,eAAe,WAAW;CAC5B,IAAI,cAAc,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,MAAM,EAAE,MAAM,YAAY,UAAU,UAAU,SAAS,IAAI,UAAU,KAAK,KAAK;CAClK,IAAI,kBAAkB,cAAc,qBAAqB,iBAAiB,aAAa;CACvF,IAAI,CAAC,MAAM;EACT,OAAO,EACL,UAAU,YACZ;CACF;CACA,IAAI,YAAY,iBAAiB,aAAa,UAAU;CACxD,IAAI,QAAQ,CAAC;CACb,IAAI,OAAO,cAAc,UAAU;EACjC,MAAM,WAAW;EACjB,IAAI,YAAY,MAAM,aAAa;EACnC,IAAI,MAAM,WAAW,MAAM,YAAY,MAAM;EAC7C,IAAI,MAAM,OAAO,MAAM,QAAQ,MAAM;EACrC,OAAO;CACT;CACA,IAAI,WAAW,KAAK,KAAK;CACzB,IAAI,cAAc,mBAAmB,KAAK,gBAAgB,QAAQ,qBAAqB,KAAK,IAAI,KAAK,IAAI,iBAAiB;CAC1H,IAAI,cAAc,eAAe,KAAK,YAAY,QAAQ,iBAAiB,KAAK,IAAI,KAAK,IAAI,aAAa;CAC1G,IAAI,iBAAiB,sBAAsB,KAAK,mBAAmB,QAAQ,wBAAwB,KAAK,IAAI,KAAK,IAAI,oBAAoB;CACzI,IAAI,iBAAiB,kBAAkB,KAAK,eAAe,QAAQ,oBAAoB,KAAK,IAAI,KAAK,IAAI,gBAAgB;CACzH,IAAI;CACJ,IAAI,aAAa,mBAAmB,MAAM,eAAe,QAAQ,qBAAqB,KAAK,IAAI,oBAAoB,cAAc,KAAK,WAAW,QAAQ,gBAAgB,KAAK,IAAI,KAAK,IAAI,YAAY;CACvM,IAAI;CACJ,IAAI,SAAS,eAAe,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,gBAAgB,cAAc,KAAK,WAAW,QAAQ,gBAAgB,KAAK,IAAI,KAAK,IAAI,YAAY;CACnL,IAAI,WAAW,MAAM,YAAY;CACjC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,eAAe,MAAM,gBAAgB;CACzC,IAAI,UAAU,MAAM,WAAW;CAC/B,IAAI,YAAY,MAAM,aAAa;CACnC,IAAI,OAAO,MAAM,QAAQ;CACzB,IAAI,QAAQ,IAAI,aAAa,eAAe;EAC1C,IAAI,MAAM,YAAY,MAAM,aAAa,WAAW;GAClD,QAAQ,eAAe,qBAA4B,aAAa,SAAS;GACzE,IAAI,UAAU;IACZ,QAAQ,KAAK;KACX;KACA;KACA;IACF,CAAC;GACH;GACA,QAAQ,SAAS;EACnB;CACF;CACA,OAAO;AACT;AACA,IAAI,cAAc,OAAO,MAAM;CAC7B,aAAa;CACb,YAAY;CACZ,UAAU,EACR,MAAM,EACJ,UAAU,aACZ,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/get-font-sized",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.643.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
"clean:build": "tamagui-build clean:build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tamagui/constants": "
|
|
37
|
-
"@tamagui/
|
|
36
|
+
"@tamagui/constants": "3.0.0-beta.643.1",
|
|
37
|
+
"@tamagui/size": "3.0.0-beta.643.1",
|
|
38
|
+
"@tamagui/web": "3.0.0-beta.643.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@tamagui/build": "
|
|
41
|
+
"@tamagui/build": "3.0.0-beta.643.1",
|
|
41
42
|
"react": ">=19"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { isClient } from '@tamagui/constants'
|
|
2
2
|
import type {
|
|
3
3
|
FontSizeTokens,
|
|
4
|
-
GenericFont,
|
|
5
4
|
TextProps,
|
|
6
5
|
TextStyle,
|
|
7
6
|
VariantSpreadFunction,
|
|
8
7
|
} from '@tamagui/web'
|
|
9
|
-
import {
|
|
8
|
+
import { resolveSizeToken } from '@tamagui/size'
|
|
9
|
+
import { styled, Text } from '@tamagui/web'
|
|
10
10
|
|
|
11
11
|
export const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (
|
|
12
|
-
sizeTokenIn =
|
|
12
|
+
sizeTokenIn = true,
|
|
13
13
|
{ font, fontFamily, props }
|
|
14
14
|
) => {
|
|
15
15
|
if (!font) {
|
|
@@ -18,7 +18,10 @@ export const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const sizeToken = sizeTokenIn
|
|
21
|
+
const sizeToken = resolveSizeToken(sizeTokenIn, 'fontSize') as Exclude<
|
|
22
|
+
FontSizeTokens,
|
|
23
|
+
true
|
|
24
|
+
>
|
|
22
25
|
|
|
23
26
|
const style: TextStyle = {}
|
|
24
27
|
|
|
@@ -68,50 +71,16 @@ export const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
export const SizableText = styled(Text, {
|
|
71
|
-
|
|
72
|
-
fontFamily: '
|
|
74
|
+
displayName: 'SizableText',
|
|
75
|
+
fontFamily: 'body',
|
|
73
76
|
|
|
74
77
|
variants: {
|
|
75
78
|
size: {
|
|
76
|
-
|
|
79
|
+
FontSize: getFontSized,
|
|
77
80
|
},
|
|
78
81
|
} as const,
|
|
79
82
|
|
|
80
83
|
defaultVariants: {
|
|
81
|
-
size:
|
|
84
|
+
size: true,
|
|
82
85
|
},
|
|
83
86
|
})
|
|
84
|
-
|
|
85
|
-
const cache = new WeakMap<any, FontSizeTokens>()
|
|
86
|
-
|
|
87
|
-
function getDefaultSizeToken(font: GenericFont) {
|
|
88
|
-
if (typeof font === 'object' && cache.has(font)) {
|
|
89
|
-
return cache.get(font)!
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// use either font.size if it has true set, or fallback to tokens.size mapping to the same
|
|
93
|
-
const tokens = getTokens()
|
|
94
|
-
const sizeTokens = '$true' in font.size ? font.size : tokens?.size
|
|
95
|
-
if (!sizeTokens) {
|
|
96
|
-
return Object.keys(font.size)[3]
|
|
97
|
-
}
|
|
98
|
-
const sizeDefault = sizeTokens['$true']
|
|
99
|
-
const sizeDefaultSpecific = sizeDefault
|
|
100
|
-
? Object.keys(sizeTokens).find(
|
|
101
|
-
(x) => x !== '$true' && sizeTokens[x]['val'] === sizeDefault['val']
|
|
102
|
-
)
|
|
103
|
-
: null
|
|
104
|
-
|
|
105
|
-
if (!sizeDefault || !sizeDefaultSpecific) {
|
|
106
|
-
if (process.env.NODE_ENV === 'development') {
|
|
107
|
-
console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
|
|
108
|
-
|
|
109
|
-
Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
|
|
110
|
-
set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`)
|
|
111
|
-
}
|
|
112
|
-
return Object.keys(font.size)[3]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
cache.set(font, sizeDefaultSpecific as FontSizeTokens)
|
|
116
|
-
return sizeDefaultSpecific
|
|
117
|
-
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { FontSizeTokens, TextProps, VariantSpreadFunction } from '@tamagui/web';
|
|
2
2
|
export declare const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens>;
|
|
3
|
-
export declare const SizableText: import("
|
|
4
|
-
size?:
|
|
5
|
-
}
|
|
3
|
+
export declare const SizableText: import("react").FunctionComponent<Omit<import("@tamagui/web").TextNonStyleProps, "size" | keyof import("@tamagui/web").TextStylePropsBase> & import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase> & {
|
|
4
|
+
size?: import("@tamagui/web").FontSize | undefined;
|
|
5
|
+
} & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").TextStylePropsBase>> & {
|
|
6
|
+
ref?: import("react").Ref<import("@tamagui/web").TamaguiTextElement> | undefined;
|
|
7
|
+
}> & import("@tamagui/web").StaticComponentObject<import("@tamagui/web").TamaDefer, import("@tamagui/web").TamaguiTextElement, import("@tamagui/web").TextNonStyleProps, import("@tamagui/web").TextStylePropsBase, {
|
|
8
|
+
size?: import("@tamagui/web").FontSize | undefined;
|
|
9
|
+
}, import("@tamagui/web").StaticConfigPublic> & Omit<import("@tamagui/web").StaticConfigPublic, "staticConfig"> & {
|
|
10
|
+
__tama: [import("@tamagui/web").TamaDefer, import("@tamagui/web").TamaguiTextElement, import("@tamagui/web").TextNonStyleProps, import("@tamagui/web").TextStylePropsBase, {
|
|
11
|
+
size?: import("@tamagui/web").FontSize | undefined;
|
|
12
|
+
}, import("@tamagui/web").StaticConfigPublic];
|
|
13
|
+
};
|
|
6
14
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EAET,qBAAqB,EACtB,MAAM,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,qBAAqB,CAAC,SAAS,EAAE,cAAc,CA4DzE,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;CAatB,CAAA"}
|