react-native-unistyles 3.0.0-alpha.33 → 3.0.0-alpha.34
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/common/Helpers.h +24 -2
- package/cxx/core/HostStyle.cpp +1 -1
- package/cxx/core/UnistyleWrapper.h +31 -1
- package/cxx/core/UnistylesMountHook.cpp +1 -1
- package/cxx/core/UnistylesMountHook.h +4 -2
- package/cxx/core/UnistylesRegistry.cpp +7 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +1 -2
- package/cxx/hybridObjects/HybridShadowRegistry.h +1 -3
- package/cxx/hybridObjects/HybridStyleSheet.cpp +4 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +12 -0
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
- package/cxx/parser/Parser.cpp +6 -6
- package/cxx/parser/Parser.h +1 -1
- package/cxx/shadowTree/ShadowTrafficController.h +2 -0
- package/lib/commonjs/components/Display.js +18 -0
- package/lib/commonjs/components/Display.js.map +1 -0
- package/lib/commonjs/components/Hide.js +18 -0
- package/lib/commonjs/components/Hide.js.map +1 -0
- package/lib/commonjs/components/index.js +20 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/components/useMedia.js +59 -0
- package/lib/commonjs/components/useMedia.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +2 -1
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +40 -2
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/commonjs/core/index.js +0 -14
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/global.js +0 -4
- package/lib/commonjs/global.js.map +1 -1
- package/lib/commonjs/index.js +12 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mq.js +27 -11
- package/lib/commonjs/mq.js.map +1 -2
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +0 -1
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -2
- package/lib/commonjs/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -2
- package/lib/commonjs/specs/ShadowRegistry/types.js +0 -4
- package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -2
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js +4 -2
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +3 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -2
- package/lib/commonjs/specs/TurboUnistyles/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +1 -1
- package/lib/commonjs/specs/index.web.js.map +1 -2
- package/lib/commonjs/specs/types.js +10 -10
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/accessibility.js +9 -9
- package/lib/commonjs/types/accessibility.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js.map +1 -1
- package/lib/commonjs/types/common.js +0 -4
- package/lib/commonjs/types/common.js.map +1 -1
- package/lib/commonjs/types/core.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -2
- package/lib/commonjs/types/stylesheet.js +2 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -2
- package/lib/commonjs/web/convert/index.js +7 -1
- package/lib/commonjs/web/convert/index.js.map +1 -2
- package/lib/commonjs/web/convert/pseudo.js.map +1 -2
- package/lib/commonjs/web/convert/shadow.js +5 -1
- package/lib/commonjs/web/convert/shadow.js.map +1 -2
- package/lib/commonjs/web/convert/style.js.map +1 -2
- package/lib/commonjs/web/convert/textShadow.js.map +1 -2
- package/lib/commonjs/web/convert/transform.js.map +1 -2
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js +2 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -2
- package/lib/commonjs/web/index.js.map +1 -2
- package/lib/commonjs/web/listener.js.map +1 -2
- package/lib/commonjs/web/mock.js.map +1 -2
- package/lib/commonjs/web/runtime.js.map +1 -2
- package/lib/commonjs/web/shadowRegistry.js +9 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -2
- package/lib/commonjs/web/state.js +5 -1
- package/lib/commonjs/web/utils/common.js +3 -1
- package/lib/commonjs/web/utils/common.js.map +1 -2
- package/lib/commonjs/web/utils/index.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +1 -1
- package/lib/commonjs/web/variants/index.js.map +1 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/components/Display.js +13 -0
- package/lib/module/components/Display.js.map +1 -0
- package/lib/module/components/Hide.js +13 -0
- package/lib/module/components/Hide.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/useMedia.js +54 -0
- package/lib/module/components/useMedia.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +2 -1
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesComponent.native.js +41 -3
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/module/core/index.js +0 -2
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/global.js +1 -1
- package/lib/module/global.js.map +0 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mq.js +21 -11
- package/lib/module/mq.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +0 -1
- package/lib/module/specs/NativePlatform/index.js.map +1 -1
- package/lib/module/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +0 -1
- package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +0 -1
- package/lib/module/specs/ShadowRegistry/types.js +0 -2
- package/lib/module/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +0 -1
- package/lib/module/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +0 -1
- package/lib/module/specs/index.web.js.map +1 -2
- package/lib/module/specs/types.js.map +0 -1
- package/lib/module/types/accessibility.js +1 -1
- package/lib/module/types/accessibility.js.map +0 -1
- package/lib/module/types/breakpoints.js.map +0 -1
- package/lib/module/types/common.js +1 -1
- package/lib/module/types/common.js.map +0 -1
- package/lib/module/types/core.js.map +0 -1
- package/lib/module/types/index.js.map +1 -2
- package/lib/module/types/stylesheet.js +2 -2
- package/lib/module/types/stylesheet.js.map +1 -2
- package/lib/module/types/variants.js.map +0 -1
- package/lib/module/web/convert/boxShadow.js +4 -1
- package/lib/module/web/convert/boxShadow.js.map +1 -2
- package/lib/module/web/convert/index.js +7 -1
- package/lib/module/web/convert/shadow.js +5 -1
- package/lib/module/web/convert/shadow.js.map +1 -2
- package/lib/module/web/convert/textShadow.js +4 -1
- package/lib/module/web/convert/utils.js +2 -1
- package/lib/module/web/convert/utils.js.map +1 -2
- package/lib/module/web/create.js +5 -1
- package/lib/module/web/create.js.map +1 -2
- package/lib/module/web/index.js +2 -1
- package/lib/module/web/index.js.map +1 -2
- package/lib/module/web/listener.js.map +1 -2
- package/lib/module/web/registry.js +3 -1
- package/lib/module/web/shadowRegistry.js +9 -1
- package/lib/module/web/shadowRegistry.js.map +1 -2
- package/lib/module/web/state.js +5 -1
- package/lib/module/web/state.js.map +1 -2
- package/lib/module/web/utils/common.js +3 -1
- package/lib/module/web/utils/common.js.map +1 -2
- package/lib/module/web/utils/unistyle.js +1 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants/getVariants.js.map +1 -2
- package/lib/module/web/variants/index.js.map +1 -1
- package/lib/typescript/src/components/Display.d.ts +7 -0
- package/lib/typescript/src/components/Display.d.ts.map +1 -0
- package/lib/typescript/src/components/Hide.d.ts +7 -0
- package/lib/typescript/src/components/Hide.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/useMedia.d.ts +6 -0
- package/lib/typescript/src/components/useMedia.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +3 -2
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +3 -2
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +0 -2
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts +8 -0
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -0
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
- package/package.json +1 -1
- package/plugin/ref.js +4 -4
- package/plugin/style.js +15 -3
- package/src/components/Display.tsx +12 -0
- package/src/components/Hide.tsx +12 -0
- package/src/components/index.ts +2 -0
- package/src/components/useMedia.ts +64 -0
- package/src/core/createUnistylesComponent.native.tsx +48 -4
- package/src/core/createUnistylesComponent.tsx +4 -2
- package/src/core/index.ts +0 -2
- package/src/index.ts +2 -1
- package/src/mq.ts +27 -9
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -0
- package/src/web/utils/unistyle.ts +1 -1
- package/lib/commonjs/core/useBreakpoint.js +0 -22
- package/lib/commonjs/core/useBreakpoint.js.map +0 -1
- package/lib/commonjs/core/useBreakpoint.native.js +0 -24
- package/lib/commonjs/core/useBreakpoint.native.js.map +0 -1
- package/lib/commonjs/core/useTheme.js +0 -22
- package/lib/commonjs/core/useTheme.js.map +0 -2
- package/lib/commonjs/core/useTheme.native.js +0 -24
- package/lib/commonjs/core/useTheme.native.js.map +0 -1
- package/lib/commonjs/web/mq.js +0 -23
- package/lib/commonjs/web/mq.js.map +0 -1
- package/lib/module/core/useBreakpoint.js +0 -17
- package/lib/module/core/useBreakpoint.js.map +0 -1
- package/lib/module/core/useBreakpoint.native.js +0 -19
- package/lib/module/core/useBreakpoint.native.js.map +0 -2
- package/lib/module/core/useTheme.js +0 -17
- package/lib/module/core/useTheme.js.map +0 -2
- package/lib/module/core/useTheme.native.js +0 -19
- package/lib/module/core/useTheme.native.js.map +0 -1
- package/lib/module/web/mq.js +0 -17
- package/lib/module/web/mq.js.map +0 -1
- package/lib/typescript/src/core/useBreakpoint.d.ts +0 -2
- package/lib/typescript/src/core/useBreakpoint.d.ts.map +0 -1
- package/lib/typescript/src/core/useBreakpoint.native.d.ts +0 -2
- package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +0 -1
- package/lib/typescript/src/core/useTheme.d.ts +0 -3
- package/lib/typescript/src/core/useTheme.d.ts.map +0 -1
- package/lib/typescript/src/core/useTheme.native.d.ts +0 -3
- package/lib/typescript/src/core/useTheme.native.d.ts.map +0 -1
- package/lib/typescript/src/web/mq.d.ts +0 -8
- package/lib/typescript/src/web/mq.d.ts.map +0 -1
- package/src/common.js +0 -4
- package/src/core/createUnistylesComponent.js +0 -6
- package/src/core/createUnistylesComponent.native.js +0 -31
- package/src/core/index.js +0 -3
- package/src/core/useBreakpoint.js +0 -14
- package/src/core/useBreakpoint.native.js +0 -16
- package/src/core/useBreakpoint.native.ts +0 -21
- package/src/core/useBreakpoint.ts +0 -18
- package/src/core/useTheme.js +0 -14
- package/src/core/useTheme.native.js +0 -16
- package/src/core/useTheme.native.ts +0 -22
- package/src/core/useTheme.ts +0 -19
- package/src/global.js +0 -1
- package/src/index.js +0 -3
- package/src/mq.js +0 -38
- package/src/specs/NativePlatform/NativePlatform.nitro.js +0 -19
- package/src/specs/NativePlatform/index.js +0 -1
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.js +0 -1
- package/src/specs/NavigtionBar/index.js +0 -9
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.js +0 -1
- package/src/specs/ShadowRegistry/index.js +0 -26
- package/src/specs/ShadowRegistry/types.js +0 -1
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.js +0 -1
- package/src/specs/StatusBar/index.js +0 -25
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.js +0 -1
- package/src/specs/StyleSheet/index.js +0 -13
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.js +0 -2
- package/src/specs/TurboUnistyles/index.js +0 -1
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.js +0 -1
- package/src/specs/UnistylesRuntime/index.js +0 -20
- package/src/specs/index.js +0 -8
- package/src/specs/index.web.js +0 -2
- package/src/specs/types.js +0 -17
- package/src/types/accessibility.js +0 -30
- package/src/types/breakpoints.js +0 -1
- package/src/types/common.js +0 -1
- package/src/types/core.js +0 -1
- package/src/types/index.js +0 -1
- package/src/types/stylesheet.js +0 -2
- package/src/types/variants.js +0 -1
- package/src/web/convert/boxShadow.js +0 -59
- package/src/web/convert/index.js +0 -56
- package/src/web/convert/pseudo.js +0 -131
- package/src/web/convert/shadow.js +0 -50
- package/src/web/convert/style.js +0 -137
- package/src/web/convert/textShadow.js +0 -56
- package/src/web/convert/transform.js +0 -65
- package/src/web/convert/types.js +0 -2
- package/src/web/convert/utils.js +0 -39
- package/src/web/create.js +0 -36
- package/src/web/index.js +0 -22
- package/src/web/listener.js +0 -26
- package/src/web/mock.js +0 -21
- package/src/web/mq.js +0 -14
- package/src/web/mq.ts +0 -17
- package/src/web/registry.js +0 -165
- package/src/web/runtime.js +0 -160
- package/src/web/shadowRegistry.js +0 -96
- package/src/web/state.js +0 -68
- package/src/web/utils/common.js +0 -79
- package/src/web/utils/index.js +0 -2
- package/src/web/utils/unistyle.js +0 -72
- package/src/web/variants/getVariants.js +0 -26
- package/src/web/variants/index.js +0 -2
- package/src/web/variants/useVariants.js +0 -50
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.useTheme = void 0;
|
7
|
-
var _react = require("react");
|
8
|
-
var _specs = require("../specs");
|
9
|
-
const useTheme = () => {
|
10
|
-
const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme());
|
11
|
-
(0, _react.useEffect)(() => {
|
12
|
-
const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
|
13
|
-
if (dependencies.includes(_specs.UnistyleDependency.Theme)) {
|
14
|
-
setTheme(_specs.UnistylesRuntime.getTheme());
|
15
|
-
}
|
16
|
-
});
|
17
|
-
return () => {
|
18
|
-
removeChangeListener();
|
19
|
-
};
|
20
|
-
}, []);
|
21
|
-
return theme;
|
22
|
-
};
|
23
|
-
exports.useTheme = useTheme;
|
24
|
-
//# sourceMappingURL=useTheme.native.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_specs","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,QAAQ,GAAGA,CAAA,KAAsB;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,EAAE;QACjDX,QAAQ,CAACE,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;MACzC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAON,KAAK;AAChB,CAAC;AAAAa,OAAA,CAAAd,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/lib/commonjs/web/mq.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.parseMq = exports.isUnistylesMq = void 0;
|
7
|
-
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
|
-
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
|
-
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
10
|
-
const parseMq = mq => {
|
11
|
-
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
|
12
|
-
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
|
13
|
-
return {
|
14
|
-
minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
|
15
|
-
maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
|
16
|
-
minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
|
17
|
-
maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH)
|
18
|
-
};
|
19
|
-
};
|
20
|
-
exports.parseMq = parseMq;
|
21
|
-
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
22
|
-
exports.isUnistylesMq = isUnistylesMq;
|
23
|
-
//# sourceMappingURL=mq.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","exports","isUnistylesMq","test"],"sourceRoot":"../../../src","sources":["web/mq.js"],"mappings":";;;;;;AAAA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAC7D,MAAMC,OAAO,GAAIC,EAAE,IAAK;EAC3B,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EACpE,OAAO;IACHQ,QAAQ,EAAE,CAACP,KAAK,IAAIC,KAAK,KAAK,UAAU,GAAGO,SAAS,GAAGC,MAAM,CAACR,KAAK,CAAC;IACpES,QAAQ,EAAE,CAACV,KAAK,IAAIE,GAAG,KAAK,UAAU,GAAGM,SAAS,GAAGC,MAAM,CAACP,GAAG,CAAC;IAChES,SAAS,EAAE,CAACP,MAAM,IAAIC,KAAK,KAAK,UAAU,GAAGG,SAAS,GAAGC,MAAM,CAACJ,KAAK,CAAC;IACtEO,SAAS,EAAE,CAACR,MAAM,IAAIE,GAAG,KAAK,UAAU,GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAACO,OAAA,CAAAf,OAAA,GAAAA,OAAA;AACK,MAAMgB,aAAa,GAAIf,EAAE,IAAKJ,kBAAkB,CAACoB,IAAI,CAAChB,EAAE,CAAC;AAACc,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
import { useEffect, useState } from 'react';
|
4
|
-
import { UnistylesRuntime } from '../web';
|
5
|
-
import { UnistylesListener } from '../web/listener';
|
6
|
-
import { UnistyleDependency } from '../specs/NativePlatform';
|
7
|
-
export const useBreakpoint = () => {
|
8
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
9
|
-
useEffect(() => {
|
10
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
|
11
|
-
return () => {
|
12
|
-
removeChangeListener();
|
13
|
-
};
|
14
|
-
}, []);
|
15
|
-
return breakpoint;
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=useBreakpoint.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useState","UnistylesRuntime","UnistylesListener","UnistyleDependency","useBreakpoint","breakpoint","setBreakpoint","removeChangeListener","addListeners","Breakpoints"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,QAAQ;AACzC,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGN,QAAQ,CAACC,gBAAgB,CAACI,UAAU,CAAC;EAEzEN,SAAS,CAAC,MAAM;IACZ,MAAMQ,oBAAoB,GAAGL,iBAAiB,CAACM,YAAY,CAAC,CAACL,kBAAkB,CAACM,WAAW,CAAC,EAAE,MAAMH,aAAa,CAACL,gBAAgB,CAACI,UAAU,CAAC,CAAC;IAE/I,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,UAAU;AACrB,CAAC","ignoreList":[]}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
import { useEffect, useState } from 'react';
|
4
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
5
|
-
export const useBreakpoint = () => {
|
6
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
7
|
-
useEffect(() => {
|
8
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
9
|
-
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
10
|
-
setBreakpoint(UnistylesRuntime.breakpoint);
|
11
|
-
}
|
12
|
-
});
|
13
|
-
return () => {
|
14
|
-
removeChangeListener();
|
15
|
-
};
|
16
|
-
}, []);
|
17
|
-
return breakpoint;
|
18
|
-
};
|
19
|
-
//# sourceMappingURL=useBreakpoint.native.js.map
|
@@ -1,2 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","useBreakpoint","breakpoint","setBreakpoint","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.native.js"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAC3E,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGN,QAAQ,CAACG,gBAAgB,CAACE,UAAU,CAAC;EACzEN,SAAS,CAAC,MAAM;IACZ,MAAMQ,oBAAoB,GAAGN,UAAU,CAACO,iBAAiB,CAACC,YAAY,IAAI;MACtE,IAAIA,YAAY,CAACC,QAAQ,CAACR,kBAAkB,CAACS,WAAW,CAAC,EAAE;QACvDL,aAAa,CAACH,gBAAgB,CAACE,UAAU,CAAC;MAC9C;IACJ,CAAC,CAAC;IACF,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAOF,UAAU;AACrB,CAAC","ignoreList":[]}
|
2
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
import { useEffect, useState } from 'react';
|
4
|
-
import { UnistylesRuntime } from '../web';
|
5
|
-
import { UnistylesListener } from '../web/listener';
|
6
|
-
import { UnistyleDependency } from '../specs/NativePlatform';
|
7
|
-
export const useTheme = () => {
|
8
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
9
|
-
useEffect(() => {
|
10
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()));
|
11
|
-
return () => {
|
12
|
-
removeChangeListener();
|
13
|
-
};
|
14
|
-
}, []);
|
15
|
-
return theme;
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=useTheme.js.map
|
@@ -1,2 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useState","UnistylesRuntime","UnistylesListener","UnistyleDependency","useTheme","theme","setTheme","getTheme","removeChangeListener","addListeners","Theme"],"sourceRoot":"../../../src","sources":["core/useTheme.js"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,QAAQ;AACzC,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGN,QAAQ,CAACC,gBAAgB,CAACM,QAAQ,CAAC,CAAC,CAAC;EAC/DR,SAAS,CAAC,MAAM;IACZ,MAAMS,oBAAoB,GAAGN,iBAAiB,CAACO,YAAY,CAAC,CAACN,kBAAkB,CAACO,KAAK,CAAC,EAAE,MAAMJ,QAAQ,CAACL,gBAAgB,CAACM,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpI,OAAO,MAAM;MACTC,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
|
2
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
import { useEffect, useState } from 'react';
|
4
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
5
|
-
export const useTheme = () => {
|
6
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
7
|
-
useEffect(() => {
|
8
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
9
|
-
if (dependencies.includes(UnistyleDependency.Theme)) {
|
10
|
-
setTheme(UnistylesRuntime.getTheme());
|
11
|
-
}
|
12
|
-
});
|
13
|
-
return () => {
|
14
|
-
removeChangeListener();
|
15
|
-
};
|
16
|
-
}, []);
|
17
|
-
return theme;
|
18
|
-
};
|
19
|
-
//# sourceMappingURL=useTheme.native.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","useTheme","theme","setTheme","getTheme","removeChangeListener","addChangeListener","dependencies","includes","Theme"],"sourceRoot":"../../../src","sources":["core/useTheme.native.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAI3E,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAsB;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGN,QAAQ,CAACG,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;EAE/DR,SAAS,CAAC,MAAM;IACZ,MAAMS,oBAAoB,GAAIP,UAAU,CAAyBQ,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACT,kBAAkB,CAACU,KAAK,CAAC,EAAE;QACjDN,QAAQ,CAACH,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;MACzC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTC,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
|
package/lib/module/web/mq.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
4
|
-
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
5
|
-
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
6
|
-
export const parseMq = mq => {
|
7
|
-
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
|
8
|
-
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
|
9
|
-
return {
|
10
|
-
minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
|
11
|
-
maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
|
12
|
-
minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
|
13
|
-
maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH)
|
14
|
-
};
|
15
|
-
};
|
16
|
-
export const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
17
|
-
//# sourceMappingURL=mq.js.map
|
package/lib/module/web/mq.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","isUnistylesMq","test"],"sourceRoot":"../../../src","sources":["web/mq.ts"],"mappings":";;AAAA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAEpE,OAAO,MAAMC,OAAO,GAAIC,EAAU,IAAK;EACnC,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHQ,QAAQ,EAAE,CAACP,KAAK,IAAIC,KAAK,KAAK,UAAU,GAAGO,SAAS,GAAGC,MAAM,CAACR,KAAK,CAAC;IACpES,QAAQ,EAAE,CAACV,KAAK,IAAIE,GAAG,KAAK,UAAU,GAAGM,SAAS,GAAGC,MAAM,CAACP,GAAG,CAAC;IAChES,SAAS,EAAE,CAACP,MAAM,IAAIC,KAAK,KAAK,UAAU,GAAGG,SAAS,GAAGC,MAAM,CAACJ,KAAK,CAAC;IACtEO,SAAS,EAAE,CAACR,MAAM,IAAIE,GAAG,KAAK,UAAU,GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAED,OAAO,MAAMO,aAAa,GAAId,EAAU,IAAKJ,kBAAkB,CAACmB,IAAI,CAACf,EAAE,CAAC","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useBreakpoint.d.ts","sourceRoot":"","sources":["../../../../src/core/useBreakpoint.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,4CAYzB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useBreakpoint.native.d.ts","sourceRoot":"","sources":["../../../../src/core/useBreakpoint.native.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,4CAgBzB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../src/core/useTheme.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,QAAQ,QAAO,cAY3B,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTheme.native.d.ts","sourceRoot":"","sources":["../../../../src/core/useTheme.native.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,QAAQ,QAAO,cAgB3B,CAAA"}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
export declare const parseMq: (mq: string) => {
|
2
|
-
minWidth: number | undefined;
|
3
|
-
maxWidth: number | undefined;
|
4
|
-
minHeight: number | undefined;
|
5
|
-
maxHeight: number | undefined;
|
6
|
-
};
|
7
|
-
export declare const isUnistylesMq: (mq: string) => boolean;
|
8
|
-
//# sourceMappingURL=mq.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/web/mq.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,OAAQ,MAAM;;;;;CAUjC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA"}
|
package/src/common.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
2
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
3
|
-
export const createUnistylesComponent = (Component, mappings) => {
|
4
|
-
return (props) => {
|
5
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
6
|
-
const [, setRt] = useState(0);
|
7
|
-
useEffect(() => {
|
8
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
9
|
-
const componentDependencies = (props.style?.uni__dependencies || mappings(theme).style?.uni__dependencies);
|
10
|
-
if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies || componentDependencies.includes(UnistyleDependency.Theme))) {
|
11
|
-
setTheme(UnistylesRuntime.getTheme());
|
12
|
-
}
|
13
|
-
if (dependencies.some(dependency => dependency >= 2) && (!componentDependencies || componentDependencies.some(dependency => dependency >= 2))) {
|
14
|
-
setRt(prevState => prevState + 1);
|
15
|
-
}
|
16
|
-
});
|
17
|
-
return () => {
|
18
|
-
removeChangeListener();
|
19
|
-
};
|
20
|
-
}, []);
|
21
|
-
const mergedProps = { ...mappings(theme) };
|
22
|
-
Object.keys(props).forEach(key => {
|
23
|
-
if (key in mergedProps) {
|
24
|
-
mergedProps[key] = Object.assign(props[key], mergedProps[key]);
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
mergedProps[key] = props[key];
|
28
|
-
});
|
29
|
-
return React.createElement(Component, { ...mergedProps });
|
30
|
-
};
|
31
|
-
};
|
package/src/core/index.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react';
|
2
|
-
import { UnistylesRuntime } from '../web';
|
3
|
-
import { UnistylesListener } from '../web/listener';
|
4
|
-
import { UnistyleDependency } from '../specs/NativePlatform';
|
5
|
-
export const useBreakpoint = () => {
|
6
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
7
|
-
useEffect(() => {
|
8
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
|
9
|
-
return () => {
|
10
|
-
removeChangeListener();
|
11
|
-
};
|
12
|
-
}, []);
|
13
|
-
return breakpoint;
|
14
|
-
};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react';
|
2
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
3
|
-
export const useBreakpoint = () => {
|
4
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
5
|
-
useEffect(() => {
|
6
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
7
|
-
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
8
|
-
setBreakpoint(UnistylesRuntime.breakpoint);
|
9
|
-
}
|
10
|
-
});
|
11
|
-
return () => {
|
12
|
-
removeChangeListener();
|
13
|
-
};
|
14
|
-
}, []);
|
15
|
-
return breakpoint;
|
16
|
-
};
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react'
|
2
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
3
|
-
import type { UnistylesStyleSheet } from '../specs'
|
4
|
-
|
5
|
-
export const useBreakpoint = () => {
|
6
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
|
7
|
-
|
8
|
-
useEffect(() => {
|
9
|
-
const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
|
10
|
-
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
11
|
-
setBreakpoint(UnistylesRuntime.breakpoint)
|
12
|
-
}
|
13
|
-
})
|
14
|
-
|
15
|
-
return () => {
|
16
|
-
removeChangeListener()
|
17
|
-
}
|
18
|
-
}, [])
|
19
|
-
|
20
|
-
return breakpoint
|
21
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react'
|
2
|
-
import { UnistylesRuntime } from '../web'
|
3
|
-
import { UnistylesListener } from '../web/listener'
|
4
|
-
import { UnistyleDependency } from '../specs/NativePlatform'
|
5
|
-
|
6
|
-
export const useBreakpoint = () => {
|
7
|
-
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
|
8
|
-
|
9
|
-
useEffect(() => {
|
10
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint))
|
11
|
-
|
12
|
-
return () => {
|
13
|
-
removeChangeListener()
|
14
|
-
}
|
15
|
-
}, [])
|
16
|
-
|
17
|
-
return breakpoint
|
18
|
-
}
|
package/src/core/useTheme.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react';
|
2
|
-
import { UnistylesRuntime } from '../web';
|
3
|
-
import { UnistylesListener } from '../web/listener';
|
4
|
-
import { UnistyleDependency } from '../specs/NativePlatform';
|
5
|
-
export const useTheme = () => {
|
6
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
7
|
-
useEffect(() => {
|
8
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()));
|
9
|
-
return () => {
|
10
|
-
removeChangeListener();
|
11
|
-
};
|
12
|
-
}, []);
|
13
|
-
return theme;
|
14
|
-
};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react';
|
2
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
3
|
-
export const useTheme = () => {
|
4
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
5
|
-
useEffect(() => {
|
6
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
7
|
-
if (dependencies.includes(UnistyleDependency.Theme)) {
|
8
|
-
setTheme(UnistylesRuntime.getTheme());
|
9
|
-
}
|
10
|
-
});
|
11
|
-
return () => {
|
12
|
-
removeChangeListener();
|
13
|
-
};
|
14
|
-
}, []);
|
15
|
-
return theme;
|
16
|
-
};
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react'
|
2
|
-
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
3
|
-
import type { UnistylesStyleSheet } from '../specs'
|
4
|
-
import type { UnistylesTheme } from '../types'
|
5
|
-
|
6
|
-
export const useTheme = (): UnistylesTheme => {
|
7
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
|
8
|
-
|
9
|
-
useEffect(() => {
|
10
|
-
const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
|
11
|
-
if (dependencies.includes(UnistyleDependency.Theme)) {
|
12
|
-
setTheme(UnistylesRuntime.getTheme())
|
13
|
-
}
|
14
|
-
})
|
15
|
-
|
16
|
-
return () => {
|
17
|
-
removeChangeListener()
|
18
|
-
}
|
19
|
-
}, [])
|
20
|
-
|
21
|
-
return theme
|
22
|
-
}
|
package/src/core/useTheme.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { useEffect, useState } from 'react'
|
2
|
-
import { UnistylesRuntime } from '../web'
|
3
|
-
import { UnistylesListener } from '../web/listener'
|
4
|
-
import { UnistyleDependency } from '../specs/NativePlatform'
|
5
|
-
import type { UnistylesTheme } from '../types'
|
6
|
-
|
7
|
-
export const useTheme = (): UnistylesTheme => {
|
8
|
-
const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
|
9
|
-
|
10
|
-
useEffect(() => {
|
11
|
-
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()))
|
12
|
-
|
13
|
-
return () => {
|
14
|
-
removeChangeListener()
|
15
|
-
}
|
16
|
-
}, [])
|
17
|
-
|
18
|
-
return theme
|
19
|
-
}
|
package/src/global.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/src/index.js
DELETED
package/src/mq.js
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
const getMQValue = (value) => {
|
2
|
-
if (typeof value === 'number') {
|
3
|
-
return value;
|
4
|
-
}
|
5
|
-
if (value === null) {
|
6
|
-
return 0;
|
7
|
-
}
|
8
|
-
// todo take it from js
|
9
|
-
const breakpoints = {
|
10
|
-
xs: 0,
|
11
|
-
sm: 300,
|
12
|
-
md: 500,
|
13
|
-
lg: 800,
|
14
|
-
xl: 1200
|
15
|
-
};
|
16
|
-
// @ts-ignore
|
17
|
-
return breakpoints[value] ?? 0;
|
18
|
-
};
|
19
|
-
/**
|
20
|
-
* Utility to create cross-platform media queries
|
21
|
-
* @returns - JavaScript symbol to be used in your stylesheet
|
22
|
-
*/
|
23
|
-
export const mq = {
|
24
|
-
only: {
|
25
|
-
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
|
26
|
-
height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
27
|
-
},
|
28
|
-
width: (wMin = 0, wMax = Infinity) => ({
|
29
|
-
and: {
|
30
|
-
height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
31
|
-
}
|
32
|
-
}),
|
33
|
-
height: (hMin = 0, hMax = Infinity) => ({
|
34
|
-
and: {
|
35
|
-
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
36
|
-
}
|
37
|
-
})
|
38
|
-
};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import {} from '../types';
|
2
|
-
export var UnistyleDependency;
|
3
|
-
(function (UnistyleDependency) {
|
4
|
-
UnistyleDependency[UnistyleDependency["Theme"] = 0] = "Theme";
|
5
|
-
UnistyleDependency[UnistyleDependency["ThemeName"] = 1] = "ThemeName";
|
6
|
-
UnistyleDependency[UnistyleDependency["AdaptiveThemes"] = 2] = "AdaptiveThemes";
|
7
|
-
UnistyleDependency[UnistyleDependency["Breakpoints"] = 3] = "Breakpoints";
|
8
|
-
UnistyleDependency[UnistyleDependency["Variants"] = 4] = "Variants";
|
9
|
-
UnistyleDependency[UnistyleDependency["ColorScheme"] = 5] = "ColorScheme";
|
10
|
-
UnistyleDependency[UnistyleDependency["Dimensions"] = 6] = "Dimensions";
|
11
|
-
UnistyleDependency[UnistyleDependency["Orientation"] = 7] = "Orientation";
|
12
|
-
UnistyleDependency[UnistyleDependency["ContentSizeCategory"] = 8] = "ContentSizeCategory";
|
13
|
-
UnistyleDependency[UnistyleDependency["Insets"] = 9] = "Insets";
|
14
|
-
UnistyleDependency[UnistyleDependency["PixelRatio"] = 10] = "PixelRatio";
|
15
|
-
UnistyleDependency[UnistyleDependency["FontScale"] = 11] = "FontScale";
|
16
|
-
UnistyleDependency[UnistyleDependency["StatusBar"] = 12] = "StatusBar";
|
17
|
-
UnistyleDependency[UnistyleDependency["NavigationBar"] = 13] = "NavigationBar";
|
18
|
-
UnistyleDependency[UnistyleDependency["Ime"] = 14] = "Ime";
|
19
|
-
})(UnistyleDependency || (UnistyleDependency = {}));
|
@@ -1 +0,0 @@
|
|
1
|
-
export { UnistyleDependency } from './NativePlatform.nitro';
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { processColor } from 'react-native';
|
2
|
-
export const attachNavigationBarJSMethods = (hybridObject) => {
|
3
|
-
const privateHybrid = hybridObject;
|
4
|
-
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
5
|
-
hybridObject.setBackgroundColor = (color) => {
|
6
|
-
const parsedColor = processColor(color) ?? 0;
|
7
|
-
privateHybrid._setBackgroundColor(parsedColor);
|
8
|
-
};
|
9
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
-
const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
|
3
|
-
const findShadowNodeForHandle = (handle) => {
|
4
|
-
const node = handle?.__internalInstanceHandle?.stateNode?.node
|
5
|
-
?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
|
6
|
-
?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
|
7
|
-
if (!node) {
|
8
|
-
// todo extend log with file name / component name
|
9
|
-
throw new Error('Could not find shadow node for one of your components');
|
10
|
-
}
|
11
|
-
return node;
|
12
|
-
};
|
13
|
-
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
14
|
-
// virtualized nodes can be null
|
15
|
-
if (!handle || !style) {
|
16
|
-
return;
|
17
|
-
}
|
18
|
-
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
19
|
-
};
|
20
|
-
HybridShadowRegistry.remove = handle => {
|
21
|
-
if (!handle) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
|
25
|
-
};
|
26
|
-
export const UnistylesShadowRegistry = HybridShadowRegistry;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { processColor, StatusBar as NativeStatusBar } from 'react-native';
|
2
|
-
import { StatusBarStyle } from '../types';
|
3
|
-
export const attachStatusBarJSMethods = (hybridObject) => {
|
4
|
-
hybridObject.setStyle = (style, animated) => {
|
5
|
-
switch (style) {
|
6
|
-
case StatusBarStyle.Light:
|
7
|
-
return NativeStatusBar.setBarStyle('light-content', animated);
|
8
|
-
case StatusBarStyle.Dark:
|
9
|
-
return NativeStatusBar.setBarStyle('dark-content', animated);
|
10
|
-
case StatusBarStyle.Default:
|
11
|
-
return NativeStatusBar.setBarStyle('default', animated);
|
12
|
-
}
|
13
|
-
};
|
14
|
-
const privateHybrid = hybridObject;
|
15
|
-
privateHybrid._setHidden = hybridObject.setHidden;
|
16
|
-
hybridObject.setHidden = (isHidden, animation) => {
|
17
|
-
NativeStatusBar.setHidden(isHidden, animation);
|
18
|
-
privateHybrid._setHidden(isHidden);
|
19
|
-
};
|
20
|
-
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
21
|
-
hybridObject.setBackgroundColor = (color) => {
|
22
|
-
const parsedColor = processColor(color) ?? 0;
|
23
|
-
privateHybrid._setBackgroundColor(parsedColor);
|
24
|
-
};
|
25
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
import { UnistyleDependency } from '../NativePlatform';
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
-
import { processColor, StyleSheet as NativeStyleSheet } from 'react-native';
|
3
|
-
const HybridUnistylesStyleSheet = NitroModules
|
4
|
-
.createHybridObject('UnistylesStyleSheet');
|
5
|
-
HybridUnistylesStyleSheet.absoluteFillObject = NativeStyleSheet.absoluteFillObject;
|
6
|
-
HybridUnistylesStyleSheet.absoluteFill = NativeStyleSheet.absoluteFill;
|
7
|
-
HybridUnistylesStyleSheet.flatten = NativeStyleSheet.flatten;
|
8
|
-
HybridUnistylesStyleSheet.compose = NativeStyleSheet.compose;
|
9
|
-
HybridUnistylesStyleSheet.jsMethods = {
|
10
|
-
processColor
|
11
|
-
};
|
12
|
-
HybridUnistylesStyleSheet.init();
|
13
|
-
export const StyleSheet = HybridUnistylesStyleSheet;
|
@@ -1 +0,0 @@
|
|
1
|
-
import './NativeTurboUnistyles';
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|