praxis-kit 2.0.0 → 2.0.1
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/dist/contract/index.d.ts +127 -2
- package/package.json +3 -3
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReadonlyDeep } from 'type-fest';
|
|
1
|
+
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
2
|
|
|
3
3
|
type AnyRecord = Record<string, unknown>;
|
|
4
4
|
|
|
@@ -11,10 +11,18 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
11
11
|
|
|
12
12
|
type AriaRole = KnownAriaRole | (string & {});
|
|
13
13
|
|
|
14
|
+
type ClassName = string | string[];
|
|
15
|
+
|
|
16
|
+
type EmptyRecord = Record<never, never>;
|
|
17
|
+
|
|
14
18
|
type IntrinsicProps = AnyRecord & {
|
|
15
19
|
role?: AriaRole;
|
|
16
20
|
};
|
|
17
21
|
|
|
22
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
23
|
+
|
|
24
|
+
type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
|
|
25
|
+
|
|
18
26
|
type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
|
|
19
27
|
|
|
20
28
|
type CardinalityInput = {
|
|
@@ -43,6 +51,99 @@ type ValidResult = {
|
|
|
43
51
|
valid: true;
|
|
44
52
|
};
|
|
45
53
|
|
|
54
|
+
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
55
|
+
|
|
56
|
+
type VariantValue = string | string[];
|
|
57
|
+
|
|
58
|
+
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
59
|
+
|
|
60
|
+
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
61
|
+
|
|
62
|
+
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
63
|
+
|
|
64
|
+
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
65
|
+
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
66
|
+
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
67
|
+
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
68
|
+
}>;
|
|
69
|
+
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
70
|
+
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
71
|
+
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
72
|
+
class: VariantValue;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
interface CVACompounds<V extends VariantMap> {
|
|
76
|
+
compoundVariants?: readonly CompoundVariant<V>[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The full optional prop surface exposed to callers for a given variant map. */
|
|
80
|
+
type VariantProps<V extends VariantMap> = {
|
|
81
|
+
[K in keyof V]?: VariantKey<V, K>;
|
|
82
|
+
};
|
|
83
|
+
type DefaultVariants<V extends VariantMap> = {
|
|
84
|
+
[K in keyof V]?: VariantKey<V, K>;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
interface CVADefaults<V extends VariantMap> {
|
|
88
|
+
defaultVariants?: DefaultVariants<V>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface CVAVariants<V extends VariantMap> {
|
|
92
|
+
variants?: V;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A partial selection of variant states authored at factory definition time.
|
|
97
|
+
*
|
|
98
|
+
* Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
|
|
99
|
+
* resolve the union at constraint-check time without deferred conditional types.
|
|
100
|
+
*/
|
|
101
|
+
type VariantSelection<V extends VariantMap> = {
|
|
102
|
+
[K in keyof V]?: keyof V[K];
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A static, immutable map of named presets to partial variant selections.
|
|
107
|
+
*
|
|
108
|
+
* Presets are named bundles of variant props that callers activate by key,
|
|
109
|
+
* avoiding the need to repeat variant combinations at each call site.
|
|
110
|
+
*/
|
|
111
|
+
type PresetMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
112
|
+
|
|
113
|
+
type PresetTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
114
|
+
|
|
115
|
+
interface BaseClassOptions {
|
|
116
|
+
baseClassName?: ClassName;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, variantKey?: string) => string;
|
|
120
|
+
|
|
121
|
+
interface PresetOptions<TVariants extends VariantMap = VariantMap> {
|
|
122
|
+
presetMap?: Record<string, PresetTarget<TVariants>>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface TagMapOptions {
|
|
126
|
+
tagMap?: TagMap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & PresetOptions<TVariants>>;
|
|
130
|
+
|
|
131
|
+
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
132
|
+
|
|
133
|
+
type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
|
|
134
|
+
|
|
135
|
+
type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
|
|
136
|
+
|
|
137
|
+
type OwnedPropKeys = ReadonlySet<string>;
|
|
138
|
+
|
|
139
|
+
type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
140
|
+
pipeline: ClassPipelineFn;
|
|
141
|
+
ownedKeys?: OwnedPropKeys;
|
|
142
|
+
readonly _pluginProps?: TProps;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode) => ClassPlugin<TProps>;
|
|
146
|
+
|
|
46
147
|
type AriaContext = {
|
|
47
148
|
readonly tag: IntrinsicTag;
|
|
48
149
|
readonly implicitRole: AriaRole | undefined;
|
|
@@ -100,6 +201,30 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
100
201
|
readonly allowedAs?: readonly TAllowed[];
|
|
101
202
|
};
|
|
102
203
|
|
|
204
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
205
|
+
readonly base?: ClassName;
|
|
206
|
+
readonly variants?: V;
|
|
207
|
+
readonly defaults?: Partial<VariantProps<V>>;
|
|
208
|
+
readonly compounds?: readonly CompoundVariant<V>[];
|
|
209
|
+
readonly presets?: TPreset;
|
|
210
|
+
readonly tags?: Readonly<TagMap>;
|
|
211
|
+
readonly plugin?: ClassPluginFactory<TPluginProps>;
|
|
212
|
+
readonly precomputedClasses?: Readonly<Record<string, string>>;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
216
|
+
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
217
|
+
}['normalize'];
|
|
218
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
|
|
219
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
|
|
220
|
+
readonly tag?: TDefault;
|
|
221
|
+
readonly name?: string;
|
|
222
|
+
readonly defaults?: Partial<NoInfer<Props>>;
|
|
223
|
+
readonly normalize?: NormalizeFn<NoInfer<Props>>;
|
|
224
|
+
readonly styling?: StylingOptions<V, TPreset, TPluginProps>;
|
|
225
|
+
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
226
|
+
};
|
|
227
|
+
|
|
103
228
|
declare const activeProps: PropNormalizer;
|
|
104
229
|
|
|
105
230
|
declare const disabledProps: PropNormalizer;
|
|
@@ -127,4 +252,4 @@ declare const selectedContract: EnforcementOptions;
|
|
|
127
252
|
|
|
128
253
|
declare function mergeContracts(...contracts: readonly EnforcementOptions[]): EnforcementOptions;
|
|
129
254
|
|
|
130
|
-
export { type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
|
|
255
|
+
export { type AnyFactoryOptions, type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praxis-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./react": {
|
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"vite": "^8.0.16",
|
|
131
131
|
"vue": "^3.5.38",
|
|
132
132
|
"@praxis-kit/adapter-utils": "0.0.0",
|
|
133
|
-
"@praxis-kit/
|
|
134
|
-
"@praxis-kit/
|
|
133
|
+
"@praxis-kit/core": "0.8.0-beta.4",
|
|
134
|
+
"@praxis-kit/shared": "0.8.0-beta.4"
|
|
135
135
|
},
|
|
136
136
|
"publishConfig": {
|
|
137
137
|
"access": "public"
|