@stramien/vue 0.0.0-stage → 0.13.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Erik-Jan van Baaren
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @stramien/vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 3 adapter for [Stramien](https://github.com/stramien/stramien) with `<Teleport>`-based scoped slots (`#cell-<colId>`, `#detail`) and Vue component cell/detail renderers.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @stramien/vue @stramien/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```vue
14
+ <script setup lang="ts">
15
+ import '@stramien/core/styles.css';
16
+ import { ref } from 'vue';
17
+ import { StramienGrid, type ColumnDefItem } from '@stramien/vue';
18
+
19
+ interface Employee {
20
+ id: number;
21
+ name: string;
22
+ status: string;
23
+ salary: number;
24
+ notes: string;
25
+ }
26
+
27
+ const employees = ref<Employee[]>([
28
+ { id: 1, name: 'Alice', status: 'Active', salary: 142000, notes: 'Core architecture' },
29
+ ]);
30
+
31
+ const columnDefs: ColumnDefItem<Employee>[] = [
32
+ { field: 'name', pinned: 'left', filter: 'text', floatingFilter: true, editable: true },
33
+ { field: 'status', filter: 'set' },
34
+ { field: 'salary', dataType: 'number', editable: true, aggFunc: 'avg' },
35
+ { field: 'notes', minWidth: 240, flex: 1, wrapText: true, autoHeight: true },
36
+ ];
37
+ </script>
38
+
39
+ <template>
40
+ <div style="height: 640px">
41
+ <StramienGrid
42
+ :row-data="employees"
43
+ :column-defs="columnDefs"
44
+ :get-row-id="({ data }) => String(data.id)"
45
+ :master-detail="true"
46
+ :pinned-bottom-summary="{ labelColId: 'name', label: 'Summary' }"
47
+ :global-search="true"
48
+ :pagination="true"
49
+ row-selection="multiple"
50
+ >
51
+ <template #cell-status="{ value }">
52
+ <span class="badge">{{ value }}</span>
53
+ </template>
54
+
55
+ <template #detail="{ data }">
56
+ <div><strong>{{ data.name }}</strong> — {{ data.notes }}</div>
57
+ </template>
58
+ </StramienGrid>
59
+ </div>
60
+ </template>
61
+ ```
62
+
63
+ ### How props & slots work
64
+
65
+ - **Scoped slots:** Provide `#cell-<colId>="{ value, formattedValue, data, node, colDef, api }"` for any column, and `#detail="{ data, node, api }"` for Master–Detail rows. All slots render through Vue `<Teleport>`, preserving Pinia, Vue Router, `provide`/`inject`, and reactivity. Each cell is its own component, so a cell re-renders only when its own params change (scrolling does not re-run the slots of cells that stay visible).
66
+ - **Component renderers:** Pass any Vue component (SFC, `defineComponent`, `defineAsyncComponent`) as `cellRenderer` or `detailCellRenderer` in `columnDefs` / props. The component receives only the props it declares: declare `params` to get the whole params object, and/or individual keys (`value`, `formattedValue`, `data`, `node`, `colDef`, `api`, ...). Undeclared keys are not passed, so they never end up as DOM attributes on the component's root element. Exceptions: a component with `inheritAttrs: false` receives every key (read them from `attrs`), and so does an async component that has not finished loading.
67
+ - **Function renderers:** A plain function is called like a Vue functional component, `(props, { attrs, slots, emit })`, where `props` (and `attrs`) is the params object plus a `params` key. It can return a VNode, a string, `null`, or a DOM `Node` (mounted as is). A `props` option on the function is not used for validation or defaults. An inline `detailCellRenderer` function is fine: the grid gets a stable wrapper that calls the latest function, so a parent re-render does not remount rows or open detail panels.
68
+ - **Vanilla DOM renderers:** Wrap plain DOM functions with `vanillaRenderer(fn)` so the grid core renders them directly, without going through Vue.
69
+ - **Error isolation:** If a slot, function or component throws, only that cell (or detail panel) renders empty; the error is logged with `console.error` and the other cells keep rendering.
70
+ - **Changed-prop diffing:** After mount, only props whose value changed (`Object.is`) are sent to `updateOptions`, so unrelated updates never overwrite `applyTransaction` rows, active search text, or imperative `api.setTheme(...)`.
71
+ - **Reactive data:** `rowData`, `pinnedTopRowData` and `pinnedBottomRowData` may be reactive (`ref`, `reactive`). The grid stores the raw objects (`toRaw`), because row identity relies on object identity; `params.data`, `node.data` and `api.getSelectedRows()` therefore return raw objects. Mutating a row in place or pushing onto the array is not picked up: assign a new array or use `api.applyTransaction(...)`. `applyTransaction`, `setRowData` and `setPinned*RowData` accept both raw objects and reactive proxies.
72
+ - **Attributes:** `class`, `style`, `id`, `data-*` and other attributes go on the grid's host `<div>` (which defaults to `width: 100%; height: 100%`), e.g. `<StramienGrid class="my-grid" style="height: 480px" />`.
73
+ - **Grid API:** Access the API via `@grid-ready="({ api }) => ..."` or `gridRef.value?.getApi()`.
74
+
75
+ See the [Stramien documentation](https://github.com/stramien/stramien#readme) for full API details.
76
+
77
+ ## License
78
+
79
+ MIT © 2026 Erik-Jan van Baaren