@tamagui/core 1.0.1-beta.21 → 1.0.1-beta.23

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.
Files changed (44) hide show
  1. package/dist/cjs/createComponent.js +11 -9
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/helpers/createShallowUpdate.js +3 -2
  4. package/dist/cjs/helpers/createShallowUpdate.js.map +2 -2
  5. package/dist/cjs/helpers/getStackSize.js +1 -1
  6. package/dist/cjs/helpers/getStackSize.js.map +1 -1
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/types.js.map +1 -1
  10. package/dist/esm/createComponent.js +11 -9
  11. package/dist/esm/createComponent.js.map +2 -2
  12. package/dist/esm/helpers/createShallowUpdate.js +3 -2
  13. package/dist/esm/helpers/createShallowUpdate.js.map +2 -2
  14. package/dist/esm/helpers/getStackSize.js +1 -1
  15. package/dist/esm/helpers/getStackSize.js.map +1 -1
  16. package/dist/esm/index.js +1 -0
  17. package/dist/esm/index.js.map +2 -2
  18. package/dist/jsx/createComponent.js +11 -9
  19. package/dist/jsx/helpers/createShallowUpdate.js +3 -2
  20. package/dist/jsx/helpers/getStackSize.js +1 -1
  21. package/dist/jsx/index.js +1 -0
  22. package/package.json +5 -5
  23. package/types/createComponent.d.ts +1 -1
  24. package/types/createComponent.d.ts.map +1 -1
  25. package/types/helpers/createShallowUpdate.d.ts +1 -2
  26. package/types/helpers/createShallowUpdate.d.ts.map +1 -1
  27. package/types/index.d.ts +1 -0
  28. package/types/index.d.ts.map +1 -1
  29. package/types/types.d.ts +3 -1
  30. package/types/types.d.ts.map +1 -1
  31. package/dist/cjs/helpers/addStylesUsingClassname.js +0 -87
  32. package/dist/cjs/helpers/addStylesUsingClassname.js.map +0 -7
  33. package/dist/cjs/helpers/getButtonSize.js +0 -45
  34. package/dist/cjs/helpers/getButtonSize.js.map +0 -7
  35. package/dist/esm/helpers/addStylesUsingClassname.js +0 -64
  36. package/dist/esm/helpers/addStylesUsingClassname.js.map +0 -7
  37. package/dist/esm/helpers/getButtonSize.js +0 -24
  38. package/dist/esm/helpers/getButtonSize.js.map +0 -7
  39. package/dist/jsx/helpers/addStylesUsingClassname.js +0 -63
  40. package/dist/jsx/helpers/getButtonSize.js +0 -23
  41. package/types/helpers/addStylesUsingClassname.d.ts +0 -3
  42. package/types/helpers/addStylesUsingClassname.d.ts.map +0 -1
  43. package/types/helpers/getButtonSize.d.ts +0 -8
  44. package/types/helpers/getButtonSize.d.ts.map +0 -1
@@ -1,87 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 addStylesUsingClassname_exports = {};
20
- __export(addStylesUsingClassname_exports, {
21
- addStylesUsingClassname: () => addStylesUsingClassname,
22
- useStylesAsClassname: () => useStylesAsClassname
23
- });
24
- module.exports = __toCommonJS(addStylesUsingClassname_exports);
25
- var import_react = require("react");
26
- var import_getStylesAtomic = require("./getStylesAtomic");
27
- var import_insertStyleRule = require("./insertStyleRule");
28
- let added = /* @__PURE__ */ new Set();
29
- function useStylesAsClassname(styles, disable = false, debug = false) {
30
- if (!import_react.useInsertionEffect) {
31
- return addStylesUsingClassname(disable ? styles : [], debug);
32
- } else {
33
- const insertions = [];
34
- const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
35
- for (const rule of rules) {
36
- insertions.push({ identifier, rule });
37
- }
38
- });
39
- for (const { identifier, rule } of insertions) {
40
- (0, import_insertStyleRule.updateInsertedCache)(identifier, rule);
41
- }
42
- (0, import_react.useInsertionEffect)(() => {
43
- for (const { identifier, rule } of insertions) {
44
- (0, import_insertStyleRule.insertStyleRule)(identifier, rule);
45
- }
46
- });
47
- return className;
48
- }
49
- }
50
- __name(useStylesAsClassname, "useStylesAsClassname");
51
- function addStylesUsingClassname(styles, debug = false, onAdd) {
52
- let className = "";
53
- for (const style of styles) {
54
- if (!style)
55
- continue;
56
- if (Array.isArray(style)) {
57
- className += " " + addStylesUsingClassname(style);
58
- continue;
59
- }
60
- const atomicStyles = (0, import_getStylesAtomic.getStylesAtomic)(style);
61
- if (process.env.NODE_ENV === "development") {
62
- if (debug === "verbose") {
63
- console.log(" atomicStyles ", atomicStyles);
64
- }
65
- }
66
- for (const { identifier, rules } of atomicStyles) {
67
- className += ` ${identifier}`;
68
- if (added.has(identifier)) {
69
- continue;
70
- }
71
- added.add(identifier);
72
- if (onAdd) {
73
- onAdd(identifier, rules);
74
- } else {
75
- (0, import_insertStyleRule.insertStyleRule)(identifier, rules[0]);
76
- }
77
- }
78
- }
79
- return className;
80
- }
81
- __name(addStylesUsingClassname, "addStylesUsingClassname");
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- addStylesUsingClassname,
85
- useStylesAsClassname
86
- });
87
- //# sourceMappingURL=addStylesUsingClassname.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/addStylesUsingClassname.tsx"],
4
- "sourcesContent": ["// @ts-ignore\nimport { useInsertionEffect } from 'react'\n\nimport { getStylesAtomic } from './getStylesAtomic'\nimport { insertStyleRule, updateInsertedCache } from './insertStyleRule'\n\n// TODO can drop most of this code once we drop support for 17\n// uses new useInsertionEffect for better perf if available\n\n// could be cleared occasionally\nlet added = new Set<string>()\n\nexport function useStylesAsClassname(styles: any[], disable = false, debug = false) {\n if (!useInsertionEffect) {\n return addStylesUsingClassname(disable ? styles : [], debug)\n } else {\n const insertions: any[] = []\n const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {\n for (const rule of rules) {\n insertions.push({ identifier, rule })\n }\n })\n // avoid race conditions in lookups because useInsertionEffect is delayed\n for (const { identifier, rule } of insertions) {\n updateInsertedCache(identifier, rule)\n }\n useInsertionEffect(() => {\n for (const { identifier, rule } of insertions) {\n insertStyleRule(identifier, rule)\n }\n })\n return className\n }\n}\n\nexport function addStylesUsingClassname(\n styles: any[],\n debug: boolean | 'verbose' = false,\n onAdd?: (identifier: string, rules: string[]) => any\n) {\n let className = ''\n for (const style of styles) {\n if (!style) continue\n if (Array.isArray(style)) {\n className += ' ' + addStylesUsingClassname(style)\n continue\n }\n const atomicStyles = getStylesAtomic(style)\n if (process.env.NODE_ENV === 'development') {\n if (debug === 'verbose') {\n console.log(' atomicStyles ', atomicStyles)\n }\n }\n for (const { identifier, rules } of atomicStyles) {\n className += ` ${identifier}`\n if (added.has(identifier)) {\n continue\n }\n added.add(identifier)\n if (onAdd) {\n onAdd(identifier, rules)\n } else {\n insertStyleRule(identifier, rules[0])\n }\n }\n }\n return className\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmC;AAEnC,6BAAgC;AAChC,6BAAqD;AAMrD,IAAI,QAAQ,oBAAI,IAAY;AAErB,8BAA8B,QAAe,UAAU,OAAO,QAAQ,OAAO;AAClF,MAAI,CAAC,iCAAoB;AACvB,WAAO,wBAAwB,UAAU,SAAS,CAAC,GAAG,KAAK;AAAA,EAC7D,OAAO;AACL,UAAM,aAAoB,CAAC;AAC3B,UAAM,YAAY,wBAAwB,UAAU,CAAC,IAAI,QAAQ,OAAO,CAAC,YAAY,UAAU;AAC7F,iBAAW,QAAQ,OAAO;AACxB,mBAAW,KAAK,EAAE,YAAY,KAAK,CAAC;AAAA,MACtC;AAAA,IACF,CAAC;AAED,eAAW,EAAE,YAAY,UAAU,YAAY;AAC7C,sDAAoB,YAAY,IAAI;AAAA,IACtC;AACA,yCAAmB,MAAM;AACvB,iBAAW,EAAE,YAAY,UAAU,YAAY;AAC7C,oDAAgB,YAAY,IAAI;AAAA,MAClC;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AACF;AArBgB;AAuBT,iCACL,QACA,QAA6B,OAC7B,OACA;AACA,MAAI,YAAY;AAChB,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC;AAAO;AACZ,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,mBAAa,MAAM,wBAAwB,KAAK;AAChD;AAAA,IACF;AACA,UAAM,eAAe,4CAAgB,KAAK;AAC1C,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAI,UAAU,WAAW;AACvB,gBAAQ,IAAI,kBAAkB,YAAY;AAAA,MAC5C;AAAA,IACF;AACA,eAAW,EAAE,YAAY,WAAW,cAAc;AAChD,mBAAa,IAAI;AACjB,UAAI,MAAM,IAAI,UAAU,GAAG;AACzB;AAAA,MACF;AACA,YAAM,IAAI,UAAU;AACpB,UAAI,OAAO;AACT,cAAM,YAAY,KAAK;AAAA,MACzB,OAAO;AACL,oDAAgB,YAAY,MAAM,EAAE;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAhCgB;",
6
- "names": []
7
- }
@@ -1,45 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 getButtonSize_exports = {};
20
- __export(getButtonSize_exports, {
21
- getButtonSize: () => getButtonSize
22
- });
23
- module.exports = __toCommonJS(getButtonSize_exports);
24
- var import_core = require("@tamagui/core");
25
- const getButtonSize = /* @__PURE__ */ __name((sizeX = 0.9, sizeY = 0.333) => (val, { tokens, props, fonts }) => {
26
- const size = tokens.size[val] ?? tokens.size["$4"] ?? val ?? 14;
27
- const radius = tokens.radius[val] ?? tokens.radius["$4"] ?? size;
28
- const px = Math.round(+((0, import_core.isVariable)(size) ? size.val : size) * sizeX);
29
- const py = Math.round(+((0, import_core.isVariable)(size) ? size.val : size) * sizeY);
30
- const font = fonts[props.fontFamily] || fonts["$body"];
31
- const lineHeights = font.lineHeight;
32
- const lineHeight = lineHeights[val] ?? lineHeights["$4"];
33
- const minHeight = Math.round((0, import_core.getVariableValue)(lineHeight) + py * 2);
34
- return {
35
- minHeight,
36
- paddingHorizontal: props.circular ? 0 : px,
37
- paddingVertical: props.circular ? 0 : py,
38
- borderRadius: props.circular ? 1e5 : props.borderRadius ?? radius
39
- };
40
- }, "getButtonSize");
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- getButtonSize
44
- });
45
- //# sourceMappingURL=getButtonSize.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getButtonSize.ts"],
4
- "sourcesContent": ["import { VariantSpreadExtras, getVariableValue, isVariable } from '@tamagui/core'\n\n// for use in button-like things\n\nexport const getButtonSize =\n (sizeX = 0.9, sizeY = 0.333) =>\n (val: any, { tokens, props, fonts }: VariantSpreadExtras<any>) => {\n const size = tokens.size[val] ?? tokens.size['$4'] ?? val ?? 14\n const radius = tokens.radius[val] ?? tokens.radius['$4'] ?? size\n const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX)\n const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY)\n // keep buttons height aligned to the font used\n const font = fonts[props.fontFamily] || fonts['$body']\n const lineHeights = font.lineHeight\n const lineHeight = lineHeights[val] ?? lineHeights['$4']\n const minHeight = Math.round(getVariableValue(lineHeight) + py * 2)\n return {\n minHeight,\n paddingHorizontal: props.circular ? 0 : px,\n paddingVertical: props.circular ? 0 : py,\n borderRadius: props.circular ? 100_000 : props.borderRadius ?? radius,\n }\n }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkE;AAI3D,MAAM,gBACX,wBAAC,QAAQ,KAAK,QAAQ,UACtB,CAAC,KAAU,EAAE,QAAQ,OAAO,YAAsC;AAChE,QAAM,OAAO,OAAO,KAAK,QAAQ,OAAO,KAAK,SAAS,OAAO;AAC7D,QAAM,SAAS,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS;AAC5D,QAAM,KAAK,KAAK,MAAM,CAAE,6BAAW,IAAI,IAAI,KAAK,MAAM,QAAQ,KAAK;AACnE,QAAM,KAAK,KAAK,MAAM,CAAE,6BAAW,IAAI,IAAI,KAAK,MAAM,QAAQ,KAAK;AAEnE,QAAM,OAAO,MAAM,MAAM,eAAe,MAAM;AAC9C,QAAM,cAAc,KAAK;AACzB,QAAM,aAAa,YAAY,QAAQ,YAAY;AACnD,QAAM,YAAY,KAAK,MAAM,kCAAiB,UAAU,IAAI,KAAK,CAAC;AAClE,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,MAAM,WAAW,IAAI;AAAA,IACxC,iBAAiB,MAAM,WAAW,IAAI;AAAA,IACtC,cAAc,MAAM,WAAW,MAAU,MAAM,gBAAgB;AAAA,EACjE;AACF,GAjBA;",
6
- "names": []
7
- }
@@ -1,64 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useInsertionEffect } from "react";
4
- import { getStylesAtomic } from "./getStylesAtomic";
5
- import { insertStyleRule, updateInsertedCache } from "./insertStyleRule";
6
- let added = /* @__PURE__ */ new Set();
7
- function useStylesAsClassname(styles, disable = false, debug = false) {
8
- if (!useInsertionEffect) {
9
- return addStylesUsingClassname(disable ? styles : [], debug);
10
- } else {
11
- const insertions = [];
12
- const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
13
- for (const rule of rules) {
14
- insertions.push({ identifier, rule });
15
- }
16
- });
17
- for (const { identifier, rule } of insertions) {
18
- updateInsertedCache(identifier, rule);
19
- }
20
- useInsertionEffect(() => {
21
- for (const { identifier, rule } of insertions) {
22
- insertStyleRule(identifier, rule);
23
- }
24
- });
25
- return className;
26
- }
27
- }
28
- __name(useStylesAsClassname, "useStylesAsClassname");
29
- function addStylesUsingClassname(styles, debug = false, onAdd) {
30
- let className = "";
31
- for (const style of styles) {
32
- if (!style)
33
- continue;
34
- if (Array.isArray(style)) {
35
- className += " " + addStylesUsingClassname(style);
36
- continue;
37
- }
38
- const atomicStyles = getStylesAtomic(style);
39
- if (process.env.NODE_ENV === "development") {
40
- if (debug === "verbose") {
41
- console.log(" atomicStyles ", atomicStyles);
42
- }
43
- }
44
- for (const { identifier, rules } of atomicStyles) {
45
- className += ` ${identifier}`;
46
- if (added.has(identifier)) {
47
- continue;
48
- }
49
- added.add(identifier);
50
- if (onAdd) {
51
- onAdd(identifier, rules);
52
- } else {
53
- insertStyleRule(identifier, rules[0]);
54
- }
55
- }
56
- }
57
- return className;
58
- }
59
- __name(addStylesUsingClassname, "addStylesUsingClassname");
60
- export {
61
- addStylesUsingClassname,
62
- useStylesAsClassname
63
- };
64
- //# sourceMappingURL=addStylesUsingClassname.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/addStylesUsingClassname.tsx"],
4
- "sourcesContent": ["// @ts-ignore\nimport { useInsertionEffect } from 'react'\n\nimport { getStylesAtomic } from './getStylesAtomic'\nimport { insertStyleRule, updateInsertedCache } from './insertStyleRule'\n\n// TODO can drop most of this code once we drop support for 17\n// uses new useInsertionEffect for better perf if available\n\n// could be cleared occasionally\nlet added = new Set<string>()\n\nexport function useStylesAsClassname(styles: any[], disable = false, debug = false) {\n if (!useInsertionEffect) {\n return addStylesUsingClassname(disable ? styles : [], debug)\n } else {\n const insertions: any[] = []\n const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {\n for (const rule of rules) {\n insertions.push({ identifier, rule })\n }\n })\n // avoid race conditions in lookups because useInsertionEffect is delayed\n for (const { identifier, rule } of insertions) {\n updateInsertedCache(identifier, rule)\n }\n useInsertionEffect(() => {\n for (const { identifier, rule } of insertions) {\n insertStyleRule(identifier, rule)\n }\n })\n return className\n }\n}\n\nexport function addStylesUsingClassname(\n styles: any[],\n debug: boolean | 'verbose' = false,\n onAdd?: (identifier: string, rules: string[]) => any\n) {\n let className = ''\n for (const style of styles) {\n if (!style) continue\n if (Array.isArray(style)) {\n className += ' ' + addStylesUsingClassname(style)\n continue\n }\n const atomicStyles = getStylesAtomic(style)\n if (process.env.NODE_ENV === 'development') {\n if (debug === 'verbose') {\n console.log(' atomicStyles ', atomicStyles)\n }\n }\n for (const { identifier, rules } of atomicStyles) {\n className += ` ${identifier}`\n if (added.has(identifier)) {\n continue\n }\n added.add(identifier)\n if (onAdd) {\n onAdd(identifier, rules)\n } else {\n insertStyleRule(identifier, rules[0])\n }\n }\n }\n return className\n}\n"],
5
- "mappings": ";;AACA;AAEA;AACA;AAMA,IAAI,QAAQ,oBAAI,IAAY;AAErB,8BAA8B,QAAe,UAAU,OAAO,QAAQ,OAAO;AAClF,MAAI,CAAC,oBAAoB;AACvB,WAAO,wBAAwB,UAAU,SAAS,CAAC,GAAG,KAAK;AAAA,EAC7D,OAAO;AACL,UAAM,aAAoB,CAAC;AAC3B,UAAM,YAAY,wBAAwB,UAAU,CAAC,IAAI,QAAQ,OAAO,CAAC,YAAY,UAAU;AAC7F,iBAAW,QAAQ,OAAO;AACxB,mBAAW,KAAK,EAAE,YAAY,KAAK,CAAC;AAAA,MACtC;AAAA,IACF,CAAC;AAED,eAAW,EAAE,YAAY,UAAU,YAAY;AAC7C,0BAAoB,YAAY,IAAI;AAAA,IACtC;AACA,uBAAmB,MAAM;AACvB,iBAAW,EAAE,YAAY,UAAU,YAAY;AAC7C,wBAAgB,YAAY,IAAI;AAAA,MAClC;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AACF;AArBgB;AAuBT,iCACL,QACA,QAA6B,OAC7B,OACA;AACA,MAAI,YAAY;AAChB,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC;AAAO;AACZ,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,mBAAa,MAAM,wBAAwB,KAAK;AAChD;AAAA,IACF;AACA,UAAM,eAAe,gBAAgB,KAAK;AAC1C,QAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAI,UAAU,WAAW;AACvB,gBAAQ,IAAI,kBAAkB,YAAY;AAAA,MAC5C;AAAA,IACF;AACA,eAAW,EAAE,YAAY,WAAW,cAAc;AAChD,mBAAa,IAAI;AACjB,UAAI,MAAM,IAAI,UAAU,GAAG;AACzB;AAAA,MACF;AACA,YAAM,IAAI,UAAU;AACpB,UAAI,OAAO;AACT,cAAM,YAAY,KAAK;AAAA,MACzB,OAAO;AACL,wBAAgB,YAAY,MAAM,EAAE;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAhCgB;",
6
- "names": []
7
- }
@@ -1,24 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { getVariableValue, isVariable } from "@tamagui/core";
4
- const getButtonSize = /* @__PURE__ */ __name((sizeX = 0.9, sizeY = 0.333) => (val, { tokens, props, fonts }) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
6
- const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : tokens.size["$4"]) != null ? _b : val) != null ? _c : 14;
7
- const radius = (_e = (_d = tokens.radius[val]) != null ? _d : tokens.radius["$4"]) != null ? _e : size;
8
- const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX);
9
- const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY);
10
- const font = fonts[props.fontFamily] || fonts["$body"];
11
- const lineHeights = font.lineHeight;
12
- const lineHeight = (_f = lineHeights[val]) != null ? _f : lineHeights["$4"];
13
- const minHeight = Math.round(getVariableValue(lineHeight) + py * 2);
14
- return {
15
- minHeight,
16
- paddingHorizontal: props.circular ? 0 : px,
17
- paddingVertical: props.circular ? 0 : py,
18
- borderRadius: props.circular ? 1e5 : (_g = props.borderRadius) != null ? _g : radius
19
- };
20
- }, "getButtonSize");
21
- export {
22
- getButtonSize
23
- };
24
- //# sourceMappingURL=getButtonSize.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/getButtonSize.ts"],
4
- "sourcesContent": ["import { VariantSpreadExtras, getVariableValue, isVariable } from '@tamagui/core'\n\n// for use in button-like things\n\nexport const getButtonSize =\n (sizeX = 0.9, sizeY = 0.333) =>\n (val: any, { tokens, props, fonts }: VariantSpreadExtras<any>) => {\n const size = tokens.size[val] ?? tokens.size['$4'] ?? val ?? 14\n const radius = tokens.radius[val] ?? tokens.radius['$4'] ?? size\n const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX)\n const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY)\n // keep buttons height aligned to the font used\n const font = fonts[props.fontFamily] || fonts['$body']\n const lineHeights = font.lineHeight\n const lineHeight = lineHeights[val] ?? lineHeights['$4']\n const minHeight = Math.round(getVariableValue(lineHeight) + py * 2)\n return {\n minHeight,\n paddingHorizontal: props.circular ? 0 : px,\n paddingVertical: props.circular ? 0 : py,\n borderRadius: props.circular ? 100_000 : props.borderRadius ?? radius,\n }\n }\n"],
5
- "mappings": ";;AAAA;AAIO,MAAM,gBACX,wBAAC,QAAQ,KAAK,QAAQ,UACtB,CAAC,KAAU,EAAE,QAAQ,OAAO,YAAsC;AANpE;AAOI,QAAM,OAAO,yBAAO,KAAK,SAAZ,YAAoB,OAAO,KAAK,UAAhC,YAAyC,QAAzC,YAAgD;AAC7D,QAAM,SAAS,mBAAO,OAAO,SAAd,YAAsB,OAAO,OAAO,UAApC,YAA6C;AAC5D,QAAM,KAAK,KAAK,MAAM,CAAE,YAAW,IAAI,IAAI,KAAK,MAAM,QAAQ,KAAK;AACnE,QAAM,KAAK,KAAK,MAAM,CAAE,YAAW,IAAI,IAAI,KAAK,MAAM,QAAQ,KAAK;AAEnE,QAAM,OAAO,MAAM,MAAM,eAAe,MAAM;AAC9C,QAAM,cAAc,KAAK;AACzB,QAAM,aAAa,kBAAY,SAAZ,YAAoB,YAAY;AACnD,QAAM,YAAY,KAAK,MAAM,iBAAiB,UAAU,IAAI,KAAK,CAAC;AAClE,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB,MAAM,WAAW,IAAI;AAAA,IACxC,iBAAiB,MAAM,WAAW,IAAI;AAAA,IACtC,cAAc,MAAM,WAAW,MAAU,YAAM,iBAAN,YAAsB;AAAA,EACjE;AACF,GAjBA;",
6
- "names": []
7
- }
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useInsertionEffect } from "react";
4
- import { getStylesAtomic } from "./getStylesAtomic";
5
- import { insertStyleRule, updateInsertedCache } from "./insertStyleRule";
6
- let added = /* @__PURE__ */ new Set();
7
- function useStylesAsClassname(styles, disable = false, debug = false) {
8
- if (!useInsertionEffect) {
9
- return addStylesUsingClassname(disable ? styles : [], debug);
10
- } else {
11
- const insertions = [];
12
- const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
13
- for (const rule of rules) {
14
- insertions.push({ identifier, rule });
15
- }
16
- });
17
- for (const { identifier, rule } of insertions) {
18
- updateInsertedCache(identifier, rule);
19
- }
20
- useInsertionEffect(() => {
21
- for (const { identifier, rule } of insertions) {
22
- insertStyleRule(identifier, rule);
23
- }
24
- });
25
- return className;
26
- }
27
- }
28
- __name(useStylesAsClassname, "useStylesAsClassname");
29
- function addStylesUsingClassname(styles, debug = false, onAdd) {
30
- let className = "";
31
- for (const style of styles) {
32
- if (!style)
33
- continue;
34
- if (Array.isArray(style)) {
35
- className += " " + addStylesUsingClassname(style);
36
- continue;
37
- }
38
- const atomicStyles = getStylesAtomic(style);
39
- if (process.env.NODE_ENV === "development") {
40
- if (debug === "verbose") {
41
- console.log(" atomicStyles ", atomicStyles);
42
- }
43
- }
44
- for (const { identifier, rules } of atomicStyles) {
45
- className += ` ${identifier}`;
46
- if (added.has(identifier)) {
47
- continue;
48
- }
49
- added.add(identifier);
50
- if (onAdd) {
51
- onAdd(identifier, rules);
52
- } else {
53
- insertStyleRule(identifier, rules[0]);
54
- }
55
- }
56
- }
57
- return className;
58
- }
59
- __name(addStylesUsingClassname, "addStylesUsingClassname");
60
- export {
61
- addStylesUsingClassname,
62
- useStylesAsClassname
63
- };
@@ -1,23 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { getVariableValue, isVariable } from "@tamagui/core";
4
- const getButtonSize = /* @__PURE__ */ __name((sizeX = 0.9, sizeY = 0.333) => (val, { tokens, props, fonts }) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
6
- const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : tokens.size["$4"]) != null ? _b : val) != null ? _c : 14;
7
- const radius = (_e = (_d = tokens.radius[val]) != null ? _d : tokens.radius["$4"]) != null ? _e : size;
8
- const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX);
9
- const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY);
10
- const font = fonts[props.fontFamily] || fonts["$body"];
11
- const lineHeights = font.lineHeight;
12
- const lineHeight = (_f = lineHeights[val]) != null ? _f : lineHeights["$4"];
13
- const minHeight = Math.round(getVariableValue(lineHeight) + py * 2);
14
- return {
15
- minHeight,
16
- paddingHorizontal: props.circular ? 0 : px,
17
- paddingVertical: props.circular ? 0 : py,
18
- borderRadius: props.circular ? 1e5 : (_g = props.borderRadius) != null ? _g : radius
19
- };
20
- }, "getButtonSize");
21
- export {
22
- getButtonSize
23
- };
@@ -1,3 +0,0 @@
1
- export declare function useStylesAsClassname(styles: any[], disable?: boolean, debug?: boolean): string;
2
- export declare function addStylesUsingClassname(styles: any[], debug?: boolean | 'verbose', onAdd?: (identifier: string, rules: string[]) => any): string;
3
- //# sourceMappingURL=addStylesUsingClassname.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addStylesUsingClassname.d.ts","sourceRoot":"","sources":["../../src/helpers/addStylesUsingClassname.tsx"],"names":[],"mappings":"AAYA,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,UAAQ,EAAE,KAAK,UAAQ,UAqBjF;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,EAAE,EACb,KAAK,GAAE,OAAO,GAAG,SAAiB,EAClC,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,UA6BrD"}
@@ -1,8 +0,0 @@
1
- import { VariantSpreadExtras } from '@tamagui/core';
2
- export declare const getButtonSize: (sizeX?: number, sizeY?: number) => (val: any, { tokens, props, fonts }: VariantSpreadExtras<any>) => {
3
- minHeight: number;
4
- paddingHorizontal: number;
5
- paddingVertical: number;
6
- borderRadius: any;
7
- };
8
- //# sourceMappingURL=getButtonSize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getButtonSize.d.ts","sourceRoot":"","sources":["../../src/helpers/getButtonSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgC,MAAM,eAAe,CAAA;AAIjF,eAAO,MAAM,aAAa,4CAElB,GAAG,4BAA4B,oBAAoB,GAAG,CAAC;;;;;CAgB5D,CAAA"}