virtua 0.49.2 → 0.50.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.
Files changed (59) hide show
  1. package/README.md +39 -5
  2. package/lib/angular/ListItem.d.ts +1 -0
  3. package/lib/angular/VList.d.ts +85 -0
  4. package/lib/angular/Virtualizer.d.ts +141 -0
  5. package/lib/angular/WindowVirtualizer.d.ts +103 -0
  6. package/lib/angular/index.d.ts +6 -0
  7. package/lib/angular/index.js +1148 -0
  8. package/lib/angular/index.js.map +1 -0
  9. package/lib/angular/utils.d.ts +19 -0
  10. package/lib/core/index.cjs +237 -233
  11. package/lib/core/index.cjs.map +1 -1
  12. package/lib/core/index.d.ts +6 -6
  13. package/lib/core/index.js +272 -272
  14. package/lib/core/index.js.map +1 -1
  15. package/lib/index.cjs +529 -499
  16. package/lib/index.cjs.map +1 -1
  17. package/lib/index.d.ts +2 -2
  18. package/lib/index.js +321 -315
  19. package/lib/index.js.map +1 -1
  20. package/lib/react/VGrid.d.ts +2 -2
  21. package/lib/react/VList.d.ts +3 -3
  22. package/lib/react/Virtualizer.d.ts +3 -3
  23. package/lib/react/WindowVirtualizer.d.ts +3 -3
  24. package/lib/react/index.d.ts +9 -9
  25. package/lib/react/types.d.ts +1 -1
  26. package/lib/solid/VList.d.ts +3 -6
  27. package/lib/solid/Virtualizer.d.ts +2 -5
  28. package/lib/solid/WindowVirtualizer.d.ts +2 -5
  29. package/lib/solid/index.cjs +331 -323
  30. package/lib/solid/index.cjs.map +1 -1
  31. package/lib/solid/index.d.ts +7 -7
  32. package/lib/solid/index.js +249 -257
  33. package/lib/solid/index.js.map +1 -1
  34. package/lib/solid/index.jsx +1224 -1566
  35. package/lib/solid/index.jsx.map +1 -1
  36. package/lib/solid/types.d.ts +1 -1
  37. package/lib/svelte/ListItem.svelte +12 -2
  38. package/lib/svelte/VList.svelte +2 -0
  39. package/lib/svelte/VList.type.d.ts +3 -3
  40. package/lib/svelte/Virtualizer.svelte +2 -0
  41. package/lib/svelte/Virtualizer.type.d.ts +8 -3
  42. package/lib/svelte/WindowVirtualizer.type.d.ts +2 -2
  43. package/lib/svelte/index.d.ts +6 -6
  44. package/lib/svelte/index.js +4 -4
  45. package/lib/svelte/types.d.ts +1 -1
  46. package/lib/svelte/utils.d.ts +7 -0
  47. package/lib/svelte/utils.js +11 -11
  48. package/lib/svelte/utils.js.map +1 -1
  49. package/lib/vue/VList.d.ts +2 -3
  50. package/lib/vue/Virtualizer.d.ts +3 -4
  51. package/lib/vue/WindowVirtualizer.d.ts +2 -3
  52. package/lib/vue/index.cjs +327 -317
  53. package/lib/vue/index.cjs.map +1 -1
  54. package/lib/vue/index.d.ts +6 -6
  55. package/lib/vue/index.js +284 -284
  56. package/lib/vue/index.js.map +1 -1
  57. package/lib/vue/utils.d.ts +1 -1
  58. package/package.json +40 -17
  59. package/lib/svelte/index.js.map +0 -1
@@ -15,6 +15,7 @@
15
15
  horizontal,
16
16
  keepMounted,
17
17
  cache,
18
+ itemProps,
18
19
  children,
19
20
  onscroll,
20
21
  onscrollend,
@@ -82,6 +83,7 @@
82
83
  {horizontal}
83
84
  {keepMounted}
84
85
  {cache}
86
+ {itemProps}
85
87
  {onscroll}
86
88
  {onscrollend}
87
89
  />
@@ -1,9 +1,9 @@
1
- import type { ViewportComponentAttributes } from "./types.js";
2
- import type { VirtualizerHandle, VirtualizerProps } from "./Virtualizer.type.js";
1
+ import { ViewportComponentAttributes } from './types.js';
2
+ import { VirtualizerHandle, VirtualizerProps } from './Virtualizer.type.js';
3
3
  /**
4
4
  * Props of {@link VList}.
5
5
  */
6
- export interface VListProps<T> extends Pick<VirtualizerProps<T>, "data" | "getKey" | "bufferSize" | "itemSize" | "ssrCount" | "shift" | "horizontal" | "children" | "onscroll" | "onscrollend" | "keepMounted" | "cache">, ViewportComponentAttributes {
6
+ export interface VListProps<T> extends Pick<VirtualizerProps<T>, "data" | "getKey" | "bufferSize" | "itemSize" | "ssrCount" | "shift" | "horizontal" | "children" | "onscroll" | "onscrollend" | "keepMounted" | "cache" | "itemProps">, ViewportComponentAttributes {
7
7
  }
8
8
  /**
9
9
  * Methods of {@link VList}.
@@ -27,6 +27,7 @@
27
27
  getKey = defaultGetKey,
28
28
  as = "div",
29
29
  item: itemAs,
30
+ itemProps,
30
31
  scrollRef,
31
32
  bufferSize,
32
33
  itemSize,
@@ -187,6 +188,7 @@
187
188
  hide={stateVersion && store.$isUnmeasuredItem(index)}
188
189
  {horizontal}
189
190
  resizer={resizer.$observeItem}
191
+ itemProps={itemProps?.({ item, index })}
190
192
  />
191
193
  {/each}
192
194
  </svelte:element>
@@ -1,6 +1,7 @@
1
- import { type Snippet } from "svelte";
2
- import type { SvelteHTMLElements } from "svelte/elements";
3
- import { type CacheSnapshot, type ScrollToIndexOpts } from "../core/index.js";
1
+ import { Snippet } from 'svelte';
2
+ import { SvelteHTMLElements } from 'svelte/elements';
3
+ import { CacheSnapshot, ScrollToIndexOpts } from '../core/index.js';
4
+ import { ItemProps } from './utils.js';
4
5
  /**
5
6
  * Props of {@link Virtualizer}.
6
7
  */
@@ -28,6 +29,10 @@ export interface VirtualizerProps<T> {
28
29
  * @defaultValue "div"
29
30
  */
30
31
  item?: keyof SvelteHTMLElements;
32
+ /**
33
+ * A function that provides properties/attributes for item element
34
+ */
35
+ itemProps?: ItemProps<T>;
31
36
  /**
32
37
  * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
33
38
  * @defaultValue 200
@@ -1,5 +1,5 @@
1
- import { type Snippet } from "svelte";
2
- import { type CacheSnapshot, type ScrollToIndexOpts } from "../core/index.js";
1
+ import { Snippet } from 'svelte';
2
+ import { CacheSnapshot, ScrollToIndexOpts } from '../core/index.js';
3
3
  /**
4
4
  * Props of {@link WindowVirtualizer}.
5
5
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @module svelte
3
3
  */
4
- export { default as VList } from "./VList.svelte";
5
- export type { VListProps, VListHandle } from "./VList.type.js";
6
- export { default as Virtualizer } from "./Virtualizer.svelte";
7
- export type { VirtualizerProps, VirtualizerHandle, } from "./Virtualizer.type.js";
8
- export { default as WindowVirtualizer } from "./WindowVirtualizer.svelte";
9
- export type { WindowVirtualizerProps } from "./WindowVirtualizer.type.js";
4
+ export { default as VList } from './VList.svelte';
5
+ export type { VListProps, VListHandle } from './VList.type.js';
6
+ export { default as Virtualizer } from './Virtualizer.svelte';
7
+ export type { VirtualizerProps, VirtualizerHandle, } from './Virtualizer.type.js';
8
+ export { default as WindowVirtualizer } from './WindowVirtualizer.svelte';
9
+ export type { WindowVirtualizerProps } from './WindowVirtualizer.type.js';
@@ -1,4 +1,4 @@
1
- export { default as VList } from './VList.svelte';
2
- export { default as Virtualizer } from './Virtualizer.svelte';
3
- export { default as WindowVirtualizer } from './WindowVirtualizer.svelte';
4
- //# sourceMappingURL=index.js.map
1
+ import VList from "./VList.svelte";
2
+ import Virtualizer from "./Virtualizer.svelte";
3
+ import WindowVirtualizer from "./WindowVirtualizer.svelte";
4
+ export { VList, Virtualizer, WindowVirtualizer };
@@ -1,2 +1,2 @@
1
- import type { HTMLAttributes, AriaAttributes } from "svelte/elements";
1
+ import { HTMLAttributes, AriaAttributes } from 'svelte/elements';
2
2
  export type ViewportComponentAttributes = Pick<HTMLAttributes<HTMLElement>, "class" | "style" | "id" | "role" | "tabindex"> & AriaAttributes;
@@ -1,2 +1,9 @@
1
1
  export declare const styleToString: (obj: Record<string, string | undefined>) => string;
2
2
  export declare const defaultGetKey: (_data: unknown, i: number) => string;
3
+ /**
4
+ * A function that provides properties/attributes for item element
5
+ */
6
+ export type ItemProps<T = unknown> = (payload: {
7
+ item: T;
8
+ index: number;
9
+ }) => ItemAttrs | undefined;
@@ -1,13 +1,13 @@
1
- const styleToString = (obj) => {
2
- return Object.keys(obj).reduce((acc, k) => {
3
- const value = obj[k];
4
- if (value == null) {
5
- return acc;
6
- }
7
- return acc + `${k}:${value};`;
8
- }, "");
1
+ //#region src/svelte/utils.ts
2
+ var styleToString = (obj) => {
3
+ return Object.keys(obj).reduce((acc, k) => {
4
+ const value = obj[k];
5
+ if (value == null) return acc;
6
+ return acc + `${k}:${value};`;
7
+ }, "");
9
8
  };
10
- const defaultGetKey = (_data, i) => "_" + i;
11
-
9
+ var defaultGetKey = (_data, i) => "_" + i;
10
+ //#endregion
12
11
  export { defaultGetKey, styleToString };
13
- //# sourceMappingURL=utils.js.map
12
+
13
+ //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/svelte/utils.ts"],"sourcesContent":["export const styleToString = (\n obj: Record<string, string | undefined>,\n): string => {\n return Object.keys(obj).reduce((acc, k) => {\n const value = obj[k];\n if (value == null) {\n return acc;\n }\n return acc + `${k}:${value};`;\n }, \"\");\n};\n\nexport const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n"],"names":[],"mappings":"AAAO,MAAM,aAAa,GAAG,CAC3B,GAAuC,KAC7B;AACV,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAI;AACxC,QAAA,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;AACpB,QAAA,IAAI,KAAK,IAAI,IAAI,EAAE;AACjB,YAAA,OAAO,GAAG;QACZ;AACA,QAAA,OAAO,GAAG,GAAG,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,KAAK,GAAG;IAC/B,CAAC,EAAE,EAAE,CAAC;AACR;AAEO,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,CAAS,KAAK,GAAG,GAAG;;;;"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/svelte/utils.ts"],"sourcesContent":["export const styleToString = (\n obj: Record<string, string | undefined>,\n): string => {\n return Object.keys(obj).reduce((acc, k) => {\n const value = obj[k];\n if (value == null) {\n return acc;\n }\n return acc + `${k}:${value};`;\n }, \"\");\n};\n\nexport const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n\n/**\n * @internal\n */\nexport type ItemAttrs = {\n [key: string]: any;\n style?: Record<string, string | undefined>;\n class?: string;\n};\n\n/**\n * A function that provides properties/attributes for item element\n */\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => ItemAttrs | undefined;\n"],"mappings":";AAAA,IAAa,iBACX,QACW;CACX,OAAO,OAAO,KAAK,GAAG,EAAE,QAAQ,KAAK,MAAM;EACzC,MAAM,QAAQ,IAAI;EAClB,IAAI,SAAS,MACX,OAAO;EAET,OAAO,MAAM,GAAG,EAAE,GAAG,MAAM;CAC7B,GAAG,EAAE;AACP;AAEA,IAAa,iBAAiB,OAAgB,MAAc,MAAM"}
@@ -1,6 +1,5 @@
1
- /** @jsxImportSource vue */
2
- import { type VNode, type PublicProps } from "vue";
3
- import { VirtualizerProps, type VirtualizerHandle } from "./Virtualizer.js";
1
+ import { VNode, PublicProps } from 'vue';
2
+ import { VirtualizerProps, VirtualizerHandle } from './Virtualizer.js';
4
3
  /**
5
4
  * Methods of {@link VList}.
6
5
  */
@@ -1,7 +1,6 @@
1
- /** @jsxImportSource vue */
2
- import { type VNode, type PublicProps, type NativeElements } from "vue";
3
- import { type ScrollToIndexOpts, type CacheSnapshot } from "../core/index.js";
4
- import { type ItemProps } from "./utils.js";
1
+ import { VNode, PublicProps, NativeElements } from 'vue';
2
+ import { ScrollToIndexOpts, CacheSnapshot } from '../core/index.js';
3
+ import { ItemProps } from './utils.js';
5
4
  /**
6
5
  * Props of {@link Virtualizer}.
7
6
  */
@@ -1,6 +1,5 @@
1
- /** @jsxImportSource vue */
2
- import { type VNode, type NativeElements, type PublicProps } from "vue";
3
- import { type ScrollToIndexOpts, type CacheSnapshot } from "../core/index.js";
1
+ import { VNode, NativeElements, PublicProps } from 'vue';
2
+ import { ScrollToIndexOpts, CacheSnapshot } from '../core/index.js';
4
3
  /**
5
4
  * Props of {@link WindowVirtualizer}.
6
5
  */