@tamagui/core 1.74.16 → 1.74.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/native.js CHANGED
@@ -905,7 +905,12 @@ var require_validStyleProps_native = __commonJS({
905
905
  borderTopLeftRadius: !0,
906
906
  borderTopRightRadius: !0,
907
907
  borderBottomLeftRadius: !0,
908
- borderBottomRightRadius: !0
908
+ borderBottomRightRadius: !0,
909
+ // logical
910
+ borderStartStartRadius: !0,
911
+ borderStartEndRadius: !0,
912
+ borderEndStartRadius: !0,
913
+ borderEndEndRadius: !0
909
914
  },
910
915
  size: {
911
916
  width: !0,
@@ -921,6 +926,9 @@ var require_validStyleProps_native = __commonJS({
921
926
  color: {
922
927
  backgroundColor: !0,
923
928
  borderColor: !0,
929
+ borderBlockStartColor: !0,
930
+ borderBlockEndColor: !0,
931
+ borderBlockColor: !0,
924
932
  borderBottomColor: !0,
925
933
  borderTopColor: !0,
926
934
  borderLeftColor: !0,
@@ -1010,6 +1018,11 @@ var require_validStyleProps_native = __commonJS({
1010
1018
  justifyContent: !0,
1011
1019
  left: !0,
1012
1020
  margin: !0,
1021
+ marginBlockEnd: !0,
1022
+ marginBlockStart: !0,
1023
+ marginInlineEnd: !0,
1024
+ marginInline: !0,
1025
+ marginInlineStart: !0,
1013
1026
  marginBottom: !0,
1014
1027
  marginEnd: !0,
1015
1028
  marginHorizontal: !0,
@@ -1021,6 +1034,11 @@ var require_validStyleProps_native = __commonJS({
1021
1034
  overflow: !0,
1022
1035
  padding: !0,
1023
1036
  paddingBottom: !0,
1037
+ paddingInline: !0,
1038
+ paddingBlock: !0,
1039
+ paddingBlockStart: !0,
1040
+ paddingInlineEnd: !0,
1041
+ paddingInlineStart: !0,
1024
1042
  paddingEnd: !0,
1025
1043
  paddingHorizontal: !0,
1026
1044
  paddingLeft: !0,
@@ -2151,6 +2169,7 @@ var require_createShallowSetState_native = __commonJS({
2151
2169
  }, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), createShallowSetState_exports = {};
2152
2170
  __export2(createShallowSetState_exports, {
2153
2171
  createShallowSetState: () => createShallowSetState,
2172
+ isEqualShallow: () => isEqualShallow,
2154
2173
  mergeIfNotShallowEqual: () => mergeIfNotShallowEqual
2155
2174
  });
2156
2175
  module2.exports = __toCommonJS2(createShallowSetState_exports);
@@ -2158,10 +2177,13 @@ var require_createShallowSetState_native = __commonJS({
2158
2177
  return (next) => setter((prev) => mergeIfNotShallowEqual(prev, next));
2159
2178
  }
2160
2179
  function mergeIfNotShallowEqual(prev, next) {
2180
+ return isEqualShallow(prev, next) ? prev : { ...prev, ...next };
2181
+ }
2182
+ function isEqualShallow(prev, next) {
2161
2183
  for (let key in next)
2162
2184
  if (prev[key] !== next[key])
2163
- return { ...prev, ...next };
2164
- return prev;
2185
+ return !1;
2186
+ return !0;
2165
2187
  }
2166
2188
  }
2167
2189
  });
@@ -4056,7 +4078,7 @@ var require_ThemeManager_native = __commonJS({
4056
4078
  return this.updateState(nextState, shouldNotify), nextState;
4057
4079
  }
4058
4080
  updateState(nextState, shouldNotify = !0) {
4059
- this.state = nextState, this._allKeys = null, process.env.NODE_ENV === "development" && (this._numChangeEventsSent ??= 0, this._numChangeEventsSent++), shouldNotify && queueMicrotask(() => {
4081
+ this.state = nextState, this._allKeys = null, process.env.NODE_ENV !== "production" && (this._numChangeEventsSent ??= 0, this._numChangeEventsSent++), shouldNotify && queueMicrotask(() => {
4060
4082
  this.notify();
4061
4083
  });
4062
4084
  }
@@ -4084,25 +4106,28 @@ var require_ThemeManager_native = __commonJS({
4084
4106
  this.themeListeners.forEach((cb) => cb(this.state.name, this, forced));
4085
4107
  }
4086
4108
  onChangeTheme(cb, debugId) {
4087
- return process.env.NODE_ENV === "development" && debugId && (this._listeningIds ??= /* @__PURE__ */ new Set(), this._listeningIds.add(debugId)), this.themeListeners.add(cb), () => {
4109
+ return process.env.NODE_ENV !== "production" && debugId && (this._listeningIds ??= /* @__PURE__ */ new Set(), this._listeningIds.add(debugId)), this.themeListeners.add(cb), () => {
4088
4110
  this.themeListeners.delete(cb);
4089
4111
  };
4090
4112
  }
4091
4113
  };
4092
4114
  function getState(props, manager) {
4115
+ var _a;
4093
4116
  if (props.name && props.reset)
4094
4117
  throw new Error(
4095
4118
  process.env.NODE_ENV === "production" ? "\u274C004" : "Cannot reset and set a new name at the same time."
4096
4119
  );
4097
4120
  if (!getHasThemeUpdatingProps(props))
4098
4121
  return null;
4099
- let themes = (0, import_config.getThemes)(), [allManagers, componentManagers] = getManagers(manager), isDirectParentAComponentTheme = !!(manager != null && manager.state.isComponent), startIndex = allManagers.findIndex((x) => !(x != null && x.state.isComponent)) + (props.reset && !isDirectParentAComponentTheme ? 1 : 0), baseManager = allManagers[startIndex], parentManager = allManagers[startIndex + 1];
4122
+ let themes = (0, import_config.getThemes)(), [allManagers, componentManagers] = getManagers(manager), isDirectParentAComponentTheme = !!(manager != null && manager.state.isComponent), startIndex = props.reset && !isDirectParentAComponentTheme ? 1 : 0, baseManager = allManagers[startIndex], parentManager = allManagers[startIndex + 1];
4100
4123
  if (!baseManager && props.reset)
4101
4124
  return process.env.NODE_ENV !== "production" && console.warn("Cannot reset, no parent theme exists"), null;
4102
- let result = null, baseName = (baseManager == null ? void 0 : baseManager.state.name) || "", nextName = props.reset ? baseName : props.name || "", allComponentThemes = componentManagers.map((x) => (x == null ? void 0 : x.state.name) || "");
4103
- props.reset && isDirectParentAComponentTheme && allComponentThemes.shift();
4125
+ let { componentName } = props, result = null, baseName = (baseManager == null ? void 0 : baseManager.state.name) || "";
4126
+ baseManager != null && baseManager.state.isComponent && (baseName = baseName.replace(/_[A-Z][a-z]+/, ""));
4127
+ let nextName = props.reset ? baseName : props.name || "", allComponentThemes = componentManagers.map((x) => (x == null ? void 0 : x.state.name) || "");
4128
+ isDirectParentAComponentTheme && allComponentThemes.shift();
4104
4129
  let base = baseName.split(import_constants22.THEME_NAME_SEPARATOR), max = base.length, min = props.componentName && !nextName ? max : 0;
4105
- process.env.NODE_ENV === "development" && typeof props.debug == "string" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min, max }));
4130
+ process.env.NODE_ENV !== "production" && typeof props.debug == "string" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min, max }));
4106
4131
  for (let i = max; i >= min; i--) {
4107
4132
  let prefix = base.slice(0, i).join(import_constants22.THEME_NAME_SEPARATOR);
4108
4133
  props.inverse && (prefix = inverseThemeName(prefix));
@@ -4111,39 +4136,38 @@ var require_ThemeManager_native = __commonJS({
4111
4136
  let lastSegment = potentials.findIndex((x) => !x.includes("_"));
4112
4137
  lastSegment > 0 && potentials.splice(lastSegment, 0, nextName);
4113
4138
  }
4114
- if (props.componentName) {
4139
+ if (componentName && !props.reset) {
4115
4140
  let componentPotentials = [];
4116
4141
  if (nextName) {
4117
4142
  let beforeSeparator = prefix.slice(0, prefix.indexOf(import_constants22.THEME_NAME_SEPARATOR));
4118
- componentPotentials.push(`${beforeSeparator}_${nextName}_${props.componentName}`);
4143
+ componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`);
4119
4144
  }
4120
- if (componentPotentials.push(`${prefix}_${props.componentName}`), nextName) {
4145
+ if (componentPotentials.push(`${prefix}_${componentName}`), nextName) {
4121
4146
  let prefixLessOne = base.slice(0, i - 1).join(import_constants22.THEME_NAME_SEPARATOR);
4122
4147
  if (prefixLessOne) {
4123
- let lessSpecific = `${prefixLessOne}_${nextName}_${props.componentName}`;
4148
+ let lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`;
4124
4149
  componentPotentials.unshift(lessSpecific);
4125
4150
  }
4126
- let moreSpecific = `${prefix}_${nextName}_${props.componentName}`;
4151
+ let moreSpecific = `${prefix}_${nextName}_${componentName}`;
4127
4152
  componentPotentials.unshift(moreSpecific);
4128
4153
  }
4129
4154
  potentials = [...componentPotentials, ...potentials, ...allComponentThemes];
4130
4155
  }
4131
4156
  let found = potentials.find((t) => t in themes);
4132
- if (process.env.NODE_ENV === "development" && typeof props.debug == "string" && console.info(" - ", { found, potentials, baseManager }), found) {
4133
- let names = found.split("_"), [firstName, ...restNames] = names, lastName = names[names.length - 1], isComponent = lastName[0] === lastName[0].toUpperCase(), scheme = firstName === "light" ? "light" : firstName === "dark" ? "dark" : void 0, pre = import_constants22.THEME_CLASSNAME_PREFIX, className = import_constants2.isWeb ? `${pre}sub_theme ${pre}${!scheme || !restNames.length ? firstName : restNames.join("_")}` : "", parentState = baseManager == null ? void 0 : baseManager.state, parentScheme = parentState == null ? void 0 : parentState.scheme, parentName = parentState == null ? void 0 : parentState.name, inverse = parentScheme && scheme !== parentScheme;
4157
+ if (process.env.NODE_ENV !== "production" && typeof props.debug == "string" && console.info(" - ", { found, potentials, baseManager, nextName, baseName, prefix }), found) {
4158
+ let names = found.split("_"), [firstName, ...restNames] = names, lastName = names[names.length - 1], isComponent = lastName[0] === lastName[0].toUpperCase(), scheme = firstName === "light" ? "light" : firstName === "dark" ? "dark" : void 0, pre = import_constants22.THEME_CLASSNAME_PREFIX, className = import_constants2.isWeb ? `${pre}sub_theme ${pre}${!scheme || !restNames.length ? firstName : restNames.join("_")}` : "", parentState = (_a = baseManager || parentManager) == null ? void 0 : _a.state, parentName = parentState == null ? void 0 : parentState.name;
4134
4159
  result = {
4135
4160
  name: found,
4136
4161
  parentName,
4137
4162
  theme: themes[found],
4138
4163
  className,
4139
- inverse,
4140
4164
  isComponent,
4141
4165
  scheme
4142
4166
  };
4143
4167
  break;
4144
4168
  }
4145
4169
  }
4146
- return process.env.NODE_ENV === "development" && typeof props.debug == "string" && typeof window < "u" && (console.warn("ThemeManager.getState():", { result }), console.trace(), console.groupEnd()), result;
4170
+ return process.env.NODE_ENV !== "production" && typeof props.debug == "string" && typeof window < "u" && (console.warn("ThemeManager.getState():", { result }), console.trace(), console.groupEnd()), result;
4147
4171
  }
4148
4172
  var inverseThemeName = (themeName) => themeName.startsWith("light") ? themeName.replace(/^light/, "dark") : themeName.replace(/^dark/, "light");
4149
4173
  function getManagers(themeManager) {
@@ -4198,7 +4222,7 @@ var require_useTheme_native = __commonJS({
4198
4222
  useThemeWithState: () => useThemeWithState
4199
4223
  });
4200
4224
  module2.exports = __toCommonJS2(useTheme_exports);
4201
- var import_constants2 = require_index_native2(), import_react = require("react"), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_createProxy = require_createProxy_native(), import_ThemeManager = require_ThemeManager_native(), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_getThemeUnwrapped = require_getThemeUnwrapped_native(), emptyProps = { name: null }, cached;
4225
+ var import_constants2 = require_index_native2(), import_react = require("react"), import_config = require_config_native(), import_createVariable = require_createVariable_native(), import_createProxy = require_createProxy_native(), import_createShallowSetState = require_createShallowSetState_native(), import_ThemeManager = require_ThemeManager_native(), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_getThemeUnwrapped = require_getThemeUnwrapped_native(), emptyProps = { name: null }, cached;
4202
4226
  function getDefaultThemeProxied() {
4203
4227
  if (cached)
4204
4228
  return cached;
@@ -4292,8 +4316,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4292
4316
  {
4293
4317
  let cur = manager;
4294
4318
  for (; cur; ) {
4295
- if (cur.state.inverse)
4319
+ if (!cur.parentManager)
4296
4320
  return !0;
4321
+ if (cur.parentManager.state.scheme !== cur.state.scheme)
4322
+ return !1;
4297
4323
  cur = cur.parentManager;
4298
4324
  }
4299
4325
  }
@@ -4307,7 +4333,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4307
4333
  state: parentManager == null ? void 0 : parentManager.state,
4308
4334
  themeManager: parentManager
4309
4335
  };
4310
- let [themeState, setThemeState] = (0, import_react.useState)(createState), { state, mounted, isNewTheme, themeManager } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
4336
+ let [themeState, setThemeState] = (0, import_react.useState)(createState), { state, mounted, isNewTheme, themeManager, inversed } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
4311
4337
  function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = !1) {
4312
4338
  let forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate();
4313
4339
  if (!manager || !forceShouldChange && forceUpdate === !1)
@@ -4320,7 +4346,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4320
4346
  if (!themeManager)
4321
4347
  return;
4322
4348
  if (props.inverse && !mounted) {
4323
- setThemeState({ ...themeState, mounted: !0 });
4349
+ setThemeState((prev) => createState({
4350
+ ...prev,
4351
+ mounted: !0
4352
+ }));
4324
4353
  return;
4325
4354
  }
4326
4355
  isNewTheme && themeManager && activeThemeManagers.add(themeManager), (isNewTheme || getShouldUpdateTheme(themeManager)) && setThemeState(createState);
@@ -4354,6 +4383,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4354
4383
  }), [themeManager])), isInversingOnMount)
4355
4384
  return {
4356
4385
  isNewTheme: !1,
4386
+ inversed: !1,
4357
4387
  themeManager: parentManager,
4358
4388
  state: {
4359
4389
  name: "",
@@ -4364,10 +4394,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4364
4394
  return {
4365
4395
  state,
4366
4396
  isNewTheme,
4397
+ inversed,
4367
4398
  themeManager
4368
4399
  };
4369
4400
  function createState(prev, force = !1) {
4370
- var _a;
4371
4401
  if (prev && (shouldUpdate == null ? void 0 : shouldUpdate()) === !1)
4372
4402
  return prev;
4373
4403
  let themeManager2 = parentManager, state2;
@@ -4386,15 +4416,18 @@ If this is intended and you are using Tamagui without any themes, you can disabl
4386
4416
  themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
4387
4417
  }
4388
4418
  let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse), mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
4389
- if (state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager)), !force && (state2 == null ? void 0 : state2.name) === ((_a = prev == null ? void 0 : prev.state) == null ? void 0 : _a.name))
4390
- return prev;
4391
- let response = {
4392
- state: state2,
4419
+ state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
4420
+ let wasInversed = prev == null ? void 0 : prev.inversed, inversed2 = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme) ? !0 : wasInversed ? !1 : null, response = {
4393
4421
  themeManager: themeManager2,
4394
4422
  isNewTheme: isNewTheme2,
4395
- mounted: mounted2
4396
- };
4397
- if (process.env.NODE_ENV === "development" && props.debug && import_constants2.isClient) {
4423
+ mounted: mounted2,
4424
+ inversed: inversed2
4425
+ }, shouldReturnPrev = !force && prev && // isEqualShallow uses the second arg as the keys so this should compare without state first...
4426
+ (0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
4427
+ (0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
4428
+ if (prev && shouldReturnPrev)
4429
+ return prev;
4430
+ if (response.state = state2, process.env.NODE_ENV === "development" && props.debug && import_constants2.isClient) {
4398
4431
  console.groupCollapsed(` \u{1F537} ${themeManager2.id} useChangeThemeEffect createState`);
4399
4432
  let parentState = { ...parentManager == null ? void 0 : parentManager.state }, parentId = parentManager == null ? void 0 : parentManager.id, themeManagerState = { ...themeManager2.state };
4400
4433
  console.info({
@@ -4462,9 +4495,7 @@ var require_Theme_native = __commonJS({
4462
4495
  )), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Theme_exports = {};
4463
4496
  __export2(Theme_exports, {
4464
4497
  Theme: () => Theme,
4465
- getThemeCNStyle: () => getThemeCNStyle,
4466
- useThemedChildren: () => useThemedChildren,
4467
- wrapThemeElements: () => wrapThemeElements
4498
+ useThemedChildren: () => useThemedChildren
4468
4499
  });
4469
4500
  module2.exports = __toCommonJS2(Theme_exports);
4470
4501
  var import_constants2 = require_index_native2(), import_react = __toESM2(require("react")), import_createVariable = require_createVariable_native(), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_useTheme = require_useTheme_native(), import_ThemeDebug = require_ThemeDebug_native(), import_jsx_runtime = require("react/jsx-runtime"), Theme = (0, import_react.forwardRef)(function(props, ref) {
@@ -4503,40 +4534,32 @@ var require_Theme_native = __commonJS({
4503
4534
  isRoot
4504
4535
  }) : elementsWithContext;
4505
4536
  }
4506
- function getThemeCNStyle(themeState, isRoot = !1) {
4507
- var _a, _b;
4508
- if (!themeState.isNewTheme)
4509
- return;
4510
- let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
4511
- color: themeColor
4512
- } : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
4513
- return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
4514
- }
4515
4537
  function wrapThemeElements({
4516
4538
  children,
4517
4539
  themeState,
4518
4540
  forceClassName,
4519
4541
  isRoot
4520
4542
  }) {
4521
- var _a, _b;
4543
+ var _a;
4522
4544
  if (isRoot && forceClassName === !1)
4523
4545
  return children;
4524
- let inverse = (_a = themeState.state) == null ? void 0 : _a.inverse;
4525
- if (!themeState.isNewTheme && !inverse && !forceClassName)
4546
+ let inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
4547
+ if (!themeState.isNewTheme && !requiresExtraWrapper)
4526
4548
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "_dsp_contents is_Theme", children });
4527
- let { className, style } = getThemeCNStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
4528
- if (inverse != null || forceClassName) {
4529
- let name = ((_b = themeState.state) == null ? void 0 : _b.name) || "";
4530
- themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4531
- "span",
4532
- {
4533
- className: `${name.startsWith("light") ? "t_light" : name.startsWith("dark") ? "t_dark" : ""} _dsp_contents ${inverse ? "is_inversed" : ""}`,
4534
- children: themedChildren
4535
- }
4536
- );
4549
+ let { className, style } = getThemeClassNameAndStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
4550
+ if (requiresExtraWrapper) {
4551
+ let name = ((_a = themeState.state) == null ? void 0 : _a.name) || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
4552
+ themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
4537
4553
  }
4538
4554
  return themedChildren;
4539
4555
  }
4556
+ function getThemeClassNameAndStyle(themeState, isRoot = !1) {
4557
+ var _a, _b;
4558
+ let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
4559
+ color: themeColor
4560
+ } : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
4561
+ return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
4562
+ }
4540
4563
  }
4541
4564
  });
4542
4565
 
@@ -4565,7 +4588,7 @@ var require_themeable_native = __commonJS({
4565
4588
  import_Theme.Theme,
4566
4589
  {
4567
4590
  componentName: componentName || (staticConfig == null ? void 0 : staticConfig.componentName),
4568
- name: theme || null,
4591
+ name: theme,
4569
4592
  "disable-child-theme": !0,
4570
4593
  debug: props.debug,
4571
4594
  inverse: themeInverse,