@tamagui/core 1.124.9 → 1.124.11
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 +90 -36
- package/dist/native.js.map +2 -2
- package/dist/test.native.js +54 -28
- package/dist/test.native.js.map +2 -2
- package/package.json +7 -7
package/dist/native.js
CHANGED
|
@@ -6050,24 +6050,29 @@ var require_createShallowSetState_native = __commonJS({
|
|
|
6050
6050
|
var import_react3 = require("react"), callImmediate = function(cb) {
|
|
6051
6051
|
return cb();
|
|
6052
6052
|
};
|
|
6053
|
-
function createShallowSetState(setter,
|
|
6053
|
+
function createShallowSetState(setter, onlyAllow, transition, debug, callback) {
|
|
6054
6054
|
return (0, import_react3.useCallback)(function(next) {
|
|
6055
6055
|
var wrap = transition ? import_react3.startTransition : callImmediate;
|
|
6056
6056
|
wrap(function() {
|
|
6057
6057
|
setter(function(prev) {
|
|
6058
|
-
var out = mergeIfNotShallowEqual(prev, next,
|
|
6058
|
+
var out = mergeIfNotShallowEqual(prev, next, onlyAllow, debug);
|
|
6059
6059
|
return callback == null || callback(out), out;
|
|
6060
6060
|
});
|
|
6061
6061
|
});
|
|
6062
6062
|
}, [
|
|
6063
6063
|
setter,
|
|
6064
|
-
|
|
6064
|
+
onlyAllow ? onlyAllow.join("") : "",
|
|
6065
6065
|
transition,
|
|
6066
6066
|
debug
|
|
6067
6067
|
]);
|
|
6068
6068
|
}
|
|
6069
|
-
function mergeIfNotShallowEqual(prev, next,
|
|
6070
|
-
if (
|
|
6069
|
+
function mergeIfNotShallowEqual(prev, next, onlyAllow, debug) {
|
|
6070
|
+
if (onlyAllow) {
|
|
6071
|
+
var allowed = {};
|
|
6072
|
+
for (var key in next) onlyAllow.includes(key) && (allowed[key] = next[key]);
|
|
6073
|
+
next = allowed;
|
|
6074
|
+
}
|
|
6075
|
+
if (!prev || !next || isEqualShallow(prev, next)) return prev || next;
|
|
6071
6076
|
if (process.env.NODE_ENV === "development" && debug && (console.info("setStateShallow CHANGE", {
|
|
6072
6077
|
prev,
|
|
6073
6078
|
next
|
|
@@ -6217,16 +6222,34 @@ var require_useThemeState_native = __commonJS({
|
|
|
6217
6222
|
}
|
|
6218
6223
|
});
|
|
6219
6224
|
module2.exports = __toCommonJS2(useThemeState_exports);
|
|
6220
|
-
var import_constants2 = require_index_native2(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), keysToId = /* @__PURE__ */ new WeakMap(), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, hasRenderedOnce = /* @__PURE__ */ new WeakMap(), pendingUpdate = /* @__PURE__ */ new Map(), states = /* @__PURE__ */ new Map(),
|
|
6225
|
+
var import_constants2 = require_index_native2(), import_react3 = require("react"), import_config = require_config_native(), ThemeStateContext = (0, import_react3.createContext)(""), keysToId = /* @__PURE__ */ new WeakMap(), allListeners = /* @__PURE__ */ new Map(), listenersByParent = {}, hasRenderedOnce = /* @__PURE__ */ new WeakMap(), pendingUpdate = /* @__PURE__ */ new Map(), states = /* @__PURE__ */ new Map(), localStates = /* @__PURE__ */ new Map();
|
|
6226
|
+
process.env.NODE_ENV === "development" && (globalThis.getTamaguiThemes = function() {
|
|
6227
|
+
function buildTree(id) {
|
|
6228
|
+
var node = states.get(id);
|
|
6229
|
+
if (!node) return null;
|
|
6230
|
+
var children = Array.from(states.values()).filter(function(child) {
|
|
6231
|
+
return (child == null ? void 0 : child.parentId) === id;
|
|
6232
|
+
}).map(function(child) {
|
|
6233
|
+
return buildTree(child.id);
|
|
6234
|
+
}).filter(Boolean);
|
|
6235
|
+
return {
|
|
6236
|
+
...node,
|
|
6237
|
+
children
|
|
6238
|
+
};
|
|
6239
|
+
}
|
|
6240
|
+
rootThemeState && console.info(buildTree(rootThemeState.id));
|
|
6241
|
+
});
|
|
6242
|
+
var shouldForce = !1, forceUpdateThemes2 = function() {
|
|
6221
6243
|
cacheVersion++, shouldForce = !0, allListeners.forEach(function(cb) {
|
|
6222
6244
|
return cb();
|
|
6223
6245
|
});
|
|
6224
6246
|
}, getThemeState = function(id) {
|
|
6225
6247
|
return states.get(id);
|
|
6226
|
-
},
|
|
6248
|
+
}, cacheVersion = 0, themes = null, rootThemeState = null, getRootThemeState = function() {
|
|
6227
6249
|
return rootThemeState;
|
|
6228
6250
|
}, useThemeState = function(props) {
|
|
6229
6251
|
var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, keys = arguments.length > 2 ? arguments[2] : void 0, { disable } = props, parentId = (0, import_react3.useContext)(ThemeStateContext);
|
|
6252
|
+
if (!parentId && !isRoot) throw new Error("No parent?");
|
|
6230
6253
|
if (disable) return states.get(parentId) || {
|
|
6231
6254
|
id: "",
|
|
6232
6255
|
name: "light",
|
|
@@ -6238,16 +6261,24 @@ var require_useThemeState_native = __commonJS({
|
|
|
6238
6261
|
return (_listenersByParent = listenersByParent)[_parentId = parentId] || (_listenersByParent[_parentId] = /* @__PURE__ */ new Set()), listenersByParent[parentId].add(id), allListeners.set(id, function() {
|
|
6239
6262
|
pendingUpdate.set(id, shouldForce ? "force" : !0), cb();
|
|
6240
6263
|
}), function() {
|
|
6241
|
-
allListeners.delete(id), listenersByParent[parentId].delete(id);
|
|
6264
|
+
allListeners.delete(id), listenersByParent[parentId].delete(id), localStates.delete(id), states.delete(id), pendingUpdate.delete(id);
|
|
6242
6265
|
};
|
|
6243
6266
|
}, [
|
|
6244
6267
|
id,
|
|
6245
6268
|
parentId
|
|
6246
6269
|
]), propsKey = getPropsKey(props), getSnapshot = function() {
|
|
6247
|
-
var _keys_current, _props_needsUpdate,
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6270
|
+
var _keys_current, _props_needsUpdate, local = localStates.get(id), needsUpdate = isRoot || props.name === "light" || props.name === "dark" || props.name === null ? !0 : hasRenderedOnce.get(keys) ? !(keys == null || (_keys_current = keys.current) === null || _keys_current === void 0) && _keys_current.size ? !0 : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props) : !0, [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, pendingUpdate.get(id));
|
|
6271
|
+
return pendingUpdate.delete(id), (!local || rerender) && (local = {
|
|
6272
|
+
...next
|
|
6273
|
+
}, localStates.set(id, local)), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed(` ${id} \u{1FA84} ${rerender}`, local.name, ">", next.name), console.info({
|
|
6274
|
+
props,
|
|
6275
|
+
propsKey,
|
|
6276
|
+
isRoot,
|
|
6277
|
+
parentId,
|
|
6278
|
+
local,
|
|
6279
|
+
next,
|
|
6280
|
+
needsUpdate
|
|
6281
|
+
}), console.groupEnd()), Object.assign(local, next), local.id = id, states.set(id, next), local;
|
|
6251
6282
|
};
|
|
6252
6283
|
process.env.NODE_ENV === "development" && globalThis.time && globalThis.time`theme-prep-uses`;
|
|
6253
6284
|
var state = (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
@@ -6266,31 +6297,39 @@ var require_useThemeState_native = __commonJS({
|
|
|
6266
6297
|
}, [
|
|
6267
6298
|
keys,
|
|
6268
6299
|
propsKey
|
|
6269
|
-
]), state
|
|
6270
|
-
|
|
6271
|
-
isNew: !0
|
|
6272
|
-
} : state;
|
|
6273
|
-
}, getSnapshotFrom = function(lastState, props, propsKey) {
|
|
6300
|
+
]), state;
|
|
6301
|
+
}, getNextState = function(lastState, props, propsKey) {
|
|
6274
6302
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate2 = arguments.length > 7 ? arguments[7] : void 0, { debug } = props, parentState = states.get(parentId);
|
|
6275
6303
|
themes || (themes = (0, import_config.getConfig)().themes);
|
|
6276
|
-
var name = !propsKey &&
|
|
6304
|
+
var name = !propsKey && (!lastState || !(lastState != null && lastState.isNew)) ? null : getNewThemeName(parentState == null ? void 0 : parentState.name, props, pendingUpdate2 === "force" ? !0 : !!needsUpdate), isSameAsParent = parentState && (!name || name === parentState.name), shouldRerender = !!(needsUpdate && (pendingUpdate2 || (lastState == null ? void 0 : lastState.name) !== (parentState == null ? void 0 : parentState.name)));
|
|
6277
6305
|
if (process.env.NODE_ENV === "development" && debug && debug !== "profile") {
|
|
6278
|
-
var message = ` \xB7 useTheme(${id})
|
|
6306
|
+
var message = ` \xB7 useTheme(${id}) => ${name} needsUpdate ${needsUpdate} shouldRerender ${shouldRerender}`;
|
|
6279
6307
|
console.info(message);
|
|
6280
6308
|
}
|
|
6281
|
-
if (
|
|
6309
|
+
if (isSameAsParent) return [
|
|
6310
|
+
shouldRerender,
|
|
6311
|
+
{
|
|
6312
|
+
...parentState,
|
|
6313
|
+
isNew: !1
|
|
6314
|
+
}
|
|
6315
|
+
];
|
|
6282
6316
|
if (!name) {
|
|
6283
6317
|
var next = lastState ?? parentState;
|
|
6284
6318
|
if (!next) throw new Error("No theme and no parent?");
|
|
6285
|
-
if (
|
|
6319
|
+
if (shouldRerender) {
|
|
6286
6320
|
var updated = {
|
|
6287
6321
|
...parentState || lastState
|
|
6288
6322
|
};
|
|
6289
|
-
return
|
|
6323
|
+
return [
|
|
6324
|
+
!0,
|
|
6325
|
+
updated
|
|
6326
|
+
];
|
|
6290
6327
|
}
|
|
6291
|
-
return
|
|
6328
|
+
return [
|
|
6329
|
+
!1,
|
|
6330
|
+
next
|
|
6331
|
+
];
|
|
6292
6332
|
}
|
|
6293
|
-
if (pendingUpdate2 !== "force" && lastState && lastState.name === name) return lastState;
|
|
6294
6333
|
var scheme = getScheme(name), _parentState_inverses, parentInverses = (_parentState_inverses = parentState == null ? void 0 : parentState.inverses) !== null && _parentState_inverses !== void 0 ? _parentState_inverses : 0, isInverse = parentState && scheme !== parentState.scheme, inverses = parentInverses + (isInverse ? 1 : 0), nextState = {
|
|
6295
6334
|
id,
|
|
6296
6335
|
name,
|
|
@@ -6299,16 +6338,26 @@ var require_useThemeState_native = __commonJS({
|
|
|
6299
6338
|
parentId,
|
|
6300
6339
|
parentName: parentState == null ? void 0 : parentState.name,
|
|
6301
6340
|
inverses,
|
|
6302
|
-
isInverse
|
|
6341
|
+
isInverse,
|
|
6342
|
+
isNew: !0
|
|
6303
6343
|
};
|
|
6304
|
-
isRoot && (rootThemeState = nextState)
|
|
6344
|
+
if (isRoot && (rootThemeState = nextState), pendingUpdate2 !== "force" && lastState && lastState.name === name) return [
|
|
6345
|
+
!1,
|
|
6346
|
+
nextState
|
|
6347
|
+
];
|
|
6305
6348
|
var shouldAvoidRerender = pendingUpdate2 !== "force" && lastState && !needsUpdate && nextState.name === lastState.name;
|
|
6306
6349
|
return process.env.NODE_ENV === "development" && debug && debug !== "profile" && (console.groupCollapsed(` \xB7 useTheme(${id}) \u23ED\uFE0F ${name} shouldAvoidRerender: ${shouldAvoidRerender}`), console.info({
|
|
6307
6350
|
lastState,
|
|
6308
6351
|
needsUpdate,
|
|
6309
6352
|
nextState,
|
|
6310
6353
|
pendingUpdate: pendingUpdate2
|
|
6311
|
-
}), console.groupEnd()), shouldAvoidRerender ?
|
|
6354
|
+
}), console.groupEnd()), shouldAvoidRerender ? [
|
|
6355
|
+
!1,
|
|
6356
|
+
nextState
|
|
6357
|
+
] : [
|
|
6358
|
+
!0,
|
|
6359
|
+
nextState
|
|
6360
|
+
];
|
|
6312
6361
|
};
|
|
6313
6362
|
function scheduleUpdate(id) {
|
|
6314
6363
|
for (var queue = [
|
|
@@ -6745,7 +6794,11 @@ var require_Theme_native = __commonJS({
|
|
|
6745
6794
|
Theme.avoidForwardRef = !0;
|
|
6746
6795
|
function getThemedChildren(themeState, children, props) {
|
|
6747
6796
|
var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, stateRef = arguments.length > 4 ? arguments[4] : void 0, { shallow, forceClassName } = props, state = stateRef.current, hasEverThemed = state.hasEverThemed, shouldRenderChildrenWithTheme = hasEverThemed || themeState.isNew || isRoot || (0, import_useThemeState.hasThemeUpdatingProps)(props);
|
|
6748
|
-
if (
|
|
6797
|
+
if (process.env.NODE_ENV === "development" && props.debug && (children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeDebug.ThemeDebug, {
|
|
6798
|
+
themeState,
|
|
6799
|
+
themeProps: props,
|
|
6800
|
+
children
|
|
6801
|
+
})), !shouldRenderChildrenWithTheme) return children;
|
|
6749
6802
|
children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_useThemeState.ThemeStateContext.Provider, {
|
|
6750
6803
|
value: themeState.id,
|
|
6751
6804
|
children
|
|
@@ -6763,20 +6816,19 @@ var require_Theme_native = __commonJS({
|
|
|
6763
6816
|
})) : child;
|
|
6764
6817
|
});
|
|
6765
6818
|
}
|
|
6766
|
-
if (process.env.NODE_ENV === "development" && props.debug &&
|
|
6819
|
+
if (process.env.NODE_ENV === "development" && props.debug && console.warn(" getThemedChildren", {
|
|
6767
6820
|
requiresExtraWrapper,
|
|
6768
6821
|
forceClassName,
|
|
6769
6822
|
themeState,
|
|
6770
6823
|
state,
|
|
6771
6824
|
...getThemeClassNameAndStyle(themeState, props, isRoot)
|
|
6772
|
-
}),
|
|
6773
|
-
themeState,
|
|
6774
|
-
themeProps: props,
|
|
6775
|
-
children
|
|
6776
|
-
})), forceClassName === !1) return children;
|
|
6825
|
+
}), forceClassName === !1) return children;
|
|
6777
6826
|
if (import_constants2.isWeb) {
|
|
6778
6827
|
var { className, style } = getThemeClassNameAndStyle(themeState, props, isRoot);
|
|
6779
6828
|
if (children = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
6829
|
+
...process.env.NODE_ENV === "development" && {
|
|
6830
|
+
"data-theme-id": themeState.id
|
|
6831
|
+
},
|
|
6780
6832
|
className: `${className} _dsp_contents is_Theme`,
|
|
6781
6833
|
style,
|
|
6782
6834
|
children
|
|
@@ -7031,7 +7083,9 @@ var require_useComponentState_native = __commonJS({
|
|
|
7031
7083
|
groupContextState[groupName] = next;
|
|
7032
7084
|
};
|
|
7033
7085
|
}
|
|
7034
|
-
var setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled
|
|
7086
|
+
var setStateShallow = (0, import_createShallowSetState.createShallowSetState)(setState, disabled ? [
|
|
7087
|
+
"disabled"
|
|
7088
|
+
] : void 0, !1, props.debug, setStateWrapper);
|
|
7035
7089
|
if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
|
|
7036
7090
|
process.env.NODE_ENV === "development" && props.debug === "verbose" && console.warn(`has presenceState ${JSON.stringify(presenceState)}`);
|
|
7037
7091
|
var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
|
|
@@ -9759,7 +9813,7 @@ var require_useProps_native = __commonJS({
|
|
|
9759
9813
|
resolveValues: "auto",
|
|
9760
9814
|
...opts
|
|
9761
9815
|
}, null, componentContext), { mediaGroups, pseudoGroups } = splitStyles;
|
|
9762
|
-
return import_react3.default.
|
|
9816
|
+
return import_react3.default.useLayoutEffect(function() {
|
|
9763
9817
|
if (!disabled) {
|
|
9764
9818
|
if (state.unmounted) {
|
|
9765
9819
|
setStateShallow({
|