@toolbox-web/grid-vue 0.4.0 → 0.4.1
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
CHANGED
|
@@ -217,6 +217,72 @@ import '@toolbox-web/grid-vue/features/editing';
|
|
|
217
217
|
| `commit` | `(value: any) => void` | Save the new value |
|
|
218
218
|
| `cancel` | `() => void` | Cancel editing |
|
|
219
219
|
|
|
220
|
+
## Events
|
|
221
|
+
|
|
222
|
+
Handle grid events using Vue's template syntax or the `useGridEvent` composable.
|
|
223
|
+
|
|
224
|
+
### Template Event Binding
|
|
225
|
+
|
|
226
|
+
```vue
|
|
227
|
+
<script setup lang="ts">
|
|
228
|
+
import { TbwGrid } from '@toolbox-web/grid-vue';
|
|
229
|
+
import type { CellClickDetail, SortChangeDetail } from '@toolbox-web/grid';
|
|
230
|
+
|
|
231
|
+
function onCellClick(e: CustomEvent<CellClickDetail>) {
|
|
232
|
+
console.log(`Clicked ${e.detail.field} at row ${e.detail.rowIndex}`);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function onSortChange(e: CustomEvent<SortChangeDetail>) {
|
|
236
|
+
console.log(`Sorted by ${e.detail.field} ${e.detail.direction}`);
|
|
237
|
+
}
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<template>
|
|
241
|
+
<TbwGrid :rows="rows" @cell-click="onCellClick" @sort-change="onSortChange">
|
|
242
|
+
<TbwGridColumn field="name" header="Name" sortable />
|
|
243
|
+
</TbwGrid>
|
|
244
|
+
</template>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Available Events
|
|
248
|
+
|
|
249
|
+
| Event | Detail Type | Description |
|
|
250
|
+
| ---------------------- | -------------------- | --------------------------------- |
|
|
251
|
+
| `@cell-click` | `CellClickDetail` | Cell was clicked |
|
|
252
|
+
| `@row-click` | `RowClickDetail` | Row was clicked |
|
|
253
|
+
| `@cell-commit` | `CellCommitDetail` | Cell value committed (cancelable) |
|
|
254
|
+
| `@row-commit` | `RowCommitDetail` | Row edit completed (cancelable) |
|
|
255
|
+
| `@cell-change` | `CellChangeDetail` | Row updated via API |
|
|
256
|
+
| `@sort-change` | `SortChangeDetail` | Sort state changed |
|
|
257
|
+
| `@column-resize` | `ColumnResizeDetail` | Column was resized |
|
|
258
|
+
| `@cell-activate` | `CellActivateDetail` | Cell activated (cancelable) |
|
|
259
|
+
| `@column-state-change` | `GridColumnState` | Column visibility/order changed |
|
|
260
|
+
|
|
261
|
+
## Using Plugins (Advanced)
|
|
262
|
+
|
|
263
|
+
For full control, pass plugin instances directly via `:grid-config`. Use `markRaw()` to prevent Vue from making plugin instances reactive:
|
|
264
|
+
|
|
265
|
+
```vue
|
|
266
|
+
<script setup lang="ts">
|
|
267
|
+
import { markRaw } from 'vue';
|
|
268
|
+
import { TbwGrid, TbwGridColumn } from '@toolbox-web/grid-vue';
|
|
269
|
+
import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';
|
|
270
|
+
import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';
|
|
271
|
+
|
|
272
|
+
const gridConfig = {
|
|
273
|
+
plugins: markRaw([new SelectionPlugin({ mode: 'range' }), new FilteringPlugin({ debounceMs: 200 })]),
|
|
274
|
+
};
|
|
275
|
+
</script>
|
|
276
|
+
|
|
277
|
+
<template>
|
|
278
|
+
<TbwGrid :rows="rows" :grid-config="gridConfig">
|
|
279
|
+
<TbwGridColumn field="name" header="Name" />
|
|
280
|
+
</TbwGrid>
|
|
281
|
+
</template>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
> **Important:** Always wrap plugin arrays with `markRaw()`. Vue's reactivity proxy breaks plugin internal state.
|
|
285
|
+
|
|
220
286
|
## Composables
|
|
221
287
|
|
|
222
288
|
### useGrid
|
|
@@ -480,6 +546,19 @@ const props = defineProps<{
|
|
|
480
546
|
| `VueCellEditor` | Deprecated - use `CellEditor` |
|
|
481
547
|
| `VueTypeDefault` | Deprecated - use `TypeDefault` |
|
|
482
548
|
|
|
549
|
+
## Requirements
|
|
550
|
+
|
|
551
|
+
- **Vue 3.4+** (uses `defineModel` and improved generics)
|
|
552
|
+
- **@toolbox-web/grid** (peer dependency)
|
|
553
|
+
|
|
554
|
+
## Demo
|
|
555
|
+
|
|
556
|
+
See the [Vue demo app](../../demos/employee-management/vue/) for a full-featured example using `@toolbox-web/grid-vue`.
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
bun nx serve demo-vue
|
|
560
|
+
```
|
|
561
|
+
|
|
483
562
|
## Building
|
|
484
563
|
|
|
485
564
|
```bash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pinned-columns.js","sources":["../../../../libs/grid-vue/src/features/pinned-columns.ts"],"sourcesContent":["/**\n * Pinned columns feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `pinnedColumns` prop on TbwGrid.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/pinned-columns';\n * </script>\n *\n * <template>\n * <TbwGrid pinnedColumns :columns=\"[\n * { field: 'id',
|
|
1
|
+
{"version":3,"file":"pinned-columns.js","sources":["../../../../libs/grid-vue/src/features/pinned-columns.ts"],"sourcesContent":["/**\n * Pinned columns feature for @toolbox-web/grid-vue\n *\n * Import this module to enable the `pinnedColumns` prop on TbwGrid.\n *\n * @example\n * ```vue\n * <script setup>\n * import '@toolbox-web/grid-vue/features/pinned-columns';\n * </script>\n *\n * <template>\n * <TbwGrid pinnedColumns :columns=\"[\n * { field: 'id', pinned: 'left' },\n * { field: 'name' },\n * ]\" />\n * </template>\n * ```\n *\n * @packageDocumentation\n */\n\nimport { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';\nimport { registerFeature } from '../lib/feature-registry';\n\nregisterFeature('pinnedColumns', () => {\n return new PinnedColumnsPlugin();\n});\n"],"names":["registerFeature","PinnedColumnsPlugin"],"mappings":";;AAyBAA,EAAgB,iBAAiB,MACxB,IAAIC,EAAA,CACZ;"}
|
package/lib/feature-props.d.ts
CHANGED
|
@@ -156,9 +156,9 @@ export interface FeatureProps<TRow = unknown> {
|
|
|
156
156
|
* @example
|
|
157
157
|
* ```vue
|
|
158
158
|
* <TbwGrid pinnedColumns :columns="[
|
|
159
|
-
* { field: 'id',
|
|
159
|
+
* { field: 'id', pinned: 'left' },
|
|
160
160
|
* { field: 'name' },
|
|
161
|
-
* { field: 'actions',
|
|
161
|
+
* { field: 'actions', pinned: 'right' },
|
|
162
162
|
* ]" />
|
|
163
163
|
* ```
|
|
164
164
|
*/
|