praxis-kit 6.5.0 → 6.6.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.
@@ -250,6 +250,16 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
250
250
  */
251
251
  readonly diagnostics?: Diagnostics | DiagnosticsMode;
252
252
  readonly aria?: readonly AriaRule[];
253
+ /**
254
+ * Rules that need `AriaPolicyEngine`'s fix-application/caching machinery
255
+ * (`AriaRule`'s `readsProps`, fixable `AriaFix` results) but have no
256
+ * relationship to ARIA semantics — an HTML fact or a security check like a
257
+ * dangerous-URL-scheme guard, for example. Evaluated together with `aria`
258
+ * (both run through the same engine, merged into one rule set) — this is a
259
+ * separate bucket purely so a non-ARIA rule doesn't have to sit under the
260
+ * misleading `aria` name to get the machinery it needs.
261
+ */
262
+ readonly rules?: readonly AriaRule[];
253
263
  readonly children?: readonly ChildRuleInput[];
254
264
  /**
255
265
  * When true, only children matching a `children` rule (or text, per `allowText`)
@@ -339,25 +349,27 @@ type SlotComponent = ComponentType<UnknownProps>;
339
349
  type RenderCallbackProps = Readonly<AnyRecord>;
340
350
 
341
351
  /**
342
- * Maps a polymorphic element type to the instance type exposed through `ref`.
352
+ * Resolves the instance type exposed through `ref` for a polymorphic
353
+ * element.
343
354
  *
344
- * Intrinsic HTML elements resolve to their corresponding DOM element type;
345
- * custom React components currently fall back to `unknown`.
355
+ * Intrinsic HTML elements map to their corresponding DOM element type;
356
+ * custom React components currently resolve to `unknown`.
346
357
  */
347
358
  type ElementRef<T extends ElementType> = T extends IntrinsicTag ? HTMLElementTagNameMap[T] : unknown;
348
359
  /**
349
- * React's intrinsic JSX props for a given element.
360
+ * React's intrinsic JSX props for an element type.
350
361
  *
351
- * Custom components intentionally fall back to `UnknownProps`; the component's
352
- * own prop model defines their accepted props instead.
362
+ * Custom components intentionally resolve to `UnknownProps`; their own
363
+ * prop definitions determine the accepted props.
353
364
  */
354
365
  type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.IntrinsicElements[T] : UnknownProps;
355
366
  /**
356
- * Removes index signatures while preserving explicitly named properties.
367
+ * Removes index signatures while preserving explicitly declared
368
+ * properties.
357
369
  *
358
- * This prevents generic fallback constraints such as `Record<string, unknown>`
359
- * from collapsing `keyof T` to `string`, which would cause
360
- * `Omit<IntrinsicJSXProps<T>, keyof ...>` to remove every intrinsic prop.
370
+ * Prevents broad index signatures (for example `Record<string, unknown>`)
371
+ * from causing `keyof T` to become `string`, which would otherwise erase
372
+ * every intrinsic prop during `Omit`.
361
373
  */
362
374
  type StripIndexSignature<T> = {
363
375
  [K in keyof T as string extends K ? never : K]: T[K];
@@ -367,18 +379,16 @@ type ComponentProps<G extends PolymorphicGenerics> = StripIndexSignature<PropsOf
367
379
  /** Variant props generated from the component's variant definitions. */
368
380
  type ComponentVariants<G extends PolymorphicGenerics> = StripIndexSignature<VariantProps<VariantsOf<G>>>;
369
381
  /**
370
- * Props owned by the component itself.
382
+ * Props defined by the component itself.
371
383
  *
372
- * These take precedence over intrinsic HTML props when names overlap.
384
+ * These override intrinsic JSX props with the same name.
373
385
  */
374
386
  type OwnedProps<G extends PolymorphicGenerics> = ComponentProps<G> & ComponentVariants<G>;
375
387
  /**
376
- * Polymorphic rendering controls.
388
+ * Props that control how the component renders.
377
389
  *
378
- * These describe *how* the component renders rather than the data it owns.
379
- *
380
- * `children` and `asChild` are intentionally omitted so each render mode
381
- * can provide its own stricter contract.
390
+ * `children` and `asChild` are intentionally omitted so each render
391
+ * strategy can define its own contract.
382
392
  */
383
393
  type PolymorphicControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = {
384
394
  /**
@@ -398,22 +408,21 @@ type PolymorphicControlProps<G extends PolymorphicGenerics, TAs extends ElementT
398
408
  ref?: Ref<ElementRef<TAs>>;
399
409
  };
400
410
  /**
401
- * Complete set of props owned by the component.
411
+ * All props reserved by the polymorphic component.
402
412
  *
403
- * Used primarily as the exclusion list when inheriting intrinsic JSX props.
413
+ * Used primarily to exclude conflicting intrinsic JSX props.
404
414
  */
405
415
  type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OwnedProps<G> & PolymorphicControlProps<G, TAs>;
406
416
  /**
407
- * Intrinsic JSX props after removing every prop owned by the component.
417
+ * Intrinsic JSX props after removing every reserved component prop.
408
418
  *
409
- * Component props always win over intrinsic props with the same name.
419
+ * Component-defined props always take precedence.
410
420
  */
411
421
  type IntrinsicPropsWithoutOwned<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children'>;
412
422
  /**
413
- * Base props shared by every render mode.
423
+ * Props shared by every rendering strategy.
414
424
  *
415
- * Render modes contribute only their discriminants (`asChild`, `render`,
416
- * `children`, etc.).
425
+ * Each render mode contributes only its discriminating props.
417
426
  */
418
427
  type BaseProps<G extends PolymorphicGenerics, TAs extends ElementType> = IntrinsicPropsWithoutOwned<G, TAs> & ControlProps<G, TAs>;
419
428
  /** Standard rendering (`asChild` absent or false). */
@@ -433,12 +442,9 @@ type SlotRenderMode = {
433
442
  children: ReactElement | NonEmptyTuple<ReactElement>;
434
443
  };
435
444
  /**
436
- * Render callback.
437
- *
438
- * The callback receives fully resolved props (classes, refs, filtered props)
439
- * and is responsible for rendering the target element.
445
+ * Render callback mode.
440
446
  *
441
- * This provides the flexibility of `asChild` without `cloneElement`.
447
+ * Receives the fully resolved props and returns the rendered element.
442
448
  */
443
449
  type CallbackRenderMode = {
444
450
  render: (props: RenderCallbackProps) => ReactElement;
@@ -464,16 +470,26 @@ type PolymorphicWithRender<G extends PolymorphicGenerics, TAs extends ElementTyp
464
470
  /**
465
471
  * A polymorphic React component.
466
472
  *
467
- * Overloads form a discriminated union:
473
+ * Overloads provide three rendering strategies:
468
474
  *
469
- * `render` render callback
470
- * `asChild` Slot rendering
471
- * otherwise → normal rendering
475
+ * - `render` render callback
476
+ * - `asChild` slot rendering
477
+ * - default — standard polymorphic rendering
472
478
  */
473
479
  type PolymorphicComponent<G extends PolymorphicGenerics> = {
474
480
  <TAs extends ElementType = DefaultOf<G>>(props: PolymorphicWithRender<G, TAs>): ReactElement;
475
481
  <TAs extends ElementType = DefaultOf<G>>(props: PolymorphicWithAsChild<G, TAs>): ReactElement;
476
482
  <TAs extends ElementType = DefaultOf<G>>(props: PolymorphicProps<G, TAs>): ReactElement;
483
+ /**
484
+ * Non-generic fallback overload used for type extraction.
485
+ *
486
+ * TypeScript resolves conditional types such as
487
+ * `React.ComponentProps<typeof Component>` against only the final
488
+ * overload. Anchoring that overload to the default element preserves
489
+ * correct prop inference for tools such as Storybook and
490
+ * `React.ComponentProps`.
491
+ */
492
+ (props: PolymorphicProps<G, DefaultOf<G>>): ReactElement;
477
493
  displayName?: string;
478
494
  };
479
495
 
@@ -249,6 +249,16 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
249
249
  */
250
250
  readonly diagnostics?: Diagnostics | DiagnosticsMode;
251
251
  readonly aria?: readonly AriaRule[];
252
+ /**
253
+ * Rules that need `AriaPolicyEngine`'s fix-application/caching machinery
254
+ * (`AriaRule`'s `readsProps`, fixable `AriaFix` results) but have no
255
+ * relationship to ARIA semantics — an HTML fact or a security check like a
256
+ * dangerous-URL-scheme guard, for example. Evaluated together with `aria`
257
+ * (both run through the same engine, merged into one rule set) — this is a
258
+ * separate bucket purely so a non-ARIA rule doesn't have to sit under the
259
+ * misleading `aria` name to get the machinery it needs.
260
+ */
261
+ readonly rules?: readonly AriaRule[];
252
262
  readonly children?: readonly ChildRuleInput[];
253
263
  /**
254
264
  * When true, only children matching a `children` rule (or text, per `allowText`)
@@ -332,6 +342,15 @@ type PolymorphicProps<G extends PolymorphicGenerics, TAs extends ElementType = D
332
342
  }) | AsChildProps<G>>;
333
343
  type PolymorphicComponent<G extends PolymorphicGenerics> = {
334
344
  <TAs extends ElementType = DefaultOf<G>>(props: PolymorphicProps<G, TAs>): JSX.Element;
345
+ /**
346
+ * Non-generic fallback overload used for type extraction.
347
+ *
348
+ * TypeScript resolves conditional types such as
349
+ * `ComponentProps<typeof Component>` against only the final overload.
350
+ * Anchoring that overload to the default element preserves correct prop
351
+ * inference for tools such as Storybook and `ComponentProps`.
352
+ */
353
+ (props: PolymorphicProps<G, DefaultOf<G>>): JSX.Element;
335
354
  displayName?: string;
336
355
  };
337
356