react-native-unistyles 3.5.0 → 3.5.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/Unistyles.podspec +1 -0
- package/cxx/common/UnistylesConstants.h +3 -0
- package/cxx/core/HostUnistyle.cpp +13 -1
- package/cxx/core/HostUnistyle.h +6 -2
- package/cxx/core/RNStyle.h +1 -1
- package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +5 -0
- package/lib/commonjs/components/AdaptiveTheme.js +9 -1
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -1
- package/lib/commonjs/components/NamedTheme.js +9 -1
- package/lib/commonjs/components/NamedTheme.js.map +1 -1
- package/lib/commonjs/components/ScopedThemeContext.js +9 -0
- package/lib/commonjs/components/ScopedThemeContext.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.native.js +6 -5
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/components/scopeChildren.js +29 -0
- package/lib/commonjs/components/scopeChildren.js.map +1 -0
- package/lib/commonjs/components/scopeChildren.native.js +9 -0
- package/lib/commonjs/components/scopeChildren.native.js.map +1 -0
- package/lib/commonjs/core/createUnistylesActivityIndicator.js +5 -3
- package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +1 -1
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +3 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +7 -4
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -8
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +15 -3
- package/lib/commonjs/core/passForwardRef.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +10 -5
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +12 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/mocks.js +1 -1
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.js +8 -5
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +8 -5
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +12 -3
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/web/css/state.js +5 -2
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/runtime.js +6 -0
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +3 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/module/components/AdaptiveTheme.js +10 -2
- package/lib/module/components/AdaptiveTheme.js.map +1 -1
- package/lib/module/components/NamedTheme.js +10 -2
- package/lib/module/components/NamedTheme.js.map +1 -1
- package/lib/module/components/ScopedThemeContext.js +5 -0
- package/lib/module/components/ScopedThemeContext.js.map +1 -0
- package/lib/module/components/native/Pressable.native.js +7 -6
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/components/scopeChildren.js +23 -0
- package/lib/module/components/scopeChildren.js.map +1 -0
- package/lib/module/components/scopeChildren.native.js +4 -0
- package/lib/module/components/scopeChildren.native.js.map +1 -0
- package/lib/module/core/createUnistylesActivityIndicator.js +4 -2
- package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +1 -1
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +4 -2
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +6 -3
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/createUnistylesTouchableHighlight.js +7 -9
- package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
- package/lib/module/core/passForwardRef.js +15 -3
- package/lib/module/core/passForwardRef.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +12 -7
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +13 -3
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/mocks.js +1 -1
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.js +10 -7
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js +10 -7
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +12 -3
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/web/css/state.js +5 -2
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/runtime.js +6 -0
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +3 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ScopedThemeContext.d.ts +6 -0
- package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/scopeChildren.d.ts +4 -0
- package/lib/typescript/src/components/scopeChildren.d.ts.map +1 -0
- package/lib/typescript/src/components/scopeChildren.native.d.ts +4 -0
- package/lib/typescript/src/components/scopeChildren.native.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +1 -2
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/AdaptiveTheme.tsx +8 -2
- package/src/components/NamedTheme.tsx +8 -2
- package/src/components/ScopedThemeContext.ts +9 -0
- package/src/components/native/Pressable.native.tsx +8 -7
- package/src/components/scopeChildren.native.ts +5 -0
- package/src/components/scopeChildren.tsx +19 -0
- package/src/core/createUnistylesActivityIndicator.tsx +5 -2
- package/src/core/createUnistylesElement.native.tsx +4 -2
- package/src/core/createUnistylesElement.tsx +6 -1
- package/src/core/createUnistylesImageBackground.tsx +6 -3
- package/src/core/createUnistylesTouchableHighlight.tsx +7 -11
- package/src/core/passForwardRef.ts +16 -4
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +11 -10
- package/src/core/withUnistyles/withUnistyles.native.tsx +24 -5
- package/src/mocks.ts +6 -2
- package/src/reanimated/useAnimatedTheme.native.ts +9 -9
- package/src/reanimated/useAnimatedTheme.ts +9 -9
- package/src/specs/ShadowRegistry/index.ts +16 -4
- package/src/web/css/state.ts +10 -2
- package/src/web/runtime.ts +6 -0
- package/src/web/shadowRegistry.ts +3 -1
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useLayoutEffect } from 'react';
|
|
3
|
+
import React, { useLayoutEffect, useMemo } from 'react';
|
|
4
4
|
import { UnistylesShadowRegistry } from '../specs';
|
|
5
5
|
import { ApplyScopedTheme } from './ApplyScopedTheme';
|
|
6
|
+
import { scopeChildren } from './scopeChildren';
|
|
7
|
+
import { ScopedThemeContext } from './ScopedThemeContext';
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
export const NamedTheme = ({
|
|
8
10
|
name,
|
|
9
11
|
children,
|
|
10
12
|
previousScopedTheme
|
|
11
13
|
}) => {
|
|
14
|
+
const scope = useMemo(() => ({
|
|
15
|
+
name
|
|
16
|
+
}), [name]);
|
|
12
17
|
const mappedChildren = [/*#__PURE__*/_jsx(ApplyScopedTheme, {
|
|
13
18
|
name: name
|
|
14
|
-
}, "apply"),
|
|
19
|
+
}, "apply"), /*#__PURE__*/_jsx(ScopedThemeContext.Provider, {
|
|
20
|
+
value: scope,
|
|
21
|
+
children: scopeChildren(name, children)
|
|
22
|
+
}, "scope"), /*#__PURE__*/_jsx(ApplyScopedTheme, {
|
|
15
23
|
name: previousScopedTheme
|
|
16
24
|
}, "dispose")];
|
|
17
25
|
useLayoutEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useLayoutEffect","UnistylesShadowRegistry","ApplyScopedTheme","jsx","_jsx","NamedTheme","name","children","previousScopedTheme","mappedChildren","flush","Fragment"],"sourceRoot":"../../../src","sources":["components/NamedTheme.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,eAAe,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["React","useLayoutEffect","useMemo","UnistylesShadowRegistry","ApplyScopedTheme","scopeChildren","ScopedThemeContext","jsx","_jsx","NamedTheme","name","children","previousScopedTheme","scope","mappedChildren","Provider","value","flush","Fragment"],"sourceRoot":"../../../src","sources":["components/NamedTheme.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,OAAO,QAAQ,OAAO;AAIvD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,kBAAkB,QAAQ,sBAAsB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOzD,OAAO,MAAMC,UAAoD,GAAGA,CAAC;EAAEC,IAAI;EAAEC,QAAQ;EAAEC;AAAoB,CAAC,KAAK;EAC7G,MAAMC,KAAK,GAAGX,OAAO,CAAC,OAAO;IAAEQ;EAAK,CAAC,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAE/C,MAAMI,cAAc,GAAG,cACnBN,IAAA,CAACJ,gBAAgB;IAAaM,IAAI,EAAEA;EAAK,GAAnB,OAAqB,CAAC,eAC5CF,IAAA,CAACF,kBAAkB,CAACS,QAAQ;IAAaC,KAAK,EAAEH,KAAM;IAAAF,QAAA,EACjDN,aAAa,CAACK,IAAI,EAAEC,QAAQ;EAAC,GADD,OAEJ,CAAC,eAC9BH,IAAA,CAACJ,gBAAgB;IAAeM,IAAI,EAAEE;EAAyD,GAAzE,SAA2E,CAAC,CACrG;EAEDX,eAAe,CAAC,MAAM;IAClB;IACAE,uBAAuB,CAACc,KAAK,CAAC,CAAC;EACnC,CAAC,CAAC;EAEF,oBAAOT,IAAA,CAACR,KAAK,CAACkB,QAAQ;IAAAP,QAAA,EAAEG;EAAc,CAAiB,CAAC;AAC5D,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","ScopedThemeContext"],"sourceRoot":"../../../src","sources":["components/ScopedThemeContext.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,OAAO;AAQrC,OAAO,MAAMC,kBAAkB,gBAAGD,aAAa,CAAe,IAAI,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef, useLayoutEffect, useRef } from 'react';
|
|
3
|
+
import React, { forwardRef, useContext, useLayoutEffect, useRef } from 'react';
|
|
4
4
|
import { Pressable as NativePressableReactNative } from 'react-native';
|
|
5
5
|
import { passForwardedRef } from '../../core';
|
|
6
6
|
import { UnistylesShadowRegistry } from '../../specs';
|
|
7
|
+
import { ScopedThemeContext } from '../ScopedThemeContext';
|
|
7
8
|
|
|
8
9
|
// instance type of View for both legacy and Strict TypeScript API (RN 0.87+)
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -24,7 +25,7 @@ export const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
24
25
|
...props
|
|
25
26
|
}, forwardedRef) => {
|
|
26
27
|
const storedRef = useRef(null);
|
|
27
|
-
const
|
|
28
|
+
const scope = useContext(ScopedThemeContext);
|
|
28
29
|
useLayoutEffect(() => {
|
|
29
30
|
return () => {
|
|
30
31
|
if (storedRef.current) {
|
|
@@ -45,7 +46,7 @@ export const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
45
46
|
}
|
|
46
47
|
return passForwardedRef(ref, forwardedRef, () => {
|
|
47
48
|
// @ts-expect-error - this is hidden from TS
|
|
48
|
-
UnistylesShadowRegistry.add(ref, unistyles);
|
|
49
|
+
UnistylesShadowRegistry.add(ref, unistyles, scope);
|
|
49
50
|
}, () => {
|
|
50
51
|
// @ts-expect-error - this is hidden from TS
|
|
51
52
|
UnistylesShadowRegistry.remove(ref);
|
|
@@ -54,8 +55,9 @@ export const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
54
55
|
style: state => {
|
|
55
56
|
const isPropStyleAFunction = typeof style === 'function';
|
|
56
57
|
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme();
|
|
57
|
-
UnistylesShadowRegistry.setScopedTheme(
|
|
58
|
+
UnistylesShadowRegistry.setScopedTheme(scope?.name);
|
|
58
59
|
const unistyles = isPropStyleAFunction ? style.call(style, state) : getStyles(style);
|
|
60
|
+
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
59
61
|
if (!storedRef.current) {
|
|
60
62
|
return unistyles;
|
|
61
63
|
}
|
|
@@ -64,8 +66,7 @@ export const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
64
66
|
UnistylesShadowRegistry.remove(storedRef.current);
|
|
65
67
|
|
|
66
68
|
// @ts-expect-error - this is hidden from TS
|
|
67
|
-
UnistylesShadowRegistry.add(storedRef.current, unistyles);
|
|
68
|
-
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
69
|
+
UnistylesShadowRegistry.add(storedRef.current, unistyles, scope);
|
|
69
70
|
return unistyles;
|
|
70
71
|
}
|
|
71
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useLayoutEffect","useRef","Pressable","NativePressableReactNative","passForwardedRef","UnistylesShadowRegistry","jsx","_jsx","getStyles","styleProps","unistyleKey","Object","keys","find","key","startsWith","uni__getStyles","variants","style","props","forwardedRef","storedRef","
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useContext","useLayoutEffect","useRef","Pressable","NativePressableReactNative","passForwardedRef","UnistylesShadowRegistry","ScopedThemeContext","jsx","_jsx","getStyles","styleProps","unistyleKey","Object","keys","find","key","startsWith","uni__getStyles","variants","style","props","forwardedRef","storedRef","scope","current","remove","ref","isPropStyleAFunction","unistyles","call","pressed","add","state","previousScopedTheme","getScopedTheme","setScopedTheme","name"],"sourceRoot":"../../../../src","sources":["components/native/Pressable.native.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,UAAU,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAC9E,SAASC,SAAS,IAAIC,0BAA0B,QAAQ,cAAc;AAItE,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;;AAE1D;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOA,MAAMC,SAAS,GAAGA,CAACC,UAA+B,GAAG,CAAC,CAAC,KAAK;EACxD,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACH,UAAU,CAAC,CAACI,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;EAEvF,IAAI,CAACL,WAAW,EAAE;IACd,OAAOD,UAAU;EACrB;EAEA,OAAO;IACH;IACA,GAAGA,UAAU,CAACC,WAAW,CAAC,CAACM,cAAc,CAAC,CAAC;IAC3C,CAACN,WAAW,GAAGD,UAAU,CAACC,WAAW;EACzC,CAAC;AACL,CAAC;AAED,OAAO,MAAMT,SAAyF,gBAAGJ,UAAU,CAGjH,CAAC;EAAEoB,QAAQ;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,YAAY,KAAK;EAC/C,MAAMC,SAAS,GAAGrB,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMsB,KAAK,GAAGxB,UAAU,CAACO,kBAAkB,CAAC;EAE5CN,eAAe,CAAC,M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;MAEA;MACAvB,uBAAuB,CAACoB,MAAM,CAACH,SAAS,CAACE,OAAO,CAAC;;MAEjD;MACAnB,uBAAuB,CAAC0B,GAAG,CAACT,SAAS,CAACE,OAAO,EAAEI,SAAS,EAAEL,KAAK,CAAC;MAEhE,OAAOK,SAAS;IACpB;EAAE,CACL,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { services } from '../web/services';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const scopeChildren = (name, children) => {
|
|
7
|
+
if (!services.state.CSSVars) {
|
|
8
|
+
return children;
|
|
9
|
+
}
|
|
10
|
+
const scopeProps = name ? {
|
|
11
|
+
'data-unistyles-theme': name
|
|
12
|
+
} : {
|
|
13
|
+
'data-unistyles-reset': ''
|
|
14
|
+
};
|
|
15
|
+
return /*#__PURE__*/_jsx("div", {
|
|
16
|
+
style: {
|
|
17
|
+
display: 'contents'
|
|
18
|
+
},
|
|
19
|
+
...scopeProps,
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=scopeChildren.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","services","jsx","_jsx","scopeChildren","name","children","state","CSSVars","scopeProps","style","display"],"sourceRoot":"../../../src","sources":["components/scopeChildren.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,QAAQ,QAAQ,iBAAiB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAE1C,OAAO,MAAMC,aAAa,GAAGA,CAACC,IAAuC,EAAEC,QAAyB,KAAK;EACjG,IAAI,CAACL,QAAQ,CAACM,KAAK,CAACC,OAAO,EAAE;IACzB,OAAOF,QAAQ;EACnB;EAEA,MAAMG,UAAU,GAAGJ,IAAI,GAAG;IAAE,sBAAsB,EAAEA;EAAK,CAAC,GAAG;IAAE,sBAAsB,EAAE;EAAG,CAAC;EAE3F,oBACIF,IAAA;IAAKO,KAAK,EAAE;MAAEC,OAAO,EAAE;IAAW,CAAE;IAAA,GAAKF,UAAU;IAAAH,QAAA,EAC9CA;EAAQ,CACR,CAAC;AAEd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["scopeChildren","_name","children"],"sourceRoot":"../../../src","sources":["components/scopeChildren.native.ts"],"mappings":";;AAIA,OAAO,MAAMA,aAAa,GAAGA,CAACC,KAAwC,EAAEC,QAAyB,KAAKA,QAAQ","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
4
|
import { isAndroid } from '../common';
|
|
5
|
+
import { ScopedThemeContext } from '../components/ScopedThemeContext';
|
|
5
6
|
import { UnistylesShadowRegistry } from '../specs';
|
|
6
7
|
import { copyComponentProperties } from '../utils';
|
|
7
8
|
import { passForwardedRef } from './passForwardRef';
|
|
@@ -15,6 +16,7 @@ const getWrapperHandle = ref => {
|
|
|
15
16
|
};
|
|
16
17
|
export const createUnistylesActivityIndicator = Component => {
|
|
17
18
|
const UnistylesActivityIndicator = props => {
|
|
19
|
+
const scope = useContext(ScopedThemeContext);
|
|
18
20
|
return /*#__PURE__*/_jsx(Component, {
|
|
19
21
|
...props,
|
|
20
22
|
ref: ref => {
|
|
@@ -22,7 +24,7 @@ export const createUnistylesActivityIndicator = Component => {
|
|
|
22
24
|
const wrapperHandle = getWrapperHandle(ref);
|
|
23
25
|
return passForwardedRef(ref, props.ref, () => {
|
|
24
26
|
// @ts-ignore this is hidden from TS
|
|
25
|
-
UnistylesShadowRegistry.add(wrapperHandle, props.style);
|
|
27
|
+
UnistylesShadowRegistry.add(wrapperHandle, props.style, scope);
|
|
26
28
|
}, () => {
|
|
27
29
|
// @ts-ignore this is hidden from TS
|
|
28
30
|
UnistylesShadowRegistry.remove(wrapperHandle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","isAndroid","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","getWrapperHandle","ref","spinner","__internalInstanceHandle","return","createUnistylesActivityIndicator","Component","UnistylesActivityIndicator","props","style","wrapperHandle","add","remove"],"sourceRoot":"../../../src","sources":["core/createUnistylesActivityIndicator.tsx"],"mappings":";;AAEA,OAAOA,KAAK,
|
|
1
|
+
{"version":3,"names":["React","useContext","isAndroid","ScopedThemeContext","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","getWrapperHandle","ref","spinner","__internalInstanceHandle","return","createUnistylesActivityIndicator","Component","UnistylesActivityIndicator","props","scope","style","wrapperHandle","add","remove"],"sourceRoot":"../../../src","sources":["core/createUnistylesActivityIndicator.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,gBAAgB,GAAIC,GAAQ,IAAK;EACnC,MAAMC,OAAO,GAAGD,GAAG,EAAEE,wBAAwB;EAE7C,OAAO;IACHA,wBAAwB,EAAEX,SAAS,GAAGU,OAAO,EAAEE,MAAM,EAAEA,MAAM,GAAGF,OAAO,EAAEE;EAC7E,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,gCAAgC,GAAIC,SAAmC,IAAK;EACrF,MAAMC,0BAA0B,GAAIC,KAAU,IAAK;IAC/C,MAAMC,KAAK,GAAGlB,UAAU,CAACE,kBAAkB,CAAC;IAE5C,oBACIM,IAAA,CAACO,SAAS;MAAA,GACFE,KAAK;MACTP,GAAG,EAAGA,GAAY,IAAK;QACnBJ,+BAA+B,CAACW,KAAK,CAACE,KAAK,EAAE,mBAAmB,CAAC;QAEjE,MAAMC,aAAa,GAAGX,gBAAgB,CAACC,GAAG,CAAC;QAE3C,OAAOL,gBAAgB,CACnBK,GAAG,EACHO,KAAK,CAACP,GAAG,EACT,MAAM;UACF;UACAP,uBAAuB,CAACkB,GAAG,CAACD,aAAa,EAAEH,KAAK,CAACE,KAAK,EAAED,KAAK,CAAC;QAClE,CAAC,EACD,MAAM;UACF;UACAf,uBAAuB,CAACmB,MAAM,CAACF,aAAa,CAAC;QACjD,CACJ,CAAC;MACL;IAAE,CACL,CAAC;EAEV,CAAC;EAED,OAAOhB,uBAAuB,CAACW,SAAS,EAAEC,0BAA0B,CAAC;AACzE,CAAC","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ import { isServer } from '../web/utils';
|
|
|
7
7
|
import { getClassName } from './getClassname';
|
|
8
8
|
import { maybeWarnAboutMultipleUnistyles } from './warn';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const STYLE_PROPS = ['contentContainerStyle', 'columnWrapperStyle'];
|
|
10
|
+
const STYLE_PROPS = ['contentContainerStyle', 'columnWrapperStyle', 'ListHeaderComponentStyle', 'ListFooterComponentStyle'];
|
|
11
11
|
const buildUnistylesProps = (Component, props) => {
|
|
12
12
|
const componentStyleProps = ['style', ...STYLE_PROPS.filter(styleProp => styleProp in props)];
|
|
13
13
|
componentStyleProps.forEach(styleProp => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useLayoutEffect","useRef","copyComponentProperties","unistyles","isServer","getClassName","maybeWarnAboutMultipleUnistyles","jsx","_jsx","STYLE_PROPS","buildUnistylesProps","Component","props","componentStyleProps","filter","styleProp","forEach","displayName","Object","fromEntries","map","assignRef","ref","value","current","createUnistylesElement","UnistylesComponent","classNames","hashes","values","className","hash","stored","node","unistylesRef","shadowRegistry","services","add","remove","previousHashes","previousRef","join","undefined"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAInE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,OAAO,KAAKC,SAAS,MAAM,iBAAiB;AAC5C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,WAAW,GAAG,
|
|
1
|
+
{"version":3,"names":["React","useCallback","useLayoutEffect","useRef","copyComponentProperties","unistyles","isServer","getClassName","maybeWarnAboutMultipleUnistyles","jsx","_jsx","STYLE_PROPS","buildUnistylesProps","Component","props","componentStyleProps","filter","styleProp","forEach","displayName","Object","fromEntries","map","assignRef","ref","value","current","createUnistylesElement","UnistylesComponent","classNames","hashes","values","className","hash","stored","node","unistylesRef","shadowRegistry","services","add","remove","previousHashes","previousRef","join","undefined"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,eAAe,EAAEC,MAAM,QAAQ,OAAO;AAInE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,OAAO,KAAKC,SAAS,MAAM,iBAAiB;AAC5C,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,WAAW,GAAG,CAChB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,CACpB;AAQV,MAAMC,mBAAmB,GAAGA,CAACC,SAAc,EAAE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SAAS,GAAGR;IAAa,CAAE,CAAC;EAC/F,CAAC;EAED,OAAOhC,uBAAuB,CAACS,SAAS,EAAEe,kBAAkB,CAAC;AACjE,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useRef } from 'react';
|
|
3
|
+
import React, { useContext, useRef } from 'react';
|
|
4
|
+
import { ScopedThemeContext } from '../components/ScopedThemeContext';
|
|
4
5
|
import { UnistylesShadowRegistry } from '../specs';
|
|
5
6
|
import { copyComponentProperties } from '../utils';
|
|
6
7
|
import { passForwardedRef } from './passForwardRef';
|
|
@@ -9,6 +10,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
10
|
export const createUnistylesElement = Component => {
|
|
10
11
|
const UnistylesComponent = props => {
|
|
11
12
|
const scrollViewRef = useRef(null);
|
|
13
|
+
const scope = useContext(ScopedThemeContext);
|
|
12
14
|
return /*#__PURE__*/_jsx(Component, {
|
|
13
15
|
...props,
|
|
14
16
|
ref: ref => {
|
|
@@ -28,7 +30,7 @@ export const createUnistylesElement = Component => {
|
|
|
28
30
|
}
|
|
29
31
|
return passForwardedRef(ref, props.ref, () => {
|
|
30
32
|
// @ts-ignore this is hidden from TS
|
|
31
|
-
UnistylesShadowRegistry.add(ref, props.style);
|
|
33
|
+
UnistylesShadowRegistry.add(ref, props.style, scope);
|
|
32
34
|
}, () => {
|
|
33
35
|
// @ts-ignore this is hidden from TS
|
|
34
36
|
UnistylesShadowRegistry.remove(ref);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesElement","Component","UnistylesComponent","props","scrollViewRef","ref","style","displayName","isScrollView","current","remove","add"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["React","useContext","useRef","ScopedThemeContext","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesElement","Component","UnistylesComponent","props","scrollViewRef","scope","ref","style","displayName","isScrollView","current","remove","add"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,MAAM,QAAQ,OAAO;AAEjD,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,OAAO,MAAMC,sBAAsB,GAAIC,SAAc,IAAK;EACtD,MAAMC,kBAAkB,GAAIC,KAAU,IAAK;IACvC,MAAMC,aAAa,GAAGZ,MAAM,CAAa,IAAI,CAAC;IAC9C,MAAMa,KAAK,GAAGd,UAAU,CAACE,kBAAkB,CAAC;IAE5C,oBACIM,IAAA,CAACE,SAAS;MAAA,GACFE,KAAK;MACTG,GAAG,EAAGA,GAAY,IAAK;QACnBT,+BAA+B,CAACM,KAAK,CAACI,KAAK,EAAEN,SAAS,CAACO,WAAW,CAAC;;QAEnE;QACA;QACA,MAAMC,YAAY,GAAGR,SAAS,CAACO,WAAW,KAAK,YAAY;QAE3D,IAAIC,YAAY,IAAIH,GAAG,EAAE;UACrBF,aAAa,CAACM,OAAO,GAAGJ,GAAiB;QAC7C;QAEA,IAAIG,YAAY,IAAI,CAACH,GAAG,EAAE;UACtB;UACAZ,uBAAuB,CAACiB,MAAM,CAACP,aAAa,CAACM,OAAO,CAAC;UACrDN,aAAa,CAACM,OAAO,GAAG,IAAI;UAE5B;QACJ;QAEA,OAAOd,gBAAgB,CACnBU,GAAG,EACHH,KAAK,CAACG,GAAG,EACT,MAAM;UACF;UACAZ,uBAAuB,CAACkB,GAAG,CAACN,GAAG,EAAEH,KAAK,CAACI,KAAK,EAAEF,KAAK,CAAC;QACxD,CAAC,EACD,MAAM;UACF;UACAX,uBAAuB,CAACiB,MAAM,CAACL,GAAG,CAAC;QACvC,CACJ,CAAC;MACL;IAAE,CACL,CAAC;EAEV,CAAC;EAED,OAAOX,uBAAuB,CAACM,SAAS,EAAEC,kBAAkB,CAAC;AACjE,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
|
+
import { ScopedThemeContext } from '../components/ScopedThemeContext';
|
|
4
5
|
import { UnistylesShadowRegistry } from '../specs';
|
|
5
6
|
import { copyComponentProperties } from '../utils';
|
|
6
7
|
import { passForwardedRef } from './passForwardRef';
|
|
@@ -8,6 +9,8 @@ import { maybeWarnAboutMultipleUnistyles } from './warn';
|
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
export const createUnistylesImageBackground = Component => {
|
|
10
11
|
const UnistylesImageBackground = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
12
|
+
const scope = useContext(ScopedThemeContext);
|
|
13
|
+
|
|
11
14
|
// @ts-expect-error we don't know the type of the component
|
|
12
15
|
maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground');
|
|
13
16
|
// @ts-ignore we don't know the type of the component
|
|
@@ -17,7 +20,7 @@ export const createUnistylesImageBackground = Component => {
|
|
|
17
20
|
ref: ref => {
|
|
18
21
|
return passForwardedRef(ref, forwardedRef, () => {
|
|
19
22
|
// @ts-expect-error - this is hidden from TS
|
|
20
|
-
UnistylesShadowRegistry.add(ref, props.style);
|
|
23
|
+
UnistylesShadowRegistry.add(ref, props.style, scope);
|
|
21
24
|
}, () => {
|
|
22
25
|
// @ts-expect-error - this is hidden from TS
|
|
23
26
|
UnistylesShadowRegistry.remove(ref);
|
|
@@ -25,7 +28,7 @@ export const createUnistylesImageBackground = Component => {
|
|
|
25
28
|
},
|
|
26
29
|
imageRef: ref => {
|
|
27
30
|
// @ts-expect-error web types are not compatible with RN styles
|
|
28
|
-
UnistylesShadowRegistry.add(ref, props.imageStyle);
|
|
31
|
+
UnistylesShadowRegistry.add(ref, props.imageStyle, scope);
|
|
29
32
|
return () => {
|
|
30
33
|
// @ts-ignore this is hidden from TS
|
|
31
34
|
UnistylesShadowRegistry.remove(ref);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesImageBackground","Component","UnistylesImageBackground","forwardRef","props","forwardedRef","style","imageStyle","ref","add","remove","imageRef"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":";;AAEA,OAAOA,KAAK,
|
|
1
|
+
{"version":3,"names":["React","useContext","ScopedThemeContext","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesImageBackground","Component","UnistylesImageBackground","forwardRef","props","forwardedRef","scope","style","imageStyle","ref","add","remove","imageRef"],"sourceRoot":"../../../src","sources":["core/createUnistylesImageBackground.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,OAAO,MAAMC,8BAA8B,GAAIC,SAAiC,IAAK;EACjF,MAAMC,wBAAwB,gBAAGX,KAAK,CAACY,UAAU,CAAwC,CAACC,KAAK,EAAEC,YAAY,KAAK;IAC9G,MAAMC,KAAK,GAAGd,UAAU,CAACC,kBAAkB,CAAC;;IAE5C;IACAI,+BAA+B,CAACO,KAAK,CAACG,KAAK,EAAE,iBAAiB,CAAC;IAC/D;IACAV,+BAA+B,CAACO,KAAK,CAACI,UAAU,EAAE,iBAAiB,CAAC;IAEpE,oBACIT,IAAA,CAACE,SAAS;MAAA,GACFG,KAAK;MACTK,GAAG,EAAGA,GAAG,IAAK;QACV,OAAOb,gBAAgB,CACnBa,GAAG,EACHJ,YAAY,EACZ,MAAM;UACF;UACAX,uBAAuB,CAACgB,GAAG,CAACD,GAAG,EAAEL,KAAK,CAACG,KAAK,EAAED,KAAK,CAAC;QACxD,CAAC,EACD,MAAM;UACF;UACAZ,uBAAuB,CAACiB,MAAM,CAACF,GAAG,CAAC;QACvC,CACJ,CAAC;MACL,CAAE;MACFG,QAAQ,EAAGH,GAAG,IAAK;QACf;QACAf,uBAAuB,CAACgB,GAAG,CAACD,GAAG,EAAEL,KAAK,CAACI,UAAU,EAAEF,KAAK,CAAC;QAEzD,OAAO,MAAM;UACT;UACAZ,uBAAuB,CAACiB,MAAM,CAACF,GAAG,CAAC;QACvC,CAAC;MACL;IAAE,CACL,CAAC;EAEV,CAAC,CAAC;EAEF,OAAOd,uBAAuB,CAACM,SAAS,EAAEC,wBAAwB,CAAC;AACvE,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useContext, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { ScopedThemeContext } from '../components/ScopedThemeContext';
|
|
4
5
|
import { UnistylesShadowRegistry } from '../specs';
|
|
5
6
|
import { copyComponentProperties } from '../utils';
|
|
6
7
|
import { passForwardedRef } from './passForwardRef';
|
|
@@ -8,6 +9,7 @@ import { maybeWarnAboutMultipleUnistyles } from './warn';
|
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
export const createUnistylesTouchableHighlight = Component => {
|
|
10
11
|
const UnistylesTouchableHighlight = props => {
|
|
12
|
+
const scope = useContext(ScopedThemeContext);
|
|
11
13
|
const relinkRef = useRef(undefined);
|
|
12
14
|
const [hiddenUnderlays, setHiddenUnderlays] = useState(0);
|
|
13
15
|
useLayoutEffect(() => {
|
|
@@ -16,28 +18,24 @@ export const createUnistylesTouchableHighlight = Component => {
|
|
|
16
18
|
}
|
|
17
19
|
}, [hiddenUnderlays]);
|
|
18
20
|
|
|
19
|
-
// new props come with a parent render, re-renders for the underlay keep the ref
|
|
21
|
+
// new props come with a parent render, re-renders for the underlay keep the ref
|
|
20
22
|
const ref = useCallback(ref => {
|
|
21
23
|
maybeWarnAboutMultipleUnistyles(props.style, 'TouchableHighlight');
|
|
22
|
-
const scopedTheme = UnistylesShadowRegistry.getScopedTheme();
|
|
23
24
|
relinkRef.current = () => {
|
|
24
|
-
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme();
|
|
25
|
-
UnistylesShadowRegistry.setScopedTheme(scopedTheme);
|
|
26
25
|
// @ts-ignore this is hidden from TS
|
|
27
26
|
UnistylesShadowRegistry.remove(ref);
|
|
28
27
|
// @ts-ignore this is hidden from TS
|
|
29
|
-
UnistylesShadowRegistry.add(ref, props.style);
|
|
30
|
-
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
28
|
+
UnistylesShadowRegistry.add(ref, props.style, scope);
|
|
31
29
|
};
|
|
32
30
|
return passForwardedRef(ref, props.ref, () => {
|
|
33
31
|
// @ts-ignore this is hidden from TS
|
|
34
|
-
UnistylesShadowRegistry.add(ref, props.style);
|
|
32
|
+
UnistylesShadowRegistry.add(ref, props.style, scope);
|
|
35
33
|
}, () => {
|
|
36
34
|
relinkRef.current = undefined;
|
|
37
35
|
// @ts-ignore this is hidden from TS
|
|
38
36
|
UnistylesShadowRegistry.remove(ref);
|
|
39
37
|
});
|
|
40
|
-
}, [props]);
|
|
38
|
+
}, [props, scope]);
|
|
41
39
|
return /*#__PURE__*/_jsx(Component, {
|
|
42
40
|
...props,
|
|
43
41
|
ref: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useLayoutEffect","useRef","useState","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesTouchableHighlight","Component","UnistylesTouchableHighlight","props","relinkRef","undefined","hiddenUnderlays","setHiddenUnderlays","current","ref","style","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useContext","useLayoutEffect","useRef","useState","ScopedThemeContext","UnistylesShadowRegistry","copyComponentProperties","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","createUnistylesTouchableHighlight","Component","UnistylesTouchableHighlight","props","scope","relinkRef","undefined","hiddenUnderlays","setHiddenUnderlays","current","ref","style","remove","add","onHideUnderlay","count"],"sourceRoot":"../../../src","sources":["core/createUnistylesTouchableHighlight.tsx"],"mappings":";;AAEA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,UAAU,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEzF,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,OAAO,MAAMC,iCAAiC,GAAIC,SAAoC,IAAK;EACvF,MAAMC,2BAA2B,GAAIC,KAAU,IAAK;IAChD,MAAMC,KAAK,GAAGf,UAAU,CAACI,kBAAkB,CAAC;IAC5C,MAAMY,SAAS,GAAGd,MAAM,CAAae,SAAS,CAAC;IAC/C,MAAM,CAACC,eAAe,EAAEC,kBAAkB,CAAC,GAAGhB,QAAQ,CAAC,CAAC,CAAC;IAEzDF,eAAe,CAAC,MAAM;MAClB,IAAIiB,eAAe,GAAG,CAAC,EAAE;QACrBF,SAAS,CAACI,OAAO,GAAG,CAAC;MACzB;IACJ,CAAC,EAAE,CAACF,eAAe,CAAC,CAAC;;IAErB;IACA,MAAMG,GAAG,GAAGtB,WAAW,CAClBsB,GAAY,IAAK;MACdb,+BAA+B,CAACM,KAAK,CAACQ,KAAK,EAAE,oBAAoB,CAAC;MAElEN,SAAS,CAACI,OAAO,GAAG,MAAM;QACtB;QACAf,uBAAuB,CAACkB,MAAM,CAACF,GAAG,CAAC;QACnC;QACAhB,uBAAuB,CAACmB,GAAG,CAACH,GAAG,EAAEP,KAAK,CAACQ,KAAK,EAAEP,KAAK,CAAC;MACxD,CAAC;MAED,OAAOR,gBAAgB,CACnBc,GAAG,EACHP,KAAK,CAACO,GAAG,EACT,MAAM;QACF;QACAhB,uBAAuB,CAACmB,GAAG,CAACH,GAAG,EAAEP,KAAK,CAACQ,KAAK,EAAEP,KAAK,CAAC;MACxD,CAAC,EACD,MAAM;QACFC,SAAS,CAACI,OAAO,GAAGH,SAAS;QAC7B;QACAZ,uBAAuB,CAACkB,MAAM,CAACF,GAAG,CAAC;MACvC,CACJ,CAAC;IACL,CAAC,EACD,CAACP,KAAK,EAAEC,KAAK,CACjB,CAAC;IAED,oBACIL,IAAA,CAACE,SAAS;MAAA,GACFE,KAAK;MACTO,GAAG,EAAEA,GAAI;MACTI,cAAc,EAAEA,CAAA,KAAM;QAClBN,kBAAkB,CAAEO,KAAK,IAAKA,KAAK,GAAG,CAAC,CAAC;QACxCZ,KAAK,CAACW,cAAc,GAAG,CAAC;MAC5B;IAAE,CACL,CAAC;EAEV,CAAC;EAED,OAAOnB,uBAAuB,CAACM,SAAS,EAAEC,2BAA2B,CAAC;AAC1E,CAAC","ignoreList":[]}
|
|
@@ -8,13 +8,25 @@ export const passForwardedRef = (ref, forwardedRef, onMount, onUnmount) => {
|
|
|
8
8
|
if (forwardedRef) {
|
|
9
9
|
forwardedRef.current = ref;
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return undefined;
|
|
12
12
|
};
|
|
13
13
|
const forwardedRefReturnFn = passForwardedRef();
|
|
14
14
|
onMount?.();
|
|
15
15
|
return () => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
try {
|
|
17
|
+
// React 19 allows a callback ref to return a cleanup function, but returning
|
|
18
|
+
// any other value is still valid, so it can't be called unconditionally.
|
|
19
|
+
// Without a cleanup function React detaches the ref with null, so do we.
|
|
20
|
+
if (typeof forwardedRefReturnFn === 'function') {
|
|
21
|
+
forwardedRefReturnFn();
|
|
22
|
+
} else if (typeof forwardedRef === 'function') {
|
|
23
|
+
forwardedRef(null);
|
|
24
|
+
} else if (forwardedRef) {
|
|
25
|
+
forwardedRef.current = null;
|
|
26
|
+
}
|
|
27
|
+
} finally {
|
|
28
|
+
onUnmount?.();
|
|
29
|
+
}
|
|
18
30
|
};
|
|
19
31
|
};
|
|
20
32
|
//# sourceMappingURL=passForwardRef.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["passForwardedRef","ref","forwardedRef","onMount","onUnmount","current","forwardedRefReturnFn"],"sourceRoot":"../../../src","sources":["core/passForwardRef.ts"],"mappings":";;AAEA,OAAO,MAAMA,gBAAgB,GAAGA,CAC5BC,GAAM,EACNC,YAAmC,EACnCC,OAAoB,EACpBC,SAAsB,KACrB;EACD,MAAMJ,gBAAgB,GAAGA,CAAA,
|
|
1
|
+
{"version":3,"names":["passForwardedRef","ref","forwardedRef","onMount","onUnmount","current","undefined","forwardedRefReturnFn"],"sourceRoot":"../../../src","sources":["core/passForwardRef.ts"],"mappings":";;AAEA,OAAO,MAAMA,gBAAgB,GAAGA,CAC5BC,GAAM,EACNC,YAAmC,EACnCC,OAAoB,EACpBC,SAAsB,KACrB;EACD,MAAMJ,gBAAgB,GAAGA,CAAA,KAAe;IACpC,IAAI,OAAOE,YAAY,KAAK,UAAU,EAAE;MACpC,OAAOA,YAAY,CAACD,GAAG,CAAC;IAC5B;IAEA,IAAIC,YAAY,EAAE;MACdA,YAAY,CAACG,OAAO,GAAGJ,GAAG;IAC9B;IAEA,OAAOK,SAAS;EACpB,CAAC;EACD,MAAMC,oBAAoB,GAAGP,gBAAgB,CAAC,CAAC;EAE/CG,OAAO,GAAG,CAAC;EAEX,OAAO,MAAM;IACT,IAAI;MACA;MACA;MACA;MACA,IAAI,OAAOI,oBAAoB,KAAK,UAAU,EAAE;QAC5CA,oBAAoB,CAAC,CAAC;MAC1B,CAAC,MAAM,IAAI,OAAOL,YAAY,KAAK,UAAU,EAAE;QAC3CA,YAAY,CAAC,IAAI,CAAC;MACtB,CAAC,MAAM,IAAIA,YAAY,EAAE;QACrBA,YAAY,CAACG,OAAO,GAAG,IAAI;MAC/B;IACJ,CAAC,SAAS;MACND,SAAS,GAAG,CAAC;IACjB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';
|
|
4
|
-
import {
|
|
3
|
+
import { useContext, useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';
|
|
4
|
+
import { ScopedThemeContext } from '../../components/ScopedThemeContext';
|
|
5
|
+
import { UnistylesRuntime } from '../../specs';
|
|
5
6
|
// It's imported that way because of circular dependency
|
|
6
7
|
import { UnistyleDependency } from '../../specs/NativePlatform';
|
|
7
8
|
import { listener } from './listener';
|
|
@@ -25,8 +26,9 @@ const RTDependencyMap = {
|
|
|
25
26
|
themeName: UnistyleDependency.ThemeName,
|
|
26
27
|
rtl: UnistyleDependency.Rtl
|
|
27
28
|
};
|
|
28
|
-
export const useProxifiedUnistyles =
|
|
29
|
-
const
|
|
29
|
+
export const useProxifiedUnistyles = () => {
|
|
30
|
+
const scope = useContext(ScopedThemeContext);
|
|
31
|
+
const [scopedTheme, setScopedTheme] = useState(scope?.name);
|
|
30
32
|
const [dependencies] = useState(() => new Set());
|
|
31
33
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme));
|
|
32
34
|
const [_, runtimeChanged] = useReducer(() => ({}), {});
|
|
@@ -57,9 +59,12 @@ export const useProxifiedUnistyles = forcedTheme => {
|
|
|
57
59
|
syncedDependenciesSizeRef.current = -1;
|
|
58
60
|
};
|
|
59
61
|
}, [disposeRef]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
// Follow the closest ScopedTheme, `reset` included. Every ScopedTheme provides the context, so the registry isn't read:
|
|
64
|
+
// a suspended ScopedTheme can leave its theme there
|
|
65
|
+
if (scope && scopedTheme !== scope.name) {
|
|
66
|
+
setScopedTheme(scope.name);
|
|
67
|
+
setTheme(UnistylesRuntime.getTheme(scope.name));
|
|
63
68
|
}
|
|
64
69
|
const proxifiedTheme = new Proxy(theme, {
|
|
65
70
|
get: (target, prop) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useReducer","useRef","useState","
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","useLayoutEffect","useReducer","useRef","useState","ScopedThemeContext","UnistylesRuntime","UnistyleDependency","listener","getMiniRuntime","miniRuntime","RTDependencyMap","breakpoint","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","rtl","Rtl","useProxifiedUnistyles","scope","scopedTheme","setScopedTheme","name","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","disposeRef","undefined","syncedDependenciesSizeRef","syncedScopedThemeRef","reinitListener","current","Array","from","updateTheme","updateRuntime","hasThemeNameChange","proxifiedTheme","Proxy","get","target","prop","add","Theme","proxifiedRuntime","Ime","sameDeps","size","sameScopedTheme","addDependencies","newDependencies","dependenciesSize","forEach","dependency"],"sourceRoot":"../../../../src","sources":["core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,eAAe,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAI5F,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAAoCC,gBAAgB,QAAQ,aAAa;AACzE;AACA,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,QAAQ,QAAQ,YAAY;AAErC,MAAMC,cAAc,GAAGA,CAAA,KAA4B;EAC/C;EACA,OAAOH,gBAAgB,CAACI,WAAW;AACvC,CAAC;AAED,MAAMC,eAAe,GAAG;EACpBC,UAAU,EAAEL,kBAAkB,CAACM,WAAW;EAC1CC,WAAW,EAAEP,kBAAkB,CAACQ,WAAW;EAC3CC,mBAAmB,EAAET,kBAAkB,CAACU,mBAAmB;EAC3DC,iBAAiB,EAAEX,kBAAkB,CAACY,cAAc;EACpDC,MAAM,EAAEb,kBAAkB,CAACc,MAAM;EACjCC,SAAS,EAAEf,kBAAkB,CAACgB,SAAS;EACvCC,WAAW,EAAEjB,kBAAkB,CAACkB,WAAW;EAC3CC,UAAU,EAAEnB,kBAAkB,CAACkB,WAAW;EAC1CE,aAAa,EAAEpB,kBAAkB,CAACqB,aAAa;EAC/CC,MAAM,EAAEtB,kBAAkB,CAACuB,UAAU;EACrCC,SAAS,EAAExB,kBAAkB,CAACyB,SAAS;EACvCC,UAAU,EAAE1B,kBAAkB,CAAC2B,UAAU;EACzCC,SAAS,EAAE5B,kBAAkB,CAAC6B,SAAS;EACvCC,GAAG,EAAE9B,kBAAkB,CAAC+B;AAC5B,CAA2E;AAE3E,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,KAAK,GAAGzC,UAAU,CAACM,kBAAkB,CAAC;EAC5C,MAAM,CAACoC,WAAW,EAAEC,cAAc,CAAC,G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C,CAAC;EAEFjE,eAAe,CAAC,MAAM;IAClB,MAAMsE,QAAQ,GAAGlB,yBAAyB,CAACG,OAAO,KAAKZ,YAAY,CAAC4B,IAAI;IACxE,MAAMC,eAAe,GAAGnB,oBAAoB,CAACE,OAAO,KAAKf,WAAW;IAEpE,IAAI8B,QAAQ,IAAIE,eAAe,EAAE;MAC7B;IACJ;IAEApB,yBAAyB,CAACG,OAAO,GAAGZ,YAAY,CAAC4B,IAAI;IACrDlB,oBAAoB,CAACE,OAAO,GAAGf,WAAW;IAE1Cc,cAAc,CAAC,CAAC;EACpB,CAAC,EAAE,CAACO,cAAc,EAAEO,gBAAgB,EAAE5B,WAAW,CAAC,CAAC;EAEnD,OAAO;IACHqB,cAAc;IACdO,gBAAgB;IAChBK,eAAe,EAAGC,eAA0C,IAAK;MAC7D,MAAMC,gBAAgB,GAAGhC,YAAY,CAAC4B,IAAI;MAE1CG,eAAe,CAACE,OAAO,CAAEC,UAAU,IAAK;QACpClC,YAAY,CAACuB,GAAG,CAACW,UAAU,CAAC;MAChC,CAAC,CAAC;MAEF,IAAIF,gBAAgB,KAAKhC,YAAY,CAAC4B,IAAI,EAAE;QACxC;MACJ;MAEAnB,yBAAyB,CAACG,OAAO,GAAGZ,YAAY,CAAC4B,IAAI;MACrDlB,oBAAoB,CAACE,OAAO,GAAGf,WAAW;MAC1Cc,cAAc,CAAC,CAAC;IACpB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef,
|
|
3
|
+
import React, { forwardRef, useContext, useEffect } from 'react';
|
|
4
|
+
import { ScopedThemeContext } from '../../components/ScopedThemeContext';
|
|
4
5
|
import { UnistylesShadowRegistry } from '../../specs';
|
|
5
6
|
import { deepMergeObjects } from '../../utils';
|
|
6
7
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles';
|
|
@@ -35,12 +36,12 @@ export const withUnistyles = (Component, mappings) => {
|
|
|
35
36
|
// @ts-ignore we don't know the type of the component
|
|
36
37
|
// prettier-ignore
|
|
37
38
|
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`);
|
|
38
|
-
const
|
|
39
|
+
const scope = useContext(ScopedThemeContext);
|
|
39
40
|
const {
|
|
40
41
|
proxifiedRuntime,
|
|
41
42
|
proxifiedTheme,
|
|
42
43
|
addDependencies
|
|
43
|
-
} = useProxifiedUnistyles(
|
|
44
|
+
} = useProxifiedUnistyles();
|
|
44
45
|
|
|
45
46
|
// Always track Theme dependency — accessing any property on proxifiedTheme
|
|
46
47
|
// triggers the Proxy get trap which adds Theme to the dependency Set
|
|
@@ -58,8 +59,17 @@ export const withUnistyles = (Component, mappings) => {
|
|
|
58
59
|
key: uniPropsKey,
|
|
59
60
|
...unistyleProps
|
|
60
61
|
} = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {};
|
|
62
|
+
|
|
63
|
+
// styles resolve in the registry's scoped theme, which is already restored when this re-renders or mounts later
|
|
64
|
+
const previousScopedTheme = scope ? UnistylesShadowRegistry.getScopedTheme() : undefined;
|
|
65
|
+
if (scope) {
|
|
66
|
+
UnistylesShadowRegistry.setScopedTheme(scope.name);
|
|
67
|
+
}
|
|
61
68
|
const styleSecrets = getSecrets(narrowedProps.style);
|
|
62
69
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle);
|
|
70
|
+
if (scope) {
|
|
71
|
+
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
72
|
+
}
|
|
63
73
|
const finalProps = {
|
|
64
74
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
|
65
75
|
...(narrowedProps.style ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useEffect","
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useContext","useEffect","ScopedThemeContext","UnistylesShadowRegistry","deepMergeObjects","useProxifiedUnistyles","maybeWarnAboutMultipleUnistyles","jsx","_jsx","withUnistyles","Component","mappings","getSecrets","styleProps","styles","Array","isArray","flat","secrets","filter","Boolean","reduce","acc","style","unistyleKey","Object","keys","find","key","startsWith","concat","uni__getStyles","uni__dependencies","secret","assign","dependencies","flatMap","props","ref","narrowedProps","NativeComponent","displayName","name","contentContainerStyle","scope","proxifiedRuntime","proxifiedTheme","addDependencies","__uni","styleSecrets","contentContainerStyleSecrets","from","Set","mappingsKey","mappingsProps","uniPropsKey","unistyleProps","uniProps","previousScopedTheme","getScopedTheme","undefined","setScopedTheme","finalProps"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACRC,UAAU,EACVC,UAAU,EACVC,SAAS,QAIN,OAAO;AAKd,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAAkCC,uBAAuB,QAAQ,aAAa;AAC9E,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,+BAA+B,QAAQ,SAAS;;AAEzD;;AAEA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAaA,OAAO,MAAMC,aAAa,GAAGA,CACzBC,SAAqB,EACrBC,QAA8B,KAC7B;EAUD,MAAMC,UAAU,GAAGA,CAACC,UAA+B,GAAG,CAAC,CAAC,KAAoB;IACxE,MAAMC,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,GAAGA,UAAU,CAACI,IAAI,CAAC,CAAC,GAAG,CAACJ,UAAU,CAAC;IAE3E,MAAMK,OAAgC,GAAGJ,MAAM,CAACK,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,KAAK,KAAK;MACnF,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAACI,IAAI,CAAEC,GAAG,IAAKA,GAA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AC,CAAC,CAAC;MACT,IAAIyB,aAAa,CAACI,qBAAqB,GACjC;QACIA,qBAAqB,EAAEO,4BAA4B,CAACpC;MACxD,CAAC,GACD,CAAC,CAAC;IACZ,CAAQ;IAER,oBAAON,IAAA,CAACgC,eAAe;MAAA,GAAsCsB,UAAU;MAAExB,GAAG,EAAEA;IAAI,GAArDiB,WAAW,IAAIF,WAAwC,CAAC;EACzF,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/lib/module/mocks.js
CHANGED
|
@@ -14,7 +14,7 @@ jest.mock('react-native-nitro-modules', () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
jest.mock('react-native-unistyles', () => {
|
|
16
16
|
const React = require('react');
|
|
17
|
-
const _REGISTRY = {
|
|
17
|
+
const _REGISTRY = globalThis.__UNISTYLES_MOCK_REGISTRY__ ??= {
|
|
18
18
|
themes: {},
|
|
19
19
|
breakpoints: {}
|
|
20
20
|
};
|