react-native-unistyles 3.0.0-beta.5 → 3.0.0-nightly-20250121
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/lib/commonjs/core/createUnistylesElement.native.js +13 -3
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +13 -3
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/createUnistylesElement.native.tsx +14 -4
@@ -11,6 +11,18 @@ var _warn = require("./warn");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
14
|
+
const getNativeRef = (Component, ref) => {
|
15
|
+
switch (Component.name) {
|
16
|
+
case 'KeyboardAvoidingView':
|
17
|
+
return ref.viewRef?.current;
|
18
|
+
case 'FlatList':
|
19
|
+
return ref.getNativeScrollRef?.();
|
20
|
+
case 'VirtualizedList':
|
21
|
+
return ref.getScrollRef?.();
|
22
|
+
default:
|
23
|
+
return ref;
|
24
|
+
}
|
25
|
+
};
|
14
26
|
const createUnistylesElement = Component => /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
|
15
27
|
const storedRef = (0, _react.useRef)(null);
|
16
28
|
(0, _react.useEffect)(() => {
|
@@ -25,9 +37,7 @@ const createUnistylesElement = Component => /*#__PURE__*/_react.default.forwardR
|
|
25
37
|
...props,
|
26
38
|
ref: ref => {
|
27
39
|
if (ref) {
|
28
|
-
storedRef.current = Component
|
29
|
-
// @ts-ignore this is special case for KeyboardAvoidingView
|
30
|
-
? ref.viewRef.current : ref;
|
40
|
+
storedRef.current = getNativeRef(Component, ref);
|
31
41
|
}
|
32
42
|
(0, _passForwardRef.passForwardedRef)(props, ref, forwardedRef);
|
33
43
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_passForwardRef","_warn","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","React","forwardRef","props","forwardedRef","storedRef","useRef","useEffect","UnistylesShadowRegistry","remove","jsx","passForwardedRef","maybeWarnAboutMultipleUnistyles","style","displayName","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAwD,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CA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,CAAC;IAC/B;MACI,OAAOL,GAAG;EAClB;AACJ,CAAC;AAEM,MAAMM,sBAAsB,GAAIP,SAAc,iBAAKQ,cAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,YAAY,KAAK;EAChG,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAU,IAAI,CAAC;EAEvC,IAAAC,gBAAS,EAAC,MAAM;IACZ,OAAO,MAAM;MACT,IAAIF,SAAS,CAACR,OAAO,EAAE;QACnB;QACAW,8BAAuB,CAACC,MAAM,CAACJ,SAAS,CAACR,OAAO,CAAC;MACrD;IACJ,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,oBACI,IAAA1B,WAAA,CAAAuC,GAAA,EAACjB,SAAS;IAAA,GACFU,KAAK;IACTT,GAAG,EAAGA,GAAY,IAAK;MACnB,IAAIA,GAAG,EAAE;QACLW,SAAS,CAACR,OAAO,GAAGL,YAAY,CAACC,SAAS,EAAEC,GAAG,CAAC;MACpD;MAEA,IAAAiB,gCAAgB,EAACR,KAAK,EAAET,GAAG,EAAEU,YAAY,CAAC;;MAE1C;MACA,IAAAQ,qCAA+B,EAACT,KAAK,CAACU,KAAK,EAAEpB,SAAS,CAACqB,WAAW,CAAC;IACvE;EAAE,CACL,CAAC;AAEV,CAAC,CAAC;AAAAC,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
@@ -5,6 +5,18 @@ import { UnistylesShadowRegistry } from '../specs';
|
|
5
5
|
import { passForwardedRef } from './passForwardRef';
|
6
6
|
import { maybeWarnAboutMultipleUnistyles } from './warn';
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
const getNativeRef = (Component, ref) => {
|
9
|
+
switch (Component.name) {
|
10
|
+
case 'KeyboardAvoidingView':
|
11
|
+
return ref.viewRef?.current;
|
12
|
+
case 'FlatList':
|
13
|
+
return ref.getNativeScrollRef?.();
|
14
|
+
case 'VirtualizedList':
|
15
|
+
return ref.getScrollRef?.();
|
16
|
+
default:
|
17
|
+
return ref;
|
18
|
+
}
|
19
|
+
};
|
8
20
|
export const createUnistylesElement = Component => /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
9
21
|
const storedRef = useRef(null);
|
10
22
|
useEffect(() => {
|
@@ -19,9 +31,7 @@ export const createUnistylesElement = Component => /*#__PURE__*/React.forwardRef
|
|
19
31
|
...props,
|
20
32
|
ref: ref => {
|
21
33
|
if (ref) {
|
22
|
-
storedRef.current = Component
|
23
|
-
// @ts-ignore this is special case for KeyboardAvoidingView
|
24
|
-
? ref.viewRef.current : ref;
|
34
|
+
storedRef.current = getNativeRef(Component, ref);
|
25
35
|
}
|
26
36
|
passForwardedRef(props, ref, forwardedRef);
|
27
37
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","UnistylesShadowRegistry","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","UnistylesShadowRegistry","passForwardedRef","maybeWarnAboutMultipleUnistyles","jsx","_jsx","getNativeRef","Component","ref","name","viewRef","current","getNativeScrollRef","getScrollRef","createUnistylesElement","forwardRef","props","forwardedRef","storedRef","remove","style","displayName"],"sourceRoot":"../../../src","sources":["core/createUnistylesElement.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,YAAY,GAAGA,CAACC,SAAc,EAAEC,GAAQ,KAAK;EAC/C,QAAQD,SAAS,CAACE,IAAI;IAClB,KAAK,sBAAsB;MACvB,OAAOD,GAAG,CAACE,OAAO,EAAEC,OAAO;IAC/B,KAAK,UAAU;MACX,OAAOH,GAAG,CAACI,kBAAkB,GAAG,CAAC;IACrC,KAAK,iBAAiB;MAClB,OAAOJ,GAAG,CAACK,YAAY,GAAG,CAAC;IAC/B;MACI,OAAOL,GAAG;EAClB;AACJ,CAAC;AAED,OAAO,MAAMM,sBAAsB,GAAIP,SAAc,iBAAKT,KAAK,CAACiB,UAAU,CAAC,CAACC,KAAK,EAAEC,YAAY,KAAK;EAChG,MAAMC,SAAS,GAAGlB,MAAM,CAAU,IAAI,CAAC;EAEvCD,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACT,IAAImB,SAAS,CAACP,OAAO,EAAE;QACnB;QACAV,uBAAuB,CAACkB,MAAM,CAACD,SAAS,CAACP,OAAO,CAAC;MACrD;IACJ,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,oBACIN,IAAA,CAACE,SAAS;IAAA,GACFS,KAAK;IACTR,GAAG,EAAGA,GAAY,IAAK;MACnB,IAAIA,GAAG,EAAE;QACLU,SAAS,CAACP,OAAO,GAAGL,YAAY,CAACC,SAAS,EAAEC,GAAG,CAAC;MACpD;MAEAN,gBAAgB,CAACc,KAAK,EAAER,GAAG,EAAES,YAAY,CAAC;;MAE1C;MACAd,+BAA+B,CAACa,KAAK,CAACI,KAAK,EAAEb,SAAS,CAACc,WAAW,CAAC;IACvE;EAAE,CACL,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"createUnistylesElement.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesElement.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAkBhD,eAAO,MAAM,sBAAsB,cAAe,GAAG,kEA2BnD,CAAA"}
|
package/package.json
CHANGED
@@ -3,6 +3,19 @@ import { UnistylesShadowRegistry } from '../specs'
|
|
3
3
|
import { passForwardedRef } from './passForwardRef'
|
4
4
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
5
5
|
|
6
|
+
const getNativeRef = (Component: any, ref: any) => {
|
7
|
+
switch (Component.name) {
|
8
|
+
case 'KeyboardAvoidingView':
|
9
|
+
return ref.viewRef?.current
|
10
|
+
case 'FlatList':
|
11
|
+
return ref.getNativeScrollRef?.()
|
12
|
+
case 'VirtualizedList':
|
13
|
+
return ref.getScrollRef?.()
|
14
|
+
default:
|
15
|
+
return ref
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
6
19
|
export const createUnistylesElement = (Component: any) => React.forwardRef((props, forwardedRef) => {
|
7
20
|
const storedRef = useRef<unknown>(null)
|
8
21
|
|
@@ -20,10 +33,7 @@ export const createUnistylesElement = (Component: any) => React.forwardRef((prop
|
|
20
33
|
{...props}
|
21
34
|
ref={(ref: unknown) => {
|
22
35
|
if (ref) {
|
23
|
-
storedRef.current = Component
|
24
|
-
// @ts-ignore this is special case for KeyboardAvoidingView
|
25
|
-
? ref.viewRef.current
|
26
|
-
: ref
|
36
|
+
storedRef.current = getNativeRef(Component, ref)
|
27
37
|
}
|
28
38
|
|
29
39
|
passForwardedRef(props, ref, forwardedRef)
|