@tamagui/core 1.84.1 → 1.84.2
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 +23 -15
- package/dist/native.js.map +2 -2
- package/dist/test.native.js +22 -16
- package/dist/test.native.js.map +2 -2
- package/package.json +6 -6
package/dist/native.js
CHANGED
|
@@ -4092,10 +4092,10 @@ var require_ThemeManagerContext_native = __commonJS({
|
|
|
4092
4092
|
return to;
|
|
4093
4093
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), ThemeManagerContext_exports = {};
|
|
4094
4094
|
__export2(ThemeManagerContext_exports, {
|
|
4095
|
-
|
|
4095
|
+
ThemeManagerIDContext: () => ThemeManagerIDContext
|
|
4096
4096
|
});
|
|
4097
4097
|
module2.exports = __toCommonJS2(ThemeManagerContext_exports);
|
|
4098
|
-
var import_react3 = require("react"),
|
|
4098
|
+
var import_react3 = require("react"), ThemeManagerIDContext = (0, import_react3.createContext)(1);
|
|
4099
4099
|
}
|
|
4100
4100
|
});
|
|
4101
4101
|
|
|
@@ -4124,7 +4124,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
4124
4124
|
}
|
|
4125
4125
|
var uid = 0, ThemeManager = class {
|
|
4126
4126
|
constructor(props = {}, parentManager) {
|
|
4127
|
-
if (this.props = props, this.id =
|
|
4127
|
+
if (this.props = props, this.id = 0, this.themeListeners = /* @__PURE__ */ new Set(), this.parentManager = null, this.state = emptyState, this._allKeys = null, uid = (uid + 1) % Number.MAX_VALUE, this.id = uid, parentManager === "root") {
|
|
4128
4128
|
this.updateStateFromProps(props, !1);
|
|
4129
4129
|
return;
|
|
4130
4130
|
}
|
|
@@ -4267,6 +4267,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4267
4267
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), useTheme_exports = {};
|
|
4268
4268
|
__export2(useTheme_exports, {
|
|
4269
4269
|
activeThemeManagers: () => activeThemeManagers,
|
|
4270
|
+
getThemeManager: () => getThemeManager,
|
|
4270
4271
|
getThemeProxied: () => getThemeProxied,
|
|
4271
4272
|
useChangeThemeEffect: () => useChangeThemeEffect,
|
|
4272
4273
|
useTheme: () => useTheme,
|
|
@@ -4297,13 +4298,13 @@ var require_useTheme_native = __commonJS({
|
|
|
4297
4298
|
}), next;
|
|
4298
4299
|
}
|
|
4299
4300
|
), { themeManager, state } = changedThemeState;
|
|
4300
|
-
state != null && state.theme || process.env.
|
|
4301
|
+
process.env.NODE_ENV === "development" && (state != null && state.theme || process.env.TAMAGUI_DISABLE_NO_THEME_WARNING !== "1" && console.warn(
|
|
4301
4302
|
`[tamagui] No theme found, this could be due to an invalid theme name (given theme props ${JSON.stringify(
|
|
4302
4303
|
props
|
|
4303
4304
|
)}).
|
|
4304
4305
|
|
|
4305
4306
|
If this is intended and you are using Tamagui without any themes, you can disable this warning by setting the environment variable TAMAGUI_DISABLE_NO_THEME_WARNING=1`
|
|
4306
|
-
);
|
|
4307
|
+
));
|
|
4307
4308
|
let themeProxied = (0, import_react3.useMemo)(() => !themeManager || !(state != null && state.theme) ? {} : getThemeProxied(state, props.deopt, themeManager, keys.current, props.debug), [state == null ? void 0 : state.theme, themeManager, props.deopt, props.debug]);
|
|
4308
4309
|
return process.env.NODE_ENV === "development" && props.debug === "verbose" && (console.groupCollapsed(" \u{1F539} useTheme =>", state == null ? void 0 : state.name), console.info("returning state", changedThemeState, "from props", props), console.groupEnd()), [changedThemeState, themeProxied];
|
|
4309
4310
|
};
|
|
@@ -4381,8 +4382,13 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4381
4382
|
}
|
|
4382
4383
|
return !1;
|
|
4383
4384
|
}
|
|
4384
|
-
var activeThemeManagers = /* @__PURE__ */ new Set(),
|
|
4385
|
-
|
|
4385
|
+
var activeThemeManagers = /* @__PURE__ */ new Set(), _uidToManager = /* @__PURE__ */ new WeakMap(), _idToUID = {}, getId = (id) => _idToUID[id], getThemeManager = (id) => _uidToManager.get(getId(id)), registerThemeManager = (t) => {
|
|
4386
|
+
if (!_idToUID[t.id]) {
|
|
4387
|
+
let id = _idToUID[t.id] = {};
|
|
4388
|
+
_uidToManager.set(id, t);
|
|
4389
|
+
}
|
|
4390
|
+
}, useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => {
|
|
4391
|
+
let { disable } = props, parentManagerId = (0, import_react3.useContext)(import_ThemeManagerContext.ThemeManagerIDContext), parentManager = getThemeManager(parentManagerId);
|
|
4386
4392
|
if (!isRoot && !parentManager || disable)
|
|
4387
4393
|
return {
|
|
4388
4394
|
isNewTheme: !1,
|
|
@@ -4408,7 +4414,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4408
4414
|
}));
|
|
4409
4415
|
return;
|
|
4410
4416
|
}
|
|
4411
|
-
isNewTheme
|
|
4417
|
+
(isNewTheme || getShouldUpdateTheme(themeManager)) && (activeThemeManagers.add(themeManager), setThemeState(createState));
|
|
4412
4418
|
let selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => {
|
|
4413
4419
|
forced && setThemeState((prev) => createState(prev, !0));
|
|
4414
4420
|
}), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(
|
|
@@ -4419,7 +4425,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4419
4425
|
themeManager.id
|
|
4420
4426
|
);
|
|
4421
4427
|
return () => {
|
|
4422
|
-
selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), activeThemeManagers.delete(themeManager);
|
|
4428
|
+
selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), isNewTheme && activeThemeManagers.delete(themeManager);
|
|
4423
4429
|
};
|
|
4424
4430
|
}, [
|
|
4425
4431
|
themeManager,
|
|
@@ -4467,14 +4473,16 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
4467
4473
|
} else
|
|
4468
4474
|
themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
|
|
4469
4475
|
}
|
|
4470
|
-
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse)
|
|
4476
|
+
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse);
|
|
4477
|
+
isNewTheme2 && registerThemeManager(themeManager2);
|
|
4478
|
+
let mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
|
|
4471
4479
|
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
|
|
4472
4480
|
let wasInversed = prev == null ? void 0 : prev.inversed, inversed2 = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme) ? !0 : wasInversed != null ? !1 : null, response = {
|
|
4473
4481
|
themeManager: themeManager2,
|
|
4474
4482
|
isNewTheme: isNewTheme2,
|
|
4475
4483
|
mounted: mounted2,
|
|
4476
4484
|
inversed: inversed2
|
|
4477
|
-
}, shouldReturnPrev =
|
|
4485
|
+
}, shouldReturnPrev = prev && !force && // isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
4478
4486
|
(0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
4479
4487
|
(0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
|
|
4480
4488
|
if (prev && shouldReturnPrev)
|
|
@@ -4570,7 +4578,7 @@ var require_Theme_native = __commonJS({
|
|
|
4570
4578
|
function getThemedChildren(themeState, children, props, isRoot = !1) {
|
|
4571
4579
|
let { themeManager, isNewTheme } = themeState;
|
|
4572
4580
|
if (!themeManager)
|
|
4573
|
-
throw "\u274C";
|
|
4581
|
+
throw new Error(process.env.NODE_ENV === "development" ? "\u274C No theme found, either incorrect name, potential duplicate tamagui deps, or TamaguiProvider not providing themes." : "\u274C");
|
|
4574
4582
|
let { shallow, forceClassName } = props, hasEverThemed = (0, import_react3.useRef)(!1), shouldRenderChildrenWithTheme = isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot;
|
|
4575
4583
|
if (shouldRenderChildrenWithTheme && (hasEverThemed.current = !0), !shouldRenderChildrenWithTheme)
|
|
4576
4584
|
return children;
|
|
@@ -4580,7 +4588,7 @@ var require_Theme_native = __commonJS({
|
|
|
4580
4588
|
void 0,
|
|
4581
4589
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Theme, { name: themeManager.state.parentName, children: child.props.children })
|
|
4582
4590
|
) : child));
|
|
4583
|
-
let elementsWithContext = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeManagerContext.
|
|
4591
|
+
let elementsWithContext = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeManagerContext.ThemeManagerIDContext.Provider, { value: themeManager.id, children: next });
|
|
4584
4592
|
return forceClassName === !1 ? elementsWithContext : import_constants3.isWeb ? wrapThemeElements({
|
|
4585
4593
|
children: elementsWithContext,
|
|
4586
4594
|
themeState,
|
|
@@ -6264,9 +6272,9 @@ var require_useThemeName_native = __commonJS({
|
|
|
6264
6272
|
useThemeName: () => useThemeName
|
|
6265
6273
|
});
|
|
6266
6274
|
module2.exports = __toCommonJS2(useThemeName_exports);
|
|
6267
|
-
var import_constants3 = require_index_native3(), import_react3 = require("react"), import_ThemeManagerContext = require_ThemeManagerContext_native();
|
|
6275
|
+
var import_constants3 = require_index_native3(), import_react3 = require("react"), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_useTheme = require_useTheme_native();
|
|
6268
6276
|
function useThemeName(opts) {
|
|
6269
|
-
let manager = (0, import_react3.useContext)(import_ThemeManagerContext.
|
|
6277
|
+
let manager = (0, import_useTheme.getThemeManager)((0, import_react3.useContext)(import_ThemeManagerContext.ThemeManagerIDContext)), [name, setName] = (0, import_react3.useState)((manager == null ? void 0 : manager.state.name) || "");
|
|
6270
6278
|
return (0, import_constants3.useIsomorphicLayoutEffect)(() => {
|
|
6271
6279
|
if (manager)
|
|
6272
6280
|
return setName(manager.state.name), manager.onChangeTheme((next, manager2) => {
|