@pyreon/rocketstyle 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +17 -15
- package/package.json +6 -6
- package/src/hoc/rocketstyleAttrsHoc.ts +24 -18
package/lib/index.js
CHANGED
|
@@ -296,22 +296,24 @@ const rocketStyleHOC = ({ inversed, attrs, priorityAttrs }) => {
|
|
|
296
296
|
const Enhanced = (WrappedComponent) => {
|
|
297
297
|
const HOCComponent = (props) => {
|
|
298
298
|
const themeAttrs = useThemeAttrs({ inversed });
|
|
299
|
-
const callbackParams = [themeAttrs.theme, {
|
|
300
|
-
render,
|
|
301
|
-
mode: themeAttrs.mode,
|
|
302
|
-
isDark: themeAttrs.isDark,
|
|
303
|
-
isLight: themeAttrs.isLight
|
|
304
|
-
}];
|
|
305
299
|
const filteredProps = removeUndefinedProps(props);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
...
|
|
314
|
-
|
|
300
|
+
return (() => {
|
|
301
|
+
const callbackParams = [themeAttrs.theme, {
|
|
302
|
+
render,
|
|
303
|
+
mode: themeAttrs.mode,
|
|
304
|
+
isDark: themeAttrs.isDark,
|
|
305
|
+
isLight: themeAttrs.isLight
|
|
306
|
+
}];
|
|
307
|
+
const prioritizedAttrs = calculatePriorityAttrs([filteredProps, ...callbackParams]);
|
|
308
|
+
const finalAttrs = calculateAttrs([{
|
|
309
|
+
...prioritizedAttrs,
|
|
310
|
+
...filteredProps
|
|
311
|
+
}, ...callbackParams]);
|
|
312
|
+
return WrappedComponent({
|
|
313
|
+
...prioritizedAttrs,
|
|
314
|
+
...finalAttrs,
|
|
315
|
+
...filteredProps
|
|
316
|
+
});
|
|
315
317
|
});
|
|
316
318
|
};
|
|
317
319
|
return HOCComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/rocketstyle",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pyreon/pyreon",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.11.
|
|
48
|
-
"@pyreon/reactivity": "^0.11.
|
|
49
|
-
"@pyreon/ui-core": "^0.11.
|
|
50
|
-
"@pyreon/styler": "^0.11.
|
|
47
|
+
"@pyreon/core": "^0.11.5",
|
|
48
|
+
"@pyreon/reactivity": "^0.11.5",
|
|
49
|
+
"@pyreon/ui-core": "^0.11.5",
|
|
50
|
+
"@pyreon/styler": "^0.11.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@vitus-labs/tools-rolldown": "^1.15.3",
|
|
54
|
-
"@pyreon/typescript": "^0.11.
|
|
54
|
+
"@pyreon/typescript": "^0.11.5"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -32,31 +32,37 @@ const rocketStyleHOC: RocketStyleHOC = ({ inversed, attrs, priorityAttrs }) => {
|
|
|
32
32
|
// Keep the object reference so properties re-evaluate lazily.
|
|
33
33
|
const themeAttrs = useTheme({ inversed })
|
|
34
34
|
|
|
35
|
-
const callbackParams = [
|
|
36
|
-
themeAttrs.theme,
|
|
37
|
-
{ render, mode: themeAttrs.mode, isDark: themeAttrs.isDark, isLight: themeAttrs.isLight },
|
|
38
|
-
]
|
|
39
|
-
|
|
40
35
|
// Remove undefined props not to override potential default props
|
|
41
36
|
const filteredProps = removeUndefinedProps(props)
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
// Reactive accessor — re-evaluates when mode changes.
|
|
39
|
+
// Reading themeAttrs.mode inside the accessor creates a dependency
|
|
40
|
+
// tracked by the runtime's effect (via mountReactive).
|
|
41
|
+
// This ensures .attrs() callbacks see the current mode on mode switch.
|
|
42
|
+
return (() => {
|
|
43
|
+
const callbackParams = [
|
|
44
|
+
themeAttrs.theme,
|
|
45
|
+
{ render, mode: themeAttrs.mode, isDark: themeAttrs.isDark, isLight: themeAttrs.isLight },
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
const prioritizedAttrs = calculatePriorityAttrs([filteredProps, ...callbackParams])
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
const finalAttrs = calculateAttrs([
|
|
51
|
+
{
|
|
52
|
+
...prioritizedAttrs,
|
|
53
|
+
...filteredProps,
|
|
54
|
+
},
|
|
55
|
+
...callbackParams,
|
|
56
|
+
])
|
|
57
|
+
|
|
58
|
+
const finalProps = {
|
|
47
59
|
...prioritizedAttrs,
|
|
60
|
+
...finalAttrs,
|
|
48
61
|
...filteredProps,
|
|
49
|
-
}
|
|
50
|
-
...callbackParams,
|
|
51
|
-
])
|
|
52
|
-
|
|
53
|
-
const finalProps = {
|
|
54
|
-
...prioritizedAttrs,
|
|
55
|
-
...finalAttrs,
|
|
56
|
-
...filteredProps,
|
|
57
|
-
}
|
|
62
|
+
}
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
return WrappedComponent(finalProps)
|
|
65
|
+
}) as unknown as ReturnType<ComponentFn<any>>
|
|
60
66
|
}
|
|
61
67
|
return HOCComponent
|
|
62
68
|
}
|