@jxsuite/runtime 6.2.2 → 7.0.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/src/types.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  /// <reference lib="dom" />
2
- import type { JxDocument, JxDocumentValue, JxElement, JxPath } from "@jxsuite/schema/types";
2
+ import type {
3
+ JxDocument,
4
+ JxDocumentValue,
5
+ JxElement,
6
+ JxMappedArray,
7
+ JxPath,
8
+ } from "@jxsuite/schema/types";
3
9
  import type { Ref } from "@vue/reactivity";
4
10
 
5
11
  export type { JxPath } from "@jxsuite/schema/types";
@@ -146,6 +152,24 @@ export interface JxMountOptions<S = JxScope> {
146
152
  signal?: AbortSignal;
147
153
  onNodeCreated?: JxRenderOptions["onNodeCreated"];
148
154
  onNodeMoved?: JxRenderOptions["onNodeMoved"];
155
+ /** Authoring hook, off by default: see {@link JxRenderOptions.rowLimit}. */
156
+ rowLimit?: JxRenderOptions["rowLimit"];
157
+ /** Authoring hook, off by default: see {@link JxRenderOptions.emptyRow}. */
158
+ emptyRow?: JxRenderOptions["emptyRow"];
159
+ /** Authoring hook, off by default: see {@link JxRenderOptions.onListReconciled}. */
160
+ onListReconciled?: JxRenderOptions["onListReconciled"];
161
+ }
162
+
163
+ /** What one reconciliation of a mapped array drew: see {@link JxRenderOptions.onListReconciled}. */
164
+ export interface JxListReconciliation {
165
+ /** How many items the list resolved to, after `filter` and `sort` and before any `rowLimit`. */
166
+ count: number;
167
+ /** How many rows stand in the DOM, the `emptyRow` placeholder included. */
168
+ rendered: number;
169
+ /** Whether the list resolved to no items (so a row that is drawn is the `emptyRow` one). */
170
+ empty: boolean;
171
+ /** The root node of each row that stands in the DOM, in order: `rendered` of them. */
172
+ nodes: readonly (HTMLElement | Text)[];
149
173
  }
150
174
 
151
175
  /** A mounted document: its live scope, its root node, and the disposer that tears it down. */
@@ -182,8 +206,15 @@ export interface JxRenderOptions {
182
206
  /** The namespace the parent element established — SVG and MathML descendants inherit it. */
183
207
  _ns?: string | null;
184
208
  /**
185
- * Called for each created node. `state` is the local scope the node's children render with —
186
- * callers can capture it to re-render a subtree in isolation later.
209
+ * Called for each created ELEMENT (a text node is not reported). `state` is the local scope the
210
+ * node's children render with — callers can capture it to re-render a subtree in isolation
211
+ * later.
212
+ *
213
+ * `path` is the node's document path, with two exceptions that name something the document does
214
+ * not hold as a node. A mapped row is at `[…array, "map", index]`. A node a template splices in
215
+ * (spec.md §8.4) is at the template's own position followed by its index in the resolved array:
216
+ * `[…, "children", j]` for a whole-`children` template, `[…, "children", i, j]` for a templated
217
+ * string member at `children[i]`; its `def` is the resolved value, not a member of the document.
187
218
  */
188
219
  onNodeCreated?: (
189
220
  el: HTMLElement | Text,
@@ -195,8 +226,32 @@ export interface JxRenderOptions {
195
226
  * Called when a keyed mapped-array row is reused at a new index. The node is the same one
196
227
  * `onNodeCreated` reported; `path` is its new document path, so a host that stamped the old one
197
228
  * can re-stamp it.
229
+ *
230
+ * Only the row's ROOT is reported. Every descendant's path changed with it (each begins with the
231
+ * row's), and none of them is reported: a host that stamped the subtree rewrites that prefix
232
+ * itself.
198
233
  */
199
234
  onNodeMoved?: (node: HTMLElement | Text, path: JxPath) => void;
235
+ /**
236
+ * Authoring hook, off by default: the most rows any one mapped array draws. Items past it are not
237
+ * rendered at all (no node, no scope, no effects). A value that is not a number of zero or more
238
+ * is ignored; a fraction is floored. It applies to every list this render reaches, nested ones
239
+ * included, and after `emptyRow`, so a limit of zero draws nothing.
240
+ */
241
+ rowLimit?: number;
242
+ /**
243
+ * Authoring hook, off by default: called when a mapped array that has a `map` resolves to no
244
+ * items (an empty array, or `items` that is not an array yet). Returning anything but `undefined`
245
+ * draws ONE row with that value as its `$map.item` at index 0, so an editor has a row to show and
246
+ * select; returning `undefined` draws nothing, as without the hook. `path` is the array's own
247
+ * document path. The row is replaced by real rows as soon as the list has any.
248
+ */
249
+ emptyRow?: (arrayDef: JxMappedArray, path: JxPath) => JxScopeValue;
250
+ /**
251
+ * Authoring hook, off by default: called after each reconciliation of a mapped array, the first
252
+ * render included, with the array's own document path.
253
+ */
254
+ onListReconciled?: (path: JxPath, result: JxListReconciliation) => void;
200
255
  }
201
256
 
202
257
  /**