@yahoo/uds-create-config 5.68.3 → 5.68.5

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.
@@ -496,7 +496,20 @@ type AsInput = ElementType | string;
496
496
  */
497
497
  type UnionToIntersection<U> = (U extends unknown ? (member: U) => void : never) extends ((member: infer I) => void) ? I : never;
498
498
  /** One element's contribution, a union of tags folded into one object type. */
499
- type ElementSurface<Element> = UnionToIntersection<ElementPropsOf<Element>>;
499
+ type ElementSurface<Element> = UnionToIntersection<SurfacePropsOf<Element>>;
500
+ /**
501
+ * {@link ElementPropsOf} as a surface takes it, beside the system's tail: a component's props less the
502
+ * style props and modifiers it takes from that tail unchanged, which are the ones it neither declares
503
+ * nor redefines in its render extra. The surface intersects the tail anyway, so each of those has the
504
+ * same type and modifiers either way, and it isn't declared twice in every component's props.
505
+ */
506
+ type SurfacePropsOf<Element> = Element extends keyof JSX.IntrinsicElements ? ElementPropsOf<Element> : Element extends ((props: infer PropsOfComponent) => unknown) ? Element extends {
507
+ metadata(meta: never): infer Builder;
508
+ } ? Builder extends ComponentBuilder<infer _L extends LayerMap, infer P extends PropMap, infer E, infer _D, infer _F extends string, infer _S extends StateMap> ? DeclaredExcept<PropsOfComponent, Exclude<keyof SystemTail, RedeclaredKeys<P, E>>> : Declared<PropsOfComponent> : Declared<PropsOfComponent> : Element extends {
509
+ readonly __ref: `component:${infer Path}`;
510
+ } ? Path extends keyof RegisteredComponentHandles ? SurfacePropsOf<RegisteredComponentHandles[Path]> : Record<never, never> : Record<never, never>;
511
+ /** {@link Declared}, less the keys in `K`. */
512
+ type DeclaredExcept<T, K> = { [Key in keyof T as string extends Key ? never : number extends Key ? never : Key extends K ? never : Key]: T[Key] };
500
513
  /**
501
514
  * What the root layer contributes to the surface.
502
515
  *
@@ -507,7 +520,7 @@ type ElementSurface<Element> = UnionToIntersection<ElementPropsOf<Element>>;
507
520
  * than intersected, or a handler is typed against both elements when only one renders. A style
508
521
  * prop the root declares is not an element key (see {@link ElementPropsOf}), so it survives the swap.
509
522
  */
510
- type RootSurface<L extends LayerMap, D, As> = [RenderedElementOf<L, D, As>] extends [L['root']] ? ElementSurface<L['root']> : Without<ElementSurface<L['root']>, keyof ElementSurface<RenderedElementOf<L, D, As>>> & ElementSurface<RenderedElementOf<L, D, As>>;
523
+ type RootSurface<L extends LayerMap, D, As> = [RenderedElementOf<L, D, As>] extends [L['root']] ? ElementSurface<L['root']> : Without<ElementSurface<L['root']>, keyof UnionToIntersection<ElementPropsOf<RenderedElementOf<L, D, As>>>> & ElementSurface<RenderedElementOf<L, D, As>>;
511
524
  /**
512
525
  * The element one call renders: what its `as` names, else what the component fixes.
513
526
  *
@@ -564,8 +577,12 @@ type LayerProps<L extends LayerMap> = {
564
577
  *
565
578
  * Open before the build: which names are style props is the system's to say, and until its emitted
566
579
  * types say it, anything may be one.
580
+ *
581
+ * The style props and modifiers are one type for the whole system, kept apart from the layer channel,
582
+ * so a component that declares none of their names takes that type as it is.
567
583
  */
568
- type OpenTail<L extends LayerMap> = Registered extends true ? StyleProps & ModifierProps & LayerProps<L> : Record<string, unknown>;
584
+ type OpenTail<L extends LayerMap, P, E> = Registered extends true ? Shadowed<SystemTail, RedeclaredKeys<P, E>> & Redeclared<LayerProps<L>, P, E> : Redeclared<Record<string, unknown>, P, E>;
585
+ type SystemTail = StyleProps & ModifierProps;
569
586
  /**
570
587
  * The props a consumer may pass — the declared ones, the rendered element's, and the style props.
571
588
  *
@@ -579,15 +596,21 @@ type OpenTail<L extends LayerMap> = Registered extends true ? StyleProps & Modif
579
596
  *
580
597
  * Ends in {@link OpenTail}: the system's own surface, open until the system's build has named it.
581
598
  */
582
- type ComponentPropsOf<L extends LayerMap, P extends PropMap, D = Record<never, never>, E = Record<never, never>, F extends string = never, As = never> = ConsumerDeclaredProps<P, D, E, L, ComponentBuilder<L, P, E, D, F>> & Partial<E> & Redeclared<RootSurface<L, D, As>, P, E> & Redeclared<ForwardedPropsOf<L, F>, P, E> & AsPropsOf<As, P, E> & Redeclared<OpenTail<L>, P, E>;
599
+ type ComponentPropsOf<L extends LayerMap, P extends PropMap, D = Record<never, never>, E = Record<never, never>, F extends string = never, As = never> = ConsumerDeclaredProps<P, D, E, L, ComponentBuilder<L, P, E, D, F>> & Partial<E> & Redeclared<RootSurface<L, D, As>, P, E> & Shadowed<ForwardedPropsOf<L, F>, RedeclaredKeys<P, E>> & AsPropsOf<As, P, E> & OpenTail<L, P, E>;
583
600
  /**
584
601
  * `T` less the keys the component declares and the keys its render extra names. {@link Without} leaves
585
602
  * `T` whole when its key set is open, so an open set of either kind is left out of the union rather
586
603
  * than opening it: an open render extra (`extends Record<string, unknown>`) must not stop the declared
587
- * props from shadowing. Both sets come out in one mapped type, since this runs once per component over
588
- * every style prop and modifier the system registers.
604
+ * props from shadowing.
605
+ */
606
+ type Redeclared<T, P, E> = Without<T, RedeclaredKeys<P, E>>;
607
+ type RedeclaredKeys<P, E> = string extends Redefined<E> ? keyof P : string extends keyof P ? Redefined<E> : keyof P | Redefined<E>;
608
+ /**
609
+ * `T` without the keys in `K` it has, and `T` itself when it has none of them. The system's tail is one
610
+ * type every component shares, and a mapped copy per component would cost the size of that type
611
+ * rather than the size of what the component declares.
589
612
  */
590
- type Redeclared<T, P, E> = string extends Redefined<E> ? Without<T, keyof P> : string extends keyof P ? Without<T, Redefined<E>> : Without<T, keyof P | Redefined<E>>;
613
+ type Shadowed<T, K extends PropertyKey> = [Extract<K, keyof T>] extends [never] ? T : Without<T, Extract<K, keyof T>>;
591
614
  /**
592
615
  * The phantom call signature's parameter. `As` is inferred from `as` alone; the rest of the surface
593
616
  * is `NoInfer`, so inference never walks it. Open to inference, a spread of
@@ -663,7 +686,7 @@ type AttributeNames = Exclude<keyof AllHTMLAttributes<HTMLElement>, 'as' | keyof
663
686
  * accept `HTMLDivElement | HTMLInputElement` instead of the input it actually receives.
664
687
  */
665
688
  type NonRootForward<L extends LayerMap, F extends string> = Exclude<F, 'root'> & keyof L;
666
- type ForwardedPropsOf<L extends LayerMap, F extends string> = [NonRootForward<L, F>] extends [never] ? Record<never, never> : Partial<ElementPropsOf<L[NonRootForward<L, F>]>>;
689
+ type ForwardedPropsOf<L extends LayerMap, F extends string> = [NonRootForward<L, F>] extends [never] ? Record<never, never> : Partial<SurfacePropsOf<L[NonRootForward<L, F>]>>;
667
690
  /**
668
691
  * Defaults a component applies with nothing set — its declared props, typed, plus the style props it
669
692
  * may also default.