react-native-unistyles 3.0.0-alpha.35 → 3.0.0-alpha.37
Sign up to get free protection for your applications and to get access to all the features.
- package/Unistyles.podspec +1 -1
- package/android/CMakeLists.txt +19 -36
- package/android/build.gradle +2 -1
- package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
- package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
- package/android/src/main/cxx/cpp-adapter.cpp +8 -86
- package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +302 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +148 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +54 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
- package/cxx/NativePlatform.h +11 -0
- package/cxx/common/Helpers.h +1 -1
- package/cxx/core/Unistyle.h +1 -1
- package/cxx/core/UnistyleData.h +1 -1
- package/cxx/core/UnistyleWrapper.h +1 -2
- package/cxx/core/UnistylesCommitHook.cpp +1 -1
- package/cxx/core/UnistylesMountHook.cpp +1 -1
- package/cxx/core/UnistylesRegistry.cpp +4 -13
- package/cxx/core/UnistylesRegistry.h +2 -3
- package/cxx/core/UnistylesState.cpp +10 -7
- package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
- package/cxx/hybridObjects/HybridStatusBar.h +3 -3
- package/cxx/hybridObjects/HybridStyleSheet.cpp +21 -18
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -8
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -3
- package/cxx/parser/Parser.cpp +3 -27
- package/cxx/parser/Parser.h +2 -3
- package/cxx/shadowTree/ShadowTrafficController.h +9 -5
- package/cxx/shadowTree/ShadowTreeManager.cpp +10 -5
- package/cxx/shadowTree/ShadowTreeManager.h +1 -1
- package/lib/commonjs/components/useMedia.js.map +1 -1
- package/lib/commonjs/components/useMedia.web.js +43 -0
- package/lib/commonjs/components/useMedia.web.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +57 -4
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +16 -11
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/object/filter.js +42 -0
- package/lib/commonjs/web/convert/object/filter.js.map +1 -0
- package/lib/commonjs/web/convert/object/index.js +39 -0
- package/lib/commonjs/web/convert/object/index.js.map +1 -0
- package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
- package/lib/commonjs/web/convert/object/transform.js +27 -0
- package/lib/commonjs/web/convert/object/transform.js.map +1 -0
- package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/commonjs/web/convert/shadow/index.js +28 -0
- package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
- package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +7 -3
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/listener.js +10 -0
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js +13 -26
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +3 -0
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +79 -39
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +3 -33
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +4 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/useMedia.js.map +1 -1
- package/lib/module/components/useMedia.web.js +38 -0
- package/lib/module/components/useMedia.web.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +55 -3
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesComponent.native.js +6 -5
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/module/web/convert/index.js +14 -9
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +53 -0
- package/lib/module/web/convert/object/boxShadow.js.map +1 -0
- package/lib/module/web/convert/object/filter.js +37 -0
- package/lib/module/web/convert/object/filter.js.map +1 -0
- package/lib/module/web/convert/object/index.js +6 -0
- package/lib/module/web/convert/object/index.js.map +1 -0
- package/lib/module/web/convert/object/objectStyle.js +50 -0
- package/lib/module/web/convert/object/objectStyle.js.map +1 -0
- package/lib/module/web/convert/object/transform.js +22 -0
- package/lib/module/web/convert/object/transform.js.map +1 -0
- package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
- package/lib/module/web/convert/shadow/index.js +5 -0
- package/lib/module/web/convert/shadow/index.js.map +1 -0
- package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
- package/lib/module/web/convert/utils.js +4 -2
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/listener.js +10 -0
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js +14 -27
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +3 -0
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +80 -40
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -31
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +4 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
- package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +1 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
- package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/types.d.ts +7 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +8 -4
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +8 -8
- package/lib/typescript/src/web/index.d.ts +8 -8
- package/lib/typescript/src/web/listener.d.ts +2 -0
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +5 -9
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts +1 -6
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
- package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
- package/package.json +3 -3
- package/src/components/useMedia.ts +1 -1
- package/src/components/useMedia.web.ts +47 -0
- package/src/core/createUnistylesComponent.native.tsx +12 -10
- package/src/core/createUnistylesComponent.tsx +72 -6
- package/src/types/common.ts +1 -0
- package/src/web/convert/index.ts +16 -9
- package/src/web/convert/object/boxShadow.ts +54 -0
- package/src/web/convert/object/filter.ts +39 -0
- package/src/web/convert/object/index.ts +3 -0
- package/src/web/convert/object/objectStyle.ts +68 -0
- package/src/web/convert/object/transform.ts +24 -0
- package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
- package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
- package/src/web/convert/shadow/index.ts +2 -0
- package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
- package/src/web/convert/types.ts +8 -1
- package/src/web/convert/utils.ts +11 -5
- package/src/web/listener.ts +10 -0
- package/src/web/registry.ts +10 -31
- package/src/web/runtime.ts +4 -0
- package/src/web/shadowRegistry.ts +85 -46
- package/src/web/utils/common.ts +1 -37
- package/src/web/utils/unistyle.ts +5 -1
- package/android/src/main/cxx/helpers.cpp +0 -105
- package/android/src/main/cxx/helpers.h +0 -16
- package/android/src/main/cxx/platform.cpp +0 -170
- package/android/src/main/cxx/platform.h +0 -20
- package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
- package/lib/commonjs/web/convert/shadow.js +0 -68
- package/lib/commonjs/web/convert/shadow.js.map +0 -1
- package/lib/commonjs/web/convert/textShadow.js.map +0 -1
- package/lib/commonjs/web/convert/transform.js +0 -72
- package/lib/commonjs/web/convert/transform.js.map +0 -1
- package/lib/module/web/convert/boxShadow.js.map +0 -1
- package/lib/module/web/convert/shadow.js +0 -63
- package/lib/module/web/convert/shadow.js.map +0 -1
- package/lib/module/web/convert/textShadow.js.map +0 -1
- package/lib/module/web/convert/transform.js +0 -67
- package/lib/module/web/convert/transform.js.map +0 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
- package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/src/web/convert/transform.d.ts +0 -4
- package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
- package/src/web/convert/shadow.ts +0 -68
- package/src/web/convert/transform.ts +0 -88
- /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
- /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.UnistylesShadowRegistry = void 0;
|
7
|
+
var _convert = require("./convert");
|
8
|
+
var _listener = require("./listener");
|
7
9
|
var _registry = require("./registry");
|
8
10
|
var _utils = require("./utils");
|
9
11
|
var _variants2 = require("./variants");
|
@@ -16,9 +18,12 @@ class UnistylesShadowRegistryBuilder {
|
|
16
18
|
dispose = () => {};
|
17
19
|
// END MOCKS
|
18
20
|
|
19
|
-
resultsMap =
|
20
|
-
|
21
|
-
|
21
|
+
resultsMap = new Map();
|
22
|
+
hashMap = new Map();
|
23
|
+
classNamesMap = new Map();
|
24
|
+
timeoutMap = new Map();
|
25
|
+
queuedResultMap = new Map();
|
26
|
+
add = (ref, _style, _variants, _args) => new Promise(resolve => {
|
22
27
|
// Style is not provided
|
23
28
|
if (!_style) {
|
24
29
|
return;
|
@@ -39,16 +44,15 @@ class UnistylesShadowRegistryBuilder {
|
|
39
44
|
if (ref === null) {
|
40
45
|
const secrets = (0, _utils.extractSecrets)(_style);
|
41
46
|
secrets.forEach(({
|
42
|
-
__uni__refs
|
43
|
-
__uni__key
|
47
|
+
__uni__refs
|
44
48
|
}) => {
|
45
49
|
__uni__refs.forEach(ref => {
|
46
50
|
if ((0, _utils.isInDocument)(ref)) {
|
47
51
|
return;
|
48
52
|
}
|
49
|
-
const oldResult = this.resultsMap.get(ref
|
50
|
-
this.resultsMap.delete(ref
|
51
|
-
this.classNamesMap.delete(ref
|
53
|
+
const oldResult = this.resultsMap.get(ref);
|
54
|
+
this.resultsMap.delete(ref);
|
55
|
+
this.classNamesMap.delete(ref);
|
52
56
|
if (oldResult) {
|
53
57
|
_registry.UnistylesRegistry.remove(oldResult);
|
54
58
|
}
|
@@ -80,42 +84,78 @@ class UnistylesShadowRegistryBuilder {
|
|
80
84
|
variantsResult: result
|
81
85
|
}, variants));
|
82
86
|
const resultWithVariants = (0, _utils.deepMergeObjects)(result, variantsResult ?? {});
|
83
|
-
const oldResult = this.resultsMap.get(ref, __uni__key);
|
84
87
|
|
85
|
-
//
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
const
|
88
|
+
// Get stored result from queue
|
89
|
+
const storedResult = this.queuedResultMap.get(ref) ?? {};
|
90
|
+
// Merge stored result with new result
|
91
|
+
const newResult = (0, _utils.deepMergeObjects)(storedResult, resultWithVariants);
|
92
|
+
const timeout = this.timeoutMap.get(ref);
|
93
|
+
|
94
|
+
// Add callback to the queue and remove old one
|
95
|
+
this.queuedResultMap.set(ref, newResult);
|
96
|
+
clearTimeout(timeout);
|
97
|
+
this.timeoutMap.set(ref, setTimeout(() => {
|
98
|
+
const oldResult = this.resultsMap.get(ref);
|
99
|
+
|
100
|
+
// If results are the same do nothing
|
101
|
+
if ((0, _utils.equal)(oldResult, newResult)) {
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
const oldClassNames = this.classNamesMap.get(ref);
|
105
|
+
|
106
|
+
// Remove old styles
|
107
|
+
if (oldResult) {
|
108
|
+
_registry.UnistylesRegistry.remove(oldResult);
|
109
|
+
}
|
110
|
+
|
111
|
+
// Remove old classnames from the ref
|
112
|
+
oldClassNames?.forEach(className => ref.classList.remove(className));
|
113
|
+
this.resultsMap.set(ref, newResult);
|
114
|
+
const {
|
115
|
+
hash,
|
116
|
+
existingHash
|
117
|
+
} = _registry.UnistylesRegistry.add(newResult);
|
118
|
+
const injectedClassNames = newResult?._web?._classNames ?? [];
|
119
|
+
const newClassNames = injectedClassNames.concat(hash);
|
120
|
+
const dependencies = (0, _utils.extractUnistyleDependencies)(newResult);
|
121
|
+
if (typeof __uni__stylesheet === 'function') {
|
122
|
+
// Add dependencies from dynamic styles to stylesheet
|
123
|
+
_registry.UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
|
124
|
+
}
|
125
|
+
__uni__refs.add(ref);
|
126
|
+
this.classNamesMap.set(ref, newClassNames);
|
127
|
+
// Add new classnames to the ref
|
128
|
+
ref.classList.add(...newClassNames);
|
129
|
+
resolve(newClassNames);
|
130
|
+
|
131
|
+
// If it is new hash add it to the map to use for the listener
|
132
|
+
if (!existingHash) {
|
133
|
+
this.hashMap.set(ref, hash);
|
134
|
+
}
|
135
|
+
}, 0));
|
90
136
|
|
91
|
-
//
|
92
|
-
|
93
|
-
|
94
|
-
}
|
137
|
+
// Listen for theme / runtime changes
|
138
|
+
const dispose = _listener.UnistylesListener.addListeners((0, _utils.extractUnistyleDependencies)(newResult), () => {
|
139
|
+
const hash = this.hashMap.get(ref);
|
95
140
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
141
|
+
// Dispose listener if there is no hash
|
142
|
+
if (!hash) {
|
143
|
+
dispose();
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
const newComputedStyleSheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
|
147
|
+
const newValue = newComputedStyleSheet[__uni__key];
|
148
|
+
const result = typeof newValue === 'function' ? newValue(...args) : newValue;
|
149
|
+
const {
|
150
|
+
variantsResult
|
151
|
+
} = Object.fromEntries((0, _variants2.getVariants)({
|
152
|
+
variantsResult: result
|
153
|
+
}, variants));
|
154
|
+
const resultWithVariants = (0, _utils.deepMergeObjects)(result, variantsResult ?? {});
|
155
|
+
_registry.UnistylesRegistry.applyStyles(hash, (0, _convert.convertUnistyles)(resultWithVariants));
|
105
156
|
});
|
106
|
-
const injectedClassNames = resultWithVariants?._web?._classNames ?? [];
|
107
|
-
const newClassNames = injectedClassNames.concat(className);
|
108
|
-
const dependencies = (0, _utils.extractUnistyleDependencies)(resultWithVariants);
|
109
|
-
if (typeof __uni__stylesheet === 'function') {
|
110
|
-
// Add dependencies from dynamic styles to stylesheet
|
111
|
-
_registry.UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
|
112
|
-
}
|
113
|
-
__uni__refs.add(ref);
|
114
|
-
this.classNamesMap.set(ref, __uni__key, newClassNames);
|
115
|
-
// Add new classnames to the ref
|
116
|
-
ref.classList.add(...newClassNames);
|
117
157
|
});
|
118
|
-
};
|
158
|
+
});
|
119
159
|
remove = () => {};
|
120
160
|
}
|
121
161
|
const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = new UnistylesShadowRegistryBuilder();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_convert","require","_listener","_registry","_utils","_variants2","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","resultsMap","Map","hashMap","classNamesMap","timeoutMap","queuedResultMap","add","ref","_style","_variants","_args","Promise","resolve","Array","isArray","forEach","style","Object","keys","some","key","startsWith","secrets","extractSecrets","__uni__refs","isInDocument","oldResult","get","delete","UnistylesRegistry","remove","HTMLElement","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","getComputedStylesheet","args","variants","length","result","variantsResult","fromEntries","getVariants","resultWithVariants","deepMergeObjects","storedResult","newResult","timeout","set","clearTimeout","setTimeout","equal","oldClassNames","className","classList","hash","existingHash","injectedClassNames","_web","_classNames","newClassNames","concat","dependencies","extractUnistyleDependencies","addDependenciesToStylesheet","UnistylesListener","addListeners","newComputedStyleSheet","newValue","applyStyles","convertUnistyles","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MA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,CAAC;QAChG,MAAMM,kBAAkB,GAAG,IAAAC,uBAAgB,EAACL,MAAM,EAAEC,cAAc,IAAI,CAAC,CAAC,CAAC;QAEzEd,2BAAiB,CAAC2C,WAAW,CAACd,IAAI,EAAE,IAAAe,yBAAgB,EAAC3B,kBAAkB,CAAC,CAAC;MAC7E,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;EAEFhB,MAAM,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB;AAEO,MAAM4C,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAIhF,8BAA8B,CAAC,CAAC","ignoreList":[]}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.warn = exports.reduceObject = exports.keyInObject = exports.isServer = exports.
|
6
|
+
exports.warn = exports.reduceObject = exports.keyInObject = exports.isServer = exports.hyphenate = exports.generateHash = exports.equal = exports.deepMergeObjects = void 0;
|
7
7
|
const reduceObject = (obj, reducer) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, reducer(value, key)]));
|
8
8
|
exports.reduceObject = reduceObject;
|
9
9
|
const keyInObject = (obj, key) => key in obj;
|
@@ -57,36 +57,6 @@ const generateHash = value => {
|
|
57
57
|
return `unistyles-${(hasher >>> 0).toString(36)}`;
|
58
58
|
};
|
59
59
|
exports.generateHash = generateHash;
|
60
|
-
const
|
61
|
-
|
62
|
-
return {
|
63
|
-
get: (key, secondKey) => {
|
64
|
-
const mapForKey = map.get(key);
|
65
|
-
if (!mapForKey) {
|
66
|
-
return undefined;
|
67
|
-
}
|
68
|
-
return mapForKey.get(secondKey);
|
69
|
-
},
|
70
|
-
set: (key, secondKey, value) => {
|
71
|
-
const mapForKey = map.get(key) ?? new Map();
|
72
|
-
map.set(key, mapForKey);
|
73
|
-
mapForKey.set(secondKey, value);
|
74
|
-
},
|
75
|
-
delete: (key, secondKey) => {
|
76
|
-
const mapForKey = map.get(key);
|
77
|
-
if (!mapForKey) {
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
mapForKey.delete(secondKey);
|
81
|
-
},
|
82
|
-
forEach: callback => {
|
83
|
-
map.forEach((mapForKey, key) => {
|
84
|
-
mapForKey.forEach((value, secondKey) => {
|
85
|
-
callback(key, secondKey, value);
|
86
|
-
});
|
87
|
-
});
|
88
|
-
}
|
89
|
-
};
|
90
|
-
};
|
91
|
-
exports.createDoubleMap = createDoubleMap;
|
60
|
+
const hyphenate = propertyName => propertyName.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
|
61
|
+
exports.hyphenate = hyphenate;
|
92
62
|
//# sourceMappingURL=common.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["reduceObject","obj","reducer","Object","fromEntries","entries","map","key","value","exports","keyInObject","isServer","window","deepMergeObjects","sources","target","forEach","source","keys","sourceValue","targetValue","warn","message","console","equal","a","b","is","keysA","length","every","prototype","hasOwnProperty","call","generateHash","str","JSON","stringify","hasher","charCodeAt","toString","
|
1
|
+
{"version":3,"names":["reduceObject","obj","reducer","Object","fromEntries","entries","map","key","value","exports","keyInObject","isServer","window","deepMergeObjects","sources","target","forEach","source","keys","sourceValue","targetValue","warn","message","console","equal","a","b","is","keysA","length","every","prototype","hasOwnProperty","call","generateHash","str","JSON","stringify","hasher","charCodeAt","toString","hyphenate","propertyName","replace","m","toLowerCase"],"sourceRoot":"../../../../src","sources":["web/utils/common.ts"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAGA,CACxBC,GAAS,EACTC,OAA+D,KAC9DC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,GAAG,CAAC,CAACK,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAACD,GAAG,EAAEL,OAAO,CAACM,KAAK,EAAsBD,GAAG,CAAC,CAAC,CAAC,CAAoC;AAAAE,OAAA,CAAAT,YAAA,GAAAA,YAAA;AAE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 @@ const getMediaQuery = query => {
|
|
75
75
|
};
|
76
76
|
exports.getMediaQuery = getMediaQuery;
|
77
77
|
const extractUnistyleDependencies = value => {
|
78
|
+
if (!value) {
|
79
|
+
return [];
|
80
|
+
}
|
78
81
|
const dependencies = (0, _common.keyInObject)(value, 'uni__dependencies') ? value.uni__dependencies : [];
|
79
|
-
return dependencies;
|
82
|
+
return Array.isArray(dependencies) ? dependencies : [];
|
80
83
|
};
|
81
84
|
exports.extractUnistyleDependencies = extractUnistyleDependencies;
|
82
85
|
//# sourceMappingURL=unistyle.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_mq","_state","_common","schemeToTheme","scheme","ColorScheme","Dark","Light","exports","hexToRGBA","hex","opacity","replace","split","map","x","parseInt","filter","num","isNaN","reduce","acc","color","concat","assignSecrets","object","secrets","Math","random","toString","slice","extractSecrets","Object","entries","key","value","startsWith","push","getStyles","values","returnValue","defineProperties","reduceObject","enumerable","configurable","isInDocument","element","document","body","contains","extractMediaQueryValue","query","_","px","match","undefined","Number","getMediaQuery","Orientation","includes","isUnistylesMq","minWidth","maxWidth","minHeight","maxHeight","parseMq","Boolean","join","UnistylesState","breakpoints","keyInObject","extractUnistyleDependencies","dependencies","uni__dependencies"],"sourceRoot":"../../../../src","sources":["web/utils/unistyle.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,GAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEO,MAAMI,aAAa,GAAIC,MAAmB,IAAa;EAC1D,QAAQA,MAAM;IACV,KAAKC,kBAAW,CAACC,IAAI;MACjB,OAAO,MAAM;IACjB,KAAKD,kBAAW,CAACE,KAAK;IACtB;MACI,OAAO,OAAO;EACtB;AACJ,CAAC;AAAAC,OAAA,CAAAL,aAAA,GAAAA,aAAA;AAEM,MAAMM,SAAS,GAAGA,CAACC,GAAW,EAAEC,OAAe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S,EACtDS,SAAS,GAAG,gBAAgBA,SAAS,KAAK,GAAGT,SAAS,CACzD,CAACtC,MAAM,CAACiD,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;EACnC;EAEA,MAAMN,QAAQ,GAAGO,qBAAc,CAACC,WAAW,IAAI,IAAAC,mBAAW,EAACF,qBAAc,CAACC,WAAW,EAAElB,KAAK,CAAC,GAAGiB,qBAAc,CAACC,WAAW,CAAClB,KAAK,CAAC,GAAGI,SAAS;EAE7I,OAAO,eAAeM,QAAQ,IAAI,CAAC,KAAK;AAC5C,CAAC;AAAArD,OAAA,CAAAiD,aAAA,GAAAA,aAAA;AAEM,MAAMc,2BAA2B,GAAIpC,KAAU,IAAK;EACvD,MAAMqC,YAAuC,GAAG,IAAAF,mBAAW,EAACnC,KAAK,EAAE,mBAAmB,CAAC,GAAGA,KAAK,CAACsC,iBAAiB,GAAG,EAAE;EAEtH,
|
1
|
+
{"version":3,"names":["_types","require","_mq","_state","_common","schemeToTheme","scheme","ColorScheme","Dark","Light","exports","hexToRGBA","hex","opacity","replace","split","map","x","parseInt","filter","num","isNaN","reduce","acc","color","concat","assignSecrets","object","secrets","Math","random","toString","slice","extractSecrets","Object","entries","key","value","startsWith","push","getStyles","values","returnValue","defineProperties","reduceObject","enumerable","configurable","isInDocument","element","document","body","contains","extractMediaQueryValue","query","_","px","match","undefined","Number","getMediaQuery","Orientation","includes","isUnistylesMq","minWidth","maxWidth","minHeight","maxHeight","parseMq","Boolean","join","UnistylesState","breakpoints","keyInObject","extractUnistyleDependencies","dependencies","uni__dependencies","Array","isArray"],"sourceRoot":"../../../../src","sources":["web/utils/unistyle.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,GAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEO,MAAMI,aAAa,GAAIC,MAAmB,IAAa;EAC1D,QAAQA,MAAM;IACV,K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G,IAAAC,WAAO,EAACd,KAAK,CAAC;IAEnE,OAAO,CACHU,QAAQ,GAAG,eAAeA,QAAQ,KAAK,GAAGN,SAAS,EACnDO,QAAQ,GAAG,eAAeA,QAAQ,KAAK,GAAGP,SAAS,EACnDQ,SAAS,GAAG,gBAAgBA,SAAS,KAAK,GAAGR,SAAS,EACtDS,SAAS,GAAG,gBAAgBA,SAAS,KAAK,GAAGT,SAAS,CACzD,CAACtC,MAAM,CAACiD,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;EACnC;EAEA,MAAMN,QAAQ,GAAGO,qBAAc,CAACC,WAAW,IAAI,IAAAC,mBAAW,EAACF,qBAAc,CAACC,WAAW,EAAElB,KAAK,CAAC,GAAGiB,qBAAc,CAACC,WAAW,CAAClB,KAAK,CAAC,GAAGI,SAAS;EAE7I,OAAO,eAAeM,QAAQ,IAAI,CAAC,KAAK;AAC5C,CAAC;AAAArD,OAAA,CAAAiD,aAAA,GAAAA,aAAA;AAEM,MAAMc,2BAA2B,GAAIpC,KAAU,IAAK;EACvD,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EAEA,MAAMqC,YAAuC,GAAG,IAAAF,mBAAW,EAACnC,KAAK,EAAE,mBAAmB,CAAC,GAAGA,KAAK,CAACsC,iBAAiB,GAAG,EAAE;EAEtH,OAAOC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC,GAAGA,YAAY,GAAG,EAAE;AAC1D,CAAC;AAAAhE,OAAA,CAAA+D,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","isValidMq","parseMq","isUnistylesMq","useMedia","config","computeIsVisible","maybeMq","mq","console","error","parsedMq","width","height","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["components/useMedia.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AACrG,SAASC,SAAS,EAAEC,OAAO,EAAEC,aAAa,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,gBAAgB,GAAGA,CAAA,KAAe;IACpC,MAAMC,OAAO,GAAGF,MAAM,CAACG,EAAuB;IAE9C,IAAI,CAACL,aAAa,CAACI,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK,CAAC,sCAAsCH,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMI,QAAQ,
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","isValidMq","parseMq","isUnistylesMq","useMedia","config","computeIsVisible","maybeMq","mq","console","error","parsedMq","width","height","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["components/useMedia.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AACrG,SAASC,SAAS,EAAEC,OAAO,EAAEC,aAAa,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,gBAAgB,GAAGA,CAAA,KAAe;IACpC,MAAMC,OAAO,GAAGF,MAAM,CAACG,EAAuB;IAE9C,IAAI,CAACL,aAAa,CAACI,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK,CAAC,sCAAsCH,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMI,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M;MACTgB,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,CAACjB,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,OAAO;IACHY;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
4
|
+
import { isUnistylesMq, isValidMq, parseMq } from '../mq';
|
5
|
+
export const useMedia = config => {
|
6
|
+
const disposeRef = useRef(() => {});
|
7
|
+
const [isVisible, setIsVisible] = useState(() => {
|
8
|
+
const maybeMq = config.mq;
|
9
|
+
if (!isUnistylesMq(maybeMq)) {
|
10
|
+
console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
|
11
|
+
return false;
|
12
|
+
}
|
13
|
+
const parsedMq = parseMq(maybeMq);
|
14
|
+
if (!isValidMq(parsedMq)) {
|
15
|
+
console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`);
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
const {
|
19
|
+
minWidth,
|
20
|
+
maxWidth,
|
21
|
+
minHeight,
|
22
|
+
maxHeight
|
23
|
+
} = parsedMq;
|
24
|
+
const mediaQuery = [minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined, maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined, minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined, maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined].filter(Boolean).join(' and ');
|
25
|
+
const media = window.matchMedia(mediaQuery);
|
26
|
+
const handler = event => setIsVisible(event.matches);
|
27
|
+
media.addEventListener('change', handler);
|
28
|
+
disposeRef.current = () => media.removeEventListener('change', handler);
|
29
|
+
return media.matches;
|
30
|
+
});
|
31
|
+
|
32
|
+
// Unmount
|
33
|
+
useEffect(() => () => disposeRef.current(), []);
|
34
|
+
return {
|
35
|
+
isVisible
|
36
|
+
};
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=useMedia.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","isUnistylesMq","isValidMq","parseMq","useMedia","config","disposeRef","isVisible","setIsVisible","maybeMq","mq","console","error","parsedMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener"],"sourceRoot":"../../../src","sources":["components/useMedia.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAGP,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACQ,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CAAC,MAAM;IAC7C,MAAMS,OAAO,GAAGJ,MAAM,CAACK,EAAuB;IAE9C,IAAI,CAACT,aAAa,CAACQ,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK,CAAC,sCAAsCH,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMI,QAAQ,GAAGV,OAAO,CAACM,OAAO,CAAC;IAEjC,IAAI,CAACP,SAAS,CAACW,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEH,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEK,QAAQ;MAAEC,QAAQ;MAAEC,SAAS;MAAEC;IAAU,CAAC,GAAGJ,QAAQ;IAE7D,MAAMK,UAAU,GAAG,CACfJ,QAAQ,KAAKK,SAAS,GAAG,eAAeL,QAAQ,KAAK,GAAGK,SAAS,EACjEJ,QAAQ,KAAKI,SAAS,GAAG,eAAeJ,QAAQ,KAAK,GAAGI,SAAS,EACjEH,SAAS,KAAKG,SAAS,GAAG,gBAAgBH,SAAS,KAAK,GAAGG,SAAS,EACpEF,SAAS,KAAKE,SAAS,GAAG,gBAAgBF,SAAS,KAAK,GAAGE,SAAS,CACvE,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;IAE/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,UAAU,CAACP,UAAU,CAAC;IAC3C,MAAMQ,OAAO,GAAIC,KAA0B,IAAKnB,YAAY,CAACmB,KAAK,CAACC,OAAO,CAAC;IAE3EL,KAAK,CAACM,gBAAgB,CAAC,QAAQ,EAAEH,OAAO,CAAC;IACzCpB,UAAU,CAACwB,OAAO,GAAG,MAAMP,KAAK,CAACQ,mBAAmB,CAAC,QAAQ,EAAEL,OAAO,CAAC;IAEvE,OAAOH,KAAK,CAACK,OAAO;EACxB,CAAC,CAAC;;EAEF;EACA9B,SAAS,CAAC,MAAM,MAAMQ,UAAU,CAACwB,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EAE/C,OAAO;IACHvB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -1,12 +1,64 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import React from 'react';
|
3
|
+
import React, { useEffect, useState } from 'react';
|
4
|
+
import { UnistylesRuntime } from '../specs';
|
5
|
+
import { UnistyleDependency } from '../specs/NativePlatform';
|
6
|
+
import { UnistylesListener } from '../web/listener';
|
7
|
+
import { UnistylesShadowRegistry } from '../web';
|
8
|
+
import { equal } from '../web/utils';
|
4
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
10
|
const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'];
|
6
|
-
|
11
|
+
const ALL_DEPENDENCIES = Object.values(UnistyleDependency).filter(dependency => typeof dependency === 'number');
|
12
|
+
const useShadowRegistry = style => {
|
13
|
+
const [classNames, setClassNames] = useState([]);
|
14
|
+
const [ref] = useState(document.createElement('div'));
|
15
|
+
if (style) {
|
16
|
+
UnistylesShadowRegistry.add(ref, style).then(newClassNames => {
|
17
|
+
if (equal(classNames, newClassNames)) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
setClassNames(newClassNames);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
useEffect(() => () => {
|
24
|
+
// Remove styles on unmount
|
25
|
+
UnistylesShadowRegistry.add(null, style);
|
26
|
+
});
|
27
|
+
return classNames;
|
28
|
+
};
|
29
|
+
export const createUnistylesComponent = (Component, mappings) => {
|
7
30
|
return props => {
|
31
|
+
const [mappingsProps, setMappingsProps] = useState(mappings?.(UnistylesRuntime.getTheme()));
|
32
|
+
const styleClassNames = useShadowRegistry(props.style);
|
33
|
+
const contentContainerStyleClassNames = useShadowRegistry(props.contentContainerStyle);
|
34
|
+
useEffect(() => {
|
35
|
+
const disposeMappings = UnistylesListener.addListeners(ALL_DEPENDENCIES, () => {
|
36
|
+
if (!mappings) {
|
37
|
+
disposeMappings();
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
return setMappingsProps(mappings(UnistylesRuntime.getTheme()));
|
41
|
+
});
|
42
|
+
return () => disposeMappings();
|
43
|
+
}, [mappingsProps, props.style]);
|
44
|
+
const combinedProps = {
|
45
|
+
...mappingsProps,
|
46
|
+
...props,
|
47
|
+
...(props.style ? {
|
48
|
+
style: {
|
49
|
+
$$css: true,
|
50
|
+
'unistyles': styleClassNames.join(' ')
|
51
|
+
}
|
52
|
+
} : {}),
|
53
|
+
...(props.contentContainerStyle ? {
|
54
|
+
style: {
|
55
|
+
$$css: true,
|
56
|
+
'unistyles': contentContainerStyleClassNames.join(' ')
|
57
|
+
}
|
58
|
+
} : {})
|
59
|
+
};
|
8
60
|
return /*#__PURE__*/_jsx(Component, {
|
9
|
-
...
|
61
|
+
...combinedProps
|
10
62
|
});
|
11
63
|
};
|
12
64
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","jsx","_jsx","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","
|
1
|
+
{"version":3,"names":["React","useEffect","useState","UnistylesRuntime","UnistyleDependency","UnistylesListener","UnistylesShadowRegistry","equal","jsx","_jsx","SUPPORTED_STYLE_PROPS","ALL_DEPENDENCIES","Object","values","filter","dependency","useShadowRegistry","style","classNames","setClassNames","ref","document","createElement","add","then","newClassNames","createUnistylesComponent","Component","mappings","props","mappingsProps","setMappingsProps","getTheme","styleClassNames","contentContainerStyleClassNames","contentContainerStyle","disposeMappings","addListeners","combinedProps","$$css","join"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAA4B,OAAO;AAEtE,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,uBAAuB,QAAQ,QAAQ;AAChD,SAASC,KAAK,QAAQ,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpC,MAAMC,qBAAqB,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAU;AACzE,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAACT,kBAAkB,CAAC,CAACU,MAAM,CAAEC,UAAU,IAAuC,OAAOA,UAAU,KAAK,QAAQ,CAAC;AAInJ,MAAMC,iBAAiB,GAAIC,KAA2B,IAAK;EACvD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGjB,QAAQ,CAAgB,EAAE,CAAC;EAC/D,MAAM,CAACkB,GAAG,CAAC,GAAGlB,QAAQ,CAACmB,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAAC;EAErD,IAAIL,KAAK,EAAE;IACPX,uBAAuB,CAClBiB,GAAG,CAACH,GAAG,EAAEH,KAAK,CAAC,CACfO,IAAI,CAACC,aAAa,IAAI;MACnB,IAAIlB,KAAK,CAACW,UAAU,EAAEO,aAAa,CAAC,EAAE;QAClC;MACJ;M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AG;QAC7BlB,KAAK,EAAE;UACHsB,KAAK,EAAE,IAAI;UACX,WAAW,EAAEL,+BAA+B,CAACM,IAAI,CAAC,GAAG;QACzD;MACJ,CAAC,GAAG,CAAC,CAAC;IACV,CAAsB;IAEtB,oBAAO/B,IAAA,CAACkB,SAAS;MAAA,GAAKW;IAAa,CAAG,CAAC;EAC3C,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -4,7 +4,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
6
|
const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'];
|
7
|
-
export const createUnistylesComponent = (Component, mappings
|
7
|
+
export const createUnistylesComponent = (Component, mappings) => {
|
8
8
|
return props => {
|
9
9
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
10
10
|
const [, setRt] = useState(0);
|
@@ -16,6 +16,8 @@ export const createUnistylesComponent = (Component, mappings = () => ({})) => {
|
|
16
16
|
if (Array.isArray(props[propName])) {
|
17
17
|
console.error(`🦄 Unistyles: createUnistylesComponent requires ${propName} to be an object. Please check props for component: ${Component.displayName}`);
|
18
18
|
}
|
19
|
+
|
20
|
+
// @ts-expect-error - this is hidden from TS
|
19
21
|
if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
|
20
22
|
console.error(`🦄 Unistyles: createUnistylesComponent received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${Component.displayName}`);
|
21
23
|
}
|
@@ -28,7 +30,7 @@ export const createUnistylesComponent = (Component, mappings = () => ({})) => {
|
|
28
30
|
}
|
29
31
|
useEffect(() => {
|
30
32
|
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
31
|
-
const componentDependencies = props.style?.__proto__.uni__dependencies || mappings(theme).style?.__proto__.uni__dependencies;
|
33
|
+
const componentDependencies = props.style?.__proto__.uni__dependencies || mappings?.(theme).style?.__proto__.uni__dependencies;
|
32
34
|
if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies || componentDependencies.includes(UnistyleDependency.Theme))) {
|
33
35
|
setTheme(UnistylesRuntime.getTheme());
|
34
36
|
|
@@ -37,6 +39,7 @@ export const createUnistylesComponent = (Component, mappings = () => ({})) => {
|
|
37
39
|
if (props?.[propName]) {
|
38
40
|
stylesRef.current = {
|
39
41
|
...stylesRef.current,
|
42
|
+
// @ts-expect-error - this is hidden from TS
|
40
43
|
[propName]: props[propName].__proto__?.getStyle() || props[propName]
|
41
44
|
};
|
42
45
|
}
|
@@ -51,9 +54,7 @@ export const createUnistylesComponent = (Component, mappings = () => ({})) => {
|
|
51
54
|
removeChangeListener();
|
52
55
|
};
|
53
56
|
}, []);
|
54
|
-
const mergedProps = {
|
55
|
-
...mappings(theme)
|
56
|
-
};
|
57
|
+
const mergedProps = mappings?.(theme) ?? {};
|
57
58
|
Object.keys(props).forEach(key => {
|
58
59
|
if (key in mergedProps) {
|
59
60
|
mergedProps[key] = Object.assign(props[key], mergedProps[key]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","jsx","_jsx","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","getTheme","setRt","stylesRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","__proto__","getStyle","removeChangeListener","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","Theme","some","dependency","prevState","mergedProps","Object","keys","key","assign"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","jsx","_jsx","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","getTheme","setRt","stylesRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","__proto__","getStyle","removeChangeListener","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","Theme","some","dependency","prevState","mergedProps","Object","keys","key","assign"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAwBC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE9E,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGrG,MAAMC,qBAAqB,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAU;AAGzE,OAAO,MAAMC,wBAAwB,GAAEA,CAAmGC,SAAgC,EAAEC,QAA+C,KAAK;EAC5N,OAAQC,KAA+D,IAAK;IACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,CAAiBG,gBAAgB,CAACU,QAAQ,CAAC,CAAC,CAAC;IAC/E,MAAM,GAAGC,KAAK,CAAC,GAAGd,QAAQ,CAAC,CAAC,CAAC;IAC7B,MAAMe,SAAS,GAAGhB,MAAM,CAAsB,CAAC,CAAC,CAAC;IACjD,MAAMiB,WAAW,GAAGjB,MAAM,CAAC,KAAK,CAAC;IAEjC,IAAI,CAACiB,WAAW,CAACC,OAAO,EAAE;MACtBX,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;QACtC,IAAIT,KAAK,GAAGS,QAAQ,CAAC,EAAE;UACnB,IAAIC,KAAK,CAACC,OAAO,CAACX,KAAK,CAACS,QAAQ,CAAC,CAAC,EAAE;YAChCG,OAAO,CAACC,KAAK,CAAC,mDAAmDJ,QAAQ,uDAAuDX,SAAS,CAACgB,WAAW,EAAE,CAAC;UAC5J;;UAEA;UACA,IAAId,KAAK,CAACS,QAAQ,CAAC,CAACM,gBAAgB,IAAI,CAACf,KAAK,CAACS,QAAQ,CAAC,CAACO,SAAS,EAAEC,QAAQ,E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AI,CAAC,CAAC,CAAC,EAAE;UAC3IvB,KAAK,CAACwB,SAAS,IAAIA,SAAS,GAAG,CAAC,CAAC;QACrC;MACJ,CAAC,CAAC;MAEF,OAAO,MAAM;QACTV,oBAAoB,CAAC,CAAC;MAC1B,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,MAAMW,WAAW,GAAG9B,QAAQ,GAAGE,KAAK,CAAC,IAA2B,CAAC,CAAC;IAElE6B,MAAM,CAACC,IAAI,CAAC/B,KAAK,CAAC,CAACQ,OAAO,CAACwB,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIH,WAAW,EAAE;QACpBA,WAAW,CAACG,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,CAACjC,KAAK,CAACgC,GAAG,CAAuB,EAAEH,WAAW,CAACG,GAAG,CAAC,CAAC;QAEpF;MACJ;MAEAH,WAAW,CAACG,GAAG,CAAC,GAAGhC,KAAK,CAACgC,GAAG,CAAuB;IACvD,CAAC,CAAC;;IAEF;IACApC,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAIoB,WAAW,CAACpB,QAAQ,CAAC,EAAE;QACvBoB,WAAW,CAACpB,QAAQ,CAAC,GAAGJ,SAAS,CAACE,OAAO,CAACE,QAAQ,CAAC;MACvD;IACJ,CAAC,CAAC;IAEFH,WAAW,CAACC,OAAO,GAAG,KAAK;IAE3B,oBAAOZ,IAAA,CAACG,SAAS;MAAA,GAAK+B;IAAW,CAAa,CAAC;EACnD,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -3,15 +3,14 @@
|
|
3
3
|
import { isPseudo } from './pseudo';
|
4
4
|
import { getStyle } from './style';
|
5
5
|
import { deepMergeObjects } from '../utils';
|
6
|
-
import { getTransformStyle } from './
|
7
|
-
import {
|
8
|
-
import { getTextShadowStyle } from './
|
9
|
-
import { getBoxShadowStyle } from './boxShadow';
|
6
|
+
import { getTransformStyle, getBoxShadow, getFilterStyle } from './object';
|
7
|
+
import { isShadow, isFilter, isTextShadow, isTransform, isBoxShadow } from './utils';
|
8
|
+
import { getTextShadowStyle, getBoxShadowStyle } from './shadow';
|
10
9
|
export const convertUnistyles = value => {
|
11
10
|
// Flag to mark if textShadow is already created
|
12
11
|
let hasTextShadow = false;
|
13
12
|
// Flag to mark if boxShadow is already created
|
14
|
-
let
|
13
|
+
let hasShadow = false;
|
15
14
|
const stylesArray = Object.entries({
|
16
15
|
...value,
|
17
16
|
...value._web
|
@@ -38,14 +37,20 @@ export const convertUnistyles = value => {
|
|
38
37
|
return getTextShadowStyle(value);
|
39
38
|
}
|
40
39
|
|
41
|
-
//
|
42
|
-
if (
|
43
|
-
if (
|
40
|
+
// RN shadows
|
41
|
+
if (isShadow(unistylesKey)) {
|
42
|
+
if (hasShadow) {
|
44
43
|
return [];
|
45
44
|
}
|
46
|
-
|
45
|
+
hasShadow = true;
|
47
46
|
return getBoxShadowStyle(value);
|
48
47
|
}
|
48
|
+
if (isFilter(unistylesKey, unistylesValue)) {
|
49
|
+
return getFilterStyle(unistylesValue);
|
50
|
+
}
|
51
|
+
if (isBoxShadow(unistylesKey, unistylesValue)) {
|
52
|
+
return getBoxShadow(unistylesValue);
|
53
|
+
}
|
49
54
|
|
50
55
|
// Transforms
|
51
56
|
if (isTransform(unistylesKey, unistylesValue)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isPseudo","getStyle","deepMergeObjects","getTransformStyle","
|
1
|
+
{"version":3,"names":["isPseudo","getStyle","deepMergeObjects","getTransformStyle","getBoxShadow","getFilterStyle","isShadow","isFilter","isTextShadow","isTransform","isBoxShadow","getTextShadowStyle","getBoxShadowStyle","convertUnistyles","value","hasTextShadow","hasShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","startsWith","flattenValues","map","breakpointKey","breakpointValue"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAQ,UAAU;AACnC,SAASC,QAAQ,QAAQ,S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AK,CAAC;IACnC;IAEA,IAAIP,QAAQ,CAACe,YAAY,EAAEC,cAAc,CAAC,EAAE;MACxC,OAAOlB,cAAc,CAACkB,cAAc,CAAC;IACzC;IAEA,IAAIb,WAAW,CAACY,YAAY,EAAEC,cAAc,CAAC,EAAE;MAC3C,OAAOnB,YAAY,CAACmB,cAAc,CAAC;IACvC;;IAEA;IACA,IAAId,WAAW,CAACa,YAAY,EAAEC,cAAc,CAAC,EAAE;MAC3C,OAAOpB,iBAAiB,CAACoB,cAAc,CAAC;IAC5C;;IAEA;IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO;UAAE,CAACD,aAAa,GAAG3B,QAAQ,CAACqB,YAAY,EAAEO,eAAe;QAAE,CAAC;MACvE,CAAC,CAAC;IACN;;IAEA;IACA,OAAO5B,QAAQ,CAACqB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAOrB,gBAAgB,CAAC,GAAGe,WAAW,CAAC;AAC3C,CAAC","ignoreList":[]}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { normalizeNumericValue } from '../utils';
|
4
|
+
import { deepMergeObjects, keyInObject } from '../../utils';
|
5
|
+
const createBoxShadowValue = style => {
|
6
|
+
const {
|
7
|
+
offsetX,
|
8
|
+
offsetY,
|
9
|
+
blurRadius = 0,
|
10
|
+
spreadDistance = 0,
|
11
|
+
color = '#000',
|
12
|
+
inset
|
13
|
+
} = style;
|
14
|
+
return `${inset ? 'inset ' : ''}${normalizeNumericValue(offsetX)} ${normalizeNumericValue(offsetY)} ${normalizeNumericValue(blurRadius)} ${normalizeNumericValue(spreadDistance)} ${color}`;
|
15
|
+
};
|
16
|
+
export const getBoxShadow = boxShadow => {
|
17
|
+
const breakpoints = new Set();
|
18
|
+
boxShadow.forEach(shadow => {
|
19
|
+
const [key] = Object.keys(shadow);
|
20
|
+
const value = shadow[key];
|
21
|
+
|
22
|
+
// Breakpoints
|
23
|
+
if (typeof value === 'object') {
|
24
|
+
Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
|
25
|
+
}
|
26
|
+
});
|
27
|
+
if (breakpoints.size === 0) {
|
28
|
+
const boxShadowStyle = Object.fromEntries(boxShadow.map(shadow => {
|
29
|
+
const [key] = Object.keys(shadow);
|
30
|
+
return [key, shadow[key]];
|
31
|
+
}));
|
32
|
+
return {
|
33
|
+
boxShadow: createBoxShadowValue(boxShadowStyle)
|
34
|
+
};
|
35
|
+
}
|
36
|
+
const breakpointStyles = Array.from(breakpoints).map(breakpoint => {
|
37
|
+
const styles = Object.fromEntries(boxShadow.map(shadow => {
|
38
|
+
const [key] = Object.keys(shadow);
|
39
|
+
const value = shadow[key];
|
40
|
+
if (typeof value === 'object' && keyInObject(value, breakpoint)) {
|
41
|
+
return [key, value[breakpoint]];
|
42
|
+
}
|
43
|
+
return [key, value];
|
44
|
+
}));
|
45
|
+
return {
|
46
|
+
[breakpoint]: {
|
47
|
+
boxShadow: createBoxShadowValue(styles)
|
48
|
+
}
|
49
|
+
};
|
50
|
+
});
|
51
|
+
return deepMergeObjects(...breakpointStyles);
|
52
|
+
};
|
53
|
+
//# sourceMappingURL=boxShadow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["normalizeNumericValue","deepMergeObjects","keyInObject","createBoxShadowValue","style","offsetX","offsetY","blurRadius","spreadDistance","color","inset","getBoxShadow","boxShadow","breakpoints","Set","forEach","shadow","key","Object","keys","value","breakpoint","add","size","boxShadowStyle","fromEntries","map","breakpointStyles","Array","from","styles"],"sourceRoot":"../../../../../src","sources":["web/convert/object/boxShadow.ts"],"mappings":";;AACA,SAASA,qBAAqB,QAAQ,UAAU;AAChD,SAASC,gBAAgB,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