@pyreon/rocketstyle 0.24.5 → 0.24.6
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/package.json +8 -10
- package/src/__tests__/attrs-overloads.test.ts +0 -97
- package/src/__tests__/attrs.test.ts +0 -190
- package/src/__tests__/cache-key-boolean-collision.test.ts +0 -54
- package/src/__tests__/chaining.test.ts +0 -86
- package/src/__tests__/collection.test.ts +0 -35
- package/src/__tests__/compose.test.ts +0 -36
- package/src/__tests__/context.test.ts +0 -200
- package/src/__tests__/createLocalProvider.test.ts +0 -280
- package/src/__tests__/dimensions.test.ts +0 -183
- package/src/__tests__/e2e-styler.test.ts +0 -299
- package/src/__tests__/hooks.test.ts +0 -178
- package/src/__tests__/isRocketComponent.test.ts +0 -48
- package/src/__tests__/memo-cap.test.ts +0 -174
- package/src/__tests__/minimal-theme.test.ts +0 -62
- package/src/__tests__/misc.test.ts +0 -204
- package/src/__tests__/native-marker.test.ts +0 -9
- package/src/__tests__/providerConsumer.test.ts +0 -183
- package/src/__tests__/reactive-props-preservation.test.ts +0 -195
- package/src/__tests__/rocketstyle.browser.test.tsx +0 -481
- package/src/__tests__/rocketstyleIntegration.test.ts +0 -711
- package/src/__tests__/theme-integration.test.tsx +0 -254
- package/src/__tests__/themeUtils.test.ts +0 -463
- package/src/cache/LocalThemeManager.ts +0 -14
- package/src/cache/index.ts +0 -3
- package/src/constants/booleanTags.ts +0 -32
- package/src/constants/defaultDimensions.ts +0 -23
- package/src/constants/index.ts +0 -59
- package/src/context/context.ts +0 -70
- package/src/context/createLocalProvider.ts +0 -97
- package/src/context/localContext.ts +0 -37
- package/src/env.d.ts +0 -6
- package/src/hoc/index.ts +0 -3
- package/src/hoc/rocketstyleAttrsHoc.ts +0 -76
- package/src/hooks/index.ts +0 -4
- package/src/hooks/usePseudoState.ts +0 -79
- package/src/hooks/useTheme.ts +0 -48
- package/src/index.ts +0 -95
- package/src/init.ts +0 -93
- package/src/isRocketComponent.ts +0 -16
- package/src/rocketstyle.ts +0 -640
- package/src/types/attrs.ts +0 -23
- package/src/types/config.ts +0 -48
- package/src/types/configuration.ts +0 -69
- package/src/types/dimensions.ts +0 -109
- package/src/types/hoc.ts +0 -5
- package/src/types/pseudo.ts +0 -19
- package/src/types/rocketComponent.ts +0 -24
- package/src/types/rocketstyle.ts +0 -220
- package/src/types/styles.ts +0 -61
- package/src/types/theme.ts +0 -18
- package/src/types/utils.ts +0 -98
- package/src/utils/attrs.ts +0 -181
- package/src/utils/chaining.ts +0 -58
- package/src/utils/collection.ts +0 -9
- package/src/utils/compose.ts +0 -11
- package/src/utils/dimensions.ts +0 -126
- package/src/utils/statics.ts +0 -44
- package/src/utils/styles.ts +0 -18
- package/src/utils/theme.ts +0 -211
package/src/types/config.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { DimensionBooleanAttrs, Dimensions, ExtractDimensions, TDKP } from './dimensions'
|
|
2
|
-
import type { PseudoState } from './pseudo'
|
|
3
|
-
import type { ElementType, TObj } from './utils'
|
|
4
|
-
|
|
5
|
-
// --------------------------------------------------------
|
|
6
|
-
// CONFIG
|
|
7
|
-
// --------------------------------------------------------
|
|
8
|
-
export type RocketComponentType = ElementType & {
|
|
9
|
-
IS_ROCKETSTYLE: true
|
|
10
|
-
$$rocketstyle: Record<string, unknown>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type RocketProviderState<T extends RocketComponentType | TObj | unknown = unknown> =
|
|
14
|
-
T extends RocketComponentType ? Partial<T['$$rocketstyle']> & { pseudo: PseudoState } : T
|
|
15
|
-
|
|
16
|
-
export type ConsumerCtxCBValue<
|
|
17
|
-
T extends RocketComponentType,
|
|
18
|
-
D extends Dimensions,
|
|
19
|
-
DKP extends TDKP,
|
|
20
|
-
> = (
|
|
21
|
-
attrs: RocketProviderState<T>,
|
|
22
|
-
) => DKP extends TDKP ? Partial<ExtractDimensions<D, DKP> & { pseudo: PseudoState }> : TObj
|
|
23
|
-
|
|
24
|
-
export type ConsumerCtxCb<D extends Dimensions, DKP extends TDKP = TDKP> = <
|
|
25
|
-
T extends RocketComponentType,
|
|
26
|
-
>(
|
|
27
|
-
attrs: ConsumerCtxCBValue<T, D, DKP>,
|
|
28
|
-
) => ReturnType<ConsumerCtxCBValue<T, D, DKP>>
|
|
29
|
-
|
|
30
|
-
export type ConsumerCb<D extends Dimensions, DKP extends TDKP = TDKP> = (
|
|
31
|
-
ctx: ConsumerCtxCb<D, DKP>,
|
|
32
|
-
) => ReturnType<ConsumerCtxCb<D, DKP>>
|
|
33
|
-
|
|
34
|
-
export type ConfigAttrs<
|
|
35
|
-
C extends ElementType | unknown,
|
|
36
|
-
D extends Dimensions,
|
|
37
|
-
DKP extends TDKP,
|
|
38
|
-
UB extends boolean,
|
|
39
|
-
> = Partial<{
|
|
40
|
-
name: string
|
|
41
|
-
component: C
|
|
42
|
-
provider: boolean
|
|
43
|
-
consumer: ConsumerCb<D, DKP>
|
|
44
|
-
DEBUG: boolean
|
|
45
|
-
inversed: boolean
|
|
46
|
-
passProps: UB extends true ? keyof DimensionBooleanAttrs<D, DKP>[] : never
|
|
47
|
-
styled: boolean
|
|
48
|
-
}>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { ConsumerCb } from './config'
|
|
2
|
-
import type { Dimensions, MultiKeys } from './dimensions'
|
|
3
|
-
import type { PseudoProps } from './pseudo'
|
|
4
|
-
import type { StylesCbArray } from './styles'
|
|
5
|
-
import type { ArrayOfKeys, ArrayOfValues, ElementType, TFn } from './utils'
|
|
6
|
-
|
|
7
|
-
export type __ROCKETSTYLE__ = {
|
|
8
|
-
dimensions: Record<string, string>
|
|
9
|
-
reservedPropNames: Record<string, true>
|
|
10
|
-
baseTheme: Record<string, unknown>
|
|
11
|
-
themes: Record<string, unknown>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type OptionFunc = (...arg: unknown[]) => Record<string, unknown>
|
|
15
|
-
|
|
16
|
-
export type InitConfiguration<C, D> = {
|
|
17
|
-
name?: string | undefined
|
|
18
|
-
component: C
|
|
19
|
-
useBooleans: boolean
|
|
20
|
-
dimensions: D
|
|
21
|
-
dimensionKeys: ArrayOfKeys<D>
|
|
22
|
-
dimensionValues: ArrayOfValues<D>
|
|
23
|
-
multiKeys: MultiKeys
|
|
24
|
-
transformKeys: Partial<Record<string, true>>
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type Configuration<
|
|
28
|
-
C = ElementType | unknown,
|
|
29
|
-
D extends Dimensions = Dimensions,
|
|
30
|
-
> = InitConfiguration<C, D> & {
|
|
31
|
-
provider?: boolean | undefined
|
|
32
|
-
consumer?: ConsumerCb<D> | undefined
|
|
33
|
-
DEBUG?: boolean | undefined
|
|
34
|
-
inversed?: boolean | undefined
|
|
35
|
-
passProps?: string[] | undefined
|
|
36
|
-
styled?: boolean | undefined
|
|
37
|
-
|
|
38
|
-
// array chaining options
|
|
39
|
-
attrs: OptionFunc[]
|
|
40
|
-
priorityAttrs: OptionFunc[]
|
|
41
|
-
filterAttrs: string[]
|
|
42
|
-
theme: OptionFunc[]
|
|
43
|
-
styles: StylesCbArray
|
|
44
|
-
compose: Record<string, TFn | null | undefined | false>
|
|
45
|
-
statics: Record<string, any>
|
|
46
|
-
} & Record<string, any>
|
|
47
|
-
|
|
48
|
-
export type ExtendedConfiguration<
|
|
49
|
-
C = ElementType | unknown,
|
|
50
|
-
D extends Dimensions = Dimensions,
|
|
51
|
-
> = InitConfiguration<C, D> & {
|
|
52
|
-
provider?: boolean | undefined
|
|
53
|
-
consumer?: ConsumerCb<D> | undefined
|
|
54
|
-
DEBUG?: boolean | undefined
|
|
55
|
-
inversed?: boolean | undefined
|
|
56
|
-
passProps?: string[] | undefined
|
|
57
|
-
styled?: boolean | undefined
|
|
58
|
-
|
|
59
|
-
// array chaining options
|
|
60
|
-
attrs: OptionFunc
|
|
61
|
-
priorityAttrs: OptionFunc
|
|
62
|
-
filterAttrs: string[]
|
|
63
|
-
theme: OptionFunc
|
|
64
|
-
styles: StylesCbArray
|
|
65
|
-
compose: Record<string, TFn | null | undefined | false>
|
|
66
|
-
statics: Record<string, any>
|
|
67
|
-
} & Record<string, any>
|
|
68
|
-
|
|
69
|
-
export type DefaultProps = Partial<PseudoProps> & { children?: import('@pyreon/core').VNodeChild }
|
package/src/types/dimensions.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { DefaultDimensions } from '../constants/defaultDimensions'
|
|
2
|
-
import type { Css } from './styles'
|
|
3
|
-
import type { ThemeModeCallback } from './theme'
|
|
4
|
-
import type { CallBackParam, NullableKeys, ReturnCbParam, Spread, TObj, ValueOf } from './utils'
|
|
5
|
-
|
|
6
|
-
export type { DefaultDimensions }
|
|
7
|
-
|
|
8
|
-
export type ExtractNullableDimensionKeys<T> = {
|
|
9
|
-
[P in keyof T as T[P] extends false ? never : P]: T[P]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type ExtractDimensionKey<T extends DimensionValue> = T extends DimensionValueObj
|
|
13
|
-
? T['propName']
|
|
14
|
-
: T
|
|
15
|
-
|
|
16
|
-
export type ExtractDimensionMulti<T extends DimensionValue> = T extends DimensionValueObj
|
|
17
|
-
? true
|
|
18
|
-
: false
|
|
19
|
-
|
|
20
|
-
export type ExtractDimensionAttrsKeys<D extends Dimensions> = {
|
|
21
|
-
[I in keyof D]: ExtractDimensionKey<D[I]>
|
|
22
|
-
}[keyof D]
|
|
23
|
-
|
|
24
|
-
export type DimensionValuePrimitive = string
|
|
25
|
-
export type DimensionValueObj = {
|
|
26
|
-
propName: string
|
|
27
|
-
multi?: boolean
|
|
28
|
-
/** When true, this dimension is evaluated last and its values receive the accumulated theme as argument. */
|
|
29
|
-
transform?: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type DimensionValue = DimensionValuePrimitive | DimensionValueObj
|
|
33
|
-
export type Dimensions = Record<string, DimensionValue>
|
|
34
|
-
|
|
35
|
-
export type MultiKeys<T extends Dimensions = Dimensions> = Partial<
|
|
36
|
-
Record<ExtractDimensionKey<T[keyof T]>, true>
|
|
37
|
-
>
|
|
38
|
-
|
|
39
|
-
/** Mode-aware value — either the value directly or a m(light, dark) callback. */
|
|
40
|
-
type ModeAware<T> = T | ((mode: 'light' | 'dark') => T)
|
|
41
|
-
|
|
42
|
-
type DeepPartial<T> = {
|
|
43
|
-
[K in keyof T]?: T[K] extends (...args: any[]) => any
|
|
44
|
-
? T[K]
|
|
45
|
-
: NonNullable<T[K]> extends Record<string, any>
|
|
46
|
-
? DeepPartial<NonNullable<T[K]>> | ModeAware<DeepPartial<NonNullable<T[K]>>> | Extract<T[K], null>
|
|
47
|
-
: ModeAware<T[K]>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type DimensionResult<CT, T = any> = Record<
|
|
51
|
-
string,
|
|
52
|
-
| boolean
|
|
53
|
-
| null
|
|
54
|
-
| DeepPartial<CT>
|
|
55
|
-
| ((theme: CT, appTheme: T, mode: ThemeModeCallback, css: Css) => DeepPartial<CT>)
|
|
56
|
-
>
|
|
57
|
-
export type DimensionObj<CT, T = any> = DimensionResult<CT, T>
|
|
58
|
-
|
|
59
|
-
export type DimensionCb<T, CT> = (
|
|
60
|
-
theme: T,
|
|
61
|
-
mode: ThemeModeCallback,
|
|
62
|
-
css: Css,
|
|
63
|
-
) => DimensionResult<CT, T>
|
|
64
|
-
|
|
65
|
-
export type DimensionCallbackParam<T, CT> = DimensionObj<CT, T> | DimensionCb<T, CT>
|
|
66
|
-
|
|
67
|
-
export type DimensionReturn<P, A> = P extends TObj ? A & P : A
|
|
68
|
-
|
|
69
|
-
export type TDKP = Record<string, unknown>
|
|
70
|
-
|
|
71
|
-
export type DimensionProps<
|
|
72
|
-
K extends DimensionValue,
|
|
73
|
-
D extends Dimensions,
|
|
74
|
-
P extends CallBackParam,
|
|
75
|
-
DKP extends TDKP,
|
|
76
|
-
> = {
|
|
77
|
-
[I in ExtractDimensionKey<D[keyof D]>]: I extends ExtractDimensionKey<K>
|
|
78
|
-
? ExtractNullableDimensionKeys<Spread<[DKP[I], NullableKeys<ReturnCbParam<P>>]>>
|
|
79
|
-
: DKP[I]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
type DimensionTypesHelper<D extends Dimensions, DKP extends TDKP> = {
|
|
83
|
-
[I in ExtractDimensionKey<D[keyof D]> & keyof DKP]: keyof DKP[I]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export type DimensionObjAttrs<D extends Dimensions, DKP extends TDKP> = {
|
|
87
|
-
[I in ExtractDimensionKey<D[keyof D]> & keyof DKP]: ExtractDimensionMulti<
|
|
88
|
-
D[I & keyof D]
|
|
89
|
-
> extends true
|
|
90
|
-
? keyof DKP[I] | Array<keyof DKP[I]>
|
|
91
|
-
: keyof DKP[I]
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type DimensionBooleanAttrs<D extends Dimensions, DKP extends TDKP> = Partial<
|
|
95
|
-
Record<ValueOf<DimensionTypesHelper<D, DKP>>, boolean>
|
|
96
|
-
>
|
|
97
|
-
|
|
98
|
-
export type ExtractDimensionProps<
|
|
99
|
-
D extends Dimensions,
|
|
100
|
-
DKP extends TDKP,
|
|
101
|
-
UB extends boolean,
|
|
102
|
-
> = UB extends true
|
|
103
|
-
? Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP> & DimensionBooleanAttrs<D, DKP>>>
|
|
104
|
-
: Partial<ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP>>>
|
|
105
|
-
|
|
106
|
-
export type ExtractDimensions<
|
|
107
|
-
D extends Dimensions,
|
|
108
|
-
DKP extends TDKP,
|
|
109
|
-
> = ExtractNullableDimensionKeys<DimensionObjAttrs<D, DKP>>
|
package/src/types/hoc.ts
DELETED
package/src/types/pseudo.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type PseudoActions = {
|
|
2
|
-
onMouseEnter: (e: MouseEvent) => void
|
|
3
|
-
onMouseLeave: (e: MouseEvent) => void
|
|
4
|
-
onMouseDown: (e: MouseEvent) => void
|
|
5
|
-
onMouseUp: (e: MouseEvent) => void
|
|
6
|
-
onFocus: (e: FocusEvent) => void
|
|
7
|
-
onBlur: (e: FocusEvent) => void
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type PseudoState = {
|
|
11
|
-
active: boolean
|
|
12
|
-
hover: boolean
|
|
13
|
-
focus: boolean
|
|
14
|
-
pressed: boolean
|
|
15
|
-
disabled: boolean
|
|
16
|
-
readOnly: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type PseudoProps = Partial<PseudoState & PseudoActions>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Configuration } from './configuration'
|
|
2
|
-
import type { DefaultDimensions, Dimensions } from './dimensions'
|
|
3
|
-
import type { RocketStyleComponent } from './rocketstyle'
|
|
4
|
-
import type { ElementType, ExtractProps, TObj } from './utils'
|
|
5
|
-
|
|
6
|
-
export type RocketComponent<
|
|
7
|
-
C extends ElementType = ElementType,
|
|
8
|
-
T extends TObj = {},
|
|
9
|
-
CSS extends TObj = {},
|
|
10
|
-
D extends Dimensions = DefaultDimensions,
|
|
11
|
-
UB extends boolean = boolean,
|
|
12
|
-
> = (props: Configuration<C, D>) => RocketStyleComponent<
|
|
13
|
-
// keep original component props + extract dimension props
|
|
14
|
-
ExtractProps<C>,
|
|
15
|
-
// set default extending props
|
|
16
|
-
{},
|
|
17
|
-
T,
|
|
18
|
-
CSS,
|
|
19
|
-
{},
|
|
20
|
-
{},
|
|
21
|
-
D,
|
|
22
|
-
UB,
|
|
23
|
-
{}
|
|
24
|
-
>
|
package/src/types/rocketstyle.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import type { VNodeChild } from '@pyreon/core'
|
|
2
|
-
import type { AttrsHelpers } from './attrs'
|
|
3
|
-
import type { ConfigAttrs } from './config'
|
|
4
|
-
import type { DefaultProps } from './configuration'
|
|
5
|
-
import type {
|
|
6
|
-
DimensionCallbackParam,
|
|
7
|
-
DimensionProps,
|
|
8
|
-
Dimensions,
|
|
9
|
-
DimensionValue,
|
|
10
|
-
ExtractDimensionProps,
|
|
11
|
-
ExtractDimensions,
|
|
12
|
-
MultiKeys,
|
|
13
|
-
TDKP,
|
|
14
|
-
} from './dimensions'
|
|
15
|
-
import type { ComposeParam } from './hoc'
|
|
16
|
-
import type { Styles, StylesCb } from './styles'
|
|
17
|
-
import type { Theme, ThemeCb, ThemeModeKeys } from './theme'
|
|
18
|
-
import type { ElementType, ExtractProps, MergeTypes, TObj } from './utils'
|
|
19
|
-
|
|
20
|
-
export type InnerComponentProps = {
|
|
21
|
-
'data-rocketstyle'?: string | undefined
|
|
22
|
-
} & Record<string, any>
|
|
23
|
-
|
|
24
|
-
export type RocketStyleComponent<
|
|
25
|
-
OA extends TObj = {},
|
|
26
|
-
EA extends TObj = {},
|
|
27
|
-
T extends TObj = {},
|
|
28
|
-
CSS extends TObj = {},
|
|
29
|
-
S extends TObj = {},
|
|
30
|
-
HOC extends TObj = {},
|
|
31
|
-
D extends Dimensions = Dimensions,
|
|
32
|
-
UB extends boolean = boolean,
|
|
33
|
-
DKP extends TDKP = TDKP,
|
|
34
|
-
> = IRocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP> & {
|
|
35
|
-
[I in keyof D]: <
|
|
36
|
-
K extends DimensionValue = D[I],
|
|
37
|
-
P extends DimensionCallbackParam<Theme<T>, Styles<CSS>> = DimensionCallbackParam<
|
|
38
|
-
Theme<T>,
|
|
39
|
-
Styles<CSS>
|
|
40
|
-
>,
|
|
41
|
-
>(
|
|
42
|
-
param: P,
|
|
43
|
-
) => P extends DimensionCallbackParam<Theme<T>, Styles<CSS>>
|
|
44
|
-
? RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DimensionProps<K, D, P, DKP>>
|
|
45
|
-
: RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param OA Origin component props params.
|
|
50
|
-
* @param EA Extended prop types
|
|
51
|
-
* @param T Theme passed via context.
|
|
52
|
-
* @param CSS Custom theme accepted by styles.
|
|
53
|
-
* @param S Defined statics
|
|
54
|
-
* @param D Dimensions to be used for defining component states.
|
|
55
|
-
* @param UB Use booleans value
|
|
56
|
-
* @param DKP Dimensions key props.
|
|
57
|
-
* @param DFP Calculated final component props
|
|
58
|
-
*/
|
|
59
|
-
export interface IRocketStyleComponent<
|
|
60
|
-
// original component props
|
|
61
|
-
OA extends TObj = {},
|
|
62
|
-
// extended component props
|
|
63
|
-
EA extends TObj = {},
|
|
64
|
-
// theme
|
|
65
|
-
T extends TObj = {},
|
|
66
|
-
// custom style properties
|
|
67
|
-
CSS extends TObj = {},
|
|
68
|
-
// statics
|
|
69
|
-
S extends TObj = {},
|
|
70
|
-
// hocs
|
|
71
|
-
HOC extends TObj = {},
|
|
72
|
-
// dimensions
|
|
73
|
-
D extends Dimensions = Dimensions,
|
|
74
|
-
// use booleans
|
|
75
|
-
UB extends boolean = boolean,
|
|
76
|
-
// dimension key props
|
|
77
|
-
DKP extends TDKP = TDKP,
|
|
78
|
-
// calculated final props
|
|
79
|
-
//
|
|
80
|
-
// `OA extends infer O` distributes over OA's union branches — future-proofs
|
|
81
|
-
// against the overload-aware `ExtractProps` (follow-up PR); for today's
|
|
82
|
-
// single-typed OA the distribution collapses to a single branch.
|
|
83
|
-
//
|
|
84
|
-
// **OA-overlapping EA keys are widened**. When `.attrs({ tag: 'a' })` sets
|
|
85
|
-
// a default for `tag` on a wrapper whose OA has `tag: HTMLTags`, we strip
|
|
86
|
-
// `tag` from OA and re-add it as `Partial<Pick<O, 'tag'>>` — taking O's
|
|
87
|
-
// WIDER type (`HTMLTags`), not EA's narrow literal `'a'`. The runtime
|
|
88
|
-
// default is `'a'`; the JSX call site still accepts any `HTMLTags` value
|
|
89
|
-
// (so `<Btn tag="span" />` is valid). `Partial<Omit<EA, keyof O>>` handles
|
|
90
|
-
// net-new EA-only keys (no OA conflict) and marks them optional too —
|
|
91
|
-
// every `.attrs()` value is semantically a default, never required of the
|
|
92
|
-
// consumer. Mirrors vitus-labs/ui-system PR #225.
|
|
93
|
-
DFP = OA extends infer O
|
|
94
|
-
? Omit<O, keyof EA & keyof O> &
|
|
95
|
-
Partial<Pick<O, keyof EA & keyof O>> &
|
|
96
|
-
MergeTypes<
|
|
97
|
-
[Partial<Omit<EA, keyof O>>, DefaultProps, ExtractDimensionProps<D, DKP, UB>]
|
|
98
|
-
>
|
|
99
|
-
: never,
|
|
100
|
-
> {
|
|
101
|
-
// The component is callable — Pyreon components are plain functions
|
|
102
|
-
(props: DFP): VNodeChild
|
|
103
|
-
|
|
104
|
-
// CONFIG chaining method
|
|
105
|
-
config: <NC extends ElementType | unknown = unknown>({
|
|
106
|
-
name,
|
|
107
|
-
component: NC,
|
|
108
|
-
provider,
|
|
109
|
-
consumer,
|
|
110
|
-
DEBUG,
|
|
111
|
-
inversed,
|
|
112
|
-
passProps,
|
|
113
|
-
}: ConfigAttrs<NC, D, DKP, UB>) => NC extends ElementType
|
|
114
|
-
? RocketStyleComponent<ExtractProps<NC>, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
115
|
-
: RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
116
|
-
|
|
117
|
-
// ATTRS chaining method
|
|
118
|
-
//
|
|
119
|
-
// Two overloads. TS resolves in declaration order; the callback form is
|
|
120
|
-
// listed FIRST so a function argument matches it before falling through to
|
|
121
|
-
// the object form. Mirrors vitus-labs/ui-system PR #227 Issue 2 (callback
|
|
122
|
-
// overload split).
|
|
123
|
-
//
|
|
124
|
-
// **Callback overload — asymmetric props/return**: the `props` arg is
|
|
125
|
-
// typed strictly as `Partial<DFP & P>` (so reading `props.x` narrows
|
|
126
|
-
// against the wrapped component's full surface), while the RETURN is
|
|
127
|
-
// `Partial<P> & Record<string, unknown>` — only the user's explicit `<P>`
|
|
128
|
-
// generic is checked, with a wildcard for runtime extras. This preserves
|
|
129
|
-
// Pyreon's documented convention where `.attrs(callback)` returns can
|
|
130
|
-
// carry runtime-only fields (`_documentProps` markers for the document-
|
|
131
|
-
// export pipeline, `tag: 'a'` overrides on Text-based components where
|
|
132
|
-
// the rendered DOM tag is outside the component's narrow `tag` union,
|
|
133
|
-
// etc.). The runtime is loose by design — `.attrs(cb, { filter })`
|
|
134
|
-
// strips keys before forwarding to the DOM. Consumers wanting strict
|
|
135
|
-
// typed extras pass `<P>` with the precise keys they expect.
|
|
136
|
-
//
|
|
137
|
-
// **Object overload — `P & Partial<NoInfer<DFP>>`**: TS infers P from
|
|
138
|
-
// the param's keys. `NoInfer<DFP>` (TS 5.4+) prevents DFP from
|
|
139
|
-
// contributing to P inference. Combined with DFP widening above, this
|
|
140
|
-
// makes `.attrs({ tag: 'a' })` keys optional at the JSX call site —
|
|
141
|
-
// every `.attrs()` value is a default, not a required prop. Mirrors
|
|
142
|
-
// vitus-labs PR #225.
|
|
143
|
-
attrs: {
|
|
144
|
-
<P extends TObj = {}>(
|
|
145
|
-
param: (
|
|
146
|
-
props: Partial<DFP & P>,
|
|
147
|
-
theme: Theme<T>,
|
|
148
|
-
helpers: AttrsHelpers,
|
|
149
|
-
) => Partial<P> & Record<string, unknown>,
|
|
150
|
-
config?: Partial<{
|
|
151
|
-
priority: boolean
|
|
152
|
-
filter: (keyof MergeTypes<[EA, P]>)[]
|
|
153
|
-
}>,
|
|
154
|
-
): RocketStyleComponent<OA, MergeTypes<[EA, P]>, T, CSS, S, HOC, D, UB, DKP>
|
|
155
|
-
|
|
156
|
-
<P extends TObj = {}>(
|
|
157
|
-
param: P & Partial<NoInfer<DFP>>,
|
|
158
|
-
config?: Partial<{
|
|
159
|
-
priority: boolean
|
|
160
|
-
filter: (keyof MergeTypes<[EA, P]>)[]
|
|
161
|
-
}>,
|
|
162
|
-
): RocketStyleComponent<OA, MergeTypes<[EA, P]>, T, CSS, S, HOC, D, UB, DKP>
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// THEME chaining method
|
|
166
|
-
theme: <P extends TObj = TObj>(
|
|
167
|
-
param: Partial<P> | Partial<Styles<CSS>> | ThemeCb<P, Theme<T>>,
|
|
168
|
-
) => RocketStyleComponent<OA, EA, T, MergeTypes<[CSS, P]>, S, HOC, D, UB, DKP>
|
|
169
|
-
|
|
170
|
-
// STYLES chaining method
|
|
171
|
-
styles: (param: StylesCb<CSS>) => RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
172
|
-
|
|
173
|
-
// COMPOSE chaining method
|
|
174
|
-
compose: <P extends ComposeParam>(
|
|
175
|
-
param: P,
|
|
176
|
-
) => P extends TObj
|
|
177
|
-
? RocketStyleComponent<OA, EA, T, CSS, S, MergeTypes<[HOC, P]>, D, UB, DKP>
|
|
178
|
-
: RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
179
|
-
|
|
180
|
-
// STATICS chaining method
|
|
181
|
-
statics: <P extends TObj | unknown = unknown>(
|
|
182
|
-
param: P,
|
|
183
|
-
) => P extends TObj
|
|
184
|
-
? RocketStyleComponent<OA, EA, T, CSS, MergeTypes<[S, P]>, HOC, D, UB, DKP>
|
|
185
|
-
: RocketStyleComponent<OA, EA, T, CSS, S, HOC, D, UB, DKP>
|
|
186
|
-
|
|
187
|
-
/** Access to all defined statics on the component. */
|
|
188
|
-
meta: S
|
|
189
|
-
|
|
190
|
-
getStaticDimensions: (theme: TObj) => {
|
|
191
|
-
dimensions: DKP
|
|
192
|
-
useBooleans: UB
|
|
193
|
-
multiKeys: MultiKeys<D>
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
getDefaultAttrs: (props: TObj, theme: TObj, mode: ThemeModeKeys) => TObj
|
|
197
|
-
|
|
198
|
-
readonly $$rocketstyle: ExtractDimensions<D, DKP>
|
|
199
|
-
readonly $$originTypes: OA
|
|
200
|
-
readonly $$extendedTypes: EA
|
|
201
|
-
readonly $$types: DFP
|
|
202
|
-
|
|
203
|
-
IS_ROCKETSTYLE: true
|
|
204
|
-
displayName: string
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The accumulated `.attrs()` callback chain — hoisted at component-creation
|
|
208
|
-
* time so external inspectors (notably `extractDocumentTree` from
|
|
209
|
-
* `@pyreon/connector-document`) can compute post-attrs props without
|
|
210
|
-
* invoking the full styled wrapper. Each callback maps user props to a
|
|
211
|
-
* partial props object; `chain.reduce(Object.assign, {})` produces the
|
|
212
|
-
* post-attrs result.
|
|
213
|
-
*
|
|
214
|
-
* Stable contract — consumers can rely on this property being present on
|
|
215
|
-
* every rocketstyle-wrapped component. Empty array when no `.attrs()`
|
|
216
|
-
* was ever called on the chain. Treat as read-only; mutating breaks
|
|
217
|
-
* `extractDocumentTree` and any other inspector consuming the hoist.
|
|
218
|
-
*/
|
|
219
|
-
readonly __rs_attrs: ReadonlyArray<(props: Record<string, unknown>) => Record<string, unknown>>
|
|
220
|
-
}
|
package/src/types/styles.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { config } from '@pyreon/ui-core'
|
|
2
|
-
import type { PseudoState } from './pseudo'
|
|
3
|
-
import type { TObj } from './utils'
|
|
4
|
-
|
|
5
|
-
export interface StylesDefault {}
|
|
6
|
-
|
|
7
|
-
export type Styles<_S = unknown> = StylesDefault
|
|
8
|
-
|
|
9
|
-
export type Css = typeof config.css
|
|
10
|
-
export type Style = ReturnType<Css>
|
|
11
|
-
export type OptionStyles = ((css: Css) => ReturnType<Css>)[]
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Props available inside `.styles()` interpolation functions.
|
|
15
|
-
*
|
|
16
|
-
* - `$rocketstyle` — resolved theme object (the styled() runtime resolves
|
|
17
|
-
* the reactive accessor before calling interpolation functions)
|
|
18
|
-
* - `$rocketstate` — active dimension values + pseudo state
|
|
19
|
-
*
|
|
20
|
-
* Note: internally, rocketstyle passes $rocketstyle as a `() => CSS` accessor
|
|
21
|
-
* to DynamicStyled for reactive class swapping. But by the time interpolation
|
|
22
|
-
* functions run, it's always been resolved to a plain CSS object.
|
|
23
|
-
*/
|
|
24
|
-
/** Pseudo-state style overrides — always present (default to {}). */
|
|
25
|
-
type PseudoStyleOverrides = {
|
|
26
|
-
hover: Record<string, unknown>
|
|
27
|
-
focus: Record<string, unknown>
|
|
28
|
-
active: Record<string, unknown>
|
|
29
|
-
disabled: Record<string, unknown>
|
|
30
|
-
pressed: Record<string, unknown>
|
|
31
|
-
readOnly: Record<string, unknown>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type RocketStyleInterpolationProps<CSS extends TObj = TObj> = {
|
|
35
|
-
/** Resolved theme object — merged from .theme(), .states(), .sizes(), .variants(). */
|
|
36
|
-
$rocketstyle: CSS & PseudoStyleOverrides & Record<string, unknown>
|
|
37
|
-
/** Active dimension values + pseudo state (hover, focus, pressed, etc.). */
|
|
38
|
-
$rocketstate: Record<string, string | string[]> & {
|
|
39
|
-
pseudo: Partial<PseudoState>
|
|
40
|
-
}
|
|
41
|
-
} & Record<string, any>
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* A tagged-template css function whose interpolation functions
|
|
45
|
-
* receive typed props including `$rocketstyle` and `$rocketstate`.
|
|
46
|
-
*/
|
|
47
|
-
export type RocketCss<CSS extends TObj = TObj> = (
|
|
48
|
-
strings: TemplateStringsArray,
|
|
49
|
-
...values: Array<
|
|
50
|
-
| string
|
|
51
|
-
| number
|
|
52
|
-
| boolean
|
|
53
|
-
| null
|
|
54
|
-
| undefined
|
|
55
|
-
| ((props: RocketStyleInterpolationProps<CSS>) => any)
|
|
56
|
-
| any[]
|
|
57
|
-
>
|
|
58
|
-
) => any
|
|
59
|
-
|
|
60
|
-
export type StylesCb<CSS extends TObj = TObj> = (css: RocketCss<CSS>) => ReturnType<Css>
|
|
61
|
-
export type StylesCbArray = StylesCb[]
|
package/src/types/theme.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { THEME_MODES } from '../constants'
|
|
2
|
-
import type { Css } from './styles'
|
|
3
|
-
import type { MergeTypes } from './utils'
|
|
4
|
-
|
|
5
|
-
export interface ThemeDefault {}
|
|
6
|
-
|
|
7
|
-
export type Theme<T> = T extends unknown ? ThemeDefault : MergeTypes<[ThemeDefault, T]>
|
|
8
|
-
|
|
9
|
-
export type ThemeModeKeys = keyof typeof THEME_MODES
|
|
10
|
-
|
|
11
|
-
export type ThemeModeCallback = <A = any, B = any>(
|
|
12
|
-
light: A,
|
|
13
|
-
dark: B,
|
|
14
|
-
) => (mode: 'light' | 'dark') => A | B
|
|
15
|
-
|
|
16
|
-
export type ThemeMode = <A = any, B = any>(light: A, dark: B) => A | B
|
|
17
|
-
|
|
18
|
-
export type ThemeCb<CSS, T> = (theme: T, mode: ThemeModeCallback, css: Css) => Partial<CSS>
|
package/src/types/utils.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type { VNodeChild } from '@pyreon/core'
|
|
2
|
-
|
|
3
|
-
export type TObj = Record<string, unknown>
|
|
4
|
-
export type TFn = (...args: any) => any
|
|
5
|
-
export type CallBackParam = TObj | TFn
|
|
6
|
-
export type DisplayName = string
|
|
7
|
-
|
|
8
|
-
/** In Pyreon, components are plain functions — no forwardRef needed. */
|
|
9
|
-
export type ComponentFn<P = any> = ((props: P) => VNodeChild) & Partial<Record<string, any>>
|
|
10
|
-
|
|
11
|
-
export type ElementType<T extends TObj | unknown = any> = ComponentFn<T>
|
|
12
|
-
|
|
13
|
-
export type ValueOf<T> = T[keyof T]
|
|
14
|
-
|
|
15
|
-
export type ArrayOfValues<T> = T[keyof T][]
|
|
16
|
-
|
|
17
|
-
export type ArrayOfKeys<T> = Array<keyof T>
|
|
18
|
-
|
|
19
|
-
export type SimpleHoc<P extends Record<string, unknown> = Record<string, unknown>> = <
|
|
20
|
-
T extends ComponentFn<any>,
|
|
21
|
-
>(
|
|
22
|
-
WrappedComponent: T,
|
|
23
|
-
) => ComponentFn<MergeTypes<[P, ExtractProps<T>]>>
|
|
24
|
-
|
|
25
|
-
type IsFalseOrNullable<T> = T extends null | undefined | false ? never : true
|
|
26
|
-
export type NullableKeys<T> = { [K in keyof T]: IsFalseOrNullable<T[K]> }
|
|
27
|
-
|
|
28
|
-
export type ReturnCbParam<P extends TFn | TObj> = P extends TFn ? ReturnType<P> : P
|
|
29
|
-
|
|
30
|
-
// ─── MergeTypes ───────────────────────────────────────────────
|
|
31
|
-
type Id<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
|
|
32
|
-
|
|
33
|
-
type IsAny<T> = 0 extends 1 & T ? true : false
|
|
34
|
-
|
|
35
|
-
type ExtractNullableKeys<T> = {
|
|
36
|
-
[P in keyof T as IsAny<T[P]> extends true
|
|
37
|
-
? P
|
|
38
|
-
: [T[P]] extends [never]
|
|
39
|
-
? never
|
|
40
|
-
: [T[P]] extends [null | undefined]
|
|
41
|
-
? never
|
|
42
|
-
: P]: T[P]
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & R>
|
|
46
|
-
|
|
47
|
-
export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
|
|
48
|
-
? SpreadTwo<L, Spread<R>>
|
|
49
|
-
: unknown
|
|
50
|
-
|
|
51
|
-
export type MergeTypes<A extends readonly [...any]> = ExtractNullableKeys<Spread<A>>
|
|
52
|
-
|
|
53
|
-
// ─── ExtractProps ─────────────────────────────────────────────
|
|
54
|
-
/**
|
|
55
|
-
* Extracts the props type from a Pyreon component function — or passes
|
|
56
|
-
* through the input unchanged when it's already a props type.
|
|
57
|
-
*
|
|
58
|
-
* Multi-overload aware: matches up to 4 call signatures and produces the
|
|
59
|
-
* UNION of their first-argument types. A single-overload function still
|
|
60
|
-
* works (the union of 4 copies of the same props type dedupes back to
|
|
61
|
-
* the single shape).
|
|
62
|
-
*
|
|
63
|
-
* **Why this shape**. `T extends (props: infer P) => any ? P : never` only
|
|
64
|
-
* captures the LAST overload of a multi-overload function — TS's overload-
|
|
65
|
-
* resolution-against-conditional-types semantics. Iterator / List / Element
|
|
66
|
-
* are 3-overload primitives where the LAST overload (`ChildrenProps`) is the
|
|
67
|
-
* loosest; without overload-aware extraction, `ExtractProps<Iterator>`
|
|
68
|
-
* returned just `ChildrenProps` and lost both `SimpleProps<T>` and
|
|
69
|
-
* `ObjectProps<T>` — wrapping Iterator through `rocketstyle()` /
|
|
70
|
-
* `attrs()` silently downgraded the public prop surface.
|
|
71
|
-
*
|
|
72
|
-
* The pattern-match shape `T extends { (props: infer P1, ...args: any): any;
|
|
73
|
-
* (props: infer P2, ...args: any): any; ... }` is the canonical TS trick
|
|
74
|
-
* for extracting overload sets — see also `Parameters<T>` semantics.
|
|
75
|
-
*
|
|
76
|
-
* Mirrors vitus-labs PR #222.
|
|
77
|
-
*/
|
|
78
|
-
export type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends {
|
|
79
|
-
(props: infer P1, ...args: any): any
|
|
80
|
-
(props: infer P2, ...args: any): any
|
|
81
|
-
(props: infer P3, ...args: any): any
|
|
82
|
-
(props: infer P4, ...args: any): any
|
|
83
|
-
}
|
|
84
|
-
? P1 | P2 | P3 | P4
|
|
85
|
-
: TComponentOrTProps extends {
|
|
86
|
-
(props: infer P1, ...args: any): any
|
|
87
|
-
(props: infer P2, ...args: any): any
|
|
88
|
-
(props: infer P3, ...args: any): any
|
|
89
|
-
}
|
|
90
|
-
? P1 | P2 | P3
|
|
91
|
-
: TComponentOrTProps extends {
|
|
92
|
-
(props: infer P1, ...args: any): any
|
|
93
|
-
(props: infer P2, ...args: any): any
|
|
94
|
-
}
|
|
95
|
-
? P1 | P2
|
|
96
|
-
: TComponentOrTProps extends ComponentFn<infer TProps>
|
|
97
|
-
? TProps
|
|
98
|
-
: TComponentOrTProps
|