tamagui 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 -56
- package/dist/native.js.map +1 -1
- package/dist/test.native.js +58 -52
- package/dist/test.native.js.map +1 -1
- package/package.json +52 -52
package/dist/native.js
CHANGED
|
@@ -1510,6 +1510,7 @@ var require_createShallowSetState_native = __commonJS({
|
|
|
1510
1510
|
}, __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), createShallowSetState_exports = {};
|
|
1511
1511
|
__export2(createShallowSetState_exports, {
|
|
1512
1512
|
createShallowSetState: () => createShallowSetState,
|
|
1513
|
+
isEqualShallow: () => isEqualShallow,
|
|
1513
1514
|
mergeIfNotShallowEqual: () => mergeIfNotShallowEqual
|
|
1514
1515
|
});
|
|
1515
1516
|
module2.exports = __toCommonJS2(createShallowSetState_exports);
|
|
@@ -1517,10 +1518,13 @@ var require_createShallowSetState_native = __commonJS({
|
|
|
1517
1518
|
return (next) => setter((prev) => mergeIfNotShallowEqual(prev, next));
|
|
1518
1519
|
}
|
|
1519
1520
|
function mergeIfNotShallowEqual(prev, next) {
|
|
1521
|
+
return isEqualShallow(prev, next) ? prev : { ...prev, ...next };
|
|
1522
|
+
}
|
|
1523
|
+
function isEqualShallow(prev, next) {
|
|
1520
1524
|
for (let key in next)
|
|
1521
1525
|
if (prev[key] !== next[key])
|
|
1522
|
-
return
|
|
1523
|
-
return
|
|
1526
|
+
return !1;
|
|
1527
|
+
return !0;
|
|
1524
1528
|
}
|
|
1525
1529
|
}
|
|
1526
1530
|
});
|
|
@@ -3415,7 +3419,7 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3415
3419
|
return this.updateState(nextState, shouldNotify), nextState;
|
|
3416
3420
|
}
|
|
3417
3421
|
updateState(nextState, shouldNotify = !0) {
|
|
3418
|
-
this.state = nextState, this._allKeys = null, process.env.NODE_ENV
|
|
3422
|
+
this.state = nextState, this._allKeys = null, process.env.NODE_ENV !== "production" && (this._numChangeEventsSent ??= 0, this._numChangeEventsSent++), shouldNotify && queueMicrotask(() => {
|
|
3419
3423
|
this.notify();
|
|
3420
3424
|
});
|
|
3421
3425
|
}
|
|
@@ -3443,25 +3447,28 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3443
3447
|
this.themeListeners.forEach((cb) => cb(this.state.name, this, forced));
|
|
3444
3448
|
}
|
|
3445
3449
|
onChangeTheme(cb, debugId) {
|
|
3446
|
-
return process.env.NODE_ENV
|
|
3450
|
+
return process.env.NODE_ENV !== "production" && debugId && (this._listeningIds ??= /* @__PURE__ */ new Set(), this._listeningIds.add(debugId)), this.themeListeners.add(cb), () => {
|
|
3447
3451
|
this.themeListeners.delete(cb);
|
|
3448
3452
|
};
|
|
3449
3453
|
}
|
|
3450
3454
|
};
|
|
3451
3455
|
function getState(props, manager) {
|
|
3456
|
+
var _a;
|
|
3452
3457
|
if (props.name && props.reset)
|
|
3453
3458
|
throw new Error(
|
|
3454
3459
|
process.env.NODE_ENV === "production" ? "\u274C004" : "Cannot reset and set a new name at the same time."
|
|
3455
3460
|
);
|
|
3456
3461
|
if (!getHasThemeUpdatingProps(props))
|
|
3457
3462
|
return null;
|
|
3458
|
-
let themes = (0, import_config.getThemes)(), [allManagers, componentManagers] = getManagers(manager), isDirectParentAComponentTheme = !!(manager != null && manager.state.isComponent), startIndex =
|
|
3463
|
+
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];
|
|
3459
3464
|
if (!baseManager && props.reset)
|
|
3460
3465
|
return process.env.NODE_ENV !== "production" && console.warn("Cannot reset, no parent theme exists"), null;
|
|
3461
|
-
let
|
|
3462
|
-
|
|
3466
|
+
let { componentName } = props, result = null, baseName = (baseManager == null ? void 0 : baseManager.state.name) || "";
|
|
3467
|
+
baseManager != null && baseManager.state.isComponent && (baseName = baseName.replace(/_[A-Z][a-z]+/, ""));
|
|
3468
|
+
let nextName = props.reset ? baseName : props.name || "", allComponentThemes = componentManagers.map((x) => (x == null ? void 0 : x.state.name) || "");
|
|
3469
|
+
isDirectParentAComponentTheme && allComponentThemes.shift();
|
|
3463
3470
|
let base = baseName.split(import_constants2.THEME_NAME_SEPARATOR), max2 = base.length, min2 = props.componentName && !nextName ? max2 : 0;
|
|
3464
|
-
process.env.NODE_ENV
|
|
3471
|
+
process.env.NODE_ENV !== "production" && typeof props.debug == "string" && (console.groupCollapsed("ThemeManager.getState()"), console.info({ props, baseName, base, min: min2, max: max2 }));
|
|
3465
3472
|
for (let i = max2; i >= min2; i--) {
|
|
3466
3473
|
let prefix = base.slice(0, i).join(import_constants2.THEME_NAME_SEPARATOR);
|
|
3467
3474
|
props.inverse && (prefix = inverseThemeName(prefix));
|
|
@@ -3470,39 +3477,38 @@ var require_ThemeManager_native = __commonJS({
|
|
|
3470
3477
|
let lastSegment = potentials.findIndex((x) => !x.includes("_"));
|
|
3471
3478
|
lastSegment > 0 && potentials.splice(lastSegment, 0, nextName);
|
|
3472
3479
|
}
|
|
3473
|
-
if (props.
|
|
3480
|
+
if (componentName && !props.reset) {
|
|
3474
3481
|
let componentPotentials = [];
|
|
3475
3482
|
if (nextName) {
|
|
3476
3483
|
let beforeSeparator = prefix.slice(0, prefix.indexOf(import_constants2.THEME_NAME_SEPARATOR));
|
|
3477
|
-
componentPotentials.push(`${beforeSeparator}_${nextName}_${
|
|
3484
|
+
componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`);
|
|
3478
3485
|
}
|
|
3479
|
-
if (componentPotentials.push(`${prefix}_${
|
|
3486
|
+
if (componentPotentials.push(`${prefix}_${componentName}`), nextName) {
|
|
3480
3487
|
let prefixLessOne = base.slice(0, i - 1).join(import_constants2.THEME_NAME_SEPARATOR);
|
|
3481
3488
|
if (prefixLessOne) {
|
|
3482
|
-
let lessSpecific = `${prefixLessOne}_${nextName}_${
|
|
3489
|
+
let lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`;
|
|
3483
3490
|
componentPotentials.unshift(lessSpecific);
|
|
3484
3491
|
}
|
|
3485
|
-
let moreSpecific = `${prefix}_${nextName}_${
|
|
3492
|
+
let moreSpecific = `${prefix}_${nextName}_${componentName}`;
|
|
3486
3493
|
componentPotentials.unshift(moreSpecific);
|
|
3487
3494
|
}
|
|
3488
3495
|
potentials = [...componentPotentials, ...potentials, ...allComponentThemes];
|
|
3489
3496
|
}
|
|
3490
3497
|
let found = potentials.find((t) => t in themes);
|
|
3491
|
-
if (process.env.NODE_ENV
|
|
3492
|
-
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_constants2.THEME_CLASSNAME_PREFIX, className = import_constants.isWeb ? `${pre}sub_theme ${pre}${!scheme || !restNames.length ? firstName : restNames.join("_")}` : "", parentState =
|
|
3498
|
+
if (process.env.NODE_ENV !== "production" && typeof props.debug == "string" && console.info(" - ", { found, potentials, baseManager, nextName, baseName, prefix }), found) {
|
|
3499
|
+
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_constants2.THEME_CLASSNAME_PREFIX, className = import_constants.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;
|
|
3493
3500
|
result = {
|
|
3494
3501
|
name: found,
|
|
3495
3502
|
parentName,
|
|
3496
3503
|
theme: themes[found],
|
|
3497
3504
|
className,
|
|
3498
|
-
inverse,
|
|
3499
3505
|
isComponent,
|
|
3500
3506
|
scheme
|
|
3501
3507
|
};
|
|
3502
3508
|
break;
|
|
3503
3509
|
}
|
|
3504
3510
|
}
|
|
3505
|
-
return process.env.NODE_ENV
|
|
3511
|
+
return process.env.NODE_ENV !== "production" && typeof props.debug == "string" && typeof window < "u" && (console.warn("ThemeManager.getState():", { result }), console.trace(), console.groupEnd()), result;
|
|
3506
3512
|
}
|
|
3507
3513
|
var inverseThemeName = (themeName) => themeName.startsWith("light") ? themeName.replace(/^light/, "dark") : themeName.replace(/^dark/, "light");
|
|
3508
3514
|
function getManagers(themeManager) {
|
|
@@ -3557,7 +3563,7 @@ var require_useTheme_native = __commonJS({
|
|
|
3557
3563
|
useThemeWithState: () => useThemeWithState
|
|
3558
3564
|
});
|
|
3559
3565
|
module2.exports = __toCommonJS2(useTheme_exports);
|
|
3560
|
-
var import_constants = require_index_native2(), import_react2 = 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;
|
|
3566
|
+
var import_constants = require_index_native2(), import_react2 = 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;
|
|
3561
3567
|
function getDefaultThemeProxied() {
|
|
3562
3568
|
if (cached)
|
|
3563
3569
|
return cached;
|
|
@@ -3651,8 +3657,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3651
3657
|
{
|
|
3652
3658
|
let cur = manager;
|
|
3653
3659
|
for (; cur; ) {
|
|
3654
|
-
if (cur.
|
|
3660
|
+
if (!cur.parentManager)
|
|
3655
3661
|
return !0;
|
|
3662
|
+
if (cur.parentManager.state.scheme !== cur.state.scheme)
|
|
3663
|
+
return !1;
|
|
3656
3664
|
cur = cur.parentManager;
|
|
3657
3665
|
}
|
|
3658
3666
|
}
|
|
@@ -3666,7 +3674,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3666
3674
|
state: parentManager == null ? void 0 : parentManager.state,
|
|
3667
3675
|
themeManager: parentManager
|
|
3668
3676
|
};
|
|
3669
|
-
let [themeState, setThemeState] = (0, import_react2.useState)(createState), { state, mounted, isNewTheme, themeManager } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
3677
|
+
let [themeState, setThemeState] = (0, import_react2.useState)(createState), { state, mounted, isNewTheme, themeManager, inversed } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
3670
3678
|
function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = !1) {
|
|
3671
3679
|
let forceUpdate = shouldUpdate == null ? void 0 : shouldUpdate();
|
|
3672
3680
|
if (!manager || !forceShouldChange && forceUpdate === !1)
|
|
@@ -3679,7 +3687,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3679
3687
|
if (!themeManager)
|
|
3680
3688
|
return;
|
|
3681
3689
|
if (props.inverse && !mounted) {
|
|
3682
|
-
setThemeState(
|
|
3690
|
+
setThemeState((prev) => createState({
|
|
3691
|
+
...prev,
|
|
3692
|
+
mounted: !0
|
|
3693
|
+
}));
|
|
3683
3694
|
return;
|
|
3684
3695
|
}
|
|
3685
3696
|
isNewTheme && themeManager && activeThemeManagers.add(themeManager), (isNewTheme || getShouldUpdateTheme(themeManager)) && setThemeState(createState);
|
|
@@ -3713,6 +3724,7 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3713
3724
|
}), [themeManager])), isInversingOnMount)
|
|
3714
3725
|
return {
|
|
3715
3726
|
isNewTheme: !1,
|
|
3727
|
+
inversed: !1,
|
|
3716
3728
|
themeManager: parentManager,
|
|
3717
3729
|
state: {
|
|
3718
3730
|
name: "",
|
|
@@ -3723,10 +3735,10 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3723
3735
|
return {
|
|
3724
3736
|
state,
|
|
3725
3737
|
isNewTheme,
|
|
3738
|
+
inversed,
|
|
3726
3739
|
themeManager
|
|
3727
3740
|
};
|
|
3728
3741
|
function createState(prev, force = !1) {
|
|
3729
|
-
var _a;
|
|
3730
3742
|
if (prev && (shouldUpdate == null ? void 0 : shouldUpdate()) === !1)
|
|
3731
3743
|
return prev;
|
|
3732
3744
|
let themeManager2 = parentManager, state2;
|
|
@@ -3745,15 +3757,18 @@ If this is intended and you are using Tamagui without any themes, you can disabl
|
|
|
3745
3757
|
themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
|
|
3746
3758
|
}
|
|
3747
3759
|
let isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse), mounted2 = props.inverse ? isRoot || (prev == null ? void 0 : prev.mounted) : !0;
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
let response = {
|
|
3751
|
-
state: state2,
|
|
3760
|
+
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
|
|
3761
|
+
let wasInversed = prev == null ? void 0 : prev.inversed, inversed2 = isNewTheme2 && state2.scheme !== (parentManager == null ? void 0 : parentManager.state.scheme) ? !0 : wasInversed ? !1 : null, response = {
|
|
3752
3762
|
themeManager: themeManager2,
|
|
3753
3763
|
isNewTheme: isNewTheme2,
|
|
3754
|
-
mounted: mounted2
|
|
3755
|
-
|
|
3756
|
-
|
|
3764
|
+
mounted: mounted2,
|
|
3765
|
+
inversed: inversed2
|
|
3766
|
+
}, shouldReturnPrev = !force && prev && // isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
3767
|
+
(0, import_createShallowSetState.isEqualShallow)(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
3768
|
+
(0, import_createShallowSetState.isEqualShallow)(prev.state, state2);
|
|
3769
|
+
if (prev && shouldReturnPrev)
|
|
3770
|
+
return prev;
|
|
3771
|
+
if (response.state = state2, process.env.NODE_ENV === "development" && props.debug && import_constants.isClient) {
|
|
3757
3772
|
console.groupCollapsed(` \u{1F537} ${themeManager2.id} useChangeThemeEffect createState`);
|
|
3758
3773
|
let parentState = { ...parentManager == null ? void 0 : parentManager.state }, parentId = parentManager == null ? void 0 : parentManager.id, themeManagerState = { ...themeManager2.state };
|
|
3759
3774
|
console.info({
|
|
@@ -3821,9 +3836,7 @@ var require_Theme_native = __commonJS({
|
|
|
3821
3836
|
)), __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: !0 }), mod), Theme_exports = {};
|
|
3822
3837
|
__export2(Theme_exports, {
|
|
3823
3838
|
Theme: () => Theme2,
|
|
3824
|
-
|
|
3825
|
-
useThemedChildren: () => useThemedChildren,
|
|
3826
|
-
wrapThemeElements: () => wrapThemeElements
|
|
3839
|
+
useThemedChildren: () => useThemedChildren
|
|
3827
3840
|
});
|
|
3828
3841
|
module2.exports = __toCommonJS2(Theme_exports);
|
|
3829
3842
|
var import_constants = require_index_native2(), import_react2 = __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_runtime6 = require("react/jsx-runtime"), Theme2 = (0, import_react2.forwardRef)(function(props, ref) {
|
|
@@ -3862,40 +3875,32 @@ var require_Theme_native = __commonJS({
|
|
|
3862
3875
|
isRoot
|
|
3863
3876
|
}) : elementsWithContext;
|
|
3864
3877
|
}
|
|
3865
|
-
function getThemeCNStyle(themeState, isRoot = !1) {
|
|
3866
|
-
var _a, _b;
|
|
3867
|
-
if (!themeState.isNewTheme)
|
|
3868
|
-
return;
|
|
3869
|
-
let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
|
|
3870
|
-
color: themeColor
|
|
3871
|
-
} : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
|
|
3872
|
-
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
3873
|
-
}
|
|
3874
3878
|
function wrapThemeElements({
|
|
3875
3879
|
children,
|
|
3876
3880
|
themeState,
|
|
3877
3881
|
forceClassName,
|
|
3878
3882
|
isRoot
|
|
3879
3883
|
}) {
|
|
3880
|
-
var _a
|
|
3884
|
+
var _a;
|
|
3881
3885
|
if (isRoot && forceClassName === !1)
|
|
3882
3886
|
return children;
|
|
3883
|
-
let inverse =
|
|
3884
|
-
if (!themeState.isNewTheme && !
|
|
3887
|
+
let inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
|
|
3888
|
+
if (!themeState.isNewTheme && !requiresExtraWrapper)
|
|
3885
3889
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "_dsp_contents is_Theme", children });
|
|
3886
|
-
let { className, style } =
|
|
3887
|
-
if (
|
|
3888
|
-
let name = ((
|
|
3889
|
-
themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3890
|
-
"span",
|
|
3891
|
-
{
|
|
3892
|
-
className: `${name.startsWith("light") ? "t_light" : name.startsWith("dark") ? "t_dark" : ""} _dsp_contents ${inverse ? "is_inversed" : ""}`,
|
|
3893
|
-
children: themedChildren
|
|
3894
|
-
}
|
|
3895
|
-
);
|
|
3890
|
+
let { className, style } = getThemeClassNameAndStyle(themeState, isRoot), themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${className} _dsp_contents is_Theme`, style, children });
|
|
3891
|
+
if (requiresExtraWrapper) {
|
|
3892
|
+
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" : "";
|
|
3893
|
+
themedChildren = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
|
|
3896
3894
|
}
|
|
3897
3895
|
return themedChildren;
|
|
3898
3896
|
}
|
|
3897
|
+
function getThemeClassNameAndStyle(themeState, isRoot = !1) {
|
|
3898
|
+
var _a, _b;
|
|
3899
|
+
let themeColor = (_a = themeState.state) != null && _a.theme && themeState.isNewTheme ? (0, import_createVariable.variableToString)(themeState.state.theme.color) : "", style = themeColor ? {
|
|
3900
|
+
color: themeColor
|
|
3901
|
+
} : void 0, className = ((_b = themeState.state) == null ? void 0 : _b.className) || "";
|
|
3902
|
+
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
3903
|
+
}
|
|
3899
3904
|
}
|
|
3900
3905
|
});
|
|
3901
3906
|
|
|
@@ -3924,7 +3929,7 @@ var require_themeable_native = __commonJS({
|
|
|
3924
3929
|
import_Theme.Theme,
|
|
3925
3930
|
{
|
|
3926
3931
|
componentName: componentName || (staticConfig == null ? void 0 : staticConfig.componentName),
|
|
3927
|
-
name: theme
|
|
3932
|
+
name: theme,
|
|
3928
3933
|
"disable-child-theme": !0,
|
|
3929
3934
|
debug: props.debug,
|
|
3930
3935
|
inverse: themeInverse,
|
|
@@ -11801,7 +11806,6 @@ var require_Button_native = __commonJS({
|
|
|
11801
11806
|
}
|
|
11802
11807
|
}), ButtonText = (0, import_web.styled)(import_text2.SizableText, {
|
|
11803
11808
|
name: "Button",
|
|
11804
|
-
// same name as the frame so they can share a single theme
|
|
11805
11809
|
context: ButtonContext,
|
|
11806
11810
|
variants: {
|
|
11807
11811
|
unstyled: {
|