@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
package/dist/index.cjs
CHANGED
|
@@ -1,37 +1,192 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_use_table_state = require("./use-table-state-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const require_as_table = require("./as-table-
|
|
29
|
-
const require_as_table_actions = require("./as-table-actions-
|
|
30
|
-
const require_as_preset_picker = require("./as-preset-picker-
|
|
2
|
+
const require_use_table_state = require("./use-table-state-jljSQQ8m.cjs");
|
|
3
|
+
const require_get_cell_value = require("./get-cell-value-CJT4fk4y.cjs");
|
|
4
|
+
const require_use_table_selection = require("./use-table-selection-DtCV3rhu.cjs");
|
|
5
|
+
const require_use_table = require("./use-table-Bm2a0g9D.cjs");
|
|
6
|
+
const require_use_table_nav_bridge = require("./use-table-nav-bridge-qyvyRm6S.cjs");
|
|
7
|
+
const require_use_table_component = require("./use-table-component-Bpy5mg_P.cjs");
|
|
8
|
+
const require_as_table_root = require("./as-table-root-EyN1JHuS.cjs");
|
|
9
|
+
const require_as_cell_array = require("./as-cell-array-D-8Pqlgo.cjs");
|
|
10
|
+
const require_as_cell_date = require("./as-cell-date-DviMJEqs.cjs");
|
|
11
|
+
const require_use_cell_locale = require("./use-cell-locale-caG2Fzpc.cjs");
|
|
12
|
+
const require_as_cell_json = require("./as-cell-json-CaVB6e7V.cjs");
|
|
13
|
+
const require_as_cell_number = require("./as-cell-number-BnYbxOiG.cjs");
|
|
14
|
+
const require_format_cell = require("./format-cell-DaxV6WIJ.cjs");
|
|
15
|
+
const require_as_cell_union = require("./as-cell-union-BjMP91PS.cjs");
|
|
16
|
+
const require_as_column_menu = require("./as-column-menu-D_8NxujZ.cjs");
|
|
17
|
+
const require_as_config_dialog = require("./as-config-dialog-CP362FP3.cjs");
|
|
18
|
+
const require_as_confirm_dialog = require("./as-confirm-dialog-D41XaN_P.cjs");
|
|
19
|
+
const require_as_filter_input = require("./as-filter-input-DUqpkTkg.cjs");
|
|
20
|
+
const require_as_filter_dialog = require("./as-filter-dialog-BCUqpKPd.cjs");
|
|
21
|
+
const require_as_table_header_cell = require("./as-table-header-cell-Ct_GPLVu.cjs");
|
|
22
|
+
const require_as_window_table = require("./as-window-table-Bxq7cYW5.cjs");
|
|
23
|
+
const require_as_filter_field = require("./as-filter-field-D3jSbSwB.cjs");
|
|
24
|
+
const require_as_filters = require("./as-filters-Dp93OWRS.cjs");
|
|
25
|
+
const require_as_preset_dialog = require("./as-preset-dialog-pusPD935.cjs");
|
|
26
|
+
const require_as_row_actions = require("./as-row-actions-PD-sFmDs.cjs");
|
|
27
|
+
const require_as_table_cell_value = require("./as-table-cell-value-BAi5yadc.cjs");
|
|
28
|
+
const require_as_table = require("./as-table-ucLFACn0.cjs");
|
|
29
|
+
const require_as_table_actions = require("./as-table-actions-D_PUqMYy.cjs");
|
|
30
|
+
const require_as_preset_picker = require("./as-preset-picker-nAx3MYl7.cjs");
|
|
31
31
|
let _atscript_ui = require("@atscript/ui");
|
|
32
32
|
let vue = require("vue");
|
|
33
33
|
let _atscript_ui_table = require("@atscript/ui-table");
|
|
34
34
|
let _vueuse_core = require("@vueuse/core");
|
|
35
|
+
//#region src/composables/use-table-export.ts
|
|
36
|
+
/**
|
|
37
|
+
* Export the table's data as it is queried right now.
|
|
38
|
+
*
|
|
39
|
+
* The export snapshots the table's own query at call time — the same filters,
|
|
40
|
+
* sorters, search term, force-filters and `$select` projection the on-screen
|
|
41
|
+
* fetch uses (`state.buildQuery()`), through the same fetch path
|
|
42
|
+
* (`state.fetchPage()`, so a custom `queryFn` is honoured) — then pages
|
|
43
|
+
* through every result instead of one page. The primary key(s) are appended
|
|
44
|
+
* to the sort as a tiebreaker so pages never overlap or skip.
|
|
45
|
+
*
|
|
46
|
+
* Values come out of the same column metadata the cells read: union/enum keys
|
|
47
|
+
* become their labels, dates become ISO strings, arrays join. Override per
|
|
48
|
+
* column with `formatters`, or globally with `formatCell`.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const { exportRows } = useTableExport()
|
|
52
|
+
* downloadExport(await exportRows({ filename: "orders.csv", csv: { bom: true } }))
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Since 0.1.134.
|
|
56
|
+
*/
|
|
57
|
+
function useTableExport(ctx) {
|
|
58
|
+
const state = (ctx ?? require_use_table_state.useTableContext()).state;
|
|
59
|
+
const progress = (0, vue.ref)(null);
|
|
60
|
+
const exporting = (0, vue.computed)(() => progress.value !== null);
|
|
61
|
+
function resolveColumns(selection, opts) {
|
|
62
|
+
if (selection && selection !== "visible") {
|
|
63
|
+
const byPath = new Map(state.allColumns.value.map((c) => [c.path, c]));
|
|
64
|
+
return selection.map((path) => byPath.get(path) ?? rawColumn(path));
|
|
65
|
+
}
|
|
66
|
+
const local = state.localColumnPaths.value;
|
|
67
|
+
const visible = state.columns.value;
|
|
68
|
+
if (local.size === 0) return visible;
|
|
69
|
+
return visible.filter((c) => !local.has(c.path) || opts.formatters?.[c.path]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One value resolver per column, built once per run: the formatter lookup
|
|
73
|
+
* and the union-option index happen here instead of per cell.
|
|
74
|
+
*/
|
|
75
|
+
function resolversFor(columns, opts) {
|
|
76
|
+
return columns.map((column) => {
|
|
77
|
+
const perColumn = opts.formatters?.[column.path];
|
|
78
|
+
const formatCell = opts.formatCell;
|
|
79
|
+
const labels = column.options?.length ? new Map(column.options.map((o) => [o.key, o.label])) : null;
|
|
80
|
+
return (row) => {
|
|
81
|
+
const raw = require_get_cell_value.getCellValue(row, column.path);
|
|
82
|
+
if (perColumn) {
|
|
83
|
+
const out = perColumn(raw, column, row);
|
|
84
|
+
if (out !== void 0) return out;
|
|
85
|
+
}
|
|
86
|
+
if (formatCell) {
|
|
87
|
+
const out = formatCell(raw, column, row);
|
|
88
|
+
if (out !== void 0) return out;
|
|
89
|
+
}
|
|
90
|
+
if (labels !== null && (typeof raw === "string" || typeof raw === "number")) {
|
|
91
|
+
const hit = labels.get(String(raw));
|
|
92
|
+
if (hit !== void 0) return hit;
|
|
93
|
+
}
|
|
94
|
+
return (0, _atscript_ui_table.resolveExportValue)(raw);
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async function exportRows(opts = {}) {
|
|
99
|
+
if (progress.value !== null) throw new Error("[vue-table] exportRows() is already running on this handle.");
|
|
100
|
+
const columns = resolveColumns(opts.columns, opts);
|
|
101
|
+
const columnPaths = columns.map((c) => c.path);
|
|
102
|
+
const query = (0, _atscript_ui_table.withStableOrder)(state.buildQuery({
|
|
103
|
+
columnPaths,
|
|
104
|
+
includeActions: false
|
|
105
|
+
}), state.tableDef.value?.primaryKeys ?? []);
|
|
106
|
+
const resolvers = resolversFor(columns, opts);
|
|
107
|
+
progress.value = { done: 0 };
|
|
108
|
+
try {
|
|
109
|
+
const { rows: matrix, total } = await (0, _atscript_ui_table.collectExportRows)({
|
|
110
|
+
query,
|
|
111
|
+
pageSize: opts.pageSize,
|
|
112
|
+
maxRows: opts.maxRows,
|
|
113
|
+
signal: opts.signal,
|
|
114
|
+
fetchPage: state.fetchPage,
|
|
115
|
+
mapRow: (row) => resolvers.map((resolve) => resolve(row)),
|
|
116
|
+
onProgress: (done, reported) => {
|
|
117
|
+
progress.value = {
|
|
118
|
+
done,
|
|
119
|
+
total: reported
|
|
120
|
+
};
|
|
121
|
+
opts.onProgress?.(done, reported);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
const header = columns.map((c) => c.label || c.path);
|
|
125
|
+
const base = {
|
|
126
|
+
columns: header,
|
|
127
|
+
columnPaths,
|
|
128
|
+
rowCount: matrix.length,
|
|
129
|
+
total
|
|
130
|
+
};
|
|
131
|
+
if (opts.format === "rows") return {
|
|
132
|
+
...base,
|
|
133
|
+
format: "rows",
|
|
134
|
+
rows: matrix
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
...base,
|
|
138
|
+
format: "csv",
|
|
139
|
+
filename: withCsvSuffix(opts.filename ?? "export.csv"),
|
|
140
|
+
csv: (0, _atscript_ui_table.toCsv)(header, matrix, opts.csv)
|
|
141
|
+
};
|
|
142
|
+
} finally {
|
|
143
|
+
progress.value = null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
exportRows,
|
|
148
|
+
exporting,
|
|
149
|
+
progress
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Hand a finished CSV export to the browser as a file download. Returns
|
|
154
|
+
* `false` without doing anything when there is no DOM (SSR / a worker), so a
|
|
155
|
+
* server render can call it unguarded.
|
|
156
|
+
*
|
|
157
|
+
* Since 0.1.134.
|
|
158
|
+
*/
|
|
159
|
+
function downloadExport(result) {
|
|
160
|
+
if (result.format !== "csv") throw new Error("[vue-table] downloadExport() needs a `format: 'csv'` export result.");
|
|
161
|
+
if (typeof document === "undefined" || typeof URL?.createObjectURL !== "function") return false;
|
|
162
|
+
const blob = new Blob([result.csv], { type: "text/csv;charset=utf-8" });
|
|
163
|
+
const href = URL.createObjectURL(blob);
|
|
164
|
+
const anchor = document.createElement("a");
|
|
165
|
+
anchor.href = href;
|
|
166
|
+
anchor.download = result.filename;
|
|
167
|
+
anchor.style.display = "none";
|
|
168
|
+
document.body.appendChild(anchor);
|
|
169
|
+
anchor.click();
|
|
170
|
+
anchor.remove();
|
|
171
|
+
URL.revokeObjectURL(href);
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
function withCsvSuffix(name) {
|
|
175
|
+
return name.toLowerCase().endsWith(".csv") ? name : `${name}.csv`;
|
|
176
|
+
}
|
|
177
|
+
/** Minimal column for an export path that is not one of the table's columns. */
|
|
178
|
+
function rawColumn(path) {
|
|
179
|
+
return {
|
|
180
|
+
path,
|
|
181
|
+
label: path,
|
|
182
|
+
type: "text",
|
|
183
|
+
sortable: false,
|
|
184
|
+
filterable: false,
|
|
185
|
+
nullable: true,
|
|
186
|
+
order: 0
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
35
190
|
//#region src/composables/use-table-filter.ts
|
|
36
191
|
/**
|
|
37
192
|
* Per-field filter state composable.
|
|
@@ -552,6 +707,12 @@ exports.AsTableCellValue = require_as_table_cell_value.as_table_cell_value_defau
|
|
|
552
707
|
exports.AsTableHeaderCell = require_as_table_header_cell.as_table_header_cell_default;
|
|
553
708
|
exports.AsTableRoot = require_as_table_root.as_table_root_default;
|
|
554
709
|
exports.AsWindowTable = require_as_window_table.as_window_table_default;
|
|
710
|
+
Object.defineProperty(exports, "ExportAbortError", {
|
|
711
|
+
enumerable: true,
|
|
712
|
+
get: function() {
|
|
713
|
+
return _atscript_ui_table.ExportAbortError;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
555
716
|
Object.defineProperty(exports, "PRESET_ASPECTS", {
|
|
556
717
|
enumerable: true,
|
|
557
718
|
get: function() {
|
|
@@ -575,6 +736,7 @@ exports.createDefaultCellTypes = createDefaultCellTypes;
|
|
|
575
736
|
exports.createDefaultControls = createDefaultControls;
|
|
576
737
|
exports.createStaticTableState = require_use_table_state.createStaticTableState;
|
|
577
738
|
exports.createTableState = require_use_table_state.createTableState;
|
|
739
|
+
exports.downloadExport = downloadExport;
|
|
578
740
|
exports.extractIdentifier = require_use_table_state.extractIdentifier;
|
|
579
741
|
exports.formatCellValue = require_format_cell.formatCellValue;
|
|
580
742
|
exports.getCellValue = require_get_cell_value.getCellValue;
|
|
@@ -593,6 +755,7 @@ Object.defineProperty(exports, "isSystemPresetId", {
|
|
|
593
755
|
}
|
|
594
756
|
});
|
|
595
757
|
exports.provideCellLocale = require_use_cell_locale.provideCellLocale;
|
|
758
|
+
exports.provideTableContext = require_use_table_state.provideTableContext;
|
|
596
759
|
Object.defineProperty(exports, "resetDefaultClientFactory", {
|
|
597
760
|
enumerable: true,
|
|
598
761
|
get: function() {
|
|
@@ -620,6 +783,7 @@ exports.useTableActions = useTableActions;
|
|
|
620
783
|
exports.useTableComponent = require_use_table_component.useTableComponent;
|
|
621
784
|
exports.useTableContext = require_use_table_state.useTableContext;
|
|
622
785
|
exports.useTableContextOptional = require_use_table_state.useTableContextOptional;
|
|
786
|
+
exports.useTableExport = useTableExport;
|
|
623
787
|
exports.useTableFilter = useTableFilter;
|
|
624
788
|
exports.useTableNavBridge = require_use_table_nav_bridge.useTableNavBridge;
|
|
625
789
|
exports.useTableSearch = useTableSearch;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { t as _default$11 } from "./as-filters.vue-DcxDnWAU.cjs";
|
|
2
2
|
import { t as _default$13 } from "./as-preset-picker.vue-DfXS3pGl.cjs";
|
|
3
|
-
import { S as
|
|
4
|
-
import { t as _default$16 } from "./as-table-actions.vue-
|
|
5
|
-
import { $ as
|
|
6
|
-
import { t as _default$15 } from "./as-table.vue-
|
|
7
|
-
import { t as _default$20 } from "./as-window-table.vue-
|
|
3
|
+
import { C as TableActionsState, S as TVueTableActionInfo, T as extractIdentifier, _ as RowHookContext, b as TAsCellTypeComponents, c as MainActionRequest, d as QueryErrorKind, f as ReactiveTableState, g as RowDeleteOpt, h as RowClassHook, l as NavKeyOptions, m as RowAttrsHook, n as ColumnMenuConfig, o as InvokeOpts, p as RowActionsConfig, r as ConfigTab, s as LocalRowAction, t as ActionResult, v as RowSelectableHook, w as TableNavBridge, x as TAsTableControls, y as RowSelectableVerdict } from "./types-CyAmAg10.cjs";
|
|
4
|
+
import { t as _default$16 } from "./as-table-actions.vue-iKw4tsJh.cjs";
|
|
5
|
+
import { $ as useTableExport, A as CellLocale, B as injectPresetsApp, C as isSystemPresetId, Ct as UseLocalDraftReturn, D as formatCellValue, E as setDefaultClientFactory, F as useTableComponent, G as useTableFilter, H as useTableUrlQuery, I as UseAppPrefsOptions, J as ExportProgress, K as useTableNavBridge, L as UseAppPrefsReturn, M as useCellLocale, N as createDefaultCellTypes, O as getCellValue, P as createDefaultControls, Q as downloadExport, R as useAppPrefs, S as getDefaultClientFactory, St as UseLocalDraftOptions, T as resolveSystemPresets, U as useTableActions, V as UseTableUrlQueryOptions, W as useTableSearch, X as ExportRowsOptions, Y as ExportResult, Z as UseTableExportReturn, _ as SYSTEM_PRESET_PREFIX, _t as ActivePresetView, a as CsvOptions, at as BuildQueryOptions, b as UrlQuerySync, bt as usePresets, c as ExportScalar, ct as QueryFn, d as PresetCapabilities, dt as TableStateInternals, et as UseTableOptions, f as PresetData, ft as createStaticTableState, g as STANDARD_PRESET_ID, gt as useTableContextOptional, h as QueryOptions, ht as useTableContext, i as ClientFactory, it as useTableSelection, j as provideCellLocale, k as getColumnWidth, l as PRESET_ASPECTS, lt as TableContext, m as PresetSnapshotWire, mt as provideTableContext, n as AppConfData, nt as useTable, o as DisplayColumnDef, ot as CreateStaticTableStateOptions, p as PresetSnapshot, pt as createTableState, q as ExportCellFormatter, r as AsPresetEntryRow, rt as SelectionPersistence, s as ExportAbortError, st as CreateTableStateOptions, t as _default$19, tt as clearTableCache, u as PresetAspect, ut as TableModelRefs, v as SystemPreset, vt as UsePresetsOptions, w as resetDefaultClientFactory, wt as useLocalDraft, x as UserConfData, xt as StorageLike, y as SystemPresetInput, yt as UsePresetsReturn, z as AS_PRESETS_APP } from "./as-table-root.vue-Do0j4ibu.cjs";
|
|
6
|
+
import { t as _default$15 } from "./as-table.vue-QQ1aXpJC.cjs";
|
|
7
|
+
import { t as _default$20 } from "./as-window-table.vue-avZGJlCe.cjs";
|
|
8
8
|
import { t as _default } from "./as-cell-array.vue-pFs5GcCR.cjs";
|
|
9
9
|
import { t as _default$1 } from "./as-cell-date.vue-BBSps2B2.cjs";
|
|
10
10
|
import { t as _default$2 } from "./as-cell-json.vue-C6wg4ARZ.cjs";
|
|
11
11
|
import { t as _default$3 } from "./as-cell-number.vue-CJ2K5zeM.cjs";
|
|
12
12
|
import { t as _default$4 } from "./as-cell-union.vue-CslPM_c2.cjs";
|
|
13
|
-
import { t as _default$5 } from "./as-column-menu.vue-
|
|
13
|
+
import { t as _default$5 } from "./as-column-menu.vue-CDlI4-Cz.cjs";
|
|
14
14
|
import { t as _default$6 } from "./as-config-dialog.vue-DvvJi3xx.cjs";
|
|
15
15
|
import { t as _default$7 } from "./as-confirm-dialog.vue-CXxLpzbu.cjs";
|
|
16
16
|
import { t as _default$8 } from "./as-filter-dialog.vue-BV2J8PgZ.cjs";
|
|
17
17
|
import { t as _default$9 } from "./as-filter-field.vue-ByQ8xIGq.cjs";
|
|
18
18
|
import { t as _default$10 } from "./as-filter-input.vue-CS4nOk_Q.cjs";
|
|
19
19
|
import { t as _default$12 } from "./as-preset-dialog.vue-DP9fy00Y.cjs";
|
|
20
|
-
import { t as _default$14 } from "./as-row-actions.vue-
|
|
20
|
+
import { t as _default$14 } from "./as-row-actions.vue-D0MXQoeg.cjs";
|
|
21
21
|
import { t as _default$17 } from "./as-table-cell-value.vue-BgFDv2JQ.cjs";
|
|
22
|
-
import { t as _default$18 } from "./as-table-header-cell.vue-
|
|
23
|
-
export { AS_PRESETS_APP, ActionResult, ActivePresetView, AppConfData, _default as AsCellArray, _default$1 as AsCellDate, _default$2 as AsCellJson, _default$3 as AsCellNumber, _default$4 as AsCellUnion, _default$5 as AsColumnMenu, _default$6 as AsConfigDialog, _default$7 as AsConfirmDialog, _default$8 as AsFilterDialog, _default$9 as AsFilterField, _default$10 as AsFilterInput, _default$11 as AsFilters, _default$12 as AsPresetDialog, AsPresetEntryRow, _default$13 as AsPresetPicker, _default$14 as AsRowActions, _default$15 as AsTable, _default$16 as AsTableActions, _default$17 as AsTableCellValue, _default$18 as AsTableHeaderCell, _default$19 as AsTableRoot, _default$20 as AsWindowTable, CellLocale, ClientFactory, ColumnMenuConfig, ConfigTab, CreateStaticTableStateOptions, CreateTableStateOptions, InvokeOpts, MainActionRequest, NavKeyOptions, PRESET_ASPECTS, PresetAspect, PresetCapabilities, PresetData, PresetSnapshot, PresetSnapshotWire, QueryErrorKind, QueryOptions, ReactiveTableState, RowAttrsHook, RowClassHook, RowDeleteOpt, RowHookContext, RowSelectableHook, RowSelectableVerdict, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, SelectionPersistence, StorageLike, SystemPreset, SystemPresetInput, TAsCellTypeComponents, TAsTableControls, TVueTableActionInfo, TableActionsState, TableContext, TableNavBridge, TableStateInternals, UrlQuerySync, UseAppPrefsOptions, UseAppPrefsReturn, UseLocalDraftOptions, UseLocalDraftReturn, UsePresetsOptions, UsePresetsReturn, UseTableOptions, UseTableUrlQueryOptions, UserConfData, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|
|
22
|
+
import { t as _default$18 } from "./as-table-header-cell.vue-DqjorECQ.cjs";
|
|
23
|
+
export { AS_PRESETS_APP, ActionResult, ActivePresetView, AppConfData, _default as AsCellArray, _default$1 as AsCellDate, _default$2 as AsCellJson, _default$3 as AsCellNumber, _default$4 as AsCellUnion, _default$5 as AsColumnMenu, _default$6 as AsConfigDialog, _default$7 as AsConfirmDialog, _default$8 as AsFilterDialog, _default$9 as AsFilterField, _default$10 as AsFilterInput, _default$11 as AsFilters, _default$12 as AsPresetDialog, AsPresetEntryRow, _default$13 as AsPresetPicker, _default$14 as AsRowActions, _default$15 as AsTable, _default$16 as AsTableActions, _default$17 as AsTableCellValue, _default$18 as AsTableHeaderCell, _default$19 as AsTableRoot, _default$20 as AsWindowTable, BuildQueryOptions, CellLocale, ClientFactory, ColumnMenuConfig, ConfigTab, CreateStaticTableStateOptions, CreateTableStateOptions, CsvOptions, DisplayColumnDef, ExportAbortError, ExportCellFormatter, ExportProgress, ExportResult, ExportRowsOptions, ExportScalar, InvokeOpts, LocalRowAction, MainActionRequest, NavKeyOptions, PRESET_ASPECTS, PresetAspect, PresetCapabilities, PresetData, PresetSnapshot, PresetSnapshotWire, QueryErrorKind, QueryFn, QueryOptions, ReactiveTableState, RowActionsConfig, RowAttrsHook, RowClassHook, RowDeleteOpt, RowHookContext, RowSelectableHook, RowSelectableVerdict, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, SelectionPersistence, StorageLike, SystemPreset, SystemPresetInput, TAsCellTypeComponents, TAsTableControls, TVueTableActionInfo, TableActionsState, TableContext, TableModelRefs, TableNavBridge, TableStateInternals, UrlQuerySync, UseAppPrefsOptions, UseAppPrefsReturn, UseLocalDraftOptions, UseLocalDraftReturn, UsePresetsOptions, UsePresetsReturn, UseTableExportReturn, UseTableOptions, UseTableUrlQueryOptions, UserConfData, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, downloadExport, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, provideTableContext, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableExport, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { t as _default$11 } from "./as-filters.vue-BG_ysCkC.mjs";
|
|
2
2
|
import { t as _default$13 } from "./as-preset-picker.vue-BPjsiaVt.mjs";
|
|
3
|
-
import { S as
|
|
4
|
-
import { t as _default$16 } from "./as-table-actions.vue-
|
|
5
|
-
import { $ as
|
|
6
|
-
import { t as _default$15 } from "./as-table.vue-
|
|
7
|
-
import { t as _default$20 } from "./as-window-table.vue-
|
|
3
|
+
import { C as TableActionsState, S as TVueTableActionInfo, T as extractIdentifier, _ as RowHookContext, b as TAsCellTypeComponents, c as MainActionRequest, d as QueryErrorKind, f as ReactiveTableState, g as RowDeleteOpt, h as RowClassHook, l as NavKeyOptions, m as RowAttrsHook, n as ColumnMenuConfig, o as InvokeOpts, p as RowActionsConfig, r as ConfigTab, s as LocalRowAction, t as ActionResult, v as RowSelectableHook, w as TableNavBridge, x as TAsTableControls, y as RowSelectableVerdict } from "./types-yS6-QFfT.mjs";
|
|
4
|
+
import { t as _default$16 } from "./as-table-actions.vue-kndyFTyi.mjs";
|
|
5
|
+
import { $ as useTableExport, A as CellLocale, B as injectPresetsApp, C as isSystemPresetId, Ct as UseLocalDraftReturn, D as formatCellValue, E as setDefaultClientFactory, F as useTableComponent, G as useTableFilter, H as useTableUrlQuery, I as UseAppPrefsOptions, J as ExportProgress, K as useTableNavBridge, L as UseAppPrefsReturn, M as useCellLocale, N as createDefaultCellTypes, O as getCellValue, P as createDefaultControls, Q as downloadExport, R as useAppPrefs, S as getDefaultClientFactory, St as UseLocalDraftOptions, T as resolveSystemPresets, U as useTableActions, V as UseTableUrlQueryOptions, W as useTableSearch, X as ExportRowsOptions, Y as ExportResult, Z as UseTableExportReturn, _ as SYSTEM_PRESET_PREFIX, _t as ActivePresetView, a as CsvOptions, at as BuildQueryOptions, b as UrlQuerySync, bt as usePresets, c as ExportScalar, ct as QueryFn, d as PresetCapabilities, dt as TableStateInternals, et as UseTableOptions, f as PresetData, ft as createStaticTableState, g as STANDARD_PRESET_ID, gt as useTableContextOptional, h as QueryOptions, ht as useTableContext, i as ClientFactory, it as useTableSelection, j as provideCellLocale, k as getColumnWidth, l as PRESET_ASPECTS, lt as TableContext, m as PresetSnapshotWire, mt as provideTableContext, n as AppConfData, nt as useTable, o as DisplayColumnDef, ot as CreateStaticTableStateOptions, p as PresetSnapshot, pt as createTableState, q as ExportCellFormatter, r as AsPresetEntryRow, rt as SelectionPersistence, s as ExportAbortError, st as CreateTableStateOptions, t as _default$19, tt as clearTableCache, u as PresetAspect, ut as TableModelRefs, v as SystemPreset, vt as UsePresetsOptions, w as resetDefaultClientFactory, wt as useLocalDraft, x as UserConfData, xt as StorageLike, y as SystemPresetInput, yt as UsePresetsReturn, z as AS_PRESETS_APP } from "./as-table-root.vue-D0XFmTEL.mjs";
|
|
6
|
+
import { t as _default$15 } from "./as-table.vue-Dl0nGtMF.mjs";
|
|
7
|
+
import { t as _default$20 } from "./as-window-table.vue-CdfbFgGs.mjs";
|
|
8
8
|
import { t as _default } from "./as-cell-array.vue-D4vS7C_D.mjs";
|
|
9
9
|
import { t as _default$1 } from "./as-cell-date.vue-Chs7WTZ9.mjs";
|
|
10
10
|
import { t as _default$2 } from "./as-cell-json.vue-C0_LDvQw.mjs";
|
|
11
11
|
import { t as _default$3 } from "./as-cell-number.vue-BBF0OuU8.mjs";
|
|
12
12
|
import { t as _default$4 } from "./as-cell-union.vue-CL-Lf-Rm.mjs";
|
|
13
|
-
import { t as _default$5 } from "./as-column-menu.vue-
|
|
13
|
+
import { t as _default$5 } from "./as-column-menu.vue-BaIGUOhP.mjs";
|
|
14
14
|
import { t as _default$6 } from "./as-config-dialog.vue-BvFZZRuY.mjs";
|
|
15
15
|
import { t as _default$7 } from "./as-confirm-dialog.vue-Cz52-v6c.mjs";
|
|
16
16
|
import { t as _default$8 } from "./as-filter-dialog.vue-likNLqzF.mjs";
|
|
17
17
|
import { t as _default$9 } from "./as-filter-field.vue-BbXLhd6O.mjs";
|
|
18
18
|
import { t as _default$10 } from "./as-filter-input.vue-B9ma2l9j.mjs";
|
|
19
19
|
import { t as _default$12 } from "./as-preset-dialog.vue-BRjjfPty.mjs";
|
|
20
|
-
import { t as _default$14 } from "./as-row-actions.vue-
|
|
20
|
+
import { t as _default$14 } from "./as-row-actions.vue-AXXt5kQS.mjs";
|
|
21
21
|
import { t as _default$17 } from "./as-table-cell-value.vue-kfNgVhzn.mjs";
|
|
22
|
-
import { t as _default$18 } from "./as-table-header-cell.vue-
|
|
23
|
-
export { AS_PRESETS_APP, ActionResult, ActivePresetView, AppConfData, _default as AsCellArray, _default$1 as AsCellDate, _default$2 as AsCellJson, _default$3 as AsCellNumber, _default$4 as AsCellUnion, _default$5 as AsColumnMenu, _default$6 as AsConfigDialog, _default$7 as AsConfirmDialog, _default$8 as AsFilterDialog, _default$9 as AsFilterField, _default$10 as AsFilterInput, _default$11 as AsFilters, _default$12 as AsPresetDialog, AsPresetEntryRow, _default$13 as AsPresetPicker, _default$14 as AsRowActions, _default$15 as AsTable, _default$16 as AsTableActions, _default$17 as AsTableCellValue, _default$18 as AsTableHeaderCell, _default$19 as AsTableRoot, _default$20 as AsWindowTable, CellLocale, ClientFactory, ColumnMenuConfig, ConfigTab, CreateStaticTableStateOptions, CreateTableStateOptions, InvokeOpts, MainActionRequest, NavKeyOptions, PRESET_ASPECTS, PresetAspect, PresetCapabilities, PresetData, PresetSnapshot, PresetSnapshotWire, QueryErrorKind, QueryOptions, ReactiveTableState, RowAttrsHook, RowClassHook, RowDeleteOpt, RowHookContext, RowSelectableHook, RowSelectableVerdict, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, SelectionPersistence, StorageLike, SystemPreset, SystemPresetInput, TAsCellTypeComponents, TAsTableControls, TVueTableActionInfo, TableActionsState, TableContext, TableNavBridge, TableStateInternals, UrlQuerySync, UseAppPrefsOptions, UseAppPrefsReturn, UseLocalDraftOptions, UseLocalDraftReturn, UsePresetsOptions, UsePresetsReturn, UseTableOptions, UseTableUrlQueryOptions, UserConfData, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|
|
22
|
+
import { t as _default$18 } from "./as-table-header-cell.vue-BNsOEsof.mjs";
|
|
23
|
+
export { AS_PRESETS_APP, ActionResult, ActivePresetView, AppConfData, _default as AsCellArray, _default$1 as AsCellDate, _default$2 as AsCellJson, _default$3 as AsCellNumber, _default$4 as AsCellUnion, _default$5 as AsColumnMenu, _default$6 as AsConfigDialog, _default$7 as AsConfirmDialog, _default$8 as AsFilterDialog, _default$9 as AsFilterField, _default$10 as AsFilterInput, _default$11 as AsFilters, _default$12 as AsPresetDialog, AsPresetEntryRow, _default$13 as AsPresetPicker, _default$14 as AsRowActions, _default$15 as AsTable, _default$16 as AsTableActions, _default$17 as AsTableCellValue, _default$18 as AsTableHeaderCell, _default$19 as AsTableRoot, _default$20 as AsWindowTable, BuildQueryOptions, CellLocale, ClientFactory, ColumnMenuConfig, ConfigTab, CreateStaticTableStateOptions, CreateTableStateOptions, CsvOptions, DisplayColumnDef, ExportAbortError, ExportCellFormatter, ExportProgress, ExportResult, ExportRowsOptions, ExportScalar, InvokeOpts, LocalRowAction, MainActionRequest, NavKeyOptions, PRESET_ASPECTS, PresetAspect, PresetCapabilities, PresetData, PresetSnapshot, PresetSnapshotWire, QueryErrorKind, QueryFn, QueryOptions, ReactiveTableState, RowActionsConfig, RowAttrsHook, RowClassHook, RowDeleteOpt, RowHookContext, RowSelectableHook, RowSelectableVerdict, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, SelectionPersistence, StorageLike, SystemPreset, SystemPresetInput, TAsCellTypeComponents, TAsTableControls, TVueTableActionInfo, TableActionsState, TableContext, TableModelRefs, TableNavBridge, TableStateInternals, UrlQuerySync, UseAppPrefsOptions, UseAppPrefsReturn, UseLocalDraftOptions, UseLocalDraftReturn, UsePresetsOptions, UsePresetsReturn, UseTableExportReturn, UseTableOptions, UseTableUrlQueryOptions, UserConfData, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, downloadExport, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, provideTableContext, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableExport, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,191 @@
|
|
|
1
|
-
import { D as ROW_ACTIONS_TYPE, a as useTableContext, b as extractIdentifier, n as createTableState, o as useTableContextOptional, t as createStaticTableState } from "./use-table-state-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as
|
|
16
|
-
import { t as
|
|
17
|
-
import { t as
|
|
18
|
-
import { t as
|
|
19
|
-
import { t as
|
|
20
|
-
import { t as
|
|
21
|
-
import { t as
|
|
22
|
-
import { t as
|
|
23
|
-
import { t as
|
|
24
|
-
import { t as
|
|
25
|
-
import { t as
|
|
26
|
-
import { t as
|
|
27
|
-
import { t as as_table_default } from "./as-table-
|
|
28
|
-
import { t as as_table_actions_default } from "./as-table-actions-
|
|
29
|
-
import { t as as_preset_picker_default } from "./as-preset-picker-
|
|
1
|
+
import { D as ROW_ACTIONS_TYPE, a as useTableContext, b as extractIdentifier, n as createTableState, o as useTableContextOptional, r as provideTableContext, t as createStaticTableState } from "./use-table-state-CwfgWmuk.mjs";
|
|
2
|
+
import { t as getCellValue } from "./get-cell-value-Cb3X8nUn.mjs";
|
|
3
|
+
import { n as useTableSelection } from "./use-table-selection-ULbKT2xW.mjs";
|
|
4
|
+
import { a as useLocalDraft, i as usePresets, o as AS_PRESETS_APP, r as useTable, s as injectPresetsApp, t as clearTableCache } from "./use-table-BVptAnaS.mjs";
|
|
5
|
+
import { t as useTableNavBridge } from "./use-table-nav-bridge-LCL6vq9F.mjs";
|
|
6
|
+
import { t as useTableComponent } from "./use-table-component-DYzKgCC4.mjs";
|
|
7
|
+
import { t as as_table_root_default } from "./as-table-root-DGYw0kPC.mjs";
|
|
8
|
+
import { t as as_cell_array_default } from "./as-cell-array-BWHkJX3I.mjs";
|
|
9
|
+
import { t as as_cell_date_default } from "./as-cell-date-mGlnDeLP.mjs";
|
|
10
|
+
import { n as useCellLocale, t as provideCellLocale } from "./use-cell-locale-CxQOQsns.mjs";
|
|
11
|
+
import { t as as_cell_json_default } from "./as-cell-json-2I081xnO.mjs";
|
|
12
|
+
import { t as as_cell_number_default } from "./as-cell-number-CP2AZI9g.mjs";
|
|
13
|
+
import { t as formatCellValue } from "./format-cell-Bx7wNc4X.mjs";
|
|
14
|
+
import { t as as_cell_union_default } from "./as-cell-union-NHpDCXty.mjs";
|
|
15
|
+
import { t as as_column_menu_default } from "./as-column-menu-BMTS3DO2.mjs";
|
|
16
|
+
import { t as as_config_dialog_default } from "./as-config-dialog-BMQxSqzl.mjs";
|
|
17
|
+
import { t as as_confirm_dialog_default } from "./as-confirm-dialog-Dp_njNXz.mjs";
|
|
18
|
+
import { t as as_filter_input_default } from "./as-filter-input-C8KmOus8.mjs";
|
|
19
|
+
import { t as as_filter_dialog_default } from "./as-filter-dialog-kAXGDwsk.mjs";
|
|
20
|
+
import { t as as_table_header_cell_default } from "./as-table-header-cell-CZyy4q1s.mjs";
|
|
21
|
+
import { t as as_window_table_default } from "./as-window-table-B9Y4Xgwm.mjs";
|
|
22
|
+
import { t as as_filter_field_default } from "./as-filter-field-WnV2axh8.mjs";
|
|
23
|
+
import { t as as_filters_default } from "./as-filters-Bc44srvA.mjs";
|
|
24
|
+
import { t as as_preset_dialog_default } from "./as-preset-dialog-Bx4nRuyk.mjs";
|
|
25
|
+
import { t as as_row_actions_default } from "./as-row-actions-gxmuZkYI.mjs";
|
|
26
|
+
import { t as as_table_cell_value_default } from "./as-table-cell-value-BVcfhhCb.mjs";
|
|
27
|
+
import { t as as_table_default } from "./as-table-BIV1W3O9.mjs";
|
|
28
|
+
import { t as as_table_actions_default } from "./as-table-actions-DQ5Nn8Jc.mjs";
|
|
29
|
+
import { t as as_preset_picker_default } from "./as-preset-picker-BRQdflJz.mjs";
|
|
30
30
|
import { getDefaultClientFactory, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
|
|
31
31
|
import { computed, effectScope, ref, shallowRef } from "vue";
|
|
32
|
-
import { AppPrefsClient, PRESET_ASPECTS, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, columnFilterType, conditionsForType, defaultCondition, isFilled, isSystemPresetId, isUnavailableError, resolveSystemPresets, urlQueryConsumesKey } from "@atscript/ui-table";
|
|
32
|
+
import { AppPrefsClient, ExportAbortError, PRESET_ASPECTS, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, collectExportRows, columnFilterType, conditionsForType, defaultCondition, isFilled, isSystemPresetId, isUnavailableError, resolveExportValue, resolveSystemPresets, toCsv, urlQueryConsumesKey, withStableOrder } from "@atscript/ui-table";
|
|
33
33
|
import { StorageSerializers, useEventBus, useStorage } from "@vueuse/core";
|
|
34
|
+
//#region src/composables/use-table-export.ts
|
|
35
|
+
/**
|
|
36
|
+
* Export the table's data as it is queried right now.
|
|
37
|
+
*
|
|
38
|
+
* The export snapshots the table's own query at call time — the same filters,
|
|
39
|
+
* sorters, search term, force-filters and `$select` projection the on-screen
|
|
40
|
+
* fetch uses (`state.buildQuery()`), through the same fetch path
|
|
41
|
+
* (`state.fetchPage()`, so a custom `queryFn` is honoured) — then pages
|
|
42
|
+
* through every result instead of one page. The primary key(s) are appended
|
|
43
|
+
* to the sort as a tiebreaker so pages never overlap or skip.
|
|
44
|
+
*
|
|
45
|
+
* Values come out of the same column metadata the cells read: union/enum keys
|
|
46
|
+
* become their labels, dates become ISO strings, arrays join. Override per
|
|
47
|
+
* column with `formatters`, or globally with `formatCell`.
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* const { exportRows } = useTableExport()
|
|
51
|
+
* downloadExport(await exportRows({ filename: "orders.csv", csv: { bom: true } }))
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Since 0.1.134.
|
|
55
|
+
*/
|
|
56
|
+
function useTableExport(ctx) {
|
|
57
|
+
const state = (ctx ?? useTableContext()).state;
|
|
58
|
+
const progress = ref(null);
|
|
59
|
+
const exporting = computed(() => progress.value !== null);
|
|
60
|
+
function resolveColumns(selection, opts) {
|
|
61
|
+
if (selection && selection !== "visible") {
|
|
62
|
+
const byPath = new Map(state.allColumns.value.map((c) => [c.path, c]));
|
|
63
|
+
return selection.map((path) => byPath.get(path) ?? rawColumn(path));
|
|
64
|
+
}
|
|
65
|
+
const local = state.localColumnPaths.value;
|
|
66
|
+
const visible = state.columns.value;
|
|
67
|
+
if (local.size === 0) return visible;
|
|
68
|
+
return visible.filter((c) => !local.has(c.path) || opts.formatters?.[c.path]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One value resolver per column, built once per run: the formatter lookup
|
|
72
|
+
* and the union-option index happen here instead of per cell.
|
|
73
|
+
*/
|
|
74
|
+
function resolversFor(columns, opts) {
|
|
75
|
+
return columns.map((column) => {
|
|
76
|
+
const perColumn = opts.formatters?.[column.path];
|
|
77
|
+
const formatCell = opts.formatCell;
|
|
78
|
+
const labels = column.options?.length ? new Map(column.options.map((o) => [o.key, o.label])) : null;
|
|
79
|
+
return (row) => {
|
|
80
|
+
const raw = getCellValue(row, column.path);
|
|
81
|
+
if (perColumn) {
|
|
82
|
+
const out = perColumn(raw, column, row);
|
|
83
|
+
if (out !== void 0) return out;
|
|
84
|
+
}
|
|
85
|
+
if (formatCell) {
|
|
86
|
+
const out = formatCell(raw, column, row);
|
|
87
|
+
if (out !== void 0) return out;
|
|
88
|
+
}
|
|
89
|
+
if (labels !== null && (typeof raw === "string" || typeof raw === "number")) {
|
|
90
|
+
const hit = labels.get(String(raw));
|
|
91
|
+
if (hit !== void 0) return hit;
|
|
92
|
+
}
|
|
93
|
+
return resolveExportValue(raw);
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function exportRows(opts = {}) {
|
|
98
|
+
if (progress.value !== null) throw new Error("[vue-table] exportRows() is already running on this handle.");
|
|
99
|
+
const columns = resolveColumns(opts.columns, opts);
|
|
100
|
+
const columnPaths = columns.map((c) => c.path);
|
|
101
|
+
const query = withStableOrder(state.buildQuery({
|
|
102
|
+
columnPaths,
|
|
103
|
+
includeActions: false
|
|
104
|
+
}), state.tableDef.value?.primaryKeys ?? []);
|
|
105
|
+
const resolvers = resolversFor(columns, opts);
|
|
106
|
+
progress.value = { done: 0 };
|
|
107
|
+
try {
|
|
108
|
+
const { rows: matrix, total } = await collectExportRows({
|
|
109
|
+
query,
|
|
110
|
+
pageSize: opts.pageSize,
|
|
111
|
+
maxRows: opts.maxRows,
|
|
112
|
+
signal: opts.signal,
|
|
113
|
+
fetchPage: state.fetchPage,
|
|
114
|
+
mapRow: (row) => resolvers.map((resolve) => resolve(row)),
|
|
115
|
+
onProgress: (done, reported) => {
|
|
116
|
+
progress.value = {
|
|
117
|
+
done,
|
|
118
|
+
total: reported
|
|
119
|
+
};
|
|
120
|
+
opts.onProgress?.(done, reported);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const header = columns.map((c) => c.label || c.path);
|
|
124
|
+
const base = {
|
|
125
|
+
columns: header,
|
|
126
|
+
columnPaths,
|
|
127
|
+
rowCount: matrix.length,
|
|
128
|
+
total
|
|
129
|
+
};
|
|
130
|
+
if (opts.format === "rows") return {
|
|
131
|
+
...base,
|
|
132
|
+
format: "rows",
|
|
133
|
+
rows: matrix
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
...base,
|
|
137
|
+
format: "csv",
|
|
138
|
+
filename: withCsvSuffix(opts.filename ?? "export.csv"),
|
|
139
|
+
csv: toCsv(header, matrix, opts.csv)
|
|
140
|
+
};
|
|
141
|
+
} finally {
|
|
142
|
+
progress.value = null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
exportRows,
|
|
147
|
+
exporting,
|
|
148
|
+
progress
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Hand a finished CSV export to the browser as a file download. Returns
|
|
153
|
+
* `false` without doing anything when there is no DOM (SSR / a worker), so a
|
|
154
|
+
* server render can call it unguarded.
|
|
155
|
+
*
|
|
156
|
+
* Since 0.1.134.
|
|
157
|
+
*/
|
|
158
|
+
function downloadExport(result) {
|
|
159
|
+
if (result.format !== "csv") throw new Error("[vue-table] downloadExport() needs a `format: 'csv'` export result.");
|
|
160
|
+
if (typeof document === "undefined" || typeof URL?.createObjectURL !== "function") return false;
|
|
161
|
+
const blob = new Blob([result.csv], { type: "text/csv;charset=utf-8" });
|
|
162
|
+
const href = URL.createObjectURL(blob);
|
|
163
|
+
const anchor = document.createElement("a");
|
|
164
|
+
anchor.href = href;
|
|
165
|
+
anchor.download = result.filename;
|
|
166
|
+
anchor.style.display = "none";
|
|
167
|
+
document.body.appendChild(anchor);
|
|
168
|
+
anchor.click();
|
|
169
|
+
anchor.remove();
|
|
170
|
+
URL.revokeObjectURL(href);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
function withCsvSuffix(name) {
|
|
174
|
+
return name.toLowerCase().endsWith(".csv") ? name : `${name}.csv`;
|
|
175
|
+
}
|
|
176
|
+
/** Minimal column for an export path that is not one of the table's columns. */
|
|
177
|
+
function rawColumn(path) {
|
|
178
|
+
return {
|
|
179
|
+
path,
|
|
180
|
+
label: path,
|
|
181
|
+
type: "text",
|
|
182
|
+
sortable: false,
|
|
183
|
+
filterable: false,
|
|
184
|
+
nullable: true,
|
|
185
|
+
order: 0
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
34
189
|
//#region src/composables/use-table-filter.ts
|
|
35
190
|
/**
|
|
36
191
|
* Per-field filter state composable.
|
|
@@ -529,4 +684,4 @@ function getColumnWidth(column) {
|
|
|
529
684
|
return column.width || DEFAULT_WIDTHS[column.type] || "15em";
|
|
530
685
|
}
|
|
531
686
|
//#endregion
|
|
532
|
-
export { AS_PRESETS_APP, as_cell_array_default as AsCellArray, as_cell_date_default as AsCellDate, as_cell_json_default as AsCellJson, as_cell_number_default as AsCellNumber, as_cell_union_default as AsCellUnion, as_column_menu_default as AsColumnMenu, as_config_dialog_default as AsConfigDialog, as_confirm_dialog_default as AsConfirmDialog, as_filter_dialog_default as AsFilterDialog, as_filter_field_default as AsFilterField, as_filter_input_default as AsFilterInput, as_filters_default as AsFilters, as_preset_dialog_default as AsPresetDialog, as_preset_picker_default as AsPresetPicker, as_row_actions_default as AsRowActions, as_table_default as AsTable, as_table_actions_default as AsTableActions, as_table_cell_value_default as AsTableCellValue, as_table_header_cell_default as AsTableHeaderCell, as_table_root_default as AsTableRoot, as_window_table_default as AsWindowTable, PRESET_ASPECTS, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|
|
687
|
+
export { AS_PRESETS_APP, as_cell_array_default as AsCellArray, as_cell_date_default as AsCellDate, as_cell_json_default as AsCellJson, as_cell_number_default as AsCellNumber, as_cell_union_default as AsCellUnion, as_column_menu_default as AsColumnMenu, as_config_dialog_default as AsConfigDialog, as_confirm_dialog_default as AsConfirmDialog, as_filter_dialog_default as AsFilterDialog, as_filter_field_default as AsFilterField, as_filter_input_default as AsFilterInput, as_filters_default as AsFilters, as_preset_dialog_default as AsPresetDialog, as_preset_picker_default as AsPresetPicker, as_row_actions_default as AsRowActions, as_table_default as AsTable, as_table_actions_default as AsTableActions, as_table_cell_value_default as AsTableCellValue, as_table_header_cell_default as AsTableHeaderCell, as_table_root_default as AsTableRoot, as_window_table_default as AsWindowTable, ExportAbortError, PRESET_ASPECTS, STANDARD_PRESET_ID, SYSTEM_PRESET_PREFIX, clearTableCache, createDefaultCellTypes, createDefaultControls, createStaticTableState, createTableState, downloadExport, extractIdentifier, formatCellValue, getCellValue, getColumnWidth, getDefaultClientFactory, injectPresetsApp, isSystemPresetId, provideCellLocale, provideTableContext, resetDefaultClientFactory, resolveSystemPresets, setDefaultClientFactory, useAppPrefs, useCellLocale, useLocalDraft, usePresets, useTable, useTableActions, useTableComponent, useTableContext, useTableContextOptional, useTableExport, useTableFilter, useTableNavBridge, useTableSearch, useTableSelection, useTableUrlQuery };
|