@anzusystems/common-admin 1.47.0-beta.dev-1778754002 → 1.47.0-beta.dev-1778754004

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/dist/labs.d.ts CHANGED
@@ -285,6 +285,10 @@ declare const __VLS_export_17: <TItem extends Record<string, any>>(__VLS_props:
285
285
  onEdit?: ((item: ListViewItem<TItem>) => any) | undefined;
286
286
  onAdd?: ((positionHint: PositionHint | undefined) => any) | undefined;
287
287
  "onUpdate:modelValue"?: ((value: TItem[]) => any) | undefined;
288
+ onAdded?: ((payload: {
289
+ item: TItem;
290
+ index: number;
291
+ }) => any) | undefined;
288
292
  "onItem-saved"?: ((item: ListViewItem<TItem>) => any) | undefined;
289
293
  "onItem-expand"?: ((item: ListViewItem<TItem>, expanded: boolean) => any) | undefined;
290
294
  "onUpdate:unsavedKeys"?: ((value: Set<ListEditorKey>) => any) | undefined;
@@ -317,7 +321,10 @@ declare const __VLS_export_17: <TItem extends Record<string, any>>(__VLS_props:
317
321
  'before-item'?: (props: RowSlotProps<TItem>) => unknown;
318
322
  'after-item'?: (props: RowSlotProps<TItem>) => unknown;
319
323
  };
320
- emit: (((evt: "deleted", item: ListViewItem<TItem>) => void) & ((evt: "close", item: ListViewItem<TItem>) => void) & ((evt: "edit", item: ListViewItem<TItem>) => void) & ((evt: "add", positionHint: PositionHint | undefined) => void) & ((evt: "item-saved", item: ListViewItem<TItem>) => void) & ((evt: "item-expand", item: ListViewItem<TItem>, expanded: boolean) => void)) & (((event: "update:modelValue", value: TItem[]) => void) & ((event: "update:unsavedKeys", value: Set<ListEditorKey>) => void));
324
+ emit: (((evt: "deleted", item: ListViewItem<TItem>) => void) & ((evt: "close", item: ListViewItem<TItem>) => void) & ((evt: "edit", item: ListViewItem<TItem>) => void) & ((evt: "add", positionHint: PositionHint | undefined) => void) & ((evt: "added", payload: {
325
+ item: TItem;
326
+ index: number;
327
+ }) => void) & ((evt: "item-saved", item: ListViewItem<TItem>) => void) & ((evt: "item-expand", item: ListViewItem<TItem>, expanded: boolean) => void)) & (((event: "update:modelValue", value: TItem[]) => void) & ((event: "update:unsavedKeys", value: Set<ListEditorKey>) => void));
321
328
  }>) => VNode & {
322
329
  __ctx?: Awaited<typeof __VLS_setup>;
323
330
  };
@@ -334,6 +341,10 @@ declare const __VLS_export_18: <TItem extends Record<string, any>>(__VLS_props:
334
341
  onAdd?: ((positionHint: PositionHint | undefined) => any) | undefined;
335
342
  "onUpdate:modelValue"?: ((value: TItem[]) => any) | undefined;
336
343
  "onUpdate:mode"?: ((value: ReorderMode) => any) | undefined;
344
+ onAdded?: ((payload: {
345
+ item: TItem;
346
+ index: number;
347
+ }) => any) | undefined;
337
348
  "onItem-saved"?: ((item: ListViewItem<TItem>) => any) | undefined;
338
349
  "onItem-expand"?: ((item: ListViewItem<TItem>, expanded: boolean) => any) | undefined;
339
350
  "onReorder-start"?: (() => any) | undefined;
@@ -377,7 +388,10 @@ declare const __VLS_export_18: <TItem extends Record<string, any>>(__VLS_props:
377
388
  'before-item'?: (props: RowSlotProps_2<TItem>) => unknown;
378
389
  'after-item'?: (props: RowSlotProps_2<TItem>) => unknown;
379
390
  };
380
- emit: (((evt: "deleted", item: ListViewItem<TItem>) => void) & ((evt: "close", item: ListViewItem<TItem>) => void) & ((evt: "edit", item: ListViewItem<TItem>) => void) & ((evt: "add", positionHint: PositionHint | undefined) => void) & ((evt: "item-saved", item: ListViewItem<TItem>) => void) & ((evt: "item-expand", item: ListViewItem<TItem>, expanded: boolean) => void) & ((evt: "reorder-start") => void) & ((evt: "reorder-cancel") => void) & ((evt: "reorder-applied", items: TItem[]) => void) & ((evt: "reorder-apply-error", error: unknown) => void) & ((evt: "reorder-end") => void)) & (((event: "update:modelValue", value: TItem[]) => void) & ((event: "update:mode", value: ReorderMode) => void) & ((event: "update:unsavedKeys", value: Set<ListEditorKey>) => void));
391
+ emit: (((evt: "deleted", item: ListViewItem<TItem>) => void) & ((evt: "close", item: ListViewItem<TItem>) => void) & ((evt: "edit", item: ListViewItem<TItem>) => void) & ((evt: "add", positionHint: PositionHint | undefined) => void) & ((evt: "added", payload: {
392
+ item: TItem;
393
+ index: number;
394
+ }) => void) & ((evt: "item-saved", item: ListViewItem<TItem>) => void) & ((evt: "item-expand", item: ListViewItem<TItem>, expanded: boolean) => void) & ((evt: "reorder-start") => void) & ((evt: "reorder-cancel") => void) & ((evt: "reorder-applied", items: TItem[]) => void) & ((evt: "reorder-apply-error", error: unknown) => void) & ((evt: "reorder-end") => void)) & (((event: "update:modelValue", value: TItem[]) => void) & ((event: "update:mode", value: ReorderMode) => void) & ((event: "update:unsavedKeys", value: Set<ListEditorKey>) => void));
381
395
  }>) => VNode & {
382
396
  __ctx?: Awaited<typeof __VLS_setup>;
383
397
  };
@@ -764,11 +778,11 @@ declare type __VLS_Slots_3 = {} & {
764
778
  };
765
779
 
766
780
  declare type __VLS_Slots_4 = {} & {
767
- title?: (props: typeof __VLS_44) => any;
781
+ title?: (props: typeof __VLS_45) => any;
768
782
  };
769
783
 
770
784
  declare type __VLS_Slots_5 = {} & {
771
- 'append-item'?: (props: typeof __VLS_12) => any;
785
+ 'append-item'?: (props: typeof __VLS_14) => any;
772
786
  };
773
787
 
774
788
  declare type __VLS_WithSlots<T, S> = T & {
@@ -1315,6 +1329,17 @@ export declare interface NestedViewItem<TItem> extends ListViewItem<TItem> {
1315
1329
  canOutdent: boolean;
1316
1330
  }
1317
1331
 
1332
+ /**
1333
+ * Unique negative temp id for new (unsaved) list rows.
1334
+ *
1335
+ * Row keys must be unique per row — duplicate or missing keys break dirty
1336
+ * tracking, validation rails and reorder targeting. A single module-wide
1337
+ * negative sequence guarantees uniqueness across all factories (two domain
1338
+ * factories can no longer both hand out `-1`), and can never collide with
1339
+ * persisted ids, which are positive. The backend assigns real ids on save.
1340
+ */
1341
+ export declare const nextListEditorTempId: () => number;
1342
+
1318
1343
  export declare interface Pagination {
1319
1344
  sortBy: DatatableSortBy;
1320
1345
  page: number;
@@ -1374,6 +1399,25 @@ declare interface Props<TItem extends Record<string, any>> {
1374
1399
  onDeleteConfirm?: (item: TItem) => Promise<boolean> | boolean;
1375
1400
  onDelete?: (item: TItem) => Promise<void> | void;
1376
1401
  onItemSave?: (item: TItem) => Promise<void> | void;
1402
+ /**
1403
+ * Editor-managed add: the add button and "add after this item" insert
1404
+ * `itemFactory()` into the model directly (positions renumbered when
1405
+ * `update-position` is on) and emit `added` — the `add` event does NOT fire,
1406
+ * so no consumer push handler is needed.
1407
+ */
1408
+ itemFactory?: () => TItem;
1409
+ /**
1410
+ * Editor-managed delete: a confirmed delete removes the row from the model
1411
+ * itself. `deleted` still fires as a notification — consumers keep side
1412
+ * effects but must not splice the model themselves.
1413
+ */
1414
+ manageDelete?: boolean;
1415
+ /**
1416
+ * Registers this editor as a named unsaved-changes section under the given
1417
+ * (already translated) label — replaces the per-consumer `useUnsavedSection`
1418
+ * call for the common one-editor case.
1419
+ */
1420
+ unsavedSectionLabel?: string;
1377
1421
  }
1378
1422
 
1379
1423
  declare interface Props_2<TItem extends Record<string, any>> {
@@ -1433,6 +1477,25 @@ declare interface Props_2<TItem extends Record<string, any>> {
1433
1477
  onDelete?: (item: TItem) => Promise<void> | void;
1434
1478
  onItemSave?: (item: TItem) => Promise<void> | void;
1435
1479
  onReorderApply?: (items: TItem[]) => Promise<void> | void;
1480
+ /**
1481
+ * Editor-managed add: the add button and "add after this item" insert
1482
+ * `itemFactory()` into the model directly (positions renumbered when
1483
+ * `update-position` is on) and emit `added` — the `add` event does NOT fire,
1484
+ * so no consumer push handler is needed.
1485
+ */
1486
+ itemFactory?: () => TItem;
1487
+ /**
1488
+ * Editor-managed delete: a confirmed delete removes the row from the model
1489
+ * itself. `deleted` still fires as a notification — consumers keep side
1490
+ * effects but must not splice the model themselves.
1491
+ */
1492
+ manageDelete?: boolean;
1493
+ /**
1494
+ * Registers this editor as a named unsaved-changes section under the given
1495
+ * (already translated) label — replaces the per-consumer `useUnsavedSection`
1496
+ * call for the common one-editor case.
1497
+ */
1498
+ unsavedSectionLabel?: string;
1436
1499
  }
1437
1500
 
1438
1501
  declare interface Props_3<TItem extends Record<string, any>> {
@@ -1474,6 +1537,12 @@ declare interface Props_3<TItem extends Record<string, any>> {
1474
1537
  onDelete?: (item: TItem) => Promise<void> | void;
1475
1538
  onItemSave?: (item: TItem) => Promise<void> | void;
1476
1539
  onReorderApply?: (tree: NestedTree<TItem>) => Promise<void> | void;
1540
+ /**
1541
+ * Registers this editor as a named unsaved-changes section under the given
1542
+ * (already translated) label — replaces the per-consumer `useUnsavedSection`
1543
+ * call for the common one-editor case.
1544
+ */
1545
+ unsavedSectionLabel?: string;
1477
1546
  }
1478
1547
 
1479
1548
  declare interface Props_4 {
@@ -1488,6 +1557,15 @@ declare interface Props_4 {
1488
1557
  dirtyLabels?: string[];
1489
1558
  }
1490
1559
 
1560
+ export declare const renumberPositions: <TItem extends Record<string, any>>(items: TItem[], options?: RenumberPositionsOptions) => TItem[];
1561
+
1562
+ export declare interface RenumberPositionsOptions {
1563
+ /** Item field holding the position. Defaults to `'position'`. */
1564
+ positionField?: string;
1565
+ /** Multiplier applied to the 1-based index (e.g. 10 → 10, 20, 30…). Defaults to `1`. */
1566
+ positionMultiplier?: number;
1567
+ }
1568
+
1491
1569
  declare type ReorderMode = 'view' | 'reorder';
1492
1570
 
1493
1571
  declare type ReorderMode_2 = 'view' | 'reorder';
@@ -1664,6 +1742,17 @@ export declare interface SortableNestedItem<TData extends SortableItemWithParent
1664
1742
  };
1665
1743
  }
1666
1744
 
1745
+ /**
1746
+ * Returns a copy of the list ordered by ascending `position`. Use after
1747
+ * fetching/saving collections whose backend returns rows in storage order —
1748
+ * a shared, non-mutating alternative to scattered
1749
+ * `items.sort((a, b) => a.position - b.position)` calls (in-place `sort`
1750
+ * mutates the source and can trigger unintended reactivity).
1751
+ */
1752
+ export declare const sortByPosition: <TItem extends {
1753
+ position: number;
1754
+ }>(items: TItem[]) => TItem[];
1755
+
1667
1756
  declare const SortOrder: {
1668
1757
  readonly Asc: "asc";
1669
1758
  readonly Desc: "desc";
@@ -1861,8 +1950,26 @@ declare interface UseListEditorItemValidationOptions {
1861
1950
  /**
1862
1951
  * Reactive validation state. Common shape: a computed reading vuelidate's
1863
1952
  * `v$.$dirty && v$.$invalid` and returning 'invalid' or null.
1953
+ *
1954
+ * Prefer `invalid` (+ optional `dirty`) below: it lets the editor surface the
1955
+ * error once the row is unsaved without relying on mount-relative `$anyDirty`.
1956
+ * `state` is kept for callers that report 'valid'/'warning' or custom logic.
1864
1957
  */
1865
- state: Ref<ListEditorValidationState> | ComputedRef<ListEditorValidationState> | (() => ListEditorValidationState);
1958
+ state?: Ref<ListEditorValidationState> | ComputedRef<ListEditorValidationState> | (() => ListEditorValidationState);
1959
+ /**
1960
+ * Whether the row's data fails validation right now (e.g. `() => v$.value.$invalid`).
1961
+ * When provided, the row is flagged 'invalid' as soon as it is invalid AND the
1962
+ * user has had a chance to fix it — i.e. the row is unsaved (added / modified)
1963
+ * or `dirty` below is true. Untouched rows on initial load stay clear so a
1964
+ * persisted-but-invalid record does not light up red before any interaction.
1965
+ */
1966
+ invalid?: () => boolean;
1967
+ /**
1968
+ * Optional extra "has been interacted with" signal OR-ed with the editor's
1969
+ * unsaved tracking (e.g. `() => v$.value.$anyDirty`). Useful when unsaved
1970
+ * tracking is disabled on the editor.
1971
+ */
1972
+ dirty?: () => boolean;
1866
1973
  }
1867
1974
 
1868
1975
  export declare interface UseListEditorOptions {
@@ -1872,6 +1979,25 @@ export declare interface UseListEditorOptions {
1872
1979
  updatePosition?: boolean;
1873
1980
  }
1874
1981
 
1982
+ /**
1983
+ * Registers a row's vuelidate state with the surrounding list editor so the
1984
+ * row shows the red invalid rail (invalid + unsaved/dirty) instead of amber.
1985
+ *
1986
+ * This is the one blessed shape for row validity sentinels — domain sentinels
1987
+ * call their validation composable and delegate here:
1988
+ *
1989
+ * ```ts
1990
+ * const item = computed(() => props.modelValue)
1991
+ * const { v$ } = useReviewListItemValidation(item)
1992
+ * useListEditorVuelidateSentinel(v$, () => item.value.id ?? item.value.position)
1993
+ * ```
1994
+ *
1995
+ * `key` must return the same key the editor resolves for the row
1996
+ * (its `key-field`) or the item's own id/position — the editor's validation
1997
+ * registry accepts either.
1998
+ */
1999
+ export declare function useListEditorVuelidateSentinel(v$: Ref<VuelidateSentinelSource>, key: () => ListEditorKey): void;
2000
+
1875
2001
  /**
1876
2002
  * Nested list editor core. Pure data behavior shared by ANestedSortableListEditor.
1877
2003
  * Works on a tree of `{ data, children, meta }` nodes — shape-compatible with the
@@ -1907,6 +2033,11 @@ declare interface UseNestedListEditorOptions {
1907
2033
  * @update:unsaved-keys="(s) => childSets.setForParent(parent.id, s)"
1908
2034
  * />
1909
2035
  * // emit `childSets.merged.value` upward
2036
+ *
2037
+ * IMPORTANT: when the parent editor uses `manage-delete`, clear the removed
2038
+ * parent's entry on its `@deleted` — `setForParent(deletedKey, new Set())` —
2039
+ * otherwise the deleted row's stale child-unsaved keys keep `merged` non-empty
2040
+ * and the unsaved-changes guard lingers after an add-then-delete.
1910
2041
  */
1911
2042
  export declare function useNestedUnsavedKeys(): UseNestedUnsavedKeysApi;
1912
2043
 
@@ -2103,6 +2234,15 @@ declare interface ViewBodySlotProps<TItem extends Record<string, any>> {
2103
2234
  };
2104
2235
  }
2105
2236
 
2237
+ /**
2238
+ * Minimal surface of a vuelidate instance the sentinel reads — any
2239
+ * `useVuelidate()` return value is structurally assignable.
2240
+ */
2241
+ export declare interface VuelidateSentinelSource {
2242
+ $invalid: boolean;
2243
+ $anyDirty: boolean;
2244
+ }
2245
+
2106
2246
  export { }
2107
2247
 
2108
2248
  declare global {