@grafloria/element 0.4.53 → 0.4.55

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.
@@ -0,0 +1,30 @@
1
+ /** Which edges of a tile a press takes, and the cursor that says so (tile first, step 4b-i: out of the binder). */
2
+ /** A press this close (CSS px) to a tile's border takes that edge for a resize. */
3
+ export const EDGE_GRIP = 7;
4
+ export const NO_EDGES = { n: false, e: false, s: false, w: false };
5
+ /** Which of a host's edges a client point is within EDGE_GRIP of (none when outside). */
6
+ export function edgesNear(host, cx, cy) {
7
+ const r = host.getBoundingClientRect();
8
+ if (cx < r.left - 2 || cx > r.right + 2 || cy < r.top - 2 || cy > r.bottom + 2)
9
+ return NO_EDGES;
10
+ return {
11
+ n: cy - r.top <= EDGE_GRIP,
12
+ s: r.bottom - cy <= EDGE_GRIP,
13
+ w: cx - r.left <= EDGE_GRIP,
14
+ e: r.right - cx <= EDGE_GRIP,
15
+ };
16
+ }
17
+ export const anyEdge = (E) => E.n || E.e || E.s || E.w;
18
+ /** The resize cursor for a set of edges ('' when none). */
19
+ export function cursorFor(E) {
20
+ const v = E.n || E.s;
21
+ const h = E.e || E.w;
22
+ if (v && h)
23
+ return (E.n && E.w) || (E.s && E.e) ? 'nwse-resize' : 'nesw-resize';
24
+ if (v)
25
+ return 'ns-resize';
26
+ if (h)
27
+ return 'ew-resize';
28
+ return '';
29
+ }
30
+ //# sourceMappingURL=edges.js.map
@@ -53,6 +53,10 @@ import { Command, type DiagramModel, type GridColumnLayout, type GroupModel, typ
53
53
  import { type ToolPointerEvent } from '@grafloria/renderer';
54
54
  import { type CellRect, type WorldRect } from './grid-mapping.js';
55
55
  import { type BesideSide } from './zones.js';
56
+ import { type ResizeEdges } from './edges.js';
57
+ import { type DragHandleOption } from './grip.js';
58
+ export { EDGE_GRIP, anyEdge, type ResizeEdges } from './edges.js';
59
+ export { GRIP_CLASS, DRAG_HANDLE_CLASS, CAPTION_BAND, normalizeDragHandle, dragHandleSelector, gripOf, syncGrip, gripHostOf, pressOnDragHandle, type DragGripOptions, type DragHandleOption } from './grip.js';
56
60
  export { SequenceCommand, SetGroupCellCommand } from './commit.js';
57
61
  /** The slice of a DiagramInstance the binder needs (structural, test-friendly). */
58
62
  export interface DashboardGridApi {
@@ -275,30 +279,6 @@ export interface DashboardGridOptions {
275
279
  */
276
280
  squeeze?: boolean;
277
281
  }
278
- /** A painted grip: the only drag zone, placed along the card's top edge. */
279
- export interface DragGripOptions {
280
- grip: true;
281
- /** Where along the top edge. Default 'left'. */
282
- position?: 'left' | 'center' | 'right';
283
- /** In the header band, or a tab above the card. Default 'inside'. */
284
- placement?: 'inside' | 'outside';
285
- }
286
- export type DragHandleOption = boolean | string | DragGripOptions;
287
- /** The class of the painted grip element (a child of the node host). */
288
- export declare const GRIP_CLASS = "axdb-grip";
289
- /** The container class that turns the caption strip's grip dots on. */
290
- export declare const DRAG_HANDLE_CLASS = "axdb-drag-handle";
291
- /** A `dragHandle` value with its defaults filled in — the form the handle reports. */
292
- export declare const normalizeDragHandle: (v: DragHandleOption | undefined) => DragHandleOption;
293
- /** The selector a `dragHandle` value names — `null` when the whole card is the handle. */
294
- export declare const dragHandleSelector: (v: DragHandleOption) => string | null;
295
- /** The grip config of a value, or null when it paints no grip. */
296
- export declare const gripOf: (v: DragHandleOption) => DragGripOptions | null;
297
- /**
298
- * Paint (or remove) the grip on one host, and stamp the host with the grip's
299
- * placement so the header can make room for it. `movable` false = no grip.
300
- */
301
- export declare function syncGrip(host: HTMLElement, cfg: DragGripOptions | null, movable: boolean): void;
302
282
  /** The member host a press on a painted grip belongs to (the grip may sit OUTSIDE the host's box). */
303
283
  /**
304
284
  * Is this press OURS? The renderer's tool registry is PAGE-GLOBAL: every
@@ -317,16 +297,6 @@ export declare function ownsPress(container: HTMLElement, diagram: {
317
297
  id: string;
318
298
  };
319
299
  }): boolean;
320
- export declare function gripHostOf(target: Element | null): HTMLElement | null;
321
- /**
322
- * Did a press land on the drag handle? A press INSIDE the handle element
323
- * always does. The default handle is a CAPTION BAR the DevExpress way: the
324
- * strip from the card's top edge down to the header's bottom, padding
325
- * included — so the pointer need not hit the header's text to grab the tile.
326
- */
327
- export declare function pressOnDragHandle(sel: string, target: Element | null, hostEl: HTMLElement | null, clientX: number, clientY: number): boolean;
328
- /** The caption strip of a host with no kit header, px from the card's top. */
329
- export declare const CAPTION_BAND = 28;
330
300
  export interface DashboardGridHandle {
331
301
  /** Rebuild the engine from the group's members + their cells, re-project pixels. */
332
302
  sync(): void;
@@ -705,13 +675,4 @@ export declare function parentPeerOf(container: HTMLElement, groupId: string): B
705
675
  export declare function clearOtherSelections(container: HTMLElement, self: BinderPeer | null): void;
706
676
  export declare function registerBoardPeer(container: HTMLElement, peer: BinderPeer): () => void;
707
677
  export type { BinderPeer };
708
- /** A press this close (CSS px) to a tile's border takes that edge for a resize. */
709
- export declare const EDGE_GRIP = 7;
710
- export interface ResizeEdges {
711
- n: boolean;
712
- e: boolean;
713
- s: boolean;
714
- w: boolean;
715
- }
716
- export declare const anyEdge: (E: ResizeEdges) => boolean;
717
678
  export declare function bindDashboardGrid(api: DashboardGridApi, group: GroupModel, options?: DashboardGridOptions): DashboardGridHandle;