@vitus-labs/rocketstyle 2.7.0 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/lib/index.js +19 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<!-- LOGO:BEGIN -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
<a href="https://github.com/vitus-labs/ui-system">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vitus-labs/ui-system/main/.github/assets/vitus-labs-mark-dark.svg">
|
|
6
|
+
<img alt="vitus·labs" src="https://raw.githubusercontent.com/vitus-labs/ui-system/main/.github/assets/vitus-labs-mark-light.svg" height="64">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
|
|
10
|
+
<picture>
|
|
11
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vitus-labs/ui-system/main/packages/rocketstyle/assets/logo-dark.svg">
|
|
12
|
+
<img alt="@vitus-labs/rocketstyle" src="https://raw.githubusercontent.com/vitus-labs/ui-system/main/packages/rocketstyle/assets/logo-light.svg" height="64">
|
|
13
|
+
</picture>
|
|
14
|
+
</div>
|
|
15
|
+
<!-- LOGO:END -->
|
|
16
|
+
|
|
1
17
|
# @vitus-labs/rocketstyle
|
|
2
18
|
|
|
3
19
|
Multi-dimensional styling system for React.
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider as Provider$1, compose, config, context, get, hoistNonReactStatics, isEmpty, merge, omit, pick, render, set, useStableValue } from "@vitus-labs/core";
|
|
2
|
-
import { createContext, memo,
|
|
2
|
+
import { createContext, memo, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/constants/index.ts
|
|
@@ -194,27 +194,36 @@ const usePseudoState = ({ onBlur, onFocus, onMouseDown, onMouseEnter, onMouseLea
|
|
|
194
194
|
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/hooks/useRef.ts
|
|
197
|
+
const assignRef = (target, node) => {
|
|
198
|
+
if (!target) return;
|
|
199
|
+
if (typeof target === "function") target(node);
|
|
200
|
+
else target.current = node;
|
|
201
|
+
};
|
|
197
202
|
/**
|
|
198
203
|
* Unifies two forwarded refs (the outer consumer ref and the internal
|
|
199
|
-
* rocketstyle HOC ref) into a single
|
|
200
|
-
*
|
|
204
|
+
* rocketstyle HOC ref) into a single merged CALLBACK ref.
|
|
205
|
+
*
|
|
206
|
+
* React re-invokes a callback ref on every attach/detach, so both forwarded
|
|
207
|
+
* refs always track the live node — including across host remounts (e.g. a
|
|
208
|
+
* `tag` change). The previous `useImperativeHandle(ref, () =>
|
|
209
|
+
* internalRef.current, [])` snapshotted `.current` once at mount, leaving
|
|
210
|
+
* consumers holding the detached old node after a remount.
|
|
201
211
|
*/
|
|
202
|
-
const useRocketstyleRef = ({ $rocketstyleRef, ref }) => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return internalRef;
|
|
207
|
-
};
|
|
212
|
+
const useRocketstyleRef = ({ $rocketstyleRef, ref }) => useCallback((node) => {
|
|
213
|
+
assignRef($rocketstyleRef, node);
|
|
214
|
+
assignRef(ref, node);
|
|
215
|
+
}, [$rocketstyleRef, ref]);
|
|
208
216
|
|
|
209
217
|
//#endregion
|
|
210
218
|
//#region src/hooks/useTheme.tsx
|
|
219
|
+
const EMPTY_THEME = {};
|
|
211
220
|
/**
|
|
212
221
|
* Retrieves the current theme object and resolved mode from context.
|
|
213
222
|
* Supports mode inversion so nested components can flip between
|
|
214
223
|
* light and dark without a new provider.
|
|
215
224
|
*/
|
|
216
225
|
const useThemeAttrs = ({ inversed }) => {
|
|
217
|
-
const { theme =
|
|
226
|
+
const { theme = EMPTY_THEME, mode: ctxMode = "light", isDark: ctxDark } = useContext(context) || {};
|
|
218
227
|
const mode = inversed ? THEME_MODES_INVERSED[ctxMode] : ctxMode;
|
|
219
228
|
const isDark = inversed ? !ctxDark : ctxDark;
|
|
220
229
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/rocketstyle",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"typecheck": "tsc --noEmit"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@vitus-labs/core": "^2.7.
|
|
68
|
+
"@vitus-labs/core": "^2.7.2",
|
|
69
69
|
"react": ">= 19"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"@vitus-labs/tools-typescript": "2.5.0",
|
|
79
79
|
"@vitus-labs/unistyle": "workspace:*",
|
|
80
80
|
"jsdom": "^29.1.1",
|
|
81
|
-
"tinybench": "^6.0.
|
|
81
|
+
"tinybench": "^6.0.2"
|
|
82
82
|
}
|
|
83
83
|
}
|