@tamagui/core 1.0.1-beta.48 → 1.0.1-beta.49

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 (131) hide show
  1. package/dist/cjs/Tamagui.js +3 -0
  2. package/dist/cjs/Tamagui.js.map +2 -2
  3. package/dist/cjs/ThemeManager.js.map +2 -2
  4. package/dist/cjs/conf.js +0 -4
  5. package/dist/cjs/conf.js.map +2 -2
  6. package/dist/cjs/createComponent.js +173 -169
  7. package/dist/cjs/createComponent.js.map +2 -2
  8. package/dist/cjs/createTamagui.js +71 -29
  9. package/dist/cjs/createTamagui.js.map +2 -2
  10. package/dist/cjs/createTheme.js +3 -1
  11. package/dist/cjs/createTheme.js.map +2 -2
  12. package/dist/cjs/createTokens.js +4 -19
  13. package/dist/cjs/createTokens.js.map +2 -2
  14. package/dist/cjs/createVariable.js +22 -8
  15. package/dist/cjs/createVariable.js.map +2 -2
  16. package/dist/cjs/createVariables.js +57 -0
  17. package/dist/cjs/createVariables.js.map +7 -0
  18. package/dist/cjs/helpers/createPropMapper.js +81 -51
  19. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  20. package/dist/cjs/helpers/generateAtomicStyles.js +41 -36
  21. package/dist/cjs/helpers/generateAtomicStyles.js.map +2 -2
  22. package/dist/cjs/helpers/getSplitStyles.js +35 -4
  23. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  24. package/dist/cjs/helpers/getStackSize.js +4 -4
  25. package/dist/cjs/helpers/getStackSize.js.map +2 -2
  26. package/dist/cjs/helpers/getStylesAtomic.js +9 -2
  27. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  28. package/dist/cjs/helpers/insertStyleRule.js +2 -0
  29. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  30. package/dist/cjs/helpers/validate.js +2 -2
  31. package/dist/cjs/helpers/validate.js.map +2 -2
  32. package/dist/cjs/hooks/useIsMounted.js +2 -2
  33. package/dist/cjs/hooks/useIsMounted.js.map +2 -2
  34. package/dist/cjs/index.js +2 -3
  35. package/dist/cjs/index.js.map +2 -2
  36. package/dist/cjs/styled.js +5 -0
  37. package/dist/cjs/styled.js.map +2 -2
  38. package/dist/cjs/types.js.map +1 -1
  39. package/dist/cjs/views/Theme.js +3 -2
  40. package/dist/cjs/views/Theme.js.map +2 -2
  41. package/dist/esm/Tamagui.js +3 -0
  42. package/dist/esm/Tamagui.js.map +2 -2
  43. package/dist/esm/ThemeManager.js.map +2 -2
  44. package/dist/esm/conf.js +0 -4
  45. package/dist/esm/conf.js.map +2 -2
  46. package/dist/esm/createComponent.js +173 -170
  47. package/dist/esm/createComponent.js.map +2 -2
  48. package/dist/esm/createTamagui.js +70 -29
  49. package/dist/esm/createTamagui.js.map +2 -2
  50. package/dist/esm/createTheme.js +3 -1
  51. package/dist/esm/createTheme.js.map +2 -2
  52. package/dist/esm/createTokens.js +3 -17
  53. package/dist/esm/createTokens.js.map +2 -2
  54. package/dist/esm/createVariable.js +22 -7
  55. package/dist/esm/createVariable.js.map +2 -2
  56. package/dist/esm/createVariables.js +35 -0
  57. package/dist/esm/createVariables.js.map +7 -0
  58. package/dist/esm/helpers/createPropMapper.js +70 -51
  59. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  60. package/dist/esm/helpers/generateAtomicStyles.js +41 -36
  61. package/dist/esm/helpers/generateAtomicStyles.js.map +2 -2
  62. package/dist/esm/helpers/getSplitStyles.js +36 -5
  63. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  64. package/dist/esm/helpers/getStackSize.js +1 -1
  65. package/dist/esm/helpers/getStackSize.js.map +2 -2
  66. package/dist/esm/helpers/getStylesAtomic.js +7 -1
  67. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  68. package/dist/esm/helpers/insertStyleRule.js +2 -0
  69. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  70. package/dist/esm/helpers/validate.js +2 -2
  71. package/dist/esm/helpers/validate.js.map +2 -2
  72. package/dist/esm/hooks/useIsMounted.js +1 -1
  73. package/dist/esm/hooks/useIsMounted.js.map +2 -2
  74. package/dist/esm/index.js +2 -2
  75. package/dist/esm/index.js.map +2 -2
  76. package/dist/esm/styled.js +5 -0
  77. package/dist/esm/styled.js.map +2 -2
  78. package/dist/esm/views/Theme.js +3 -2
  79. package/dist/esm/views/Theme.js.map +2 -2
  80. package/dist/jsx/Tamagui.js +3 -0
  81. package/dist/jsx/conf.js +0 -4
  82. package/dist/jsx/createComponent.js +173 -170
  83. package/dist/jsx/createTamagui.js +70 -29
  84. package/dist/jsx/createTheme.js +3 -1
  85. package/dist/jsx/createTokens.js +3 -17
  86. package/dist/jsx/createVariable.js +22 -7
  87. package/dist/jsx/createVariables.js +34 -0
  88. package/dist/jsx/helpers/createPropMapper.js +70 -51
  89. package/dist/jsx/helpers/generateAtomicStyles.js +41 -36
  90. package/dist/jsx/helpers/getSplitStyles.js +36 -5
  91. package/dist/jsx/helpers/getStackSize.js +1 -1
  92. package/dist/jsx/helpers/getStylesAtomic.js +7 -1
  93. package/dist/jsx/helpers/insertStyleRule.js +2 -0
  94. package/dist/jsx/helpers/validate.js +2 -2
  95. package/dist/jsx/hooks/useIsMounted.js +1 -1
  96. package/dist/jsx/index.js +2 -2
  97. package/dist/jsx/styled.js +5 -0
  98. package/dist/jsx/views/Theme.js +3 -2
  99. package/package.json +5 -5
  100. package/types/ThemeManager.d.ts.map +1 -1
  101. package/types/conf.d.ts +1 -1
  102. package/types/conf.d.ts.map +1 -1
  103. package/types/createComponent.d.ts +1 -0
  104. package/types/createComponent.d.ts.map +1 -1
  105. package/types/createTamagui.d.ts.map +1 -1
  106. package/types/createTheme.d.ts +1 -1
  107. package/types/createTheme.d.ts.map +1 -1
  108. package/types/createTokens.d.ts +0 -1
  109. package/types/createTokens.d.ts.map +1 -1
  110. package/types/createVariable.d.ts +15 -13
  111. package/types/createVariable.d.ts.map +1 -1
  112. package/types/createVariables.d.ts +10 -0
  113. package/types/createVariables.d.ts.map +1 -0
  114. package/types/helpers/createPropMapper.d.ts.map +1 -1
  115. package/types/helpers/generateAtomicStyles.d.ts.map +1 -1
  116. package/types/helpers/getSize.d.ts +1 -1
  117. package/types/helpers/getSize.d.ts.map +1 -1
  118. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  119. package/types/helpers/getStackSize.d.ts +4 -5
  120. package/types/helpers/getStackSize.d.ts.map +1 -1
  121. package/types/helpers/getStylesAtomic.d.ts +5 -0
  122. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  123. package/types/helpers/getVariantExtras.d.ts +1 -1
  124. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  125. package/types/hooks/useIsMounted.d.ts.map +1 -1
  126. package/types/index.d.ts +2 -1
  127. package/types/index.d.ts.map +1 -1
  128. package/types/styled.d.ts.map +1 -1
  129. package/types/types.d.ts +10 -7
  130. package/types/types.d.ts.map +1 -1
  131. package/types/views/Theme.d.ts.map +1 -1
@@ -1,6 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const createTheme = /* @__PURE__ */ __name((theme) => theme, "createTheme");
3
+ const createTheme = /* @__PURE__ */ __name((theme) => {
4
+ return theme;
5
+ }, "createTheme");
4
6
  export {
5
7
  createTheme
6
8
  };
@@ -1,28 +1,14 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { createVariable } from "./createVariable";
3
+ import { createVariables } from "./createVariables";
4
4
  import { validateTokens } from "./helpers/validate";
5
5
  function createTokens(tokens) {
6
6
  if (process.env.NODE_ENV === "development") {
7
7
  validateTokens(tokens);
8
8
  }
9
- return mapTokensToVariables(tokens);
9
+ return createVariables(tokens);
10
10
  }
11
11
  __name(createTokens, "createTokens");
12
- const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
13
- const res = {};
14
- for (const key in tokens) {
15
- let val = tokens[key];
16
- const name = parentPath ? `${parentPath}-${key}` : key;
17
- if (val && typeof val === "object") {
18
- res[key] = mapTokensToVariables(tokens[key], name);
19
- } else {
20
- res[key] = createVariable({ val, name, key });
21
- }
22
- }
23
- return res;
24
- }, "mapTokensToVariables");
25
12
  export {
26
- createTokens,
27
- mapTokensToVariables
13
+ createTokens
28
14
  };
@@ -4,12 +4,17 @@ var _a;
4
4
  import { isWeb } from "./constants/platform";
5
5
  const IS_VARIABLE_SYMBOL = "__isVariable__";
6
6
  class Variable {
7
- constructor({ val, name, key }) {
7
+ constructor(props) {
8
8
  this[_a] = true;
9
+ this.isFloating = false;
10
+ const { val, name, key, isFloating } = props;
9
11
  this.val = isVariable(val) ? val.val : val;
10
12
  this.name = name;
11
13
  this.key = key;
12
- this.variable = isWeb ? createCSSVariable(name) : this.val;
14
+ this.variable = isWeb ? createCSSVariable(name) : "";
15
+ if (isFloating) {
16
+ this.isFloating = true;
17
+ }
13
18
  }
14
19
  toString() {
15
20
  return `${isWeb ? this.variable : this.val}`;
@@ -17,9 +22,14 @@ class Variable {
17
22
  }
18
23
  __name(Variable, "Variable");
19
24
  _a = IS_VARIABLE_SYMBOL;
20
- const createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
25
+ const createVariable = /* @__PURE__ */ __name((props) => {
26
+ if (isVariable(props)) {
27
+ return props;
28
+ }
29
+ return new Variable(props);
30
+ }, "createVariable");
21
31
  function isVariable(v) {
22
- return v instanceof Variable || v && v[IS_VARIABLE_SYMBOL];
32
+ return !!(v instanceof Variable || v && v[IS_VARIABLE_SYMBOL]);
23
33
  }
24
34
  __name(isVariable, "isVariable");
25
35
  function getVariableValue(v) {
@@ -34,12 +44,17 @@ function getVariableName(v) {
34
44
  return v;
35
45
  }
36
46
  __name(getVariableName, "getVariableName");
37
- const createCSSVariable = /* @__PURE__ */ __name((val, includeVar = true) => {
38
- const name = val.replace(/[^a-z0-9\_\-]+/i, "_");
47
+ const createCSSVariable = /* @__PURE__ */ __name((nameProp, includeVar = true) => {
48
+ if (process.env.NODE_ENV === "development") {
49
+ if (!nameProp || typeof nameProp !== "string") {
50
+ console.warn("invalid name", nameProp);
51
+ return ``;
52
+ }
53
+ }
54
+ const name = nameProp.replace(/[^a-z0-9\_\-]+/i, "_");
39
55
  return includeVar ? `var(--${name})` : name;
40
56
  }, "createCSSVariable");
41
57
  export {
42
- IS_VARIABLE_SYMBOL,
43
58
  Variable,
44
59
  createCSSVariable,
45
60
  createVariable,
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { createVariable, isVariable } from "./createVariable";
4
+ const createVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
5
+ const res = {};
6
+ for (const key in tokens) {
7
+ let val = tokens[key];
8
+ const name = parentPath ? `${parentPath}-${key}` : key;
9
+ if (isVariable(val)) {
10
+ res[key] = val;
11
+ } else if (val && typeof val === "object") {
12
+ if (Array.isArray(val)) {
13
+ res[key] = val.map((val2, i) => {
14
+ const skey = `${key}-${i}`;
15
+ const sname = parentPath ? `${name}-${skey}` : skey;
16
+ console.log("make it", val2, key, sname);
17
+ return isVariable(val2) ? val2 : createVariable({
18
+ val: val2,
19
+ key: skey,
20
+ name: sname
21
+ });
22
+ });
23
+ } else {
24
+ res[key] = createVariables(tokens[key], name);
25
+ }
26
+ } else {
27
+ res[key] = createVariable({ val, name, key });
28
+ }
29
+ }
30
+ return res;
31
+ }, "createVariables");
32
+ export {
33
+ createVariables
34
+ };
@@ -6,30 +6,6 @@ import { isVariable } from "../createVariable";
6
6
  import { expandStyle, expandStyles } from "./generateAtomicStyles";
7
7
  import { getVariantExtras } from "./getVariantExtras";
8
8
  import { isObj } from "./isObj";
9
- function getVariantFunction(variant, key, value) {
10
- if (typeof variant === "function") {
11
- return variant;
12
- }
13
- for (const cat in tokenCategories) {
14
- if (key in tokenCategories[cat]) {
15
- const spreadVariant = variant[`...${cat}`];
16
- if (spreadVariant) {
17
- return spreadVariant;
18
- }
19
- }
20
- }
21
- let fn;
22
- if (typeof value === "number") {
23
- fn = variant[":number"];
24
- } else if (typeof value === "string") {
25
- fn = variant[":string"];
26
- } else if (value === true || value === false) {
27
- fn = variant[":boolean"];
28
- }
29
- fn = fn || variant[value];
30
- return fn || variant["..."] || variant["...size"];
31
- }
32
- __name(getVariantFunction, "getVariantFunction");
33
9
  const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
34
10
  const variants = staticConfig.variants || {};
35
11
  const defaultProps = staticConfig.defaultProps || {};
@@ -40,26 +16,11 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
40
16
  return;
41
17
  }
42
18
  const props = state.fallbackProps || propsIn;
43
- const returnVariablesAs = state.resolveVariablesAs || !!props.animation ? "value" : "auto";
19
+ const returnVariablesAs = state.resolveVariablesAs === "value" || !!props.animation ? "value" : "auto";
44
20
  const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
45
- const variant = variants && variants[key];
46
- if (variant && value !== void 0) {
47
- let variantValue = getVariantFunction(variant, key, value);
48
- if (variantValue) {
49
- if (typeof variantValue === "function") {
50
- const fn = variantValue;
51
- variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps));
52
- }
53
- if (isObj(variantValue)) {
54
- variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
55
- }
56
- return Object.entries(expandStyles(variantValue));
57
- } else {
58
- if (process.env.NODE_ENV === "development") {
59
- console.warn(`No variant found: ${staticConfig.componentName || "[UnnamedComponent]"} has variant "${key}", but no matching value "${value}"`);
60
- }
61
- return null;
62
- }
21
+ const variantValue = resolveVariants(key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, "", avoidDefaultProps);
22
+ if (variantValue) {
23
+ return variantValue;
63
24
  }
64
25
  let shouldReturn = value !== void 0 && value !== null;
65
26
  if (conf.shorthands[key]) {
@@ -79,22 +40,56 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
79
40
  }, "mapper");
80
41
  return mapper;
81
42
  }, "createPropMapper");
82
- const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, resolveAs) => {
43
+ const resolveVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps = false) => {
44
+ var _a;
45
+ const variant = variants && variants[key];
46
+ if (variant && value !== void 0) {
47
+ let variantValue = getVariantDefinition(variant, key, value);
48
+ if (variantValue) {
49
+ if (typeof variantValue === "function") {
50
+ const fn = variantValue;
51
+ variantValue = fn(value, getVariantExtras(props, theme, defaultProps, avoidDefaultProps));
52
+ }
53
+ if (isObj(variantValue)) {
54
+ variantValue = resolveTokensAndVariants(key, variantValue, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps);
55
+ }
56
+ return Object.entries(expandStyles(variantValue));
57
+ } else {
58
+ if (process.env.NODE_ENV === "development") {
59
+ if ((_a = staticConfig.validStyles) == null ? void 0 : _a[key]) {
60
+ return null;
61
+ }
62
+ console.warn(`No variant found: ${staticConfig.componentName || "[UnnamedComponent]"} has variant "${key}", but no matching value "${value}"`);
63
+ }
64
+ return null;
65
+ }
66
+ }
67
+ }, "resolveVariants");
68
+ const resolveTokensAndVariants = /* @__PURE__ */ __name((key, value, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, parentVariantKey, avoidDefaultProps) => {
83
69
  var _a;
84
70
  let res = {};
85
- for (const rKey in input) {
71
+ for (const rKey in value) {
86
72
  const fKey = conf.shorthands[rKey] || rKey;
87
- const val = input[rKey];
73
+ const val = value[rKey];
88
74
  if (isVariable(val)) {
89
- res[fKey] = resolveAs === "variable" ? val : !isWeb || resolveAs === "value" ? val.val : val.variable;
75
+ res[fKey] = !isWeb || returnVariablesAs === "value" ? val.val : val.variable;
76
+ } else if (variants[fKey]) {
77
+ if (parentVariantKey === key) {
78
+ res[fKey] = val;
79
+ } else {
80
+ res = {
81
+ ...res,
82
+ ...Object.fromEntries(resolveVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps))
83
+ };
84
+ }
90
85
  } else if (typeof val === "string") {
91
- const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, resolveAs) : val;
86
+ const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily, returnVariablesAs) : val;
92
87
  res[fKey] = fVal;
93
88
  } else {
94
89
  if (isObj(val)) {
95
- res[fKey] = resolveTokens(val, conf, theme, fontFamily, resolveAs);
90
+ res[fKey] = resolveTokensAndVariants(fKey, val, props, defaultProps, theme, variants, fontFamily, conf, returnVariablesAs, staticConfig, key, avoidDefaultProps);
96
91
  } else {
97
- res[fKey] = input[fKey];
92
+ res[fKey] = value[fKey];
98
93
  }
99
94
  }
100
95
  if (process.env.NODE_ENV === "development") {
@@ -104,7 +99,31 @@ const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, re
104
99
  }
105
100
  }
106
101
  return res;
107
- }, "resolveTokens");
102
+ }, "resolveTokensAndVariants");
103
+ function getVariantDefinition(variant, key, value) {
104
+ if (typeof variant === "function") {
105
+ return variant;
106
+ }
107
+ for (const cat in tokenCategories) {
108
+ if (key in tokenCategories[cat]) {
109
+ const spreadVariant = variant[`...${cat}`];
110
+ if (spreadVariant) {
111
+ return spreadVariant;
112
+ }
113
+ }
114
+ }
115
+ let fn;
116
+ if (typeof value === "number") {
117
+ fn = variant[":number"];
118
+ } else if (typeof value === "string") {
119
+ fn = variant[":string"];
120
+ } else if (value === true || value === false) {
121
+ fn = variant[":boolean"];
122
+ }
123
+ fn = fn || variant[value];
124
+ return fn || variant["..."] || variant["...size"];
125
+ }
126
+ __name(getVariantDefinition, "getVariantDefinition");
108
127
  const fontShorthand = {
109
128
  fontSize: "size",
110
129
  fontWeight: "weight"
@@ -40,9 +40,16 @@ const generateAtomicStyles = /* @__PURE__ */ __name((style) => {
40
40
  const res = expandStyles(style);
41
41
  if (style.shadowColor != null || style.shadowOffset != null || style.shadowOpacity != null || style.shadowRadius != null) {
42
42
  boxShadowReducer(res, style);
43
+ delete res["shadowColor"];
44
+ delete res["shadowOffset"];
45
+ delete res["shadowOpacity"];
46
+ delete res["shadowRadius"];
43
47
  }
44
48
  if (style.textShadowColor != null || style.textShadowOffset != null || style.textShadowRadius != null) {
45
49
  textShadowReducer(res, style);
50
+ delete res["textShadowColor"];
51
+ delete res["textShadowOffset"];
52
+ delete res["textShadowRadius"];
46
53
  }
47
54
  const out = {};
48
55
  for (const key in res) {
@@ -95,41 +102,39 @@ function expandStyle(key, value) {
95
102
  }
96
103
  return;
97
104
  }
98
- if (isWeb) {
99
- switch (key) {
100
- case "elevation":
101
- case "overlayColor":
102
- case "resizeMode":
103
- case "tintColor": {
104
- break;
105
- }
106
- case "aspectRatio": {
107
- return [key, value.toString()];
108
- }
109
- case "backgroundClip": {
110
- if (value === "text") {
111
- return [
112
- ["backgroundClip", value],
113
- ["WebkitBackgroundClip", value]
114
- ];
115
- }
116
- break;
117
- }
118
- case "textAlignVertical": {
119
- return [["verticalAlign", value === "center" ? "middle" : value]];
120
- }
121
- case "textDecorationLine": {
122
- return ["textDecorationLine", value];
123
- }
124
- case "transform": {
125
- if (Array.isArray(value)) {
126
- return [[key, value.map(mapTransform).join(" ")]];
127
- }
128
- break;
105
+ switch (key) {
106
+ case "elevation":
107
+ case "overlayColor":
108
+ case "resizeMode":
109
+ case "tintColor": {
110
+ break;
111
+ }
112
+ case "aspectRatio": {
113
+ return [[key, value.toString()]];
114
+ }
115
+ case "backgroundClip": {
116
+ if (value === "text") {
117
+ return [
118
+ ["backgroundClip", value],
119
+ ["WebkitBackgroundClip", value]
120
+ ];
129
121
  }
130
- case "writingDirection": {
131
- return [["direction", value]];
122
+ break;
123
+ }
124
+ case "textAlignVertical": {
125
+ return [["verticalAlign", value === "center" ? "middle" : value]];
126
+ }
127
+ case "textDecorationLine": {
128
+ return [["textDecorationLine", value]];
129
+ }
130
+ case "transform": {
131
+ if (Array.isArray(value)) {
132
+ return [[key, value.map(mapTransform).join(" ")]];
132
133
  }
134
+ break;
135
+ }
136
+ case "writingDirection": {
137
+ return [["direction", value]];
133
138
  }
134
139
  }
135
140
  const longKey = STYLE_SHORT_FORM_EXPANSIONS[key];
@@ -288,8 +293,8 @@ const colorProps = {
288
293
  textShadowColor: true
289
294
  };
290
295
  function normalizeValueWithProperty(value, property) {
291
- if (isWeb) {
292
- if ((property == null || !unitlessNumbers[property]) && typeof value === "number") {
296
+ if (process.env.TAMAGUI_TARGET === "web") {
297
+ if ((property === void 0 || property === null || !unitlessNumbers[property]) && typeof value === "number") {
293
298
  return `${value}px`;
294
299
  }
295
300
  }
@@ -303,7 +308,7 @@ const normalizeColor = /* @__PURE__ */ __name((color, opacity = 1) => {
303
308
  if (color == null || color == void 0) {
304
309
  return;
305
310
  }
306
- if (isWeb) {
311
+ if (process.env.TAMAGUI_TARGET === "web") {
307
312
  if (typeof color === "string" && isWebColor(color)) {
308
313
  return color;
309
314
  }
@@ -7,7 +7,7 @@ import { isClient, isWeb, useIsomorphicLayoutEffect } from "../constants/platfor
7
7
  import { mediaQueryConfig, mediaState } from "../hooks/useMedia";
8
8
  import { createMediaStyle } from "./createMediaStyle";
9
9
  import { fixNativeShadow } from "./fixNativeShadow";
10
- import { getStylesAtomic } from "./getStylesAtomic";
10
+ import { getStylesAtomic, psuedoCNInverse } from "./getStylesAtomic";
11
11
  import {
12
12
  insertStyleRule,
13
13
  insertedTransforms,
@@ -114,12 +114,43 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
114
114
  for (const key in valInit) {
115
115
  if (usedKeys.has(key))
116
116
  continue;
117
- style[key] = valInit;
117
+ if (valInit && typeof valInit === "object") {
118
+ for (const skey in valInit) {
119
+ if (usedKeys.has(skey))
120
+ continue;
121
+ usedKeys.add(skey);
122
+ style[skey] = valInit[skey];
123
+ }
124
+ } else {
125
+ usedKeys.add(key);
126
+ style[key] = valInit;
127
+ }
118
128
  }
119
129
  continue;
120
130
  }
121
131
  if (keyInit === "className") {
122
- mergeClassName(keyInit, valInit);
132
+ let nonTamaguis = "";
133
+ for (const cn of valInit.split(" ")) {
134
+ if (cn[0] === "_") {
135
+ const [shorthand, mediaOrPsuedo, rest] = cn.slice(1).split("-");
136
+ let fullKey = conf.shorthands[shorthand];
137
+ if (mediaOrPsuedo[0] === "_") {
138
+ let mediaShortKey = mediaOrPsuedo.slice(1);
139
+ mediaShortKey = mediaShortKey.slice(0, mediaShortKey.indexOf("_"));
140
+ fullKey += `-${mediaShortKey}`;
141
+ } else if (mediaOrPsuedo[0] === "0") {
142
+ const pseudoShortKey = mediaOrPsuedo.slice(1);
143
+ fullKey += `-${psuedoCNInverse[pseudoShortKey]}`;
144
+ }
145
+ usedKeys.add(fullKey);
146
+ mergeClassName(fullKey, cn);
147
+ } else {
148
+ nonTamaguis += " " + cn;
149
+ }
150
+ }
151
+ if (nonTamaguis) {
152
+ mergeClassName(keyInit, nonTamaguis);
153
+ }
123
154
  continue;
124
155
  }
125
156
  if (validStyleProps[keyInit] && valInit && valInit[0] === "_") {
@@ -196,7 +227,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
196
227
  const mediaStyles = getStylesAtomic(mediaStyle);
197
228
  for (const style2 of mediaStyles) {
198
229
  const out = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
199
- const fullKey = `${out.identifier}-${mediaKey}`;
230
+ const fullKey = `${style2.property}-${mediaKeyShort}`;
200
231
  if (!usedKeys.has(fullKey)) {
201
232
  usedKeys.add(fullKey);
202
233
  addStyle(out.identifier, out.styleRule);
@@ -291,7 +322,7 @@ const insertSplitStyles = /* @__PURE__ */ __name((...args) => {
291
322
  }
292
323
  return res;
293
324
  }, "insertSplitStyles");
294
- const effect = useInsertionEffect || useIsomorphicLayoutEffect;
325
+ const effect = isWeb ? useInsertionEffect || useIsomorphicLayoutEffect : useIsomorphicLayoutEffect;
295
326
  const useSplitStyles = /* @__PURE__ */ __name((...args) => {
296
327
  const res = getSplitStyles(...args);
297
328
  effect(() => {
@@ -1,6 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { getVariableValue, isVariable } from "@tamagui/core";
3
+ import { getVariableValue, isVariable } from "../createVariable";
4
4
  const getSizeScaledToFont = /* @__PURE__ */ __name((val, { sizeX = 1, sizeY = 1 }, { tokens, props, fonts }) => {
5
5
  var _a, _b, _c, _d, _e, _f;
6
6
  const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : val) != null ? _b : tokens.size["$4"]) != null ? _c : 14;
@@ -20,6 +20,11 @@ const pseudos = {
20
20
  }
21
21
  };
22
22
  const pseudosOrdered = Object.values(pseudos);
23
+ const psuedoCNInverse = {
24
+ hover: "hoverStyle",
25
+ focus: "focusStyle",
26
+ press: "pressStyle"
27
+ };
23
28
  function getStylesAtomic(stylesIn, options = {}) {
24
29
  const { hoverStyle, pressStyle, focusStyle, ...base } = stylesIn;
25
30
  let res = [];
@@ -113,5 +118,6 @@ const borderDefaults = {
113
118
  };
114
119
  export {
115
120
  getStylesAtomic,
116
- pseudos
121
+ pseudos,
122
+ psuedoCNInverse
117
123
  };
@@ -28,6 +28,8 @@ __name(addTransform, "addTransform");
28
28
  const isClient = typeof document !== "undefined";
29
29
  let hasInsertedSinceUpdate = true;
30
30
  function updateInserted() {
31
+ if (process.env.NODE_ENV === "test")
32
+ return;
31
33
  if (!isClient)
32
34
  return;
33
35
  if (!hasInsertedSinceUpdate) {
@@ -43,7 +43,7 @@ if (process.env.NODE_ENV === "development") {
43
43
  const fontOpt = {
44
44
  style: ow.optional.object.valuesOfType(ow.string),
45
45
  transform: ow.optional.object.valuesOfType(ow.string),
46
- color: ow.optional.object.valuesOfType(ow.string)
46
+ color: ow.optional.object.valuesOfType(ow.any(ow.string, ow.object))
47
47
  };
48
48
  Config = ow.object.exactShape({
49
49
  defaultTheme: ow.optional.string,
@@ -65,7 +65,7 @@ if (process.env.NODE_ENV === "development") {
65
65
  space: ow.object.nonEmpty.valuesOfType(ow.number),
66
66
  zIndex: ow.object.nonEmpty.valuesOfType(ow.number),
67
67
  radius: ow.object.nonEmpty.valuesOfType(ow.number),
68
- color: ow.object.nonEmpty.valuesOfType(ow.string)
68
+ color: ow.object.nonEmpty.valuesOfType(ow.any(ow.string, ow.object))
69
69
  });
70
70
  }
71
71
  export {
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useIsomorphicLayoutEffect } from "@tamagui/core";
4
3
  import { useRef } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../constants/platform";
5
5
  function useIsMounted() {
6
6
  const isMounted = useRef(false);
7
7
  useIsomorphicLayoutEffect(() => {
package/dist/jsx/index.js CHANGED
@@ -4,8 +4,9 @@ export * from "./createShorthands";
4
4
  export * from "./createTheme";
5
5
  export * from "./createTamagui";
6
6
  export * from "./createFont";
7
- import { createTokens } from "./createTokens";
7
+ export * from "./createTokens";
8
8
  export * from "./createVariable";
9
+ export * from "./createVariables";
9
10
  export * from "./styled";
10
11
  export * from "./types";
11
12
  import { RNWTextProps, RNWViewProps } from "./types-rnw";
@@ -48,7 +49,6 @@ export * from "@tamagui/helpers";
48
49
  export {
49
50
  RNWTextProps,
50
51
  RNWViewProps,
51
- createTokens,
52
52
  getConfig,
53
53
  getHasConfigured,
54
54
  getThemes,
@@ -4,6 +4,11 @@ import { Image, Text, TextInput } from "react-native";
4
4
  import { createComponent } from "./createComponent";
5
5
  import { RNComponents } from "./helpers/RNComponents";
6
6
  function styled(Component, options, staticExtractionOptions) {
7
+ if (process.env.NODE_ENV === "development") {
8
+ if (Component["staticConfig"] && Component["staticConfig"].isExtractable) {
9
+ console.warn(`Warning: Wrapping styled() around an extractable HOC component isn't allowed yet. Support for this is on the roadmap, see: https://github.com/tamagui/tamagui/issues/88.`);
10
+ }
11
+ }
7
12
  const staticConfigProps = (() => {
8
13
  var _a;
9
14
  if (options) {
@@ -8,13 +8,14 @@ React["createElement"];
8
8
  const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
9
9
  var _a, _b;
10
10
  const { name, theme, themeManager, themes, className } = useChangeThemeEffect(props.name, props.componentName, props);
11
- if (!themes || !name || !theme) {
11
+ const missingTheme = !themes || !name || !theme;
12
+ const contents = useMemo(() => missingTheme ? null : wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
13
+ if (missingTheme) {
12
14
  if (name && !theme && process.env.NODE_ENV === "development") {
13
15
  console.warn(`No theme found by name ${name}`);
14
16
  }
15
17
  return props.children;
16
18
  }
17
- const contents = useMemo(() => wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
18
19
  if (isWeb) {
19
20
  return <span className={[
20
21
  `tui_Theme`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.1-beta.48",
3
+ "version": "1.0.1-beta.49",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -21,10 +21,10 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@expo/match-media": "^0.3.0",
24
- "@tamagui/helpers": "^1.0.1-beta.48",
24
+ "@tamagui/helpers": "^1.0.1-beta.49",
25
25
  "@tamagui/ow": "^0.28.1",
26
- "@tamagui/use-debounce": "^1.0.1-beta.48",
27
- "@tamagui/use-force-update": "^1.0.1-beta.48",
26
+ "@tamagui/use-debounce": "^1.0.1-beta.49",
27
+ "@tamagui/use-force-update": "^1.0.1-beta.49",
28
28
  "expo-screen-orientation": "^4.2.0",
29
29
  "hyphenate-style-name": "^1.0.4",
30
30
  "inline-style-prefixer": "^6.0.0",
@@ -36,7 +36,7 @@
36
36
  "react-native-web": "*"
37
37
  },
38
38
  "devDependencies": {
39
- "@tamagui/build": "^1.0.1-beta.48",
39
+ "@tamagui/build": "^1.0.1-beta.49",
40
40
  "@types/react": "^17.0.35",
41
41
  "csstype": "^3.0.10",
42
42
  "esbuild": "^0.14.36",
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../src/ThemeManager.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAE7C,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,YAAY,EAAE,YAAY,KAAK,IAAI,CAAA;AAE9E,oBAAY,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ,CAAA;AAED,oBAAY,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,qBAAa,YAAY;;IAOd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,WAAW,GAAG,IAAI;IACzB,aAAa,EAAE,YAAY,GAAG,IAAI;IAClC,KAAK,EAAE,OAAO;IATvB,IAAI,wBAA8B;IAClC,SAAS,qBAA2B;IACpC,cAAc,qBAA2B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAO;gBAGtB,IAAI,GAAE,MAAW,EACjB,KAAK,GAAE,WAAW,GAAG,IAAW,EAChC,aAAa,GAAE,YAAY,GAAG,IAAW,EACzC,KAAK,GAAE,OAAe;IAqB/B,IAAI,UAAU,kBAEb;IAED,IAAI,QAAQ,IAAI,MAAM,CAMrB;IAGD,QAAQ,CAAC,GAAG,EAAE,MAAM;IAmBpB,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAE,mBAAwB;IAa3D,YAAY,CAAC,KAAK,GAAE,iBAAsB,EAAE,KAAK,CAAC,EAAE,GAAG;;;;;;;;;;;;;IAsFvD,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC;IAKlC,eAAe;IAYf,aAAa,CAAC,EAAE,EAAE,aAAa;IAO/B,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ;CAOjC;AAED,eAAO,MAAM,mBAAmB,8CAA2C,CAAA;AAC3E,eAAO,MAAM,YAAY,cAAqB,CAAA"}
1
+ {"version":3,"file":"ThemeManager.d.ts","sourceRoot":"","sources":["../src/ThemeManager.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAE7C,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,YAAY,EAAE,YAAY,KAAK,IAAI,CAAA;AAE9E,oBAAY,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ,CAAA;AAED,oBAAY,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,qBAAa,YAAY;;IAOd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,WAAW,GAAG,IAAI;IACzB,aAAa,EAAE,YAAY,GAAG,IAAI;IAClC,KAAK,EAAE,OAAO;IATvB,IAAI,wBAA8B;IAClC,SAAS,qBAA2B;IACpC,cAAc,qBAA2B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAO;gBAGtB,IAAI,GAAE,MAAW,EACjB,KAAK,GAAE,WAAW,GAAG,IAAW,EAChC,aAAa,GAAE,YAAY,GAAG,IAAW,EACzC,KAAK,GAAE,OAAe;IAqB/B,IAAI,UAAU,kBAEb;IAED,IAAI,QAAQ,IAAI,MAAM,CAMrB;IAGD,QAAQ,CAAC,GAAG,EAAE,MAAM;IAmBpB,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAE,mBAAwB;IAa3D,YAAY,CAAC,KAAK,GAAE,iBAAsB,EAAE,KAAK,CAAC,EAAE,GAAG;;;;;;;;;;;;;IAwFvD,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC;IAKlC,eAAe;IAYf,aAAa,CAAC,EAAE,EAAE,aAAa;IAO/B,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ;CAOjC;AAED,eAAO,MAAM,mBAAmB,8CAA2C,CAAA;AAC3E,eAAO,MAAM,YAAY,cAAqB,CAAA"}
package/types/conf.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare const getConfig: () => TamaguiInternalConfig<import("./types").Cr
16
16
  }, {
17
17
  [key: string]: import("./types").GenericFont<string | number>;
18
18
  }>;
19
- export declare const getTokens: () => import("./types").CreateTokens<import("./createVariable").Variable>;
19
+ export declare const getTokens: () => import("./types").CreateTokens<import("./createVariable").Variable<any>>;
20
20
  export declare const getThemes: () => {
21
21
  [key: string]: Partial<import("./types").TamaguiBaseTheme> & {
22
22
  [key: string]: import("./types").VariableVal;
@@ -1 +1 @@
1
- {"version":3,"file":"conf.d.ts","sourceRoot":"","sources":["../src/conf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI/D,eAAO,MAAM,SAAS,SAAU,qBAAqB,SAMpD,CAAA;AAED,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;EAAc,CAAA;AACpC,eAAO,MAAM,SAAS,2EAA2B,CAAA;AACjD,eAAO,MAAM,SAAS;;;;CAAqB,CAAA;AAE3C,eAAO,MAAM,eAAe,qBAA4B,CAAA;AAExD,eAAO,MAAM,gBAAgB,OAAQ,cAAc,SAUlD,CAAA"}
1
+ {"version":3,"file":"conf.d.ts","sourceRoot":"","sources":["../src/conf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAI/D,eAAO,MAAM,SAAS,SAAU,qBAAqB,SAMpD,CAAA;AAED,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAC5C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;EAAc,CAAA;AACpC,eAAO,MAAM,SAAS,gFAA2B,CAAA;AACjD,eAAO,MAAM,SAAS;;;;CAAqB,CAAA;AAE3C,eAAO,MAAM,eAAe,qBAA4B,CAAA;AAExD,eAAO,MAAM,gBAAgB,OAAQ,cAAc,SAMlD,CAAA"}
@@ -25,5 +25,6 @@ export declare type SpacedChildrenProps = {
25
25
  };
26
26
  export declare function spacedChildren({ isZStack, children, space, direction, spaceFlex, separator, }: SpacedChildrenProps): any;
27
27
  export declare function AbsoluteFill(props: any): JSX.Element;
28
+ export declare function assignNativePropsToWeb(elementType: string, viewProps: any, nativeProps: any): void;
28
29
  export {};
29
30
  //# sourceMappingURL=createComponent.d.ts.map