@witchcraft/ui 0.3.16 → 0.3.17
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/module.json +1 -1
- package/dist/runtime/components/LibTable/LibTable.d.vue.ts +1 -1
- package/dist/runtime/components/LibTable/LibTable.vue +8 -3
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
- package/package.json +1 -1
- package/src/runtime/components/LibTable/LibTable.vue +9 -4
package/dist/module.json
CHANGED
|
@@ -36,7 +36,7 @@ type RealProps = {
|
|
|
36
36
|
* Since the table now truncates rows by default, they will always be the same height unless you change the inner styling. In fixed mode, `forceRecalculateFixedVirtualizer` is exposed if you need to force re-calculation.
|
|
37
37
|
*
|
|
38
38
|
* If using slots, be sure to at least pass the `class` slot prop to the td element. `style` with width is also supplied but is not required if you're displaying the table as a table.
|
|
39
|
-
|
|
39
|
+
*
|
|
40
40
|
* ### Dynamic (experimental)
|
|
41
41
|
*
|
|
42
42
|
* In `dynamic` mode we use tanstack's measureElement method. This is more expensive, but it will work with any heights.
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
:style="{
|
|
178
178
|
...mergedVirtualizerOpts.enabled ? {
|
|
179
179
|
transform: mergedVirtualizerOpts.method === 'fixed' ? `translateY(${virtual.start - index * virtual.size}px)` : `translateY(${virtual.start}px)`,
|
|
180
|
-
height: virtual.size
|
|
180
|
+
height: `${virtual.size}px`
|
|
181
181
|
} : {}
|
|
182
182
|
}"
|
|
183
183
|
:data-index="virtual.index"
|
|
@@ -287,11 +287,13 @@ function measureElement(el) {
|
|
|
287
287
|
rowVirtualizer.value.measureElement(el);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
+
let mounted = false;
|
|
290
291
|
function forceRecalculateFixedVirtualizer() {
|
|
291
292
|
if (mergedVirtualizerOpts.value?.method === "dynamic" || !mergedVirtualizerOpts.value.enabled) return;
|
|
292
|
-
if (!
|
|
293
|
+
if (!mounted) {
|
|
293
294
|
throw new Error("forceRecalculateFixedVirtualizer cannot be called before the table is mounted.");
|
|
294
295
|
}
|
|
296
|
+
if (!parentRef.value) return;
|
|
295
297
|
const height = parentRef.value.querySelector("td")?.getBoundingClientRect().height;
|
|
296
298
|
if (!height) return;
|
|
297
299
|
for (let i = 0; i < props.values.length; i++) {
|
|
@@ -309,7 +311,10 @@ function updateTableHeight() {
|
|
|
309
311
|
const throttledUpdateTableHeight = throttle(updateTableHeight, 100, { leading: true });
|
|
310
312
|
onMounted(() => {
|
|
311
313
|
throttledUpdateTableHeight();
|
|
312
|
-
|
|
314
|
+
mounted = true;
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
forceRecalculateFixedVirtualizer();
|
|
317
|
+
}, 0);
|
|
313
318
|
useGlobalResizeObserver(parentRef, onResize);
|
|
314
319
|
});
|
|
315
320
|
const hasScrollbar = ref({ vertical: false, horizontal: false });
|
|
@@ -36,7 +36,7 @@ type RealProps = {
|
|
|
36
36
|
* Since the table now truncates rows by default, they will always be the same height unless you change the inner styling. In fixed mode, `forceRecalculateFixedVirtualizer` is exposed if you need to force re-calculation.
|
|
37
37
|
*
|
|
38
38
|
* If using slots, be sure to at least pass the `class` slot prop to the td element. `style` with width is also supplied but is not required if you're displaying the table as a table.
|
|
39
|
-
|
|
39
|
+
*
|
|
40
40
|
* ### Dynamic (experimental)
|
|
41
41
|
*
|
|
42
42
|
* In `dynamic` mode we use tanstack's measureElement method. This is more expensive, but it will work with any heights.
|
package/package.json
CHANGED
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
transform: mergedVirtualizerOpts.method === 'fixed'
|
|
183
183
|
? `translateY(${virtual.start - index * virtual.size!}px)`
|
|
184
184
|
: `translateY(${virtual.start}px)`,
|
|
185
|
-
height: virtual.size
|
|
185
|
+
height: `${virtual.size}px`
|
|
186
186
|
}
|
|
187
187
|
: {})
|
|
188
188
|
}"
|
|
@@ -314,11 +314,13 @@ function measureElement(el: any): void {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
let mounted = false
|
|
317
318
|
function forceRecalculateFixedVirtualizer() {
|
|
318
319
|
if (mergedVirtualizerOpts.value?.method === "dynamic" || !mergedVirtualizerOpts.value.enabled) return
|
|
319
|
-
if (!
|
|
320
|
+
if (!mounted) {
|
|
320
321
|
throw new Error("forceRecalculateFixedVirtualizer cannot be called before the table is mounted.")
|
|
321
322
|
}
|
|
323
|
+
if (!parentRef.value) return // this could happen if the table is destroyed before the timeout (highly unlikely, probably impossible)
|
|
322
324
|
const height = parentRef.value.querySelector("td")?.getBoundingClientRect().height
|
|
323
325
|
if (!height) return
|
|
324
326
|
for (let i = 0; i < props.values.length; i++) {
|
|
@@ -339,7 +341,10 @@ const throttledUpdateTableHeight = throttle(updateTableHeight, 100, { leading: t
|
|
|
339
341
|
|
|
340
342
|
onMounted(() => {
|
|
341
343
|
throttledUpdateTableHeight()
|
|
342
|
-
|
|
344
|
+
mounted = true
|
|
345
|
+
setTimeout(() => {
|
|
346
|
+
forceRecalculateFixedVirtualizer()
|
|
347
|
+
}, 0)
|
|
343
348
|
useGlobalResizeObserver(parentRef, onResize)
|
|
344
349
|
})
|
|
345
350
|
|
|
@@ -434,7 +439,7 @@ type RealProps = {
|
|
|
434
439
|
* Since the table now truncates rows by default, they will always be the same height unless you change the inner styling. In fixed mode, `forceRecalculateFixedVirtualizer` is exposed if you need to force re-calculation.
|
|
435
440
|
*
|
|
436
441
|
* If using slots, be sure to at least pass the `class` slot prop to the td element. `style` with width is also supplied but is not required if you're displaying the table as a table.
|
|
437
|
-
|
|
442
|
+
*
|
|
438
443
|
* ### Dynamic (experimental)
|
|
439
444
|
*
|
|
440
445
|
* In `dynamic` mode we use tanstack's measureElement method. This is more expensive, but it will work with any heights.
|