@tamagui/core 1.84.0 → 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 +24 -16
- package/dist/native.js.map +2 -2
- package/dist/test.native.js +23 -17
- package/dist/test.native.js.map +2 -2
- package/package.json +6 -6
package/dist/test.native.js
CHANGED
|
@@ -3915,10 +3915,10 @@ var require_ThemeManagerContext_native = __commonJS({
|
|
|
3915
3915
|
return to;
|
|
3916
3916
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), ThemeManagerContext_exports = {};
|
|
3917
3917
|
__export2(ThemeManagerContext_exports, {
|
|
3918
|
-
|
|
3918
|
+
ThemeManagerIDContext: () => ThemeManagerIDContext
|
|
3919
3919
|
});
|
|
3920
3920
|
module2.exports = __toCommonJS2(ThemeManagerContext_exports);
|
|
3921
|
-
var import_react3 = require("react"),
|
|
3921
|
+
var import_react3 = require("react"), ThemeManagerIDContext = (0, import_react3.createContext)(1);
|
|
3922
3922
|
}
|
|
3923
3923
|
});
|
|
3924
3924
|
|
|
@@ -3947,7 +3947,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3947
3947
|
}
|
|
3948
3948
|
var uid = 0, ThemeManager = class {
|
|
3949
3949
|
constructor(props = {}, parentManager) {
|
|
3950
|
-
if (this.props = props, this.id =
|
|
3950
|
+
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") {
|
|
3951
3951
|
this.updateStateFromProps(props, !1);
|
|
3952
3952
|
return;
|
|
3953
3953
|
}
|
|
@@ -4090,6 +4090,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4090
4090
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), useTheme_exports = {};
|
|
4091
4091
|
__export2(useTheme_exports, {
|
|
4092
4092
|
activeThemeManagers: () => activeThemeManagers,
|
|
4093
|
+
getThemeManager: () => getThemeManager,
|
|
4093
4094
|
getThemeProxied: () => getThemeProxied,
|
|
4094
4095
|
useChangeThemeEffect: () => useChangeThemeEffect,
|
|
4095
4096
|
useTheme: () => useTheme,
|
|
@@ -4115,9 +4116,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4115
4116
|
var _a, _b;
|
|
4116
4117
|
return ((_a = props.shouldUpdate) == null ? void 0 : _a.call(props)) ?? (keys.current.length > 0 ? !0 : void 0);
|
|
4117
4118
|
}
|
|
4118
|
-
), { themeManager, state } = changedThemeState;
|
|
4119
|
-
state != null && state.theme;
|
|
4120
|
-
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]);
|
|
4119
|
+
), { themeManager, state } = changedThemeState, 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]);
|
|
4121
4120
|
return [changedThemeState, themeProxied];
|
|
4122
4121
|
};
|
|
4123
4122
|
function getThemeProxied({ theme, name, scheme }, deopt = !1, themeManager, keys, debug) {
|
|
@@ -4187,8 +4186,13 @@ var require_useTheme_native = __commonJS({
|
|
|
4187
4186
|
}
|
|
4188
4187
|
return !1;
|
|
4189
4188
|
}
|
|
4190
|
-
var activeThemeManagers = /* @__PURE__ */ new Set(),
|
|
4191
|
-
|
|
4189
|
+
var activeThemeManagers = /* @__PURE__ */ new Set(), _uidToManager = /* @__PURE__ */ new WeakMap(), _idToUID = {}, getId = (id) => _idToUID[id], getThemeManager = (id) => _uidToManager.get(getId(id)), registerThemeManager = (t) => {
|
|
4190
|
+
if (!_idToUID[t.id]) {
|
|
4191
|
+
let id = _idToUID[t.id] = {};
|
|
4192
|
+
_uidToManager.set(id, t);
|
|
4193
|
+
}
|
|
4194
|
+
}, useChangeThemeEffect = (props, isRoot = !1, keys, shouldUpdate) => {
|
|
4195
|
+
let { disable } = props, parentManagerId = (0, import_react3.useContext)(import_ThemeManagerContext.ThemeManagerIDContext), parentManager = getThemeManager(parentManagerId);
|
|
4192
4196
|
if (!isRoot && !parentManager || disable)
|
|
4193
4197
|
return {
|
|
4194
4198
|
isNewTheme: !1,
|
|
@@ -4214,7 +4218,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4214
4218
|
}));
|
|
4215
4219
|
return;
|
|
4216
4220
|
}
|
|
4217
|
-
isNewTheme
|
|
4221
|
+
(isNewTheme || getShouldUpdateTheme(themeManager)) && (activeThemeManagers.add(themeManager), setThemeState(createState));
|
|
4218
4222
|
let selfListenerDispose = themeManager.onChangeTheme((_a, _b, forced) => {
|
|
4219
4223
|
forced && setThemeState((prev) => createState(prev, !0));
|
|
4220
4224
|
}), disposeChangeListener = parentManager == null ? void 0 : parentManager.onChangeTheme(
|
|
@@ -4225,7 +4229,7 @@ var require_useTheme_native = __commonJS({
|
|
|
4225
4229
|
themeManager.id
|
|
4226
4230
|
);
|
|
4227
4231
|
return () => {
|
|
4228
|
-
selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), activeThemeManagers.delete(themeManager);
|
|
4232
|
+
selfListenerDispose(), disposeChangeListener == null || disposeChangeListener(), isNewTheme && activeThemeManagers.delete(themeManager);
|
|
4229
4233
|
};
|
|
4230
4234
|
}, [
|
|
4231
4235
|
themeManager,
|
|
@@ -4271,14 +4275,16 @@ var require_useTheme_native = __commonJS({
|
|
|
4271
4275
|
} else
|
|
4272
4276
|
themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
|
|
4273
4277
|
}
|
|
4274
|
-
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse)
|
|
4278
|
+
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse);
|
|
4279
|
+
isNewTheme2 && registerThemeManager(themeManager2);
|
|
4280
|
+
let mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
|
|
4275
4281
|
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
|
|
4276
4282
|
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 = {
|
|
4277
4283
|
themeManager: themeManager2,
|
|
4278
4284
|
isNewTheme: isNewTheme2,
|
|
4279
4285
|
mounted: mounted2,
|
|
4280
4286
|
inversed: inversed2
|
|
4281
|
-
}, shouldReturnPrev =
|
|
4287
|
+
}, shouldReturnPrev = prev && !force && // isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
4282
4288
|
(0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
4283
4289
|
(0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
|
|
4284
4290
|
return prev && shouldReturnPrev ? prev : (response.state = state2, response);
|
|
@@ -4359,7 +4365,7 @@ var require_Theme_native = __commonJS({
|
|
|
4359
4365
|
function getThemedChildren(themeState, children, props, isRoot = !1) {
|
|
4360
4366
|
let { themeManager, isNewTheme } = themeState;
|
|
4361
4367
|
if (!themeManager)
|
|
4362
|
-
throw "\u274C";
|
|
4368
|
+
throw new Error("\u274C");
|
|
4363
4369
|
let { shallow, forceClassName } = props, hasEverThemed = (0, import_react3.useRef)(!1), shouldRenderChildrenWithTheme = isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot;
|
|
4364
4370
|
if (shouldRenderChildrenWithTheme && (hasEverThemed.current = !0), !shouldRenderChildrenWithTheme)
|
|
4365
4371
|
return children;
|
|
@@ -4369,7 +4375,7 @@ var require_Theme_native = __commonJS({
|
|
|
4369
4375
|
void 0,
|
|
4370
4376
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Theme, { name: themeManager.state.parentName, children: child.props.children })
|
|
4371
4377
|
) : child));
|
|
4372
|
-
let elementsWithContext = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeManagerContext.
|
|
4378
|
+
let elementsWithContext = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeManagerContext.ThemeManagerIDContext.Provider, { value: themeManager.id, children: next });
|
|
4373
4379
|
return forceClassName === !1 ? elementsWithContext : import_constants3.isWeb ? wrapThemeElements({
|
|
4374
4380
|
children: elementsWithContext,
|
|
4375
4381
|
themeState,
|
|
@@ -4809,7 +4815,7 @@ var require_createComponent_native = __commonJS({
|
|
|
4809
4815
|
fontFamily && fontFamily[0] === "$" && (fontFamily = fontFamily.slice(1));
|
|
4810
4816
|
let fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "", style = avoidAnimationStyle ? splitStyles.style : animationStyles || splitStyles.style, className;
|
|
4811
4817
|
asChild === "except-style" || asChild === "except-style-web" || (viewProps.style = style);
|
|
4812
|
-
let runtimePressStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.pressStyle), runtimeFocusStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusStyle), attachFocus = !!(runtimePressStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onLongPress || onClick), runtimeHoverStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.hoverStyle), needsHoverState = runtimeHoverStyle || onHoverIn || onHoverOut, isHoverable = import_constants3.isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), events = !!(attachFocus || attachPress || isHoverable || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle) && !isDisabled && !props.asChild ? {
|
|
4818
|
+
let runtimePressStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.pressStyle), runtimeFocusStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.focusStyle), attachFocus = !!(runtimePressStyle || runtimeFocusStyle || onFocus || onBlur), attachPress = !!(groupName || runtimePressStyle || onPress || onPressOut || onPressIn || onLongPress || onClick), runtimeHoverStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.hoverStyle), needsHoverState = runtimeHoverStyle || onHoverIn || onHoverOut, isHoverable = import_constants3.isWeb && !!(groupName || needsHoverState || onMouseEnter || onMouseLeave), events = !!(attachFocus || attachPress || isHoverable || runtimePressStyle || runtimeHoverStyle || runtimeFocusStyle) && !isDisabled && !props.asChild ? {
|
|
4813
4819
|
onPressOut: attachPress ? (e) => {
|
|
4814
4820
|
unPress(), onPressOut == null || onPressOut(e), onMouseUp == null || onMouseUp(e);
|
|
4815
4821
|
} : void 0,
|
|
@@ -5911,9 +5917,9 @@ var require_useThemeName_native = __commonJS({
|
|
|
5911
5917
|
useThemeName: () => useThemeName
|
|
5912
5918
|
});
|
|
5913
5919
|
module2.exports = __toCommonJS2(useThemeName_exports);
|
|
5914
|
-
var import_constants3 = require_index_native3(), import_react3 = require("react"), import_ThemeManagerContext = require_ThemeManagerContext_native();
|
|
5920
|
+
var import_constants3 = require_index_native3(), import_react3 = require("react"), import_ThemeManagerContext = require_ThemeManagerContext_native(), import_useTheme = require_useTheme_native();
|
|
5915
5921
|
function useThemeName(opts) {
|
|
5916
|
-
let manager = (0, import_react3.useContext)(import_ThemeManagerContext.
|
|
5922
|
+
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) || "");
|
|
5917
5923
|
return (0, import_constants3.useIsomorphicLayoutEffect)(() => {
|
|
5918
5924
|
if (manager)
|
|
5919
5925
|
return setName(manager.state.name), manager.onChangeTheme((next, manager2) => {
|