@indielayer/ui 1.16.0 → 1.17.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/docs/components/menu/DocsMenu.vue +3 -0
- package/docs/pages/component/infiniteLoader/composable.vue +168 -0
- package/docs/pages/component/infiniteLoader/index.vue +36 -0
- package/docs/pages/component/infiniteLoader/usage.vue +161 -0
- package/docs/pages/component/virtualGrid/index.vue +29 -0
- package/docs/pages/component/virtualGrid/usage.vue +20 -0
- package/docs/pages/component/virtualList/dynamicHeight.vue +75 -0
- package/docs/pages/component/virtualList/index.vue +36 -0
- package/docs/pages/component/virtualList/usage.vue +17 -0
- package/docs/search/components.json +1 -1
- package/lib/components/select/Select.vue.js +35 -35
- package/lib/components/table/Table.vue.js +1 -1
- package/lib/composables/useVirtualList.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +88 -76
- package/lib/index.umd.js +4 -4
- package/lib/install.js +15 -7
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.test.d.ts +1 -0
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue.d.ts +49 -0
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue.js +21 -0
- package/lib/virtual/components/infiniteLoader/InfiniteLoader.vue2.js +4 -0
- package/lib/virtual/components/virtualGrid/VirtualGrid.vue.d.ts +185 -0
- package/lib/virtual/components/virtualGrid/VirtualGrid.vue.js +241 -0
- package/lib/virtual/components/virtualGrid/VirtualGrid.vue2.js +4 -0
- package/lib/virtual/components/virtualGrid/types.d.ts +138 -0
- package/lib/virtual/components/virtualList/VirtualList.test.d.ts +1 -0
- package/lib/virtual/components/virtualList/VirtualList.vue.d.ts +135 -0
- package/lib/virtual/components/virtualList/VirtualList.vue.js +157 -0
- package/lib/virtual/components/virtualList/VirtualList.vue2.js +4 -0
- package/lib/virtual/components/virtualList/isDynamicRowHeight.d.ts +2 -0
- package/lib/virtual/components/virtualList/isDynamicRowHeight.js +6 -0
- package/lib/virtual/components/virtualList/types.d.ts +115 -0
- package/lib/virtual/components/virtualList/useDynamicRowHeight.d.ts +7 -0
- package/lib/virtual/components/virtualList/useDynamicRowHeight.js +69 -0
- package/lib/virtual/components/virtualList/useDynamicRowHeight.test.d.ts +1 -0
- package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.d.ts +8 -0
- package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.js +41 -0
- package/lib/virtual/composables/infinite-loader/scanForUnloadedIndices.test.d.ts +1 -0
- package/lib/virtual/composables/infinite-loader/types.d.ts +30 -0
- package/lib/virtual/composables/infinite-loader/useInfiniteLoader.d.ts +6 -0
- package/lib/virtual/composables/infinite-loader/useInfiniteLoader.js +42 -0
- package/lib/virtual/composables/infinite-loader/useInfiniteLoader.test.d.ts +1 -0
- package/lib/virtual/core/createCachedBounds.d.ts +6 -0
- package/lib/virtual/core/createCachedBounds.js +55 -0
- package/lib/virtual/core/getEstimatedSize.d.ts +6 -0
- package/lib/virtual/core/getEstimatedSize.js +22 -0
- package/lib/virtual/core/getOffsetForIndex.d.ts +11 -0
- package/lib/virtual/core/getOffsetForIndex.js +40 -0
- package/lib/virtual/core/getStartStopIndices.d.ts +13 -0
- package/lib/virtual/core/getStartStopIndices.js +31 -0
- package/lib/virtual/core/getStartStopIndices.test.d.ts +1 -0
- package/lib/virtual/core/types.d.ts +11 -0
- package/lib/virtual/core/useCachedBounds.d.ts +7 -0
- package/lib/virtual/core/useCachedBounds.js +18 -0
- package/lib/virtual/core/useIsRtl.d.ts +2 -0
- package/lib/virtual/core/useIsRtl.js +15 -0
- package/lib/virtual/core/useItemSize.d.ts +5 -0
- package/lib/virtual/core/useItemSize.js +27 -0
- package/lib/virtual/core/useVirtualizer.d.ts +33 -0
- package/lib/virtual/core/useVirtualizer.js +171 -0
- package/lib/virtual/index.d.ts +9 -0
- package/lib/virtual/test-utils/mockResizeObserver.d.ts +15 -0
- package/lib/virtual/types.d.ts +2 -0
- package/lib/virtual/utils/adjustScrollOffsetForRtl.d.ts +7 -0
- package/lib/virtual/utils/adjustScrollOffsetForRtl.js +24 -0
- package/lib/virtual/utils/areArraysEqual.d.ts +1 -0
- package/lib/virtual/utils/assert.d.ts +1 -0
- package/lib/virtual/utils/assert.js +7 -0
- package/lib/virtual/utils/getRTLOffsetType.d.ts +2 -0
- package/lib/virtual/utils/getRTLOffsetType.js +13 -0
- package/lib/virtual/utils/getScrollbarSize.d.ts +2 -0
- package/lib/virtual/utils/getScrollbarSize.js +11 -0
- package/lib/virtual/utils/isRtl.d.ts +1 -0
- package/lib/virtual/utils/isRtl.js +12 -0
- package/lib/virtual/utils/parseNumericStyleValue.d.ts +2 -0
- package/lib/virtual/utils/parseNumericStyleValue.js +15 -0
- package/lib/virtual/utils/shallowCompare.d.ts +1 -0
- package/lib/virtual/utils/shallowCompare.js +14 -0
- package/package.json +1 -1
- package/src/components/select/Select.vue +3 -2
- package/src/components/table/Table.vue +1 -1
- package/src/composables/useVirtualList.ts +1 -1
- package/src/index.ts +1 -0
- package/src/install.ts +9 -3
- package/src/version.ts +1 -1
- package/src/virtual/README.md +285 -0
- package/src/virtual/components/infiniteLoader/InfiniteLoader.test.ts +96 -0
- package/src/virtual/components/infiniteLoader/InfiniteLoader.vue +18 -0
- package/src/virtual/components/virtualGrid/VirtualGrid.vue +322 -0
- package/src/virtual/components/virtualGrid/types.ts +160 -0
- package/src/virtual/components/virtualList/VirtualList.test.ts +47 -0
- package/src/virtual/components/virtualList/VirtualList.vue +233 -0
- package/src/virtual/components/virtualList/isDynamicRowHeight.ts +13 -0
- package/src/virtual/components/virtualList/types.ts +127 -0
- package/src/virtual/components/virtualList/useDynamicRowHeight.test.ts +183 -0
- package/src/virtual/components/virtualList/useDynamicRowHeight.ts +147 -0
- package/src/virtual/composables/infinite-loader/scanForUnloadedIndices.test.ts +141 -0
- package/src/virtual/composables/infinite-loader/scanForUnloadedIndices.ts +82 -0
- package/src/virtual/composables/infinite-loader/types.ts +36 -0
- package/src/virtual/composables/infinite-loader/useInfiniteLoader.test.ts +236 -0
- package/src/virtual/composables/infinite-loader/useInfiniteLoader.ts +88 -0
- package/src/virtual/core/createCachedBounds.ts +72 -0
- package/src/virtual/core/getEstimatedSize.ts +29 -0
- package/src/virtual/core/getOffsetForIndex.ts +90 -0
- package/src/virtual/core/getStartStopIndices.test.ts +45 -0
- package/src/virtual/core/getStartStopIndices.ts +71 -0
- package/src/virtual/core/types.ts +17 -0
- package/src/virtual/core/useCachedBounds.ts +21 -0
- package/src/virtual/core/useIsRtl.ts +25 -0
- package/src/virtual/core/useItemSize.ts +34 -0
- package/src/virtual/core/useVirtualizer.ts +294 -0
- package/src/virtual/index.ts +25 -0
- package/src/virtual/test-utils/mockResizeObserver.ts +162 -0
- package/src/virtual/types.ts +3 -0
- package/src/virtual/utils/adjustScrollOffsetForRtl.ts +37 -0
- package/src/virtual/utils/areArraysEqual.ts +13 -0
- package/src/virtual/utils/assert.ts +10 -0
- package/src/virtual/utils/getRTLOffsetType.ts +51 -0
- package/src/virtual/utils/getScrollbarSize.ts +24 -0
- package/src/virtual/utils/isRtl.ts +13 -0
- package/src/virtual/utils/parseNumericStyleValue.ts +19 -0
- package/src/virtual/utils/shallowCompare.ts +29 -0
- package/volar.d.ts +3 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { assert as f } from "../utils/assert.js";
|
|
2
|
+
function d({
|
|
3
|
+
itemCount: u,
|
|
4
|
+
itemProps: a,
|
|
5
|
+
itemSize: r
|
|
6
|
+
}) {
|
|
7
|
+
const e = /* @__PURE__ */ new Map();
|
|
8
|
+
return {
|
|
9
|
+
get(s) {
|
|
10
|
+
for (f(s < u, `Invalid index ${s}`); e.size - 1 < s; ) {
|
|
11
|
+
const t = e.size;
|
|
12
|
+
let c;
|
|
13
|
+
switch (typeof r) {
|
|
14
|
+
case "function": {
|
|
15
|
+
c = r(t, a);
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case "number": {
|
|
19
|
+
c = r;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (t === 0)
|
|
24
|
+
e.set(t, {
|
|
25
|
+
size: c,
|
|
26
|
+
scrollOffset: 0
|
|
27
|
+
});
|
|
28
|
+
else {
|
|
29
|
+
const n = e.get(t - 1);
|
|
30
|
+
f(
|
|
31
|
+
n !== void 0,
|
|
32
|
+
`Unexpected bounds cache miss for index ${s}`
|
|
33
|
+
), e.set(t, {
|
|
34
|
+
scrollOffset: n.scrollOffset + n.size,
|
|
35
|
+
size: c
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const o = e.get(s);
|
|
40
|
+
return f(
|
|
41
|
+
o !== void 0,
|
|
42
|
+
`Unexpected bounds cache miss for index ${s}`
|
|
43
|
+
), o;
|
|
44
|
+
},
|
|
45
|
+
set(s, o) {
|
|
46
|
+
e.set(s, o);
|
|
47
|
+
},
|
|
48
|
+
get size() {
|
|
49
|
+
return e.size;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
d as createCachedBounds
|
|
55
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CachedBounds, SizeFunction } from './types';
|
|
2
|
+
export declare function getEstimatedSize<Props extends object>({ cachedBounds, itemCount, itemSize, }: {
|
|
3
|
+
cachedBounds: CachedBounds;
|
|
4
|
+
itemCount: number;
|
|
5
|
+
itemSize: number | SizeFunction<Props>;
|
|
6
|
+
}): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assert as f } from "../utils/assert.js";
|
|
2
|
+
function o({
|
|
3
|
+
cachedBounds: e,
|
|
4
|
+
itemCount: s,
|
|
5
|
+
itemSize: t
|
|
6
|
+
}) {
|
|
7
|
+
if (s === 0)
|
|
8
|
+
return 0;
|
|
9
|
+
if (typeof t == "number")
|
|
10
|
+
return s * t;
|
|
11
|
+
{
|
|
12
|
+
const r = e.get(
|
|
13
|
+
e.size === 0 ? 0 : e.size - 1
|
|
14
|
+
);
|
|
15
|
+
f(r !== void 0, "Unexpected bounds cache miss");
|
|
16
|
+
const i = (r.scrollOffset + r.size) / e.size;
|
|
17
|
+
return s * i;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
o as getEstimatedSize
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Align } from '../types';
|
|
2
|
+
import type { CachedBounds, SizeFunction } from './types';
|
|
3
|
+
export declare function getOffsetForIndex<Props extends object>({ align, cachedBounds, index, itemCount, itemSize, containerScrollOffset, containerSize, }: {
|
|
4
|
+
align: Align;
|
|
5
|
+
cachedBounds: CachedBounds;
|
|
6
|
+
index: number;
|
|
7
|
+
itemCount: number;
|
|
8
|
+
itemSize: number | SizeFunction<Props>;
|
|
9
|
+
containerScrollOffset: number;
|
|
10
|
+
containerSize: number;
|
|
11
|
+
}): number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getEstimatedSize as o } from "./getEstimatedSize.js";
|
|
2
|
+
function p({
|
|
3
|
+
align: u,
|
|
4
|
+
cachedBounds: l,
|
|
5
|
+
index: r,
|
|
6
|
+
itemCount: a,
|
|
7
|
+
itemSize: d,
|
|
8
|
+
containerScrollOffset: e,
|
|
9
|
+
containerSize: t
|
|
10
|
+
}) {
|
|
11
|
+
if (r < 0 || r >= a)
|
|
12
|
+
throw new RangeError(
|
|
13
|
+
`Invalid index specified: ${r}. Index ${r} is not within the range of 0 - ${a - 1}`
|
|
14
|
+
);
|
|
15
|
+
const h = o({
|
|
16
|
+
cachedBounds: l,
|
|
17
|
+
itemCount: a,
|
|
18
|
+
itemSize: d
|
|
19
|
+
}), s = l.get(r), m = Math.max(
|
|
20
|
+
0,
|
|
21
|
+
Math.min(h - t, s.scrollOffset)
|
|
22
|
+
), f = Math.max(
|
|
23
|
+
0,
|
|
24
|
+
s.scrollOffset - t + s.size
|
|
25
|
+
);
|
|
26
|
+
switch (u === "smart" && (e >= f && e <= m ? u = "auto" : u = "center"), u) {
|
|
27
|
+
case "start":
|
|
28
|
+
return m;
|
|
29
|
+
case "end":
|
|
30
|
+
return f;
|
|
31
|
+
case "center":
|
|
32
|
+
return s.scrollOffset <= t / 2 ? 0 : s.scrollOffset + s.size / 2 >= h - t / 2 ? h - t : s.scrollOffset + s.size / 2 - t / 2;
|
|
33
|
+
case "auto":
|
|
34
|
+
default:
|
|
35
|
+
return e >= f && e <= m ? e : e < f ? f : m;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
p as getOffsetForIndex
|
|
40
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CachedBounds } from './types';
|
|
2
|
+
export declare function getStartStopIndices({ cachedBounds, containerScrollOffset, containerSize, itemCount, overscanCount, }: {
|
|
3
|
+
cachedBounds: CachedBounds;
|
|
4
|
+
containerScrollOffset: number;
|
|
5
|
+
containerSize: number;
|
|
6
|
+
itemCount: number;
|
|
7
|
+
overscanCount: number;
|
|
8
|
+
}): {
|
|
9
|
+
startIndexVisible: number;
|
|
10
|
+
stopIndexVisible: number;
|
|
11
|
+
startIndexOverscan: number;
|
|
12
|
+
stopIndexOverscan: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function f({
|
|
2
|
+
cachedBounds: a,
|
|
3
|
+
containerScrollOffset: x,
|
|
4
|
+
containerSize: b,
|
|
5
|
+
itemCount: d,
|
|
6
|
+
overscanCount: I
|
|
7
|
+
}) {
|
|
8
|
+
const i = d - 1;
|
|
9
|
+
let t = 0, n = -1, l = 0, r = -1, e = 0;
|
|
10
|
+
for (; e < i; ) {
|
|
11
|
+
const s = a.get(e);
|
|
12
|
+
if (s.scrollOffset + s.size > x)
|
|
13
|
+
break;
|
|
14
|
+
e++;
|
|
15
|
+
}
|
|
16
|
+
for (t = e, l = Math.max(0, t - I); e < i; ) {
|
|
17
|
+
const s = a.get(e);
|
|
18
|
+
if (s.scrollOffset + s.size >= x + b)
|
|
19
|
+
break;
|
|
20
|
+
e++;
|
|
21
|
+
}
|
|
22
|
+
return n = Math.min(i, e), r = Math.min(d - 1, n + I), t < 0 && (t = 0, n = -1, l = 0, r = -1), {
|
|
23
|
+
startIndexVisible: t,
|
|
24
|
+
stopIndexVisible: n,
|
|
25
|
+
startIndexOverscan: l,
|
|
26
|
+
stopIndexOverscan: r
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
f as getStartStopIndices
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Bounds = {
|
|
2
|
+
size: number;
|
|
3
|
+
scrollOffset: number;
|
|
4
|
+
};
|
|
5
|
+
export type CachedBounds = {
|
|
6
|
+
get(index: number): Bounds;
|
|
7
|
+
set(index: number, bounds: Bounds): void;
|
|
8
|
+
size: number;
|
|
9
|
+
};
|
|
10
|
+
export type Direction = 'horizontal' | 'vertical';
|
|
11
|
+
export type SizeFunction<Props extends object> = (index: number, props: Props) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
|
+
import type { CachedBounds, SizeFunction } from './types';
|
|
3
|
+
export declare function useCachedBounds<Props extends object>({ itemCount, itemProps, itemSize, }: {
|
|
4
|
+
itemCount: number;
|
|
5
|
+
itemProps: Props;
|
|
6
|
+
itemSize: number | SizeFunction<Props>;
|
|
7
|
+
}): ComputedRef<CachedBounds>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { computed as t } from "vue";
|
|
2
|
+
import { createCachedBounds as u } from "./createCachedBounds.js";
|
|
3
|
+
function m({
|
|
4
|
+
itemCount: o,
|
|
5
|
+
itemProps: e,
|
|
6
|
+
itemSize: r
|
|
7
|
+
}) {
|
|
8
|
+
return t(
|
|
9
|
+
() => u({
|
|
10
|
+
itemCount: o,
|
|
11
|
+
itemProps: e,
|
|
12
|
+
itemSize: r
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
m as useCachedBounds
|
|
18
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ref as a, watch as f } from "vue";
|
|
2
|
+
import { isRtl as m } from "../utils/isRtl.js";
|
|
3
|
+
function i(l, r) {
|
|
4
|
+
const t = a(r === "rtl");
|
|
5
|
+
return f(
|
|
6
|
+
[l, () => r],
|
|
7
|
+
([u, e]) => {
|
|
8
|
+
u && (!e || e === "auto" ? t.value = m(u) : t.value = e === "rtl");
|
|
9
|
+
},
|
|
10
|
+
{ immediate: !0 }
|
|
11
|
+
), t;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
i as useIsRtl
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { assert as i } from "../utils/assert.js";
|
|
2
|
+
function n({
|
|
3
|
+
containerSize: t,
|
|
4
|
+
itemSize: e
|
|
5
|
+
}) {
|
|
6
|
+
let s;
|
|
7
|
+
switch (typeof e) {
|
|
8
|
+
case "string": {
|
|
9
|
+
i(
|
|
10
|
+
e.endsWith("%"),
|
|
11
|
+
`Invalid item size: "${e}"; string values must be percentages (e.g. "100%")`
|
|
12
|
+
), i(
|
|
13
|
+
t !== void 0,
|
|
14
|
+
"Container size must be defined if a percentage item size is specified"
|
|
15
|
+
), s = t * parseInt(e) / 100;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
default: {
|
|
19
|
+
s = e;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
n as useItemSize
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ComputedRef, type CSSProperties, type Ref } from 'vue';
|
|
2
|
+
import type { Align } from '../types';
|
|
3
|
+
import type { Direction, SizeFunction } from './types';
|
|
4
|
+
export declare function useVirtualizer<Props extends object>({ containerElement, containerStyle, defaultContainerSize, direction, isRtl, itemCount: itemCountInput, itemProps: itemPropsInput, itemSize: itemSizeProp, onResize, overscanCount, }: {
|
|
5
|
+
containerElement: Ref<HTMLElement | null>;
|
|
6
|
+
containerStyle?: CSSProperties;
|
|
7
|
+
defaultContainerSize?: number;
|
|
8
|
+
direction: Direction;
|
|
9
|
+
isRtl?: boolean;
|
|
10
|
+
itemCount: number | Ref<number> | ComputedRef<number>;
|
|
11
|
+
itemProps: Props | ComputedRef<Props>;
|
|
12
|
+
itemSize: number | string | SizeFunction<Props> | Ref<number | string | SizeFunction<Props>> | ComputedRef<number | string | SizeFunction<Props>>;
|
|
13
|
+
onResize: ((size: {
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
}, prevSize: {
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
19
|
+
}) => void) | undefined;
|
|
20
|
+
overscanCount: number;
|
|
21
|
+
}): {
|
|
22
|
+
getCellBounds: (index: number) => import("./types").Bounds;
|
|
23
|
+
getEstimatedSize: ComputedRef<number>;
|
|
24
|
+
scrollToIndex: ({ align, containerScrollOffset, index, }: {
|
|
25
|
+
align?: Align | undefined;
|
|
26
|
+
containerScrollOffset: number;
|
|
27
|
+
index: number;
|
|
28
|
+
}) => number | undefined;
|
|
29
|
+
startIndexOverscan: ComputedRef<number>;
|
|
30
|
+
startIndexVisible: ComputedRef<number>;
|
|
31
|
+
stopIndexOverscan: ComputedRef<number>;
|
|
32
|
+
stopIndexVisible: ComputedRef<number>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { computed as t, isRef as w, ref as b, watch as N } from "vue";
|
|
2
|
+
import { useResizeObserver as q, useEventListener as A } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
|
|
3
|
+
import { parseNumericStyleValue as $ } from "../utils/parseNumericStyleValue.js";
|
|
4
|
+
import { adjustScrollOffsetForRtl as V } from "../utils/adjustScrollOffsetForRtl.js";
|
|
5
|
+
import { shallowCompare as j } from "../utils/shallowCompare.js";
|
|
6
|
+
import { getEstimatedSize as G } from "./getEstimatedSize.js";
|
|
7
|
+
import { getOffsetForIndex as J } from "./getOffsetForIndex.js";
|
|
8
|
+
import { getStartStopIndices as B } from "./getStartStopIndices.js";
|
|
9
|
+
import { useCachedBounds as K } from "./useCachedBounds.js";
|
|
10
|
+
import { useItemSize as Q } from "./useItemSize.js";
|
|
11
|
+
function ie({
|
|
12
|
+
containerElement: u,
|
|
13
|
+
containerStyle: n,
|
|
14
|
+
defaultContainerSize: d = 0,
|
|
15
|
+
direction: i,
|
|
16
|
+
isRtl: p = !1,
|
|
17
|
+
itemCount: g,
|
|
18
|
+
itemProps: x,
|
|
19
|
+
itemSize: I,
|
|
20
|
+
onResize: T,
|
|
21
|
+
overscanCount: z
|
|
22
|
+
}) {
|
|
23
|
+
const l = t(() => w(g) ? g.value : g), D = t(() => w(x) ? x.value : x), H = t(() => w(I) ? I.value : I), C = t(() => $(n == null ? void 0 : n.height)), M = t(() => $(n == null ? void 0 : n.width)), f = b({
|
|
24
|
+
height: i === "vertical" ? d : void 0,
|
|
25
|
+
width: i === "horizontal" ? d : void 0
|
|
26
|
+
}), R = t(
|
|
27
|
+
() => i === "vertical" && C.value !== void 0 || i === "horizontal" && M.value !== void 0
|
|
28
|
+
);
|
|
29
|
+
q(
|
|
30
|
+
u,
|
|
31
|
+
(e) => {
|
|
32
|
+
if (!R.value)
|
|
33
|
+
for (const s of e) {
|
|
34
|
+
const { contentRect: a } = s, o = f.value;
|
|
35
|
+
if (o.height === a.height && o.width === a.width)
|
|
36
|
+
return;
|
|
37
|
+
f.value = {
|
|
38
|
+
height: a.height,
|
|
39
|
+
width: a.width
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
const O = t(() => ({
|
|
45
|
+
height: C.value ?? f.value.height,
|
|
46
|
+
width: M.value ?? f.value.width
|
|
47
|
+
})), L = b({
|
|
48
|
+
height: 0,
|
|
49
|
+
width: 0
|
|
50
|
+
});
|
|
51
|
+
N(
|
|
52
|
+
O,
|
|
53
|
+
(e) => {
|
|
54
|
+
if (typeof T == "function") {
|
|
55
|
+
const s = L.value, a = e.height ?? 0, o = e.width ?? 0;
|
|
56
|
+
(s.height !== a || s.width !== o) && (T({ height: a, width: o }, { ...s }), L.value = { height: a, width: o });
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{ immediate: !0 }
|
|
60
|
+
);
|
|
61
|
+
const h = t(
|
|
62
|
+
() => i === "vertical" ? O.value.height ?? d : O.value.width ?? d
|
|
63
|
+
), S = t(
|
|
64
|
+
() => Q({ containerSize: h.value, itemSize: H.value })
|
|
65
|
+
), r = t(
|
|
66
|
+
() => K({
|
|
67
|
+
itemCount: l.value,
|
|
68
|
+
itemProps: D.value,
|
|
69
|
+
itemSize: S.value
|
|
70
|
+
}).value
|
|
71
|
+
), W = (e) => r.value.get(e), v = b(
|
|
72
|
+
B({
|
|
73
|
+
cachedBounds: r.value,
|
|
74
|
+
containerScrollOffset: 0,
|
|
75
|
+
containerSize: h.value,
|
|
76
|
+
itemCount: l.value,
|
|
77
|
+
overscanCount: z
|
|
78
|
+
})
|
|
79
|
+
), m = t(() => {
|
|
80
|
+
const e = v.value;
|
|
81
|
+
return {
|
|
82
|
+
startIndexVisible: Math.min(l.value - 1, e.startIndexVisible),
|
|
83
|
+
startIndexOverscan: Math.min(l.value - 1, e.startIndexOverscan),
|
|
84
|
+
stopIndexVisible: Math.min(l.value - 1, e.stopIndexVisible),
|
|
85
|
+
stopIndexOverscan: Math.min(l.value - 1, e.stopIndexOverscan)
|
|
86
|
+
};
|
|
87
|
+
}), k = t(
|
|
88
|
+
() => G({
|
|
89
|
+
cachedBounds: r.value,
|
|
90
|
+
itemCount: l.value,
|
|
91
|
+
itemSize: S.value
|
|
92
|
+
})
|
|
93
|
+
), E = (e) => {
|
|
94
|
+
const s = V({
|
|
95
|
+
containerElement: u.value,
|
|
96
|
+
direction: i,
|
|
97
|
+
isRtl: p,
|
|
98
|
+
scrollOffset: e
|
|
99
|
+
});
|
|
100
|
+
return B({
|
|
101
|
+
cachedBounds: r.value,
|
|
102
|
+
containerScrollOffset: s,
|
|
103
|
+
containerSize: h.value,
|
|
104
|
+
itemCount: l.value,
|
|
105
|
+
overscanCount: z
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return N(
|
|
109
|
+
[u, () => i, () => r.value],
|
|
110
|
+
([e]) => {
|
|
111
|
+
const s = (i === "vertical" ? e == null ? void 0 : e.scrollTop : e == null ? void 0 : e.scrollLeft) ?? 0;
|
|
112
|
+
v.value = E(s);
|
|
113
|
+
},
|
|
114
|
+
{ immediate: !0 }
|
|
115
|
+
), A(u, "scroll", () => {
|
|
116
|
+
const e = u.value;
|
|
117
|
+
if (!e)
|
|
118
|
+
return;
|
|
119
|
+
const { scrollLeft: s, scrollTop: a } = e, o = V({
|
|
120
|
+
containerElement: e,
|
|
121
|
+
direction: i,
|
|
122
|
+
isRtl: p,
|
|
123
|
+
scrollOffset: i === "vertical" ? a : s
|
|
124
|
+
}), c = B({
|
|
125
|
+
cachedBounds: r.value,
|
|
126
|
+
containerScrollOffset: o,
|
|
127
|
+
containerSize: h.value,
|
|
128
|
+
itemCount: l.value,
|
|
129
|
+
overscanCount: z
|
|
130
|
+
});
|
|
131
|
+
j(c, v.value) || (v.value = c);
|
|
132
|
+
}), {
|
|
133
|
+
getCellBounds: W,
|
|
134
|
+
getEstimatedSize: k,
|
|
135
|
+
scrollToIndex: ({
|
|
136
|
+
align: e = "auto",
|
|
137
|
+
containerScrollOffset: s,
|
|
138
|
+
index: a
|
|
139
|
+
}) => {
|
|
140
|
+
let o = J({
|
|
141
|
+
align: e,
|
|
142
|
+
cachedBounds: r.value,
|
|
143
|
+
containerScrollOffset: s,
|
|
144
|
+
containerSize: h.value,
|
|
145
|
+
index: a,
|
|
146
|
+
itemCount: l.value,
|
|
147
|
+
itemSize: S.value
|
|
148
|
+
});
|
|
149
|
+
const c = u.value;
|
|
150
|
+
if (c) {
|
|
151
|
+
if (o = V({
|
|
152
|
+
containerElement: c,
|
|
153
|
+
direction: i,
|
|
154
|
+
isRtl: p,
|
|
155
|
+
scrollOffset: o
|
|
156
|
+
}), typeof c.scrollTo != "function") {
|
|
157
|
+
const F = E(o);
|
|
158
|
+
j(v.value, F) || (v.value = F);
|
|
159
|
+
}
|
|
160
|
+
return o;
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
startIndexOverscan: t(() => m.value.startIndexOverscan),
|
|
164
|
+
startIndexVisible: t(() => m.value.startIndexVisible),
|
|
165
|
+
stopIndexOverscan: t(() => m.value.stopIndexOverscan),
|
|
166
|
+
stopIndexVisible: t(() => m.value.stopIndexVisible)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export {
|
|
170
|
+
ie as useVirtualizer
|
|
171
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as XVirtualGrid } from './components/virtualGrid/VirtualGrid.vue';
|
|
2
|
+
export type { CellSlotProps, VirtualGridImperativeAPI, VirtualGridProps, } from './components/virtualGrid/types';
|
|
3
|
+
export { default as XVirtualList } from './components/virtualList/VirtualList.vue';
|
|
4
|
+
export { useDynamicRowHeight } from './components/virtualList/useDynamicRowHeight';
|
|
5
|
+
export type { DynamicRowHeight, VirtualListImperativeAPI, VirtualListProps, RowSlotProps, } from './components/virtualList/types';
|
|
6
|
+
export { default as XInfiniteLoader } from './components/infiniteLoader/InfiniteLoader.vue';
|
|
7
|
+
export { useInfiniteLoader } from './composables/infinite-loader/useInfiniteLoader';
|
|
8
|
+
export type { Indices, OnRowsRendered, InfiniteLoaderProps, } from './composables/infinite-loader/types';
|
|
9
|
+
export { getScrollbarSize } from './utils/getScrollbarSize';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type GetDOMRect = (element: HTMLElement) => DOMRectReadOnly | undefined | void;
|
|
2
|
+
export declare function disableResizeObserverForCurrentTest(): void;
|
|
3
|
+
export declare function setDefaultElementSize({ height, width, }: {
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function setElementSizeFunction(value: GetDOMRect): void;
|
|
8
|
+
export declare function setElementSize({ element, height, width, }: {
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
height: number;
|
|
11
|
+
width: number;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function simulateUnsupportedEnvironmentForTest(): void;
|
|
14
|
+
export declare function mockResizeObserver(): () => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Direction } from '../core/types';
|
|
2
|
+
export declare function adjustScrollOffsetForRtl({ containerElement, direction, isRtl, scrollOffset, }: {
|
|
3
|
+
containerElement: HTMLElement | null;
|
|
4
|
+
direction: Direction;
|
|
5
|
+
isRtl: boolean;
|
|
6
|
+
scrollOffset: number;
|
|
7
|
+
}): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getRTLOffsetType as f } from "./getRTLOffsetType.js";
|
|
2
|
+
function l({
|
|
3
|
+
containerElement: t,
|
|
4
|
+
direction: i,
|
|
5
|
+
isRtl: r,
|
|
6
|
+
scrollOffset: e
|
|
7
|
+
}) {
|
|
8
|
+
if (i === "horizontal" && r)
|
|
9
|
+
switch (f()) {
|
|
10
|
+
case "negative":
|
|
11
|
+
return -e;
|
|
12
|
+
case "positive-descending": {
|
|
13
|
+
if (t) {
|
|
14
|
+
const { clientWidth: o, scrollLeft: s, scrollWidth: c } = t;
|
|
15
|
+
return c - o - s;
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
l as adjustScrollOffsetForRtl
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function areArraysEqual(a: unknown[], b: unknown[]): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assert(expectedCondition: unknown, message?: string): asserts expectedCondition;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let t = null;
|
|
2
|
+
function c(o = !1) {
|
|
3
|
+
if (t === null || o) {
|
|
4
|
+
const e = document.createElement("div"), l = e.style;
|
|
5
|
+
l.width = "50px", l.height = "50px", l.overflow = "scroll", l.direction = "rtl";
|
|
6
|
+
const n = document.createElement("div"), i = n.style;
|
|
7
|
+
return i.width = "100px", i.height = "100px", e.appendChild(n), document.body.appendChild(e), e.scrollLeft > 0 ? t = "positive-descending" : (e.scrollLeft = 1, e.scrollLeft === 0 ? t = "negative" : t = "positive-ascending"), document.body.removeChild(e), t;
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
c as getRTLOffsetType
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let o = -1;
|
|
2
|
+
function i(d = !1) {
|
|
3
|
+
if (o === -1 || d) {
|
|
4
|
+
const e = document.createElement("div"), t = e.style;
|
|
5
|
+
t.width = "50px", t.height = "50px", t.overflow = "scroll", document.body.appendChild(e), o = e.offsetWidth - e.clientWidth, document.body.removeChild(e);
|
|
6
|
+
}
|
|
7
|
+
return o;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
i as getScrollbarSize
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isRtl(element: HTMLElement): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shallowCompare<Type extends object>(a: Type | undefined, b: Type | undefined): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { assert as n } from "./assert.js";
|
|
2
|
+
function i(e, r) {
|
|
3
|
+
if (e === r)
|
|
4
|
+
return !0;
|
|
5
|
+
if (!!e != !!r || (n(e !== void 0), n(r !== void 0), Object.keys(e).length !== Object.keys(r).length))
|
|
6
|
+
return !1;
|
|
7
|
+
for (const t in e)
|
|
8
|
+
if (!Object.is(r[t], e[t]))
|
|
9
|
+
return !1;
|
|
10
|
+
return !0;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
i as shallowCompare
|
|
14
|
+
};
|