praxis-kit 7.4.0 → 7.8.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.
@@ -47,6 +47,19 @@ type NoPluginProps = EmptyRecord;
47
47
  type IntrinsicTag = keyof HTMLElementTagNameMap;
48
48
 
49
49
  type ElementType = IntrinsicTag | (string & {});
50
+ /**
51
+ * Resolves a component's default tag to its real DOM interface — `HTMLDialogElement` for
52
+ * `'dialog'`, `HTMLDetailsElement` for `'details'`, and so on — falling back to `HTMLElement`
53
+ * for custom-element tags or anything not in `HTMLElementTagNameMap`. Used to type
54
+ * `FactoryOptions.onElement`'s `element` param so component authors get direct, correctly-typed
55
+ * access to tag-specific native members (`dialogEl.showModal()`) without an unsafe cast.
56
+ *
57
+ * The fallback is `HTMLElement`, not the more generic `Element` — every tag reachable through
58
+ * `IntrinsicTag` extends it, and so does every custom element per spec, so members `HTMLElement`
59
+ * itself declares (`showPopover()`/`hidePopover()`/`togglePopover()`, the `popover` attribute)
60
+ * stay directly accessible even for tags with no dedicated entry in `HTMLElementTagNameMap`.
61
+ */
62
+ type ElementForTag<TDefault extends ElementType> = TDefault extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TDefault] : HTMLElement;
50
63
 
51
64
  declare const KNOWN_ARIA_ROLES: readonly ["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"];
52
65
  type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
@@ -146,7 +159,7 @@ type DefaultVariants<V extends VariantMap> = {
146
159
  * Presets are named bundles of variant props that callers activate by key,
147
160
  * avoiding the need to repeat variant combinations at each call site.
148
161
  */
149
- type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
162
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<StringMap<VariantSelection<V>>>;
150
163
 
151
164
  type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
152
165
 
@@ -180,7 +193,7 @@ interface BaseClassOptions {
180
193
  type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
181
194
 
182
195
  interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
183
- recipeMap?: Record<string, RecipeTarget<TVariants>>;
196
+ recipeMap?: StringMap<RecipeTarget<TVariants>>;
184
197
  }
185
198
 
186
199
  interface TagMapOptions {
@@ -349,7 +362,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
349
362
  * combination, skipping runtime class computation entirely when a match is found. Normally
350
363
  * generated by a build-time class-extraction plugin rather than hand-authored.
351
364
  */
352
- readonly precomputedClasses?: Readonly<Record<string, string>>;
365
+ readonly precomputedClasses?: Readonly<StringMap<string>>;
353
366
  };
354
367
 
355
368
  type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
@@ -395,13 +408,23 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
395
408
  * no prop-based equivalent), not for anything expressible as a plain
396
409
  * prop.
397
410
  *
411
+ * `element` is typed to the real DOM interface of every tag the rendered
412
+ * element could actually be — `TDefault` plus whatever `enforcement.allowed`
413
+ * permits via `as` (`HTMLDialogElement` for `tag: 'dialog'`,
414
+ * `HTMLDetailsElement` for `tag: 'details'`, and so on) — no cast needed to
415
+ * reach tag-specific members. A component that leaves `allowed`
416
+ * unconstrained (any tag reachable via `as`) falls back to `HTMLElement`,
417
+ * which still covers members every element shares (`showPopover()` and
418
+ * friends); restrict `enforcement.allowed` to the tags `onElement`
419
+ * actually knows how to handle to get real narrowing.
420
+ *
398
421
  * `getProps` returns the instance's *current* resolved props at call
399
422
  * time — read it from inside a listener registered once at mount, rather
400
423
  * than re-subscribing on every prop change.
401
424
  *
402
425
  * Return a cleanup function to run when the instance unmounts.
403
426
  */
404
- readonly onElement?: (element: Element, getProps: () => Readonly<Props>) => void | (() => void);
427
+ readonly onElement?: (element: ElementForTag<TDefault | TAllowed>, getProps: () => Readonly<Props>) => void | (() => void);
405
428
  };
406
429
 
407
430
  /**