@grafloria/element 0.4.55 → 0.4.57

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafloria/element",
3
- "version": "0.4.55",
3
+ "version": "0.4.57",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -12,6 +12,12 @@
12
12
  import type { DiagramModel, GridPackEngine, GroupModel, NodeModel } from '@grafloria/engine';
13
13
  import type { DashboardGridGeometry, WorldRect } from './grid-mapping.js';
14
14
  import type { DashboardGridApi, DashboardGridOptions } from './grid-binder.js';
15
+ /**
16
+ * Small overshoots CLAMP onto the board instead of counting as off-board — the
17
+ * plan prototype cannot leave its board at all (cells clamp at the edges), so a
18
+ * 60 px slip past the frame must not dim or delete.
19
+ */
20
+ export declare const EDGE_GRACE = 60;
15
21
  export interface BoardCtx {
16
22
  readonly api: DashboardGridApi;
17
23
  readonly group: GroupModel;
@@ -1,2 +1,7 @@
1
- export {};
1
+ /**
2
+ * Small overshoots CLAMP onto the board instead of counting as off-board — the
3
+ * plan prototype cannot leave its board at all (cells clamp at the edges), so a
4
+ * 60 px slip past the frame must not dim or delete.
5
+ */
6
+ export const EDGE_GRACE = 60;
2
7
  //# sourceMappingURL=board-ctx.js.map
@@ -619,6 +619,8 @@ export interface DashboardHandleContext {
619
619
  tearOutPlan?: (containerId: string, pageId: string) => TearOutPlan | null;
620
620
  /** The commands that close `boardId` when it is a tab PAGE about to lose its last member `leaving` — and its container when that was its last page. */
621
621
  closePageIfEmptied?: (boardId: string, leaving: string) => Command[];
622
+ /** The bookkeeping for a CONTAINER a gesture moved from one board to another (tile first, 4b-ii): its spec entry, its registry. */
623
+ moveContainerCommands?: (containerId: string, fromBoardId: string, toBoardId: string) => Command[];
622
624
  /** A widget dragged over a strip: hit-test, marks, and the drop that makes it a new tab. Handed to every binder. */
623
625
  tabDrop?: TabDropHooks;
624
626
  /** Set by finalize: the user's `onTabChange`, so the handle can fire it. */
@@ -790,6 +790,54 @@ export function createDashboardHandle(ctx) {
790
790
  * looked like. Undo reopens the page (its grid re-binds on the history event)
791
791
  * and then the widget comes back into it.
792
792
  */
793
+ /**
794
+ * A CONTAINER CROSSES BOARDS by hand (tile first, 4b-ii): a section carried
795
+ * into a page, a tab container into a section. The membership commands
796
+ * move it; this moves what the kit keeps beside the membership — the
797
+ * authored entry from the old board's list to the new one's, and which
798
+ * board the container is filed under — as a register/unregister pair, the
799
+ * way the tear-out plan files a group it creates. `toJSON()` reads the
800
+ * membership, so the document is right either way; the registry is what
801
+ * `addWidget` and the page-closing rule read.
802
+ */
803
+ ctx.moveContainerCommands = (containerId, fromBoardId, toBoardId) => {
804
+ if (!ctx.boardGroups.has(containerId))
805
+ return [];
806
+ const spec = specById.get(containerId);
807
+ const fromArr = ctx.boardWidgets.get(fromBoardId);
808
+ const toArr = ctx.boardWidgets.get(toBoardId);
809
+ const prevFiled = viewOfWidget.get(containerId);
810
+ let slot = -1;
811
+ const moved = {
812
+ register: () => {
813
+ viewOfWidget.set(containerId, toBoardId);
814
+ if (spec && fromArr) {
815
+ const i = fromArr.findIndex((w) => w.id === containerId);
816
+ if (i >= 0) {
817
+ slot = i;
818
+ fromArr.splice(i, 1);
819
+ }
820
+ }
821
+ if (spec && toArr && !toArr.some((w) => w.id === containerId))
822
+ toArr.push(spec);
823
+ },
824
+ unregister: () => {
825
+ if (prevFiled !== undefined)
826
+ viewOfWidget.set(containerId, prevFiled);
827
+ else
828
+ viewOfWidget.delete(containerId);
829
+ if (spec && toArr) {
830
+ const i = toArr.findIndex((w) => w.id === containerId);
831
+ if (i >= 0)
832
+ toArr.splice(i, 1);
833
+ }
834
+ if (spec && fromArr && !fromArr.some((w) => w.id === containerId)) {
835
+ fromArr.splice(slot < 0 ? fromArr.length : Math.min(slot, fromArr.length), 0, spec);
836
+ }
837
+ },
838
+ };
839
+ return [new RegisterWidgetCommand(moved, 'register')];
840
+ };
793
841
  ctx.closePageIfEmptied = (boardId, leaving) => {
794
842
  var _a, _b, _c, _d, _e, _f;
795
843
  const model = (_a = ctx.apiRef) === null || _a === void 0 ? void 0 : _a.getModel();
@@ -2303,7 +2351,7 @@ export function dashboard(options) {
2303
2351
  if (e.type === 'commit')
2304
2352
  reportChanged();
2305
2353
  (_b = (_a = options.binder) === null || _a === void 0 ? void 0 : _a.onGesture) === null || _b === void 0 ? void 0 : _b.call(_a, e);
2306
- }, onSelect: (id) => { var _a; return (_a = options.onSelect) === null || _a === void 0 ? void 0 : _a.call(options, id, v.id); } }), captionHooks(v.id)), { onMemberLeaving: (memberId) => { var _a, _b; return (_b = (_a = ctx.closePageIfEmptied) === null || _a === void 0 ? void 0 : _a.call(ctx, v.id, memberId)) !== null && _b !== void 0 ? _b : []; } }), (ctx.tabDrop ? { tabDrop: ctx.tabDrop } : {}));
2354
+ }, onSelect: (id) => { var _a; return (_a = options.onSelect) === null || _a === void 0 ? void 0 : _a.call(options, id, v.id); } }), captionHooks(v.id)), { onMemberLeaving: (memberId) => { var _a, _b; return (_b = (_a = ctx.closePageIfEmptied) === null || _a === void 0 ? void 0 : _a.call(ctx, v.id, memberId)) !== null && _b !== void 0 ? _b : []; }, onMemberMoving: (memberId, from, to) => { var _a, _b; return (_b = (_a = ctx.moveContainerCommands) === null || _a === void 0 ? void 0 : _a.call(ctx, memberId, from, to)) !== null && _b !== void 0 ? _b : []; } }), (ctx.tabDrop ? { tabDrop: ctx.tabDrop } : {}));
2307
2355
  if (viewLayout === 'split') {
2308
2356
  return bindDashboardSplit(a, g, Object.assign(Object.assign(Object.assign({}, common), { columns: (_h = v.columns) !== null && _h !== void 0 ? _h : columns, baseRowHeight: rowHeight, designHeight: viewH(v) }), (v.tree !== undefined ? { tree: v.tree } : {})));
2309
2357
  }
@@ -2321,7 +2369,7 @@ export function dashboard(options) {
2321
2369
  if (e.type === 'commit')
2322
2370
  reportChanged();
2323
2371
  (_b = (_a = options.binder) === null || _a === void 0 ? void 0 : _a.onGesture) === null || _b === void 0 ? void 0 : _b.call(_a, e);
2324
- }, onSelect: (id) => { var _a, _b; return (_a = options.onSelect) === null || _a === void 0 ? void 0 : _a.call(options, id, (_b = ctx.viewOfBoard.get(w.id)) !== null && _b !== void 0 ? _b : ctx.active); } }), captionHooks((_h = ctx.viewOfBoard.get(w.id)) !== null && _h !== void 0 ? _h : ctx.active)), { onMemberLeaving: (memberId) => { var _a, _b; return (_b = (_a = ctx.closePageIfEmptied) === null || _a === void 0 ? void 0 : _a.call(ctx, w.id, memberId)) !== null && _b !== void 0 ? _b : []; } }), (ctx.tabDrop ? { tabDrop: ctx.tabDrop } : {}));
2372
+ }, onSelect: (id) => { var _a, _b; return (_a = options.onSelect) === null || _a === void 0 ? void 0 : _a.call(options, id, (_b = ctx.viewOfBoard.get(w.id)) !== null && _b !== void 0 ? _b : ctx.active); } }), captionHooks((_h = ctx.viewOfBoard.get(w.id)) !== null && _h !== void 0 ? _h : ctx.active)), { onMemberLeaving: (memberId) => { var _a, _b; return (_b = (_a = ctx.closePageIfEmptied) === null || _a === void 0 ? void 0 : _a.call(ctx, w.id, memberId)) !== null && _b !== void 0 ? _b : []; }, onMemberMoving: (memberId, from, to) => { var _a, _b; return (_b = (_a = ctx.moveContainerCommands) === null || _a === void 0 ? void 0 : _a.call(ctx, memberId, from, to)) !== null && _b !== void 0 ? _b : []; } }), (ctx.tabDrop ? { tabDrop: ctx.tabDrop } : {}));
2325
2373
  if (((_j = ctx.layoutOf.get(w.id)) !== null && _j !== void 0 ? _j : w.layout) === 'split') {
2326
2374
  // A splitter tree covering the pane; the pane's frame is the parent's
2327
2375
  // slab, so no design height of its own.
@@ -55,6 +55,7 @@ import { type CellRect, type WorldRect } from './grid-mapping.js';
55
55
  import { type BesideSide } from './zones.js';
56
56
  import { type ResizeEdges } from './edges.js';
57
57
  import { type DragHandleOption } from './grip.js';
58
+ export { TEAR_OUT_MIN_ROWS } from './tear-out.js';
58
59
  export { EDGE_GRIP, anyEdge, type ResizeEdges } from './edges.js';
59
60
  export { GRIP_CLASS, DRAG_HANDLE_CLASS, CAPTION_BAND, normalizeDragHandle, dragHandleSelector, gripOf, syncGrip, gripHostOf, pressOnDragHandle, type DragGripOptions, type DragHandleOption } from './grip.js';
60
61
  export { SequenceCommand, SetGroupCellCommand } from './commit.js';
@@ -203,6 +204,12 @@ export interface DashboardGridOptions {
203
204
  * it in the same batch — a tab page emptied by the move closes.
204
205
  */
205
206
  onMemberLeaving?: (memberId: string) => Command[];
207
+ /**
208
+ * A member CONTAINER is moving from this board to another by a gesture
209
+ * (tile first, 4b-ii). Answers the commands that carry the host's own
210
+ * bookkeeping for it — the spec entry, the registry — in the same batch.
211
+ */
212
+ onMemberMoving?: (memberId: string, fromBoardId: string, toBoardId: string) => Command[];
206
213
  /** A widget dragged over a tab STRIP becomes a new tab there: the hooks that hit-test, mark and commit it. */
207
214
  tabDrop?: TabDropHooks;
208
215
  /** Fires after commits/cancels/removals so the page can refocus/refit/flash. */
@@ -568,8 +575,6 @@ export interface TearOutPlan {
568
575
  collapse: Command[];
569
576
  };
570
577
  }
571
- /** A torn-out page never arrives shorter than this: a strip with no room under it is not a group. */
572
- export declare const TEAR_OUT_MIN_ROWS = 2;
573
578
  /**
574
579
  * A WIDGET dropped on a tab strip becomes a new tab there (a tab dropped on
575
580
  * one joins; a widget wraps into a page of its own first). The dashboard
@@ -586,7 +591,7 @@ export interface TabDropHooks {
586
591
  /** The commands that make `widgetId` a new tab of `containerId` at `index`; `displaced` are this board's survivors. Empty = refused. */
587
592
  dropIntoStrip(widgetId: string, containerId: string, index: number, sourceBoardId: string, displaced: Command[]): Command[];
588
593
  }
589
- interface AdoptOptions {
594
+ export interface AdoptOptions {
590
595
  /**
591
596
  * 'shrink': take the cell under the pointer at the height that FITS there
592
597
  * (down to TEAR_OUT_MIN_ROWS) before looking for another row — a torn-out
@@ -604,7 +609,7 @@ interface AdoptOptions {
604
609
  side: BesideSide;
605
610
  };
606
611
  }
607
- interface AdoptedLeg {
612
+ export interface AdoptedLeg {
608
613
  groupId: string;
609
614
  /** Drive the target engine from the source binder's pointer stream. `push`: the tile means it — solid tiles under the wanted cell are pushed (D2). */
610
615
  move(world: {