@yasanchezz/vue-infinite-grid 0.1.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/README.md +3 -0
- package/dist/VueGrid.d.ts +32 -0
- package/dist/favicon.ico +0 -0
- package/dist/main.d.ts +11 -0
- package/dist/vue-infinite-grid.css +2 -0
- package/dist/vue-infinite-grid.js +121 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const __VLS_export: <GridRow extends {
|
|
2
|
+
id: string | number;
|
|
3
|
+
}>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import('vue').PublicProps & __VLS_PrettifyLocal<{
|
|
5
|
+
container?: HTMLElement;
|
|
6
|
+
rows: GridRow[];
|
|
7
|
+
rowsCount: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}> & (typeof globalThis extends {
|
|
10
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
11
|
+
} ? P : {});
|
|
12
|
+
expose: (exposed: import('vue').ShallowUnwrapRef<{
|
|
13
|
+
init(): void;
|
|
14
|
+
scrollTo(id: number | string): void;
|
|
15
|
+
}>) => void;
|
|
16
|
+
attrs: any;
|
|
17
|
+
slots: {
|
|
18
|
+
row(props: {
|
|
19
|
+
row: GridRow;
|
|
20
|
+
}): unknown;
|
|
21
|
+
};
|
|
22
|
+
emit: {};
|
|
23
|
+
}>) => import('vue').VNode & {
|
|
24
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
25
|
+
};
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
29
|
+
[K in keyof T]: T[K];
|
|
30
|
+
} : {
|
|
31
|
+
[K in keyof T as K]: T[K];
|
|
32
|
+
}) & {};
|
package/dist/favicon.ico
ADDED
|
Binary file
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.infinite-grid[data-v-43bc25ca]{overflow-anchor:none;align-content:start;display:grid;overflow:clip}.grid-row[data-v-43bc25ca]{grid-column:1/-1;grid-template-columns:subgrid;display:grid}.content[data-v-43bc25ca]{display:contents}.before[data-v-43bc25ca],.after[data-v-43bc25ca]{pointer-events:none;grid-column:1/-1}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createElementBlock as n, createElementVNode as r, defineComponent as i, normalizeStyle as a, onMounted as o, onUnmounted as s, openBlock as c, ref as l, renderList as u, renderSlot as d, shallowRef as f, useTemplateRef as p, watch as m, watchEffect as h } from "vue";
|
|
2
|
+
//#region src/VueGrid.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var g = ["data-index"], _ = /*#__PURE__*/ ((e, t) => {
|
|
4
|
+
let n = e.__vccOpts || e;
|
|
5
|
+
for (let [e, r] of t) n[e] = r;
|
|
6
|
+
return n;
|
|
7
|
+
})(/* @__PURE__ */ i({
|
|
8
|
+
__name: "VueGrid",
|
|
9
|
+
props: {
|
|
10
|
+
container: {},
|
|
11
|
+
rows: {},
|
|
12
|
+
rowsCount: {},
|
|
13
|
+
height: {}
|
|
14
|
+
},
|
|
15
|
+
setup(i, { expose: _ }) {
|
|
16
|
+
let v = t(() => new Map(i.rows.map((e) => [String(e.id), e]))), y = f([]), b = p("grid"), x = p("content"), S = /* @__PURE__ */ new Map(), C = i.height * Math.trunc(i.rowsCount / 5) || 1e3, w, T = 0;
|
|
17
|
+
function E() {
|
|
18
|
+
let e = 0, t = b.value;
|
|
19
|
+
for (; t instanceof HTMLElement;) e += t.offsetTop, t = t.offsetParent;
|
|
20
|
+
T = e;
|
|
21
|
+
}
|
|
22
|
+
let D = l({ height: "0px" }), O = 0;
|
|
23
|
+
function k() {
|
|
24
|
+
return O = i.rows.map((e) => S.get(e) ?? i.height).reduce((e, t) => e + t, 0), D.value.height = `${O}px`, O;
|
|
25
|
+
}
|
|
26
|
+
let A = 0;
|
|
27
|
+
function j() {
|
|
28
|
+
A = y.value.map((e) => S.get(e) ?? i.height).reduce((e, t) => e + t, 0);
|
|
29
|
+
}
|
|
30
|
+
let M = l({ height: "0px" }), N = 0;
|
|
31
|
+
function P() {
|
|
32
|
+
let e = (i.container ? i.container.scrollTop : document.body.scrollTop || document.documentElement.scrollTop) - C - T, t = 0;
|
|
33
|
+
for (let n of i.rows) {
|
|
34
|
+
let r = S.get(n) ?? i.height;
|
|
35
|
+
if (t + r > e) break;
|
|
36
|
+
t += r;
|
|
37
|
+
}
|
|
38
|
+
let n = O - A, r = t > n ? n : t;
|
|
39
|
+
return N = r, M.value.height = `${r}px`, r;
|
|
40
|
+
}
|
|
41
|
+
let F = l({ height: "0px" }), I = 0;
|
|
42
|
+
function L() {
|
|
43
|
+
I = O - N - A, F.value.height = `${I}px`;
|
|
44
|
+
}
|
|
45
|
+
function R() {
|
|
46
|
+
cancelAnimationFrame(w), w = requestAnimationFrame(() => {
|
|
47
|
+
E(), j(), k(), P(), L();
|
|
48
|
+
let e = 0, t = 0;
|
|
49
|
+
for (let [n, r] of i.rows.entries()) {
|
|
50
|
+
let a = S.get(r) ?? i.height;
|
|
51
|
+
if (e += a, !(e <= N)) {
|
|
52
|
+
t = n;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let n = t + i.rowsCount > i.rows.length ? i.rows.slice(i.rows.length - i.rowsCount) : i.rows.slice(t, t + i.rowsCount);
|
|
57
|
+
I || (n = i.rows.slice(i.rows.length - i.rowsCount)), n.at(0) !== y.value.at(0) && (y.value = n), j(), k(), L();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
let z = new ResizeObserver((e) => {
|
|
61
|
+
for (let t of e) {
|
|
62
|
+
let e = t.target, n = t.borderBoxSize.at(0)?.blockSize ?? i.height;
|
|
63
|
+
if (e instanceof HTMLElement) {
|
|
64
|
+
let t = e.dataset.index, r = t == null ? void 0 : v.value.get(t);
|
|
65
|
+
r && S.set(r, n);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
cancelAnimationFrame(w), w = requestAnimationFrame(() => {
|
|
69
|
+
j(), k(), L();
|
|
70
|
+
});
|
|
71
|
+
}), B = new MutationObserver((e) => {
|
|
72
|
+
for (let t of e) t.addedNodes.values().filter((e) => e instanceof HTMLElement).forEach((e) => z.observe(e)), t.removedNodes.values().filter((e) => e instanceof HTMLElement).forEach((e) => z.unobserve(e));
|
|
73
|
+
});
|
|
74
|
+
return h(() => {
|
|
75
|
+
B.disconnect(), x.value && B.observe(x.value, { childList: !0 });
|
|
76
|
+
}), m(() => i.rows, R, { flush: "post" }), o(() => {
|
|
77
|
+
R(), window.addEventListener("scroll", R, { passive: !0 });
|
|
78
|
+
}), s(() => {
|
|
79
|
+
window.removeEventListener("scroll", R);
|
|
80
|
+
}), _({
|
|
81
|
+
init() {
|
|
82
|
+
E(), j(), k(), P(), L();
|
|
83
|
+
},
|
|
84
|
+
scrollTo(e) {
|
|
85
|
+
let t = 0;
|
|
86
|
+
for (let n of i.rows) {
|
|
87
|
+
if (n.id === e) break;
|
|
88
|
+
t += S.get(n) ?? i.height;
|
|
89
|
+
}
|
|
90
|
+
(i.container ?? document.documentElement).scrollTo(0, t + T);
|
|
91
|
+
}
|
|
92
|
+
}), (t, i) => (c(), n("div", {
|
|
93
|
+
ref_key: "grid",
|
|
94
|
+
ref: b,
|
|
95
|
+
class: "infinite-grid",
|
|
96
|
+
style: a(D.value)
|
|
97
|
+
}, [
|
|
98
|
+
r("div", {
|
|
99
|
+
class: "before",
|
|
100
|
+
style: a(M.value)
|
|
101
|
+
}, null, 4),
|
|
102
|
+
r("div", {
|
|
103
|
+
ref_key: "content",
|
|
104
|
+
ref: x,
|
|
105
|
+
class: "content"
|
|
106
|
+
}, [(c(!0), n(e, null, u(y.value, (e) => (c(), n("div", {
|
|
107
|
+
key: e.id,
|
|
108
|
+
class: "grid-row",
|
|
109
|
+
"data-index": e.id
|
|
110
|
+
}, [d(t.$slots, "row", { row: e }, void 0, !0)], 8, g))), 128))], 512),
|
|
111
|
+
r("div", {
|
|
112
|
+
class: "after",
|
|
113
|
+
style: a(F.value)
|
|
114
|
+
}, null, 4)
|
|
115
|
+
], 4));
|
|
116
|
+
}
|
|
117
|
+
}), [["__scopeId", "data-v-43bc25ca"]]), v = { install(e) {
|
|
118
|
+
e.component("VueGrid", _);
|
|
119
|
+
} };
|
|
120
|
+
//#endregion
|
|
121
|
+
export { v as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yasanchezz/vue-infinite-grid",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "./dist/vue-infinite-grid.js",
|
|
9
|
+
"module": "./dist/vue-infinite-grid.js",
|
|
10
|
+
"types": "./dist/main.d.ts",
|
|
11
|
+
"style": "./dist/vue-infinite-grid.css",
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"vue": "^3.5.39"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
17
|
+
"@tsconfig/node24": "^24.0.4",
|
|
18
|
+
"@types/node": "^24.13.2",
|
|
19
|
+
"@typescript-eslint/utils": "^8.63.0",
|
|
20
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
21
|
+
"@vue/eslint-config-typescript": "^14.9.0",
|
|
22
|
+
"@vue/tsconfig": "^0.9.1",
|
|
23
|
+
"eslint": "^10.6.0",
|
|
24
|
+
"eslint-config-prettier": "^10.1.8",
|
|
25
|
+
"eslint-plugin-oxlint": "~1.69.0",
|
|
26
|
+
"eslint-plugin-vue": "~10.9.2",
|
|
27
|
+
"jiti": "^2.7.0",
|
|
28
|
+
"npm-run-all2": "^9.0.2",
|
|
29
|
+
"oxfmt": "^0.54.0",
|
|
30
|
+
"oxlint": "~1.69.0",
|
|
31
|
+
"typescript": "~6.0.3",
|
|
32
|
+
"vite": "^8.1.3",
|
|
33
|
+
"vite-plugin-dts": "^5.0.3",
|
|
34
|
+
"vite-plugin-vue-devtools": "^8.1.5",
|
|
35
|
+
"vue-eslint-parser": "^10.4.1",
|
|
36
|
+
"vue-tsc": "^3.3.6"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">= 24.12.0",
|
|
40
|
+
"pnpm": ">= 11.10.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"dev": "vite build -w",
|
|
44
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
45
|
+
"preview": "vite preview",
|
|
46
|
+
"build-only": "vite build",
|
|
47
|
+
"type-check": "vue-tsc --build",
|
|
48
|
+
"lint": "run-s \"lint:*\"",
|
|
49
|
+
"lint:oxlint": "oxlint . --fix",
|
|
50
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
51
|
+
"format": "oxfmt src/"
|
|
52
|
+
}
|
|
53
|
+
}
|