@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.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/as-action-form-dialog.cjs +221 -0
- package/dist/as-action-form-dialog.d.cts +6 -0
- package/dist/as-action-form-dialog.d.mts +7 -0
- package/dist/as-action-form-dialog.mjs +221 -0
- package/dist/as-action-menu-content-CXsdPn42.mjs +104 -0
- package/dist/as-action-menu-content-CyUfBrWH.cjs +109 -0
- package/dist/as-cell-array-CXeZzZqt.cjs +69 -0
- package/dist/as-cell-array-DOQKR6t5.mjs +64 -0
- package/dist/as-cell-array.cjs +3 -0
- package/dist/as-cell-array.d.cts +2 -0
- package/dist/as-cell-array.d.mts +2 -0
- package/dist/as-cell-array.mjs +3 -0
- package/dist/as-cell-array.vue-DZGM2VHh.d.mts +12 -0
- package/dist/as-cell-array.vue-pFs5GcCR.d.cts +12 -0
- package/dist/as-cell-date-CTrvxS1h.cjs +78 -0
- package/dist/as-cell-date-Cq49RHmL.mjs +73 -0
- package/dist/as-cell-date.cjs +3 -0
- package/dist/as-cell-date.d.cts +2 -0
- package/dist/as-cell-date.d.mts +2 -0
- package/dist/as-cell-date.mjs +3 -0
- package/dist/as-cell-date.vue-BBSps2B2.d.cts +12 -0
- package/dist/as-cell-date.vue-Zlt4mHWb.d.mts +12 -0
- package/dist/as-cell-json-BynWIs1d.mjs +37 -0
- package/dist/as-cell-json-DvHvQ6IL.cjs +42 -0
- package/dist/as-cell-json-popover-BWdNs1YU.cjs +70 -0
- package/dist/as-cell-json-popover-DUq25I0L.mjs +65 -0
- package/dist/as-cell-json.cjs +3 -0
- package/dist/as-cell-json.d.cts +2 -0
- package/dist/as-cell-json.d.mts +2 -0
- package/dist/as-cell-json.mjs +3 -0
- package/dist/as-cell-json.vue-C6wg4ARZ.d.cts +12 -0
- package/dist/as-cell-json.vue-CESWuCer.d.mts +12 -0
- package/dist/as-cell-number-0_WrSCzu.cjs +76 -0
- package/dist/as-cell-number-Bc1C97Vg.mjs +71 -0
- package/dist/as-cell-number.cjs +3 -0
- package/dist/as-cell-number.d.cts +2 -0
- package/dist/as-cell-number.d.mts +2 -0
- package/dist/as-cell-number.mjs +3 -0
- package/dist/as-cell-number.vue-1Oq7nVI3.d.mts +12 -0
- package/dist/as-cell-number.vue-CJ2K5zeM.d.cts +12 -0
- package/dist/as-cell-union-C1w3B38J.mjs +88 -0
- package/dist/as-cell-union-CFAI0utz.cjs +93 -0
- package/dist/as-cell-union.cjs +4 -0
- package/dist/as-cell-union.d.cts +2 -0
- package/dist/as-cell-union.d.mts +2 -0
- package/dist/as-cell-union.mjs +4 -0
- package/dist/as-cell-union.vue-CslPM_c2.d.cts +12 -0
- package/dist/as-cell-union.vue-NnDmQZOA.d.mts +12 -0
- package/dist/as-column-menu-CH9Htz0Q.cjs +220 -0
- package/dist/as-column-menu-DCfhorMP.mjs +215 -0
- package/dist/as-column-menu.cjs +2 -0
- package/dist/as-column-menu.d.cts +2 -0
- package/dist/as-column-menu.d.mts +2 -0
- package/dist/as-column-menu.mjs +2 -0
- package/dist/as-column-menu.vue-C9e6wJ3z.d.mts +47 -0
- package/dist/as-column-menu.vue-o0qFdzoL.d.cts +47 -0
- package/dist/as-config-dialog-d2k7_l0U.cjs +699 -0
- package/dist/as-config-dialog-vRklaKbi.mjs +688 -0
- package/dist/as-config-dialog.cjs +3 -0
- package/dist/as-config-dialog.d.cts +2 -0
- package/dist/as-config-dialog.d.mts +2 -0
- package/dist/as-config-dialog.mjs +3 -0
- package/dist/as-config-dialog.vue-C6Q62xF5.d.mts +7 -0
- package/dist/as-config-dialog.vue-DvvJi3xx.d.cts +7 -0
- package/dist/as-confirm-dialog-BLh3Ju4-.mjs +52 -0
- package/dist/as-confirm-dialog-BgpIEE2z.cjs +57 -0
- package/dist/as-confirm-dialog.cjs +3 -0
- package/dist/as-confirm-dialog.d.cts +2 -0
- package/dist/as-confirm-dialog.d.mts +2 -0
- package/dist/as-confirm-dialog.mjs +3 -0
- package/dist/as-confirm-dialog.vue-CXxLpzbu.d.cts +7 -0
- package/dist/as-confirm-dialog.vue-pas8jGhv.d.mts +7 -0
- package/dist/as-filter-dialog-C0HMpUPT.mjs +610 -0
- package/dist/as-filter-dialog-DcGvIV3h.cjs +621 -0
- package/dist/as-filter-dialog.cjs +15 -0
- package/dist/as-filter-dialog.d.cts +2 -0
- package/dist/as-filter-dialog.d.mts +2 -0
- package/dist/as-filter-dialog.mjs +15 -0
- package/dist/as-filter-dialog.vue-BV2J8PgZ.d.cts +7 -0
- package/dist/as-filter-dialog.vue-RDZjp4gJ.d.mts +7 -0
- package/dist/as-filter-field-B_tYzvvl.cjs +984 -0
- package/dist/as-filter-field-Bqvu2ASN.mjs +943 -0
- package/dist/as-filter-field.cjs +9 -0
- package/dist/as-filter-field.d.cts +2 -0
- package/dist/as-filter-field.d.mts +2 -0
- package/dist/as-filter-field.mjs +9 -0
- package/dist/as-filter-field.vue-ByQ8xIGq.d.cts +11 -0
- package/dist/as-filter-field.vue-QY8wi5S5.d.mts +11 -0
- package/dist/as-filter-input--nr72iwX.cjs +106 -0
- package/dist/as-filter-input-P1i0CW2-.mjs +101 -0
- package/dist/as-filter-input.cjs +2 -0
- package/dist/as-filter-input.d.cts +2 -0
- package/dist/as-filter-input.d.mts +2 -0
- package/dist/as-filter-input.mjs +2 -0
- package/dist/as-filter-input.vue-CBQ71eNg.d.mts +18 -0
- package/dist/as-filter-input.vue-CS4nOk_Q.d.cts +18 -0
- package/dist/as-filters-Bxa9ZEMm.mjs +44 -0
- package/dist/as-filters-xRT2qv56.cjs +49 -0
- package/dist/as-filters.cjs +10 -0
- package/dist/as-filters.d.cts +2 -0
- package/dist/as-filters.d.mts +2 -0
- package/dist/as-filters.mjs +10 -0
- package/dist/as-filters.vue-BsMgYUcX.d.mts +10 -0
- package/dist/as-filters.vue-fv-tRL2H.d.cts +10 -0
- package/dist/as-preset-dialog-BaTfwMnh.cjs +569 -0
- package/dist/as-preset-dialog-BdDRgwf_.mjs +564 -0
- package/dist/as-preset-dialog.cjs +4 -0
- package/dist/as-preset-dialog.d.cts +2 -0
- package/dist/as-preset-dialog.d.mts +2 -0
- package/dist/as-preset-dialog.mjs +4 -0
- package/dist/as-preset-dialog.vue-Bzv-ON9W.d.mts +7 -0
- package/dist/as-preset-dialog.vue-DP9fy00Y.d.cts +7 -0
- package/dist/as-preset-picker-BQbNEiy9.mjs +427 -0
- package/dist/as-preset-picker-Ce3crTQy.cjs +432 -0
- package/dist/as-preset-picker.cjs +4 -0
- package/dist/as-preset-picker.d.cts +2 -0
- package/dist/as-preset-picker.d.mts +2 -0
- package/dist/as-preset-picker.mjs +4 -0
- package/dist/as-preset-picker.vue-CTBk6leV.d.mts +7 -0
- package/dist/as-preset-picker.vue-DfXS3pGl.d.cts +7 -0
- package/dist/as-row-actions-B6Kob6gt.cjs +120 -0
- package/dist/as-row-actions-CeWBBGqh.mjs +115 -0
- package/dist/as-row-actions.cjs +4 -0
- package/dist/as-row-actions.d.cts +2 -0
- package/dist/as-row-actions.d.mts +2 -0
- package/dist/as-row-actions.mjs +4 -0
- package/dist/as-row-actions.vue-BPaQfGev.d.mts +11 -0
- package/dist/as-row-actions.vue-Bvcc2tUN.d.cts +11 -0
- package/dist/as-table-Cnw2fOqZ.mjs +204 -0
- package/dist/as-table-DlDFxdXI.cjs +209 -0
- package/dist/as-table-actions-BK1Thy2G.cjs +142 -0
- package/dist/as-table-actions-BpMiNFni.mjs +137 -0
- package/dist/as-table-actions.cjs +4 -0
- package/dist/as-table-actions.d.cts +2 -0
- package/dist/as-table-actions.d.mts +2 -0
- package/dist/as-table-actions.mjs +4 -0
- package/dist/as-table-actions.vue-B7Q-JA3z.d.cts +47 -0
- package/dist/as-table-actions.vue-Bs1Jl1ep.d.mts +47 -0
- package/dist/as-table-base-D0k4k7k_.mjs +646 -0
- package/dist/as-table-base-VIz-B_6_.cjs +651 -0
- package/dist/as-table-cell-value-B1CiJYFn.mjs +26 -0
- package/dist/as-table-cell-value-CuxRtFn9.cjs +31 -0
- package/dist/as-table-cell-value.cjs +3 -0
- package/dist/as-table-cell-value.d.cts +2 -0
- package/dist/as-table-cell-value.d.mts +2 -0
- package/dist/as-table-cell-value.mjs +3 -0
- package/dist/as-table-cell-value.vue-BgFDv2JQ.d.cts +12 -0
- package/dist/as-table-cell-value.vue-BuPCQ8YA.d.mts +12 -0
- package/dist/as-table-header-cell-C3zeZUZo.cjs +117 -0
- package/dist/as-table-header-cell-CBn_ioCe.mjs +112 -0
- package/dist/as-table-header-cell.cjs +3 -0
- package/dist/as-table-header-cell.d.cts +2 -0
- package/dist/as-table-header-cell.d.mts +2 -0
- package/dist/as-table-header-cell.mjs +3 -0
- package/dist/as-table-header-cell.vue-Bc_DSsGY.d.cts +31 -0
- package/dist/as-table-header-cell.vue-DNMOHfek.d.mts +31 -0
- package/dist/as-table-root-Br6WcGRo.cjs +263 -0
- package/dist/as-table-root-gG7pTIdD.mjs +258 -0
- package/dist/as-table-root.cjs +28 -0
- package/dist/as-table-root.d.cts +2 -0
- package/dist/as-table-root.d.mts +2 -0
- package/dist/as-table-root.mjs +28 -0
- package/dist/as-table-root.vue-5_OhVwse.d.mts +2258 -0
- package/dist/as-table-root.vue-CSqEtIll.d.cts +2258 -0
- package/dist/as-table-status-BjRGGuhC.mjs +683 -0
- package/dist/as-table-status-DWYoJIMC.cjs +724 -0
- package/dist/as-table.cjs +10 -0
- package/dist/as-table.d.cts +2 -0
- package/dist/as-table.d.mts +2 -0
- package/dist/as-table.mjs +10 -0
- package/dist/as-table.vue-BTYg-e3Z.d.mts +81 -0
- package/dist/as-table.vue-wdRARLIe.d.cts +81 -0
- package/dist/as-window-table-CKIfo3M_.mjs +709 -0
- package/dist/as-window-table-DE7_NyEP.cjs +714 -0
- package/dist/as-window-table.cjs +9 -0
- package/dist/as-window-table.d.cts +2 -0
- package/dist/as-window-table.d.mts +2 -0
- package/dist/as-window-table.mjs +9 -0
- package/dist/as-window-table.vue-Bf8xGC9M.d.mts +86 -0
- package/dist/as-window-table.vue-CA8qsrz4.d.cts +86 -0
- package/dist/format-cell-B2xMDYO9.mjs +27 -0
- package/dist/format-cell-D4mqaN0E.cjs +32 -0
- package/dist/get-cell-value-CZSVfDLg.cjs +19 -0
- package/dist/get-cell-value-DiH84HKL.mjs +14 -0
- package/dist/index.cjs +598 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.mjs +505 -0
- package/dist/preset-aspect-display-BYeiSgcc.mjs +43 -0
- package/dist/preset-aspect-display-y8aal_EF.cjs +72 -0
- package/dist/types-BvvXN72P.d.mts +531 -0
- package/dist/types-CNMmF6W2.d.cts +531 -0
- package/dist/use-cell-locale-1uQaFTLQ.mjs +23 -0
- package/dist/use-cell-locale-B480_QYK.cjs +34 -0
- package/dist/use-table-column-handlers-CGYAY2xH.cjs +65 -0
- package/dist/use-table-column-handlers-t6xi1yCE.mjs +54 -0
- package/dist/use-table-state-C4JbonEZ.mjs +1822 -0
- package/dist/use-table-state-MU-vuzui.cjs +1917 -0
- package/package.json +195 -0
- package/styles.d.ts +2 -0
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
import { Component, ComputedRef, Ref, ShallowRef } from "vue";
|
|
2
|
+
import { ClientError, TDbActionInfo, TDbActionProcessor, TDbDeleteResult } from "@atscript/db-client";
|
|
3
|
+
import { ColumnDef, PaginationControl, SortControl, TableDef } from "@atscript/ui";
|
|
4
|
+
import { AsPresetEntryRow, AspectMask, ColumnWidthsMap, ConfigTab, FieldFilters, PresetAspect, PresetCapabilities, PresetSnapshot, SelectionMode, SystemPreset, SystemPresetInput, TableStateMethods } from "@atscript/ui-table";
|
|
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 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { computed, inject, provide, toValue } from "vue";
|
|
2
|
+
//#region src/composables/use-cell-locale.ts
|
|
3
|
+
const CELL_LOCALE_KEY = "__as_cell_locale";
|
|
4
|
+
function provideCellLocale(source) {
|
|
5
|
+
provide(CELL_LOCALE_KEY, source);
|
|
6
|
+
}
|
|
7
|
+
function useCellLocale() {
|
|
8
|
+
const source = inject(CELL_LOCALE_KEY, void 0);
|
|
9
|
+
return {
|
|
10
|
+
locale: computed(() => {
|
|
11
|
+
const lang = source ? toValue(source)?.language : void 0;
|
|
12
|
+
if (lang && lang.trim().length > 0) return lang;
|
|
13
|
+
return typeof navigator !== "undefined" && navigator.language ? navigator.language : "en-US";
|
|
14
|
+
}),
|
|
15
|
+
timezone: computed(() => {
|
|
16
|
+
const tz = source ? toValue(source)?.timezone : void 0;
|
|
17
|
+
if (!tz || tz === "system") return void 0;
|
|
18
|
+
return tz;
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useCellLocale as n, provideCellLocale as t };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
//#region src/composables/use-cell-locale.ts
|
|
3
|
+
const CELL_LOCALE_KEY = "__as_cell_locale";
|
|
4
|
+
function provideCellLocale(source) {
|
|
5
|
+
(0, vue.provide)(CELL_LOCALE_KEY, source);
|
|
6
|
+
}
|
|
7
|
+
function useCellLocale() {
|
|
8
|
+
const source = (0, vue.inject)(CELL_LOCALE_KEY, void 0);
|
|
9
|
+
return {
|
|
10
|
+
locale: (0, vue.computed)(() => {
|
|
11
|
+
const lang = source ? (0, vue.toValue)(source)?.language : void 0;
|
|
12
|
+
if (lang && lang.trim().length > 0) return lang;
|
|
13
|
+
return typeof navigator !== "undefined" && navigator.language ? navigator.language : "en-US";
|
|
14
|
+
}),
|
|
15
|
+
timezone: (0, vue.computed)(() => {
|
|
16
|
+
const tz = source ? (0, vue.toValue)(source)?.timezone : void 0;
|
|
17
|
+
if (!tz || tz === "system") return void 0;
|
|
18
|
+
return tz;
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "provideCellLocale", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return provideCellLocale;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "useCellLocale", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function() {
|
|
32
|
+
return useCellLocale;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let _atscript_ui_table = require("@atscript/ui-table");
|
|
3
|
+
//#region src/composables/use-has-emit-listener.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns true when the parent component bound a v-on listener for `emitName`
|
|
6
|
+
* (e.g. `onMainAction` for `@main-action`). Reads `inst.vnode.props` — the
|
|
7
|
+
* same property Vue uses to dispatch emit listeners. Non-reactive: a parent
|
|
8
|
+
* remount via `v-if` re-evaluates at the new mount.
|
|
9
|
+
*/
|
|
10
|
+
function useHasEmitListener(emitName) {
|
|
11
|
+
const inst = (0, vue.getCurrentInstance)();
|
|
12
|
+
return (0, vue.computed)(() => !!inst?.vnode.props?.[emitName]);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/composables/use-table-column-handlers.ts
|
|
16
|
+
/**
|
|
17
|
+
* Pure pass-through handlers shared between the pagination renderer
|
|
18
|
+
* (`<AsTable>`) and the window renderer (`<AsWindowTableBase>`). Selection
|
|
19
|
+
* and row-mouse handlers stay in their owning components because their
|
|
20
|
+
* semantics diverge meaningfully (window has no "all" state; standalone
|
|
21
|
+
* vs Reka renderModes need different gating).
|
|
22
|
+
*/
|
|
23
|
+
function useTableColumnHandlers(state) {
|
|
24
|
+
return {
|
|
25
|
+
onSort(column, direction) {
|
|
26
|
+
const rest = state.sorters.value.filter((s) => s.field !== column.path);
|
|
27
|
+
state.sorters.value = direction === null ? rest : [...rest, {
|
|
28
|
+
field: column.path,
|
|
29
|
+
direction
|
|
30
|
+
}];
|
|
31
|
+
},
|
|
32
|
+
onHide(column) {
|
|
33
|
+
state.columnNames.value = state.columnNames.value.filter((n) => n !== column.path);
|
|
34
|
+
},
|
|
35
|
+
onFilter(column) {
|
|
36
|
+
state.openFilterDialog(column);
|
|
37
|
+
},
|
|
38
|
+
onFiltersOff(column) {
|
|
39
|
+
state.removeFieldFilter(column.path);
|
|
40
|
+
},
|
|
41
|
+
onResetWidth(column) {
|
|
42
|
+
state.resetColumnWidth(column.path);
|
|
43
|
+
},
|
|
44
|
+
onReorder(fromPath, toPath, position) {
|
|
45
|
+
state.columnNames.value = (0, _atscript_ui_table.reorderColumnNames)(state.columnNames.value, fromPath, toPath, position);
|
|
46
|
+
},
|
|
47
|
+
onClearFilters() {
|
|
48
|
+
state.resetFilters();
|
|
49
|
+
if (state.searchTerm.value) state.searchTerm.value = "";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
Object.defineProperty(exports, "useHasEmitListener", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function() {
|
|
57
|
+
return useHasEmitListener;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "useTableColumnHandlers", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function() {
|
|
63
|
+
return useTableColumnHandlers;
|
|
64
|
+
}
|
|
65
|
+
});
|