From 0d2bc1cfa327ebd9557bbee696a595bc6d593903 Mon Sep 17 00:00:00 2001 From: zurdi Date: Tue, 28 Apr 2026 13:21:52 +0000 Subject: [PATCH] feat(frontend-v2): add RVirtualScroller primitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wraps Vuetify's VVirtualScroll with the project's wrapper contract (inheritAttrs: false, $attrs forwarding, slot passthrough). Items are typed as unknown[] so consumers cast at the call site — making the primitive non-generic keeps it usable inside Storybook components: {} registrations, where Vue 3.4 generic components clash with the Component record type. Story exercises a 5000-row list to verify only the visible window hits the DOM. Auto-discovered by test/storybook.test.ts. This primitive is the substrate for the upcoming GameGrid and LetterGroupedGrid migrations — both will chunk their items into rows of fixed-width cards and feed those rows here, so libraries with thousands of ROMs no longer mount thousands of cards at once. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/v2/lib/index.ts | 1 + .../RVirtualScroller.stories.ts | 44 +++++++++++++++++ .../RVirtualScroller/RVirtualScroller.vue | 49 +++++++++++++++++++ .../lib/structural/RVirtualScroller/index.ts | 1 + 4 files changed, 95 insertions(+) create mode 100644 frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.stories.ts create mode 100644 frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.vue create mode 100644 frontend/src/v2/lib/structural/RVirtualScroller/index.ts diff --git a/frontend/src/v2/lib/index.ts b/frontend/src/v2/lib/index.ts index cb67d2e22..564ee31ec 100644 --- a/frontend/src/v2/lib/index.ts +++ b/frontend/src/v2/lib/index.ts @@ -36,6 +36,7 @@ export * from "./structural/RList"; export * from "./structural/RListItem"; export * from "./structural/RToolbar"; export * from "./structural/RTooltip"; +export * from "./structural/RVirtualScroller"; // Menus export * from "./menus/RMenu"; diff --git a/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.stories.ts b/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.stories.ts new file mode 100644 index 000000000..eb1355632 --- /dev/null +++ b/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.stories.ts @@ -0,0 +1,44 @@ +import type { Meta, StoryObj } from "@storybook/vue3-vite"; +import RVirtualScroller from "./RVirtualScroller.vue"; + +const meta: Meta = { + title: "Structural/RVirtualScroller", + component: RVirtualScroller, + argTypes: { + itemHeight: { control: "number" }, + height: { control: "text" }, + }, +}; + +export default meta; + +type Story = StoryObj; + +const longList = Array.from({ length: 5000 }, (_, i) => ({ + id: i, + label: `Row ${i + 1}`, +})); + +export const FiveThousandRows: Story = { + args: { + items: longList, + itemHeight: 44, + height: 480, + }, + render: (args) => ({ + components: { RVirtualScroller }, + setup: () => ({ args }), + template: ` +
+ + + +
+ `, + }), +}; diff --git a/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.vue b/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.vue new file mode 100644 index 000000000..26c024fe6 --- /dev/null +++ b/frontend/src/v2/lib/structural/RVirtualScroller/RVirtualScroller.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/frontend/src/v2/lib/structural/RVirtualScroller/index.ts b/frontend/src/v2/lib/structural/RVirtualScroller/index.ts new file mode 100644 index 000000000..2e9bcbe18 --- /dev/null +++ b/frontend/src/v2/lib/structural/RVirtualScroller/index.ts @@ -0,0 +1 @@ +export { default as RVirtualScroller } from "./RVirtualScroller.vue";