@vitus-labs/rocketstyle 2.6.0 → 2.6.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/lib/index.js +27 -15
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -14,6 +14,12 @@ const PSEUDO_KEYS = [
|
|
|
14
14
|
];
|
|
15
15
|
/** Meta pseudo-state keys representing non-interactive states (disabled, readOnly). */
|
|
16
16
|
const PSEUDO_META_KEYS = ["disabled", "readOnly"];
|
|
17
|
+
/**
|
|
18
|
+
* Pre-merged interaction + meta keys. Hoisted from `rocketstyle.tsx`'s render
|
|
19
|
+
* body so the `pick(props, [...PSEUDO_KEYS, ...PSEUDO_META_KEYS])` call no
|
|
20
|
+
* longer allocates a fresh 6-element array on every render.
|
|
21
|
+
*/
|
|
22
|
+
const PSEUDO_AND_META_KEYS = [...PSEUDO_KEYS, ...PSEUDO_META_KEYS];
|
|
17
23
|
/** Supported theme mode flags. */
|
|
18
24
|
const THEME_MODES = {
|
|
19
25
|
light: true,
|
|
@@ -281,10 +287,11 @@ const removeUndefinedProps = (props) => {
|
|
|
281
287
|
for (const key in props) if (props[key] !== void 0) result[key] = props[key];
|
|
282
288
|
return result;
|
|
283
289
|
};
|
|
284
|
-
const pickStyledAttrs = (props, keywords) =>
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
290
|
+
const pickStyledAttrs = (props, keywords) => {
|
|
291
|
+
const result = {};
|
|
292
|
+
for (const key in props) if (keywords[key] && props[key]) result[key] = props[key];
|
|
293
|
+
return result;
|
|
294
|
+
};
|
|
288
295
|
const calculateChainOptions = (options) => (args) => {
|
|
289
296
|
const result = {};
|
|
290
297
|
if (isEmpty(options)) return result;
|
|
@@ -494,13 +501,16 @@ const getTheme = ({ rocketstate, themes, baseTheme, transformKeys, appTheme }) =
|
|
|
494
501
|
for (const transform of deferredTransforms) merge(finalTheme, transform(finalTheme, appTheme ?? {}, themeModeCallback, config.css));
|
|
495
502
|
return finalTheme;
|
|
496
503
|
};
|
|
497
|
-
const getThemeByMode = (object, mode) =>
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
504
|
+
const getThemeByMode = (object, mode) => {
|
|
505
|
+
const acc = {};
|
|
506
|
+
for (const key in object) {
|
|
507
|
+
const value = object[key];
|
|
508
|
+
if (typeof value === "object" && value !== null) acc[key] = getThemeByMode(value, mode);
|
|
509
|
+
else if (isModeCallback(value)) acc[key] = value(mode);
|
|
510
|
+
else acc[key] = value;
|
|
511
|
+
}
|
|
502
512
|
return acc;
|
|
503
|
-
}
|
|
513
|
+
};
|
|
504
514
|
|
|
505
515
|
//#endregion
|
|
506
516
|
//#region src/rocketstyle.tsx
|
|
@@ -519,16 +529,18 @@ const arraysEqual = (a, b) => {
|
|
|
519
529
|
const isShallowEqualRocketstate = (a, b) => {
|
|
520
530
|
if (a === b) return true;
|
|
521
531
|
if (!a || !b) return false;
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
532
|
+
let aCount = 0;
|
|
533
|
+
for (const k in a) {
|
|
534
|
+
aCount++;
|
|
525
535
|
const av = a[k];
|
|
526
536
|
const bv = b[k];
|
|
527
537
|
if (av === bv) continue;
|
|
528
538
|
if (Array.isArray(av) && Array.isArray(bv) && arraysEqual(av, bv)) continue;
|
|
529
539
|
return false;
|
|
530
540
|
}
|
|
531
|
-
|
|
541
|
+
let bCount = 0;
|
|
542
|
+
for (const _ in b) bCount++;
|
|
543
|
+
return aCount === bCount;
|
|
532
544
|
};
|
|
533
545
|
/**
|
|
534
546
|
* Clones the current configuration and merges new options, returning a fresh
|
|
@@ -619,7 +631,7 @@ const rocketComponent = (options) => {
|
|
|
619
631
|
};
|
|
620
632
|
const pseudoRocketstate = {
|
|
621
633
|
...pseudo,
|
|
622
|
-
...pick(props,
|
|
634
|
+
...pick(props, PSEUDO_AND_META_KEYS)
|
|
623
635
|
};
|
|
624
636
|
const rocketstate = _calculateStylingAttrs({
|
|
625
637
|
props: pickStyledAttrs(mergeProps, reservedPropNames),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/rocketstyle",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"typecheck": "tsc --noEmit"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@vitus-labs/core": "^2.6.
|
|
67
|
+
"@vitus-labs/core": "^2.6.2",
|
|
68
68
|
"react": ">= 19"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@vitus-labs/core": "workspace:*",
|
|
72
72
|
"@vitus-labs/elements": "workspace:*",
|
|
73
|
-
"@vitus-labs/tools-rolldown": "2.3.
|
|
74
|
-
"@vitus-labs/tools-storybook": "2.3.
|
|
75
|
-
"@vitus-labs/tools-typescript": "2.3.
|
|
73
|
+
"@vitus-labs/tools-rolldown": "2.3.1",
|
|
74
|
+
"@vitus-labs/tools-storybook": "2.3.1",
|
|
75
|
+
"@vitus-labs/tools-typescript": "2.3.1",
|
|
76
76
|
"@vitus-labs/unistyle": "workspace:*"
|
|
77
77
|
}
|
|
78
78
|
}
|