@tamagui/web 3.0.0-beta.739.1 → 3.0.0-beta.748.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.
Files changed (40) hide show
  1. package/dist/cjs/helpers/directStyle.cjs +45 -1
  2. package/dist/cjs/helpers/directStyle.native.cjs +49 -1
  3. package/dist/cjs/helpers/directStyle.native.js +49 -1
  4. package/dist/cjs/helpers/directStyle.native.js.map +1 -1
  5. package/dist/cjs/helpers/propMapper.cjs +15 -0
  6. package/dist/cjs/helpers/propMapper.native.cjs +28 -0
  7. package/dist/cjs/helpers/propMapper.native.js +28 -0
  8. package/dist/cjs/helpers/propMapper.native.js.map +1 -1
  9. package/dist/cjs/hooks/useComponentState.cjs +19 -1
  10. package/dist/cjs/hooks/useComponentState.native.cjs +19 -1
  11. package/dist/cjs/hooks/useComponentState.native.js +19 -1
  12. package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
  13. package/dist/esm/helpers/directStyle.mjs +45 -2
  14. package/dist/esm/helpers/directStyle.mjs.map +1 -1
  15. package/dist/esm/helpers/directStyle.native.js +49 -2
  16. package/dist/esm/helpers/directStyle.native.js.map +1 -1
  17. package/dist/esm/helpers/propMapper.mjs +16 -1
  18. package/dist/esm/helpers/propMapper.mjs.map +1 -1
  19. package/dist/esm/helpers/propMapper.native.js +29 -1
  20. package/dist/esm/helpers/propMapper.native.js.map +1 -1
  21. package/dist/esm/hooks/useComponentState.mjs +19 -1
  22. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  23. package/dist/esm/hooks/useComponentState.native.js +19 -1
  24. package/dist/esm/hooks/useComponentState.native.js.map +1 -1
  25. package/package.json +15 -15
  26. package/src/helpers/directStyle.ts +134 -10
  27. package/src/helpers/propMapper.ts +33 -1
  28. package/src/hooks/useComponentState.ts +24 -1
  29. package/src/styled.tsx +15 -5
  30. package/src/types.tsx +50 -10
  31. package/types/dom/html.d.ts +49 -49
  32. package/types/dom/html.native.d.ts +46 -46
  33. package/types/helpers/directStyle.d.ts +1 -0
  34. package/types/helpers/directStyle.d.ts.map +1 -1
  35. package/types/helpers/propMapper.d.ts.map +1 -1
  36. package/types/hooks/useComponentState.d.ts.map +1 -1
  37. package/types/styled.d.ts +5 -4
  38. package/types/styled.d.ts.map +1 -1
  39. package/types/types.d.ts +35 -10
  40. package/types/types.d.ts.map +1 -1
@@ -28,6 +28,7 @@ __export(directStyle_exports, {
28
28
  directStyleSignature: () => directStyleSignature,
29
29
  flushDirectStyles: () => flushDirectStyles,
30
30
  getDirectDynamicThemeAccess: () => getDirectDynamicThemeAccess,
31
+ isConditionalStyleObject: () => isConditionalStyleObject,
31
32
  platformMatches: () => platformMatches,
32
33
  resolveClauseChain: () => resolveClauseChain
33
34
  });
@@ -96,11 +97,14 @@ const directStyleHandler = {
96
97
  }
97
98
  if (process.env.NODE_ENV === "development" && !hasBase && result & 4 && (property in import_helpers.tokenCategories.color || property in import_tokenCategories.tokenCategoryByProperty) && splitComponents(source.slice(lastPayloadStart)).length > 1) (0, import_warnOnce.warnOnce)(`${property}="${source}" has multiple values after its first conditional. Write the base value before the first conditional.`);
98
99
  if ((!import_constants.isWeb || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
99
- const value = property === "opacity" ? 1 : property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
100
+ const value = implicitLifecycleBase(property);
100
101
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
101
102
  }
102
103
  }
103
104
  };
105
+ function implicitLifecycleBase(property) {
106
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
107
+ }
104
108
  const legacyTransformParts = /* @__PURE__ */ new Set([
105
109
  "matrix",
106
110
  "perspective",
@@ -888,9 +892,48 @@ function contributeFrontendValue(state, property, value, merge, contextOnly = fa
888
892
  }
889
893
  return true;
890
894
  }
895
+ function isConditionalStyleObject(state, value) {
896
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
897
+ for (const key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
898
+ return false;
899
+ }
891
900
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue, contextOnly = false) {
901
+ if (value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
902
+ for (const key in value) {
903
+ const payload = value[key];
904
+ if (payload == null) continue;
905
+ const source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
906
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
907
+ }
908
+ return;
909
+ }
892
910
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
893
911
  }
912
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
913
+ if (!isConditionalStyleObject(state, value)) return false;
914
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
915
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
916
+ return true;
917
+ }
918
+ let hasBase = false;
919
+ const base = value.default;
920
+ if (base != null) {
921
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
922
+ hasBase = true;
923
+ }
924
+ let conditions = 0;
925
+ for (const key in value) {
926
+ if (key === "default") continue;
927
+ const payload = value[key];
928
+ if (payload == null) continue;
929
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
930
+ }
931
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
932
+ const resting = implicitLifecycleBase(property);
933
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
934
+ }
935
+ return true;
936
+ }
894
937
  function contributeStyleValue(state, property, value, merge, originalValue, contextOnly = false) {
895
938
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
896
939
  const expanded = (0, import_resolveSafeArea.expandSafeAreaValue)(property);
@@ -901,6 +944,7 @@ function contributeStyleValue(state, property, value, merge, originalValue, cont
901
944
  }
902
945
  }
903
946
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
947
+ if (value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && contributeStyleObject(state, property, value, merge, contextOnly)) return true;
904
948
  if (value != null) {
905
949
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue ?? value, contextOnly);
906
950
  return true;
@@ -30,6 +30,7 @@ __export(directStyle_exports, {
30
30
  directStyleSignature: () => directStyleSignature,
31
31
  flushDirectStyles: () => flushDirectStyles,
32
32
  getDirectDynamicThemeAccess: () => getDirectDynamicThemeAccess,
33
+ isConditionalStyleObject: () => isConditionalStyleObject,
33
34
  platformMatches: () => platformMatches,
34
35
  resolveClauseChain: () => resolveClauseChain
35
36
  });
@@ -54,6 +55,10 @@ var import_resolveSafeArea = require("./resolveSafeArea.native.js");
54
55
  var import_resolveVariableValue = require("./resolveVariableValue.native.js");
55
56
  var import_themeRef = require("./themeRef.native.js");
56
57
  var import_transformsToString = require("./transformsToString.native.js");
58
+ function _type_of(obj) {
59
+ "@swc/helpers - typeof";
60
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
61
+ }
57
62
  var directStyleHandler = {
58
63
  segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid, chainCount, _result, failure, failureIndex, property, merge, originalValue, contextOnly) {
59
64
  if (isBase) {
@@ -98,11 +103,14 @@ var directStyleHandler = {
98
103
  }
99
104
  if (process.env.NODE_ENV === "development" && !hasBase && result & 4 && (property in import_helpers.tokenCategories.color || property in import_tokenCategories.tokenCategoryByProperty) && splitComponents(source.slice(lastPayloadStart)).length > 1) (0, import_warnOnce.warnOnce)(`${property}="${source}" has multiple values after its first conditional. Write the base value before the first conditional.`);
100
105
  if ((!import_constants.isWeb || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
101
- var value = property === "opacity" ? 1 : property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
106
+ var value = implicitLifecycleBase(property);
102
107
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
103
108
  }
104
109
  }
105
110
  };
111
+ function implicitLifecycleBase(property) {
112
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
113
+ }
106
114
  var legacyTransformParts = /* @__PURE__ */ new Set([
107
115
  "matrix",
108
116
  "perspective",
@@ -1070,10 +1078,49 @@ function contributeFrontendValue(state, property, value, merge) {
1070
1078
  }
1071
1079
  return true;
1072
1080
  }
1081
+ function isConditionalStyleObject(state, value) {
1082
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
1083
+ for (var key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
1084
+ return false;
1085
+ }
1073
1086
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue) {
1074
1087
  var contextOnly = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
1088
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
1089
+ for (var key in value) {
1090
+ var payload = value[key];
1091
+ if (payload == null) continue;
1092
+ var source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
1093
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
1094
+ }
1095
+ return;
1096
+ }
1075
1097
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
1076
1098
  }
1099
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
1100
+ if (!isConditionalStyleObject(state, value)) return false;
1101
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
1102
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
1103
+ return true;
1104
+ }
1105
+ var hasBase = false;
1106
+ var base = value.default;
1107
+ if (base != null) {
1108
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
1109
+ hasBase = true;
1110
+ }
1111
+ var conditions = 0;
1112
+ for (var key in value) {
1113
+ if (key === "default") continue;
1114
+ var payload = value[key];
1115
+ if (payload == null) continue;
1116
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
1117
+ }
1118
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
1119
+ var resting = implicitLifecycleBase(property);
1120
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
1121
+ }
1122
+ return true;
1123
+ }
1077
1124
  function contributeStyleValue(state, property, value, merge, originalValue) {
1078
1125
  var contextOnly = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;
1079
1126
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
@@ -1100,6 +1147,7 @@ function contributeStyleValue(state, property, value, merge, originalValue) {
1100
1147
  }
1101
1148
  }
1102
1149
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
1150
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && contributeStyleObject(state, property, value, merge, contextOnly)) return true;
1103
1151
  if (value != null) {
1104
1152
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue !== null && originalValue !== void 0 ? originalValue : value, contextOnly);
1105
1153
  return true;
@@ -30,6 +30,7 @@ __export(directStyle_exports, {
30
30
  directStyleSignature: () => directStyleSignature,
31
31
  flushDirectStyles: () => flushDirectStyles,
32
32
  getDirectDynamicThemeAccess: () => getDirectDynamicThemeAccess,
33
+ isConditionalStyleObject: () => isConditionalStyleObject,
33
34
  platformMatches: () => platformMatches,
34
35
  resolveClauseChain: () => resolveClauseChain
35
36
  });
@@ -54,6 +55,10 @@ var import_resolveSafeArea = require("./resolveSafeArea.native.js");
54
55
  var import_resolveVariableValue = require("./resolveVariableValue.native.js");
55
56
  var import_themeRef = require("./themeRef.native.js");
56
57
  var import_transformsToString = require("./transformsToString.native.js");
58
+ function _type_of(obj) {
59
+ "@swc/helpers - typeof";
60
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
61
+ }
57
62
  var directStyleHandler = {
58
63
  segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid, chainCount, _result, failure, failureIndex, property, merge, originalValue, contextOnly) {
59
64
  if (isBase) {
@@ -98,11 +103,14 @@ var directStyleHandler = {
98
103
  }
99
104
  if (process.env.NODE_ENV === "development" && !hasBase && result & 4 && (property in import_helpers.tokenCategories.color || property in import_tokenCategories.tokenCategoryByProperty) && splitComponents(source.slice(lastPayloadStart)).length > 1) (0, import_warnOnce.warnOnce)(`${property}="${source}" has multiple values after its first conditional. Write the base value before the first conditional.`);
100
105
  if ((!import_constants.isWeb || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
101
- var value = property === "opacity" ? 1 : property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
106
+ var value = implicitLifecycleBase(property);
102
107
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
103
108
  }
104
109
  }
105
110
  };
111
+ function implicitLifecycleBase(property) {
112
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
113
+ }
106
114
  var legacyTransformParts = /* @__PURE__ */ new Set([
107
115
  "matrix",
108
116
  "perspective",
@@ -1070,10 +1078,49 @@ function contributeFrontendValue(state, property, value, merge) {
1070
1078
  }
1071
1079
  return true;
1072
1080
  }
1081
+ function isConditionalStyleObject(state, value) {
1082
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
1083
+ for (var key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
1084
+ return false;
1085
+ }
1073
1086
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue) {
1074
1087
  var contextOnly = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
1088
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
1089
+ for (var key in value) {
1090
+ var payload = value[key];
1091
+ if (payload == null) continue;
1092
+ var source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
1093
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
1094
+ }
1095
+ return;
1096
+ }
1075
1097
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
1076
1098
  }
1099
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
1100
+ if (!isConditionalStyleObject(state, value)) return false;
1101
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
1102
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
1103
+ return true;
1104
+ }
1105
+ var hasBase = false;
1106
+ var base = value.default;
1107
+ if (base != null) {
1108
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
1109
+ hasBase = true;
1110
+ }
1111
+ var conditions = 0;
1112
+ for (var key in value) {
1113
+ if (key === "default") continue;
1114
+ var payload = value[key];
1115
+ if (payload == null) continue;
1116
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
1117
+ }
1118
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
1119
+ var resting = implicitLifecycleBase(property);
1120
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
1121
+ }
1122
+ return true;
1123
+ }
1077
1124
  function contributeStyleValue(state, property, value, merge, originalValue) {
1078
1125
  var contextOnly = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;
1079
1126
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
@@ -1100,6 +1147,7 @@ function contributeStyleValue(state, property, value, merge, originalValue) {
1100
1147
  }
1101
1148
  }
1102
1149
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
1150
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && contributeStyleObject(state, property, value, merge, contextOnly)) return true;
1103
1151
  if (value != null) {
1104
1152
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue !== null && originalValue !== void 0 ? originalValue : value, contextOnly);
1105
1153
  return true;