@yasanchezz/vue-infinite-grid 0.2.0 → 0.2.2
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 +13 -1
- package/dist/VueGrid.d.ts +1 -1
- package/dist/vue-infinite-grid.css +1 -1
- package/dist/vue-infinite-grid.js +24 -23
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -25,6 +25,18 @@ createApp(App)
|
|
|
25
25
|
.mount('#app');
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
Or import the component directly, without installing the plugin
|
|
29
|
+
|
|
30
|
+
``` vue
|
|
31
|
+
<script setup>
|
|
32
|
+
import { VueGrid } from '@yasanchezz/vue-infinite-grid';
|
|
33
|
+
import '@yasanchezz/vue-infinite-grid/dist/vue-infinite-grid.css';
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Don't forget to import the CSS file once, either in `main.js` or in the
|
|
38
|
+
component that uses `VueGrid`.
|
|
39
|
+
|
|
28
40
|
## Usage
|
|
29
41
|
|
|
30
42
|
``` vue
|
|
@@ -71,7 +83,7 @@ part of the rendered window (see [Styling notes](#styling-notes)).
|
|
|
71
83
|
| `rowsCount` | `number` | yes | - | How many rows to render at once (the size of the rendered window). |
|
|
72
84
|
| `rowInitialHeight` | `number` | yes | - | Estimated row height in px, used for scroll/offset math before a row has actually been measured. |
|
|
73
85
|
| `container` | `Element \| null \| ((container: Element \| null) => Element \| null \| undefined)` | no | `document.documentElement` | The scrollable element to listen to. Can be a function that receives the grid's root element (useful for resolving a custom scroll container after mount). |
|
|
74
|
-
| `
|
|
86
|
+
| `rowsCountAutoCalculated` | `boolean` | no | `false` | When `true`, grows the rendered window beyond `rowsCount` based on measured row heights so it always covers the viewport (useful when actual row heights are smaller than the estimated `rowInitialHeight`). |
|
|
75
87
|
| `rowsOffset` | `number` | no | `rowInitialHeight * Math.trunc(rowsCount / 5)` (or `1000` if that's `0`) | Extra px of buffer kept rendered above/below the viewport before the window shifts, to reduce blank space while scrolling fast. |
|
|
76
88
|
|
|
77
89
|
## Slots
|
package/dist/VueGrid.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ declare const __VLS_export: <GridRow extends {
|
|
|
3
3
|
sticky?: boolean;
|
|
4
4
|
}>(__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<{
|
|
5
5
|
props: import('vue').PublicProps & __VLS_PrettifyLocal<{
|
|
6
|
-
autoCalculatedRowsCount?: boolean;
|
|
7
6
|
container?: (Element | null | undefined) | ((container: Element | null) => Element | null | undefined);
|
|
8
7
|
rowInitialHeight: number;
|
|
9
8
|
rows: GridRow[];
|
|
10
9
|
rowsCount: number;
|
|
10
|
+
rowsCountAutoCalculated?: boolean;
|
|
11
11
|
rowsOffset?: number;
|
|
12
12
|
}> & (typeof globalThis extends {
|
|
13
13
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@layer VueGrid{.infinite-grid[data-v-
|
|
1
|
+
@layer VueGrid{.infinite-grid[data-v-e50d93db]{overflow-anchor:none;align-content:start;width:max-content;display:grid;overflow:clip}.grid-row[data-v-e50d93db]{grid-column:1/-1;grid-template-columns:subgrid;display:grid}.grid-row--sticky[data-v-e50d93db]{position:sticky;top:0}.content[data-v-e50d93db]{display:contents}.before[data-v-e50d93db],.after[data-v-e50d93db]{pointer-events:none;grid-column:1/-1}}
|
|
2
2
|
/*$vite$:1*/
|
|
@@ -7,10 +7,6 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
7
7
|
})(/* @__PURE__ */ i({
|
|
8
8
|
__name: "VueGrid",
|
|
9
9
|
props: {
|
|
10
|
-
autoCalculatedRowsCount: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: !1
|
|
13
|
-
},
|
|
14
10
|
container: {
|
|
15
11
|
type: [null, Function],
|
|
16
12
|
default: null
|
|
@@ -18,6 +14,10 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
18
14
|
rowInitialHeight: {},
|
|
19
15
|
rows: {},
|
|
20
16
|
rowsCount: {},
|
|
17
|
+
rowsCountAutoCalculated: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !1
|
|
20
|
+
},
|
|
21
21
|
rowsOffset: { default: 0 }
|
|
22
22
|
},
|
|
23
23
|
setup(i, { expose: g }) {
|
|
@@ -39,7 +39,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
39
39
|
}
|
|
40
40
|
let M = i.rowsCount;
|
|
41
41
|
function N() {
|
|
42
|
-
if (i.
|
|
42
|
+
if (i.rowsCountAutoCalculated) {
|
|
43
43
|
let e = window.innerHeight + i.rowInitialHeight, t = z - C, n = t < e ? Math.ceil(e / t * M) : M;
|
|
44
44
|
M = Number.isFinite(n) && n >= i.rowsCount ? n : i.rowsCount;
|
|
45
45
|
}
|
|
@@ -78,22 +78,23 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
78
78
|
function X() {
|
|
79
79
|
Y = L - W - z, J.value.height = `${Y}px`;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
o.sticky && (n = o, r = a, K = i);
|
|
81
|
+
function ne() {
|
|
82
|
+
F(), H(), R(), G(), q(), X();
|
|
83
|
+
let e = 0, t = 0, n, r;
|
|
84
|
+
for (let [a, o] of i.rows.entries()) {
|
|
85
|
+
let i = j(a);
|
|
86
|
+
if (e += i, e > W) {
|
|
87
|
+
t = a;
|
|
88
|
+
break;
|
|
92
89
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
o.sticky && (n = o, r = a, K = i);
|
|
91
|
+
}
|
|
92
|
+
[B, V] = t + M > i.rows.length || !Y ? [i.rows.length - M, i.rows.length] : [t, t + M], B < 0 && (B = 0);
|
|
93
|
+
let a = n && r != null && r < B ? [n] : [], o = a.length, s = i.rows.slice(B, V), c = a.concat(s);
|
|
94
|
+
o || (K = 0), (c.at(o) !== _.value.at(o) || c.length !== _.value.length) && (_.value = c), H(), R(), G(), q(), X();
|
|
95
|
+
}
|
|
96
|
+
function Z() {
|
|
97
|
+
cancelAnimationFrame(w), w = requestAnimationFrame(ne);
|
|
97
98
|
}
|
|
98
99
|
let Q = new ResizeObserver((e) => {
|
|
99
100
|
for (let t of e) {
|
|
@@ -142,7 +143,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
|
-
function
|
|
146
|
+
function re(e) {
|
|
146
147
|
let t = "grid-row";
|
|
147
148
|
return {
|
|
148
149
|
[t]: !0,
|
|
@@ -165,7 +166,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
165
166
|
class: "content"
|
|
166
167
|
}, [(l(!0), n(e, null, ee(_.value, (e) => (l(), n("div", {
|
|
167
168
|
key: e.id,
|
|
168
|
-
class: a(
|
|
169
|
+
class: a(re(e)),
|
|
169
170
|
"data-index": e.id
|
|
170
171
|
}, [te(t.$slots, "row", { row: e }, void 0, !0)], 10, h))), 128))], 512),
|
|
171
172
|
r("div", {
|
|
@@ -174,7 +175,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
|
|
|
174
175
|
}, null, 4)
|
|
175
176
|
], 4));
|
|
176
177
|
}
|
|
177
|
-
}), [["__scopeId", "data-v-
|
|
178
|
+
}), [["__scopeId", "data-v-e50d93db"]]), _ = { install(e) {
|
|
178
179
|
e.component("VueGrid", g);
|
|
179
180
|
} };
|
|
180
181
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasanchezz/vue-infinite-grid",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
"module": "./dist/vue-infinite-grid.js",
|
|
10
10
|
"types": "./dist/main.d.ts",
|
|
11
11
|
"style": "./dist/vue-infinite-grid.css",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite build -w",
|
|
14
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
15
|
+
"preview": "vite preview",
|
|
16
|
+
"build-only": "vite build",
|
|
17
|
+
"type-check": "vue-tsc --build",
|
|
18
|
+
"lint": "run-s \"lint:*\"",
|
|
19
|
+
"lint:oxlint": "oxlint . --fix",
|
|
20
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
21
|
+
"format": "oxfmt src/"
|
|
22
|
+
},
|
|
12
23
|
"peerDependencies": {
|
|
13
24
|
"vue": "^3.5.39"
|
|
14
25
|
},
|
|
@@ -40,15 +51,5 @@
|
|
|
40
51
|
"node": ">= 24.12.0",
|
|
41
52
|
"pnpm": ">= 11.10.0"
|
|
42
53
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"build": "run-p type-check \"build-only {@}\" --",
|
|
46
|
-
"preview": "vite preview",
|
|
47
|
-
"build-only": "vite build",
|
|
48
|
-
"type-check": "vue-tsc --build",
|
|
49
|
-
"lint": "run-s \"lint:*\"",
|
|
50
|
-
"lint:oxlint": "oxlint . --fix",
|
|
51
|
-
"lint:eslint": "eslint . --fix --cache",
|
|
52
|
-
"format": "oxfmt src/"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
54
|
+
"packageManager": "pnpm@11.17.0"
|
|
55
|
+
}
|