@dineug/erd-editor 3.4.0 → 3.5.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 (140) hide show
  1. package/dist/components/appContext.d.ts +8 -1
  2. package/dist/components/erd/automatic-table-placement/createAutomaticTablePlacement.d.ts +17 -1
  3. package/dist/components/erd/canvas/Canvas.d.ts +5 -0
  4. package/dist/components/erd/canvas/Canvas.styles.d.ts +11 -0
  5. package/dist/components/erd/canvas/CanvasScene.d.ts +18 -0
  6. package/dist/components/erd/canvas/EditOverlay.d.ts +8 -0
  7. package/dist/components/erd/canvas/EditOverlay.styles.d.ts +6 -0
  8. package/dist/components/erd/canvas/SceneIcon.template.d.ts +21 -0
  9. package/dist/components/erd/canvas/drag-select/DragSelect.d.ts +11 -0
  10. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.d.ts +5 -0
  11. package/dist/components/erd/canvas/entityDrag.d.ts +4 -0
  12. package/dist/components/erd/canvas/high-level-table/HighLevelTable.d.ts +4 -0
  13. package/dist/components/erd/canvas/memo/Memo.d.ts +2 -0
  14. package/dist/components/erd/canvas/memo/memo-sash/MemoSash.d.ts +11 -1
  15. package/dist/components/erd/canvas/memo/memoCaret.d.ts +26 -0
  16. package/dist/components/erd/canvas/memo/memoScroll.d.ts +28 -0
  17. package/dist/components/erd/canvas/memo/memoText.d.ts +33 -0
  18. package/dist/components/erd/canvas/memo/useMoveMemo.d.ts +6 -0
  19. package/dist/components/erd/canvas/relationship-group/RelationshipGroup.d.ts +15 -0
  20. package/dist/components/erd/canvas/relationship-group/relationship/Relationship.template.d.ts +17 -0
  21. package/dist/components/erd/canvas/sceneHit.d.ts +18 -0
  22. package/dist/components/erd/canvas/sceneKind.d.ts +11 -0
  23. package/dist/components/erd/canvas/sceneRetention.d.ts +31 -0
  24. package/dist/components/erd/canvas/sceneTokens.d.ts +67 -0
  25. package/dist/components/erd/canvas/shared-drag-select/SharedDragSelect.d.ts +4 -0
  26. package/dist/components/erd/canvas/shared-mouse-tracker/SharedMouseTracker.d.ts +1 -0
  27. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.d.ts +5 -0
  28. package/dist/components/erd/canvas/table/Table.d.ts +8 -0
  29. package/dist/components/erd/canvas/table/cellLayout.d.ts +63 -0
  30. package/dist/components/erd/canvas/table/column/Column.d.ts +16 -6
  31. package/dist/components/erd/canvas/table/doubleClick.d.ts +14 -0
  32. package/dist/components/erd/canvas/table/useMoveTable.d.ts +1 -1
  33. package/dist/components/erd/canvas/useMoveEntity.d.ts +18 -0
  34. package/dist/components/erd/erd-context-menu/ErdContextMenu.d.ts +1 -2
  35. package/dist/components/erd/erd-context-menu/menus/drawRelationshipMenus.d.ts +2 -2
  36. package/dist/components/erd/erd-context-menu/menus/exportMenus.d.ts +2 -1
  37. package/dist/components/erd/hide-sign/hideSignBounds.d.ts +9 -0
  38. package/dist/components/erd/hitTest.d.ts +22 -0
  39. package/dist/components/erd/minimap/Minimap.styles.d.ts +0 -1
  40. package/dist/components/erd/minimap/MinimapScene.d.ts +16 -0
  41. package/dist/components/erd/minimap/memo/Memo.d.ts +5 -0
  42. package/dist/components/erd/minimap/minimapGeometry.d.ts +52 -0
  43. package/dist/components/erd/minimap/table/Table.d.ts +5 -0
  44. package/dist/components/erd/virtual-scroll/useVirtualScroll.d.ts +19 -0
  45. package/dist/components/global-styles/GlobalStyles.d.ts +3 -12
  46. package/dist/components/primitives/code-block/CodeBlock.styles.d.ts +1 -1
  47. package/dist/components/primitives/icon/icons.d.ts +50 -25
  48. package/dist/components/primitives/sash/Sash.stories.d.ts +1 -1
  49. package/dist/components/primitives/toast/Toast.d.ts +4 -0
  50. package/dist/components/primitives/toast/Toast.stories.d.ts +13 -0
  51. package/dist/components/primitives/toast/Toast.styles.d.ts +5 -0
  52. package/dist/components/{erd/canvas/table → table-view}/column/column-data-type/ColumnDataType.d.ts +1 -1
  53. package/dist/components/table-view/column/useColumnCell.d.ts +23 -0
  54. package/dist/components/themeContext.d.ts +9 -0
  55. package/dist/components/toast-container/openToastWhileRunning.d.ts +11 -0
  56. package/dist/components/visualization/Visualization.d.ts +6 -0
  57. package/dist/components/visualization/Visualization.styles.d.ts +6 -0
  58. package/dist/components/visualization/VisualizationScene.d.ts +21 -0
  59. package/dist/components/visualization/createVisualization.d.ts +67 -8
  60. package/dist/components/visualization/graph-node/GraphNode.d.ts +23 -0
  61. package/dist/components/visualization/table/Table.d.ts +0 -1
  62. package/dist/components/visualization/table/column/Column.d.ts +0 -1
  63. package/dist/components/visualization/visualizationView.d.ts +90 -0
  64. package/dist/constants/language.d.ts +2 -2
  65. package/dist/constants/layout.d.ts +6 -13
  66. package/dist/constants/schema.d.ts +1 -1
  67. package/dist/engine/modules/editor/actions.d.ts +12 -0
  68. package/dist/engine/modules/editor/atom.actions.d.ts +53 -0
  69. package/dist/engine/modules/editor/state.d.ts +20 -0
  70. package/dist/engine/modules/settings/atom.actions.d.ts +24 -0
  71. package/dist/engine.js +10 -10
  72. package/dist/erd-editor.js +23476 -13675
  73. package/dist/konva/batchDraw.d.ts +41 -0
  74. package/dist/konva/host.d.ts +29 -0
  75. package/dist/konva/scene/columnDropTarget.d.ts +13 -0
  76. package/dist/konva/scene/konvaFlip.d.ts +18 -0
  77. package/dist/konva/scene/metrics.d.ts +29 -0
  78. package/dist/konva/scene/renderScene.d.ts +34 -0
  79. package/dist/konva/scene/viewport.d.ts +38 -0
  80. package/dist/konva/testHandle.d.ts +22 -0
  81. package/dist/konva/theme.d.ts +31 -0
  82. package/dist/konva/workerDomStubs.d.ts +1 -0
  83. package/dist/{schemaGCService-DAGNq0wk.js → schemaGCService-DrlqIen8.js} +5246 -4789
  84. package/dist/services/export-png/ExportScene.d.ts +9 -0
  85. package/dist/services/export-png/documentScene.d.ts +20 -0
  86. package/dist/services/export-png/exportPng.shared-worker.d.ts +0 -0
  87. package/dist/services/export-png/exportPngService.d.ts +24 -0
  88. package/dist/services/export-png/index.d.ts +48 -0
  89. package/dist/services/export-png/pixelRatio.d.ts +21 -0
  90. package/dist/services/export-png/renderPng.d.ts +37 -0
  91. package/dist/services/export-png/textWidth.d.ts +27 -0
  92. package/dist/services/schema-gc/index.d.ts +5 -0
  93. package/dist/styles/colorPicker.style.d.ts +3 -7
  94. package/dist/styles/fonts.styles.d.ts +1 -1
  95. package/dist/styles/reset.styles.d.ts +1 -1
  96. package/dist/styles/scrollbar.styles.d.ts +3 -3
  97. package/dist/styles/typography.styles.d.ts +1 -1
  98. package/dist/themes/tokens.d.ts +4 -0
  99. package/dist/utils/calcTable.d.ts +1 -1
  100. package/dist/utils/draw-relationship/incremental.d.ts +70 -0
  101. package/dist/utils/draw-relationship/index.d.ts +47 -42
  102. package/dist/utils/draw-relationship/nudge.d.ts +2 -1
  103. package/dist/utils/draw-relationship/pathFinding.d.ts +3 -5
  104. package/dist/utils/draw-relationship/route.d.ts +4 -9
  105. package/dist/utils/draw-relationship/stub.d.ts +5 -16
  106. package/dist/utils/emitter.d.ts +16 -0
  107. package/dist/utils/file/exportFile.d.ts +10 -1
  108. package/dist/utils/focus.d.ts +1 -1
  109. package/dist/utils/globalEventObservable.d.ts +13 -12
  110. package/dist/utils/icon.d.ts +9 -1
  111. package/dist/utils/keyboard-shortcut/index.d.ts +6 -0
  112. package/dist/utils/schema-aml-parser/dataType.d.ts +5 -6
  113. package/dist/utils/schema-aml-parser/tokenizer.d.ts +3 -5
  114. package/dist/utils/schema-aml-parser/types.d.ts +13 -14
  115. package/dist/utils/schema-dbml-parser/dataType.d.ts +2 -2
  116. package/dist/utils/schema-dbml-parser/types.d.ts +5 -5
  117. package/dist/utils/schema-graphql-parser/dataType.d.ts +2 -2
  118. package/dist/utils/schema-graphql-parser/types.d.ts +7 -7
  119. package/package.json +6 -5
  120. package/dist/components/erd/canvas/canvas-svg/CanvasSvg.d.ts +0 -7
  121. package/dist/components/erd/canvas/canvas-svg/relationship/Relationship.template.d.ts +0 -3
  122. package/dist/components/erd/canvas/draw-relationship/DrawRelationship.styles.d.ts +0 -1
  123. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.styles.d.ts +0 -2
  124. package/dist/components/erd/canvas/high-level-table/HighLevelTable.styles.d.ts +0 -1
  125. package/dist/components/erd/canvas/memo/Memo.styles.d.ts +0 -6
  126. package/dist/components/erd/canvas/shared-mouse-tracker/shared-mouse-cursor/SharedMouseCursor.styles.d.ts +0 -1
  127. package/dist/components/erd/canvas/table/column/Column.styles.d.ts +0 -2
  128. package/dist/components/erd/drag-select/DragSelect.d.ts +0 -9
  129. package/dist/components/erd/drag-select/DragSelect.styles.d.ts +0 -1
  130. /package/dist/components/erd/canvas/{canvas-svg → relationship-group}/relationship/Relationship.d.ts +0 -0
  131. /package/dist/components/{erd/canvas/table → table-view}/Table.styles.d.ts +0 -0
  132. /package/dist/components/{erd/canvas/canvas-svg/CanvasSvg.styles.d.ts → table-view/column/Column.styles.d.ts} +0 -0
  133. /package/dist/components/{erd/canvas/table → table-view}/column/column-data-type/ColumnDataType.styles.d.ts +0 -0
  134. /package/dist/components/{erd/canvas/table → table-view}/column/column-key/ColumnKey.d.ts +0 -0
  135. /package/dist/components/{erd/canvas/table → table-view}/column/column-key/ColumnKey.styles.d.ts +0 -0
  136. /package/dist/components/{erd/canvas/table → table-view}/column/column-not-null/ColumnNotNull.d.ts +0 -0
  137. /package/dist/components/{erd/canvas/table → table-view}/column/column-not-null/ColumnNotNull.styles.d.ts +0 -0
  138. /package/dist/components/{erd/canvas/table → table-view}/column/column-option/ColumnOption.d.ts +0 -0
  139. /package/dist/components/{erd/canvas/table → table-view}/column/column-option/ColumnOption.styles.d.ts +0 -0
  140. /package/dist/{services/schema-gc/schemaGC.worker.d.ts → konva/jsx-types.test-d.d.ts} +0 -0
@@ -17,7 +17,14 @@ export type AppContext = EngineContext & {
17
17
  emitter: Emitter;
18
18
  };
19
19
  export type InjectAppContext = InjectEngineContext;
20
- export declare function createAppContext(ctx: InjectAppContext, options?: RxStoreOptions): AppContext;
20
+ export type AppContextOptions = RxStoreOptions & {
21
+ /**
22
+ * Whether a dev build connects the store to the redux devtools extension. Off
23
+ * for a store built where there is no window to look the extension up on.
24
+ */
25
+ devtools?: boolean;
26
+ };
27
+ export declare function createAppContext(ctx: InjectAppContext, options?: AppContextOptions): AppContext;
21
28
  export declare const appContext: import('@dineug/r-html').Context<AppContext>;
22
29
  export declare const useAppContext: (ctx: Ctx, fallback?: AppContext) => import('@dineug/r-html').Ref<AppContext>;
23
30
  export declare function appDestroy(app: AppContext): void;
@@ -7,5 +7,21 @@ type Node = {
7
7
  y: number;
8
8
  ref: Table;
9
9
  };
10
- export declare function createAutomaticTablePlacement(state: RootState): import('d3').Simulation<Node, undefined>;
10
+ /** The two readings of a simulation's heat that its progress is taken from. */
11
+ type Cooling = {
12
+ alpha(): number;
13
+ alphaMin(): number;
14
+ };
15
+ /**
16
+ * How far a placement has run, from 0 to 1. The simulation cools by a fixed
17
+ * factor a tick until its heat reaches the floor it stops at, so the log of
18
+ * the heat over the log of that floor is the share of the ticks it will take.
19
+ *
20
+ * @example
21
+ * simulation.on('tick.progress', () => {
22
+ * state.progress = placementProgress(simulation);
23
+ * });
24
+ */
25
+ export declare function placementProgress(simulation: Cooling): number;
26
+ export declare function createAutomaticTablePlacement(state: RootState): import('d3-force').Simulation<Node, undefined>;
11
27
  export {};
@@ -4,5 +4,10 @@ export type CanvasProps = {
4
4
  canvas: Ref<HTMLDivElement>;
5
5
  grabMove?: boolean;
6
6
  };
7
+ /**
8
+ * The dom shell the scene hangs in: a controller box, the Stage container in it
9
+ * and the editing overlay over that. Scroll and zoom moved onto the scene's
10
+ * layers, so the shell is viewport sized rather than schema sized.
11
+ */
7
12
  declare const Canvas: FC<CanvasProps>;
8
13
  export default Canvas;
@@ -1,2 +1,13 @@
1
+ /**
2
+ * A document box, painted with the canvas background. The minimap's thumbnail
3
+ * is one of these; the editor's own document box is a konva rect on the scene's
4
+ * bottom layer, because the stage container below is the screen, not the box.
5
+ */
1
6
  export declare const root: import('@dineug/r-html').CSSTemplateLiterals;
7
+ /**
8
+ * The stage container, which is viewport sized. It paints nothing of its own so
9
+ * that the boundary background of whatever holds the editor shows through
10
+ * wherever the scene has drawn no document.
11
+ */
12
+ export declare const stage: import('@dineug/r-html').CSSTemplateLiterals;
2
13
  export declare const controller: import('@dineug/r-html').CSSTemplateLiterals;
@@ -0,0 +1,18 @@
1
+ import { FC, Ref } from '@dineug/r-html';
2
+ import { Stage } from 'konva/lib/Stage';
3
+ export type CanvasSceneProps = {
4
+ root: Ref<HTMLDivElement>;
5
+ };
6
+ /**
7
+ * The four layers of the canvas, plus the one a drag opens. Background, scene
8
+ * and presence carry the canvas transform, and the marquee layer stays in
9
+ * screen space because that is where its own mousemove measures.
10
+ */
11
+ declare const CanvasScene: FC<CanvasSceneProps>;
12
+ /**
13
+ * Renders the scene as the root of a Stage. Named in lower case on purpose:
14
+ * r-html's refresh boundary treats an all-upper-case export list as a component
15
+ * module and would self-accept this one, which kills hmr for the whole scene.
16
+ */
17
+ export declare function renderCanvasScene(stage: Stage, props: CanvasSceneProps): void;
18
+ export default CanvasScene;
@@ -0,0 +1,8 @@
1
+ import { FC } from '@dineug/r-html';
2
+ /**
3
+ * The one editing surface over the Stage. A canvas has no caret, no selection
4
+ * and no IME, so the edited cell hides its konva text and a real input takes
5
+ * its place, under the same zoom the scene layer carries.
6
+ */
7
+ declare const EditOverlay: FC;
8
+ export default EditOverlay;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A cell editor, laid out on the text the scene drew rather than beside it. The
3
+ * input's own line is centred in the same box konva centred one in, and it
4
+ * paints no underline of its own: the scene's rect keeps running under it.
5
+ */
6
+ export declare const cell: import('@dineug/r-html').CSSTemplateLiterals;
@@ -0,0 +1,21 @@
1
+ import { DOMTemplateLiterals } from '@dineug/r-html';
2
+ import { SceneMouseEvent } from './sceneTokens';
3
+ import { LucideIconName } from '../../primitives/icon/icons';
4
+ export type SceneIconOptions = {
5
+ icon: LucideIconName;
6
+ name: string;
7
+ kind: string;
8
+ size: number;
9
+ color: string;
10
+ x: number;
11
+ y: number;
12
+ click?: (event: SceneMouseEvent) => void;
13
+ mouseenter?: (event: SceneMouseEvent) => void;
14
+ mouseleave?: (event: SceneMouseEvent) => void;
15
+ };
16
+ /**
17
+ * A lucide icon drawn at size, by scaling its own 24 unit box. The scale carries
18
+ * the stroke with it, which is what keeps the weight the same as the svg the DOM
19
+ * scene rendered at that size.
20
+ */
21
+ export declare function sceneIcon({ icon, name, kind, size, color, x, y, click, mouseenter, mouseleave, }: SceneIconOptions): DOMTemplateLiterals | null;
@@ -0,0 +1,11 @@
1
+ import { FC, Ref } from '@dineug/r-html';
2
+ export type DragSelectProps = {
3
+ root: Ref<HTMLDivElement>;
4
+ };
5
+ /**
6
+ * The marquee, drawn in the screen space its own mousemove measures against the
7
+ * erd root. Its home is the overlay layer the canvas leaves untransformed, so
8
+ * these are the numbers the DOM version wrote into left and top.
9
+ */
10
+ declare const DragSelect: FC<DragSelectProps>;
11
+ export default DragSelect;
@@ -1,4 +1,9 @@
1
1
  import { FC } from '@dineug/r-html';
2
2
  export type DuplicateGhostProps = {};
3
+ /**
4
+ * The Alt-drag copies, drawn on the presence layer above the scene. Ghost
5
+ * geometry is schema coordinates read from table.ui, and the drag delta rides
6
+ * on the group above them, so both halves compose into the committed offset.
7
+ */
3
8
  declare const DuplicateGhost: FC<DuplicateGhostProps>;
4
9
  export default DuplicateGhost;
@@ -0,0 +1,4 @@
1
+ export declare function beginEntityDrag(): void;
2
+ export declare function endEntityDrag(): void;
3
+ /** Reads the flag through the observable, so a scene render tracks it. */
4
+ export declare function isEntityDragActive(): boolean;
@@ -2,6 +2,10 @@ import { FC } from '@dineug/r-html';
2
2
  import { Table } from '../../../../internal-types';
3
3
  export type HighLevelTableProps = {
4
4
  table: Table;
5
+ /** A drawn copy rather than the table itself, so nothing in it takes an id. */
6
+ preview?: boolean;
7
+ /** Off while the table is kept built but scrolled out of the culling rect. */
8
+ visible?: boolean;
5
9
  };
6
10
  declare const HighLevelTable: FC<HighLevelTableProps>;
7
11
  export default HighLevelTable;
@@ -2,6 +2,8 @@ import { FC } from '@dineug/r-html';
2
2
  import { Memo } from '../../../../internal-types';
3
3
  export type MemoProps = {
4
4
  memo: Memo;
5
+ /** A drawn copy rather than the memo itself, so nothing in it takes an id. */
6
+ preview?: boolean;
5
7
  };
6
8
  declare const Memo: FC<MemoProps>;
7
9
  export default Memo;
@@ -1,9 +1,19 @@
1
1
  import { FC } from '@dineug/r-html';
2
- import { Memo } from '../../../../../internal-types';
2
+ import { Memo, ValuesType } from '../../../../../internal-types';
3
3
  export type MemoSashProps = {
4
4
  memo: Memo;
5
5
  top: number;
6
6
  left: number;
7
7
  };
8
+ export declare const MemoSashPosition: {
9
+ readonly left: "left";
10
+ readonly right: "right";
11
+ readonly bottom: "bottom";
12
+ readonly lt: "lt";
13
+ readonly rt: "rt";
14
+ readonly lb: "lb";
15
+ readonly rb: "rb";
16
+ };
17
+ export type MemoSashPosition = ValuesType<typeof MemoSashPosition>;
8
18
  declare const MemoSash: FC<MemoSashProps>;
9
19
  export default MemoSash;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The offset in a memo's editor value that a point in its drawn body falls on,
3
+ * in the body's own coordinates. Past the last line box a textarea takes the
4
+ * end of the value whatever x is, which is where an author carries on writing.
5
+ *
6
+ * @example
7
+ * const offset = memoCaretOffsetAt(memo.value, memo.ui.width, 12, 40);
8
+ */
9
+ export declare function memoCaretOffsetAt(value: string, width: number, x: number, y: number): number;
10
+ /**
11
+ * Asks the next body editor for this memo to open with its caret here. The
12
+ * editor is a textarea the click itself mounts, so the point the pointer landed
13
+ * on is gone by the time it exists and has to be carried across.
14
+ *
15
+ * @example
16
+ * requestMemoCaret(memo.id, memoCaretOffsetAt(memo.value, width, x, y));
17
+ */
18
+ export declare function requestMemoCaret(memoId: string, offset: number): void;
19
+ /**
20
+ * The caret asked for, taken once. Anything the pointer did not open, and any
21
+ * request left over from another memo, opens the body at its start instead.
22
+ *
23
+ * @example
24
+ * const offset = takeMemoCaret(target.memoId);
25
+ */
26
+ export declare function takeMemoCaret(memoId: string): number;
@@ -0,0 +1,28 @@
1
+ import { Editor } from '../../../../engine/modules/editor/state';
2
+ import { Memo } from '../../../../internal-types';
3
+ /**
4
+ * The furthest a memo body scrolls: what its folded lines overrun the box by,
5
+ * in body px. A body the box holds whole has nowhere to go, which is where a
6
+ * textarea of the same box stops too.
7
+ *
8
+ * @example
9
+ * const max = getMemoScrollMax(memo);
10
+ */
11
+ export declare function getMemoScrollMax(memo: Memo): number;
12
+ /**
13
+ * A scroll pulled into the travel the body allows. The value, the width and
14
+ * the height can all change under a stored scroll, so the clamp runs where the
15
+ * scroll is read rather than where it was written.
16
+ *
17
+ * @example
18
+ * const next = clampMemoScrollTop(memo, scrollTop + event.deltaY);
19
+ */
20
+ export declare function clampMemoScrollTop(memo: Memo, scrollTop: number): number;
21
+ /**
22
+ * How far down its body the scene shows a memo from. A memo nothing has
23
+ * scrolled starts on its first line, as every memo always did.
24
+ *
25
+ * @example
26
+ * const scrollTop = getMemoScrollTop(store.state.editor, memo);
27
+ */
28
+ export declare function getMemoScrollTop(editor: Editor, memo: Memo): number;
@@ -0,0 +1,33 @@
1
+ /** The weight utils/text.ts measures with, which is what the body is drawn in. */
2
+ export declare const MEMO_FONT_WEIGHT = "400";
3
+ /** The css font shorthand the scene text and the overlay editor both resolve to. */
4
+ export declare const MEMO_FONT: string;
5
+ /**
6
+ * The leading a memo body takes, in px, which a css line-height and pretext
7
+ * both take. The dom textarea this replaced left it to line-height normal, so
8
+ * that is the advance, and the only way to it is to lay the lines out.
9
+ *
10
+ * @example
11
+ * const advance = getMemoLineHeightPx();
12
+ */
13
+ export declare function getMemoLineHeightPx(): number;
14
+ /** The same leading as konva's multiple of the font size, which is what it takes. */
15
+ export declare function getMemoLineHeight(): number;
16
+ /**
17
+ * The baseline konva draws the first body line on, down from the top of the
18
+ * text node. A canvas has no line box, so the leading and the canvas metrics
19
+ * konva itself measures with are the whole of where that line lands.
20
+ *
21
+ * @example
22
+ * const baseline = getMemoTextBaseline();
23
+ */
24
+ export declare function getMemoTextBaseline(): number;
25
+ /**
26
+ * The lines a memo body folds into at a box width, the way a textarea folds the
27
+ * same text. Konva breaks a string by rules of its own, so the scene draws
28
+ * these lines rather than handing it the value to wrap.
29
+ *
30
+ * @example
31
+ * const text = layoutMemoLines(memo.value, memo.ui.width).join('\n');
32
+ */
33
+ export declare function layoutMemoLines(value: string, width: number): readonly string[];
@@ -0,0 +1,6 @@
1
+ import { Ctx, Memo } from '../../../../internal-types';
2
+ export declare function useMoveMemo(ctx: Ctx, props: {
3
+ memo: Memo;
4
+ }): {
5
+ onMoveStart: (event: import('../sceneTokens').ScenePointerEvent) => void;
6
+ };
@@ -0,0 +1,15 @@
1
+ import { FC } from '@dineug/r-html';
2
+ import { Relationship as RelationshipType } from '../../../../internal-types';
3
+ import { CullingRect } from '../../../../konva/scene/viewport';
4
+ export type RelationshipGroupProps = {
5
+ relationships: RelationshipType[];
6
+ viewport?: CullingRect;
7
+ strokeWidth?: number;
8
+ };
9
+ /**
10
+ * Culling lives here, not in the parent, because a route is a side channel of
11
+ * the sort: a parent that filtered would have to route every connector to learn
12
+ * where it reaches, which is the work this arrangement avoids.
13
+ */
14
+ declare const RelationshipGroup: FC<RelationshipGroupProps>;
15
+ export default RelationshipGroup;
@@ -0,0 +1,17 @@
1
+ import { DOMTemplateLiterals } from '@dineug/r-html';
2
+ import { Circle, PointToPoint, RelationshipPath } from '../../../../../utils/draw-relationship';
3
+ /**
4
+ * What every decoration node answers a lookup and an ancestor walk with. Konva
5
+ * has no class list, so the one token is both.
6
+ */
7
+ export declare const DECORATION = "relationship-decoration";
8
+ /** Konva takes one flat pair list where svg took four attributes. */
9
+ export declare const segment: ({ x1, y1, x2, y2 }: PointToPoint) => number[];
10
+ /**
11
+ * One stroke of a cardinality marker. The paint, the width and the two naming
12
+ * attributes are per node in konva, so every marker is drawn through here.
13
+ */
14
+ export declare function decorationLine(points: PointToPoint, stroke: string): DOMTemplateLiterals;
15
+ /** The optional ring of a cardinality marker, at either anchor. */
16
+ export declare function decorationRing({ cx, cy }: Circle, stroke: string): DOMTemplateLiterals;
17
+ export declare function relationshipShape(relationshipType: number, { path, line }: RelationshipPath, stroke: string): DOMTemplateLiterals | null;
@@ -0,0 +1,18 @@
1
+ import { Context } from 'konva/lib/Context';
2
+ import { Shape } from 'konva/lib/Shape';
3
+ /** What konva calls to put a shape on the hit canvas, in the shape's own space. */
4
+ export type HitFunc = (context: Context, shape: Shape) => void;
5
+ /**
6
+ * The box a column cell's text answers a press for: the full row height and
7
+ * the gap to the next cell, which is the div the dom scene put the input in.
8
+ * The text carries it so the cell needs no shape that exists only to be hit.
9
+ */
10
+ export declare const columnCellHit: HitFunc;
11
+ /** The header cell's box, the same way, at the header input's own height. */
12
+ export declare const headerCellHit: HitFunc;
13
+ /**
14
+ * The whole 24 unit box of a lucide icon, answered by the first shape it draws.
15
+ * A circle's origin is its centre, so its own position is what puts the box
16
+ * back at the icon's corner.
17
+ */
18
+ export declare const iconHit: HitFunc;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A scene node as an ancestor walk sees it. Konva has no closest, so the routing
3
+ * climbs from the node an event landed on until a kind attr names one of the
4
+ * shapes it knows, which is the rule a class selector gave the dom scene.
5
+ */
6
+ export type SceneKindNode = {
7
+ getAttr(name: string): any;
8
+ getParent(): SceneKindNode | null;
9
+ };
10
+ /** Whether the node itself or any ancestor of it carries one of the kinds. */
11
+ export declare function hasKindAncestor(node: SceneKindNode | null | undefined, kinds: readonly string[]): boolean;
@@ -0,0 +1,31 @@
1
+ export type RetentionOptions = {
2
+ /** Hidden tables kept per drawn table. */
3
+ perDrawn: number;
4
+ /** The fewest kept however little is drawn. */
5
+ atLeast: number;
6
+ };
7
+ /**
8
+ * Three hidden per drawn. Building a table costs about twelve milliseconds and
9
+ * a fast pan builds dozens a frame, while konva walks every built node, hidden
10
+ * or not, on each scroll; this is the trade between the two that measured best.
11
+ */
12
+ export declare const RETAINED_PER_DRAWN = 3;
13
+ /** Kept even where nothing is drawn, so crossing an empty stretch keeps the pool. */
14
+ export declare const RETAINED_AT_LEAST = 16;
15
+ export type RetentionPool = {
16
+ /**
17
+ * The ids to keep built but hidden this render: what left the drawn set most
18
+ * recently, up to the bound, and never a table the document no longer holds.
19
+ */
20
+ retain(drawnIds: ReadonlySet<string>, presentIds: ReadonlySet<string>): ReadonlySet<string>;
21
+ };
22
+ /**
23
+ * Remembers which tables scrolled off so the scene hides them instead of
24
+ * destroying them, and a scroll back finds them built. Each call is one render:
25
+ * it takes what is drawn now and answers what to keep beside it.
26
+ *
27
+ * @example
28
+ * const retention = createRetentionPool();
29
+ * const retainedIds = retention.retain(drawnIds, new Set(tableIds));
30
+ */
31
+ export declare function createRetentionPool({ perDrawn, atLeast, }?: Partial<RetentionOptions>): RetentionPool;
@@ -0,0 +1,67 @@
1
+ import { KonvaEventObject } from 'konva/lib/Node';
2
+ /** A pointer event as konva hands it to a listener bound on a scene node. */
3
+ export type SceneMouseEvent = KonvaEventObject<MouseEvent>;
4
+ export type SceneTouchEvent = KonvaEventObject<TouchEvent>;
5
+ export type ScenePointerEvent = SceneMouseEvent | SceneTouchEvent;
6
+ /**
7
+ * The face utils/text.ts measures a string with. Drawing in anything else would
8
+ * make a cell wider or narrower than the width the layout reserved for it.
9
+ */
10
+ export declare const SCENE_FONT_FAMILY: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Open Sans', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'";
11
+ /** The px behind font-size-1, which is what typography.paragraph resolves to. */
12
+ export declare const SCENE_FONT_SIZE = 12;
13
+ /** The css font shorthand konva builds for a cell's text, and measures it with. */
14
+ export declare const SCENE_FONT: string;
15
+ /** The pair a canvas centres a drawn line by, which no line box is involved in. */
16
+ export type SceneFontMetrics = {
17
+ ascent: number;
18
+ descent: number;
19
+ };
20
+ /**
21
+ * The ascent and descent konva centres a drawn line by, read with the measure
22
+ * call konva makes itself. A canvas has no line box to lean on, so this pair is
23
+ * the whole of where a baseline lands, and the editor has to read the same one.
24
+ *
25
+ * @example
26
+ * const { ascent, descent } = getSceneFontMetrics();
27
+ */
28
+ export declare function getSceneFontMetrics(): SceneFontMetrics;
29
+ /**
30
+ * The px behind font-size-5 through font-size-9, in the order HighLevelTable
31
+ * steps through them as the zoom falls. The scale itself is a CSS custom
32
+ * property, and a canvas has no way to read one.
33
+ */
34
+ export declare const HIGH_LEVEL_FONT_SIZES: readonly [20, 24, 28, 35, 60];
35
+ /** Border plus padding on one side, which is where a table's own content starts. */
36
+ export declare const TABLE_INSET: number;
37
+ /** The radius Table.styles rounds a table box with. */
38
+ export declare const TABLE_CORNER_RADIUS = 6;
39
+ /** The min-height Table.styles gives the colour bar across a table header. */
40
+ export declare const HEADER_COLOR_HEIGHT = 4;
41
+ /** The 1.5px underline EditInput draws for a focused, edited or shared cell. */
42
+ export declare const FOCUS_BORDER_HEIGHT = 1.5;
43
+ /** What the ring outside a table box costs, as outline and box-shadow both do. */
44
+ export declare const RING_WIDTH = 1;
45
+ /** The side of the square viewBox every icon is authored in. */
46
+ export declare const ICON_VIEW_SIZE: number;
47
+ /** What a colour is when the scene paints nothing, as a CSS keyword konva takes. */
48
+ export declare const TRANSPARENT = "transparent";
49
+ /**
50
+ * A fill that paints nothing and still answers a hit test, which is how a cell
51
+ * keeps the whole padded box clickable the way its div did.
52
+ */
53
+ export declare const HIT_FILL = "transparent";
54
+ /** The hand a clickable scene node asks for, as the dom scene spelt it in css. */
55
+ export declare const CURSOR_POINTER = "pointer";
56
+ /** The beam a textarea carried on its own, which a drawn body has to ask for. */
57
+ export declare const CURSOR_TEXT = "text";
58
+ /** What a node hands back on the way out, leaving the container its own cursor. */
59
+ export declare const CURSOR_INHERIT = "";
60
+ /**
61
+ * Points the stage container at a cursor. A konva node carries none of its own,
62
+ * so the container is where the css the dom scene put on an element now lives.
63
+ *
64
+ * @example
65
+ * on:mouseenter={(event) => setSceneCursor(event, CURSOR_POINTER)}
66
+ */
67
+ export declare function setSceneCursor(event: ScenePointerEvent, cursor: string): void;
@@ -1,4 +1,8 @@
1
1
  import { FC } from '@dineug/r-html';
2
2
  export type SharedDragSelectProps = {};
3
+ /**
4
+ * A peer's marquee, in the schema coordinates their editor shared. Fainter than
5
+ * the local one because several may be open at once over the same tables.
6
+ */
3
7
  declare const SharedDragSelect: FC<SharedDragSelectProps>;
4
8
  export default SharedDragSelect;
@@ -1,4 +1,5 @@
1
1
  import { FC } from '@dineug/r-html';
2
2
  export type SharedMouseTrackerProps = {};
3
+ /** One cursor per peer sharing a pointer, on the presence layer. */
3
4
  declare const SharedMouseTracker: FC<SharedMouseTrackerProps>;
4
5
  export default SharedMouseTracker;
@@ -3,5 +3,10 @@ import { SharedMouseTracker } from '../../../../../engine/modules/editor/state';
3
3
  export type SharedMouseCursorProps = {
4
4
  tracker: SharedMouseTracker;
5
5
  };
6
+ /**
7
+ * One peer's pointer and nickname, eased toward the position they last shared.
8
+ * The colour identifies the editor rather than the theme, so it comes from the
9
+ * shared palette instead of a resolved token.
10
+ */
6
11
  declare const SharedMouseCursor: FC<SharedMouseCursorProps>;
7
12
  export default SharedMouseCursor;
@@ -2,6 +2,14 @@ import { FC } from '@dineug/r-html';
2
2
  import { Table } from '../../../../internal-types';
3
3
  export type TableProps = {
4
4
  table: Table;
5
+ /** A drawn copy rather than the table itself, so nothing in it takes an id. */
6
+ preview?: boolean;
7
+ hovered?: boolean;
8
+ hoveredColumnId?: string | null;
9
+ ghostColumnId?: string | null;
10
+ editorFocused?: boolean;
11
+ /** Off while the table is kept built but scrolled out of the culling rect. */
12
+ visible?: boolean;
5
13
  };
6
14
  declare const Table: FC<TableProps>;
7
15
  export default Table;
@@ -0,0 +1,63 @@
1
+ import { FocusType } from '../../../../engine/modules/editor/state';
2
+ import { RootState } from '../../../../engine/state';
3
+ import { Table } from '../../../../internal-types';
4
+ import { Theme } from '../../../../themes/tokens';
5
+ import { ColumnWidth } from '../../../../utils/calcTable';
6
+ /** The four widths a column row measures from its table; the rest are fixed. */
7
+ export type ColumnCellWidths = Pick<ColumnWidth, 'comment' | 'dataType' | 'default' | 'name'>;
8
+ /** One editable box on a table, positioned inside the table's own group. */
9
+ export type CellSlot = {
10
+ focusType: FocusType;
11
+ x: number;
12
+ width: number;
13
+ };
14
+ export type ColumnCellSlot = CellSlot & {
15
+ columnType: number;
16
+ };
17
+ /** Where the header cell row starts inside a table group. */
18
+ export declare const HEADER_CELLS_X: number;
19
+ export declare const HEADER_CELLS_Y: number;
20
+ /** The text line inside a header cell and inside a column cell. */
21
+ export declare const HEADER_TEXT_Y = 2;
22
+ export declare const COLUMN_TEXT_Y = 2;
23
+ /** Where the scene runs its focus rect inside a cell, header and column both. */
24
+ export declare const CELL_UNDERLINE_Y: number;
25
+ /**
26
+ * The paint that focus rect takes, header and column both: the input colour
27
+ * while the cell is being edited, and greyed out with the rest of the focus
28
+ * while the editor is not the one holding the keyboard.
29
+ */
30
+ export declare function focusBorderFill(theme: Theme, edit: boolean, editorFocused: boolean | undefined): string;
31
+ /**
32
+ * The baseline one line of cell text is drawn on, down from the top of the
33
+ * cell. Blink puts a painted baseline on the device grid before the zoom scales
34
+ * it, so only a whole pixel survives both rasterisers unchanged.
35
+ *
36
+ * @example
37
+ * const baseline = getCellTextBaseline();
38
+ */
39
+ export declare function getCellTextBaseline(): number;
40
+ /**
41
+ * The box one line of cell text is centred in. The scene hands konva this
42
+ * height with verticalAlign middle and the editor gives its input the same one,
43
+ * which is what puts the two baselines on one whole pixel instead of two.
44
+ *
45
+ * @example
46
+ * const height = getCellTextHeight();
47
+ */
48
+ export declare function getCellTextHeight(): number;
49
+ /** Where a column row's cells start, past the key badge. */
50
+ export declare const COLUMN_CELLS_X: number;
51
+ /** The comment width a table draws at, clamped by the setting when it is set. */
52
+ export declare function getWidthComment(state: RootState, table: Table): number;
53
+ /**
54
+ * The name and comment boxes across a table header. One list feeds both the
55
+ * scene that draws them and the overlay that edits them, so an editor can never
56
+ * sit anywhere but on the text it replaces.
57
+ */
58
+ export declare function getHeaderCellSlots(state: RootState, table: Table): CellSlot[];
59
+ /**
60
+ * The cells of one column row, in the order the settings put them and at the x
61
+ * each lands on once the ones before it have taken their width.
62
+ */
63
+ export declare function getColumnCellSlots(state: RootState, widths: ColumnCellWidths): ColumnCellSlot[];
@@ -1,9 +1,10 @@
1
- import { FC, Ref } from '@dineug/r-html';
2
- import { AppContext } from '../../../../appContext';
1
+ import { FC } from '@dineug/r-html';
2
+ import { SceneMouseEvent } from '../../sceneTokens';
3
3
  import { Column } from '../../../../../internal-types';
4
4
  export type ColumnProps = {
5
- app: Ref<AppContext>;
6
5
  column: Column;
6
+ y: number;
7
+ width: number;
7
8
  selected: boolean;
8
9
  widthName: number;
9
10
  widthDataType: number;
@@ -27,10 +28,19 @@ export type ColumnProps = {
27
28
  editDataType: boolean;
28
29
  editDefault: boolean;
29
30
  editComment: boolean;
30
- draggable?: boolean;
31
+ hovered?: boolean;
32
+ /** The placeholder row for a column dragged in from another table. */
31
33
  ghost?: boolean;
32
- onDragstart?: (event: DragEvent) => void;
33
- onDragend?: (event: DragEvent) => void;
34
+ /** Drawn inside a copy of the table, which owns none of its ids. */
35
+ preview?: boolean;
36
+ editorFocused?: boolean;
37
+ /**
38
+ * The one pair of callbacks the scene keeps. A drop lands between siblings,
39
+ * so the table that owns the order is the only thing that can judge one, and
40
+ * the row can only say that a drag of it started and that it ended.
41
+ */
42
+ onDragstart?: (columnId: string, event: SceneMouseEvent) => void;
43
+ onDragend?: () => void;
34
44
  };
35
45
  declare const Column: FC<ColumnProps>;
36
46
  export default Column;
@@ -0,0 +1,14 @@
1
+ import { SceneMouseEvent } from '../sceneTokens';
2
+ import { FocusType } from '../../../../engine/modules/editor/state';
3
+ export type DoubleClickGuard = {
4
+ /** Records the cell a click opened a pair on. */
5
+ track(cell: FocusType, event: SceneMouseEvent): void;
6
+ /** Whether a konva dblclick closes a pair that began on this same cell. */
7
+ isDouble(cell: FocusType, event: SceneMouseEvent): boolean;
8
+ };
9
+ /**
10
+ * Tells a real double click from the one konva invents. Konva fires dblclick on
11
+ * whatever the second click of any pair inside its window lands on, wherever
12
+ * the first one was, so the cell that opened the pair is remembered here.
13
+ */
14
+ export declare function createDoubleClickGuard(): DoubleClickGuard;
@@ -2,5 +2,5 @@ import { Ctx, Table } from '../../../../internal-types';
2
2
  export declare function useMoveTable(ctx: Ctx, props: {
3
3
  table: Table;
4
4
  }): {
5
- onMoveStart: (event: MouseEvent | TouchEvent) => void;
5
+ onMoveStart: (event: import('../sceneTokens').ScenePointerEvent) => void;
6
6
  };