@rowick/vue 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +35 -2
- package/dist/index.d.ts +19 -0
- package/dist/index.js +64 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rowick contributors
|
|
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,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rowick/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue adapter for Rowick.
|
|
4
|
+
|
|
5
|
+
Use this package when you want Vue bindings for the framework-agnostic core without the optional styled UI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @rowick/vue vue
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { computed } from "vue";
|
|
17
|
+
import { createColumnHelper, useGrid, useGridSelector } from "@rowick/vue";
|
|
18
|
+
|
|
19
|
+
const column = createColumnHelper<{ id: string; name: string }>();
|
|
20
|
+
const options = computed(() => ({
|
|
21
|
+
data: [{ id: "1", name: "Mina" }],
|
|
22
|
+
columns: [column.accessor("name", { header: "Name" })],
|
|
23
|
+
getRowId: (row: { id: string }) => row.id,
|
|
24
|
+
}));
|
|
25
|
+
const { grid, state, dispose } = useGrid(options);
|
|
26
|
+
const { selected: selectedRowCount } = useGridSelector(
|
|
27
|
+
grid,
|
|
28
|
+
(currentGrid) => Object.keys(currentGrid.getState().rowSelection).length,
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`state` is a shallow ref updated by core subscriptions; `dispose` is called automatically inside a Vue effect scope. Use [`@rowick/vue-ui`](https://www.npmjs.com/package/@rowick/vue-ui) for the maintained styled grid.
|
|
33
|
+
|
|
34
|
+
`useGridSelector` returns a shallow `selected` ref and updates it only when the
|
|
35
|
+
selected value changes. Its subscription is also disposed with the active Vue
|
|
36
|
+
effect scope, or can be disposed manually through the returned `dispose` function.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GridOptions, GridSelectorSubscriptionOptions, Grid, GridSelector } from '@rowick/core';
|
|
2
|
+
export { AccessorColumnOptions, AccessorFnColumnDef, AccessorKey, AccessorKeyColumnDef, AnyColumnDef, CellContext, CellCoordinate, CellEditEvent, CellEditEventParams, CellEditHistoryAction, CellEditHistoryState, CellEditParserContext, CellEditPhase, CellEditingState, CellEditorContext, CellFillOptions, CellInteractionEvent, CellInteractionEventParams, CellRange, CellRangeSelectionState, ClipboardCellContext, ClipboardCopyOptions, ClipboardPasteOptions, Column, ColumnDef, ColumnFilter, ColumnFiltersState, ColumnHelper, ColumnId, ColumnMovePosition, ColumnOrderState, ColumnPinningPosition, ColumnPinningState, ColumnResizeEvent, ColumnResizeEventParams, ColumnResizePhase, ColumnSizingState, ColumnVisibilityState, DisplayColumnDef, ExpandedState, FilterFn, FitColumnsToWidthOptions, Grid, GridCacheDiagnostics, GridCacheDiagnosticsEntry, GridCacheKey, GridOptions, GridSelector, GridSelectorListener, GridSelectorSubscriptionOptions, GridState, GroupColumnDef, GroupingState, Header, HeaderContext, HeaderGroup, MoveFocusOptions, PaginationState, Row, RowId, RowInteractionEvent, RowInteractionEventParams, RowModel, RowSelectionCleanupScope, RowSelectionState, SortFn, SortingRule, SortingState, Updater, createColumnHelper, createGrid, fitColumnsToWidth } from '@rowick/core';
|
|
3
|
+
import { MaybeRefOrGetter, ShallowRef } from 'vue';
|
|
4
|
+
|
|
5
|
+
interface VueGrid<TData> {
|
|
6
|
+
grid: Grid<TData>;
|
|
7
|
+
state: ShallowRef<ReturnType<Grid<TData>["getState"]>>;
|
|
8
|
+
dispose: () => void;
|
|
9
|
+
}
|
|
10
|
+
type UseGridOptions<TData> = MaybeRefOrGetter<GridOptions<TData>>;
|
|
11
|
+
interface VueGridSelector<TSelected> {
|
|
12
|
+
selected: ShallowRef<TSelected>;
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
}
|
|
15
|
+
type UseGridSelectorOptions<TSelected> = Pick<GridSelectorSubscriptionOptions<TSelected>, "equalityFn">;
|
|
16
|
+
declare function useGrid<TData>(options: UseGridOptions<TData>): VueGrid<TData>;
|
|
17
|
+
declare function useGridSelector<TData, TSelected>(grid: Grid<TData>, selector: GridSelector<TData, TSelected>, options?: UseGridSelectorOptions<TSelected>): VueGridSelector<TSelected>;
|
|
18
|
+
|
|
19
|
+
export { type UseGridOptions, type UseGridSelectorOptions, type VueGrid, type VueGridSelector, useGrid, useGridSelector };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createGrid
|
|
4
|
+
} from "@rowick/core";
|
|
5
|
+
import {
|
|
6
|
+
getCurrentScope,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
shallowRef,
|
|
9
|
+
toValue,
|
|
10
|
+
triggerRef,
|
|
11
|
+
watchEffect
|
|
12
|
+
} from "vue";
|
|
13
|
+
import { createColumnHelper, fitColumnsToWidth } from "@rowick/core";
|
|
14
|
+
function useGrid(options) {
|
|
15
|
+
const grid = createGrid(toValue(options));
|
|
16
|
+
const state = shallowRef(grid.getState());
|
|
17
|
+
const unsubscribe = grid.subscribe(() => {
|
|
18
|
+
state.value = grid.getState();
|
|
19
|
+
triggerRef(state);
|
|
20
|
+
});
|
|
21
|
+
const stopOptions = watchEffect(() => {
|
|
22
|
+
grid.setOptions(toValue(options), { notify: false });
|
|
23
|
+
grid.reconcileState();
|
|
24
|
+
state.value = grid.getState();
|
|
25
|
+
triggerRef(state);
|
|
26
|
+
});
|
|
27
|
+
const dispose = () => {
|
|
28
|
+
stopOptions();
|
|
29
|
+
unsubscribe();
|
|
30
|
+
};
|
|
31
|
+
if (getCurrentScope()) {
|
|
32
|
+
onScopeDispose(dispose);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
grid,
|
|
36
|
+
state,
|
|
37
|
+
dispose
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function useGridSelector(grid, selector, options) {
|
|
41
|
+
const selected = shallowRef(selector(grid));
|
|
42
|
+
const dispose = grid.subscribeSelector(
|
|
43
|
+
selector,
|
|
44
|
+
(nextValue) => {
|
|
45
|
+
if (Object.is(selected.value, nextValue)) {
|
|
46
|
+
triggerRef(selected);
|
|
47
|
+
} else {
|
|
48
|
+
selected.value = nextValue;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
options
|
|
52
|
+
);
|
|
53
|
+
if (getCurrentScope()) {
|
|
54
|
+
onScopeDispose(dispose);
|
|
55
|
+
}
|
|
56
|
+
return { selected, dispose };
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
createColumnHelper,
|
|
60
|
+
createGrid,
|
|
61
|
+
fitColumnsToWidth,
|
|
62
|
+
useGrid,
|
|
63
|
+
useGridSelector
|
|
64
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowick/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Vue adapter for Rowick.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"data-grid",
|
|
7
|
+
"grid",
|
|
8
|
+
"table",
|
|
9
|
+
"vue",
|
|
10
|
+
"adapter"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/Goatshave/rowick/tree/main/packages/vue#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Goatshave/rowick/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
34
|
+
"check": "tsc --noEmit",
|
|
35
|
+
"test": "vitest run --passWithNoTests",
|
|
36
|
+
"lint": "tsc --noEmit"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@rowick/core": "0.1.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"vue": "^3.4.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"tsup": "^8.3.5",
|
|
46
|
+
"typescript": "^5.7.2",
|
|
47
|
+
"vitest": "^4.1.11",
|
|
48
|
+
"vue": "^3.5.44"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/Goatshave/rowick.git",
|
|
53
|
+
"directory": "packages/vue"
|
|
54
|
+
}
|
|
55
|
+
}
|