@anzusystems/common-admin 1.47.0-beta.dev-1782077999 → 1.47.0-beta.dev-1782079999

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
@@ -10,6 +10,7 @@ import { MaybeRefOrGetter } from 'vue';
10
10
  import { Method } from 'axios';
11
11
  import { PublicProps } from 'vue';
12
12
  import { Ref } from 'vue';
13
+ import { ShallowRef } from 'vue';
13
14
  import { ShallowUnwrapRef } from 'vue';
14
15
  import { UseDebounceFnReturn } from '@vueuse/shared';
15
16
  import { VNode } from 'vue';
@@ -907,6 +908,14 @@ export declare function createFilter<F extends readonly MakeFilterOption<string>
907
908
 
908
909
  export declare function createFilterStore<F extends readonly MakeFilterOption<string>[]>(filterFields: F): FilterData<F>;
909
910
 
911
+ /**
912
+ * Create a scope. The internal `effectScope` is NOT detached: it attaches to whatever scope creates
913
+ * it — the providing editor's component scope (so everything stops on its unmount) or a persisted
914
+ * ENTRY's scope (so a nested editor's own row scope outlives the editor exactly as its controller
915
+ * does).
916
+ */
917
+ export declare function createListEditorStateScope(): ListEditorStateScope;
918
+
910
919
  declare interface DatatableColumnsConfigMoreOptions {
911
920
  storeColumnsLocalStorage: string | boolean;
912
921
  disableActions: boolean;
@@ -1238,6 +1247,60 @@ export declare interface ListEditorHandle<TItem extends Record<string, any>> {
1238
1247
 
1239
1248
  export declare type ListEditorKey = DocId | IntegerId | string;
1240
1249
 
1250
+ /**
1251
+ * The instance-bound controller options an editor re-supplies on EVERY (re)mount. `get`/`set` close
1252
+ * over the editor instance's `modelValue`/`emit`, and `factory`/`validate`/`dirtyExclude` over its
1253
+ * props — a remounted editor is a NEW instance, so a persisted controller must read all of them
1254
+ * through the live binding (see `useListEditorStateEntry`), never through the closures of the dead
1255
+ * instance that happened to create it.
1256
+ */
1257
+ export declare type ListEditorStateBindings<TItem extends Record<string, any>> = Pick<UseListEditorControllerOptions<TItem>, 'get' | 'set' | 'factory' | 'getKey' | 'position' | 'dirtyExclude' | 'validate'>;
1258
+
1259
+ /** What a `state-key`'d editor gets back: its persisted handle + the scope to hand to ITS own rows. */
1260
+ export declare interface ListEditorStateEntry<THandle> {
1261
+ handle: THandle;
1262
+ /** Scope for this editor's `#item` slot subtree — persisted alongside the entry, so a
1263
+ * grand-nested `state-key`'d editor survives this editor's unmount too. */
1264
+ childScope: ListEditorStateScope | null;
1265
+ }
1266
+
1267
+ /**
1268
+ * A keyed registry of list-editor state controllers, owned by an ANCESTOR (the editor that provides
1269
+ * it for its `#item` slot subtree) and living in that ancestor's `effectScope` — NOT in the scope of
1270
+ * the transient editor component that resolves it. That is the whole point: a nested editor's `#item`
1271
+ * slot is behind a `v-if`, so collapsing a row UNMOUNTS the nested editor; a component-owned
1272
+ * controller dies with it and a brand-new one re-baselines the already-edited data on re-expand,
1273
+ * losing amber / movedKeys / editedKeys / tombstones / the submitted (red-rail) flag.
1274
+ */
1275
+ export declare interface ListEditorStateScope {
1276
+ /** Unique per scope instance; namespaces the row prefixes this scope mints (and can prune). */
1277
+ readonly id: string;
1278
+ /**
1279
+ * First call for `key` CREATES the controller inside this scope (via `create`, from the calling
1280
+ * editor's own bindings) and registers it. Every later call REBINDS the registered controller to
1281
+ * the (new) calling instance's bindings and returns it — state intact.
1282
+ */
1283
+ resolve<TBindings extends object, THandle>(key: string, bindings: TBindings, create: (live: ShallowRef<TBindings>) => THandle, uid?: number | null): THandle;
1284
+ /**
1285
+ * The editor bound to `key` is unmounting: park the entry — its model accessors are swapped for a
1286
+ * frozen read + a no-op write so the orphaned controller can never read or write through the dead
1287
+ * instance's `modelValue`/`emit`. No-op when another instance has already rebound (mount-before-
1288
+ * unmount ordering), which is why the caller passes its uid.
1289
+ */
1290
+ release<TBindings extends object>(key: string, uid: number | null, park: (bindings: TBindings) => TBindings): void;
1291
+ /** Child scope of a registered entry (created lazily inside the entry's effect scope). */
1292
+ childScope(key: string): ListEditorStateScope | null;
1293
+ /** The state-key prefix for a row — hosts thread it down and suffix it per nested list. */
1294
+ prefixFor(rowKey: ListEditorKey): string;
1295
+ /** Dispose the entries of rows that no longer exist (keys minted from `prefixFor` only). */
1296
+ retainOwners(liveRowKeys: Iterable<ListEditorKey>): void;
1297
+ has(key: string): boolean;
1298
+ size(): number;
1299
+ dispose(): void;
1300
+ }
1301
+
1302
+ export declare const ListEditorStateScopeKey: InjectionKey<ListEditorStateScope>;
1303
+
1241
1304
  /** Per-row validity. `true` (or `{ valid: true }`) = VALID. Only `valid: false` blocks save. */
1242
1305
  export declare type ListEditorValidationResult = boolean | {
1243
1306
  valid: boolean;
@@ -1376,6 +1439,8 @@ export declare interface NestedListEditorHandle<TItem extends Record<string, any
1376
1439
  calculateSubtreeDepth: (node: NestedTreeNode<TItem>) => number;
1377
1440
  }
1378
1441
 
1442
+ export declare type NestedListEditorStateBindings<TItem extends Record<string, any>> = Pick<UseNestedListEditorControllerOptions<TItem>, 'get' | 'set' | 'factory' | 'getKey' | 'position' | 'parentField' | 'maxDepth' | 'dirtyExclude' | 'validate'>;
1443
+
1379
1444
  export declare interface NestedPositionHint {
1380
1445
  parentId?: ListEditorKey | null;
1381
1446
  afterId?: ListEditorKey;
@@ -1502,6 +1567,18 @@ declare interface Props<TItem extends Record<string, any>> {
1502
1567
  * internally. Either way the `ListEditorHandle` is reachable via `useTemplateRef`.
1503
1568
  */
1504
1569
  editor?: ListEditorHandle<TItem>;
1570
+ /**
1571
+ * Persist this editor's controller in the nearest ANCESTOR editor's row-state scope under this
1572
+ * key, instead of owning it. Use it for an editor rendered in another editor's `#item` slot: that
1573
+ * slot is behind a `v-if`, so collapsing the row unmounts this editor and a component-owned
1574
+ * controller would re-baseline the already-edited data on re-expand (losing amber, tombstones and
1575
+ * the red rail). Derive the key from the row slot's `stateKeyPrefix`, e.g.
1576
+ * `:state-key="`${stateKeyPrefix}:adverts`"`. Options stay declared here, on this tag: the
1577
+ * controller is built from THIS editor's `factory`/`get-key`/`position`/`dirty-exclude`/`validate`
1578
+ * and rebound to each new instance's model on remount. Ignored when `:editor` is passed, and a
1579
+ * no-op without an ancestor scope.
1580
+ */
1581
+ stateKey?: string;
1505
1582
  readonly?: boolean;
1506
1583
  disabled?: boolean;
1507
1584
  loading?: boolean;
@@ -1591,6 +1668,18 @@ declare interface Props_2<TItem extends Record<string, any>> {
1591
1668
  * relocation). When omitted the editor owns an internal controller.
1592
1669
  */
1593
1670
  editor?: ListEditorHandle<TItem>;
1671
+ /**
1672
+ * Persist this editor's controller in the nearest ANCESTOR editor's row-state scope under this
1673
+ * key, instead of owning it. Use it for an editor rendered in another editor's `#item` slot: that
1674
+ * slot is behind a `v-if`, so collapsing the row unmounts this editor and a component-owned
1675
+ * controller would re-baseline the already-edited data on re-expand (losing amber, moved rows,
1676
+ * tombstones and the red rail). Derive the key from the row slot's `stateKeyPrefix`, e.g.
1677
+ * `:state-key="`${stateKeyPrefix}:answers`"`. Options stay declared here, on this tag: the
1678
+ * controller is built from THIS editor's `factory`/`get-key`/`position`/`dirty-exclude`/`validate`
1679
+ * and rebound to each new instance's model on remount. Ignored when `:editor` is passed, and a
1680
+ * no-op without an ancestor scope.
1681
+ */
1682
+ stateKey?: string;
1594
1683
  readonly?: boolean;
1595
1684
  disabled?: boolean;
1596
1685
  loading?: boolean;
@@ -1689,6 +1778,15 @@ declare interface Props_3<TItem extends Record<string, any>> {
1689
1778
  * reachable via `useTemplateRef`.
1690
1779
  */
1691
1780
  editor?: NestedListEditorHandle<TItem>;
1781
+ /**
1782
+ * Persist this editor's controller in the nearest ANCESTOR editor's row-state scope under this
1783
+ * key, instead of owning it. Use it for an editor rendered in another editor's `#item` slot (that
1784
+ * slot is behind a `v-if`, so collapsing the row unmounts this editor and a component-owned
1785
+ * controller would re-baseline the already-edited tree on re-expand). Derive the key from the row
1786
+ * slot's `stateKeyPrefix`. Options stay declared here, on this tag. Ignored when `:editor` is
1787
+ * passed, and a no-op without an ancestor scope.
1788
+ */
1789
+ stateKey?: string;
1692
1790
  readonly?: boolean;
1693
1791
  disabled?: boolean;
1694
1792
  loading?: boolean;
@@ -1741,6 +1839,13 @@ declare interface Props_4 {
1741
1839
  dirtyLabels?: string[];
1742
1840
  }
1743
1841
 
1842
+ /**
1843
+ * Provide the row-state scope for an editor's `#item` slot subtree. A `state-key`'d editor passes
1844
+ * the `childScope` of its own persisted entry (so the chain survives at any depth); a plain editor
1845
+ * creates a component-owned scope that dies with it.
1846
+ */
1847
+ export declare function provideListEditorStateScope(inherited: ListEditorStateScope | null): ListEditorStateScope;
1848
+
1744
1849
  /**
1745
1850
  * Non-mutating renumber to sequential positions matching array order — the same
1746
1851
  * renumbering the editors apply on commit. Unchanged items stay reference-equal.
@@ -1838,6 +1943,13 @@ declare interface RowSlotProps<TItem extends Record<string, any>> {
1838
1943
  /** Aliases `dirty` here (no reorder mode → no `moved` to OR). Same field name as on sortable/nested variants. */
1839
1944
  unsaved: boolean;
1840
1945
  touch: boolean;
1946
+ /**
1947
+ * Row-scoped `state-key` prefix. Thread it down to any list editor rendered in this slot and set
1948
+ * its `:state-key="`${stateKeyPrefix}:someList`"` — that editor's controller then lives in THIS
1949
+ * editor's scope and survives the row collapsing (which unmounts the whole slot subtree). Entries
1950
+ * under this prefix are disposed when the row is removed.
1951
+ */
1952
+ stateKeyPrefix: string;
1841
1953
  actions: RowActions<TItem>;
1842
1954
  }
1843
1955
 
@@ -1857,6 +1969,13 @@ declare interface RowSlotProps_2<TItem extends Record<string, any>> {
1857
1969
  canMoveUp: boolean;
1858
1970
  canMoveDown: boolean;
1859
1971
  touch: boolean;
1972
+ /**
1973
+ * Row-scoped `state-key` prefix. Thread it down to any list editor rendered in this slot and set
1974
+ * its `:state-key="`${stateKeyPrefix}:someList`"` — that editor's controller then lives in THIS
1975
+ * editor's scope and survives the row collapsing (which unmounts the whole slot subtree). Entries
1976
+ * under this prefix are disposed when the row is removed.
1977
+ */
1978
+ stateKeyPrefix: string;
1860
1979
  actions: RowActions_2<TItem>;
1861
1980
  }
1862
1981
 
@@ -1890,6 +2009,13 @@ declare interface RowSlotProps_3<TItem extends Record<string, any>> {
1890
2009
  canOutdent: boolean;
1891
2010
  canAddChild: boolean;
1892
2011
  touch: boolean;
2012
+ /**
2013
+ * Row-scoped `state-key` prefix. Thread it down to any list editor rendered in this slot and set
2014
+ * its `:state-key="`${stateKeyPrefix}:someList`"` — that editor's controller then lives in THIS
2015
+ * editor's scope and survives the row collapsing (which unmounts the whole slot subtree). Entries
2016
+ * under this prefix are disposed when the row is removed.
2017
+ */
2018
+ stateKeyPrefix: string;
1893
2019
  actions: RowActions_3<TItem>;
1894
2020
  }
1895
2021
 
@@ -2198,6 +2324,18 @@ export declare interface UseListEditorOptions {
2198
2324
  updatePosition?: boolean;
2199
2325
  }
2200
2326
 
2327
+ /**
2328
+ * Resolve this editor's controller from the nearest ancestor scope under `stateKey` (or `null` when
2329
+ * the editor has no `state-key`, or no ancestor provides a scope → today's component-owned
2330
+ * controller, unchanged).
2331
+ *
2332
+ * The controller is built from the FIRST mounting instance's own props, but every instance-bound
2333
+ * option is read through `live` — the shallowRef the scope swaps on each (re)mount. `getKey` and
2334
+ * `position` are static per tag, so the controller reads them once (it derives its key field at
2335
+ * construction); everything else is indirected.
2336
+ */
2337
+ export declare function useListEditorStateEntry<TItem extends Record<string, any>>(stateKey: string | undefined, bindings: ListEditorStateBindings<TItem>): ListEditorStateEntry<ListEditorHandle<TItem>> | null;
2338
+
2201
2339
  /**
2202
2340
  * Nested list editor core. Pure data behavior shared by ANestedSortableListEditor.
2203
2341
  * Works on a tree of `{ data, children, meta }` nodes — shape-compatible with the
@@ -2257,6 +2395,9 @@ declare interface UseNestedListEditorOptions {
2257
2395
  expandedKeys?: Ref<Set<ListEditorKey>>;
2258
2396
  }
2259
2397
 
2398
+ /** Tree-shaped twin of `useListEditorStateEntry` for ANestedSortableListEditor. */
2399
+ export declare function useNestedListEditorStateEntry<TItem extends Record<string, any>>(stateKey: string | undefined, bindings: NestedListEditorStateBindings<TItem>): ListEditorStateEntry<NestedListEditorHandle<TItem>> | null;
2400
+
2260
2401
  /**
2261
2402
  * Aggregates per-parent child-editor unsaved-keys into one prefix-merged set.
2262
2403
  * Used by stacked editors (e.g. quiz: questions → answers) so the outer