@v-c/table 1.0.3 → 1.0.5
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/Table.js +5 -3
- package/dist/VirtualTable/BodyGrid.js +9 -4
- package/dist/interface.d.ts +5 -1
- package/package.json +3 -3
package/dist/Table.js
CHANGED
|
@@ -102,13 +102,15 @@ var ImmutableTable = /* @__PURE__ */ defineComponent((props, { attrs, slots, exp
|
|
|
102
102
|
const targetRef = scrollBodyRef.value;
|
|
103
103
|
const targetElement = getDOM(targetRef);
|
|
104
104
|
if (targetElement instanceof HTMLElement) {
|
|
105
|
-
const { index, top, key, offset } = config || {};
|
|
105
|
+
const { index, top, key, offset, align = "nearest" } = config || {};
|
|
106
106
|
if (validNumberValue(top)) targetElement.scrollTo({ top });
|
|
107
107
|
else {
|
|
108
108
|
const mergedKey = key ?? getRowKey.value(mergedData.value[index]);
|
|
109
109
|
const rowElement = targetElement.querySelector(`[data-row-key="${mergedKey}"]`);
|
|
110
|
-
if (rowElement)
|
|
111
|
-
|
|
110
|
+
if (rowElement) {
|
|
111
|
+
rowElement.scrollIntoView({ block: align });
|
|
112
|
+
if (offset) targetElement.scrollTo({ top: targetElement.scrollTop + offset });
|
|
113
|
+
}
|
|
112
114
|
}
|
|
113
115
|
} else if (targetRef?.scrollTo) targetRef.scrollTo(config);
|
|
114
116
|
}
|
|
@@ -5,6 +5,11 @@ import BodyLine_default from "./BodyLine.js";
|
|
|
5
5
|
import { computed, createVNode, defineComponent, reactive, ref, toRaw, watch, watchEffect } from "vue";
|
|
6
6
|
import { getStylePxValue } from "@v-c/util/dist/props-util";
|
|
7
7
|
import VirtualList from "@v-c/virtual-list";
|
|
8
|
+
var ALIGN_MAP = {
|
|
9
|
+
start: "top",
|
|
10
|
+
end: "bottom",
|
|
11
|
+
nearest: "auto"
|
|
12
|
+
};
|
|
8
13
|
var BodyGrid_default = /* @__PURE__ */ defineComponent({
|
|
9
14
|
name: "TableBodyGrid",
|
|
10
15
|
props: ["data", "onScroll"],
|
|
@@ -102,13 +107,13 @@ var BodyGrid_default = /* @__PURE__ */ defineComponent({
|
|
|
102
107
|
const exposed = {
|
|
103
108
|
scrollTo: (config) => {
|
|
104
109
|
if (!listRef.value) return;
|
|
105
|
-
const { offset, ...restConfig } = config || {};
|
|
106
|
-
|
|
110
|
+
const { align, offset, ...restConfig } = config || {};
|
|
111
|
+
const virtualAlign = ALIGN_MAP[align] ?? (offset ? "top" : "auto");
|
|
112
|
+
listRef.value.scrollTo({
|
|
107
113
|
...restConfig,
|
|
108
114
|
offset,
|
|
109
|
-
align:
|
|
115
|
+
align: virtualAlign
|
|
110
116
|
});
|
|
111
|
-
else listRef.value.scrollTo(config);
|
|
112
117
|
},
|
|
113
118
|
get nativeElement() {
|
|
114
119
|
const native = listRef.value?.nativeElement;
|
package/dist/interface.d.ts
CHANGED
|
@@ -19,10 +19,14 @@ export interface ScrollConfig {
|
|
|
19
19
|
* Additional offset in pixels to apply to the scroll position.
|
|
20
20
|
* Only effective when using `key` or `index` mode.
|
|
21
21
|
* Ignored when using `top` mode.
|
|
22
|
-
*
|
|
22
|
+
* In `key` / `index` mode, `offset` is added to the position resolved by `align`.
|
|
23
23
|
*/
|
|
24
24
|
offset?: number;
|
|
25
|
+
align?: ScrollLogicalPosition;
|
|
25
26
|
}
|
|
27
|
+
export type VirtualScrollConfig = ScrollConfig & {
|
|
28
|
+
align?: Exclude<ScrollLogicalPosition, 'center'>;
|
|
29
|
+
};
|
|
26
30
|
export interface Reference {
|
|
27
31
|
nativeElement: HTMLDivElement;
|
|
28
32
|
scrollTo: (config: ScrollConfig) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/table",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@v-c/resize-observer": "^1.0.8",
|
|
24
|
-
"@v-c/util": "^1.0.
|
|
25
|
-
"@v-c/virtual-list": "^1.0.
|
|
24
|
+
"@v-c/util": "^1.0.19",
|
|
25
|
+
"@v-c/virtual-list": "^1.0.7"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|