@pyreon/rocketstyle 0.1.2 → 0.3.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 +15 -15
- package/lib/index.js +11 -8
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VNodeChild } from "@pyreon/core";
|
|
2
2
|
import { config, context, render } from "@pyreon/ui-core";
|
|
3
3
|
|
|
4
4
|
//#region src/context/context.d.ts
|
|
@@ -7,7 +7,7 @@ type Theme$1 = {
|
|
|
7
7
|
breakpoints?: Record<string, number>;
|
|
8
8
|
} & Record<string, unknown>;
|
|
9
9
|
type TProvider = {
|
|
10
|
-
children:
|
|
10
|
+
children: VNodeChild;
|
|
11
11
|
theme?: Theme$1 | undefined;
|
|
12
12
|
mode?: "light" | "dark" | undefined;
|
|
13
13
|
inversed?: boolean | undefined;
|
|
@@ -18,13 +18,13 @@ type TProvider = {
|
|
|
18
18
|
* Reads the parent context, merges incoming props, and resolves
|
|
19
19
|
* the active mode (with optional inversion for nested dark/light switching).
|
|
20
20
|
*
|
|
21
|
-
* In Pyreon, context is provided via
|
|
21
|
+
* In Pyreon, context is provided via provide() instead of React.Provider.
|
|
22
22
|
*/
|
|
23
23
|
declare const Provider: ({
|
|
24
24
|
provider,
|
|
25
25
|
inversed,
|
|
26
26
|
...props
|
|
27
|
-
}: TProvider) =>
|
|
27
|
+
}: TProvider) => VNodeChild;
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/constants/defaultDimensions.d.ts
|
|
30
30
|
/**
|
|
@@ -72,7 +72,7 @@ type TObj = Record<string, unknown>;
|
|
|
72
72
|
type TFn = (...args: any) => any;
|
|
73
73
|
type CallBackParam = TObj | TFn;
|
|
74
74
|
/** In Pyreon, components are plain functions — no forwardRef needed. */
|
|
75
|
-
type ComponentFn<P = any> = ((props: P) =>
|
|
75
|
+
type ComponentFn<P = any> = ((props: P) => VNodeChild) & Partial<Record<string, any>>;
|
|
76
76
|
type ElementType<T extends TObj | unknown = any> = ComponentFn<T>;
|
|
77
77
|
type ValueOf<T> = T[keyof T];
|
|
78
78
|
type ArrayOfValues<T> = T[keyof T][];
|
|
@@ -145,12 +145,12 @@ type DimensionResult<CT, T = any> = Record<string, boolean | null | DeepPartial<
|
|
|
145
145
|
type DimensionObj<CT, T = any> = DimensionResult<CT, T>;
|
|
146
146
|
type DimensionCb<T, CT> = (theme: T, mode: ThemeModeCallback, css: Css) => DimensionResult<CT, T>;
|
|
147
147
|
type DimensionCallbackParam<T, CT> = DimensionObj<CT, T> | DimensionCb<T, CT>;
|
|
148
|
-
type TDKP = Record<
|
|
148
|
+
type TDKP = Record<string, unknown>;
|
|
149
149
|
type DimensionProps<K extends DimensionValue, D extends Dimensions, P extends CallBackParam, DKP extends TDKP> = { [I in ExtractDimensionKey<D[keyof D]>]: I extends ExtractDimensionKey<K> ? ExtractNullableDimensionKeys<Spread<[DKP[I], NullableKeys<ReturnCbParam<P>>]>> : DKP[I] };
|
|
150
|
-
type DimensionTypesHelper<DKP extends TDKP> = { [I in keyof DKP]: keyof DKP[I] };
|
|
151
|
-
type DimensionObjAttrs<D extends Dimensions, DKP extends TDKP> = { [I in keyof DKP]: ExtractDimensionMulti<D[I]> extends true ? Array<keyof DKP[I]> : keyof DKP[I] };
|
|
152
|
-
type DimensionBooleanAttrs<DKP extends TDKP> = Partial<Record<ValueOf<DimensionTypesHelper<DKP>>, boolean>>;
|
|
153
|
-
type ExtractDimensionProps<D extends Dimensions, DKP extends TDKP, UB extends boolean> = UB extends true ? Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP> & DimensionBooleanAttrs<DKP>>> : Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP>>>;
|
|
150
|
+
type DimensionTypesHelper<D extends Dimensions, DKP extends TDKP> = { [I in ExtractDimensionKey<D[keyof D]> & keyof DKP]: keyof DKP[I] };
|
|
151
|
+
type DimensionObjAttrs<D extends Dimensions, DKP extends TDKP> = { [I in ExtractDimensionKey<D[keyof D]> & keyof DKP]: ExtractDimensionMulti<D[I & keyof D]> extends true ? Array<keyof DKP[I]> : keyof DKP[I] };
|
|
152
|
+
type DimensionBooleanAttrs<D extends Dimensions, DKP extends TDKP> = Partial<Record<ValueOf<DimensionTypesHelper<D, DKP>>, boolean>>;
|
|
153
|
+
type ExtractDimensionProps<D extends Dimensions, DKP extends TDKP, UB extends boolean> = UB extends true ? Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP> & DimensionBooleanAttrs<D, DKP>>> : Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP>>>;
|
|
154
154
|
type ExtractDimensions<D extends Dimensions, DKP extends TDKP> = ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP>>;
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region src/types/config.d.ts
|
|
@@ -173,7 +173,7 @@ type ConfigAttrs<C extends ElementType | unknown, D extends Dimensions, DKP exte
|
|
|
173
173
|
consumer: ConsumerCb<D, DKP>;
|
|
174
174
|
DEBUG: boolean;
|
|
175
175
|
inversed: boolean;
|
|
176
|
-
passProps: UB extends true ? keyof DimensionBooleanAttrs<DKP>[] : never;
|
|
176
|
+
passProps: UB extends true ? keyof DimensionBooleanAttrs<D, DKP>[] : never;
|
|
177
177
|
styled: boolean;
|
|
178
178
|
}>;
|
|
179
179
|
//#endregion
|
|
@@ -232,7 +232,7 @@ type RocketStyleComponent<OA extends TObj = {}, EA extends TObj = {}, T extends
|
|
|
232
232
|
* @param DFP Calculated final component props
|
|
233
233
|
*/
|
|
234
234
|
interface IRocketStyleComponent<OA extends TObj = {}, EA extends TObj = {}, T extends TObj = {}, CSS extends TObj = {}, S extends TObj = {}, HOC extends TObj = {}, D extends Dimensions = Dimensions, UB extends boolean = boolean, DKP extends TDKP = TDKP, DFP = MergeTypes<[OA, EA, DefaultProps, ExtractDimensionProps<D, DKP, UB>]>> {
|
|
235
|
-
(props: DFP):
|
|
235
|
+
(props: DFP): VNodeChild;
|
|
236
236
|
config: <NC extends ElementType | unknown = unknown>({
|
|
237
237
|
name,
|
|
238
238
|
component: NC,
|
|
@@ -242,9 +242,9 @@ interface IRocketStyleComponent<OA extends TObj = {}, EA extends TObj = {}, T ex
|
|
|
242
242
|
inversed,
|
|
243
243
|
passProps
|
|
244
244
|
}: ConfigAttrs<NC, D, DKP, UB>) => NC extends ElementType ? RocketStyleComponent<ExtractProps<NC>, EA, T, CSS, S, HOC, D, UB, DKP> : RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>;
|
|
245
|
-
attrs: <P extends TObj | unknown = unknown>(param: P extends TObj ? Partial<
|
|
245
|
+
attrs: <P extends TObj | unknown = unknown>(param: P extends TObj ? Partial<DFP & P> | ((props: Partial<DFP & P>, theme: Theme<T>, helpers: any) => Partial<P> & Record<string, unknown>) : Partial<DFP> | AttrsCb<DFP, Theme<T>>, config?: Partial<{
|
|
246
246
|
priority: boolean;
|
|
247
|
-
filter: P extends TObj ? Partial<keyof
|
|
247
|
+
filter: P extends TObj ? Partial<keyof (EA & P)>[] : Partial<keyof EA>[];
|
|
248
248
|
}>) => P extends TObj ? RocketStyleComponent<OA, MergeTypes<[EA, P]>, T, CSS, S, HOC, D, UB, DKP> : RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>;
|
|
249
249
|
theme: <P extends TObj = TObj>(param: Partial<P> | Partial<Styles<CSS>> | ThemeCb<P, Theme<T>>) => RocketStyleComponent<OA, EA, T, MergeTypes<[CSS, P]>, S, HOC, D, UB, DKP>;
|
|
250
250
|
styles: (param: StylesCb<CSS>) => RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>;
|
|
@@ -270,7 +270,7 @@ interface IRocketStyleComponent<OA extends TObj = {}, EA extends TObj = {}, T ex
|
|
|
270
270
|
type RocketComponent<C extends ElementType = ElementType, T extends TObj = {}, CSS extends TObj = {}, D extends Dimensions = DefaultDimensions, UB extends boolean = boolean> = (props: Configuration<C, D>) => RocketStyleComponent<ExtractProps<C>, {}, T, CSS, {}, {}, D, UB, {}>;
|
|
271
271
|
//#endregion
|
|
272
272
|
//#region src/init.d.ts
|
|
273
|
-
type Rocketstyle = <D extends Dimensions = DefaultDimensions, UB extends boolean = true>({
|
|
273
|
+
type Rocketstyle = <const D extends Dimensions = DefaultDimensions, UB extends boolean = true>({
|
|
274
274
|
dimensions,
|
|
275
275
|
useBooleans
|
|
276
276
|
}?: {
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, provide, useContext } from "@pyreon/core";
|
|
2
2
|
import { Provider as Provider$1, compose, config, context, get, hoistNonReactStatics, isEmpty, merge, omit, pick, render, set } from "@pyreon/ui-core";
|
|
3
3
|
import { signal } from "@pyreon/reactivity";
|
|
4
4
|
|
|
@@ -53,7 +53,7 @@ const ALL_RESERVED_KEYS = [
|
|
|
53
53
|
* Reads the parent context, merges incoming props, and resolves
|
|
54
54
|
* the active mode (with optional inversion for nested dark/light switching).
|
|
55
55
|
*
|
|
56
|
-
* In Pyreon, context is provided via
|
|
56
|
+
* In Pyreon, context is provided via provide() instead of React.Provider.
|
|
57
57
|
*/
|
|
58
58
|
const Provider = ({ provider = Provider$1, inversed, ...props }) => {
|
|
59
59
|
const { theme, mode, provider: RocketstyleProvider, children } = {
|
|
@@ -140,8 +140,8 @@ const useLocalContext = (consumer) => {
|
|
|
140
140
|
* detecting pseudo-states (hover, focus, pressed) via mouse/focus events
|
|
141
141
|
* and broadcasting them through local context to child rocketstyle components.
|
|
142
142
|
*
|
|
143
|
-
* In Pyreon, context is provided via
|
|
144
|
-
*
|
|
143
|
+
* In Pyreon, context is provided via provide(), and state is managed
|
|
144
|
+
* with signals instead of useState.
|
|
145
145
|
*/
|
|
146
146
|
const createLocalProvider = (WrappedComponent) => {
|
|
147
147
|
const HOCComponent = ({ onMouseEnter, onMouseLeave, onMouseUp, onMouseDown, onFocus, onBlur, $rocketstate, ...props }) => {
|
|
@@ -187,8 +187,7 @@ const createLocalProvider = (WrappedComponent) => {
|
|
|
187
187
|
...pseudoState()
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
|
|
191
|
-
onUnmount(() => popContext());
|
|
190
|
+
provide(localContext, updatedState);
|
|
192
191
|
return WrappedComponent({
|
|
193
192
|
...props,
|
|
194
193
|
...events,
|
|
@@ -570,6 +569,10 @@ const rocketComponent = (options) => {
|
|
|
570
569
|
context: FinalComponent.meta,
|
|
571
570
|
options: options.statics
|
|
572
571
|
});
|
|
572
|
+
createStaticsEnhancers({
|
|
573
|
+
context: FinalComponent,
|
|
574
|
+
options: options.statics
|
|
575
|
+
});
|
|
573
576
|
Object.assign(FinalComponent, {
|
|
574
577
|
attrs: (attrs, { priority, filter } = {}) => {
|
|
575
578
|
const result = {};
|
|
@@ -625,7 +628,7 @@ const validateInit = (name, component, dimensions) => {
|
|
|
625
628
|
}
|
|
626
629
|
if (!isEmpty(errors)) throw Error(JSON.stringify(errors));
|
|
627
630
|
};
|
|
628
|
-
const rocketstyle = ({ dimensions = DEFAULT_DIMENSIONS, useBooleans = true } = {}) => ({ name, component }) => {
|
|
631
|
+
const rocketstyle = (({ dimensions = DEFAULT_DIMENSIONS, useBooleans = true } = {}) => ({ name, component }) => {
|
|
629
632
|
if (process.env.NODE_ENV !== "production") validateInit(name, component, dimensions);
|
|
630
633
|
return rocketComponent({
|
|
631
634
|
name,
|
|
@@ -638,7 +641,7 @@ const rocketstyle = ({ dimensions = DEFAULT_DIMENSIONS, useBooleans = true } = {
|
|
|
638
641
|
transformKeys: getTransformDimensions(dimensions),
|
|
639
642
|
styled: true
|
|
640
643
|
});
|
|
641
|
-
};
|
|
644
|
+
});
|
|
642
645
|
|
|
643
646
|
//#endregion
|
|
644
647
|
//#region src/isRocketComponent.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/rocketstyle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pyreon/ui-system",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@pyreon/core": ">=0.4.0 <1.0.0",
|
|
45
45
|
"@pyreon/reactivity": ">=0.4.0 <1.0.0",
|
|
46
|
-
"@pyreon/ui-core": ">=0.
|
|
47
|
-
"@pyreon/styler": ">=0.
|
|
46
|
+
"@pyreon/ui-core": ">=0.3.0",
|
|
47
|
+
"@pyreon/styler": ">=0.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@vitus-labs/tools-rolldown": "^1.15.3",
|
|
51
|
-
"@
|
|
51
|
+
"@pyreon/typescript": "^0.7.4"
|
|
52
52
|
}
|
|
53
53
|
}
|