@atscript/vue-table 0.1.133 → 0.1.135
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/as-action-form-dialog.cjs +1 -1
- package/dist/as-action-form-dialog.mjs +1 -1
- package/dist/{as-action-menu-content-DiS37BYK.cjs → as-action-menu-content-D8VzLK9e.cjs} +1 -1
- package/dist/{as-action-menu-content-4D7CJNgr.mjs → as-action-menu-content-qATZy3cu.mjs} +1 -1
- package/dist/{as-cell-array-2qmJ1lT2.mjs → as-cell-array-BWHkJX3I.mjs} +2 -2
- package/dist/{as-cell-array-iPeUnk2G.cjs → as-cell-array-D-8Pqlgo.cjs} +2 -2
- package/dist/as-cell-array.cjs +1 -1
- package/dist/as-cell-array.mjs +1 -1
- package/dist/{as-cell-date-DyixWKuS.cjs → as-cell-date-DviMJEqs.cjs} +2 -2
- package/dist/{as-cell-date-BwFgi6O0.mjs → as-cell-date-mGlnDeLP.mjs} +2 -2
- package/dist/as-cell-date.cjs +1 -1
- package/dist/as-cell-date.mjs +1 -1
- package/dist/{as-cell-json--95Xq6yq.mjs → as-cell-json-2I081xnO.mjs} +2 -2
- package/dist/{as-cell-json-Bvv2P7YV.cjs → as-cell-json-CaVB6e7V.cjs} +2 -2
- package/dist/as-cell-json.cjs +1 -1
- package/dist/as-cell-json.mjs +1 -1
- package/dist/{as-cell-number-DuPMOesI.cjs → as-cell-number-BnYbxOiG.cjs} +2 -2
- package/dist/{as-cell-number-DKRaS9pM.mjs → as-cell-number-CP2AZI9g.mjs} +2 -2
- package/dist/as-cell-number.cjs +1 -1
- package/dist/as-cell-number.mjs +1 -1
- package/dist/{as-cell-union-DJNsEKTi.cjs → as-cell-union-BjMP91PS.cjs} +3 -3
- package/dist/{as-cell-union-C9FukGqF.mjs → as-cell-union-NHpDCXty.mjs} +3 -3
- package/dist/as-cell-union.cjs +1 -1
- package/dist/as-cell-union.mjs +1 -1
- package/dist/as-column-menu.cjs +1 -1
- package/dist/as-column-menu.d.cts +1 -1
- package/dist/as-column-menu.d.mts +1 -1
- package/dist/as-column-menu.mjs +1 -1
- package/dist/{as-column-menu.vue-Cuelpv3p.d.mts → as-column-menu.vue-BaIGUOhP.d.mts} +1 -1
- package/dist/{as-column-menu.vue-CZ8XqHl0.d.cts → as-column-menu.vue-CDlI4-Cz.d.cts} +1 -1
- package/dist/{as-config-dialog-BKsm8OHR.mjs → as-config-dialog-BMQxSqzl.mjs} +31 -15
- package/dist/{as-config-dialog-Bt8oP8qg.cjs → as-config-dialog-CP362FP3.cjs} +31 -15
- package/dist/as-config-dialog.cjs +1 -1
- package/dist/as-config-dialog.mjs +1 -1
- package/dist/{as-confirm-dialog-Cw7KErhz.cjs → as-confirm-dialog-D41XaN_P.cjs} +1 -1
- package/dist/{as-confirm-dialog-BV01t7dn.mjs → as-confirm-dialog-Dp_njNXz.mjs} +1 -1
- package/dist/as-confirm-dialog.cjs +1 -1
- package/dist/as-confirm-dialog.mjs +1 -1
- package/dist/{as-filter-dialog-Bxii-mYH.cjs → as-filter-dialog-BCUqpKPd.cjs} +9 -9
- package/dist/{as-filter-dialog-Ckrl79kU.mjs → as-filter-dialog-kAXGDwsk.mjs} +9 -9
- package/dist/as-filter-dialog.cjs +1 -1
- package/dist/as-filter-dialog.mjs +1 -1
- package/dist/{as-filter-field-xBr6TtKo.cjs → as-filter-field-D3jSbSwB.cjs} +3 -3
- package/dist/{as-filter-field-C-IFnj8K.mjs → as-filter-field-WnV2axh8.mjs} +3 -3
- package/dist/as-filter-field.cjs +1 -1
- package/dist/as-filter-field.mjs +1 -1
- package/dist/as-filter-input.cjs +1 -1
- package/dist/as-filter-input.mjs +1 -1
- package/dist/{as-filters-DJEQj7_p.mjs → as-filters-Bc44srvA.mjs} +3 -3
- package/dist/{as-filters-DuCk8nkk.cjs → as-filters-Dp93OWRS.cjs} +3 -3
- package/dist/as-filters.cjs +1 -1
- package/dist/as-filters.mjs +1 -1
- package/dist/{as-preset-dialog-CCIacZ2C.mjs → as-preset-dialog-Bx4nRuyk.mjs} +3 -3
- package/dist/{as-preset-dialog-jZeyXJeJ.cjs → as-preset-dialog-pusPD935.cjs} +3 -3
- package/dist/as-preset-dialog.cjs +1 -1
- package/dist/as-preset-dialog.mjs +1 -1
- package/dist/{as-preset-picker-DGSqQl9A.mjs → as-preset-picker-BRQdflJz.mjs} +54 -50
- package/dist/{as-preset-picker-4xXU1KQz.cjs → as-preset-picker-nAx3MYl7.cjs} +54 -50
- package/dist/as-preset-picker.cjs +1 -1
- package/dist/as-preset-picker.mjs +1 -1
- package/dist/{as-row-actions-B_OHWIAt.cjs → as-row-actions-PD-sFmDs.cjs} +24 -11
- package/dist/{as-row-actions-pukI1JT7.mjs → as-row-actions-gxmuZkYI.mjs} +24 -11
- package/dist/as-row-actions.cjs +1 -1
- package/dist/as-row-actions.d.cts +1 -1
- package/dist/as-row-actions.d.mts +1 -1
- package/dist/as-row-actions.mjs +1 -1
- package/dist/{as-row-actions.vue-DUSDuoR2.d.mts → as-row-actions.vue-AXXt5kQS.d.mts} +8 -0
- package/dist/{as-row-actions.vue-Bvcc2tUN.d.cts → as-row-actions.vue-D0MXQoeg.d.cts} +8 -0
- package/dist/{as-table-D5_bQ0p5.mjs → as-table-BIV1W3O9.mjs} +6 -6
- package/dist/{as-table-actions-DKYK_mTO.mjs → as-table-actions-DQ5Nn8Jc.mjs} +14 -9
- package/dist/{as-table-actions-qb0gQz2D.cjs → as-table-actions-D_PUqMYy.cjs} +14 -9
- package/dist/as-table-actions.cjs +1 -1
- package/dist/as-table-actions.d.cts +1 -1
- package/dist/as-table-actions.d.mts +1 -1
- package/dist/as-table-actions.mjs +1 -1
- package/dist/{as-table-actions.vue-CckRRsL6.d.cts → as-table-actions.vue-iKw4tsJh.d.cts} +2 -2
- package/dist/{as-table-actions.vue-DsqauvXR.d.mts → as-table-actions.vue-kndyFTyi.d.mts} +2 -2
- package/dist/{as-table-base-Dfw012G5.cjs → as-table-base-M6_12pPq.cjs} +3 -3
- package/dist/{as-table-base-B0arhJI8.mjs → as-table-base-kHOKCI7T.mjs} +3 -3
- package/dist/{as-table-cell-value-D1JkTQt0.cjs → as-table-cell-value-BAi5yadc.cjs} +2 -2
- package/dist/{as-table-cell-value-CPcFxSOj.mjs → as-table-cell-value-BVcfhhCb.mjs} +2 -2
- package/dist/as-table-cell-value.cjs +1 -1
- package/dist/as-table-cell-value.mjs +1 -1
- package/dist/{as-table-header-cell-q-c_QklI.mjs → as-table-header-cell-CZyy4q1s.mjs} +2 -2
- package/dist/{as-table-header-cell-Bb4ddLmQ.cjs → as-table-header-cell-Ct_GPLVu.cjs} +2 -2
- package/dist/as-table-header-cell.cjs +1 -1
- package/dist/as-table-header-cell.d.cts +1 -1
- package/dist/as-table-header-cell.d.mts +1 -1
- package/dist/as-table-header-cell.mjs +1 -1
- package/dist/{as-table-header-cell.vue-BjVOEFqz.d.mts → as-table-header-cell.vue-BNsOEsof.d.mts} +1 -1
- package/dist/{as-table-header-cell.vue-qS1Xfc-U.d.cts → as-table-header-cell.vue-DqjorECQ.d.cts} +1 -1
- package/dist/{as-table-root-Bpsrp0Vz.mjs → as-table-root-DGYw0kPC.mjs} +111 -9
- package/dist/{as-table-root-CUDO9ybm.cjs → as-table-root-EyN1JHuS.cjs} +111 -9
- package/dist/as-table-root.cjs +1 -1
- package/dist/as-table-root.d.cts +1 -1
- package/dist/as-table-root.d.mts +1 -1
- package/dist/as-table-root.mjs +1 -1
- package/dist/{as-table-root.vue-szvjZsCn.d.cts → as-table-root.vue-D0XFmTEL.d.mts} +201 -28
- package/dist/{as-table-root.vue-BPU92_Ns.d.mts → as-table-root.vue-Do0j4ibu.d.cts} +202 -29
- package/dist/{as-table-status-B9jlzPPV.mjs → as-table-status-CYzRbU71.mjs} +5 -5
- package/dist/{as-table-status-BgDexT2x.cjs → as-table-status-DMFZuZfJ.cjs} +5 -5
- package/dist/{as-table-BejpMVid.cjs → as-table-ucLFACn0.cjs} +6 -6
- package/dist/as-table.cjs +1 -1
- package/dist/as-table.d.cts +1 -1
- package/dist/as-table.d.mts +1 -1
- package/dist/as-table.mjs +1 -1
- package/dist/{as-table.vue-4WhMA8AM.d.mts → as-table.vue-Dl0nGtMF.d.mts} +5 -5
- package/dist/{as-table.vue-_urybtQj.d.cts → as-table.vue-QQ1aXpJC.d.cts} +5 -5
- package/dist/{as-window-table-S1XWpDHQ.mjs → as-window-table-B9Y4Xgwm.mjs} +11 -7
- package/dist/{as-window-table-CXq6UuUx.cjs → as-window-table-Bxq7cYW5.cjs} +11 -7
- package/dist/as-window-table.cjs +1 -1
- package/dist/as-window-table.d.cts +1 -1
- package/dist/as-window-table.d.mts +1 -1
- package/dist/as-window-table.mjs +1 -1
- package/dist/{as-window-table.vue-h1bdyMv7.d.cts → as-window-table.vue-CdfbFgGs.d.mts} +4 -4
- package/dist/{as-window-table.vue-CWsJvOkL.d.mts → as-window-table.vue-avZGJlCe.d.cts} +4 -4
- package/dist/index.cjs +193 -29
- package/dist/index.d.cts +9 -9
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +186 -31
- package/dist/{types-BZ0HssRY.d.cts → types-CyAmAg10.d.cts} +147 -2
- package/dist/{types-CXz-4dPz.d.mts → types-yS6-QFfT.d.mts} +147 -2
- package/dist/{use-table-Bk-jSxOM.mjs → use-table-BVptAnaS.mjs} +23 -13
- package/dist/{use-table-CdFFqaEx.cjs → use-table-Bm2a0g9D.cjs} +28 -12
- package/dist/{use-table-component-DlLganVc.cjs → use-table-component-Bpy5mg_P.cjs} +1 -1
- package/dist/{use-table-component-KuzZxAP8.mjs → use-table-component-DYzKgCC4.mjs} +1 -1
- package/dist/{use-table-nav-bridge-B9SSEajW.mjs → use-table-nav-bridge-LCL6vq9F.mjs} +1 -1
- package/dist/{use-table-nav-bridge-CVUmTjDr.cjs → use-table-nav-bridge-qyvyRm6S.cjs} +1 -1
- package/dist/{use-table-state-DLJbW753.mjs → use-table-state-CwfgWmuk.mjs} +222 -52
- package/dist/{use-table-state-D6dHOFrA.cjs → use-table-state-jljSQQ8m.cjs} +226 -56
- package/package.json +4 -4
- /package/dist/{as-cell-json-popover-Dkdv5Y9E.mjs → as-cell-json-popover-CH5bAcLE.mjs} +0 -0
- /package/dist/{as-cell-json-popover-BM2QLgfk.cjs → as-cell-json-popover-vty5vMjW.cjs} +0 -0
- /package/dist/{as-column-menu-kTIQfLTi.mjs → as-column-menu-BMTS3DO2.mjs} +0 -0
- /package/dist/{as-column-menu-fZVbJ9lU.cjs → as-column-menu-D_8NxujZ.cjs} +0 -0
- /package/dist/{as-filter-input-BM23TNeh.mjs → as-filter-input-C8KmOus8.mjs} +0 -0
- /package/dist/{as-filter-input-DJu2k9gO.cjs → as-filter-input-DUqpkTkg.cjs} +0 -0
- /package/dist/{error-message-CglODWl4.cjs → error-message-CfKpn_5w.cjs} +0 -0
- /package/dist/{error-message-hPSAu8Ug.mjs → error-message-gNEXnnbb.mjs} +0 -0
- /package/dist/{format-cell-D1Ziv96Q.mjs → format-cell-Bx7wNc4X.mjs} +0 -0
- /package/dist/{format-cell-vCNTh4WZ.cjs → format-cell-DaxV6WIJ.cjs} +0 -0
- /package/dist/{get-cell-value-4rHKP-TG.cjs → get-cell-value-CJT4fk4y.cjs} +0 -0
- /package/dist/{get-cell-value-C8LLc_Rr.mjs → get-cell-value-Cb3X8nUn.mjs} +0 -0
- /package/dist/{use-cell-locale-MQXoONh5.mjs → use-cell-locale-CxQOQsns.mjs} +0 -0
- /package/dist/{use-cell-locale-BGBRQB7s.cjs → use-cell-locale-caG2Fzpc.cjs} +0 -0
- /package/dist/{use-has-emit-listener-hhOH8CBI.cjs → use-has-emit-listener-BaGFZDyM.cjs} +0 -0
- /package/dist/{use-has-emit-listener-BTMDIv2e.mjs → use-has-emit-listener-DrBbsLHQ.mjs} +0 -0
- /package/dist/{use-seed-on-open-Dg9I89fU.cjs → use-seed-on-open-9TSm1Vbv.cjs} +0 -0
- /package/dist/{use-seed-on-open-DO3A1kIb.mjs → use-seed-on-open-DSh4XFyp.mjs} +0 -0
- /package/dist/{use-table-column-handlers-ehreEzcx.cjs → use-table-column-handlers-BMrP0WY2.cjs} +0 -0
- /package/dist/{use-table-column-handlers-CpiiIniD.mjs → use-table-column-handlers-Bx3JERqs.mjs} +0 -0
- /package/dist/{use-table-selection-Cmiu1h4S.cjs → use-table-selection-DtCV3rhu.cjs} +0 -0
- /package/dist/{use-table-selection-C84z4OZy.mjs → use-table-selection-ULbKT2xW.mjs} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_get_cell_value = require("./get-cell-value-CJT4fk4y.cjs");
|
|
1
2
|
let _atscript_ui = require("@atscript/ui");
|
|
2
3
|
let vue = require("vue");
|
|
3
4
|
let _atscript_ui_table = require("@atscript/ui-table");
|
|
@@ -43,18 +44,25 @@ function rowActionGate(row) {
|
|
|
43
44
|
return names ? gateFor(new Set(names)) : null;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
47
|
+
* Walk a `{default, others, rows}` triple once: keep the actions `gate`
|
|
48
|
+
* admits, then run each survivor through `map`. Both are optional — with
|
|
49
|
+
* neither, the input `buckets` reference comes back unchanged so source-array
|
|
50
|
+
* references stay stable downstream (no spurious recomputes in consumers that
|
|
51
|
+
* compare array identity). Shared by the single-row (`applyRowGate`), bulk
|
|
52
|
+
* (`applyRowsGate`) and per-screen-policy paths.
|
|
51
53
|
*/
|
|
52
|
-
function applyGate(buckets, gate) {
|
|
53
|
-
if (!gate) return buckets;
|
|
54
|
+
function applyGate(buckets, gate, map) {
|
|
55
|
+
if (!gate && !map) return buckets;
|
|
56
|
+
const keep = gate ?? (() => true);
|
|
57
|
+
const walk = (list) => {
|
|
58
|
+
const kept = gate ? list.filter(keep) : list;
|
|
59
|
+
return map ? kept.map(map) : kept;
|
|
60
|
+
};
|
|
61
|
+
const def = buckets.default;
|
|
54
62
|
return {
|
|
55
|
-
default:
|
|
56
|
-
others: buckets.others
|
|
57
|
-
rows: buckets.rows
|
|
63
|
+
default: def && keep(def) ? map ? map(def) : def : void 0,
|
|
64
|
+
others: walk(buckets.others),
|
|
65
|
+
rows: walk(buckets.rows)
|
|
58
66
|
};
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
@@ -281,12 +289,16 @@ async function triggerAction(state, action, ctx, event) {
|
|
|
281
289
|
if (input === null) return;
|
|
282
290
|
state.actions.invoke(action, pk, {
|
|
283
291
|
event,
|
|
284
|
-
input
|
|
292
|
+
input,
|
|
293
|
+
row: ctx.row
|
|
285
294
|
});
|
|
286
295
|
return;
|
|
287
296
|
}
|
|
288
297
|
if (!await confirmAction(state, action, ctx)) return;
|
|
289
|
-
state.actions.invoke(action, pk, {
|
|
298
|
+
state.actions.invoke(action, pk, {
|
|
299
|
+
event,
|
|
300
|
+
row: ctx.row
|
|
301
|
+
});
|
|
290
302
|
}
|
|
291
303
|
/**
|
|
292
304
|
* Pick the `pk` argument to forward to `state.actions.invoke` based on the
|
|
@@ -308,6 +320,75 @@ function idsForAction(level, pk) {
|
|
|
308
320
|
return pk === void 0 ? [] : [pk];
|
|
309
321
|
}
|
|
310
322
|
//#endregion
|
|
323
|
+
//#region src/composables/state/row-actions-config.ts
|
|
324
|
+
/** The app definition behind a client-only action, or `undefined` for a server action. */
|
|
325
|
+
function localActionOf(action) {
|
|
326
|
+
return action.$local;
|
|
327
|
+
}
|
|
328
|
+
/** Wrap an app-owned action in the descriptor shape the row-actions cell renders. */
|
|
329
|
+
function toLocalActionInfo(local) {
|
|
330
|
+
return {
|
|
331
|
+
name: local.name,
|
|
332
|
+
label: local.label,
|
|
333
|
+
level: "row",
|
|
334
|
+
processor: "custom",
|
|
335
|
+
value: "",
|
|
336
|
+
icon: local.icon,
|
|
337
|
+
intent: local.intent,
|
|
338
|
+
promptText: local.promptText,
|
|
339
|
+
$local: local
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Render-time href for a row action, whichever kind it is: a client-only
|
|
344
|
+
* action builds its own from the row — still mapped through
|
|
345
|
+
* `state.resolveHref`, so router base paths apply exactly as they do for a
|
|
346
|
+
* server `navigate` action — and a server action goes through
|
|
347
|
+
* {@link actionHref}.
|
|
348
|
+
*/
|
|
349
|
+
function rowActionHref(state, action, id, row) {
|
|
350
|
+
const local = localActionOf(action);
|
|
351
|
+
if (local) return local.href && row !== void 0 ? state.resolveHref(local.href(row)) : void 0;
|
|
352
|
+
return actionHref(state, action, id);
|
|
353
|
+
}
|
|
354
|
+
const EMPTY = Object.freeze([]);
|
|
355
|
+
/** The identity policy — used when no `RowActionsConfig` is wired. */
|
|
356
|
+
const PASS_THROUGH = {
|
|
357
|
+
apply: (buckets) => buckets,
|
|
358
|
+
extra: () => EMPTY
|
|
359
|
+
};
|
|
360
|
+
/** Compile a per-screen {@link RowActionsConfig} into a {@link RowActionsPolicy}. */
|
|
361
|
+
function compileRowActionsConfig(config) {
|
|
362
|
+
if (!config) return PASS_THROUGH;
|
|
363
|
+
const include = config.include ? new Set(config.include) : null;
|
|
364
|
+
const exclude = config.exclude ? new Set(config.exclude) : null;
|
|
365
|
+
const overrides = config.overrides;
|
|
366
|
+
const gate = (a) => (!include || include.has(a.name)) && !exclude?.has(a.name);
|
|
367
|
+
const decorate = overrides ? (action) => {
|
|
368
|
+
const patch = overrides[action.name];
|
|
369
|
+
if (!patch) return action;
|
|
370
|
+
const next = { ...action };
|
|
371
|
+
for (const key of [
|
|
372
|
+
"label",
|
|
373
|
+
"icon",
|
|
374
|
+
"intent",
|
|
375
|
+
"promptText"
|
|
376
|
+
]) {
|
|
377
|
+
const value = patch[key];
|
|
378
|
+
if (value !== void 0) next[key] = value;
|
|
379
|
+
}
|
|
380
|
+
return next;
|
|
381
|
+
} : void 0;
|
|
382
|
+
const locals = (config.extra ?? []).filter((local) => !exclude?.has(local.name));
|
|
383
|
+
return {
|
|
384
|
+
apply: (buckets) => applyGate(buckets, gate, decorate),
|
|
385
|
+
extra: (row) => {
|
|
386
|
+
if (locals.length === 0) return EMPTY;
|
|
387
|
+
return (row === void 0 ? locals : locals.filter((l) => l.enabled?.(row) !== false)).map(toLocalActionInfo);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
//#endregion
|
|
311
392
|
//#region src/composables/state/create-actions.ts
|
|
312
393
|
const REMOVE_NAME = REMOVE_PROCESSOR;
|
|
313
394
|
const REMOVE_DEFAULTS = {
|
|
@@ -340,13 +421,16 @@ function createActions(opts) {
|
|
|
340
421
|
let result;
|
|
341
422
|
try {
|
|
342
423
|
switch (action.processor) {
|
|
343
|
-
case "custom":
|
|
424
|
+
case "custom": {
|
|
425
|
+
const local = localActionOf(action);
|
|
426
|
+
if (local?.onInvoke) await local.onInvoke(callOpts?.row ?? {}, Array.isArray(pk) ? pk[0] : pk);
|
|
344
427
|
result = {
|
|
345
428
|
ok: true,
|
|
346
429
|
kind: "custom",
|
|
347
430
|
dispatched: true
|
|
348
431
|
};
|
|
349
432
|
break;
|
|
433
|
+
}
|
|
350
434
|
case "navigate":
|
|
351
435
|
await opts.client.action(action.name, pk);
|
|
352
436
|
result = {
|
|
@@ -1440,17 +1524,21 @@ const DEFAULT_BLOCK_SIZE = 100;
|
|
|
1440
1524
|
const DEFAULT_DRAG_RELEASE_DEBOUNCE_MS = 300;
|
|
1441
1525
|
const DEFAULT_ITEMS_PER_PAGE = 25;
|
|
1442
1526
|
let _tblUid = 0;
|
|
1527
|
+
/** Shared empty sorter list — keeps `splitSorters` identity-stable. */
|
|
1528
|
+
const EMPTY_SORTERS = Object.freeze([]);
|
|
1443
1529
|
/**
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
* scope so it's not recreated on every fetch.
|
|
1530
|
+
* Build the value reader used for in-memory sorting: a display column's
|
|
1531
|
+
* `sortValue(row)` wins for its own key, everything else reads the row by
|
|
1532
|
+
* path. Returns `getCellValue` itself when no display column defines one.
|
|
1448
1533
|
*/
|
|
1449
|
-
function
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
if (
|
|
1453
|
-
return
|
|
1534
|
+
function createSortValueReader(display) {
|
|
1535
|
+
const map = /* @__PURE__ */ new Map();
|
|
1536
|
+
for (const d of display ?? []) if (d.sortValue) map.set(d.key, d.sortValue);
|
|
1537
|
+
if (map.size === 0) return require_get_cell_value.getCellValue;
|
|
1538
|
+
return (row, field) => {
|
|
1539
|
+
const fn = map.get(field);
|
|
1540
|
+
return fn ? fn(row) : require_get_cell_value.getCellValue(row, field);
|
|
1541
|
+
};
|
|
1454
1542
|
}
|
|
1455
1543
|
/**
|
|
1456
1544
|
* Promise-based dialog slot. A second `request()` while one is open
|
|
@@ -1526,6 +1614,13 @@ function createTableState(opts) {
|
|
|
1526
1614
|
});
|
|
1527
1615
|
const rowDelete = (0, vue.ref)(false);
|
|
1528
1616
|
const includeActions = (0, vue.ref)(false);
|
|
1617
|
+
const rowActions = (0, vue.ref)(void 0);
|
|
1618
|
+
/**
|
|
1619
|
+
* The per-screen row-action policy, compiled once per config change instead
|
|
1620
|
+
* of once per row per render — and read by every surface that renders row
|
|
1621
|
+
* actions, so the cell and the selection toolbar can't drift apart.
|
|
1622
|
+
*/
|
|
1623
|
+
const rowActionsPolicy = (0, vue.computed)(() => compileRowActionsConfig(rowActions.value));
|
|
1529
1624
|
const filters = (0, vue.shallowRef)({});
|
|
1530
1625
|
const results = (0, vue.shallowRef)([]);
|
|
1531
1626
|
const resultsStart = (0, vue.ref)(0);
|
|
@@ -1612,23 +1707,65 @@ function createTableState(opts) {
|
|
|
1612
1707
|
let generation = 0;
|
|
1613
1708
|
let queryDetected = false;
|
|
1614
1709
|
let skipPaginationWatch = 0;
|
|
1615
|
-
|
|
1710
|
+
/**
|
|
1711
|
+
* Paths of client-owned columns — they have no server field behind them, so
|
|
1712
|
+
* they are stripped from `$select` and from `$sort`. Recomputed only when
|
|
1713
|
+
* the column set changes.
|
|
1714
|
+
*/
|
|
1715
|
+
const localColumnPaths = (0, vue.computed)(() => {
|
|
1716
|
+
const out = /* @__PURE__ */ new Set();
|
|
1717
|
+
for (const c of allColumns.value) if (c.local) out.add(c.path);
|
|
1718
|
+
return out;
|
|
1719
|
+
});
|
|
1720
|
+
/**
|
|
1721
|
+
* The active sorters split by who applies them: `server` goes into `$sort`,
|
|
1722
|
+
* `local` targets a client-owned column and is applied in memory. One pass,
|
|
1723
|
+
* one dependency — the two halves are complements.
|
|
1724
|
+
*/
|
|
1725
|
+
const splitSorters = (0, vue.computed)(() => {
|
|
1726
|
+
const paths = localColumnPaths.value;
|
|
1727
|
+
if (paths.size === 0) return {
|
|
1728
|
+
local: EMPTY_SORTERS,
|
|
1729
|
+
server: sorters.value
|
|
1730
|
+
};
|
|
1731
|
+
const local = [];
|
|
1732
|
+
const server = [];
|
|
1733
|
+
for (const s of sorters.value) (paths.has(s.field) ? local : server).push(s);
|
|
1734
|
+
return {
|
|
1735
|
+
local,
|
|
1736
|
+
server
|
|
1737
|
+
};
|
|
1738
|
+
});
|
|
1739
|
+
/** `true` while the query deliberately drops user sorters to keep search relevance. */
|
|
1740
|
+
function sortersIgnored() {
|
|
1741
|
+
return ignoreSortersWhenSearched.value && !!searchTerm.value;
|
|
1742
|
+
}
|
|
1743
|
+
/** Reads the value a sorter orders by — a display column's `sortValue` wins. */
|
|
1744
|
+
const sortValueOf = createSortValueReader(opts.displayColumns);
|
|
1745
|
+
function applyLocalSort(rows) {
|
|
1746
|
+
if (queryOpts?.preSorted) return rows;
|
|
1747
|
+
if (splitSorters.value.local.length === 0 || sortersIgnored()) return rows;
|
|
1748
|
+
return (0, _atscript_ui_table.sortRowsLocally)(rows, queryOpts?.forceSorters?.length ? (0, _atscript_ui_table.mergeSorters)(queryOpts.forceSorters, sorters.value) : sorters.value, sortValueOf);
|
|
1749
|
+
}
|
|
1750
|
+
function buildCurrentQuery(buildOpts) {
|
|
1616
1751
|
const available = tableDef.value?.fetchableFields ?? new Set(allColumns.value.map((c) => c.path));
|
|
1617
1752
|
const extra = /* @__PURE__ */ new Set();
|
|
1618
1753
|
for (const c of columns.value) for (const p of c.selectWith ?? []) if (available.has(p)) extra.add(p);
|
|
1619
1754
|
if (queryOpts?.alwaysSelected) {
|
|
1620
1755
|
for (const p of queryOpts.alwaysSelected) if (available.has(p)) extra.add(p);
|
|
1621
1756
|
}
|
|
1757
|
+
const localPaths = localColumnPaths.value;
|
|
1758
|
+
const requested = buildOpts?.columnPaths ?? columnNames.value;
|
|
1622
1759
|
return (0, _atscript_ui_table.buildTableQuery)({
|
|
1623
|
-
visibleColumnPaths:
|
|
1760
|
+
visibleColumnPaths: localPaths.size ? requested.filter((p) => !localPaths.has(p)) : requested,
|
|
1624
1761
|
extraSelect: extra.size ? [...extra] : void 0,
|
|
1625
|
-
sorters:
|
|
1762
|
+
sorters: splitSorters.value.server,
|
|
1626
1763
|
forceSorters: queryOpts?.forceSorters,
|
|
1627
1764
|
filters: filters.value,
|
|
1628
1765
|
forceFilters: queryOpts?.forceFilters,
|
|
1629
1766
|
search: searchTerm.value || void 0,
|
|
1630
|
-
ignoreSorters:
|
|
1631
|
-
includeActions: includeActions.value
|
|
1767
|
+
ignoreSorters: sortersIgnored(),
|
|
1768
|
+
includeActions: buildOpts?.includeActions ?? includeActions.value
|
|
1632
1769
|
});
|
|
1633
1770
|
}
|
|
1634
1771
|
function dispatchPages(query, page, size) {
|
|
@@ -1646,6 +1783,19 @@ function createTableState(opts) {
|
|
|
1646
1783
|
/** -1 == nothing active. */
|
|
1647
1784
|
const activeIndex = (0, vue.ref)(-1);
|
|
1648
1785
|
const navMode = (0, vue.ref)("pagination");
|
|
1786
|
+
/**
|
|
1787
|
+
* Whether a sorter on a client-owned column does anything right now — the
|
|
1788
|
+
* one rule every surface that renders a sort affordance reads, so the
|
|
1789
|
+
* header and the config dialog cannot disagree about it.
|
|
1790
|
+
*
|
|
1791
|
+
* Sorting a client-owned column happens in memory over the loaded page.
|
|
1792
|
+
* Window mode has no page: it caches rows by absolute index and drops them
|
|
1793
|
+
* as the viewport moves, so behind a server fetcher the order would shift
|
|
1794
|
+
* under the user as they scrolled. `preSorted` is the case where it would
|
|
1795
|
+
* not — the in-memory provider orders the whole dataset before it slices,
|
|
1796
|
+
* so every absolute index arrives already in place.
|
|
1797
|
+
*/
|
|
1798
|
+
const localSortAvailable = (0, vue.computed)(() => navMode.value !== "window" || !!queryOpts?.preSorted);
|
|
1649
1799
|
const isQueryBlocked = (0, vue.computed)(() => {
|
|
1650
1800
|
const blocked = queryOpts?.blockQuery;
|
|
1651
1801
|
return typeof blocked === "function" ? !!blocked() : !!blocked;
|
|
@@ -1840,6 +1990,7 @@ function createTableState(opts) {
|
|
|
1840
1990
|
selectableCount,
|
|
1841
1991
|
selectAll,
|
|
1842
1992
|
rowDelete,
|
|
1993
|
+
rowActions,
|
|
1843
1994
|
includeActions,
|
|
1844
1995
|
activeIndex,
|
|
1845
1996
|
navMode,
|
|
@@ -1870,6 +2021,12 @@ function createTableState(opts) {
|
|
|
1870
2021
|
queryNext,
|
|
1871
2022
|
loadRange,
|
|
1872
2023
|
invalidate,
|
|
2024
|
+
buildQuery: buildCurrentQuery,
|
|
2025
|
+
fetchPage: dispatchPages,
|
|
2026
|
+
localColumnPaths,
|
|
2027
|
+
applyLocalSort,
|
|
2028
|
+
localSortAvailable,
|
|
2029
|
+
rowActionsPolicy,
|
|
1873
2030
|
dataAt,
|
|
1874
2031
|
loadingAt,
|
|
1875
2032
|
errorAt,
|
|
@@ -2028,6 +2185,11 @@ function createTableState(opts) {
|
|
|
2028
2185
|
if ((0, _atscript_ui_table.sortersEqual)(prev, next)) return;
|
|
2029
2186
|
if (searchTerm.value) setIgnoreSortersInternal(false);
|
|
2030
2187
|
if (!queryDetected) return;
|
|
2188
|
+
const paths = localColumnPaths.value;
|
|
2189
|
+
if (paths.size > 0) {
|
|
2190
|
+
const keep = (s) => !paths.has(s.field);
|
|
2191
|
+
if ((0, _atscript_ui_table.sortersEqual)(prev.filter(keep), next.filter(keep))) return;
|
|
2192
|
+
}
|
|
2031
2193
|
requestRefresh();
|
|
2032
2194
|
}, { immediate: false });
|
|
2033
2195
|
(0, vue.watch)(() => searchTerm.value, (next, prev) => {
|
|
@@ -2098,10 +2260,11 @@ function createTableState(opts) {
|
|
|
2098
2260
|
state,
|
|
2099
2261
|
internals: {
|
|
2100
2262
|
init(def) {
|
|
2101
|
-
|
|
2102
|
-
|
|
2263
|
+
const merged = (0, _atscript_ui_table.mergeDisplayColumns)(def.columns, opts.displayColumns ?? []);
|
|
2264
|
+
allColumns.value = merged;
|
|
2265
|
+
const reconciled = (0, _atscript_ui_table.reconcileColumnWidthDefaults)(merged, columnWidths.value);
|
|
2103
2266
|
if (reconciled !== columnWidths.value) columnWidths.value = reconciled;
|
|
2104
|
-
if (columnNames.value.length === 0) columnNames.value =
|
|
2267
|
+
if (columnNames.value.length === 0) columnNames.value = merged.map((c) => c.path);
|
|
2105
2268
|
tableDef.value = def;
|
|
2106
2269
|
},
|
|
2107
2270
|
resetPagination
|
|
@@ -2115,6 +2278,7 @@ function createTableState(opts) {
|
|
|
2115
2278
|
*/
|
|
2116
2279
|
function createStaticTableState(opts) {
|
|
2117
2280
|
let _state = null;
|
|
2281
|
+
let fetcher = null;
|
|
2118
2282
|
const queryFn = (q, page, size) => {
|
|
2119
2283
|
if (!_state) return Promise.resolve({
|
|
2120
2284
|
data: [],
|
|
@@ -2123,13 +2287,21 @@ function createStaticTableState(opts) {
|
|
|
2123
2287
|
itemsPerPage: size,
|
|
2124
2288
|
pages: 1
|
|
2125
2289
|
});
|
|
2126
|
-
|
|
2290
|
+
fetcher ??= buildStaticQueryFn(opts, _state);
|
|
2291
|
+
return fetcher(q, page, size);
|
|
2127
2292
|
};
|
|
2128
2293
|
const result = createTableState({
|
|
2129
2294
|
client: {},
|
|
2130
2295
|
selection: opts.selection,
|
|
2131
2296
|
limit: opts.limit,
|
|
2132
|
-
|
|
2297
|
+
displayColumns: opts.displayColumns,
|
|
2298
|
+
model: opts.model,
|
|
2299
|
+
actions: opts.actions,
|
|
2300
|
+
query: {
|
|
2301
|
+
fn: queryFn,
|
|
2302
|
+
queryOnMount: opts.queryOnMount,
|
|
2303
|
+
preSorted: true
|
|
2304
|
+
}
|
|
2133
2305
|
});
|
|
2134
2306
|
_state = result.state;
|
|
2135
2307
|
result.state.loadingMetadata.value = false;
|
|
@@ -2161,26 +2333,24 @@ function createStaticTableState(opts) {
|
|
|
2161
2333
|
}
|
|
2162
2334
|
function buildStaticQueryFn(opts, state) {
|
|
2163
2335
|
const searchPaths = opts.searchPaths ?? [];
|
|
2336
|
+
const sortValueOf = createSortValueReader(opts.displayColumns);
|
|
2337
|
+
let sortedFrom = null;
|
|
2338
|
+
let sortedBy = null;
|
|
2339
|
+
let sorted = [];
|
|
2340
|
+
function sortedRows(all) {
|
|
2341
|
+
const by = state.sorters.value;
|
|
2342
|
+
if (all !== sortedFrom || by !== sortedBy) {
|
|
2343
|
+
sorted = (0, _atscript_ui_table.sortRowsLocally)(all, by, sortValueOf);
|
|
2344
|
+
sortedFrom = all;
|
|
2345
|
+
sortedBy = by;
|
|
2346
|
+
}
|
|
2347
|
+
return sorted;
|
|
2348
|
+
}
|
|
2164
2349
|
return (_query, page, size) => {
|
|
2165
|
-
|
|
2350
|
+
const all = (0, vue.toValue)(opts.rows);
|
|
2351
|
+
let filtered = opts.localSort === false ? all : sortedRows(all);
|
|
2166
2352
|
const term = state.searchTerm.value.trim().toLowerCase();
|
|
2167
|
-
if (term && searchPaths.length > 0) filtered = filtered.filter((row) => searchPaths.some((p) => cellAsString(row
|
|
2168
|
-
const active = state.sorters.value;
|
|
2169
|
-
if (active.length > 0) filtered = filtered.toSorted((a, b) => {
|
|
2170
|
-
for (const s of active) {
|
|
2171
|
-
const dir = s.direction === "desc" ? -1 : 1;
|
|
2172
|
-
const av = a[s.field];
|
|
2173
|
-
const bv = b[s.field];
|
|
2174
|
-
if (typeof av === "number" && typeof bv === "number") {
|
|
2175
|
-
if (av < bv) return -dir;
|
|
2176
|
-
if (av > bv) return dir;
|
|
2177
|
-
} else {
|
|
2178
|
-
const cmp = cellAsString(av).localeCompare(cellAsString(bv));
|
|
2179
|
-
if (cmp !== 0) return cmp * dir;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
return 0;
|
|
2183
|
-
});
|
|
2353
|
+
if (term && searchPaths.length > 0) filtered = filtered.filter((row) => searchPaths.some((p) => (0, _atscript_ui_table.cellAsString)(require_get_cell_value.getCellValue(row, p)).toLowerCase().includes(term)));
|
|
2184
2354
|
const start = (page - 1) * size;
|
|
2185
2355
|
return Promise.resolve({
|
|
2186
2356
|
data: filtered.slice(start, start + size),
|
|
@@ -2270,12 +2440,6 @@ Object.defineProperty(exports, "ROW_ACTIONS_TYPE", {
|
|
|
2270
2440
|
return ROW_ACTIONS_TYPE;
|
|
2271
2441
|
}
|
|
2272
2442
|
});
|
|
2273
|
-
Object.defineProperty(exports, "actionHref", {
|
|
2274
|
-
enumerable: true,
|
|
2275
|
-
get: function() {
|
|
2276
|
-
return actionHref;
|
|
2277
|
-
}
|
|
2278
|
-
});
|
|
2279
2443
|
Object.defineProperty(exports, "applyRowGate", {
|
|
2280
2444
|
enumerable: true,
|
|
2281
2445
|
get: function() {
|
|
@@ -2372,6 +2536,12 @@ Object.defineProperty(exports, "readPresetLabel", {
|
|
|
2372
2536
|
return readPresetLabel;
|
|
2373
2537
|
}
|
|
2374
2538
|
});
|
|
2539
|
+
Object.defineProperty(exports, "rowActionHref", {
|
|
2540
|
+
enumerable: true,
|
|
2541
|
+
get: function() {
|
|
2542
|
+
return rowActionHref;
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2375
2545
|
Object.defineProperty(exports, "triggerAction", {
|
|
2376
2546
|
enumerable: true,
|
|
2377
2547
|
get: function() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/vue-table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.135",
|
|
4
4
|
"description": "Type-driven table components for Atscript with Vue 3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -162,9 +162,9 @@
|
|
|
162
162
|
"access": "public"
|
|
163
163
|
},
|
|
164
164
|
"dependencies": {
|
|
165
|
-
"@atscript/ui": "^0.1.
|
|
166
|
-
"@atscript/
|
|
167
|
-
"@atscript/
|
|
165
|
+
"@atscript/ui": "^0.1.135",
|
|
166
|
+
"@atscript/ui-table": "^0.1.135",
|
|
167
|
+
"@atscript/vue-form": "^0.1.135"
|
|
168
168
|
},
|
|
169
169
|
"devDependencies": {
|
|
170
170
|
"@atscript/db-client": "^0.1.129",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{use-table-column-handlers-ehreEzcx.cjs → use-table-column-handlers-BMrP0WY2.cjs}
RENAMED
|
File without changes
|
/package/dist/{use-table-column-handlers-CpiiIniD.mjs → use-table-column-handlers-Bx3JERqs.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|