virtua 0.50.0 → 0.50.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.
@@ -12,6 +12,7 @@
12
12
  offset: number;
13
13
  hide: boolean;
14
14
  horizontal: boolean;
15
+ isSSR?: boolean;
15
16
  resizer: ItemResizeObserver;
16
17
  itemProps?: ItemAttrs | undefined;
17
18
  }
@@ -24,6 +25,7 @@
24
25
  offset,
25
26
  hide,
26
27
  horizontal,
28
+ isSSR,
27
29
  resizer,
28
30
  itemProps,
29
31
  }: Props = $props();
@@ -45,11 +47,11 @@
45
47
  let style: string = $derived.by(() => {
46
48
  const _style: Record<string, string | undefined> = {
47
49
  contain: "layout style",
48
- position: "absolute",
50
+ position: hide && isSSR ? undefined : "absolute",
49
51
  [horizontal ? "height" : "width"]: "100%",
50
52
  [horizontal ? "top" : "left"]: "0px",
51
53
  [horizontal ? "left" : "top"]: offset + "px",
52
- visibility: hide ? "hidden" : undefined,
54
+ visibility: !hide || isSSR ? undefined : "hidden",
53
55
  ...itemProps?.style,
54
56
  };
55
57
  if (horizontal) {
@@ -61,6 +61,8 @@
61
61
  onscrollend && onscrollend();
62
62
  });
63
63
 
64
+ let isSSR = $state(!!ssrCount);
65
+
64
66
  let containerRef: HTMLDivElement | undefined = $state();
65
67
 
66
68
  let stateVersion: StateVersion = $state(store.$getStateVersion());
@@ -97,19 +99,27 @@
97
99
  });
98
100
 
99
101
  onMount(() => {
102
+ isSSR = false;
103
+
104
+ let unmounted = false;
100
105
  const container = containerRef!;
101
- const assignRef = (scrollable: HTMLElement) => {
102
- resizer.$observeRoot(scrollable);
103
- scroller.$observe(container, scrollable);
104
- };
105
106
  // parent's ref may not exist on mount https://github.com/inokawa/virtua/issues/603 https://github.com/inokawa/virtua/issues/690
106
107
  tick().then(() => {
108
+ // https://github.com/inokawa/virtua/pull/914
109
+ if (unmounted) return;
110
+ const assignRef = (scrollable: HTMLElement) => {
111
+ resizer.$observeRoot(scrollable);
112
+ scroller.$observe(container, scrollable);
113
+ };
107
114
  if (scrollRef) {
108
115
  assignRef(scrollRef);
109
116
  } else {
110
117
  assignRef(container.parentElement!);
111
118
  }
112
119
  });
120
+ return () => {
121
+ unmounted = true;
122
+ };
113
123
  });
114
124
  onDestroy(() => {
115
125
  store.$dispose();
@@ -187,6 +197,7 @@
187
197
  offset={stateVersion && store.$getItemOffset(index, negative)}
188
198
  hide={stateVersion && store.$isUnmeasuredItem(index)}
189
199
  {horizontal}
200
+ {isSSR}
190
201
  resizer={resizer.$observeItem}
191
202
  itemProps={itemProps?.({ item, index })}
192
203
  />
@@ -6,4 +6,4 @@ export type { VListProps, VListHandle } from './VList.type.js';
6
6
  export { default as Virtualizer } from './Virtualizer.svelte';
7
7
  export type { VirtualizerProps, VirtualizerHandle, } from './Virtualizer.type.js';
8
8
  export { default as WindowVirtualizer } from './WindowVirtualizer.svelte';
9
- export type { WindowVirtualizerProps } from './WindowVirtualizer.type.js';
9
+ export type { WindowVirtualizerProps, WindowVirtualizerHandle, } from './WindowVirtualizer.type.js';
package/lib/vue/index.cjs CHANGED
@@ -265,7 +265,7 @@ var {min: t, max: r, abs: o, floor: n} = Math, s = (e, o, n) => t(n, r(o, e)), i
265
265
  t && t.disconnect();
266
266
  }
267
267
  };
268
- }, O = /*#__PURE__*/ /*#__PURE__*/ (0, e.defineComponent)({
268
+ }, O = /* @__PURE__ */ /* @__PURE__ */ (0, e.defineComponent)({
269
269
  props: {
270
270
  L: {
271
271
  type: Object,
@@ -336,7 +336,7 @@ var {min: t, max: r, abs: o, floor: n} = Math, s = (e, o, n) => t(n, r(o, e)), i
336
336
  if (null != t) return t;
337
337
  }
338
338
  return "_" + t;
339
- }, j = (e, t) => e[0] === t[0] && e[1] === t[1], N = /*#__PURE__*/ /*#__PURE__*/ (0,
339
+ }, j = (e, t) => e[0] === t[0] && e[1] === t[1], N = /* @__PURE__ */ /* @__PURE__ */ (0,
340
340
  e.defineComponent)({
341
341
  props: {
342
342
  data: {
@@ -507,7 +507,7 @@ e.defineComponent)({
507
507
  item: t.data[r],
508
508
  index: r
509
509
  })
510
- }, null, 8, [ "_stateVersion", "_store", "_resizer", "_index", "_children", "_isHorizontal", "_isNegative", "_isSSR", "_as", "_itemProps" ]);
510
+ }, null, 8, [ "L", "W", "Y", "D", "X", "U", "K", "G", "Z", "ee" ]);
511
511
  };
512
512
  if (t.keepMounted) {
513
513
  const e = new Set(t.keepMounted);
@@ -535,7 +535,7 @@ e.defineComponent)({
535
535
  var y;
536
536
  };
537
537
  }
538
- }), q = /*#__PURE__*/ /*#__PURE__*/ (0, e.defineComponent)({
538
+ }), q = /* @__PURE__ */ /* @__PURE__ */ (0, e.defineComponent)({
539
539
  props: {
540
540
  data: {
541
541
  type: Array,
@@ -606,7 +606,7 @@ e.defineComponent)({
606
606
  var r;
607
607
  };
608
608
  }
609
- }), B = /*#__PURE__*/ /*#__PURE__*/ (0, e.defineComponent)({
609
+ }), B = /* @__PURE__ */ /* @__PURE__ */ (0, e.defineComponent)({
610
610
  props: {
611
611
  data: {
612
612
  type: Array,
@@ -757,7 +757,7 @@ e.defineComponent)({
757
757
  U: i,
758
758
  K: l,
759
759
  Z: n
760
- }, null, 8, [ "_stateVersion", "_store", "_resizer", "_index", "_children", "_isHorizontal", "_isNegative", "_as" ]));
760
+ }, null, 8, [ "L", "W", "Y", "D", "X", "U", "K", "Z" ]));
761
761
  }
762
762
  return (0, e.createVNode)(r, {
763
763
  ref: a,