@vitus-labs/rocketstyle 2.0.0 → 2.2.0
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.d.ts +6 -1
- package/lib/index.js +34 -19
- package/package.json +6 -7
package/lib/index.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends ComponentType
|
|
|
87
87
|
interface StylesDefault {}
|
|
88
88
|
type Styles<S = unknown> = StylesDefault;
|
|
89
89
|
type Css = typeof config.css;
|
|
90
|
+
type Style = ReturnType<Css>;
|
|
90
91
|
/**
|
|
91
92
|
* Props available inside `.styles()` interpolation functions.
|
|
92
93
|
*
|
|
@@ -105,8 +106,12 @@ type RocketStyleInterpolationProps<CSS extends TObj = TObj> = {
|
|
|
105
106
|
*
|
|
106
107
|
* When used via `.styles()`, `CSS` is inferred from the chain's
|
|
107
108
|
* accumulated `.theme()` calls, so both props are typed automatically.
|
|
109
|
+
*
|
|
110
|
+
* `Style` (= `ReturnType<typeof config.css>`) is included so that nested
|
|
111
|
+
* css results — e.g. `${styles({ ... })}` from unistyle — interpolate
|
|
112
|
+
* cleanly without casts.
|
|
108
113
|
*/
|
|
109
|
-
type RocketCss<CSS extends TObj = TObj> = (strings: TemplateStringsArray, ...values: Array<string | number | boolean | null | undefined | ((props: RocketStyleInterpolationProps<CSS>) => any) | any[]>) => any;
|
|
114
|
+
type RocketCss<CSS extends TObj = TObj> = (strings: TemplateStringsArray, ...values: Array<string | number | boolean | null | undefined | Style | ((props: RocketStyleInterpolationProps<CSS>) => any) | any[]>) => any;
|
|
110
115
|
type StylesCb<CSS extends TObj = TObj> = (css: RocketCss<CSS>) => ReturnType<Css>;
|
|
111
116
|
type StylesCbArray = StylesCb[];
|
|
112
117
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -530,23 +530,38 @@ const isShallowEqualRocketstate = (a, b) => {
|
|
|
530
530
|
}
|
|
531
531
|
return true;
|
|
532
532
|
};
|
|
533
|
-
/**
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
533
|
+
/**
|
|
534
|
+
* Clones the current configuration and merges new options, returning a fresh
|
|
535
|
+
* rocketComponent.
|
|
536
|
+
*
|
|
537
|
+
* Component-swap reset: when `opts.component` is set AND differs from the
|
|
538
|
+
* current `defaultOpts.component`, the prior `attrs`, `priorityAttrs`, and
|
|
539
|
+
* `compose` chains are dropped — they were tailored to the previous
|
|
540
|
+
* component's prop shape, and applying them to a different component
|
|
541
|
+
* silently leaks invalid props through to the DOM (e.g. `disabled` on an
|
|
542
|
+
* `<a>`). Callers who want to preserve them must re-chain explicitly:
|
|
543
|
+
*
|
|
544
|
+
* const NewBtn = Button.config({ component: 'a' }).attrs(sharedAttrs)
|
|
545
|
+
*/
|
|
546
|
+
const cloneAndEnhance = (defaultOpts, opts) => {
|
|
547
|
+
const componentChanged = opts.component != null && opts.component !== defaultOpts.component;
|
|
548
|
+
return rocketComponent({
|
|
549
|
+
...defaultOpts,
|
|
550
|
+
attrs: componentChanged ? chainOptions(opts.attrs, []) : chainOptions(opts.attrs, defaultOpts.attrs),
|
|
551
|
+
filterAttrs: componentChanged ? [...opts.filterAttrs ?? []] : [...defaultOpts.filterAttrs ?? [], ...opts.filterAttrs ?? []],
|
|
552
|
+
priorityAttrs: componentChanged ? chainOptions(opts.priorityAttrs, []) : chainOptions(opts.priorityAttrs, defaultOpts.priorityAttrs),
|
|
553
|
+
statics: {
|
|
554
|
+
...defaultOpts.statics,
|
|
555
|
+
...opts.statics
|
|
556
|
+
},
|
|
557
|
+
compose: componentChanged ? { ...opts.compose } : {
|
|
558
|
+
...defaultOpts.compose,
|
|
559
|
+
...opts.compose
|
|
560
|
+
},
|
|
561
|
+
...chainOrOptions(CONFIG_KEYS, opts, defaultOpts),
|
|
562
|
+
...chainReservedKeyOptions([...defaultOpts.dimensionKeys, ...STYLING_KEYS], opts, defaultOpts)
|
|
563
|
+
});
|
|
564
|
+
};
|
|
550
565
|
/**
|
|
551
566
|
* Builds the final renderable React component with theme resolution,
|
|
552
567
|
* dimension mapping, pseudo-state context, HOC composition, and
|
|
@@ -707,8 +722,8 @@ const rocketComponent = (options) => {
|
|
|
707
722
|
{
|
|
708
723
|
render,
|
|
709
724
|
mode,
|
|
710
|
-
isDark: mode === "
|
|
711
|
-
isLight: mode === "
|
|
725
|
+
isDark: mode === "dark",
|
|
726
|
+
isLight: mode === "light"
|
|
712
727
|
}
|
|
713
728
|
])
|
|
714
729
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/rocketstyle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -61,19 +61,18 @@
|
|
|
61
61
|
"test:coverage": "vitest run --coverage",
|
|
62
62
|
"test:watch": "vitest",
|
|
63
63
|
"cover": "coveralls < .coverage/lcov.info",
|
|
64
|
-
"typecheck": "tsc --noEmit"
|
|
65
|
-
"version": "node ../../scripts/sync-peer-deps.mjs"
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
66
65
|
},
|
|
67
66
|
"peerDependencies": {
|
|
68
|
-
"@vitus-labs/core": "
|
|
67
|
+
"@vitus-labs/core": "workspace:^",
|
|
69
68
|
"react": ">= 19"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"@vitus-labs/core": "workspace:*",
|
|
73
72
|
"@vitus-labs/elements": "workspace:*",
|
|
74
|
-
"@vitus-labs/tools-rolldown": "2.
|
|
75
|
-
"@vitus-labs/tools-storybook": "2.
|
|
76
|
-
"@vitus-labs/tools-typescript": "2.
|
|
73
|
+
"@vitus-labs/tools-rolldown": "2.3.0",
|
|
74
|
+
"@vitus-labs/tools-storybook": "2.3.0",
|
|
75
|
+
"@vitus-labs/tools-typescript": "2.3.0",
|
|
77
76
|
"@vitus-labs/unistyle": "workspace:*"
|
|
78
77
|
}
|
|
79
78
|
}
|