praxis-kit 2.0.2 → 3.1.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/dist/{chunk-ACAKUHH5.js → chunk-6RJN5B6L.js} +192 -175
- package/dist/codemod/index.d.ts +1 -20
- package/dist/codemod/index.js +668 -637
- package/dist/contract/index.d.ts +9 -9
- package/dist/contract/index.js +24 -13
- package/dist/eslint/index.js +16 -16
- package/dist/lit/index.d.ts +14 -14
- package/dist/lit/index.js +67 -56
- package/dist/{merge-refs-tA18zYP6.d.ts → merge-refs-CfAbwCKz.d.ts} +16 -14
- package/dist/preact/index.d.ts +16 -16
- package/dist/preact/index.js +63 -52
- package/dist/react/index.d.ts +8 -10
- package/dist/react/index.js +2 -6
- package/dist/react/legacy.d.ts +7 -7
- package/dist/react/legacy.js +3 -1
- package/dist/solid/index.d.ts +17 -17
- package/dist/solid/index.js +63 -52
- package/dist/svelte/index.d.ts +20 -20
- package/dist/svelte/index.js +60 -49
- package/dist/tailwind/index.js +23 -23
- package/dist/vite-plugin/index.d.ts +76 -50
- package/dist/vite-plugin/index.js +146 -41
- package/dist/vue/index.d.ts +16 -16
- package/dist/vue/index.js +63 -52
- package/dist/web/index.d.ts +14 -14
- package/dist/web/index.js +65 -54
- package/package.json +4 -4
package/dist/contract/index.d.ts
CHANGED
|
@@ -111,25 +111,25 @@ type VariantSelection<V extends VariantMap> = {
|
|
|
111
111
|
* Presets are named bundles of variant props that callers activate by key,
|
|
112
112
|
* avoiding the need to repeat variant combinations at each call site.
|
|
113
113
|
*/
|
|
114
|
-
type
|
|
114
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
115
115
|
|
|
116
|
-
type
|
|
116
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
117
117
|
|
|
118
118
|
interface BaseClassOptions {
|
|
119
119
|
baseClassName?: ClassName;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName,
|
|
122
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
123
123
|
|
|
124
|
-
interface
|
|
125
|
-
|
|
124
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
125
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
interface TagMapOptions {
|
|
129
129
|
tagMap?: TagMap;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions &
|
|
132
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
133
133
|
|
|
134
134
|
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
135
135
|
|
|
@@ -204,7 +204,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
204
204
|
readonly allowedAs?: readonly TAllowed[];
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
207
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
208
208
|
readonly base?: ClassName;
|
|
209
209
|
readonly variants?: V;
|
|
210
210
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
@@ -218,8 +218,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
218
218
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
219
219
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
220
220
|
}['normalize'];
|
|
221
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap,
|
|
222
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
221
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
|
|
222
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
|
|
223
223
|
readonly tag?: TDefault;
|
|
224
224
|
readonly name?: string;
|
|
225
225
|
readonly defaults?: Partial<NoInfer<Props>>;
|
package/dist/contract/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/chunk-
|
|
1
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
2
2
|
function assertNever(value) {
|
|
3
3
|
throw new Error(`Unexpected value: ${String(value)}`);
|
|
4
4
|
}
|
|
@@ -321,7 +321,7 @@ function isStandaloneTag(tag) {
|
|
|
321
321
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
// ../core/dist/chunk-
|
|
324
|
+
// ../core/dist/chunk-2NJ5XLOA.js
|
|
325
325
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
326
326
|
article: "article",
|
|
327
327
|
aside: "complementary",
|
|
@@ -350,26 +350,37 @@ function getImplicitRole(tag) {
|
|
|
350
350
|
if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
|
|
351
351
|
return void 0;
|
|
352
352
|
}
|
|
353
|
-
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
354
|
-
function
|
|
353
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
354
|
+
function getAsProp(child) {
|
|
355
|
+
if (!isObject(child) || !("props" in child)) return void 0;
|
|
356
|
+
const props = child.props;
|
|
357
|
+
if (!isObject(props)) return void 0;
|
|
358
|
+
const as = props.as;
|
|
359
|
+
return isString(as) && as !== "" ? as : void 0;
|
|
360
|
+
}
|
|
361
|
+
function getTag(child) {
|
|
355
362
|
if (!isObject(child) || !("type" in child)) return void 0;
|
|
356
363
|
const t = child.type;
|
|
357
364
|
if (isString(t)) return t;
|
|
358
|
-
if (
|
|
365
|
+
if (typeof t === "function" || isObject(t)) {
|
|
359
366
|
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
360
367
|
if (!isString(defaultTag)) return void 0;
|
|
361
|
-
|
|
362
|
-
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
363
|
-
return isString(as) ? as : defaultTag;
|
|
368
|
+
return getAsProp(child) ?? defaultTag;
|
|
364
369
|
}
|
|
365
370
|
return void 0;
|
|
366
371
|
}
|
|
367
|
-
function isTag(...
|
|
372
|
+
function isTag(...args) {
|
|
373
|
+
if (isString(args[0])) {
|
|
374
|
+
const set2 = new Set(args);
|
|
375
|
+
return (child2) => {
|
|
376
|
+
const tag2 = getTag(child2);
|
|
377
|
+
return tag2 !== void 0 && set2.has(tag2);
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
const [child, ...tags] = args;
|
|
368
381
|
const set = new Set(tags);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return tag !== void 0 && set.has(tag);
|
|
372
|
-
};
|
|
382
|
+
const tag = getTag(child);
|
|
383
|
+
return tag !== void 0 && set.has(tag);
|
|
373
384
|
}
|
|
374
385
|
var pendingAsyncWarns = /* @__PURE__ */ new Set();
|
|
375
386
|
var asyncWarnScheduled = false;
|
package/dist/eslint/index.js
CHANGED
|
@@ -24,9 +24,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
27
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js
|
|
28
28
|
var require_deepMerge = __commonJS({
|
|
29
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
29
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js"(exports) {
|
|
30
30
|
"use strict";
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.isObjectNotArray = isObjectNotArray;
|
|
@@ -59,9 +59,9 @@ var require_deepMerge = __commonJS({
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
62
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js
|
|
63
63
|
var require_applyDefault = __commonJS({
|
|
64
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
64
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js"(exports) {
|
|
65
65
|
"use strict";
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
67
|
exports.applyDefault = applyDefault;
|
|
@@ -86,9 +86,9 @@ var require_applyDefault = __commonJS({
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
89
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js
|
|
90
90
|
var require_parserSeemsToBeTSESLint = __commonJS({
|
|
91
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
91
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js"(exports) {
|
|
92
92
|
"use strict";
|
|
93
93
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
94
94
|
exports.parserSeemsToBeTSESLint = parserSeemsToBeTSESLint;
|
|
@@ -98,9 +98,9 @@ var require_parserSeemsToBeTSESLint = __commonJS({
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
101
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js
|
|
102
102
|
var require_getParserServices = __commonJS({
|
|
103
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
103
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js"(exports) {
|
|
104
104
|
"use strict";
|
|
105
105
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106
106
|
exports.getParserServices = getParserServices;
|
|
@@ -131,17 +131,17 @@ var require_getParserServices = __commonJS({
|
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
134
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js
|
|
135
135
|
var require_InferTypesFromRule = __commonJS({
|
|
136
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
136
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js"(exports) {
|
|
137
137
|
"use strict";
|
|
138
138
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
142
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js
|
|
143
143
|
var require_nullThrows = __commonJS({
|
|
144
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
144
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js"(exports) {
|
|
145
145
|
"use strict";
|
|
146
146
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
147
147
|
exports.NullThrowsReasons = void 0;
|
|
@@ -159,9 +159,9 @@ var require_nullThrows = __commonJS({
|
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
162
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js
|
|
163
163
|
var require_RuleCreator = __commonJS({
|
|
164
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
164
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js"(exports) {
|
|
165
165
|
"use strict";
|
|
166
166
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
167
167
|
exports.RuleCreator = RuleCreator8;
|
|
@@ -207,9 +207,9 @@ var require_RuleCreator = __commonJS({
|
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
210
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js
|
|
211
211
|
var require_eslint_utils = __commonJS({
|
|
212
|
-
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.
|
|
212
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.5.0_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js"(exports) {
|
|
213
213
|
"use strict";
|
|
214
214
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
215
215
|
if (k2 === void 0) k2 = k;
|
package/dist/lit/index.d.ts
CHANGED
|
@@ -112,25 +112,25 @@ type VariantSelection<V extends VariantMap> = {
|
|
|
112
112
|
* Presets are named bundles of variant props that callers activate by key,
|
|
113
113
|
* avoiding the need to repeat variant combinations at each call site.
|
|
114
114
|
*/
|
|
115
|
-
type
|
|
115
|
+
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
116
116
|
|
|
117
|
-
type
|
|
117
|
+
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
118
118
|
|
|
119
119
|
interface BaseClassOptions {
|
|
120
120
|
baseClassName?: ClassName;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName,
|
|
123
|
+
type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string;
|
|
124
124
|
|
|
125
|
-
interface
|
|
126
|
-
|
|
125
|
+
interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
|
|
126
|
+
recipeMap?: Record<string, RecipeTarget<TVariants>>;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
interface TagMapOptions {
|
|
130
130
|
tagMap?: TagMap;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions &
|
|
133
|
+
type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
|
|
134
134
|
|
|
135
135
|
type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
|
|
136
136
|
|
|
@@ -205,7 +205,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
205
205
|
readonly allowedAs?: readonly TAllowed[];
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
208
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
209
209
|
readonly base?: ClassName;
|
|
210
210
|
readonly variants?: V;
|
|
211
211
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
@@ -219,8 +219,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
219
219
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
220
220
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
221
221
|
}['normalize'];
|
|
222
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap,
|
|
223
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
222
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyRecord>;
|
|
223
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
|
|
224
224
|
readonly tag?: TDefault;
|
|
225
225
|
readonly name?: string;
|
|
226
226
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
@@ -231,6 +231,8 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
231
231
|
|
|
232
232
|
type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
233
233
|
|
|
234
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
235
|
+
|
|
234
236
|
/**
|
|
235
237
|
* Options accepted by createContractComponent in the Lit adapter.
|
|
236
238
|
*
|
|
@@ -242,7 +244,7 @@ type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolea
|
|
|
242
244
|
* Note: this adapter targets Light DOM composition only. Shadow DOM slot
|
|
243
245
|
* protocol is intentionally out of scope.
|
|
244
246
|
*/
|
|
245
|
-
type LitFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
247
|
+
type LitFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps> & {
|
|
246
248
|
readonly filterProps?: FilterPredicate;
|
|
247
249
|
};
|
|
248
250
|
|
|
@@ -257,7 +259,7 @@ type UnknownProps = AnyRecord;
|
|
|
257
259
|
type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>> = {
|
|
258
260
|
new (): LitElement & {
|
|
259
261
|
as: string | undefined;
|
|
260
|
-
|
|
262
|
+
recipe: string | undefined;
|
|
261
263
|
praxisClass: string | undefined;
|
|
262
264
|
} & {
|
|
263
265
|
[K in Extract<keyof TVariants, string>]?: string | null;
|
|
@@ -284,9 +286,7 @@ type LitContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
|
|
|
284
286
|
* customElements.define('praxis-button', Button)
|
|
285
287
|
* ```
|
|
286
288
|
*/
|
|
287
|
-
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends
|
|
288
|
-
|
|
289
|
-
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
289
|
+
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<TVariants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: LitFactoryOptions<TDefault, TProps, TVariants, TPreset, TPluginProps>): LitContractComponent<TVariants>;
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
292
|
* Renders a praxis-kit Lit component to an HTML string without requiring a DOM.
|
package/dist/lit/index.js
CHANGED
|
@@ -12,7 +12,12 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
12
12
|
return out;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// ../../lib/adapter-utils/src/define-component.ts
|
|
16
|
+
function defineContractComponent(options) {
|
|
17
|
+
return (factory) => factory(options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ../core/dist/chunk-KKSHJDE7.js
|
|
16
21
|
function makeResolveTag(defaultTag) {
|
|
17
22
|
return function tag(as) {
|
|
18
23
|
return as ?? defaultTag;
|
|
@@ -81,7 +86,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
81
86
|
...whenDefined("defaultProps", options.defaults),
|
|
82
87
|
...whenDefined("baseClassName", styling?.base),
|
|
83
88
|
...whenDefined("tagMap", styling?.tags),
|
|
84
|
-
...whenDefined("
|
|
89
|
+
...whenDefined("recipeMap", styling?.presets),
|
|
85
90
|
...whenDefined("variants", styling?.variants),
|
|
86
91
|
...whenDefined("defaultVariants", styling?.defaults),
|
|
87
92
|
...whenDefined("compoundVariants", styling?.compounds),
|
|
@@ -122,10 +127,10 @@ function validateFactoryOptions(resolved) {
|
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
};
|
|
125
|
-
const {
|
|
126
|
-
if (
|
|
127
|
-
for (const
|
|
128
|
-
checkSelection(`preset "${
|
|
130
|
+
const { recipeMap } = resolved;
|
|
131
|
+
if (recipeMap) {
|
|
132
|
+
for (const recipeKey in recipeMap) {
|
|
133
|
+
checkSelection(`preset "${recipeKey}"`, recipeMap[recipeKey]);
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
|
|
@@ -161,12 +166,12 @@ function report2(strict, message) {
|
|
|
161
166
|
function label(name) {
|
|
162
167
|
return name ? `[${name}]` : "[createContractComponent]";
|
|
163
168
|
}
|
|
164
|
-
function validateRenderProps(options, props,
|
|
165
|
-
const { strict,
|
|
169
|
+
function validateRenderProps(options, props, recipeKey) {
|
|
170
|
+
const { strict, recipeMap, variants, displayName } = options;
|
|
166
171
|
if (!strict) return;
|
|
167
172
|
const tag = label(displayName);
|
|
168
|
-
if (
|
|
169
|
-
report2(strict, `${tag} Unknown
|
|
173
|
+
if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
|
|
174
|
+
report2(strict, `${tag} Unknown recipeKey "${recipeKey}" \u2014 no preset with that name exists.`);
|
|
170
175
|
}
|
|
171
176
|
if (variants) {
|
|
172
177
|
for (const key in variants) {
|
|
@@ -204,8 +209,8 @@ function assertPluginShape(result) {
|
|
|
204
209
|
}
|
|
205
210
|
function guardPipeline(pipeline) {
|
|
206
211
|
if (process.env.NODE_ENV === "production") return pipeline;
|
|
207
|
-
return function guardedPipeline(tag, props, className,
|
|
208
|
-
const result = pipeline(tag, props, className,
|
|
212
|
+
return function guardedPipeline(tag, props, className, recipe) {
|
|
213
|
+
const result = pipeline(tag, props, className, recipe);
|
|
209
214
|
if (typeof result !== "string")
|
|
210
215
|
panic(`[praxis-kit] Plugin pipeline must return a string. Got: ${describe(result)}.`);
|
|
211
216
|
return result;
|
|
@@ -230,11 +235,11 @@ function createRuntimeMethods(resolved, classPipeline, engine) {
|
|
|
230
235
|
resolveProps(props) {
|
|
231
236
|
return mergeProps(resolved.defaultProps, props);
|
|
232
237
|
},
|
|
233
|
-
resolveClasses(tag, props, className,
|
|
238
|
+
resolveClasses(tag, props, className, recipe) {
|
|
234
239
|
if (process.env.NODE_ENV !== "production") {
|
|
235
|
-
validateRenderProps(resolved, props,
|
|
240
|
+
validateRenderProps(resolved, props, recipe);
|
|
236
241
|
}
|
|
237
|
-
return classPipeline(tag, props, className,
|
|
242
|
+
return classPipeline(tag, props, className, recipe);
|
|
238
243
|
},
|
|
239
244
|
resolveAria(tag, props) {
|
|
240
245
|
if (!engine) return { props };
|
|
@@ -580,7 +585,7 @@ function isStandaloneTag(tag) {
|
|
|
580
585
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
581
586
|
}
|
|
582
587
|
|
|
583
|
-
// ../core/dist/chunk-
|
|
588
|
+
// ../core/dist/chunk-2NJ5XLOA.js
|
|
584
589
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
585
590
|
article: "article",
|
|
586
591
|
aside: "complementary",
|
|
@@ -609,26 +614,37 @@ function getImplicitRole(tag) {
|
|
|
609
614
|
if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
|
|
610
615
|
return void 0;
|
|
611
616
|
}
|
|
612
|
-
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
613
|
-
function
|
|
617
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
|
|
618
|
+
function getAsProp(child) {
|
|
619
|
+
if (!isObject(child) || !("props" in child)) return void 0;
|
|
620
|
+
const props = child.props;
|
|
621
|
+
if (!isObject(props)) return void 0;
|
|
622
|
+
const as = props.as;
|
|
623
|
+
return isString(as) && as !== "" ? as : void 0;
|
|
624
|
+
}
|
|
625
|
+
function getTag(child) {
|
|
614
626
|
if (!isObject(child) || !("type" in child)) return void 0;
|
|
615
627
|
const t = child.type;
|
|
616
628
|
if (isString(t)) return t;
|
|
617
|
-
if (
|
|
629
|
+
if (typeof t === "function" || isObject(t)) {
|
|
618
630
|
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
619
631
|
if (!isString(defaultTag)) return void 0;
|
|
620
|
-
|
|
621
|
-
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
622
|
-
return isString(as) ? as : defaultTag;
|
|
632
|
+
return getAsProp(child) ?? defaultTag;
|
|
623
633
|
}
|
|
624
634
|
return void 0;
|
|
625
635
|
}
|
|
626
|
-
function isTag(...
|
|
636
|
+
function isTag(...args) {
|
|
637
|
+
if (isString(args[0])) {
|
|
638
|
+
const set2 = new Set(args);
|
|
639
|
+
return (child2) => {
|
|
640
|
+
const tag2 = getTag(child2);
|
|
641
|
+
return tag2 !== void 0 && set2.has(tag2);
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const [child, ...tags] = args;
|
|
627
645
|
const set = new Set(tags);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
return tag !== void 0 && set.has(tag);
|
|
631
|
-
};
|
|
646
|
+
const tag = getTag(child);
|
|
647
|
+
return tag !== void 0 && set.has(tag);
|
|
632
648
|
}
|
|
633
649
|
var pendingAsyncWarns2 = /* @__PURE__ */ new Set();
|
|
634
650
|
var asyncWarnScheduled2 = false;
|
|
@@ -1515,7 +1531,7 @@ function getHtmlPropNormalizers(tag) {
|
|
|
1515
1531
|
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1516
1532
|
}
|
|
1517
1533
|
|
|
1518
|
-
// ../core/dist/chunk-
|
|
1534
|
+
// ../core/dist/chunk-3T4EM5FG.js
|
|
1519
1535
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1520
1536
|
var cx = clsx;
|
|
1521
1537
|
var cva = (base, config) => (props) => {
|
|
@@ -1592,18 +1608,18 @@ var StaticClassResolver = class {
|
|
|
1592
1608
|
};
|
|
1593
1609
|
var VariantClassResolver = class _VariantClassResolver {
|
|
1594
1610
|
#cvaFn;
|
|
1595
|
-
#
|
|
1611
|
+
#recipeMap;
|
|
1596
1612
|
#variantKeys;
|
|
1597
1613
|
#precomputedClasses;
|
|
1598
1614
|
#cache = /* @__PURE__ */ new Map();
|
|
1599
|
-
constructor(cvaFn,
|
|
1615
|
+
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
1600
1616
|
this.#cvaFn = cvaFn ?? null;
|
|
1601
|
-
this.#
|
|
1617
|
+
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
1602
1618
|
this.#variantKeys = variantKeys ?? null;
|
|
1603
1619
|
this.#precomputedClasses = precomputedClasses ?? null;
|
|
1604
1620
|
}
|
|
1605
|
-
resolve({ props,
|
|
1606
|
-
const normalizedKey =
|
|
1621
|
+
resolve({ props, recipe }) {
|
|
1622
|
+
const normalizedKey = recipe ?? "__none__";
|
|
1607
1623
|
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
1608
1624
|
if (this.#precomputedClasses !== null) {
|
|
1609
1625
|
const precomputed = this.#precomputedClasses[cacheKey];
|
|
@@ -1615,7 +1631,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1615
1631
|
this.#cache.set(cacheKey, cached);
|
|
1616
1632
|
return cached;
|
|
1617
1633
|
}
|
|
1618
|
-
const result = this.#compute(props,
|
|
1634
|
+
const result = this.#compute(props, recipe);
|
|
1619
1635
|
this.#cache.set(cacheKey, result);
|
|
1620
1636
|
if (this.#cache.size > 1e3) {
|
|
1621
1637
|
const lru = this.#cache.keys().next().value;
|
|
@@ -1623,10 +1639,10 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1623
1639
|
}
|
|
1624
1640
|
return result;
|
|
1625
1641
|
}
|
|
1626
|
-
#compute(props,
|
|
1642
|
+
#compute(props, recipe) {
|
|
1627
1643
|
if (!this.#cvaFn) return "";
|
|
1628
|
-
if (!
|
|
1629
|
-
const preset = this.#
|
|
1644
|
+
if (!recipe) return this.#cvaFn(props);
|
|
1645
|
+
const preset = this.#recipeMap[recipe];
|
|
1630
1646
|
if (!preset) return this.#cvaFn(props);
|
|
1631
1647
|
return this.#cvaFn({ ...preset, ...props });
|
|
1632
1648
|
}
|
|
@@ -1634,15 +1650,15 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
1634
1650
|
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
1635
1651
|
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
1636
1652
|
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
1637
|
-
#createCacheKey(props,
|
|
1653
|
+
#createCacheKey(props, recipe) {
|
|
1638
1654
|
if (this.#variantKeys !== null) {
|
|
1639
|
-
let key2 =
|
|
1655
|
+
let key2 = recipe;
|
|
1640
1656
|
for (const k of this.#variantKeys) {
|
|
1641
1657
|
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1642
1658
|
}
|
|
1643
1659
|
return key2;
|
|
1644
1660
|
}
|
|
1645
|
-
let key =
|
|
1661
|
+
let key = recipe;
|
|
1646
1662
|
for (const k of Object.keys(props).sort()) {
|
|
1647
1663
|
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
1648
1664
|
}
|
|
@@ -1667,13 +1683,13 @@ function createClassPipeline(resolved) {
|
|
|
1667
1683
|
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
1668
1684
|
const variantResolver = new VariantClassResolver(
|
|
1669
1685
|
cvaFn,
|
|
1670
|
-
resolved.
|
|
1686
|
+
resolved.recipeMap,
|
|
1671
1687
|
variantKeys,
|
|
1672
1688
|
resolved.precomputedClasses
|
|
1673
1689
|
);
|
|
1674
|
-
return function resolveClasses(tag, props, className,
|
|
1675
|
-
const staticClasses = staticResolver.resolve(tag,
|
|
1676
|
-
const variantClasses = variantResolver.resolve({ props,
|
|
1690
|
+
return function resolveClasses(tag, props, className, recipe) {
|
|
1691
|
+
const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
|
|
1692
|
+
const variantClasses = variantResolver.resolve({ props, recipe });
|
|
1677
1693
|
if (!className)
|
|
1678
1694
|
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
1679
1695
|
return cn(staticClasses, variantClasses, className);
|
|
@@ -1776,7 +1792,7 @@ function renderToString(component, props = {}, innerHTML = "") {
|
|
|
1776
1792
|
);
|
|
1777
1793
|
}
|
|
1778
1794
|
const { bundle } = entry;
|
|
1779
|
-
const { as, className,
|
|
1795
|
+
const { as, className, recipe, class: classAttr, ...rest } = props;
|
|
1780
1796
|
const tag = bundle.runtime.resolveTag(as);
|
|
1781
1797
|
const mergedProps = bundle.runtime.resolveProps(rest);
|
|
1782
1798
|
const resolvedClass = bundle.runtime.resolveClasses(
|
|
@@ -1784,7 +1800,7 @@ function renderToString(component, props = {}, innerHTML = "") {
|
|
|
1784
1800
|
mergedProps,
|
|
1785
1801
|
// Accept both React-style className and HTML-native class
|
|
1786
1802
|
className ?? classAttr,
|
|
1787
|
-
|
|
1803
|
+
recipe
|
|
1788
1804
|
);
|
|
1789
1805
|
const ariaResult = bundle.runtime.resolveAria(tag, mergedProps);
|
|
1790
1806
|
const filtered = applyFilter(
|
|
@@ -1820,7 +1836,7 @@ function toLooseBundle(bundle) {
|
|
|
1820
1836
|
return bundle;
|
|
1821
1837
|
}
|
|
1822
1838
|
function resolveHostState(bundle, props) {
|
|
1823
|
-
const { as, className,
|
|
1839
|
+
const { as, className, recipe, ...rest } = props;
|
|
1824
1840
|
const tag = bundle.runtime.resolveTag(as);
|
|
1825
1841
|
const mergedProps = bundle.runtime.resolveProps(rest);
|
|
1826
1842
|
const baseProps = bundle.runtime.options.normalizeFn ? bundle.runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
@@ -1830,7 +1846,7 @@ function resolveHostState(bundle, props) {
|
|
|
1830
1846
|
tag,
|
|
1831
1847
|
normalizedProps,
|
|
1832
1848
|
className,
|
|
1833
|
-
|
|
1849
|
+
recipe
|
|
1834
1850
|
);
|
|
1835
1851
|
const ariaResult = bundle.runtime.resolveAria(tag, normalizedProps);
|
|
1836
1852
|
const attributes = applyFilter(
|
|
@@ -1871,10 +1887,10 @@ function createContractComponent(options) {
|
|
|
1871
1887
|
const bundle = buildRuntime(options);
|
|
1872
1888
|
const looseBundle = toLooseBundle(bundle);
|
|
1873
1889
|
const variantKeys = options.styling?.variants ? Object.keys(options.styling.variants) : [];
|
|
1874
|
-
const praxisProps = /* @__PURE__ */ new Set(["as", "
|
|
1890
|
+
const praxisProps = /* @__PURE__ */ new Set(["as", "recipe", "praxisClass", ...variantKeys]);
|
|
1875
1891
|
const staticProps = {
|
|
1876
1892
|
as: { type: String, attribute: "as" },
|
|
1877
|
-
|
|
1893
|
+
recipe: { type: String, attribute: "variant-key" },
|
|
1878
1894
|
// External className input — separate from the pipeline-output `class`
|
|
1879
1895
|
// attribute so _applyPraxis can read it without a circular class→pipeline→class loop.
|
|
1880
1896
|
praxisClass: { type: String, attribute: "praxis-class" }
|
|
@@ -1927,7 +1943,7 @@ function createContractComponent(options) {
|
|
|
1927
1943
|
if (attr.name !== "class") props[attr.name] = attr.value;
|
|
1928
1944
|
}
|
|
1929
1945
|
props["as"] = self.as;
|
|
1930
|
-
props["
|
|
1946
|
+
props["recipe"] = self.recipe;
|
|
1931
1947
|
props["className"] = self.praxisClass;
|
|
1932
1948
|
for (const key of variantKeys) {
|
|
1933
1949
|
const val = self[key];
|
|
@@ -1948,11 +1964,6 @@ function createContractComponent(options) {
|
|
|
1948
1964
|
registerForSsr(PolymorphicLitElement, looseBundle);
|
|
1949
1965
|
return PolymorphicLitElement;
|
|
1950
1966
|
}
|
|
1951
|
-
|
|
1952
|
-
// ../../adapters/lit/src/define-contract-component.ts
|
|
1953
|
-
function defineContractComponent(options) {
|
|
1954
|
-
return (factory) => factory(options);
|
|
1955
|
-
}
|
|
1956
1967
|
export {
|
|
1957
1968
|
createContractComponent,
|
|
1958
1969
|
defineContractComponent,
|