praxis-kit 7.0.0 → 7.4.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/_shared/diagnostics.d.ts +6 -0
- package/dist/{chunk-35CJAOJW.js → chunk-EIKPSL26.js} +63 -6
- package/dist/codemod/index.js +121 -72
- package/dist/contract/index.d.ts +92 -0
- package/dist/guards/index.d.ts +6 -0
- package/dist/guards/index.js +4 -4
- package/dist/html/index.d.ts +6 -0
- package/dist/lit/index.d.ts +158 -6
- package/dist/lit/index.js +83 -9
- package/dist/preact/index.d.ts +164 -3
- package/dist/preact/index.js +104 -31
- package/dist/react/index.d.ts +26 -3
- package/dist/react/index.js +34 -8
- package/dist/react/legacy.d.ts +25 -3
- package/dist/react/legacy.js +17 -3
- package/dist/{react-options-Cm99IE5J.d.ts → react-options-BnjZpdVh.d.ts} +141 -3
- package/dist/solid/index.d.ts +163 -3
- package/dist/solid/index.js +100 -17
- package/dist/svelte/Polymorphic.svelte +25 -0
- package/dist/svelte/index.d.ts +231 -13
- package/dist/svelte/index.js +16 -8
- package/dist/tailwind/index.d.ts +12 -0
- package/dist/ts-plugin/index.cjs +5 -2
- package/dist/vite-plugin/index.d.ts +6 -0
- package/dist/vue/index.d.ts +166 -3
- package/dist/vue/index.js +119 -37
- package/dist/web/index.d.ts +132 -4
- package/dist/web/index.js +94 -13
- package/package.json +4 -4
package/dist/web/index.d.ts
CHANGED
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
2
|
import { Diagnostics, DiagnosticInput, DiagnosticsMode } from '../_shared/diagnostics.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A string-keyed object whose values are of type `T`.
|
|
6
|
+
*/
|
|
4
7
|
type StringMap<T = unknown> = Record<string, T>;
|
|
8
|
+
/**
|
|
9
|
+
* A string-keyed object with values of unknown type.
|
|
10
|
+
*/
|
|
5
11
|
type AnyRecord = StringMap<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* An object type with no named properties.
|
|
14
|
+
*
|
|
15
|
+
* Unlike `{}`, this excludes arbitrary properties during type operations while
|
|
16
|
+
* still satisfying `extends object`.
|
|
17
|
+
*/
|
|
6
18
|
type EmptyRecord = Record<never, never>;
|
|
19
|
+
/**
|
|
20
|
+
* A compound component's named sub-components, for example
|
|
21
|
+
* `{ Header, Content, Footer }`.
|
|
22
|
+
*/
|
|
23
|
+
type SubComponentMap = Readonly<AnyRecord>;
|
|
24
|
+
/**
|
|
25
|
+
* Default `Variants` type for components that declare no variants.
|
|
26
|
+
*
|
|
27
|
+
* Structurally identical to `Readonly<EmptyRecord>`, but named separately so
|
|
28
|
+
* editor hovers remain self-descriptive.
|
|
29
|
+
*/
|
|
30
|
+
type NoVariants = Readonly<EmptyRecord>;
|
|
31
|
+
/**
|
|
32
|
+
* Default `TPreset` type for components that declare no named presets.
|
|
33
|
+
*
|
|
34
|
+
* Structurally identical to `Readonly<EmptyRecord>`, but named separately so
|
|
35
|
+
* editor hovers remain self-descriptive.
|
|
36
|
+
*/
|
|
37
|
+
type NoPreset = Readonly<EmptyRecord>;
|
|
38
|
+
/**
|
|
39
|
+
* Fallback for `ExtractPluginProps<TPlugin>` when a plugin contributes no
|
|
40
|
+
* props, including the no-plugin case.
|
|
41
|
+
*
|
|
42
|
+
* Structurally identical to `EmptyRecord`, but named separately so editor
|
|
43
|
+
* hovers remain self-descriptive.
|
|
44
|
+
*/
|
|
45
|
+
type NoPluginProps = EmptyRecord;
|
|
7
46
|
|
|
8
47
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
9
48
|
|
|
@@ -169,7 +208,7 @@ type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends Var
|
|
|
169
208
|
* wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
|
|
170
209
|
* capability wiring). */
|
|
171
210
|
type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
|
|
172
|
-
type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ?
|
|
211
|
+
type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? NoPluginProps : T : NoPluginProps;
|
|
173
212
|
|
|
174
213
|
type AriaContext = {
|
|
175
214
|
readonly tag: IntrinsicTag;
|
|
@@ -233,6 +272,12 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
233
272
|
* `@praxis-kit/diagnostics`.
|
|
234
273
|
*/
|
|
235
274
|
readonly diagnostics?: Diagnostics | DiagnosticsMode;
|
|
275
|
+
/**
|
|
276
|
+
* ARIA/accessibility rules evaluated against the resolved tag and props on every render.
|
|
277
|
+
* Each rule is a function receiving the current context and returning zero or more
|
|
278
|
+
* violations, some of which can carry an auto-applicable fix (see `createRemoveAttributeRule`
|
|
279
|
+
* and friends in `praxis-kit/contract`).
|
|
280
|
+
*/
|
|
236
281
|
readonly aria?: readonly AriaRule[];
|
|
237
282
|
/**
|
|
238
283
|
* Rules that need `AriaPolicyEngine`'s fix-application/caching machinery
|
|
@@ -244,6 +289,11 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
244
289
|
* misleading `aria` name to get the machinery it needs.
|
|
245
290
|
*/
|
|
246
291
|
readonly rules?: readonly AriaRule[];
|
|
292
|
+
/**
|
|
293
|
+
* Declares which children are valid, by name, match predicate, and cardinality (e.g. "at
|
|
294
|
+
* least 1, at most 4 `Button` children"). Open by default — children matching no rule are
|
|
295
|
+
* still allowed unless `exclusiveChildren` is set.
|
|
296
|
+
*/
|
|
247
297
|
readonly children?: readonly ChildRuleInput[];
|
|
248
298
|
/**
|
|
249
299
|
* When true, only children matching a `children` rule (or text, per `allowText`)
|
|
@@ -256,19 +306,49 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
256
306
|
* or any listed rule. Default: true.
|
|
257
307
|
*/
|
|
258
308
|
readonly allowText?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Prop transforms composed with the component's own `normalize` (from `FactoryOptions`) and
|
|
311
|
+
* run before it. Unlike `normalize`, these live in the enforcement bucket because they
|
|
312
|
+
* typically encode a built-in HTML/ARIA fact rather than component-specific behavior.
|
|
313
|
+
*/
|
|
259
314
|
readonly props?: readonly PropNormalizer[];
|
|
260
315
|
/** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
|
|
261
316
|
readonly allowedAs?: readonly TAllowed[];
|
|
262
317
|
};
|
|
263
318
|
|
|
264
319
|
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
|
|
320
|
+
/** Class applied to every instance regardless of variant selection. */
|
|
265
321
|
readonly base?: ClassName;
|
|
322
|
+
/**
|
|
323
|
+
* Named variant groups (e.g. `intent`, `size`), each mapping its possible values to a
|
|
324
|
+
* class string. A consumer selects a value per group as a prop (`<Button intent="primary">`).
|
|
325
|
+
*/
|
|
266
326
|
readonly variants?: V;
|
|
327
|
+
/** Value used for a variant group when the consumer doesn't pass one explicitly. */
|
|
267
328
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
329
|
+
/**
|
|
330
|
+
* Applies an extra class only when a specific *combination* of variant selections matches —
|
|
331
|
+
* for cases `variants` alone can't express (e.g. `intent: 'primary'` + `size: 'lg'` together
|
|
332
|
+
* need a class neither variant would add on its own).
|
|
333
|
+
*/
|
|
268
334
|
readonly compounds?: readonly CompoundVariant<V>[];
|
|
335
|
+
/**
|
|
336
|
+
* Named bundles of variant values, selectable as a single unit via the `recipe` prop (e.g.
|
|
337
|
+
* `<Button recipe="cta">` instead of setting `intent`/`size` individually).
|
|
338
|
+
*/
|
|
269
339
|
readonly presets?: TPreset;
|
|
340
|
+
/** Maps a resolved tag directly to a raw class string, independent of the variant system. */
|
|
270
341
|
readonly tags?: Readonly<TagMap>;
|
|
342
|
+
/**
|
|
343
|
+
* A `ClassPluginFactory` (e.g. the Tailwind layout pipeline) that extends class resolution
|
|
344
|
+
* with its own owned props, layered on top of `variants`/`presets`/`tags`.
|
|
345
|
+
*/
|
|
271
346
|
readonly plugin?: TPlugin;
|
|
347
|
+
/**
|
|
348
|
+
* A cache-key → resolved-class-string lookup for every statically-known variant
|
|
349
|
+
* combination, skipping runtime class computation entirely when a match is found. Normally
|
|
350
|
+
* generated by a build-time class-extraction plugin rather than hand-authored.
|
|
351
|
+
*/
|
|
272
352
|
readonly precomputedClasses?: Readonly<Record<string, string>>;
|
|
273
353
|
};
|
|
274
354
|
|
|
@@ -277,19 +357,65 @@ type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
|
277
357
|
}['normalize'];
|
|
278
358
|
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
|
|
279
359
|
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TAllowed extends ElementType = ElementType> = {
|
|
360
|
+
/** The intrinsic tag the component renders by default. Overridable per instance via `as`. */
|
|
280
361
|
readonly tag?: TDefault;
|
|
362
|
+
/** Display name used in diagnostics, dev tools, and generated component naming. */
|
|
281
363
|
readonly name?: string;
|
|
364
|
+
/** Values used for the component's own (non-variant) props when the consumer omits them. */
|
|
282
365
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
366
|
+
/**
|
|
367
|
+
* A pure `(props) => props` transform run on every render, after `enforcement.props`'s
|
|
368
|
+
* normalizers see the same input. Use this for component-specific prop shaping — anything
|
|
369
|
+
* that depends on live instance state or the real DOM element belongs in `onElement` instead.
|
|
370
|
+
*/
|
|
283
371
|
readonly normalize?: NormalizeFn<NoInfer<Props>>;
|
|
372
|
+
/** Variant groups, base classes, presets, and the optional class-resolution plugin. */
|
|
284
373
|
readonly styling?: StylingOptions<V, TPreset, TPlugin>;
|
|
374
|
+
/** ARIA rules, child-content contracts, and other runtime validation for this component. */
|
|
285
375
|
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
286
376
|
/**
|
|
287
377
|
* Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
|
|
288
378
|
* be set directly by component authors — use `enforcement.diagnostics` to override per component.
|
|
289
379
|
*/
|
|
290
380
|
readonly diagnostics?: Diagnostics;
|
|
381
|
+
/**
|
|
382
|
+
* Sub-components to attach to the generated root component, producing a
|
|
383
|
+
* compound component API (for example, `Card.Header`, `Card.Content`,
|
|
384
|
+
* and `Card.Footer`). Purely additive — has no effect on
|
|
385
|
+
* `enforcement.children`; author child rules explicitly if the component
|
|
386
|
+
* needs to validate its children.
|
|
387
|
+
*/
|
|
388
|
+
readonly subComponents?: SubComponentMap;
|
|
389
|
+
/**
|
|
390
|
+
* Called once per instance, when the real underlying DOM element first
|
|
391
|
+
* exists, in every adapter — via that adapter's own native mount
|
|
392
|
+
* lifecycle, never through the props/attribute pipeline. Use this for
|
|
393
|
+
* wiring that needs the actual element (native imperative methods like
|
|
394
|
+
* `dialogEl.showModal()`, native events like `close`/`cancel` that have
|
|
395
|
+
* no prop-based equivalent), not for anything expressible as a plain
|
|
396
|
+
* prop.
|
|
397
|
+
*
|
|
398
|
+
* `getProps` returns the instance's *current* resolved props at call
|
|
399
|
+
* time — read it from inside a listener registered once at mount, rather
|
|
400
|
+
* than re-subscribing on every prop change.
|
|
401
|
+
*
|
|
402
|
+
* Return a cleanup function to run when the instance unmounts.
|
|
403
|
+
*/
|
|
404
|
+
readonly onElement?: (element: Element, getProps: () => Readonly<Props>) => void | (() => void);
|
|
291
405
|
};
|
|
292
406
|
|
|
407
|
+
/**
|
|
408
|
+
* Determines whether a prop should be stripped before forwarding to the
|
|
409
|
+
* rendered element.
|
|
410
|
+
*
|
|
411
|
+
* Returning `true` excludes the prop from the output; returning `false`
|
|
412
|
+
* keeps it. This is the inverse polarity of `shouldForwardProp`-style
|
|
413
|
+
* predicates (Emotion/styled-components), where `true` means include.
|
|
414
|
+
*
|
|
415
|
+
* @param key - The prop name being evaluated.
|
|
416
|
+
* @param variantKeys - The set of configured variant prop names.
|
|
417
|
+
* @returns `true` to strip the prop; `false` to forward it.
|
|
418
|
+
*/
|
|
293
419
|
type FilterPredicate = (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
294
420
|
|
|
295
421
|
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
@@ -300,7 +426,7 @@ declare function defineContractComponent<O extends FactoryOptions>(options: O):
|
|
|
300
426
|
* Identical shape to LitFactoryOptions — a plain HTMLElement subclass with
|
|
301
427
|
* no framework dependency. Light DOM only; Shadow DOM is out of scope.
|
|
302
428
|
*/
|
|
303
|
-
type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> =
|
|
429
|
+
type WebFactoryOptions<TDefault extends ElementType = ElementType, TProps extends AnyRecord = EmptyRecord, TVariants extends Readonly<VariantMap> = NoVariants, TPreset extends RecipeMap<TVariants> = NoPreset, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = FactoryOptions<TDefault, TProps, TVariants, TPreset, TPlugin> & {
|
|
304
430
|
readonly filterProps?: FilterPredicate;
|
|
305
431
|
};
|
|
306
432
|
|
|
@@ -311,7 +437,7 @@ type UnknownProps = AnyRecord;
|
|
|
311
437
|
* Describes the public contract without exposing HTMLElement's internal members.
|
|
312
438
|
* Variant key instance properties are typed via TVariants.
|
|
313
439
|
*/
|
|
314
|
-
type WebContractComponent<TVariants extends Readonly<VariantMap> =
|
|
440
|
+
type WebContractComponent<TVariants extends Readonly<VariantMap> = NoVariants, TPluginProps extends AnyRecord = EmptyRecord> = {
|
|
315
441
|
new (): HTMLElement & {
|
|
316
442
|
as: string | undefined;
|
|
317
443
|
recipe: string | undefined;
|
|
@@ -352,7 +478,9 @@ type WebContractComponent<TVariants extends Readonly<VariantMap> = Readonly<Empt
|
|
|
352
478
|
* For non-reactive attributes (`aria-*`, `role`, `data-*`) call `element.update()`
|
|
353
479
|
* after setting them to trigger an explicit pipeline re-run.
|
|
354
480
|
*/
|
|
355
|
-
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> =
|
|
481
|
+
declare function createContractComponent<TDefault extends ElementType, TProps extends UnknownProps = EmptyRecord, TVariants extends Readonly<VariantMap> = NoVariants, TPreset extends RecipeMap<TVariants> = NoPreset, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TSubComponents extends Readonly<AnyRecord> = EmptyRecord>(options: WebFactoryOptions<TDefault, TProps, TVariants, TPreset, TPlugin> & {
|
|
482
|
+
readonly subComponents?: TSubComponents;
|
|
483
|
+
}): WebContractComponent<TVariants, ExtractPluginProps<TPlugin>> & TSubComponents;
|
|
356
484
|
|
|
357
485
|
/**
|
|
358
486
|
* Renders a praxis-kit web component to an HTML string without requiring a DOM.
|
package/dist/web/index.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
// ../../lib/adapter-utils/src/invariant.ts
|
|
2
|
+
function panic(message) {
|
|
3
|
+
throw new Error(message);
|
|
4
|
+
}
|
|
5
|
+
function invariant(condition, message) {
|
|
6
|
+
if (!condition) panic(message);
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
// ../../lib/adapter-utils/src/runtime/define-component.ts
|
|
2
10
|
function defineContractComponent(options) {
|
|
3
11
|
return (factory) => factory(options);
|
|
4
12
|
}
|
|
5
13
|
|
|
14
|
+
// ../../lib/adapter-utils/src/runtime/assemble-compound-component.ts
|
|
15
|
+
function assembleCompoundComponent(root, subComponents) {
|
|
16
|
+
if (!subComponents) return root;
|
|
17
|
+
return Object.assign(root, subComponents);
|
|
18
|
+
}
|
|
19
|
+
|
|
6
20
|
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
7
21
|
function makeResolveTag(defaultTag) {
|
|
8
22
|
return function tag(as) {
|
|
@@ -45,10 +59,13 @@ function isString(value) {
|
|
|
45
59
|
function isNumber(value) {
|
|
46
60
|
return typeof value === "number";
|
|
47
61
|
}
|
|
62
|
+
function isFunction(value) {
|
|
63
|
+
return typeof value === "function";
|
|
64
|
+
}
|
|
48
65
|
|
|
49
66
|
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
50
67
|
function isDynamicRule(rule) {
|
|
51
|
-
return isObject(rule, true) && rule
|
|
68
|
+
return isObject(rule, true) && Reflect.get(rule, RULE_BRAND) === true;
|
|
52
69
|
}
|
|
53
70
|
|
|
54
71
|
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
@@ -587,17 +604,17 @@ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default
|
|
|
587
604
|
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
588
605
|
function getAsProp(child) {
|
|
589
606
|
if (!isObject(child) || !("props" in child)) return void 0;
|
|
590
|
-
const props = child
|
|
607
|
+
const { props } = child;
|
|
591
608
|
if (!isObject(props)) return void 0;
|
|
592
|
-
const as = props
|
|
609
|
+
const as = Reflect.get(props, "as");
|
|
593
610
|
return isString(as) && as !== "" ? as : void 0;
|
|
594
611
|
}
|
|
595
612
|
function getTag(child) {
|
|
596
613
|
if (!isObject(child) || !("type" in child)) return void 0;
|
|
597
|
-
const t = child
|
|
614
|
+
const { type: t } = child;
|
|
598
615
|
if (isString(t)) return t;
|
|
599
616
|
if (typeof t === "function" || isObject(t)) {
|
|
600
|
-
const defaultTag = t
|
|
617
|
+
const defaultTag = Reflect.get(t, COMPONENT_DEFAULT_TAG);
|
|
601
618
|
if (!isString(defaultTag)) return void 0;
|
|
602
619
|
return getAsProp(child) ?? defaultTag;
|
|
603
620
|
}
|
|
@@ -617,6 +634,28 @@ function isTag(...args) {
|
|
|
617
634
|
return tag !== void 0 && set2.has(tag);
|
|
618
635
|
}
|
|
619
636
|
|
|
637
|
+
// ../../lib/adapter-utils/src/runtime/is-factory-options-like.ts
|
|
638
|
+
var FACTORY_OPTIONS_FIELD_VALIDATORS = {
|
|
639
|
+
tag: (v) => v === void 0 || isString(v),
|
|
640
|
+
name: (v) => v === void 0 || isString(v),
|
|
641
|
+
defaults: (v) => v === void 0 || isObject(v),
|
|
642
|
+
normalize: (v) => v === void 0 || isFunction(v),
|
|
643
|
+
styling: (v) => v === void 0 || isObject(v),
|
|
644
|
+
enforcement: (v) => v === void 0 || isObject(v),
|
|
645
|
+
diagnostics: (v) => v === void 0 || isObject(v),
|
|
646
|
+
subComponents: (v) => v === void 0 || isObject(v),
|
|
647
|
+
onElement: (v) => v === void 0 || isFunction(v)
|
|
648
|
+
};
|
|
649
|
+
function isFactoryOptionsLike(options, extraFieldValidators) {
|
|
650
|
+
if (!isObject(options)) return false;
|
|
651
|
+
const validators = { ...FACTORY_OPTIONS_FIELD_VALIDATORS, ...extraFieldValidators };
|
|
652
|
+
for (const [key, value] of Object.entries(options)) {
|
|
653
|
+
const validate = validators[key];
|
|
654
|
+
if (!validate || !validate(value)) return false;
|
|
655
|
+
}
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
|
|
620
659
|
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
621
660
|
function getImplicitRole(tag, props) {
|
|
622
661
|
if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
|
|
@@ -2721,7 +2760,7 @@ function getChildProp(child, key) {
|
|
|
2721
2760
|
if (!isVNodeLike(child)) return void 0;
|
|
2722
2761
|
const { props } = child;
|
|
2723
2762
|
if (!isObject(props)) return void 0;
|
|
2724
|
-
return props
|
|
2763
|
+
return Reflect.get(props, key);
|
|
2725
2764
|
}
|
|
2726
2765
|
|
|
2727
2766
|
// ../core/src/html/contracts/aria/landmarks.ts
|
|
@@ -3526,6 +3565,14 @@ function buildRuntime(options) {
|
|
|
3526
3565
|
};
|
|
3527
3566
|
}
|
|
3528
3567
|
|
|
3568
|
+
// ../../adapters/web/src/is-web-contract-component.ts
|
|
3569
|
+
function isWebContractComponent(value) {
|
|
3570
|
+
if (!isFunction(value)) return false;
|
|
3571
|
+
if (typeof HTMLElement !== "undefined" && !(value.prototype instanceof HTMLElement)) return false;
|
|
3572
|
+
if (!("diagnostics" in value)) return false;
|
|
3573
|
+
return isObject(value.diagnostics);
|
|
3574
|
+
}
|
|
3575
|
+
|
|
3529
3576
|
// ../../adapters/web/src/render-to-string.ts
|
|
3530
3577
|
var ssrRegistry = /* @__PURE__ */ new WeakMap();
|
|
3531
3578
|
function registerForSsr(cls, bundle) {
|
|
@@ -3542,8 +3589,17 @@ function renderToString(component, props = {}, innerHTML = "") {
|
|
|
3542
3589
|
return renderBundleToString(entry.bundle, props, innerHTML);
|
|
3543
3590
|
}
|
|
3544
3591
|
|
|
3592
|
+
// ../../adapters/web/src/to-web-factory-options.ts
|
|
3593
|
+
var WEB_FIELD_VALIDATORS = {
|
|
3594
|
+
filterProps: (v) => v === void 0 || isFunction(v)
|
|
3595
|
+
};
|
|
3596
|
+
function isWebFactoryOptions(options) {
|
|
3597
|
+
return isFactoryOptionsLike(options, WEB_FIELD_VALIDATORS);
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3545
3600
|
// ../../adapters/web/src/create-contract-component.ts
|
|
3546
3601
|
function createContractComponent(options) {
|
|
3602
|
+
invariant(isWebFactoryOptions(options), "options is not a valid WebFactoryOptions object");
|
|
3547
3603
|
const bundle = buildRuntime(options);
|
|
3548
3604
|
const looseBundle = toLooseBundle(bundle);
|
|
3549
3605
|
const variantKeys = options.styling?.variants ? Object.keys(options.styling.variants) : [];
|
|
@@ -3557,8 +3613,20 @@ function createContractComponent(options) {
|
|
|
3557
3613
|
static get observedAttributes() {
|
|
3558
3614
|
return observedAttrNames;
|
|
3559
3615
|
}
|
|
3616
|
+
// Tag registered by the consumer's own customElements.define() call is never literally
|
|
3617
|
+
// `dialog` (custom-element names must be hyphenated), so native `<dialog>`-specific methods
|
|
3618
|
+
// like showModal() won't exist on this class unless the consumer opts into "customized
|
|
3619
|
+
// built-ins" (`{ extends: 'dialog' }`) themselves — not something this adapter special-cases.
|
|
3620
|
+
_onElementCleanup;
|
|
3560
3621
|
connectedCallback() {
|
|
3561
3622
|
this._applyPraxis();
|
|
3623
|
+
if (options.onElement) {
|
|
3624
|
+
this._onElementCleanup = options.onElement(this, () => this._buildProps()) ?? void 0;
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
disconnectedCallback() {
|
|
3628
|
+
this._onElementCleanup?.();
|
|
3629
|
+
this._onElementCleanup = void 0;
|
|
3562
3630
|
}
|
|
3563
3631
|
// Fires synchronously for every observed attribute change — no microtask
|
|
3564
3632
|
// scheduling needed. The guard is implicit: this only fires for
|
|
@@ -3575,12 +3643,11 @@ function createContractComponent(options) {
|
|
|
3575
3643
|
get _self() {
|
|
3576
3644
|
return this;
|
|
3577
3645
|
}
|
|
3578
|
-
_applyPraxis
|
|
3646
|
+
// Shared by _applyPraxis and the onElement getProps accessor — both need the same
|
|
3647
|
+
// attribute-derived prop snapshot, just for different purposes (pipeline input vs.
|
|
3648
|
+
// exposing "current props" to author-supplied element wiring).
|
|
3649
|
+
_buildProps() {
|
|
3579
3650
|
const self = this._self;
|
|
3580
|
-
const {
|
|
3581
|
-
childrenEvaluator,
|
|
3582
|
-
runtime: { options: options2 }
|
|
3583
|
-
} = bundle;
|
|
3584
3651
|
const observedSet = new Set(
|
|
3585
3652
|
this.constructor.observedAttributes ?? []
|
|
3586
3653
|
);
|
|
@@ -3596,6 +3663,14 @@ function createContractComponent(options) {
|
|
|
3596
3663
|
const val = self[key] ?? this.getAttribute(key);
|
|
3597
3664
|
if (val != null) props[key] = val;
|
|
3598
3665
|
}
|
|
3666
|
+
return props;
|
|
3667
|
+
}
|
|
3668
|
+
_applyPraxis() {
|
|
3669
|
+
const {
|
|
3670
|
+
childrenEvaluator,
|
|
3671
|
+
runtime: { options: options2 }
|
|
3672
|
+
} = bundle;
|
|
3673
|
+
const props = this._buildProps();
|
|
3599
3674
|
const hostState = resolveHostState(looseBundle, props);
|
|
3600
3675
|
const children = Array.from(this.childNodes);
|
|
3601
3676
|
if (childrenEvaluator) {
|
|
@@ -3612,8 +3687,14 @@ function createContractComponent(options) {
|
|
|
3612
3687
|
Object.defineProperty(PolymorphicWebElement, "name", { value: options.name });
|
|
3613
3688
|
}
|
|
3614
3689
|
Object.defineProperty(PolymorphicWebElement, "diagnostics", { value: bundle.diagnostics });
|
|
3615
|
-
|
|
3616
|
-
|
|
3690
|
+
const contractClass = PolymorphicWebElement;
|
|
3691
|
+
invariant(
|
|
3692
|
+
isWebContractComponent(contractClass),
|
|
3693
|
+
"Generated class failed to satisfy the WebContractComponent shape"
|
|
3694
|
+
);
|
|
3695
|
+
registerForSsr(contractClass, looseBundle);
|
|
3696
|
+
const assembled = assembleCompoundComponent(contractClass, options.subComponents);
|
|
3697
|
+
return assembled;
|
|
3617
3698
|
}
|
|
3618
3699
|
export {
|
|
3619
3700
|
createContractComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praxis-kit",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./react": {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
188
188
|
"esbuild": "^0.28.1",
|
|
189
189
|
"esbuild-plugin-solid": "^0.6.0",
|
|
190
|
-
"@types/node": "^26.1.
|
|
190
|
+
"@types/node": "^26.1.2",
|
|
191
191
|
"@types/react": "^19.2.17",
|
|
192
192
|
"@types/react-dom": "^19.0.0",
|
|
193
193
|
"@typescript-eslint/utils": "8.65.0",
|
|
@@ -204,10 +204,10 @@
|
|
|
204
204
|
"vite": "^8.1.5",
|
|
205
205
|
"vue": "^3.5.40",
|
|
206
206
|
"@praxis-kit/adapter-utils": "0.0.0",
|
|
207
|
-
"@praxis-kit/diagnostics": "0.0.0",
|
|
208
207
|
"@praxis-kit/core": "0.0.0",
|
|
209
|
-
"@praxis-kit/pipeline": "0.0.0",
|
|
210
208
|
"@praxis-kit/primitive": "0.0.0",
|
|
209
|
+
"@praxis-kit/pipeline": "0.0.0",
|
|
210
|
+
"@praxis-kit/diagnostics": "0.0.0",
|
|
211
211
|
"@praxis-kit/vite-plugin": "0.0.0"
|
|
212
212
|
},
|
|
213
213
|
"publishConfig": {
|