@toolbox-web/grid-vue 0.1.0 → 0.3.0
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/README.md +18 -10
- package/chunks/use-grid-DwjXrO19.js +21 -0
- package/chunks/use-grid-DwjXrO19.js.map +1 -0
- package/features/export.d.ts +51 -10
- package/features/export.d.ts.map +1 -1
- package/features/export.js +54 -3
- package/features/export.js.map +1 -1
- package/features/filtering.d.ts +57 -7
- package/features/filtering.d.ts.map +1 -1
- package/features/filtering.js +70 -3
- package/features/filtering.js.map +1 -1
- package/features/print.d.ts +30 -7
- package/features/print.d.ts.map +1 -1
- package/features/print.js +27 -3
- package/features/print.js.map +1 -1
- package/features/selection.d.ts +43 -10
- package/features/selection.d.ts.map +1 -1
- package/features/selection.js +42 -3
- package/features/selection.js.map +1 -1
- package/features/undo-redo.d.ts +47 -7
- package/features/undo-redo.d.ts.map +1 -1
- package/features/undo-redo.js +48 -3
- package/features/undo-redo.js.map +1 -1
- package/index.d.ts +14 -2
- package/index.d.ts.map +1 -1
- package/index.js +337 -260
- package/index.js.map +1 -1
- package/lib/TbwGrid.vue.d.ts +46 -44
- package/lib/TbwGrid.vue.d.ts.map +1 -1
- package/lib/feature-props.d.ts +5 -1
- package/lib/feature-props.d.ts.map +1 -1
- package/lib/grid-provider.d.ts +1 -1
- package/lib/grid-type-registry.d.ts +27 -5
- package/lib/grid-type-registry.d.ts.map +1 -1
- package/lib/vue-column-config.d.ts +77 -15
- package/lib/vue-column-config.d.ts.map +1 -1
- package/lib/vue-grid-adapter.d.ts +57 -4
- package/lib/vue-grid-adapter.d.ts.map +1 -1
- package/package.json +1 -1
- package/typedoc-entry.d.ts +12 -2
- package/typedoc-entry.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -461,16 +461,24 @@ const props = defineProps<{
|
|
|
461
461
|
|
|
462
462
|
### Types
|
|
463
463
|
|
|
464
|
-
| Type | Description
|
|
465
|
-
| ----------------------- |
|
|
466
|
-
| `CellSlotProps` | Props for `#cell` slot
|
|
467
|
-
| `EditorSlotProps` | Props for `#editor` slot
|
|
468
|
-
| `DetailPanelContext` | Props for detail panel slot
|
|
469
|
-
| `ToolPanelContext` | Props for tool panel slot
|
|
470
|
-
| `ResponsiveCardContext` | Props for responsive card slot
|
|
471
|
-
| `
|
|
472
|
-
| `
|
|
473
|
-
| `
|
|
464
|
+
| Type | Description |
|
|
465
|
+
| ----------------------- | ------------------------------------ |
|
|
466
|
+
| `CellSlotProps` | Props for `#cell` slot |
|
|
467
|
+
| `EditorSlotProps` | Props for `#editor` slot |
|
|
468
|
+
| `DetailPanelContext` | Props for detail panel slot |
|
|
469
|
+
| `ToolPanelContext` | Props for tool panel slot |
|
|
470
|
+
| `ResponsiveCardContext` | Props for responsive card slot |
|
|
471
|
+
| `GridConfig` | Grid configuration type (primary) |
|
|
472
|
+
| `ColumnConfig` | Column configuration type (primary) |
|
|
473
|
+
| `CellRenderer` | Cell renderer type (primary) |
|
|
474
|
+
| `CellEditor` | Cell editor type (primary) |
|
|
475
|
+
| `TypeDefault` | Type default configuration (primary) |
|
|
476
|
+
| `TypeDefaultsMap` | Type defaults registry type |
|
|
477
|
+
| `VueGridConfig` | Deprecated - use `GridConfig` |
|
|
478
|
+
| `VueColumnConfig` | Deprecated - use `ColumnConfig` |
|
|
479
|
+
| `VueCellRenderer` | Deprecated - use `CellRenderer` |
|
|
480
|
+
| `VueCellEditor` | Deprecated - use `CellEditor` |
|
|
481
|
+
| `VueTypeDefault` | Deprecated - use `TypeDefault` |
|
|
474
482
|
|
|
475
483
|
## Building
|
|
476
484
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { inject as r, ref as a } from "vue";
|
|
2
|
+
const n = /* @__PURE__ */ Symbol("tbw-grid");
|
|
3
|
+
function o() {
|
|
4
|
+
const e = r(n, a(null));
|
|
5
|
+
return {
|
|
6
|
+
gridElement: e,
|
|
7
|
+
forceLayout: async () => {
|
|
8
|
+
await e.value?.forceLayout();
|
|
9
|
+
},
|
|
10
|
+
getConfig: () => e.value?.getConfig(),
|
|
11
|
+
ready: async () => {
|
|
12
|
+
await e.value?.ready();
|
|
13
|
+
},
|
|
14
|
+
getPlugin: (t) => e.value?.getPlugin(t)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
n as G,
|
|
19
|
+
o as u
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=use-grid-DwjXrO19.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-grid-DwjXrO19.js","sources":["../../../../libs/grid-vue/src/lib/use-grid.ts"],"sourcesContent":["import type { DataGridElement } from '@toolbox-web/grid';\nimport { inject, ref, type InjectionKey, type Ref } from 'vue';\n\n/**\n * Injection key for the grid element.\n */\nexport const GRID_ELEMENT_KEY: InjectionKey<Ref<DataGridElement | null>> = Symbol('tbw-grid');\n\n/**\n * Return type for useGrid composable.\n */\nexport interface UseGridReturn {\n /** The grid element reference */\n gridElement: Ref<DataGridElement | null>;\n /** Force a layout recalculation */\n forceLayout: () => Promise<void>;\n /** Get current grid configuration */\n getConfig: () => ReturnType<DataGridElement['getConfig']> | undefined;\n /** Wait for grid to be ready */\n ready: () => Promise<void>;\n /** Get a plugin by its class */\n getPlugin: <T>(pluginClass: new (...args: unknown[]) => T) => T | undefined;\n}\n\n/**\n * Composable for programmatic access to the grid.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useGrid } from '@toolbox-web/grid-vue';\n *\n * const { forceLayout, getConfig } = useGrid();\n *\n * async function handleResize() {\n * await forceLayout();\n * }\n * </script>\n * ```\n */\nexport function useGrid(): UseGridReturn {\n const gridElement = inject(GRID_ELEMENT_KEY, ref(null));\n\n return {\n gridElement,\n forceLayout: async () => {\n await gridElement.value?.forceLayout();\n },\n getConfig: () => {\n return gridElement.value?.getConfig();\n },\n ready: async () => {\n await gridElement.value?.ready();\n },\n getPlugin: <T>(pluginClass: new (...args: unknown[]) => T) => {\n return gridElement.value?.getPlugin(pluginClass);\n },\n };\n}\n"],"names":["GRID_ELEMENT_KEY","useGrid","gridElement","inject","ref","pluginClass"],"mappings":";AAMO,MAAMA,2BAAqE,UAAU;AAkCrF,SAASC,IAAyB;AACvC,QAAMC,IAAcC,EAAOH,GAAkBI,EAAI,IAAI,CAAC;AAEtD,SAAO;AAAA,IACL,aAAAF;AAAA,IACA,aAAa,YAAY;AACvB,YAAMA,EAAY,OAAO,YAAA;AAAA,IAC3B;AAAA,IACA,WAAW,MACFA,EAAY,OAAO,UAAA;AAAA,IAE5B,OAAO,YAAY;AACjB,YAAMA,EAAY,OAAO,MAAA;AAAA,IAC3B;AAAA,IACA,WAAW,CAAIG,MACNH,EAAY,OAAO,UAAUG,CAAW;AAAA,EACjD;AAEJ;"}
|
package/features/export.d.ts
CHANGED
|
@@ -1,20 +1,61 @@
|
|
|
1
|
+
import { ExportFormat, ExportParams } from '@toolbox-web/grid/plugins/export';
|
|
1
2
|
/**
|
|
2
|
-
* Export
|
|
3
|
+
* Export methods returned from useGridExport.
|
|
4
|
+
*/
|
|
5
|
+
export interface ExportMethods {
|
|
6
|
+
/**
|
|
7
|
+
* Export grid data to CSV file.
|
|
8
|
+
* @param filename - Optional filename (defaults to 'export.csv')
|
|
9
|
+
* @param params - Optional export parameters
|
|
10
|
+
*/
|
|
11
|
+
exportToCsv: (filename?: string, params?: Partial<ExportParams>) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Export grid data to Excel file (XML Spreadsheet format).
|
|
14
|
+
* @param filename - Optional filename (defaults to 'export.xlsx')
|
|
15
|
+
* @param params - Optional export parameters
|
|
16
|
+
*/
|
|
17
|
+
exportToExcel: (filename?: string, params?: Partial<ExportParams>) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Export grid data to JSON file.
|
|
20
|
+
* @param filename - Optional filename (defaults to 'export.json')
|
|
21
|
+
* @param params - Optional export parameters
|
|
22
|
+
*/
|
|
23
|
+
exportToJson: (filename?: string, params?: Partial<ExportParams>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Check if an export is currently in progress.
|
|
26
|
+
*/
|
|
27
|
+
isExporting: () => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get information about the last export.
|
|
30
|
+
*/
|
|
31
|
+
getLastExport: () => {
|
|
32
|
+
format: ExportFormat;
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
} | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Composable for programmatic export control.
|
|
3
38
|
*
|
|
4
|
-
*
|
|
39
|
+
* Must be used within a component that contains a TbwGrid with the export feature enabled.
|
|
5
40
|
*
|
|
6
41
|
* @example
|
|
7
42
|
* ```vue
|
|
8
43
|
* <script setup>
|
|
9
|
-
* import '@toolbox-web/grid-vue/features/export';
|
|
10
|
-
* </script>
|
|
44
|
+
* import { useGridExport } from '@toolbox-web/grid-vue/features/export';
|
|
11
45
|
*
|
|
12
|
-
*
|
|
13
|
-
* <TbwGrid export />
|
|
14
|
-
* </template>
|
|
15
|
-
* ```
|
|
46
|
+
* const { exportToCsv, exportToExcel, isExporting } = useGridExport();
|
|
16
47
|
*
|
|
17
|
-
*
|
|
48
|
+
* async function handleExport(format: 'csv' | 'excel' | 'json') {
|
|
49
|
+
* if (isExporting()) return; // Prevent concurrent exports
|
|
50
|
+
*
|
|
51
|
+
* switch (format) {
|
|
52
|
+
* case 'csv': exportToCsv('data.csv'); break;
|
|
53
|
+
* case 'excel': exportToExcel('data.xlsx'); break;
|
|
54
|
+
* case 'json': exportToJson('data.json'); break;
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* </script>
|
|
58
|
+
* ```
|
|
18
59
|
*/
|
|
19
|
-
export
|
|
60
|
+
export declare function useGridExport(): ExportMethods;
|
|
20
61
|
//# sourceMappingURL=export.d.ts.map
|
package/features/export.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/export.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAgB,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAYtG;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAEzE;;;;OAIG;IACH,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE3E;;;;OAIG;IACH,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAE1E;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC;IAE3B;;OAEG;IACH,aAAa,EAAE,MAAM;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,SAAS,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,IAAI,aAAa,CAwD7C"}
|
package/features/export.js
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
|
-
import { ExportPlugin as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ExportPlugin as i } from "@toolbox-web/grid/plugins/export";
|
|
2
|
+
import { inject as p, ref as x } from "vue";
|
|
3
|
+
import { r as l } from "../chunks/feature-registry-BgEOysSJ.js";
|
|
4
|
+
import { G as u } from "../chunks/use-grid-DwjXrO19.js";
|
|
5
|
+
l("export", (n) => n === !0 ? new i() : new i(n ?? void 0));
|
|
6
|
+
function d() {
|
|
7
|
+
const n = p(u, x(null)), o = () => n.value?.getPlugin(i);
|
|
8
|
+
return {
|
|
9
|
+
exportToCsv: (t, r) => {
|
|
10
|
+
const e = o();
|
|
11
|
+
if (!e) {
|
|
12
|
+
console.warn(
|
|
13
|
+
`[tbw-grid:export] ExportPlugin not found.
|
|
14
|
+
|
|
15
|
+
→ Enable export on the grid:
|
|
16
|
+
<TbwGrid :export="true" />`
|
|
17
|
+
);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
e.exportCsv({ ...r, fileName: t ?? r?.fileName ?? "export.csv" });
|
|
21
|
+
},
|
|
22
|
+
exportToExcel: (t, r) => {
|
|
23
|
+
const e = o();
|
|
24
|
+
if (!e) {
|
|
25
|
+
console.warn(
|
|
26
|
+
`[tbw-grid:export] ExportPlugin not found.
|
|
27
|
+
|
|
28
|
+
→ Enable export on the grid:
|
|
29
|
+
<TbwGrid :export="true" />`
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
e.exportExcel({ ...r, fileName: t ?? r?.fileName ?? "export.xlsx" });
|
|
34
|
+
},
|
|
35
|
+
exportToJson: (t, r) => {
|
|
36
|
+
const e = o();
|
|
37
|
+
if (!e) {
|
|
38
|
+
console.warn(
|
|
39
|
+
`[tbw-grid:export] ExportPlugin not found.
|
|
40
|
+
|
|
41
|
+
→ Enable export on the grid:
|
|
42
|
+
<TbwGrid :export="true" />`
|
|
43
|
+
);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
e.exportJson({ ...r, fileName: t ?? r?.fileName ?? "export.json" });
|
|
47
|
+
},
|
|
48
|
+
isExporting: () => o()?.isExporting() ?? !1,
|
|
49
|
+
getLastExport: () => o()?.getLastExport() ?? null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
d as useGridExport
|
|
54
|
+
};
|
|
4
55
|
//# sourceMappingURL=export.js.map
|
package/features/export.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sources":["../../../../libs/grid-vue/src/features/export.ts"],"sourcesContent":["/**\n * Export feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `export` prop on TbwGrid.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/export';\n * </script>\n *\n * <template>\n * <TbwGrid export />\n * </template>\n * ```\n *\n * @packageDocumentation\n */\n\nimport { ExportPlugin } from '@toolbox-web/grid/plugins/export';\nimport { registerFeature } from '../lib/feature-registry';\n\nregisterFeature('export', (config) => {\n if (config === true) {\n return new ExportPlugin();\n }\n return new ExportPlugin(config ?? undefined);\n});\n"],"names":["registerFeature","config","ExportPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.js","sources":["../../../../libs/grid-vue/src/features/export.ts"],"sourcesContent":["/**\n * Export feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `export` prop on TbwGrid.\n * Also exports `useGridExport()` composable for programmatic export control.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/export';\n * </script>\n *\n * <template>\n * <TbwGrid export />\n * </template>\n * ```\n *\n * @example Using the composable\n * ```vue\n * <script setup>\n * import { useGridExport } from '@toolbox-web/grid-vue/features/export';\n *\n * const { exportToCsv, exportToExcel, exportToJson } = useGridExport();\n *\n * function handleExport() {\n * exportToCsv('employees.csv');\n * }\n * </script>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { ExportPlugin, type ExportFormat, type ExportParams } from '@toolbox-web/grid/plugins/export';\nimport { inject, ref } from 'vue';\nimport { registerFeature } from '../lib/feature-registry';\nimport { GRID_ELEMENT_KEY } from '../lib/use-grid';\n\nregisterFeature('export', (config) => {\n if (config === true) {\n return new ExportPlugin();\n }\n return new ExportPlugin(config ?? undefined);\n});\n\n/**\n * Export methods returned from useGridExport.\n */\nexport interface ExportMethods {\n /**\n * Export grid data to CSV file.\n * @param filename - Optional filename (defaults to 'export.csv')\n * @param params - Optional export parameters\n */\n exportToCsv: (filename?: string, params?: Partial<ExportParams>) => void;\n\n /**\n * Export grid data to Excel file (XML Spreadsheet format).\n * @param filename - Optional filename (defaults to 'export.xlsx')\n * @param params - Optional export parameters\n */\n exportToExcel: (filename?: string, params?: Partial<ExportParams>) => void;\n\n /**\n * Export grid data to JSON file.\n * @param filename - Optional filename (defaults to 'export.json')\n * @param params - Optional export parameters\n */\n exportToJson: (filename?: string, params?: Partial<ExportParams>) => void;\n\n /**\n * Check if an export is currently in progress.\n */\n isExporting: () => boolean;\n\n /**\n * Get information about the last export.\n */\n getLastExport: () => { format: ExportFormat; timestamp: Date } | null;\n}\n\n/**\n * Composable for programmatic export control.\n *\n * Must be used within a component that contains a TbwGrid with the export feature enabled.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useGridExport } from '@toolbox-web/grid-vue/features/export';\n *\n * const { exportToCsv, exportToExcel, isExporting } = useGridExport();\n *\n * async function handleExport(format: 'csv' | 'excel' | 'json') {\n * if (isExporting()) return; // Prevent concurrent exports\n *\n * switch (format) {\n * case 'csv': exportToCsv('data.csv'); break;\n * case 'excel': exportToExcel('data.xlsx'); break;\n * case 'json': exportToJson('data.json'); break;\n * }\n * }\n * </script>\n * ```\n */\nexport function useGridExport(): ExportMethods {\n const gridElement = inject(GRID_ELEMENT_KEY, ref(null));\n\n const getPlugin = (): ExportPlugin | undefined => {\n const grid = gridElement.value as DataGridElement | null;\n return grid?.getPlugin(ExportPlugin);\n };\n\n return {\n exportToCsv: (filename?: string, params?: Partial<ExportParams>) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:export] ExportPlugin not found.\\n\\n` +\n ` → Enable export on the grid:\\n` +\n ` <TbwGrid :export=\"true\" />`,\n );\n return;\n }\n plugin.exportCsv({ ...params, fileName: filename ?? params?.fileName ?? 'export.csv' });\n },\n\n exportToExcel: (filename?: string, params?: Partial<ExportParams>) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:export] ExportPlugin not found.\\n\\n` +\n ` → Enable export on the grid:\\n` +\n ` <TbwGrid :export=\"true\" />`,\n );\n return;\n }\n plugin.exportExcel({ ...params, fileName: filename ?? params?.fileName ?? 'export.xlsx' });\n },\n\n exportToJson: (filename?: string, params?: Partial<ExportParams>) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:export] ExportPlugin not found.\\n\\n` +\n ` → Enable export on the grid:\\n` +\n ` <TbwGrid :export=\"true\" />`,\n );\n return;\n }\n plugin.exportJson({ ...params, fileName: filename ?? params?.fileName ?? 'export.json' });\n },\n\n isExporting: () => {\n return getPlugin()?.isExporting() ?? false;\n },\n\n getLastExport: () => {\n return getPlugin()?.getLastExport() ?? null;\n },\n };\n}\n"],"names":["registerFeature","config","ExportPlugin","useGridExport","gridElement","inject","GRID_ELEMENT_KEY","ref","getPlugin","filename","params","plugin"],"mappings":";;;;AAuCAA,EAAgB,UAAU,CAACC,MACrBA,MAAW,KACN,IAAIC,EAAA,IAEN,IAAIA,EAAaD,KAAU,MAAS,CAC5C;AA8DM,SAASE,IAA+B;AAC7C,QAAMC,IAAcC,EAAOC,GAAkBC,EAAI,IAAI,CAAC,GAEhDC,IAAY,MACHJ,EAAY,OACZ,UAAUF,CAAY;AAGrC,SAAO;AAAA,IACL,aAAa,CAACO,GAAmBC,MAAmC;AAClE,YAAMC,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,UAAU,EAAE,GAAGD,GAAQ,UAAUD,KAAYC,GAAQ,YAAY,cAAc;AAAA,IACxF;AAAA,IAEA,eAAe,CAACD,GAAmBC,MAAmC;AACpE,YAAMC,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,YAAY,EAAE,GAAGD,GAAQ,UAAUD,KAAYC,GAAQ,YAAY,eAAe;AAAA,IAC3F;AAAA,IAEA,cAAc,CAACD,GAAmBC,MAAmC;AACnE,YAAMC,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,WAAW,EAAE,GAAGD,GAAQ,UAAUD,KAAYC,GAAQ,YAAY,eAAe;AAAA,IAC1F;AAAA,IAEA,aAAa,MACJF,EAAA,GAAa,YAAA,KAAiB;AAAA,IAGvC,eAAe,MACNA,EAAA,GAAa,cAAA,KAAmB;AAAA,EACzC;AAEJ;"}
|
package/features/filtering.d.ts
CHANGED
|
@@ -1,20 +1,70 @@
|
|
|
1
|
+
import { FilterModel } from '@toolbox-web/grid/plugins/filtering';
|
|
1
2
|
/**
|
|
2
|
-
* Filtering
|
|
3
|
+
* Filtering methods returned from useGridFiltering.
|
|
4
|
+
*/
|
|
5
|
+
export interface FilteringMethods {
|
|
6
|
+
/**
|
|
7
|
+
* Set a filter on a specific field.
|
|
8
|
+
* @param field - The field name to filter
|
|
9
|
+
* @param filter - Filter configuration, or null to remove
|
|
10
|
+
*/
|
|
11
|
+
setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Get the current filter for a field.
|
|
14
|
+
*/
|
|
15
|
+
getFilter: (field: string) => FilterModel | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Get all active filters.
|
|
18
|
+
*/
|
|
19
|
+
getFilters: () => FilterModel[];
|
|
20
|
+
/**
|
|
21
|
+
* Set all filters at once (replaces existing).
|
|
22
|
+
*/
|
|
23
|
+
setFilterModel: (filters: FilterModel[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Clear all active filters.
|
|
26
|
+
*/
|
|
27
|
+
clearAllFilters: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Clear filter for a specific field.
|
|
30
|
+
*/
|
|
31
|
+
clearFieldFilter: (field: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a field has an active filter.
|
|
34
|
+
*/
|
|
35
|
+
isFieldFiltered: (field: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get the count of rows after filtering.
|
|
38
|
+
*/
|
|
39
|
+
getFilteredRowCount: () => number;
|
|
40
|
+
/**
|
|
41
|
+
* Get unique values for a field (for building filter dropdowns).
|
|
42
|
+
*/
|
|
43
|
+
getUniqueValues: (field: string) => unknown[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Composable for programmatic filter control.
|
|
3
47
|
*
|
|
4
|
-
*
|
|
48
|
+
* Must be used within a component that contains a TbwGrid with filtering enabled.
|
|
5
49
|
*
|
|
6
50
|
* @example
|
|
7
51
|
* ```vue
|
|
8
52
|
* <script setup>
|
|
9
|
-
* import '@toolbox-web/grid-vue/features/filtering';
|
|
53
|
+
* import { useGridFiltering } from '@toolbox-web/grid-vue/features/filtering';
|
|
54
|
+
*
|
|
55
|
+
* const { setFilter, clearAllFilters, getFilteredRowCount, isFieldFiltered } = useGridFiltering();
|
|
56
|
+
*
|
|
57
|
+
* function applyQuickFilter(field: string, value: string) {
|
|
58
|
+
* setFilter(field, { operator: 'contains', value });
|
|
59
|
+
* }
|
|
10
60
|
* </script>
|
|
11
61
|
*
|
|
12
62
|
* <template>
|
|
13
|
-
* <
|
|
63
|
+
* <input @input="applyQuickFilter('name', $event.target.value)" placeholder="Filter by name..." />
|
|
64
|
+
* <span>{{ getFilteredRowCount() }} results</span>
|
|
65
|
+
* <button @click="clearAllFilters">Clear Filters</button>
|
|
14
66
|
* </template>
|
|
15
67
|
* ```
|
|
16
|
-
*
|
|
17
|
-
* @packageDocumentation
|
|
18
68
|
*/
|
|
19
|
-
export
|
|
69
|
+
export declare function useGridFiltering(): FilteringMethods;
|
|
20
70
|
//# sourceMappingURL=filtering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/filtering.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/filtering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAYxF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9E;;OAEG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,UAAU,EAAE,MAAM,WAAW,EAAE,CAAC;IAEhC;;OAEG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAEjD;;OAEG;IACH,eAAe,EAAE,MAAM,IAAI,CAAC;IAE5B;;OAEG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5C;;OAEG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAElC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAuEnD"}
|
package/features/filtering.js
CHANGED
|
@@ -1,4 +1,71 @@
|
|
|
1
|
-
import { FilteringPlugin as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { FilteringPlugin as n } from "@toolbox-web/grid/plugins/filtering";
|
|
2
|
+
import { inject as g, ref as o } from "vue";
|
|
3
|
+
import { r as u } from "../chunks/feature-registry-BgEOysSJ.js";
|
|
4
|
+
import { G as d } from "../chunks/use-grid-DwjXrO19.js";
|
|
5
|
+
u("filtering", (t) => t === !0 ? new n() : new n(t ?? void 0));
|
|
6
|
+
function c() {
|
|
7
|
+
const t = g(d, o(null)), i = () => t.value?.getPlugin(n);
|
|
8
|
+
return {
|
|
9
|
+
setFilter: (e, r) => {
|
|
10
|
+
const l = i();
|
|
11
|
+
if (!l) {
|
|
12
|
+
console.warn(
|
|
13
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
14
|
+
|
|
15
|
+
→ Enable filtering on the grid:
|
|
16
|
+
<TbwGrid filtering />`
|
|
17
|
+
);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
l.setFilter(e, r);
|
|
21
|
+
},
|
|
22
|
+
getFilter: (e) => i()?.getFilter(e),
|
|
23
|
+
getFilters: () => i()?.getFilters() ?? [],
|
|
24
|
+
setFilterModel: (e) => {
|
|
25
|
+
const r = i();
|
|
26
|
+
if (!r) {
|
|
27
|
+
console.warn(
|
|
28
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
29
|
+
|
|
30
|
+
→ Enable filtering on the grid:
|
|
31
|
+
<TbwGrid filtering />`
|
|
32
|
+
);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
r.setFilterModel(e);
|
|
36
|
+
},
|
|
37
|
+
clearAllFilters: () => {
|
|
38
|
+
const e = i();
|
|
39
|
+
if (!e) {
|
|
40
|
+
console.warn(
|
|
41
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
42
|
+
|
|
43
|
+
→ Enable filtering on the grid:
|
|
44
|
+
<TbwGrid filtering />`
|
|
45
|
+
);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
e.clearAllFilters();
|
|
49
|
+
},
|
|
50
|
+
clearFieldFilter: (e) => {
|
|
51
|
+
const r = i();
|
|
52
|
+
if (!r) {
|
|
53
|
+
console.warn(
|
|
54
|
+
`[tbw-grid:filtering] FilteringPlugin not found.
|
|
55
|
+
|
|
56
|
+
→ Enable filtering on the grid:
|
|
57
|
+
<TbwGrid filtering />`
|
|
58
|
+
);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
r.clearFieldFilter(e);
|
|
62
|
+
},
|
|
63
|
+
isFieldFiltered: (e) => i()?.isFieldFiltered(e) ?? !1,
|
|
64
|
+
getFilteredRowCount: () => i()?.getFilteredRowCount() ?? 0,
|
|
65
|
+
getUniqueValues: (e) => i()?.getUniqueValues(e) ?? []
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
c as useGridFiltering
|
|
70
|
+
};
|
|
4
71
|
//# sourceMappingURL=filtering.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.js","sources":["../../../../libs/grid-vue/src/features/filtering.ts"],"sourcesContent":["/**\n * Filtering feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `filtering` prop on TbwGrid.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/filtering';\n * </script>\n *\n * <template>\n * <TbwGrid filtering />\n * </template>\n * ```\n *\n * @packageDocumentation\n */\n\nimport { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';\nimport { registerFeature } from '../lib/feature-registry';\n\nregisterFeature('filtering', (config) => {\n if (config === true) {\n return new FilteringPlugin();\n }\n return new FilteringPlugin(config ?? undefined);\n});\n"],"names":["registerFeature","config","FilteringPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"filtering.js","sources":["../../../../libs/grid-vue/src/features/filtering.ts"],"sourcesContent":["/**\n * Filtering feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `filtering` prop on TbwGrid.\n * Also exports `useGridFiltering()` composable for programmatic filter control.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/filtering';\n * </script>\n *\n * <template>\n * <TbwGrid filtering />\n * </template>\n * ```\n *\n * @example Using the composable\n * ```vue\n * <script setup>\n * import { useGridFiltering } from '@toolbox-web/grid-vue/features/filtering';\n *\n * const { setFilter, clearAllFilters, getFilteredRowCount } = useGridFiltering();\n *\n * function filterByStatus(status: string) {\n * setFilter('status', { operator: 'equals', value: status });\n * }\n * </script>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { FilteringPlugin, type FilterModel } from '@toolbox-web/grid/plugins/filtering';\nimport { inject, ref } from 'vue';\nimport { registerFeature } from '../lib/feature-registry';\nimport { GRID_ELEMENT_KEY } from '../lib/use-grid';\n\nregisterFeature('filtering', (config) => {\n if (config === true) {\n return new FilteringPlugin();\n }\n return new FilteringPlugin(config ?? undefined);\n});\n\n/**\n * Filtering methods returned from useGridFiltering.\n */\nexport interface FilteringMethods {\n /**\n * Set a filter on a specific field.\n * @param field - The field name to filter\n * @param filter - Filter configuration, or null to remove\n */\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null) => void;\n\n /**\n * Get the current filter for a field.\n */\n getFilter: (field: string) => FilterModel | undefined;\n\n /**\n * Get all active filters.\n */\n getFilters: () => FilterModel[];\n\n /**\n * Set all filters at once (replaces existing).\n */\n setFilterModel: (filters: FilterModel[]) => void;\n\n /**\n * Clear all active filters.\n */\n clearAllFilters: () => void;\n\n /**\n * Clear filter for a specific field.\n */\n clearFieldFilter: (field: string) => void;\n\n /**\n * Check if a field has an active filter.\n */\n isFieldFiltered: (field: string) => boolean;\n\n /**\n * Get the count of rows after filtering.\n */\n getFilteredRowCount: () => number;\n\n /**\n * Get unique values for a field (for building filter dropdowns).\n */\n getUniqueValues: (field: string) => unknown[];\n}\n\n/**\n * Composable for programmatic filter control.\n *\n * Must be used within a component that contains a TbwGrid with filtering enabled.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useGridFiltering } from '@toolbox-web/grid-vue/features/filtering';\n *\n * const { setFilter, clearAllFilters, getFilteredRowCount, isFieldFiltered } = useGridFiltering();\n *\n * function applyQuickFilter(field: string, value: string) {\n * setFilter(field, { operator: 'contains', value });\n * }\n * </script>\n *\n * <template>\n * <input @input=\"applyQuickFilter('name', $event.target.value)\" placeholder=\"Filter by name...\" />\n * <span>{{ getFilteredRowCount() }} results</span>\n * <button @click=\"clearAllFilters\">Clear Filters</button>\n * </template>\n * ```\n */\nexport function useGridFiltering(): FilteringMethods {\n const gridElement = inject(GRID_ELEMENT_KEY, ref(null));\n\n const getPlugin = (): FilteringPlugin | undefined => {\n const grid = gridElement.value as DataGridElement | null;\n return grid?.getPlugin(FilteringPlugin);\n };\n\n return {\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <TbwGrid filtering />`,\n );\n return;\n }\n plugin.setFilter(field, filter);\n },\n\n getFilter: (field: string) => getPlugin()?.getFilter(field),\n\n getFilters: () => getPlugin()?.getFilters() ?? [],\n\n setFilterModel: (filters: FilterModel[]) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <TbwGrid filtering />`,\n );\n return;\n }\n plugin.setFilterModel(filters);\n },\n\n clearAllFilters: () => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <TbwGrid filtering />`,\n );\n return;\n }\n plugin.clearAllFilters();\n },\n\n clearFieldFilter: (field: string) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <TbwGrid filtering />`,\n );\n return;\n }\n plugin.clearFieldFilter(field);\n },\n\n isFieldFiltered: (field: string) => getPlugin()?.isFieldFiltered(field) ?? false,\n\n getFilteredRowCount: () => getPlugin()?.getFilteredRowCount() ?? 0,\n\n getUniqueValues: (field: string) => getPlugin()?.getUniqueValues(field) ?? [],\n };\n}\n"],"names":["registerFeature","config","FilteringPlugin","useGridFiltering","gridElement","inject","GRID_ELEMENT_KEY","ref","getPlugin","field","filter","plugin","filters"],"mappings":";;;;AAuCAA,EAAgB,aAAa,CAACC,MACxBA,MAAW,KACN,IAAIC,EAAA,IAEN,IAAIA,EAAgBD,KAAU,MAAS,CAC/C;AA8EM,SAASE,IAAqC;AACnD,QAAMC,IAAcC,EAAOC,GAAkBC,EAAI,IAAI,CAAC,GAEhDC,IAAY,MACHJ,EAAY,OACZ,UAAUF,CAAe;AAGxC,SAAO;AAAA,IACL,WAAW,CAACO,GAAeC,MAA8C;AACvE,YAAMC,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,UAAUF,GAAOC,CAAM;AAAA,IAChC;AAAA,IAEA,WAAW,CAACD,MAAkBD,EAAA,GAAa,UAAUC,CAAK;AAAA,IAE1D,YAAY,MAAMD,KAAa,WAAA,KAAgB,CAAA;AAAA,IAE/C,gBAAgB,CAACI,MAA2B;AAC1C,YAAMD,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,eAAeC,CAAO;AAAA,IAC/B;AAAA,IAEA,iBAAiB,MAAM;AACrB,YAAMD,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,gBAAA;AAAA,IACT;AAAA,IAEA,kBAAkB,CAACF,MAAkB;AACnC,YAAME,IAASH,EAAA;AACf,UAAI,CAACG,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAIF;AAAA,MACF;AACA,MAAAA,EAAO,iBAAiBF,CAAK;AAAA,IAC/B;AAAA,IAEA,iBAAiB,CAACA,MAAkBD,KAAa,gBAAgBC,CAAK,KAAK;AAAA,IAE3E,qBAAqB,MAAMD,KAAa,yBAAyB;AAAA,IAEjE,iBAAiB,CAACC,MAAkBD,EAAA,GAAa,gBAAgBC,CAAK,KAAK,CAAA;AAAA,EAAC;AAEhF;"}
|
package/features/print.d.ts
CHANGED
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
import { PrintParams } from '@toolbox-web/grid/plugins/print';
|
|
1
2
|
/**
|
|
2
|
-
* Print
|
|
3
|
+
* Print methods returned from useGridPrint.
|
|
4
|
+
*/
|
|
5
|
+
export interface PrintMethods {
|
|
6
|
+
/**
|
|
7
|
+
* Print the grid.
|
|
8
|
+
* Opens browser print dialog after preparing the grid for printing.
|
|
9
|
+
* @param params - Optional print parameters
|
|
10
|
+
*/
|
|
11
|
+
print: (params?: PrintParams) => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a print operation is currently in progress.
|
|
14
|
+
*/
|
|
15
|
+
isPrinting: () => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Composable for programmatic print control.
|
|
3
19
|
*
|
|
4
|
-
*
|
|
20
|
+
* Must be used within a component that contains a TbwGrid with print enabled.
|
|
5
21
|
*
|
|
6
22
|
* @example
|
|
7
23
|
* ```vue
|
|
8
24
|
* <script setup>
|
|
9
|
-
* import '@toolbox-web/grid-vue/features/print';
|
|
25
|
+
* import { useGridPrint } from '@toolbox-web/grid-vue/features/print';
|
|
26
|
+
*
|
|
27
|
+
* const { print, isPrinting } = useGridPrint();
|
|
28
|
+
*
|
|
29
|
+
* async function handlePrint() {
|
|
30
|
+
* await print({ title: 'My Report', isolate: true });
|
|
31
|
+
* console.log('Print completed');
|
|
32
|
+
* }
|
|
10
33
|
* </script>
|
|
11
34
|
*
|
|
12
35
|
* <template>
|
|
13
|
-
* <
|
|
36
|
+
* <button @click="handlePrint" :disabled="isPrinting()">
|
|
37
|
+
* {{ isPrinting() ? 'Printing...' : 'Print' }}
|
|
38
|
+
* </button>
|
|
14
39
|
* </template>
|
|
15
40
|
* ```
|
|
16
|
-
*
|
|
17
|
-
* @packageDocumentation
|
|
18
41
|
*/
|
|
19
|
-
export
|
|
42
|
+
export declare function useGridPrint(): PrintMethods;
|
|
20
43
|
//# sourceMappingURL=print.d.ts.map
|
package/features/print.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/print.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/print.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAYhF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;OAEG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,IAAI,YAAY,CAsB3C"}
|
package/features/print.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import { PrintPlugin as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { PrintPlugin as n } from "@toolbox-web/grid/plugins/print";
|
|
2
|
+
import { inject as o, ref as u } from "vue";
|
|
3
|
+
import { r as g } from "../chunks/feature-registry-BgEOysSJ.js";
|
|
4
|
+
import { G as s } from "../chunks/use-grid-DwjXrO19.js";
|
|
5
|
+
g("print", (r) => r === !0 ? new n() : new n(r ?? void 0));
|
|
6
|
+
function f() {
|
|
7
|
+
const r = o(s, u(null)), i = () => r.value?.getPlugin(n);
|
|
8
|
+
return {
|
|
9
|
+
print: async (t) => {
|
|
10
|
+
const e = i();
|
|
11
|
+
if (!e) {
|
|
12
|
+
console.warn(
|
|
13
|
+
`[tbw-grid:print] PrintPlugin not found.
|
|
14
|
+
|
|
15
|
+
→ Enable print on the grid:
|
|
16
|
+
<TbwGrid print />`
|
|
17
|
+
);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
await e.print(t);
|
|
21
|
+
},
|
|
22
|
+
isPrinting: () => i()?.isPrinting() ?? !1
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
f as useGridPrint
|
|
27
|
+
};
|
|
4
28
|
//# sourceMappingURL=print.js.map
|
package/features/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print.js","sources":["../../../../libs/grid-vue/src/features/print.ts"],"sourcesContent":["/**\n * Print feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `print` prop on TbwGrid.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/print';\n * </script>\n *\n * <template>\n * <TbwGrid print />\n * </template>\n * ```\n *\n * @packageDocumentation\n */\n\nimport { PrintPlugin } from '@toolbox-web/grid/plugins/print';\nimport { registerFeature } from '../lib/feature-registry';\n\nregisterFeature('print', (config) => {\n if (config === true) {\n return new PrintPlugin();\n }\n return new PrintPlugin(config ?? undefined);\n});\n"],"names":["registerFeature","config","PrintPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"print.js","sources":["../../../../libs/grid-vue/src/features/print.ts"],"sourcesContent":["/**\n * Print feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `print` prop on TbwGrid.\n * Also exports `useGridPrint()` composable for programmatic print control.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/print';\n * </script>\n *\n * <template>\n * <TbwGrid print />\n * </template>\n * ```\n *\n * @example Using the composable\n * ```vue\n * <script setup>\n * import { useGridPrint } from '@toolbox-web/grid-vue/features/print';\n *\n * const { print, isPrinting } = useGridPrint();\n * </script>\n *\n * <template>\n * <button @click=\"print\" :disabled=\"isPrinting()\">Print Grid</button>\n * </template>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { PrintPlugin, type PrintParams } from '@toolbox-web/grid/plugins/print';\nimport { inject, ref } from 'vue';\nimport { registerFeature } from '../lib/feature-registry';\nimport { GRID_ELEMENT_KEY } from '../lib/use-grid';\n\nregisterFeature('print', (config) => {\n if (config === true) {\n return new PrintPlugin();\n }\n return new PrintPlugin(config ?? undefined);\n});\n\n/**\n * Print methods returned from useGridPrint.\n */\nexport interface PrintMethods {\n /**\n * Print the grid.\n * Opens browser print dialog after preparing the grid for printing.\n * @param params - Optional print parameters\n */\n print: (params?: PrintParams) => Promise<void>;\n\n /**\n * Check if a print operation is currently in progress.\n */\n isPrinting: () => boolean;\n}\n\n/**\n * Composable for programmatic print control.\n *\n * Must be used within a component that contains a TbwGrid with print enabled.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useGridPrint } from '@toolbox-web/grid-vue/features/print';\n *\n * const { print, isPrinting } = useGridPrint();\n *\n * async function handlePrint() {\n * await print({ title: 'My Report', isolate: true });\n * console.log('Print completed');\n * }\n * </script>\n *\n * <template>\n * <button @click=\"handlePrint\" :disabled=\"isPrinting()\">\n * {{ isPrinting() ? 'Printing...' : 'Print' }}\n * </button>\n * </template>\n * ```\n */\nexport function useGridPrint(): PrintMethods {\n const gridElement = inject(GRID_ELEMENT_KEY, ref(null));\n\n const getPlugin = (): PrintPlugin | undefined => {\n const grid = gridElement.value as DataGridElement | null;\n return grid?.getPlugin(PrintPlugin);\n };\n\n return {\n print: async (params?: PrintParams) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:print] PrintPlugin not found.\\n\\n` + ` → Enable print on the grid:\\n` + ` <TbwGrid print />`,\n );\n return;\n }\n await plugin.print(params);\n },\n\n isPrinting: () => getPlugin()?.isPrinting() ?? false,\n };\n}\n"],"names":["registerFeature","config","PrintPlugin","useGridPrint","gridElement","inject","GRID_ELEMENT_KEY","ref","getPlugin","params","plugin"],"mappings":";;;;AAuCAA,EAAgB,SAAS,CAACC,MACpBA,MAAW,KACN,IAAIC,EAAA,IAEN,IAAIA,EAAYD,KAAU,MAAS,CAC3C;AA4CM,SAASE,IAA6B;AAC3C,QAAMC,IAAcC,EAAOC,GAAkBC,EAAI,IAAI,CAAC,GAEhDC,IAAY,MACHJ,EAAY,OACZ,UAAUF,CAAW;AAGpC,SAAO;AAAA,IACL,OAAO,OAAOO,MAAyB;AACrC,YAAMC,IAASF,EAAA;AACf,UAAI,CAACE,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA;AAAA;AAAA;AAAA,QAAA;AAEF;AAAA,MACF;AACA,YAAMA,EAAO,MAAMD,CAAM;AAAA,IAC3B;AAAA,IAEA,YAAY,MAAMD,KAAa,gBAAgB;AAAA,EAAA;AAEnD;"}
|
package/features/selection.d.ts
CHANGED
|
@@ -1,20 +1,53 @@
|
|
|
1
|
+
import { CellRange, SelectionResult } from '@toolbox-web/grid/plugins/selection';
|
|
1
2
|
/**
|
|
2
|
-
* Selection
|
|
3
|
+
* Selection methods returned from useGridSelection.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
+
* Uses the injected grid element from TbwGrid's provide/inject.
|
|
6
|
+
* Methods work immediately when grid is available.
|
|
7
|
+
*/
|
|
8
|
+
export interface SelectionMethods {
|
|
9
|
+
/**
|
|
10
|
+
* Select all rows (row mode) or all cells (range mode).
|
|
11
|
+
*/
|
|
12
|
+
selectAll: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Clear all selection.
|
|
15
|
+
*/
|
|
16
|
+
clearSelection: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Get the current selection state.
|
|
19
|
+
* Use this to derive selected rows, indices, etc.
|
|
20
|
+
*/
|
|
21
|
+
getSelection: () => SelectionResult | null;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a specific cell is selected.
|
|
24
|
+
*/
|
|
25
|
+
isCellSelected: (row: number, col: number) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Set selection ranges programmatically.
|
|
28
|
+
*/
|
|
29
|
+
setRanges: (ranges: CellRange[]) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Composable for programmatic selection control.
|
|
33
|
+
*
|
|
34
|
+
* Must be used within a component that contains a TbwGrid with the selection feature enabled.
|
|
35
|
+
* Uses Vue's provide/inject, so it works reliably regardless of when the grid renders.
|
|
5
36
|
*
|
|
6
37
|
* @example
|
|
7
38
|
* ```vue
|
|
8
39
|
* <script setup>
|
|
9
|
-
* import '@toolbox-web/grid-vue/features/selection';
|
|
10
|
-
* </script>
|
|
40
|
+
* import { useGridSelection } from '@toolbox-web/grid-vue/features/selection';
|
|
11
41
|
*
|
|
12
|
-
*
|
|
13
|
-
* <TbwGrid selection="range" />
|
|
14
|
-
* </template>
|
|
15
|
-
* ```
|
|
42
|
+
* const { selectAll, clearSelection, getSelection } = useGridSelection();
|
|
16
43
|
*
|
|
17
|
-
*
|
|
44
|
+
* function exportSelected() {
|
|
45
|
+
* const selection = getSelection();
|
|
46
|
+
* if (!selection) return;
|
|
47
|
+
* // Derive rows from selection.ranges and grid.rows
|
|
48
|
+
* }
|
|
49
|
+
* </script>
|
|
50
|
+
* ```
|
|
18
51
|
*/
|
|
19
|
-
export
|
|
52
|
+
export declare function useGridSelection<TRow = unknown>(): SelectionMethods;
|
|
20
53
|
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/selection.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../libs/grid-vue/src/features/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAmB,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAc5G;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B;;;OAGG;IACH,YAAY,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAE3C;;OAEG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAEtD;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,KAAK,gBAAgB,CAsDnE"}
|
package/features/selection.js
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
import { SelectionPlugin as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { SelectionPlugin as s } from "@toolbox-web/grid/plugins/selection";
|
|
2
|
+
import { inject as u, ref as g } from "vue";
|
|
3
|
+
import { r as d } from "../chunks/feature-registry-BgEOysSJ.js";
|
|
4
|
+
import { G as a } from "../chunks/use-grid-DwjXrO19.js";
|
|
5
|
+
d("selection", (t) => t === "cell" || t === "row" || t === "range" ? new s({ mode: t }) : new s(t ?? void 0));
|
|
6
|
+
function p() {
|
|
7
|
+
const t = u(a, g(null)), n = () => t.value?.getPlugin(s);
|
|
8
|
+
return {
|
|
9
|
+
selectAll: () => {
|
|
10
|
+
const e = n();
|
|
11
|
+
if (!e) {
|
|
12
|
+
console.warn(
|
|
13
|
+
`[tbw-grid:selection] SelectionPlugin not found.
|
|
14
|
+
|
|
15
|
+
→ Enable selection on the grid:
|
|
16
|
+
<TbwGrid selection="range" />`
|
|
17
|
+
);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const o = t.value, c = e.config?.mode;
|
|
21
|
+
if (c === "row") {
|
|
22
|
+
const l = o?.rows?.length ?? 0, r = /* @__PURE__ */ new Set();
|
|
23
|
+
for (let i = 0; i < l; i++) r.add(i);
|
|
24
|
+
e.selected = r, e.requestAfterRender?.();
|
|
25
|
+
} else if (c === "range") {
|
|
26
|
+
const l = o?.rows?.length ?? 0, r = o?._columns?.length ?? 0;
|
|
27
|
+
l > 0 && r > 0 && e.setRanges([{ from: { row: 0, col: 0 }, to: { row: l - 1, col: r - 1 } }]);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
clearSelection: () => {
|
|
31
|
+
n()?.clearSelection();
|
|
32
|
+
},
|
|
33
|
+
getSelection: () => n()?.getSelection() ?? null,
|
|
34
|
+
isCellSelected: (e, o) => n()?.isCellSelected(e, o) ?? !1,
|
|
35
|
+
setRanges: (e) => {
|
|
36
|
+
n()?.setRanges(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
p as useGridSelection
|
|
42
|
+
};
|
|
4
43
|
//# sourceMappingURL=selection.js.map
|