@tamagui/core 1.74.16 → 1.74.17
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 +60 -55
- package/dist/native.js.map +1 -1
- package/dist/test.native.js +58 -51
- package/dist/test.native.js.map +1 -1
- package/package.json +6 -6
package/dist/native.js
CHANGED
|
@@ -2151,6 +2151,7 @@ var require_createShallowSetState_native = __commonJS({
|
|
|
2151
2151
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), createShallowSetState_exports = {};
|
|
2152
2152
|
__export2(createShallowSetState_exports, {
|
|
2153
2153
|
createShallowSetState: () => createShallowSetState,
|
|
2154
|
+
isEqualShallow: () => isEqualShallow,
|
|
2154
2155
|
mergeIfNotShallowEqual: () => mergeIfNotShallowEqual
|
|
2155
2156
|
});
|
|
2156
2157
|
module2.exports = __toCommonJS2(createShallowSetState_exports);
|
|
@@ -2158,10 +2159,13 @@ var require_createShallowSetState_native = __commonJS({
|
|
|
2158
2159
|
return (next) => setter((prev) => mergeIfNotShallowEqual(prev, next));
|
|
2159
2160
|
}
|
|
2160
2161
|
function mergeIfNotShallowEqual(prev, next) {
|
|
2162
|
+
return isEqualShallow(prev, next) ? prev : { ...prev, ...next };
|
|
2163
|
+
}
|
|
2164
|
+
function isEqualShallow(prev, next) {
|
|
2161
2165
|
for (let key in next)
|
|
2162
2166
|
if (prev[key] !== next[key])
|
|
2163
|
-
return
|
|
2164
|
-
return
|
|
2167
|
+
return !1;
|
|
2168
|
+
return !0;
|
|
2165
2169
|
}
|
|
2166
2170
|
}
|
|
2167
2171
|
});
|
|
@@ -4056,7 +4060,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
4056
4060
|
return this.updateState(nextState, shouldNotify), nextState;
|
|
4057
4061
|
}
|
|
4058
4062
|
updateState(nextState, shouldNotify = !0) {
|
|
4059
|
-
this.state = nextState, this._allKeys = null, process.env.NODE_ENV
|
|
4063
|
+
this.state = nextState, this._allKeys = null, process.env.NODE_ENV !== "production" && (this._numChangeEventsSent ??= 0, this._numChangeEventsSent++), shouldNotify && queueMicrotask(() => {
|
|
4060
4064
|
this.notify();
|
|
4061
4065
|
});
|
|
4062
4066
|
}
|
|
@@ -4084,25 +4088,28 @@ var require_ThemeManager_native = __commonJS({
|
|
|
4084
4088
|
this.themeListeners.forEach((cb) => cb(this.state.name, this, forced));
|
|
4085
4089
|
}
|
|
4086
4090
|
onChangeTheme(cb, debugId) {
|
|
4087
|
-
return process.env.NODE_ENV
|
|
4091
|
+
return process.env.NODE_ENV !== "production" && debugId && (this._listeningIds ??= /* @__PURE__ */ new Set(), this._listeningIds.add(debugId)), this.themeListeners.add(cb), () => {
|
|
4088
4092
|
this.themeListeners.delete(cb);
|
|
4089
4093
|
};
|
|
4090
4094
|
}
|
|
4091
4095
|
};
|
|
4092
4096
|
function getState(props, manager) {
|
|
4097
|
+
var _a;
|
|
4093
4098
|
if (props.name && props.reset)
|
|
4094
4099
|
throw new Error(
|
|
4095
4100
|
process.env.NODE_ENV === "production" ? "\u274C004" : "Cannot reset and set a new name at the same time."
|
|
4096
4101
|
);
|
|
4097
4102
|
if (!getHasThemeUpdatingProps(props))
|
|
4098
4103
|
return null;
|
|
4099
|
-
let themes = (0, import_config.getThemes)(), [allManagers, componentManagers] = getManagers(manager), isDirectParentAComponentTheme = !!(manager != null && manager.state.isComponent), startIndex =
|
|
4104
|
+
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
4105
|
if (!baseManager && props.reset)
|
|
4101
4106
|
return process.env.NODE_ENV !== "production" && console.warn("Cannot reset, no parent theme exists"), null;
|
|
4102
|
-
let
|
|
4103
|
-
|
|
4107
|
+
let { componentName } = props, result = null, baseName = (baseManager == null ? void 0 : baseManager.state.name) || "";
|
|
4108
|
+
baseManager != null && baseManager.state.isComponent && (baseName = baseName.replace(/_[A-Z][a-z]+/, ""));
|
|
4109
|
+
let nextName = props.reset ? baseName : props.name || "", allComponentThemes = componentManagers.map((x) => (x == null ? void 0 : x.state.name) || "");
|
|
4110
|
+
isDirectParentAComponentTheme && allComponentThemes.shift();
|
|
4104
4111
|
let base = baseName.split(import_constants22.THEME_NAME_SEPARATOR), max = base.length, min = props.componentName && !nextName ? max : 0;
|
|
4105
|
-
process.env.NODE_ENV
|
|
4112
|
+
process.env.NODE_ENV !== "production" && typeof props.debug == "string" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min, max }));
|
|
4106
4113
|
for (let i = max; i >= min; i--) {
|
|
4107
4114
|
let prefix = base.slice(0, i).join(import_constants22.THEME_NAME_SEPARATOR);
|
|
4108
4115
|
props.inverse && (prefix = inverseThemeName(prefix));
|
|
@@ -4111,39 +4118,38 @@ var require_ThemeManager_native = __commonJS({
|
|
|
4111
4118
|
let lastSegment = potentials.findIndex((x) => !x.includes("_"));
|
|
4112
4119
|
lastSegment > 0 && potentials.splice(lastSegment, 0, nextName);
|
|
4113
4120
|
}
|
|
4114
|
-
if (props.
|
|
4121
|
+
if (componentName && !props.reset) {
|
|
4115
4122
|
let componentPotentials = [];
|
|
4116
4123
|
if (nextName) {
|
|
4117
4124
|
let beforeSeparator = prefix.slice(0, prefix.indexOf(import_constants22.THEME_NAME_SEPARATOR));
|
|
4118
|
-
componentPotentials.push(`${beforeSeparator}_${nextName}_${
|
|
4125
|
+
componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`);
|
|
4119
4126
|
}
|
|
4120
|
-
if (componentPotentials.push(`${prefix}_${
|
|
4127
|
+
if (componentPotentials.push(`${prefix}_${componentName}`), nextName) {
|
|
4121
4128
|
let prefixLessOne = base.slice(0, i - 1).join(import_constants22.THEME_NAME_SEPARATOR);
|
|
4122
4129
|
if (prefixLessOne) {
|
|
4123
|
-
let lessSpecific = `${prefixLessOne}_${nextName}_${
|
|
4130
|
+
let lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`;
|
|
4124
4131
|
componentPotentials.unshift(lessSpecific);
|
|
4125
4132
|
}
|
|
4126
|
-
let moreSpecific = `${prefix}_${nextName}_${
|
|
4133
|
+
let moreSpecific = `${prefix}_${nextName}_${componentName}`;
|
|
4127
4134
|
componentPotentials.unshift(moreSpecific);
|
|
4128
4135
|
}
|
|
4129
4136
|
potentials = [...componentPotentials, ...potentials, ...allComponentThemes];
|
|
4130
4137
|
}
|
|
4131
4138
|
let found = potentials.find((t) => t in themes);
|
|
4132
|
-
if (process.env.NODE_ENV
|
|
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 =
|
|
4139
|
+
if (process.env.NODE_ENV !== "production" && typeof props.debug == "string" && console.info(" - ", { found, potentials, baseManager, nextName, baseName, prefix }), found) {
|
|
4140
|
+
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
4141
|
result = {
|
|
4135
4142
|
name: found,
|
|
4136
4143
|
parentName,
|
|
4137
4144
|
theme: themes[found],
|
|
4138
4145
|
className,
|
|
4139
|
-
inverse,
|
|
4140
4146
|
isComponent,
|
|
4141
4147
|
scheme
|
|
4142
4148
|
};
|
|
4143
4149
|
break;
|
|
4144
4150
|
}
|
|
4145
4151
|
}
|
|
4146
|
-
return process.env.NODE_ENV
|
|
4152
|
+
return process.env.NODE_ENV !== "production" && typeof props.debug == "string" && typeof window < "u" && (console.warn("ThemeManager.getState():", { result }), console.trace(), console.groupEnd()), result;
|
|
4147
4153
|
}
|
|
4148
4154
|
var inverseThemeName = (themeName) => themeName.startsWith("light") ? themeName.replace(/^light/, "dark") : themeName.replace(/^dark/, "light");
|
|
4149
4155
|
function getManagers(themeManager) {
|
|
@@ -4198,7 +4204,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4198
4204
|
useThemeWithState: () => useThemeWithState
|
|
4199
4205
|
});
|
|
4200
4206
|
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;
|
|
4207
|
+
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
4208
|
function getDefaultThemeProxied() {
|
|
4203
4209
|
if (cached)
|
|
4204
4210
|
return cached;
|
|
@@ -4292,8 +4298,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4292
4298
|
{
|
|
4293
4299
|
let cur = manager;
|
|
4294
4300
|
for (; cur; ) {
|
|
4295
|
-
if (cur.
|
|
4301
|
+
if (!cur.parentManager)
|
|
4296
4302
|
return !0;
|
|
4303
|
+
if (cur.parentManager.state.scheme !== cur.state.scheme)
|
|
4304
|
+
return !1;
|
|
4297
4305
|
cur = cur.parentManager;
|
|
4298
4306
|
}
|
|
4299
4307
|
}
|
|
@@ -4307,7 +4315,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4307
4315
|
state: parentManager == null ? void 0 : parentManager.state,
|
|
4308
4316
|
themeManager: parentManager
|
|
4309
4317
|
};
|
|
4310
|
-
let [themeState, setThemeState] = (0, import_react.useState)(createState), { state, mounted, isNewTheme, themeManager } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
4318
|
+
let [themeState, setThemeState] = (0, import_react.useState)(createState), { state, mounted, isNewTheme, themeManager, inversed } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
4311
4319
|
function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = !1) {
|
|
4312
4320
|
let forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate();
|
|
4313
4321
|
if (!manager || !forceShouldChange && forceUpdate === !1)
|
|
@@ -4320,7 +4328,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4320
4328
|
if (!themeManager)
|
|
4321
4329
|
return;
|
|
4322
4330
|
if (props.inverse && !mounted) {
|
|
4323
|
-
setThemeState(
|
|
4331
|
+
setThemeState((prev) => createState({
|
|
4332
|
+
...prev,
|
|
4333
|
+
mounted: !0
|
|
4334
|
+
}));
|
|
4324
4335
|
return;
|
|
4325
4336
|
}
|
|
4326
4337
|
isNewTheme && themeManager && activeThemeManagers.add(themeManager), (isNewTheme || getShouldUpdateTheme(themeManager)) && setThemeState(createState);
|
|
@@ -4354,6 +4365,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4354
4365
|
}), [themeManager])), isInversingOnMount)
|
|
4355
4366
|
return {
|
|
4356
4367
|
isNewTheme: !1,
|
|
4368
|
+
inversed: !1,
|
|
4357
4369
|
themeManager: parentManager,
|
|
4358
4370
|
state: {
|
|
4359
4371
|
name: "",
|
|
@@ -4364,10 +4376,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4364
4376
|
return {
|
|
4365
4377
|
state,
|
|
4366
4378
|
isNewTheme,
|
|
4379
|
+
inversed,
|
|
4367
4380
|
themeManager
|
|
4368
4381
|
};
|
|
4369
4382
|
function createState(prev, force = !1) {
|
|
4370
|
-
var _a;
|
|
4371
4383
|
if (prev && (shouldUpdate == null ? void 0 : shouldUpdate()) === !1)
|
|
4372
4384
|
return prev;
|
|
4373
4385
|
let themeManager2 = parentManager, state2;
|
|
@@ -4386,15 +4398,18 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4386
4398
|
themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
|
|
4387
4399
|
}
|
|
4388
4400
|
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse), mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
let response = {
|
|
4392
|
-
state: state2,
|
|
4401
|
+
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
|
|
4402
|
+
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
4403
|
themeManager: themeManager2,
|
|
4394
4404
|
isNewTheme: isNewTheme2,
|
|
4395
|
-
mounted: mounted2
|
|
4396
|
-
|
|
4397
|
-
|
|
4405
|
+
mounted: mounted2,
|
|
4406
|
+
inversed: inversed2
|
|
4407
|
+
}, shouldReturnPrev = !force && prev && // isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
4408
|
+
(0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
4409
|
+
(0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
|
|
4410
|
+
if (prev && shouldReturnPrev)
|
|
4411
|
+
return prev;
|
|
4412
|
+
if (response.state = state2, process.env.NODE_ENV === "development" && props.debug && import_constants2.isClient) {
|
|
4398
4413
|
console.groupCollapsed(` \u{1F537} ${themeManager2.id} useChangeThemeEffect createState`);
|
|
4399
4414
|
let parentState = { ...parentManager == null ? void 0 : parentManager.state }, parentId = parentManager == null ? void 0 : parentManager.id, themeManagerState = { ...themeManager2.state };
|
|
4400
4415
|
console.info({
|
|
@@ -4462,9 +4477,7 @@ var require_Theme_native = __commonJS({
|
|
|
4462
4477
|
)), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Theme_exports = {};
|
|
4463
4478
|
__export2(Theme_exports, {
|
|
4464
4479
|
Theme: () => Theme,
|
|
4465
|
-
|
|
4466
|
-
useThemedChildren: () => useThemedChildren,
|
|
4467
|
-
wrapThemeElements: () => wrapThemeElements
|
|
4480
|
+
useThemedChildren: () => useThemedChildren
|
|
4468
4481
|
});
|
|
4469
4482
|
module2.exports = __toCommonJS2(Theme_exports);
|
|
4470
4483
|
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 +4516,32 @@ var require_Theme_native = __commonJS({
|
|
|
4503
4516
|
isRoot
|
|
4504
4517
|
}) : elementsWithContext;
|
|
4505
4518
|
}
|
|
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
4519
|
function wrapThemeElements({
|
|
4516
4520
|
children,
|
|
4517
4521
|
themeState,
|
|
4518
4522
|
forceClassName,
|
|
4519
4523
|
isRoot
|
|
4520
4524
|
}) {
|
|
4521
|
-
var _a
|
|
4525
|
+
var _a;
|
|
4522
4526
|
if (isRoot && forceClassName === !1)
|
|
4523
4527
|
return children;
|
|
4524
|
-
let inverse =
|
|
4525
|
-
if (!themeState.isNewTheme && !
|
|
4528
|
+
let inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
|
|
4529
|
+
if (!themeState.isNewTheme && !requiresExtraWrapper)
|
|
4526
4530
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "_dsp_contents is_Theme", children });
|
|
4527
|
-
let { className, style } =
|
|
4528
|
-
if (
|
|
4529
|
-
let 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
|
-
);
|
|
4531
|
+
let { className, style } = getThemeClassNameAndStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
|
|
4532
|
+
if (requiresExtraWrapper) {
|
|
4533
|
+
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" : "";
|
|
4534
|
+
themedChildren = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
|
|
4537
4535
|
}
|
|
4538
4536
|
return themedChildren;
|
|
4539
4537
|
}
|
|
4538
|
+
function getThemeClassNameAndStyle(themeState, isRoot = !1) {
|
|
4539
|
+
var _a, _b;
|
|
4540
|
+
let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
|
|
4541
|
+
color: themeColor
|
|
4542
|
+
} : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
|
|
4543
|
+
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
4544
|
+
}
|
|
4540
4545
|
}
|
|
4541
4546
|
});
|
|
4542
4547
|
|
|
@@ -4565,7 +4570,7 @@ var require_themeable_native = __commonJS({
|
|
|
4565
4570
|
import_Theme.Theme,
|
|
4566
4571
|
{
|
|
4567
4572
|
componentName: componentName || (staticConfig == null ? void 0 : staticConfig.componentName),
|
|
4568
|
-
name: theme
|
|
4573
|
+
name: theme,
|
|
4569
4574
|
"disable-child-theme": !0,
|
|
4570
4575
|
debug: props.debug,
|
|
4571
4576
|
inverse: themeInverse,
|