ngx-json-render 0.8.1 → 0.9.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/README.md +67 -2
- package/fesm2022/ngx-json-render.mjs +1243 -1129
- package/fesm2022/ngx-json-render.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-json-render.d.ts +39 -4
package/package.json
CHANGED
|
@@ -319,6 +319,14 @@ interface RegistryEntry {
|
|
|
319
319
|
component: Type<unknown>;
|
|
320
320
|
/** Slot names this component supports (from the catalog definition). */
|
|
321
321
|
slots?: string[];
|
|
322
|
+
/**
|
|
323
|
+
* Shown instead of `component` while the spec streams and this element's
|
|
324
|
+
* props do not yet pass its component's schema in the renderer's
|
|
325
|
+
* `catalog`. It gets the same render context, so it can read the props
|
|
326
|
+
* that have arrived and place `<jr-children />`. Without one, the element
|
|
327
|
+
* renders nothing until it is ready.
|
|
328
|
+
*/
|
|
329
|
+
fallback?: Type<unknown>;
|
|
322
330
|
}
|
|
323
331
|
/**
|
|
324
332
|
* Registry of component renderers: catalog type name → Angular component
|
|
@@ -327,10 +335,11 @@ interface RegistryEntry {
|
|
|
327
335
|
type ComponentRegistry = Record<string, Type<unknown> | RegistryEntry>;
|
|
328
336
|
/**
|
|
329
337
|
* Registry of all Angular components for a catalog. Keys are checked against
|
|
330
|
-
* the catalog's component names.
|
|
338
|
+
* the catalog's component names. A value is the component, or the component
|
|
339
|
+
* with a {@link RegistryEntry.fallback} to show while its props stream in.
|
|
331
340
|
*/
|
|
332
341
|
type Components<C extends Catalog> = {
|
|
333
|
-
[K in keyof InferCatalogComponents<C>]: Type<unknown>;
|
|
342
|
+
[K in keyof InferCatalogComponents<C>]: Type<unknown> | Pick<RegistryEntry, 'component' | 'fallback'>;
|
|
334
343
|
};
|
|
335
344
|
/**
|
|
336
345
|
* The repeat scope available to elements rendered inside a `repeat` block.
|
|
@@ -509,8 +518,14 @@ declare class JsonRenderer {
|
|
|
509
518
|
* `$bindState`, `$template`, a directive — has no value until render time,
|
|
510
519
|
* so it is not checked.
|
|
511
520
|
*
|
|
512
|
-
*
|
|
513
|
-
* skipped while `loading`.
|
|
521
|
+
* The check is read only when `validate` is on, and — like the rest of
|
|
522
|
+
* it — skipped while `loading`.
|
|
523
|
+
*
|
|
524
|
+
* While `loading`, the catalog also gates mounting, whatever `validate` is:
|
|
525
|
+
* an element whose props do not yet pass its component's schema shows its
|
|
526
|
+
* registry entry's `fallback`, or nothing, instead of a component with half
|
|
527
|
+
* its props. Once an element has mounted it stays mounted, and when
|
|
528
|
+
* `loading` ends every element mounts.
|
|
514
529
|
*/
|
|
515
530
|
readonly catalog: _angular_core.InputSignal<SpecCatalog | null>;
|
|
516
531
|
/**
|
|
@@ -700,6 +715,21 @@ declare class JrElement {
|
|
|
700
715
|
/** Two-way binding paths ($bindState / $bindItem) by prop name. */
|
|
701
716
|
readonly bindings: Signal<Record<string, string> | undefined>;
|
|
702
717
|
private readonly entry;
|
|
718
|
+
/** Set once the real component has been shown; see {@link held}. */
|
|
719
|
+
private mounted;
|
|
720
|
+
/**
|
|
721
|
+
* Whether the component waits for its props: the spec is still loading, a
|
|
722
|
+
* catalog was given, and the props written so far do not pass the
|
|
723
|
+
* component's schema (see {@link propsArrived}).
|
|
724
|
+
*
|
|
725
|
+
* One-way. Once the component has been shown it is never swapped back for
|
|
726
|
+
* the fallback, even if a later patch takes a prop away again: a component
|
|
727
|
+
* flickering out mid-stream is worse than one showing a gap. Once latched
|
|
728
|
+
* this reads no signals, so a mounted element pays nothing for the gate on
|
|
729
|
+
* later patches — and neither does any element when nothing is loading.
|
|
730
|
+
*/
|
|
731
|
+
protected readonly held: Signal<boolean>;
|
|
732
|
+
/** What the outlet shows: the component, or its fallback while held. */
|
|
703
733
|
protected readonly component: Signal<_angular_core.Type<unknown> | null>;
|
|
704
734
|
protected readonly devtoolsKey: Signal<string | null>;
|
|
705
735
|
/**
|
|
@@ -926,6 +956,11 @@ declare class JsonRenderRootContext {
|
|
|
926
956
|
* they apply whatever `validate` is set to.
|
|
927
957
|
*/
|
|
928
958
|
limits: Signal<RenderLimits | null | undefined>;
|
|
959
|
+
/**
|
|
960
|
+
* The catalog the spec was generated for. While loading, an element whose
|
|
961
|
+
* props do not pass its component's schema waits for them.
|
|
962
|
+
*/
|
|
963
|
+
catalog: Signal<SpecCatalog | null | undefined>;
|
|
929
964
|
/** External store (controlled mode). */
|
|
930
965
|
store: Signal<StateStore | null | undefined>;
|
|
931
966
|
/** Initial state (uncontrolled mode); falls back to `spec.state`. */
|