@yahoo/uds-create-config 5.68.2 → 5.68.3
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.
|
@@ -15,8 +15,8 @@ declare const DocumentationDefinition: EntityClass<z.ZodObject<{
|
|
|
15
15
|
uds: "uds";
|
|
16
16
|
}>>;
|
|
17
17
|
platform: z.ZodOptional<z.ZodEnum<{
|
|
18
|
-
mobile: "mobile";
|
|
19
18
|
web: "web";
|
|
19
|
+
mobile: "mobile";
|
|
20
20
|
}>>;
|
|
21
21
|
}, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "documentation", {
|
|
22
22
|
readonly search: {
|
|
@@ -14,9 +14,8 @@ import { AllHTMLAttributes, ComponentPropsWithRef, ComponentType, ElementType, J
|
|
|
14
14
|
* Enough of another component to BE a layer's element — the handle `defineComponent` returns, with
|
|
15
15
|
* its declarations forgotten so a builder of any shape fits.
|
|
16
16
|
*
|
|
17
|
-
* Named separately from `AuthoredComponent
|
|
18
|
-
*
|
|
19
|
-
* from. `ComponentBuilder<{root:'button'}, …>` satisfies this; it does not satisfy `AuthoredComponent`.
|
|
17
|
+
* Named separately from `AuthoredComponent`, which is what a registry holds; a layer only needs to know
|
|
18
|
+
* the value is a component, and keeps the referenced component's own type for its props.
|
|
20
19
|
*/
|
|
21
20
|
interface ComponentElement extends Authored {
|
|
22
21
|
readonly kind: 'component';
|
|
@@ -582,11 +581,13 @@ type OpenTail<L extends LayerMap> = Registered extends true ? StyleProps & Modif
|
|
|
582
581
|
*/
|
|
583
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>;
|
|
584
583
|
/**
|
|
585
|
-
* `T` less the keys the component declares and the keys its render extra names
|
|
586
|
-
*
|
|
587
|
-
* extra (`extends Record<string, unknown>`) must not stop the declared
|
|
584
|
+
* `T` less the keys the component declares and the keys its render extra names. {@link Without} leaves
|
|
585
|
+
* `T` whole when its key set is open, so an open set of either kind is left out of the union rather
|
|
586
|
+
* 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.
|
|
588
589
|
*/
|
|
589
|
-
type Redeclared<T, P, E> = Without<Without<T, keyof P
|
|
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>>;
|
|
590
591
|
/**
|
|
591
592
|
* The phantom call signature's parameter. `As` is inferred from `as` alone; the rest of the surface
|
|
592
593
|
* is `NoInfer`, so inference never walks it. Open to inference, a spread of
|
|
@@ -642,7 +643,13 @@ type IntrinsicAttributeNames<As> = As extends keyof JSX.IntrinsicElements ? keyo
|
|
|
642
643
|
* there is no telling a stray attribute from a style prop, and an unbuilt consumer compiles the way
|
|
643
644
|
* the registry promises.
|
|
644
645
|
*/
|
|
645
|
-
type ForeignAttributesOf<As, P, E> = Registered extends false ? Record<never, never> : [As] extends [keyof JSX.IntrinsicElements] ? { [K in Exclude<
|
|
646
|
+
type ForeignAttributesOf<As, P, E> = Registered extends false ? Record<never, never> : [As] extends [keyof JSX.IntrinsicElements] ? { [K in Exclude<AttributeNames, IntrinsicAttributeNames<As> | keyof P | keyof E>]?: never } : Record<never, never>;
|
|
647
|
+
/**
|
|
648
|
+
* The HTML attribute names less `as` and the registered style props, which are the same for every
|
|
649
|
+
* component. A single `Exclude` over this concrete union takes out the rest: one over a deferred
|
|
650
|
+
* `Exclude<…, IntrinsicAttributeNames<As>>` would build an intersection per name while `As` is generic.
|
|
651
|
+
*/
|
|
652
|
+
type AttributeNames = Exclude<keyof AllHTMLAttributes<HTMLElement>, 'as' | keyof RegisteredStyleProps>;
|
|
646
653
|
/**
|
|
647
654
|
* The props a component picks up from the layers it FORWARDS.
|
|
648
655
|
*
|
|
@@ -753,19 +760,24 @@ type WhenAny<K, T> = [K] extends [never] ? unknown : T;
|
|
|
753
760
|
* with `P` in full as its type argument.
|
|
754
761
|
*/
|
|
755
762
|
type CompactProps<P extends PropMap> = [StyleRefKeys<P> | StyleRefPropKeys<P>] extends [never] ? P : { [K in keyof P as K extends StyleRefKeys<P> | StyleRefPropKeys<P> ? never : K]: P[K] } & WhenAny<StyleRefKeys<P>, StyleRefs<StyleRefKeys<P> & string>> & WhenAny<StyleRefPropKeys<P>, StyleRefProps<StyleRefPropKeys<P> & string>>;
|
|
756
|
-
|
|
763
|
+
/**
|
|
764
|
+
* Every type parameter is declared `in out`. Measured instead, TypeScript relates two instantiations
|
|
765
|
+
* with `P` generic, which crosses every registered style prop and modifier name with every other, and
|
|
766
|
+
* past 316 of them that is over its 100,000-member union limit (TS2590).
|
|
767
|
+
*/
|
|
768
|
+
interface ComponentBuilder<in out L extends LayerMap, in out P extends PropMap,
|
|
757
769
|
/** Props the RENDER takes that the config doesn't describe — React handlers, mostly (`onPress`).
|
|
758
770
|
* They're part of the component's surface but not of its data, which is why they're declared at
|
|
759
771
|
* `.render()` rather than in `.props()`. */
|
|
760
|
-
E = Record<never, never>,
|
|
772
|
+
in out E = Record<never, never>,
|
|
761
773
|
/** The defaults as AUTHORED, kept because one of them decides the type of every other prop: an
|
|
762
774
|
* `as` fixes which element this renders. See {@link ElementOf}. */
|
|
763
|
-
D = Record<never, never>,
|
|
775
|
+
in out D = Record<never, never>,
|
|
764
776
|
/** The layers this component FORWARDS from, as a union of their names. Accumulates through
|
|
765
777
|
* `.forwards()` so `ComponentPropsOf` can union each forwarded layer's element props — `root` is
|
|
766
778
|
* already covered structurally by {@link ElementOf}, so for a root-only forward this changes no
|
|
767
779
|
* inferred type, which is what makes replacing `inherits` a no-op at every call site. */
|
|
768
|
-
F extends string = never, /** The states `.states()` declared — what the render knows and reports, never a caller's prop. */S extends StateMap = Record<never, never>> extends Authored {
|
|
780
|
+
in out F extends string = never, /** The states `.states()` declared — what the render knows and reports, never a caller's prop. */in out S extends StateMap = Record<never, never>> extends Authored {
|
|
769
781
|
/**
|
|
770
782
|
* The phantom call signature — the authored value is never rendered (the build substitutes the
|
|
771
783
|
* emitted module), but a call site is checked against it. Generic over the element a call site
|
|
@@ -884,8 +896,19 @@ F extends string = never, /** The states `.states()` declared — what the rende
|
|
|
884
896
|
toStored(): Record<string, unknown>;
|
|
885
897
|
assignPath(path: string): void;
|
|
886
898
|
}
|
|
887
|
-
/**
|
|
888
|
-
|
|
899
|
+
/**
|
|
900
|
+
* A component under authorship, with its declarations forgotten — what a registry holds. It names only
|
|
901
|
+
* the members every builder has with the same type, so a builder of any shape is assignable to it.
|
|
902
|
+
*/
|
|
903
|
+
interface AuthoredComponent extends Authored {
|
|
904
|
+
readonly kind: 'component';
|
|
905
|
+
readonly body: Record<string, unknown>;
|
|
906
|
+
readonly path?: string;
|
|
907
|
+
toStored(): Record<string, unknown>;
|
|
908
|
+
assignPath(path: string): void;
|
|
909
|
+
}
|
|
910
|
+
/** What the whole-body form returns: a builder whose declarations are all at their widest. */
|
|
911
|
+
type WidestComponentBuilder = ComponentBuilder<LayerMap, PropMap, unknown, unknown>;
|
|
889
912
|
/**
|
|
890
913
|
* A linked component's handle as the system that links it holds it. The build emits one for each
|
|
891
914
|
* linked component the link changes, and the system's linked alias resolves to it first (UDS-4611).
|
|
@@ -931,7 +954,7 @@ interface DefineComponent {
|
|
|
931
954
|
root: El;
|
|
932
955
|
}, Record<never, never>>;
|
|
933
956
|
/** The whole body at once, for a component with nothing to narrow step by step. */
|
|
934
|
-
(body?: ComponentSourceInput<Record<string, unknown>>):
|
|
957
|
+
(body?: ComponentSourceInput<Record<string, unknown>>): WidestComponentBuilder;
|
|
935
958
|
layers<const L extends LayerMap>(layers: L): ComponentBuilder<L, Record<never, never>>;
|
|
936
959
|
props: typeof definePropsFirst;
|
|
937
960
|
}
|
|
@@ -402,24 +402,6 @@ function toStored(body) {
|
|
|
402
402
|
styles: storedStyleRules(rules)
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Author a component.
|
|
407
|
-
*
|
|
408
|
-
* Callable for the case with nothing to narrow — `defineComponent({ layers: { root: 'div' } })` — and
|
|
409
|
-
* chainable for every other, since a chain is what lets each step's types come from the last.
|
|
410
|
-
*/
|
|
411
|
-
/**
|
|
412
|
-
* Author a component.
|
|
413
|
-
*
|
|
414
|
-
* Called with an ELEMENT — `defineComponent('input')`, `defineComponent(Component.ref('Box'))` — that
|
|
415
|
-
* element becomes the root layer, because a component with one layer IS that element and saying so
|
|
416
|
-
* twice adds nothing. It's also what makes the element's props type correctly: v1 expressed this as a
|
|
417
|
-
* `defaultProps: { as: 'input' }` on a `div`-rooted component, which left the config claiming the
|
|
418
|
-
* element was a `div` while every call site treated it as an input.
|
|
419
|
-
*
|
|
420
|
-
* The render follows from it too — one layer needs no anatomy, so the build generates the element
|
|
421
|
-
* rather than reading a `.render()` that would only restate the layer.
|
|
422
|
-
*/
|
|
423
405
|
function defineComponentImpl(bodyOrElement) {
|
|
424
406
|
if (isComponentElement(bodyOrElement)) return build({ layers: { root: bodyOrElement } });
|
|
425
407
|
if (typeof bodyOrElement === "function" || isRef(bodyOrElement) && kindOf(bodyOrElement) === "package") throw new Error("[uds] defineComponent(<package export>): a package export cannot be a component's only layer yet — the generated one-layer render emits web elements. Declare `layers` and a `.render()` instead.");
|