@dxos/react-ui-canvas 0.8.4-main.03d5cd7b56 → 0.8.4-main.05e74ebcff

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 (63) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +777 -18
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +777 -18
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/CellGrid/CellGrid.d.ts +21 -0
  9. package/dist/types/src/components/CellGrid/CellGrid.d.ts.map +1 -0
  10. package/dist/types/src/components/CellGrid/CellGrid.stories.d.ts +21 -0
  11. package/dist/types/src/components/CellGrid/CellGrid.stories.d.ts.map +1 -0
  12. package/dist/types/src/components/CellGrid/headers/Ruler.d.ts +15 -0
  13. package/dist/types/src/components/CellGrid/headers/Ruler.d.ts.map +1 -0
  14. package/dist/types/src/components/CellGrid/headers/TrackHeader.d.ts +19 -0
  15. package/dist/types/src/components/CellGrid/headers/TrackHeader.d.ts.map +1 -0
  16. package/dist/types/src/components/CellGrid/headers/index.d.ts +3 -0
  17. package/dist/types/src/components/CellGrid/headers/index.d.ts.map +1 -0
  18. package/dist/types/src/components/CellGrid/index.d.ts +6 -0
  19. package/dist/types/src/components/CellGrid/index.d.ts.map +1 -0
  20. package/dist/types/src/components/CellGrid/input/index.d.ts +3 -0
  21. package/dist/types/src/components/CellGrid/input/index.d.ts.map +1 -0
  22. package/dist/types/src/components/CellGrid/input/pointer.d.ts +29 -0
  23. package/dist/types/src/components/CellGrid/input/pointer.d.ts.map +1 -0
  24. package/dist/types/src/components/CellGrid/input/wheel.d.ts +14 -0
  25. package/dist/types/src/components/CellGrid/input/wheel.d.ts.map +1 -0
  26. package/dist/types/src/components/CellGrid/render/index.d.ts +3 -0
  27. package/dist/types/src/components/CellGrid/render/index.d.ts.map +1 -0
  28. package/dist/types/src/components/CellGrid/render/overlay-layer.d.ts +21 -0
  29. package/dist/types/src/components/CellGrid/render/overlay-layer.d.ts.map +1 -0
  30. package/dist/types/src/components/CellGrid/render/static-layer.d.ts +36 -0
  31. package/dist/types/src/components/CellGrid/render/static-layer.d.ts.map +1 -0
  32. package/dist/types/src/components/CellGrid/state/atoms.d.ts +23 -0
  33. package/dist/types/src/components/CellGrid/state/atoms.d.ts.map +1 -0
  34. package/dist/types/src/components/CellGrid/state/index.d.ts +4 -0
  35. package/dist/types/src/components/CellGrid/state/index.d.ts.map +1 -0
  36. package/dist/types/src/components/CellGrid/state/types.d.ts +39 -0
  37. package/dist/types/src/components/CellGrid/state/types.d.ts.map +1 -0
  38. package/dist/types/src/components/CellGrid/state/viewport.d.ts +52 -0
  39. package/dist/types/src/components/CellGrid/state/viewport.d.ts.map +1 -0
  40. package/dist/types/src/components/CellGrid/state/viewport.test.d.ts +2 -0
  41. package/dist/types/src/components/CellGrid/state/viewport.test.d.ts.map +1 -0
  42. package/dist/types/src/components/index.d.ts +1 -0
  43. package/dist/types/src/components/index.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +14 -13
  46. package/src/components/CellGrid/CellGrid.stories.tsx +238 -0
  47. package/src/components/CellGrid/CellGrid.tsx +266 -0
  48. package/src/components/CellGrid/headers/Ruler.tsx +71 -0
  49. package/src/components/CellGrid/headers/TrackHeader.tsx +58 -0
  50. package/src/components/CellGrid/headers/index.ts +6 -0
  51. package/src/components/CellGrid/index.ts +9 -0
  52. package/src/components/CellGrid/input/index.ts +6 -0
  53. package/src/components/CellGrid/input/pointer.ts +208 -0
  54. package/src/components/CellGrid/input/wheel.ts +68 -0
  55. package/src/components/CellGrid/render/index.ts +6 -0
  56. package/src/components/CellGrid/render/overlay-layer.ts +66 -0
  57. package/src/components/CellGrid/render/static-layer.ts +112 -0
  58. package/src/components/CellGrid/state/atoms.ts +43 -0
  59. package/src/components/CellGrid/state/index.ts +7 -0
  60. package/src/components/CellGrid/state/types.ts +40 -0
  61. package/src/components/CellGrid/state/viewport.test.ts +50 -0
  62. package/src/components/CellGrid/state/viewport.ts +94 -0
  63. package/src/components/index.ts +1 -0
@@ -0,0 +1,29 @@
1
+ import type { Registry } from '@effect-atom/atom-react';
2
+ import type { CellGridAtoms } from '../state/atoms';
3
+ import type { Cell, CellCoord, Headers, SelectionRange } from '../state/types';
4
+ /**
5
+ * 'set' / 'unset' are idempotent — the receiver must add or remove the cell
6
+ * regardless of current state. 'toggle' flips it. Drag operations always pick
7
+ * a fixed mode (set or unset) based on the cell under the initial pointerdown
8
+ * so the user paints a uniform stroke instead of flipping each cell.
9
+ */
10
+ export type ToggleMode = 'set' | 'unset' | 'toggle';
11
+ export type PointerHandlers = {
12
+ onCellToggle?: (coord: CellCoord, mode: ToggleMode) => void;
13
+ onSelectionCommit?: (range: SelectionRange) => void;
14
+ };
15
+ export type PointerControllerOptions<T> = {
16
+ registry: Registry.Registry;
17
+ atoms: CellGridAtoms<T>;
18
+ headers: Headers;
19
+ handlers: PointerHandlers;
20
+ };
21
+ /**
22
+ * Attach pointer handlers to an element. Returns an unsubscribe.
23
+ */
24
+ export declare const attachPointerHandlers: <T>(element: HTMLElement, { registry, atoms, headers, handlers }: PointerControllerOptions<T>) => (() => void);
25
+ /**
26
+ * Utility for consumers: toggle, set, or unset membership of a cell in the cells atom.
27
+ */
28
+ export declare const toggleCell: <T>(registry: Registry.Registry, atoms: CellGridAtoms<T>, coord: CellCoord, factory: (coord: CellCoord) => Cell<T>, mode?: ToggleMode) => void;
29
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/input/pointer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAQ,MAAM,gBAAgB,CAAC;AAGrF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAC5D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD,CAAC;AAOF,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI;IACxC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,WAC5B,WAAW,0CACoB,wBAAwB,CAAC,CAAC,CAAC,KAClE,CAAC,MAAM,IAAI,CA+Ib,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,YAChB,QAAQ,CAAC,QAAQ,SACpB,aAAa,CAAC,CAAC,CAAC,SAChB,SAAS,WACP,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,SAChC,UAAU,KACf,IAYF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Registry } from '@effect-atom/atom-react';
2
+ import type { CellGridAtoms } from '../state/atoms';
3
+ import type { Headers } from '../state/types';
4
+ export type WheelControllerOptions<T> = {
5
+ registry: Registry.Registry;
6
+ atoms: CellGridAtoms<T>;
7
+ headers: Headers;
8
+ };
9
+ /**
10
+ * Attach wheel handlers. Vertical wheel scrolls y; shift+wheel scrolls x;
11
+ * cmd/ctrl+wheel zooms x around the cursor.
12
+ */
13
+ export declare const attachWheelHandlers: <T>(element: HTMLElement, { registry, atoms, headers }: WheelControllerOptions<T>) => (() => void);
14
+ //# sourceMappingURL=wheel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wheel.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/input/wheel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAM9C,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,WAC1B,WAAW,gCACU,sBAAsB,CAAC,CAAC,CAAC,KACtD,CAAC,MAAM,IAAI,CAyCb,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './overlay-layer';
2
+ export * from './static-layer';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/render/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Headers, Selection, Viewport } from '../state/types';
2
+ export type OverlayStyle = {
3
+ playhead: string;
4
+ selectionFill: string;
5
+ selectionStroke: string;
6
+ };
7
+ export type DrawOverlayOptions = {
8
+ ctx: CanvasRenderingContext2D;
9
+ size: {
10
+ width: number;
11
+ height: number;
12
+ };
13
+ viewport: Viewport;
14
+ headers: Headers;
15
+ selection: Selection;
16
+ /** Playhead position in world units (col + fraction), or null when not playing. */
17
+ playhead: number | null;
18
+ style: OverlayStyle;
19
+ };
20
+ export declare const drawOverlay: ({ ctx, size, viewport, headers, selection, playhead, style }: DrawOverlayOptions) => void;
21
+ //# sourceMappingURL=overlay-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-layer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/render/overlay-layer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnE,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,wBAAwB,CAAC;IAC9B,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,WAAW,iEAAkE,kBAAkB,KAAG,IAyC9G,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Cell, Headers, Row, Viewport } from '../state/types';
2
+ export type RenderCellArgs<T> = {
3
+ ctx: CanvasRenderingContext2D;
4
+ x: number;
5
+ y: number;
6
+ w: number;
7
+ h: number;
8
+ cell: Cell<T>;
9
+ };
10
+ export type RenderCell<T = unknown> = (args: RenderCellArgs<T>) => void;
11
+ export type StaticLayerStyle = {
12
+ /** Grid line color, e.g. 'rgba(0,0,0,0.08)'. */
13
+ gridLine: string;
14
+ /** Row band fill (alternating), e.g. 'rgba(0,0,0,0.02)'. */
15
+ rowBand?: string;
16
+ background?: string;
17
+ };
18
+ export type DrawCellsOptions<T> = {
19
+ ctx: CanvasRenderingContext2D;
20
+ size: {
21
+ width: number;
22
+ height: number;
23
+ };
24
+ viewport: Viewport;
25
+ headers: Headers;
26
+ rows: ReadonlyArray<Row>;
27
+ cells: ReadonlyMap<string, Cell<T>>;
28
+ renderCell: RenderCell<T>;
29
+ style: StaticLayerStyle;
30
+ };
31
+ /**
32
+ * Paint the static layer: background, gridlines, alternating row bands, and cells.
33
+ * Pure with respect to its inputs (writes only to the supplied ctx).
34
+ */
35
+ export declare const drawCells: <T>({ ctx, size, viewport, headers, rows, cells, renderCell, style, }: DrawCellsOptions<T>) => void;
36
+ //# sourceMappingURL=static-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-layer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/render/static-layer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,GAAG,EAAE,wBAAwB,CAAC;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,GAAG,EAAE,wBAAwB,CAAC;IAC9B,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,qEASxB,gBAAgB,CAAC,CAAC,CAAC,KAAG,IA6DxB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Atom } from '@effect-atom/atom-react';
2
+ import type { Cell, Selection, Tool, Viewport } from './types';
3
+ export type CellGridAtoms<T = unknown> = {
4
+ cells: Atom.Writable<ReadonlyMap<string, Cell<T>>>;
5
+ viewport: Atom.Writable<Viewport>;
6
+ selection: Atom.Writable<Selection>;
7
+ playhead: Atom.Writable<number | null>;
8
+ tool: Atom.Writable<Tool>;
9
+ };
10
+ export type CellGridAtomsOptions = {
11
+ cellWidth?: number;
12
+ cellHeight?: number;
13
+ };
14
+ export declare const defaultViewport: (options?: CellGridAtomsOptions) => Viewport;
15
+ /**
16
+ * Create a fresh set of atoms backing a CellGrid instance. Consumers may pass any of these as props
17
+ * or substitute their own (e.g., a cells atom backed by ECHO).
18
+ *
19
+ * Atoms are marked keepAlive so they preserve state across transient unsubscribe windows (e.g. React
20
+ * Strict Mode mount-unmount-remount). Consumers are responsible for the atoms' lifetime.
21
+ */
22
+ export declare const createCellGridAtoms: <T = unknown>(options?: CellGridAtomsOptions) => CellGridAtoms<T>;
23
+ //# sourceMappingURL=atoms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atoms.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/state/atoms.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACvC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe,aAAa,oBAAoB,KAAQ,QAMnE,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,GAAG,OAAO,YAAW,oBAAoB,KAAQ,aAAa,CAAC,CAAC,CAMnG,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './atoms';
2
+ export * from './types';
3
+ export * from './viewport';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/state/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,39 @@
1
+ export type CellCoord = {
2
+ col: number;
3
+ row: number;
4
+ };
5
+ export type Cell<T = unknown> = {
6
+ col: number;
7
+ row: number;
8
+ length: number;
9
+ data?: T;
10
+ };
11
+ export type Viewport = {
12
+ /** World-space scroll offset (pixels). */
13
+ scrollX: number;
14
+ scrollY: number;
15
+ /** Cell dimensions in pixels at zoomX = 1. */
16
+ baseCellWidth: number;
17
+ cellHeight: number;
18
+ /** Horizontal zoom factor. */
19
+ zoomX: number;
20
+ };
21
+ export type SelectionRange = {
22
+ col0: number;
23
+ row0: number;
24
+ col1: number;
25
+ row1: number;
26
+ };
27
+ export type Selection = {
28
+ range: SelectionRange | null;
29
+ };
30
+ export type Tool = 'toggle' | 'select' | 'resize';
31
+ export type Row = {
32
+ id: string;
33
+ label?: string;
34
+ };
35
+ export type Headers = {
36
+ left: number;
37
+ top: number;
38
+ };
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/state/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,MAAM,MAAM,GAAG,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { Cell, CellCoord, Headers, Viewport } from './types';
2
+ export declare const cellKey: (col: number, row: number) => string;
3
+ export declare const cellWidth: (viewport: Viewport) => number;
4
+ /**
5
+ * Convert a cell's world coordinates to screen-space pixel rectangle (relative to canvas origin).
6
+ */
7
+ export declare const worldToScreen: (viewport: Viewport, headers: Headers, coord: {
8
+ col: number;
9
+ row: number;
10
+ length?: number;
11
+ }) => {
12
+ x: number;
13
+ y: number;
14
+ w: number;
15
+ h: number;
16
+ };
17
+ /**
18
+ * Convert screen-space pixels (relative to canvas origin) to fractional cell coordinates.
19
+ */
20
+ export declare const screenToWorld: (viewport: Viewport, headers: Headers, point: {
21
+ x: number;
22
+ y: number;
23
+ }) => {
24
+ col: number;
25
+ row: number;
26
+ };
27
+ export declare const hitTestCell: (viewport: Viewport, headers: Headers, point: {
28
+ x: number;
29
+ y: number;
30
+ }) => CellCoord | null;
31
+ /**
32
+ * Compute the inclusive range of cell coordinates intersecting the visible content rect.
33
+ */
34
+ export declare const visibleCellRange: (viewport: Viewport, headers: Headers, size: {
35
+ width: number;
36
+ height: number;
37
+ }) => {
38
+ minCol: number;
39
+ maxCol: number;
40
+ minRow: number;
41
+ maxRow: number;
42
+ };
43
+ /**
44
+ * Iterate sparse cell map, yielding only cells whose horizontal extent intersects visible cols and whose row is visible.
45
+ */
46
+ export declare const visibleCells: <T>(cells: ReadonlyMap<string, Cell<T>>, range: {
47
+ minCol: number;
48
+ maxCol: number;
49
+ minRow: number;
50
+ maxRow: number;
51
+ }) => Generator<Cell<T>>;
52
+ //# sourceMappingURL=viewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/state/viewport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,OAAO,QAAS,MAAM,OAAO,MAAM,KAAG,MAAyB,CAAC;AAE7E,eAAO,MAAM,SAAS,aAAc,QAAQ,KAAG,MAAiD,CAAC;AAEjG;;GAEG;AACH,eAAO,MAAM,aAAa,aACd,QAAQ,WACT,OAAO,SACT;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KACnD;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAQ9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,aACd,QAAQ,WACT,OAAO,SACT;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAM5B,CAAC;AAEF,eAAO,MAAM,WAAW,aACZ,QAAQ,WACT,OAAO,SACT;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9B,SAAS,GAAG,IASd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,aACjB,QAAQ,WACT,OAAO,QACV;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KACtC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CASlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAc,CAAC,SAC/B,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAC5B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KACxE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAYnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=viewport.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.test.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CellGrid/state/viewport.test.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  export * from './Canvas';
2
+ export * from './CellGrid';
2
3
  export * from './FPS';
3
4
  export * from './Grid';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}