@ankhorage/zora 25.5.0 → 25.6.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 (36) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -1
  3. package/dist/features/grid-view/adapters/inbound/GridView.d.ts +2 -7
  4. package/dist/features/grid-view/adapters/inbound/GridView.d.ts.map +1 -1
  5. package/dist/features/grid-view/adapters/inbound/GridView.js +309 -51
  6. package/dist/features/grid-view/adapters/inbound/GridView.js.map +1 -1
  7. package/dist/features/grid-view/adapters/inbound/TileGrid.d.ts +1 -1
  8. package/dist/features/grid-view/adapters/inbound/TileGrid.d.ts.map +1 -1
  9. package/dist/features/grid-view/adapters/inbound/TileGrid.js +11 -4
  10. package/dist/features/grid-view/adapters/inbound/TileGrid.js.map +1 -1
  11. package/dist/types/grid-view.d.ts +18 -1
  12. package/dist/types/grid-view.d.ts.map +1 -1
  13. package/dist/types/grid-view.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/features/grid-view/adapters/inbound/GridView.interaction.test.tsx +585 -0
  16. package/src/features/grid-view/adapters/inbound/GridView.test.tsx +74 -0
  17. package/src/features/grid-view/adapters/inbound/GridView.tsx +506 -77
  18. package/src/features/grid-view/adapters/inbound/TileGrid.tsx +26 -3
  19. package/src/features/time-grid/adapters/inbound/TimeGrid.test.tsx +35 -8
  20. package/src/types/grid-view.ts +27 -1
  21. package/web-dist/chunks/{Accordion-0my2z6qe.js → Accordion-ebghcyzj.js} +41 -1
  22. package/web-dist/chunks/{Accordion-d6azgz09.js → Accordion-f43jba23.js} +1 -1
  23. package/web-dist/chunks/Accordion-q8exgc3h.js +515 -0
  24. package/web-dist/chunks/{Accordion-7qfd4cb4.js → Accordion-szar8dt5.js} +1 -1
  25. package/web-dist/components/explorer/Explorer.js +2 -2
  26. package/web-dist/components/file-explorer/FileExplorer.js +2 -2
  27. package/web-dist/components/grid-line-overlay/GridLineOverlay.js +1 -1
  28. package/web-dist/components/grid-ruler/GridRuler.js +1 -1
  29. package/web-dist/components/grid-view/GridView.js +1 -1
  30. package/web-dist/components/media-explorer/MediaExplorer.js +2 -2
  31. package/web-dist/components/spatial-grid/SpatialGrid.js +1 -1
  32. package/web-dist/components/tile-grid/TileGrid.js +1 -1
  33. package/web-dist/components/time-grid/TimeGrid.js +2 -2
  34. package/web-dist/components/uploader/Uploader.js +2 -2
  35. package/web-dist/manifest.json +24 -24
  36. package/web-dist/chunks/Accordion-gxj5qbpr.js +0 -194
@@ -0,0 +1,74 @@
1
+ import { join } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+
4
+ import type { GridRectItem, GridViewport } from '@ankhorage/grid-view';
5
+ import { expect, test } from 'bun:test';
6
+ import React from 'react';
7
+ import { renderToStaticMarkup } from 'react-dom/server';
8
+
9
+ import type { GridView as GridViewComponent } from './GridView';
10
+
11
+ const webDistRoot = join(import.meta.dir, '../../../../../web-dist');
12
+ const load = (path: string) => import(pathToFileURL(join(webDistRoot, path)).href);
13
+
14
+ const world = Array.from({ length: 10_000 }, (_, index): GridRectItem => ({
15
+ height: 10,
16
+ id: `item-${index}`,
17
+ width: 10,
18
+ x: (index % 100) * 10,
19
+ y: Math.floor(index / 100) * 10,
20
+ }));
21
+
22
+ test('virtualizes a large bounded world using independent default viewport scales', async () => {
23
+ const { GridView } = (await load('components/grid-view/index.js')) as {
24
+ GridView: typeof GridViewComponent;
25
+ };
26
+ const markup = renderGrid(GridView, {
27
+ height: 100,
28
+ offsetX: 200,
29
+ offsetY: 300,
30
+ pixelsPerUnitX: 2,
31
+ pixelsPerUnitY: 1,
32
+ width: 100,
33
+ });
34
+
35
+ expect(markup).toContain('item-3020');
36
+ expect(markup).not.toContain('item-0');
37
+ expect(markup).not.toContain('item-9999');
38
+ expect(markup.match(/data-grid-item=/g)?.length).toBeLessThan(150);
39
+ });
40
+
41
+ test('renders controlled world offsets without expanding the mounted item set', async () => {
42
+ const { GridView } = (await load('components/grid-view/index.js')) as {
43
+ GridView: typeof GridViewComponent;
44
+ };
45
+ const markup = renderGrid(GridView, {
46
+ height: 100,
47
+ offsetX: 800,
48
+ offsetY: 700,
49
+ pixelsPerUnitX: 1,
50
+ pixelsPerUnitY: 2,
51
+ width: 100,
52
+ });
53
+
54
+ expect(markup).toContain('item-7080');
55
+ expect(markup).not.toContain('item-3020');
56
+ expect(markup.match(/data-grid-item=/g)?.length).toBeLessThan(150);
57
+ });
58
+
59
+ /*** Renders the public viewport boundary with caller-owned controlled state. */
60
+ function renderGrid(GridView: typeof GridViewComponent, viewport: GridViewport): string {
61
+ return renderToStaticMarkup(
62
+ <GridView
63
+ contentHeight={1000}
64
+ contentWidth={1000}
65
+ height={viewport.height}
66
+ items={world}
67
+ overscanPixels={0}
68
+ renderItem={(item) => <span data-grid-item={item.id}>{item.id}</span>}
69
+ viewport={viewport}
70
+ viewportConstraints={{ world: { height: 1000, width: 1000, x: 0, y: 0 } }}
71
+ width={viewport.width}
72
+ />,
73
+ );
74
+ }