@tamagui/web 3.0.0-beta.739.1 → 3.0.0-beta.745.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.
@@ -96,11 +96,14 @@ const directStyleHandler = {
96
96
  }
97
97
  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
98
  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;
99
+ const value = implicitLifecycleBase(property);
100
100
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
101
101
  }
102
102
  }
103
103
  };
104
+ function implicitLifecycleBase(property) {
105
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
106
+ }
104
107
  const legacyTransformParts = /* @__PURE__ */ new Set([
105
108
  "matrix",
106
109
  "perspective",
@@ -888,9 +891,48 @@ function contributeFrontendValue(state, property, value, merge, contextOnly = fa
888
891
  }
889
892
  return true;
890
893
  }
894
+ function isConditionalStyleObject(state, value) {
895
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
896
+ for (const key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
897
+ return false;
898
+ }
891
899
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue, contextOnly = false) {
900
+ if (value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
901
+ for (const key in value) {
902
+ const payload = value[key];
903
+ if (payload == null) continue;
904
+ const source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
905
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
906
+ }
907
+ return;
908
+ }
892
909
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
893
910
  }
911
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
912
+ if (!isConditionalStyleObject(state, value)) return false;
913
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
914
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
915
+ return true;
916
+ }
917
+ let hasBase = false;
918
+ const base = value.default;
919
+ if (base != null) {
920
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
921
+ hasBase = true;
922
+ }
923
+ let conditions = 0;
924
+ for (const key in value) {
925
+ if (key === "default") continue;
926
+ const payload = value[key];
927
+ if (payload == null) continue;
928
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
929
+ }
930
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
931
+ const resting = implicitLifecycleBase(property);
932
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
933
+ }
934
+ return true;
935
+ }
894
936
  function contributeStyleValue(state, property, value, merge, originalValue, contextOnly = false) {
895
937
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
896
938
  const expanded = (0, import_resolveSafeArea.expandSafeAreaValue)(property);
@@ -901,6 +943,7 @@ function contributeStyleValue(state, property, value, merge, originalValue, cont
901
943
  }
902
944
  }
903
945
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
946
+ if (value && typeof value === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && contributeStyleObject(state, property, value, merge, contextOnly)) return true;
904
947
  if (value != null) {
905
948
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue ?? value, contextOnly);
906
949
  return true;
@@ -54,6 +54,10 @@ var import_resolveSafeArea = require("./resolveSafeArea.native.js");
54
54
  var import_resolveVariableValue = require("./resolveVariableValue.native.js");
55
55
  var import_themeRef = require("./themeRef.native.js");
56
56
  var import_transformsToString = require("./transformsToString.native.js");
57
+ function _type_of(obj) {
58
+ "@swc/helpers - typeof";
59
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
60
+ }
57
61
  var directStyleHandler = {
58
62
  segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid, chainCount, _result, failure, failureIndex, property, merge, originalValue, contextOnly) {
59
63
  if (isBase) {
@@ -98,11 +102,14 @@ var directStyleHandler = {
98
102
  }
99
103
  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
104
  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;
105
+ var value = implicitLifecycleBase(property);
102
106
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
103
107
  }
104
108
  }
105
109
  };
110
+ function implicitLifecycleBase(property) {
111
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
112
+ }
106
113
  var legacyTransformParts = /* @__PURE__ */ new Set([
107
114
  "matrix",
108
115
  "perspective",
@@ -1070,10 +1077,49 @@ function contributeFrontendValue(state, property, value, merge) {
1070
1077
  }
1071
1078
  return true;
1072
1079
  }
1080
+ function isConditionalStyleObject(state, value) {
1081
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
1082
+ for (var key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
1083
+ return false;
1084
+ }
1073
1085
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue) {
1074
1086
  var contextOnly = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
1087
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
1088
+ for (var key in value) {
1089
+ var payload = value[key];
1090
+ if (payload == null) continue;
1091
+ var source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
1092
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
1093
+ }
1094
+ return;
1095
+ }
1075
1096
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
1076
1097
  }
1098
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
1099
+ if (!isConditionalStyleObject(state, value)) return false;
1100
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
1101
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
1102
+ return true;
1103
+ }
1104
+ var hasBase = false;
1105
+ var base = value.default;
1106
+ if (base != null) {
1107
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
1108
+ hasBase = true;
1109
+ }
1110
+ var conditions = 0;
1111
+ for (var key in value) {
1112
+ if (key === "default") continue;
1113
+ var payload = value[key];
1114
+ if (payload == null) continue;
1115
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
1116
+ }
1117
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
1118
+ var resting = implicitLifecycleBase(property);
1119
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
1120
+ }
1121
+ return true;
1122
+ }
1077
1123
  function contributeStyleValue(state, property, value, merge, originalValue) {
1078
1124
  var contextOnly = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;
1079
1125
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
@@ -1100,6 +1146,7 @@ function contributeStyleValue(state, property, value, merge, originalValue) {
1100
1146
  }
1101
1147
  }
1102
1148
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
1149
+ 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
1150
  if (value != null) {
1104
1151
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue !== null && originalValue !== void 0 ? originalValue : value, contextOnly);
1105
1152
  return true;
@@ -54,6 +54,10 @@ var import_resolveSafeArea = require("./resolveSafeArea.native.js");
54
54
  var import_resolveVariableValue = require("./resolveVariableValue.native.js");
55
55
  var import_themeRef = require("./themeRef.native.js");
56
56
  var import_transformsToString = require("./transformsToString.native.js");
57
+ function _type_of(obj) {
58
+ "@swc/helpers - typeof";
59
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
60
+ }
57
61
  var directStyleHandler = {
58
62
  segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid, chainCount, _result, failure, failureIndex, property, merge, originalValue, contextOnly) {
59
63
  if (isBase) {
@@ -98,11 +102,14 @@ var directStyleHandler = {
98
102
  }
99
103
  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
104
  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;
105
+ var value = implicitLifecycleBase(property);
102
106
  if (value !== null) emitValue(state, property, value, 0, "", void 0, "", "", merge, value, contextOnly);
103
107
  }
104
108
  }
105
109
  };
110
+ function implicitLifecycleBase(property) {
111
+ return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
112
+ }
106
113
  var legacyTransformParts = /* @__PURE__ */ new Set([
107
114
  "matrix",
108
115
  "perspective",
@@ -1070,10 +1077,49 @@ function contributeFrontendValue(state, property, value, merge) {
1070
1077
  }
1071
1078
  return true;
1072
1079
  }
1080
+ function isConditionalStyleObject(state, value) {
1081
+ if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
1082
+ for (var key in value) return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length);
1083
+ return false;
1084
+ }
1073
1085
  function contributeVariantClauseValue(state, property, value, conditionSource, merge, originalValue) {
1074
1086
  var contextOnly = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
1087
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && !Array.isArray(value) && !(0, import_createVariable.isVariable)(value) && isConditionalStyleObject(state, value)) {
1088
+ for (var key in value) {
1089
+ var payload = value[key];
1090
+ if (payload == null) continue;
1091
+ var source = key === "default" ? conditionSource : `${conditionSource}:${key}`;
1092
+ resolveClauseChain(state, source, 0, source.length, property, payload, merge, payload, contextOnly, -1, -1, 2);
1093
+ }
1094
+ return;
1095
+ }
1075
1096
  resolveClauseChain(state, conditionSource, 0, conditionSource.length, property, value, merge, originalValue, contextOnly, -1, -1, 2);
1076
1097
  }
1098
+ function contributeStyleObject(state, property, value, merge, contextOnly) {
1099
+ if (!isConditionalStyleObject(state, value)) return false;
1100
+ if (import_constants.isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
1101
+ if (process.env.NODE_ENV === "development") (0, import_warnOnce.warnOnce)(`conditional "${property}" needs its composite property; dropping it`);
1102
+ return true;
1103
+ }
1104
+ var hasBase = false;
1105
+ var base = value.default;
1106
+ if (base != null) {
1107
+ emitValue(state, property, base, 0, "", void 0, "", "", merge, base, contextOnly);
1108
+ hasBase = true;
1109
+ }
1110
+ var conditions = 0;
1111
+ for (var key in value) {
1112
+ if (key === "default") continue;
1113
+ var payload = value[key];
1114
+ if (payload == null) continue;
1115
+ conditions |= resolveClauseChain(state, key, 0, key.length, property, payload, merge, payload, contextOnly, -1, -1, 1);
1116
+ }
1117
+ if ((!import_constants.isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
1118
+ var resting = implicitLifecycleBase(property);
1119
+ if (resting !== null) emitValue(state, property, resting, 0, "", void 0, "", "", merge, resting, contextOnly);
1120
+ }
1121
+ return true;
1122
+ }
1077
1123
  function contributeStyleValue(state, property, value, merge, originalValue) {
1078
1124
  var contextOnly = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : false;
1079
1125
  if (value === "safe" && (0, import_resolveSafeArea.isSafeAreaKey)(property)) {
@@ -1100,6 +1146,7 @@ function contributeStyleValue(state, property, value, merge, originalValue) {
1100
1146
  }
1101
1147
  }
1102
1148
  if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
1149
+ 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
1150
  if (value != null) {
1104
1151
  emitValue(state, property, value, 0, "", void 0, "", "", merge, originalValue !== null && originalValue !== void 0 ? originalValue : value, contextOnly);
1105
1152
  return true;