@atscript/vue-table 0.1.58

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.
Files changed (202) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/as-action-form-dialog.cjs +221 -0
  4. package/dist/as-action-form-dialog.d.cts +6 -0
  5. package/dist/as-action-form-dialog.d.mts +7 -0
  6. package/dist/as-action-form-dialog.mjs +221 -0
  7. package/dist/as-action-menu-content-CXsdPn42.mjs +104 -0
  8. package/dist/as-action-menu-content-CyUfBrWH.cjs +109 -0
  9. package/dist/as-cell-array-CXeZzZqt.cjs +69 -0
  10. package/dist/as-cell-array-DOQKR6t5.mjs +64 -0
  11. package/dist/as-cell-array.cjs +3 -0
  12. package/dist/as-cell-array.d.cts +2 -0
  13. package/dist/as-cell-array.d.mts +2 -0
  14. package/dist/as-cell-array.mjs +3 -0
  15. package/dist/as-cell-array.vue-DZGM2VHh.d.mts +12 -0
  16. package/dist/as-cell-array.vue-pFs5GcCR.d.cts +12 -0
  17. package/dist/as-cell-date-CTrvxS1h.cjs +78 -0
  18. package/dist/as-cell-date-Cq49RHmL.mjs +73 -0
  19. package/dist/as-cell-date.cjs +3 -0
  20. package/dist/as-cell-date.d.cts +2 -0
  21. package/dist/as-cell-date.d.mts +2 -0
  22. package/dist/as-cell-date.mjs +3 -0
  23. package/dist/as-cell-date.vue-BBSps2B2.d.cts +12 -0
  24. package/dist/as-cell-date.vue-Zlt4mHWb.d.mts +12 -0
  25. package/dist/as-cell-json-BynWIs1d.mjs +37 -0
  26. package/dist/as-cell-json-DvHvQ6IL.cjs +42 -0
  27. package/dist/as-cell-json-popover-BWdNs1YU.cjs +70 -0
  28. package/dist/as-cell-json-popover-DUq25I0L.mjs +65 -0
  29. package/dist/as-cell-json.cjs +3 -0
  30. package/dist/as-cell-json.d.cts +2 -0
  31. package/dist/as-cell-json.d.mts +2 -0
  32. package/dist/as-cell-json.mjs +3 -0
  33. package/dist/as-cell-json.vue-C6wg4ARZ.d.cts +12 -0
  34. package/dist/as-cell-json.vue-CESWuCer.d.mts +12 -0
  35. package/dist/as-cell-number-0_WrSCzu.cjs +76 -0
  36. package/dist/as-cell-number-Bc1C97Vg.mjs +71 -0
  37. package/dist/as-cell-number.cjs +3 -0
  38. package/dist/as-cell-number.d.cts +2 -0
  39. package/dist/as-cell-number.d.mts +2 -0
  40. package/dist/as-cell-number.mjs +3 -0
  41. package/dist/as-cell-number.vue-1Oq7nVI3.d.mts +12 -0
  42. package/dist/as-cell-number.vue-CJ2K5zeM.d.cts +12 -0
  43. package/dist/as-cell-union-C1w3B38J.mjs +88 -0
  44. package/dist/as-cell-union-CFAI0utz.cjs +93 -0
  45. package/dist/as-cell-union.cjs +4 -0
  46. package/dist/as-cell-union.d.cts +2 -0
  47. package/dist/as-cell-union.d.mts +2 -0
  48. package/dist/as-cell-union.mjs +4 -0
  49. package/dist/as-cell-union.vue-CslPM_c2.d.cts +12 -0
  50. package/dist/as-cell-union.vue-NnDmQZOA.d.mts +12 -0
  51. package/dist/as-column-menu-CH9Htz0Q.cjs +220 -0
  52. package/dist/as-column-menu-DCfhorMP.mjs +215 -0
  53. package/dist/as-column-menu.cjs +2 -0
  54. package/dist/as-column-menu.d.cts +2 -0
  55. package/dist/as-column-menu.d.mts +2 -0
  56. package/dist/as-column-menu.mjs +2 -0
  57. package/dist/as-column-menu.vue-C9e6wJ3z.d.mts +47 -0
  58. package/dist/as-column-menu.vue-o0qFdzoL.d.cts +47 -0
  59. package/dist/as-config-dialog-d2k7_l0U.cjs +699 -0
  60. package/dist/as-config-dialog-vRklaKbi.mjs +688 -0
  61. package/dist/as-config-dialog.cjs +3 -0
  62. package/dist/as-config-dialog.d.cts +2 -0
  63. package/dist/as-config-dialog.d.mts +2 -0
  64. package/dist/as-config-dialog.mjs +3 -0
  65. package/dist/as-config-dialog.vue-C6Q62xF5.d.mts +7 -0
  66. package/dist/as-config-dialog.vue-DvvJi3xx.d.cts +7 -0
  67. package/dist/as-confirm-dialog-BLh3Ju4-.mjs +52 -0
  68. package/dist/as-confirm-dialog-BgpIEE2z.cjs +57 -0
  69. package/dist/as-confirm-dialog.cjs +3 -0
  70. package/dist/as-confirm-dialog.d.cts +2 -0
  71. package/dist/as-confirm-dialog.d.mts +2 -0
  72. package/dist/as-confirm-dialog.mjs +3 -0
  73. package/dist/as-confirm-dialog.vue-CXxLpzbu.d.cts +7 -0
  74. package/dist/as-confirm-dialog.vue-pas8jGhv.d.mts +7 -0
  75. package/dist/as-filter-dialog-C0HMpUPT.mjs +610 -0
  76. package/dist/as-filter-dialog-DcGvIV3h.cjs +621 -0
  77. package/dist/as-filter-dialog.cjs +15 -0
  78. package/dist/as-filter-dialog.d.cts +2 -0
  79. package/dist/as-filter-dialog.d.mts +2 -0
  80. package/dist/as-filter-dialog.mjs +15 -0
  81. package/dist/as-filter-dialog.vue-BV2J8PgZ.d.cts +7 -0
  82. package/dist/as-filter-dialog.vue-RDZjp4gJ.d.mts +7 -0
  83. package/dist/as-filter-field-B_tYzvvl.cjs +984 -0
  84. package/dist/as-filter-field-Bqvu2ASN.mjs +943 -0
  85. package/dist/as-filter-field.cjs +9 -0
  86. package/dist/as-filter-field.d.cts +2 -0
  87. package/dist/as-filter-field.d.mts +2 -0
  88. package/dist/as-filter-field.mjs +9 -0
  89. package/dist/as-filter-field.vue-ByQ8xIGq.d.cts +11 -0
  90. package/dist/as-filter-field.vue-QY8wi5S5.d.mts +11 -0
  91. package/dist/as-filter-input--nr72iwX.cjs +106 -0
  92. package/dist/as-filter-input-P1i0CW2-.mjs +101 -0
  93. package/dist/as-filter-input.cjs +2 -0
  94. package/dist/as-filter-input.d.cts +2 -0
  95. package/dist/as-filter-input.d.mts +2 -0
  96. package/dist/as-filter-input.mjs +2 -0
  97. package/dist/as-filter-input.vue-CBQ71eNg.d.mts +18 -0
  98. package/dist/as-filter-input.vue-CS4nOk_Q.d.cts +18 -0
  99. package/dist/as-filters-Bxa9ZEMm.mjs +44 -0
  100. package/dist/as-filters-xRT2qv56.cjs +49 -0
  101. package/dist/as-filters.cjs +10 -0
  102. package/dist/as-filters.d.cts +2 -0
  103. package/dist/as-filters.d.mts +2 -0
  104. package/dist/as-filters.mjs +10 -0
  105. package/dist/as-filters.vue-BsMgYUcX.d.mts +10 -0
  106. package/dist/as-filters.vue-fv-tRL2H.d.cts +10 -0
  107. package/dist/as-preset-dialog-BaTfwMnh.cjs +569 -0
  108. package/dist/as-preset-dialog-BdDRgwf_.mjs +564 -0
  109. package/dist/as-preset-dialog.cjs +4 -0
  110. package/dist/as-preset-dialog.d.cts +2 -0
  111. package/dist/as-preset-dialog.d.mts +2 -0
  112. package/dist/as-preset-dialog.mjs +4 -0
  113. package/dist/as-preset-dialog.vue-Bzv-ON9W.d.mts +7 -0
  114. package/dist/as-preset-dialog.vue-DP9fy00Y.d.cts +7 -0
  115. package/dist/as-preset-picker-BQbNEiy9.mjs +427 -0
  116. package/dist/as-preset-picker-Ce3crTQy.cjs +432 -0
  117. package/dist/as-preset-picker.cjs +4 -0
  118. package/dist/as-preset-picker.d.cts +2 -0
  119. package/dist/as-preset-picker.d.mts +2 -0
  120. package/dist/as-preset-picker.mjs +4 -0
  121. package/dist/as-preset-picker.vue-CTBk6leV.d.mts +7 -0
  122. package/dist/as-preset-picker.vue-DfXS3pGl.d.cts +7 -0
  123. package/dist/as-row-actions-B6Kob6gt.cjs +120 -0
  124. package/dist/as-row-actions-CeWBBGqh.mjs +115 -0
  125. package/dist/as-row-actions.cjs +4 -0
  126. package/dist/as-row-actions.d.cts +2 -0
  127. package/dist/as-row-actions.d.mts +2 -0
  128. package/dist/as-row-actions.mjs +4 -0
  129. package/dist/as-row-actions.vue-BPaQfGev.d.mts +11 -0
  130. package/dist/as-row-actions.vue-Bvcc2tUN.d.cts +11 -0
  131. package/dist/as-table-Cnw2fOqZ.mjs +204 -0
  132. package/dist/as-table-DlDFxdXI.cjs +209 -0
  133. package/dist/as-table-actions-BK1Thy2G.cjs +142 -0
  134. package/dist/as-table-actions-BpMiNFni.mjs +137 -0
  135. package/dist/as-table-actions.cjs +4 -0
  136. package/dist/as-table-actions.d.cts +2 -0
  137. package/dist/as-table-actions.d.mts +2 -0
  138. package/dist/as-table-actions.mjs +4 -0
  139. package/dist/as-table-actions.vue-B7Q-JA3z.d.cts +47 -0
  140. package/dist/as-table-actions.vue-Bs1Jl1ep.d.mts +47 -0
  141. package/dist/as-table-base-D0k4k7k_.mjs +646 -0
  142. package/dist/as-table-base-VIz-B_6_.cjs +651 -0
  143. package/dist/as-table-cell-value-B1CiJYFn.mjs +26 -0
  144. package/dist/as-table-cell-value-CuxRtFn9.cjs +31 -0
  145. package/dist/as-table-cell-value.cjs +3 -0
  146. package/dist/as-table-cell-value.d.cts +2 -0
  147. package/dist/as-table-cell-value.d.mts +2 -0
  148. package/dist/as-table-cell-value.mjs +3 -0
  149. package/dist/as-table-cell-value.vue-BgFDv2JQ.d.cts +12 -0
  150. package/dist/as-table-cell-value.vue-BuPCQ8YA.d.mts +12 -0
  151. package/dist/as-table-header-cell-C3zeZUZo.cjs +117 -0
  152. package/dist/as-table-header-cell-CBn_ioCe.mjs +112 -0
  153. package/dist/as-table-header-cell.cjs +3 -0
  154. package/dist/as-table-header-cell.d.cts +2 -0
  155. package/dist/as-table-header-cell.d.mts +2 -0
  156. package/dist/as-table-header-cell.mjs +3 -0
  157. package/dist/as-table-header-cell.vue-Bc_DSsGY.d.cts +31 -0
  158. package/dist/as-table-header-cell.vue-DNMOHfek.d.mts +31 -0
  159. package/dist/as-table-root-Br6WcGRo.cjs +263 -0
  160. package/dist/as-table-root-gG7pTIdD.mjs +258 -0
  161. package/dist/as-table-root.cjs +28 -0
  162. package/dist/as-table-root.d.cts +2 -0
  163. package/dist/as-table-root.d.mts +2 -0
  164. package/dist/as-table-root.mjs +28 -0
  165. package/dist/as-table-root.vue-5_OhVwse.d.mts +2258 -0
  166. package/dist/as-table-root.vue-CSqEtIll.d.cts +2258 -0
  167. package/dist/as-table-status-BjRGGuhC.mjs +683 -0
  168. package/dist/as-table-status-DWYoJIMC.cjs +724 -0
  169. package/dist/as-table.cjs +10 -0
  170. package/dist/as-table.d.cts +2 -0
  171. package/dist/as-table.d.mts +2 -0
  172. package/dist/as-table.mjs +10 -0
  173. package/dist/as-table.vue-BTYg-e3Z.d.mts +81 -0
  174. package/dist/as-table.vue-wdRARLIe.d.cts +81 -0
  175. package/dist/as-window-table-CKIfo3M_.mjs +709 -0
  176. package/dist/as-window-table-DE7_NyEP.cjs +714 -0
  177. package/dist/as-window-table.cjs +9 -0
  178. package/dist/as-window-table.d.cts +2 -0
  179. package/dist/as-window-table.d.mts +2 -0
  180. package/dist/as-window-table.mjs +9 -0
  181. package/dist/as-window-table.vue-Bf8xGC9M.d.mts +86 -0
  182. package/dist/as-window-table.vue-CA8qsrz4.d.cts +86 -0
  183. package/dist/format-cell-B2xMDYO9.mjs +27 -0
  184. package/dist/format-cell-D4mqaN0E.cjs +32 -0
  185. package/dist/get-cell-value-CZSVfDLg.cjs +19 -0
  186. package/dist/get-cell-value-DiH84HKL.mjs +14 -0
  187. package/dist/index.cjs +598 -0
  188. package/dist/index.d.cts +21 -0
  189. package/dist/index.d.mts +21 -0
  190. package/dist/index.mjs +505 -0
  191. package/dist/preset-aspect-display-BYeiSgcc.mjs +43 -0
  192. package/dist/preset-aspect-display-y8aal_EF.cjs +72 -0
  193. package/dist/types-BvvXN72P.d.mts +531 -0
  194. package/dist/types-CNMmF6W2.d.cts +531 -0
  195. package/dist/use-cell-locale-1uQaFTLQ.mjs +23 -0
  196. package/dist/use-cell-locale-B480_QYK.cjs +34 -0
  197. package/dist/use-table-column-handlers-CGYAY2xH.cjs +65 -0
  198. package/dist/use-table-column-handlers-t6xi1yCE.mjs +54 -0
  199. package/dist/use-table-state-C4JbonEZ.mjs +1822 -0
  200. package/dist/use-table-state-MU-vuzui.cjs +1917 -0
  201. package/package.json +195 -0
  202. package/styles.d.ts +2 -0
@@ -0,0 +1,531 @@
1
+ import { ColumnDef, PaginationControl, SortControl, TableDef } from "@atscript/ui";
2
+ import { Component, ComputedRef, Ref, ShallowRef } from "vue";
3
+ import { AsPresetEntryRow, AspectMask, ColumnWidthsMap, ConfigTab, FieldFilters, PresetAspect, PresetCapabilities, PresetSnapshot, SelectionMode, SystemPreset, SystemPresetInput, TableStateMethods } from "@atscript/ui-table";
4
+ import { ClientError, TDbActionInfo, TDbActionProcessor, TDbDeleteResult } from "@atscript/db-client";
5
+
6
+ //#region src/types.d.ts
7
+ /** UI-side sentinel for the synthesised row-delete processor. */
8
+ declare const REMOVE_PROCESSOR = "__remove";
9
+ /**
10
+ * Action descriptor used everywhere in vue-table. Widens `processor` to admit
11
+ * the UI-side `__remove` sentinel without leaking into db-client.
12
+ */
13
+ type TVueTableActionInfo = Omit<TDbActionInfo, "processor"> & {
14
+ processor: TDbActionProcessor | typeof REMOVE_PROCESSOR;
15
+ };
16
+ /** Per-call options for `state.actions.invoke`. */
17
+ interface InvokeOpts {
18
+ /**
19
+ * Skip the post-success `state.query()` refresh for this call. Default:
20
+ * respect the `:refreshOnAction` root prop.
21
+ */
22
+ suppressRefresh?: boolean;
23
+ /** Originating user event — bridged to the AsTableRoot @action emit. */
24
+ event?: KeyboardEvent | MouseEvent;
25
+ /**
26
+ * `@InputForm` payload for actions whose `inputForm` field is set. Wrapped
27
+ * by the client into the request envelope's `input` field. Omit for
28
+ * actions without a form.
29
+ */
30
+ input?: unknown;
31
+ }
32
+ /** Discriminated result returned by `state.actions.invoke`. Never throws. */
33
+ type ActionResult = {
34
+ ok: true;
35
+ kind: "backend";
36
+ data: unknown;
37
+ message?: string;
38
+ } | {
39
+ ok: true;
40
+ kind: "navigate";
41
+ } | {
42
+ ok: true;
43
+ kind: "custom";
44
+ dispatched: true;
45
+ } | {
46
+ ok: true;
47
+ kind: "remove";
48
+ data: TDbDeleteResult;
49
+ } | {
50
+ ok: false;
51
+ kind: "error";
52
+ error: ClientError | Error;
53
+ };
54
+ /** Reactive table-actions namespace exposed under `state.actions`. */
55
+ interface TableActionsState {
56
+ table: TVueTableActionInfo[];
57
+ /** Includes the synthesised `__remove` when `:rowDelete` is opted in. */
58
+ row: TVueTableActionInfo[];
59
+ rows: TVueTableActionInfo[];
60
+ default: {
61
+ table?: TVueTableActionInfo; /** Never the synthesised `__remove`. */
62
+ row?: TVueTableActionInfo;
63
+ rows?: TVueTableActionInfo;
64
+ };
65
+ /**
66
+ * Per-level lists with the declared default removed. Pre-computed once per
67
+ * `tableDef`/`rowDelete` change so per-row / per-render consumers don't
68
+ * re-filter against the same default action on every read.
69
+ */
70
+ others: {
71
+ table: TVueTableActionInfo[];
72
+ row: TVueTableActionInfo[];
73
+ rows: TVueTableActionInfo[];
74
+ };
75
+ /**
76
+ * Flattened action list rendered by the per-row `<AsRowActions>` cell:
77
+ * `[default?, ...others.row, ...rows]`. Same for every row — pre-built on
78
+ * the state so per-row cells don't re-derive it.
79
+ */
80
+ cellRow: TVueTableActionInfo[];
81
+ /**
82
+ * Invoke an action. `pk` is an identifier object (or array for `'rows'`)
83
+ * built from `preferredId`. Per `@atscript/db-client` invariant #11 the
84
+ * server rejects bare scalars — even single-field PK tables send
85
+ * `{ id: '...' }`.
86
+ */
87
+ invoke: (action: TVueTableActionInfo, pk?: Record<string, unknown> | Record<string, unknown>[], opts?: InvokeOpts) => Promise<ActionResult>;
88
+ /** Set of action names with an in-flight invoke. */
89
+ invoking: ShallowRef<Set<string>>;
90
+ /** Latest result keyed by action name. */
91
+ lastResult: ShallowRef<Map<string, ActionResult>>;
92
+ }
93
+ /** Built-in row-delete configuration accepted by `<AsTableRoot :rowDelete>`. */
94
+ interface RowDeleteOpt {
95
+ label?: string;
96
+ icon?: string;
97
+ /**
98
+ * Confirmation prompt shown by the in-app `AsConfirmDialog` (driven by
99
+ * `state.prompt()`) before invoking. Pass `""` to skip the prompt.
100
+ */
101
+ confirm?: string;
102
+ intent?: TDbActionInfo["intent"];
103
+ }
104
+ /** What Enter does when the keyboard-nav handler sees it. */
105
+ type EnterAction = "main-action" | "toggle-select" | "passthrough";
106
+ /**
107
+ * Per-call options for the keyboard-nav handler / bridge. `mode` is passed
108
+ * by the caller because selection mode lives on the renderer's `:select`
109
+ * prop, not on state — the renderer's keydown closes over `props.select`,
110
+ * the search-input bridge passes the mode reader its consumer supplied.
111
+ */
112
+ interface NavKeyOptions {
113
+ enterAction?: EnterAction;
114
+ mode?: SelectionMode;
115
+ }
116
+ /** Pending request to emit `main-action`, written by handleNavKey and click handlers. */
117
+ interface MainActionRequest {
118
+ row: Record<string, unknown>;
119
+ absIndex: number;
120
+ event: KeyboardEvent | MouseEvent;
121
+ }
122
+ /**
123
+ * Vunor scope names accepted by `state.prompt()`. The confirm button maps
124
+ * `scope` → `scope-{name}` and the `c8-filled` chrome picks contrasting fg
125
+ * automatically. Mirrors action intent semantics — pass `"error"` for
126
+ * destructive ops, `"good"` for affirmations, etc.
127
+ */
128
+ type ConfirmScope = "primary" | "secondary" | "good" | "warn" | "error" | "neutral";
129
+ /**
130
+ * Options for `state.prompt()`. Title is fixed (`"Confirmation"`); only the
131
+ * body text and the two button labels are tunable. `scope` styles the
132
+ * confirm button — destructive prompts pass `"error"`, etc.
133
+ */
134
+ interface ConfirmOptions {
135
+ /** Override the confirm button label. Default: `"Confirm"`. */
136
+ confirmButton?: string;
137
+ /** Override the cancel button label. Default: `"Cancel"`. */
138
+ cancelButton?: string;
139
+ /** Vunor scope applied to the confirm button. Default: `"primary"`. */
140
+ scope?: ConfirmScope;
141
+ }
142
+ /**
143
+ * Internal pending-request shape held in `state.confirmRequest`. The default
144
+ * `AsConfirmDialog` watches this ref; setting it opens the dialog,
145
+ * resolving (via `state.acceptPrompt` / `state.dismissPrompt`) clears it.
146
+ */
147
+ interface ConfirmRequest extends ConfirmOptions {
148
+ message: string;
149
+ /** Internal — the dialog never calls this directly; use accept/dismiss. */
150
+ resolve: (ok: boolean) => void;
151
+ }
152
+ /** Internal pending-request shape held in `state.actionFormRequest`. */
153
+ interface ActionFormRequest {
154
+ action: TVueTableActionInfo;
155
+ /** Identifier objects for the targeted rows (used by `$1`/`$N` substitution in dialog copy). */
156
+ identifiers: Record<string, unknown>[];
157
+ preferredId: readonly string[];
158
+ /** Internal — the dialog never calls this directly; use accept/dismiss. */
159
+ resolve: (input: unknown) => void;
160
+ }
161
+ /**
162
+ * Public bridge object exposed by `state.navBridge` (and by the slot prop
163
+ * on `<AsTableRoot>`). Lets external `<input>`s drive table nav without
164
+ * losing focus. Space, unmodified Home/End, and printable keys pass
165
+ * through; modifier-arrow combinations are consumed.
166
+ */
167
+ interface TableNavBridge {
168
+ onKeydown: (event: KeyboardEvent, opts?: NavKeyOptions) => void;
169
+ activeIndex: Ref<number>;
170
+ setActive: (absIndex: number) => void;
171
+ clearActive: () => void;
172
+ }
173
+ /**
174
+ * Preset feature configuration passed to `useTable({ preset })` /
175
+ * `<AsTableRoot :preset>`. Presence of this object enables the feature;
176
+ * omit it entirely to disable. `app` defaults to `inject(AS_PRESETS_APP)`.
177
+ */
178
+ interface PresetConfig {
179
+ /** Preset controller URL, e.g. `"/api/db/_presets"`. */
180
+ url: string;
181
+ /** Per-table identifier — scopes preset rows under `(app, tableKey)`. */
182
+ tableKey: string;
183
+ /** Optional override; defaults to `inject(AS_PRESETS_APP)`. */
184
+ app?: string;
185
+ /** Consumer-supplied synthetic system presets (`sys:*` namespace, never persisted). */
186
+ systemPresets?: SystemPresetInput[];
187
+ /**
188
+ * App-declared aspect set — render gate for picker checkboxes / dialog
189
+ * badges + capture filter. Default `['columns','filters','filterOps','sorters']`.
190
+ * Add `'itemsPerPage'` for paginated tables; drop any aspect this app doesn't use.
191
+ */
192
+ aspects?: PresetAspect[];
193
+ /**
194
+ * Opt-in localStorage overlay for the user's in-flight tweaks (default
195
+ * `false`). Persists `columns` / `filters` / `sorters` / opt-in
196
+ * `itemsPerPage`; `filterOps` / `searchTerm` / pagination are NOT persisted.
197
+ */
198
+ persistDrafts?: boolean;
199
+ }
200
+ type QueryErrorKind = "initial" | "query" | "queryNext" | "loadRange";
201
+ /** Controls which sections appear in the column header dropdown menu. */
202
+ interface ColumnMenuConfig {
203
+ sort?: boolean;
204
+ filters?: boolean;
205
+ hide?: boolean;
206
+ /** Show "Reset width" entry. Renders only when the column's `w !== d`. */
207
+ resetWidth?: boolean;
208
+ }
209
+ /**
210
+ * Skin-slot override map for table chrome (header cells, column menu, filter
211
+ * dialog, etc.). Unstyled defaults ship out of the box; users replace any
212
+ * piece by passing a partial map via `<AsTableRoot :controls="...">`.
213
+ *
214
+ * For per-cell rendering, use `types` (cell-type dispatch) and `components`
215
+ * (named overrides via `@ui.table.component "name"`) instead — this map
216
+ * intentionally holds only the chrome, not the cell renderer.
217
+ */
218
+ interface TAsTableControls {
219
+ headerCell?: Component;
220
+ columnMenu?: Component;
221
+ /** Per-row actions cell — single button (1 action) or `…` dropdown (≥2 actions). */
222
+ rowActions?: Component;
223
+ filterInput?: Component;
224
+ filterDialog?: Component;
225
+ filterField?: Component;
226
+ filterValueHelp?: Component;
227
+ configDialog?: Component;
228
+ fieldsSelector?: Component;
229
+ sortersConfig?: Component;
230
+ /**
231
+ * Prompt dialog rendered in response to `state.prompt()`. Replaces
232
+ * `window.confirm()` for action prompts; the confirm button picks up the
233
+ * caller's `scope` so destructive ops show in the error scope, etc.
234
+ */
235
+ confirmDialog?: Component;
236
+ /**
237
+ * Dialog rendered for actions that declare an `@InputForm` schema. Owns
238
+ * the form-schema fetch + dialog chrome; the consumer fills the body via
239
+ * `<AsTableRoot>`'s `#actionForm` slot (forwarded through to this dialog).
240
+ */
241
+ actionFormDialog?: Component;
242
+ /** Tier-1 dropdown picker. Renders the presets menu (Save / Save as / Reset / Manage). */
243
+ presetPicker?: Component;
244
+ /** Tier-2 management dialog (rename / delete / public-toggle / favorite / default). */
245
+ presetDialog?: Component;
246
+ }
247
+ /**
248
+ * Cell-type → component dispatch map. Mirrors vue-form's `TAsTypeComponents`:
249
+ * a typed map keyed by built-in cell types, with `Record<string, Component>`
250
+ * to permit user-defined types.
251
+ *
252
+ * Use {@link createDefaultCellTypes} to get a pre-built map seeded with the
253
+ * default `AsTableCellValue` for every built-in type.
254
+ */
255
+ type TAsCellTypeComponents = {
256
+ text: Component;
257
+ number: Component;
258
+ boolean: Component;
259
+ date: Component; /** Date + time-of-day. Defaulted to `<AsCellDate>`. */
260
+ datetime?: Component; /** Relative time (`"3 hours ago"`). Defaulted to `<AsCellDate>`. */
261
+ relative?: Component;
262
+ array: Component;
263
+ object: Component;
264
+ enum: Component;
265
+ ref: Component; /** Synthesised row-actions pseudo-column (`:rowActionsColumn` opt-in). */
266
+ __actions?: Component;
267
+ } & Record<string, Component>;
268
+ /**
269
+ * Reactive table state — Vue implementation of the framework-agnostic
270
+ * TableStateData + TableStateMethods interfaces.
271
+ *
272
+ * Arrays/objects use ShallowRef (replaced wholesale, no deep reactivity).
273
+ * Scalars use Ref for fine-grained updates.
274
+ */
275
+ interface ReactiveTableState extends TableStateMethods {
276
+ tableDef: ShallowRef<TableDef | null>;
277
+ /** True while the table metadata (TableDef) is being loaded. */
278
+ loadingMetadata: Ref<boolean>;
279
+ columnNames: ShallowRef<string[]>;
280
+ columns: ComputedRef<ColumnDef[]>;
281
+ allColumns: ShallowRef<ColumnDef[]>;
282
+ /**
283
+ * Per-column widths keyed by column path; always populated for every column.
284
+ * Each entry: `{ w: currentRenderedWidth, d: defaultWidth }`. Deep-reactive —
285
+ * writers mutate `entry.w` directly. Default is the `@ui.table.width` annotation
286
+ * when present, otherwise type+`@expect.maxLen`-derived (see `computeDefaultColumnWidth`).
287
+ */
288
+ columnWidths: Ref<ColumnWidthsMap>;
289
+ filterFields: ShallowRef<string[]>;
290
+ filters: ShallowRef<FieldFilters>;
291
+ sorters: ShallowRef<SortControl[]>;
292
+ results: ShallowRef<Record<string, unknown>[]>;
293
+ /** Absolute index where `results[0]` sits. */
294
+ resultsStart: Ref<number>;
295
+ /** Universal cache of every loaded row keyed by absolute index. */
296
+ windowCache: ShallowRef<Map<number, Record<string, unknown>>>;
297
+ /** Block firstIndex values currently being fetched by `loadRange`. */
298
+ windowLoading: ShallowRef<Set<number>>;
299
+ /** Absolute index at the top of a windowed renderer's viewport. */
300
+ topIndex: Ref<number>;
301
+ /** Number of fixed-pool rows a windowed renderer is displaying. */
302
+ viewportRowCount: Ref<number>;
303
+ /**
304
+ * Nav-only viewport row count (standalone `<AsTable>` writes this so
305
+ * PageUp/PageDown step by the visible row count). Window mode keeps
306
+ * writing `viewportRowCount`; `pageStep()` reads `max(viewportRowCount,
307
+ * navViewportRowCount, 10) - 1`.
308
+ */
309
+ navViewportRowCount: Ref<number>;
310
+ querying: Ref<boolean>;
311
+ queryingNext: Ref<boolean>;
312
+ totalCount: Ref<number>;
313
+ loadedCount: ComputedRef<number>;
314
+ pagination: Ref<PaginationControl>;
315
+ queryError: Ref<Error | null>;
316
+ metadataError: Ref<Error | null>;
317
+ /**
318
+ * Most recent fetch error of any kind, tagged with `kind` so consumers
319
+ * can format toasts differently per source. Wrapped in a fresh
320
+ * `{ error, kind }` object on every assignment so watchers fire even
321
+ * when consecutive failures share an Error reference. Fire-and-forget:
322
+ * a successful retry does NOT clear this; it just stops re-firing.
323
+ */
324
+ lastError: Ref<{
325
+ error: Error;
326
+ kind: QueryErrorKind;
327
+ } | null>;
328
+ mustRefresh: Ref<boolean>;
329
+ searchTerm: Ref<string>;
330
+ configDialogOpen: Ref<boolean>;
331
+ configTab: Ref<ConfigTab>;
332
+ /** Selected row values (PKs extracted via `rowValueFn`). */
333
+ selectedRows: ShallowRef<unknown[]>;
334
+ selectedCount: ComputedRef<number>;
335
+ /** Extract unique value from a row for selection tracking. */
336
+ rowValueFn: (row: Record<string, unknown>) => unknown;
337
+ /**
338
+ * Row-delete opt-in — writable ref owned by the renderer. `<AsTable>` and
339
+ * `<AsWindowTable>` push their `:row-delete` prop into this ref via a
340
+ * watcher; `createActions` reads `.value` inside its computed `groups`,
341
+ * so the synthesised `__remove` action appears/disappears live without
342
+ * remounting.
343
+ */
344
+ rowDelete: Ref<boolean | RowDeleteOpt>;
345
+ /**
346
+ * `?$actions=true` opt-in — writable ref owned by the renderer.
347
+ * `<AsTable>` / `<AsWindowTable>` flip this on whenever their
348
+ * `:row-actions-column` prop is non-`false` AND the table has at least one
349
+ * row/rows-level action. When on, `buildTableQuery` requests per-row
350
+ * `$actions: string[]` so the dropdown can hide server-disabled actions.
351
+ */
352
+ includeActions: Ref<boolean>;
353
+ /**
354
+ * Whether `pk` is in the current selection set. Mode-independent — the
355
+ * renderer is expected to keep `selectedRows` empty in `select="none"`
356
+ * (its mode-transition watcher handles this), so this returns `false`
357
+ * naturally without consulting mode.
358
+ */
359
+ isPkSelected: (pk: unknown) => boolean;
360
+ /** Column currently open in the filter dialog (null when closed). */
361
+ filterDialogColumn: Ref<ColumnDef | null>;
362
+ /** Absolute index of the keyboard-active row. -1 = nothing active. */
363
+ activeIndex: Ref<number>;
364
+ /**
365
+ * Whether the active renderer caps `activeIndex` by the loaded row count
366
+ * (`"pagination"`, default — only DOM-rendered rows are navigable) or by
367
+ * the backend total (`"window"`, set by `<AsWindowTableBase>` on mount —
368
+ * unloaded rows still navigable, the windowed renderer fetches them in).
369
+ */
370
+ navMode: Ref<"pagination" | "window">;
371
+ /** True when at least one of `<AsTableRoot>` / `<AsTable>` / `<AsWindowTable>` has a `main-action` listener bound. */
372
+ hasMainActionListener: Ref<boolean>;
373
+ /** Build a deterministic DOM `id` for the row at `absIndex` (per-state UID). */
374
+ rowId: (absIndex: number) => string;
375
+ /** Set the active-row index (clamped to `[-1, totalCount - 1]`). */
376
+ setActive: (absIndex: number) => void;
377
+ /** Reset the active-row index to `-1`. */
378
+ clearActive: () => void;
379
+ /** Toggle selection of the active row's PK in `selectedRows`. */
380
+ toggleActiveSelection: (mode: SelectionMode) => void;
381
+ /** Ask the rendering component to emit `main-action` for the active row. */
382
+ requestMainAction: (event: KeyboardEvent | MouseEvent) => void;
383
+ /** Translate a keyboard event into the appropriate downstream mutations. */
384
+ handleNavKey: (event: KeyboardEvent, opts?: NavKeyOptions) => void;
385
+ /** Register a main-action callback; returns a one-shot disposer. */
386
+ registerMainActionListener: (cb: (req: MainActionRequest) => void) => () => void;
387
+ /** Server-declared actions + UI-side `__remove`, with `invoke`/`invoking`/`lastResult`. */
388
+ actions: TableActionsState;
389
+ /**
390
+ * Currently pending prompt request — `null` when no dialog is open. The
391
+ * default `<AsConfirmDialog>` v-binds its open state to this ref. Writes
392
+ * here are owned by `prompt()` / `acceptPrompt()` / `dismissPrompt()`;
393
+ * consumers should not mutate directly.
394
+ */
395
+ confirmRequest: Ref<ConfirmRequest | null>;
396
+ /**
397
+ * Open the in-app confirm dialog with `message` as the body. Resolves
398
+ * `true` on accept, `false` on cancel/dismiss. Public — consumers can
399
+ * reuse this for their own confirmation flows; the dialog is rendered
400
+ * once by `<AsTableRoot>` (or a swap-in via `controls.confirmDialog`).
401
+ *
402
+ * ```ts
403
+ * const ok = await state.prompt("Discard changes?", { scope: "error" });
404
+ * if (ok) discard();
405
+ * ```
406
+ */
407
+ prompt: (message: string, opts?: ConfirmOptions) => Promise<boolean>;
408
+ /** Resolve the active prompt with `true`. Internal — used by the dialog. */
409
+ acceptPrompt: () => void;
410
+ /** Resolve the active prompt with `false`. Internal — used by the dialog. */
411
+ dismissPrompt: () => void;
412
+ /**
413
+ * Currently pending action-form request — `null` when no form is open.
414
+ * Writes are owned by `requestActionInput()` / `acceptActionForm()` /
415
+ * `dismissActionForm()`; consumers should not mutate directly.
416
+ */
417
+ actionFormRequest: Ref<ActionFormRequest | null>;
418
+ /**
419
+ * Open the action-form dialog. Resolves with the submitted form payload
420
+ * on accept, or `null` on cancel/dismiss.
421
+ */
422
+ requestActionInput: (action: TVueTableActionInfo, ctx: {
423
+ identifiers: Record<string, unknown>[];
424
+ preferredId: readonly string[];
425
+ }) => Promise<unknown>;
426
+ /** Resolve the active form request with `input`. Internal — used by the dialog. */
427
+ acceptActionForm: (input: unknown) => void;
428
+ /** Resolve the active form request with `null`. Internal — used by the dialog. */
429
+ dismissActionForm: () => void;
430
+ /**
431
+ * Hydrate state from a URL query string produced by `stateToUrlQueryString`.
432
+ * Replaces filters / sorters / search / pagination with values decoded from
433
+ * the URL; unions decoded filter fields into `filterFields`. Echo-guarded
434
+ * against the bridge's own emissions. Does NOT call `query()` — root
435
+ * watchers refetch in reaction to the writes.
436
+ */
437
+ applyUrlQuery: (urlString: string) => void;
438
+ /**
439
+ * Preset feature surface. Always present; inert (`available=false`,
440
+ * mutators throw) when `useTable({ preset })` was not configured.
441
+ */
442
+ preset: PresetSurface;
443
+ }
444
+ /**
445
+ * Preset namespace exposed on `state.preset`. Read-only refs for picker
446
+ * UI; mutators are pure batched writes (never call `query()` — root
447
+ * watchers refetch automatically).
448
+ */
449
+ interface PresetSurface {
450
+ /** Owned + public preset rows for this `(app, tableKey)`. `[]` when feature off. */
451
+ presets: ShallowRef<AsPresetEntryRow[]>;
452
+ /** Lookup table for stored presets — O(1) by id. */
453
+ presetsById: ComputedRef<Map<string, AsPresetEntryRow>>;
454
+ /** This user's userConf row (`type='userConf'`), or null. */
455
+ userConf: ShallowRef<AsPresetEntryRow | null>;
456
+ /** Server-issued capabilities (`canPublish`, `presetLimit`); null when unavailable. */
457
+ capabilities: Ref<PresetCapabilities | null>;
458
+ /** Standard always at index 0; consumer-supplied named presets follow. */
459
+ systemPresets: ComputedRef<SystemPreset[]>;
460
+ /** Lookup table for system presets — O(1) by id. */
461
+ systemPresetsById: ComputedRef<Map<string, SystemPreset>>;
462
+ /**
463
+ * App-declared preset aspect set — render gate for picker checkboxes /
464
+ * dialog badges + capture filter. Static (captured at setup); default
465
+ * `['columns', 'filters', 'filterOps', 'sorters']`.
466
+ */
467
+ availableAspects: PresetAspect[];
468
+ /**
469
+ * False when `preset` config is absent OR the initial load returned
470
+ * 401/403 OR any other error. The picker / dialog should hide their UI.
471
+ */
472
+ available: ComputedRef<boolean>;
473
+ /** Currently active preset id (system `'sys:*'` or stored). null = no active. */
474
+ activeId: Ref<string | null>;
475
+ /** Active preset's snapshot (system presets are aspect-expanded). */
476
+ activeSnapshot: ComputedRef<PresetSnapshot>;
477
+ /** True when the current snapshot ≠ active preset's claimed aspects. */
478
+ isDirty: ComputedRef<boolean>;
479
+ /** True iff the active preset is owned by the current user (gates Save). */
480
+ canSaveActive: ComputedRef<boolean>;
481
+ /** Owner-aware: returns the user id resolved from capabilities or any private row. */
482
+ currentUser: ComputedRef<string | null>;
483
+ /** Open state for `<AsPresetDialog>` — picker's "Manage…" item flips this. */
484
+ dialogOpen: Ref<boolean>;
485
+ /** Capture a snapshot of the current state, gated by `availableAspects`. */
486
+ captureSnapshot: (mask?: AspectMask) => PresetSnapshot;
487
+ /**
488
+ * Apply a preset by id (system `sys:*` or stored) or by raw snapshot.
489
+ * Pure batched mutation — never calls `query()`. The root watcher
490
+ * picks up the changed state arrays and re-fetches automatically.
491
+ */
492
+ apply: (idOrSnapshot: string | PresetSnapshot) => void;
493
+ /** Re-apply the active preset's content; drops local edits to its claimed aspects. */
494
+ resetActive: () => void;
495
+ /** Drop the persisted localStorage draft (no-op when persistence is off). */
496
+ clearLocalDraft: () => void;
497
+ /**
498
+ * Resolve the bootstrap default preset id: pinned `userConf.defaultPresetId`
499
+ * if it still references a known preset, else `STANDARD_PRESET_ID`.
500
+ */
501
+ resolveDefaultId: () => string;
502
+ /** Re-capture the active preset's existing aspect mask. Never widens. */
503
+ saveActive: () => Promise<void>;
504
+ /** Create a new preset and switch the active id to it. */
505
+ saveAs: (label: string, opts?: {
506
+ aspects?: AspectMask;
507
+ public?: boolean;
508
+ }) => Promise<string>;
509
+ rename: (id: string, label: string) => Promise<void>;
510
+ remove: (id: string) => Promise<void>;
511
+ togglePublic: (id: string) => Promise<void>;
512
+ /** Pin a preset as default for `(user, app, tableKey)`. */
513
+ setDefault: (id: string | null) => Promise<void>;
514
+ /** Toggle a preset's pinned-as-favorite state. */
515
+ toggleFav: (id: string) => Promise<void>;
516
+ /**
517
+ * Replace the full favorites list in one upsert. Use when a UI batches
518
+ * several toggles (manage dialog) so one round-trip applies the new set.
519
+ */
520
+ setFavorites: (ids: string[]) => Promise<void>;
521
+ /**
522
+ * Run `fn` with the trailing reload of every mutator deferred until `fn`
523
+ * resolves; one coalesced reload fires at the end. Use for batched flows
524
+ * (e.g. dialog Save with N renames + M public flips + K deletes) to
525
+ * collapse N+M+K reload round-trips into 1. Pass-through when the preset
526
+ * feature is off.
527
+ */
528
+ batch: <T>(fn: () => Promise<T>) => Promise<T>;
529
+ }
530
+ //#endregion
531
+ export { TableNavBridge as _, EnterAction as a, NavKeyOptions as c, ReactiveTableState as d, RowDeleteOpt as f, TableActionsState as g, TVueTableActionInfo as h, ConfirmOptions as i, PresetConfig as l, TAsTableControls as m, ColumnMenuConfig as n, InvokeOpts as o, TAsCellTypeComponents as p, ConfigTab as r, MainActionRequest as s, ActionResult as t, QueryErrorKind as u };