@dashfoo/core 1.0.0 → 1.1.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.
- package/README.md +19 -12
- package/dist/index.d.ts +197 -85
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +267 -259
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,10 +183,10 @@ getFirstTabset(model): TabsetNode | undefined;
|
|
|
183
183
|
findTabset(model, tabsetId): TabsetNode | undefined;
|
|
184
184
|
findTab(model, tabId): TabLocation | undefined; // searches tabsets
|
|
185
185
|
findFloat(model, floatId): FloatNode | undefined;
|
|
186
|
-
findRow(
|
|
186
|
+
findRow(model, rowId): RowNode | undefined;
|
|
187
187
|
findRootContaining(model, nodeId): RowNode | undefined; // which root holds a node
|
|
188
188
|
findAttributedNode(model, id): AttributedNode | undefined; // row, tabset, or tab
|
|
189
|
-
findTabsetParent(
|
|
189
|
+
findTabsetParent(model, tabsetId): { index: number; parent: RowNode } | undefined;
|
|
190
190
|
findDuplicateIds(model): Array<string>; // ids used more than once
|
|
191
191
|
```
|
|
192
192
|
|
|
@@ -225,14 +225,14 @@ indicator rect. The @dnd-kit adapter in `@dashfoo/react` feeds them rects; you c
|
|
|
225
225
|
call them directly for custom drag logic.
|
|
226
226
|
|
|
227
227
|
```ts
|
|
228
|
-
resolveDockTarget(pointer, rect, opts?):
|
|
228
|
+
resolveDockTarget(pointer, rect, opts?): DockLocation;
|
|
229
229
|
dockZonePolygons(rect, opts?): Array<DockZone>;
|
|
230
230
|
zoneRect(rect, location): Rect;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
`resolveDockTarget` decides where a drag over a tabset should land: `
|
|
234
|
-
when the pointer is in the interior, or `{
|
|
235
|
-
|
|
233
|
+
`resolveDockTarget` decides where a drag over a tabset should land: `"center"`
|
|
234
|
+
when the pointer is in the interior, or `split-${edge}` when it is within an
|
|
235
|
+
outer band of one of the four edges (default 22%; the closer edge wins in
|
|
236
236
|
corners). It accepts `{ bandFraction }` to tune the band. `zoneRect` returns the
|
|
237
237
|
region the dock indicator highlights for a `DockLocation`: the whole tabset for a
|
|
238
238
|
`center` stack, the matching half for a split. `Point` and `Rect` are exported.
|
|
@@ -252,8 +252,9 @@ these arrays and supplies the dragged boundary index.
|
|
|
252
252
|
|
|
253
253
|
```ts
|
|
254
254
|
resolveSnapTargets(config: SnapConfig, panelCount: number): number[]; // grid positions inside 0..100
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
resolveSnapGrid(config: SnapConfig | null, panelCount: number): SnapGrid;
|
|
256
|
+
snapSizes(sizes: number[], boundaryIndex: number, grid: SnapGrid): { sizes: number[]; snapped: boolean };
|
|
257
|
+
snapEnabled(grid: SnapGrid): boolean;
|
|
257
258
|
```
|
|
258
259
|
|
|
259
260
|
`resolveSnapTargets` builds the grid for a row from its config and panel count: the
|
|
@@ -262,8 +263,14 @@ union of the `step` grid (multiples of a fixed percent) and the `divisions` grid
|
|
|
262
263
|
the panel count). `snapSizes` snaps the boundary between panel `boundaryIndex` and
|
|
263
264
|
the next onto the nearest target within `threshold` (default `4`), moving only that
|
|
264
265
|
pair so siblings keep their size. It is a no-op when the grid is empty, the index
|
|
265
|
-
is out of range, or the correction would drive a panel negative.
|
|
266
|
-
|
|
266
|
+
is out of range, or the correction would drive a panel negative.
|
|
267
|
+
|
|
268
|
+
`resolveSnapGrid` is the entry point: it resolves the targets once for a row and
|
|
269
|
+
carries the threshold alongside them, and every other function takes that
|
|
270
|
+
`SnapGrid`. `snapEnabled` is then just "does this grid have any target", which
|
|
271
|
+
is why a config with no reachable target (`{ step: 100 }`, or
|
|
272
|
+
`{ divisions: "panels" }` on a one-panel row) reports off rather than arming the
|
|
273
|
+
per-move snap path. `SnapConfig` is the
|
|
267
274
|
`{ step?, divisions?, threshold? }` shape carried by `global.snap` and
|
|
268
275
|
`RowNode.snap`.
|
|
269
276
|
|
|
@@ -370,9 +377,9 @@ layout, carrying the `TabNode` to insert), which the React layer forwards to
|
|
|
370
377
|
types `AttributedNode`, `TabContainer`, `TabLocation`.
|
|
371
378
|
|
|
372
379
|
`geometry`: `resolveDockTarget`, `dockZonePolygons`, `zoneRect`; types
|
|
373
|
-
`
|
|
380
|
+
`DockZone`, `BandOptions`, `Point`, `Rect`.
|
|
374
381
|
|
|
375
|
-
`snap`: `resolveSnapTargets`, `snapSizes`, `snapEnabled`, `DEFAULT_SNAP_THRESHOLD`;
|
|
382
|
+
`snap`: `resolveSnapGrid`, `resolveSnapTargets`, `snapSizes`, `snapEnabled`, `DEFAULT_SNAP_THRESHOLD`;
|
|
376
383
|
type `SnapResult`.
|
|
377
384
|
|
|
378
385
|
`history`: `createHistory`, `dispatch`, `undo`, `redo`, `canUndo`, `canRedo`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/state/node-attrs.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* its first member and strips the keys the others own, which erased every
|
|
7
|
-
* tabset and row attribute at the parse boundary. The four keys that two kinds
|
|
8
|
-
* share (`enableClose`, `max`, `min`, `weight`) declare the same type on both
|
|
9
|
-
* sides, so merging widens nothing. Which keys are legal for a given node is
|
|
10
|
-
* enforced by the reducer against that node's own schema.
|
|
4
|
+
* Merged, not a union: a union of all-optional members matches its first member
|
|
5
|
+
* and strips the rest. The reducer enforces which keys a given node accepts.
|
|
11
6
|
*/
|
|
12
7
|
declare const mutableNodeAttrsSchema: z.ZodObject<{
|
|
13
8
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -189,7 +184,6 @@ declare const actionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
189
184
|
targetId: z.ZodString;
|
|
190
185
|
type: z.ZodLiteral<"moveNode">;
|
|
191
186
|
}, z.core.$strip>, z.ZodObject<{
|
|
192
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
193
187
|
location: z.ZodEnum<{
|
|
194
188
|
center: "center";
|
|
195
189
|
"split-bottom": "split-bottom";
|
|
@@ -397,23 +391,16 @@ type DropIntent = {
|
|
|
397
391
|
};
|
|
398
392
|
//#endregion
|
|
399
393
|
//#region src/model/schema.d.ts
|
|
400
|
-
/**
|
|
401
|
-
* Weights are relative shares, and every reader that rendered one already
|
|
402
|
-
* treated a missing weight as a single share (`row-view` summed `weight ?? 1`),
|
|
403
|
-
* so filling it in at the boundary changes nothing on screen. The one place that
|
|
404
|
-
* read a missing weight as a percentage was `placeBesideTarget`, which is why
|
|
405
|
-
* docking beside an unweighted target halved it to `50` and left its unweighted
|
|
406
|
-
* siblings rendering as a sliver of the row.
|
|
407
|
-
*/
|
|
394
|
+
/** Weights are relative shares of a row, not percentages. */
|
|
408
395
|
declare const DEFAULT_WEIGHT = 1;
|
|
409
396
|
type JsonValue = string | number | boolean | null | Array<JsonValue> | {
|
|
410
397
|
[key: string]: JsonValue;
|
|
411
398
|
};
|
|
412
399
|
declare const jsonValueSchema: z.ZodType<JsonValue>;
|
|
413
400
|
declare const edgeSchema: z.ZodEnum<{
|
|
414
|
-
left: "left";
|
|
415
401
|
top: "top";
|
|
416
402
|
bottom: "bottom";
|
|
403
|
+
left: "left";
|
|
417
404
|
right: "right";
|
|
418
405
|
}>;
|
|
419
406
|
declare const unitSchema: z.ZodEnum<{
|
|
@@ -455,11 +442,8 @@ declare const tabNodeSchema: z.ZodObject<{
|
|
|
455
442
|
type: z.ZodLiteral<"tab">;
|
|
456
443
|
}, z.core.$strip>;
|
|
457
444
|
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* `.pick`), and picking `weight` with its default attached would inject that
|
|
461
|
-
* default: `.partial()` over a defaulted field still fills it in, which would
|
|
462
|
-
* rewrite a tabset's weight on every unrelated attribute update.
|
|
445
|
+
* Kept pre-transform so `node-attrs` can `.pick()` from it: a pipe has no
|
|
446
|
+
* `.pick`, and `.partial()` over a defaulted field still fills the default in.
|
|
463
447
|
*/
|
|
464
448
|
declare const tabsetNodeObjectSchema: z.ZodObject<{
|
|
465
449
|
children: z.ZodArray<z.ZodObject<{
|
|
@@ -595,27 +579,46 @@ declare const tabsetNodeSchema: z.ZodPipe<z.ZodObject<{
|
|
|
595
579
|
} | undefined;
|
|
596
580
|
name?: string | undefined;
|
|
597
581
|
}>>;
|
|
598
|
-
type
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
582
|
+
/** The getter's explicit return type is required: without it, TS7023. */
|
|
583
|
+
declare const rowNodeSchema: z.ZodObject<{
|
|
584
|
+
children: z.ZodArray<z.ZodUnion<[typeof rowNodeSchema, typeof tabsetNodeSchema]>>;
|
|
585
|
+
id: z.ZodString;
|
|
586
|
+
max: z.ZodOptional<z.ZodObject<{
|
|
587
|
+
unit: z.ZodEnum<{
|
|
588
|
+
px: "px";
|
|
589
|
+
"%": "%";
|
|
590
|
+
em: "em";
|
|
591
|
+
rem: "rem";
|
|
592
|
+
vh: "vh";
|
|
593
|
+
vw: "vw";
|
|
594
|
+
}>;
|
|
595
|
+
value: z.ZodNumber;
|
|
596
|
+
}, z.core.$strip>>;
|
|
597
|
+
min: z.ZodOptional<z.ZodObject<{
|
|
598
|
+
unit: z.ZodEnum<{
|
|
599
|
+
px: "px";
|
|
600
|
+
"%": "%";
|
|
601
|
+
em: "em";
|
|
602
|
+
rem: "rem";
|
|
603
|
+
vh: "vh";
|
|
604
|
+
vw: "vw";
|
|
605
|
+
}>;
|
|
606
|
+
value: z.ZodNumber;
|
|
607
|
+
}, z.core.$strip>>;
|
|
608
|
+
orientation: z.ZodEnum<{
|
|
609
|
+
row: "row";
|
|
610
|
+
column: "column";
|
|
611
|
+
}>;
|
|
612
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
613
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
614
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
615
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
616
|
+
}, z.core.$strip>>;
|
|
617
|
+
type: z.ZodLiteral<"row">;
|
|
618
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
619
|
+
}, z.core.$strip>;
|
|
620
|
+
type RowNode = z.infer<typeof rowNodeSchema>;
|
|
621
|
+
type RowNodeInput = z.input<typeof rowNodeSchema>;
|
|
619
622
|
declare const geometrySchema: z.ZodObject<{
|
|
620
623
|
height: z.ZodNumber;
|
|
621
624
|
left: z.ZodNumber;
|
|
@@ -630,7 +633,43 @@ declare const floatNodeSchema: z.ZodObject<{
|
|
|
630
633
|
width: z.ZodNumber;
|
|
631
634
|
}, z.core.$strip>;
|
|
632
635
|
id: z.ZodString;
|
|
633
|
-
layout: z.
|
|
636
|
+
layout: z.ZodObject<{
|
|
637
|
+
children: z.ZodArray<z.ZodUnion<[typeof rowNodeSchema, typeof tabsetNodeSchema]>>;
|
|
638
|
+
id: z.ZodString;
|
|
639
|
+
max: z.ZodOptional<z.ZodObject<{
|
|
640
|
+
unit: z.ZodEnum<{
|
|
641
|
+
px: "px";
|
|
642
|
+
"%": "%";
|
|
643
|
+
em: "em";
|
|
644
|
+
rem: "rem";
|
|
645
|
+
vh: "vh";
|
|
646
|
+
vw: "vw";
|
|
647
|
+
}>;
|
|
648
|
+
value: z.ZodNumber;
|
|
649
|
+
}, z.core.$strip>>;
|
|
650
|
+
min: z.ZodOptional<z.ZodObject<{
|
|
651
|
+
unit: z.ZodEnum<{
|
|
652
|
+
px: "px";
|
|
653
|
+
"%": "%";
|
|
654
|
+
em: "em";
|
|
655
|
+
rem: "rem";
|
|
656
|
+
vh: "vh";
|
|
657
|
+
vw: "vw";
|
|
658
|
+
}>;
|
|
659
|
+
value: z.ZodNumber;
|
|
660
|
+
}, z.core.$strip>>;
|
|
661
|
+
orientation: z.ZodEnum<{
|
|
662
|
+
row: "row";
|
|
663
|
+
column: "column";
|
|
664
|
+
}>;
|
|
665
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
666
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
667
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
668
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
669
|
+
}, z.core.$strip>>;
|
|
670
|
+
type: z.ZodLiteral<"row">;
|
|
671
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
672
|
+
}, z.core.$strip>;
|
|
634
673
|
minimized: z.ZodOptional<z.ZodBoolean>;
|
|
635
674
|
name: z.ZodOptional<z.ZodString>;
|
|
636
675
|
type: z.ZodLiteral<"float">;
|
|
@@ -665,7 +704,43 @@ declare const dashfooSchema: z.ZodObject<{
|
|
|
665
704
|
width: z.ZodNumber;
|
|
666
705
|
}, z.core.$strip>;
|
|
667
706
|
id: z.ZodString;
|
|
668
|
-
layout: z.
|
|
707
|
+
layout: z.ZodObject<{
|
|
708
|
+
children: z.ZodArray<z.ZodUnion<[typeof rowNodeSchema, typeof tabsetNodeSchema]>>;
|
|
709
|
+
id: z.ZodString;
|
|
710
|
+
max: z.ZodOptional<z.ZodObject<{
|
|
711
|
+
unit: z.ZodEnum<{
|
|
712
|
+
px: "px";
|
|
713
|
+
"%": "%";
|
|
714
|
+
em: "em";
|
|
715
|
+
rem: "rem";
|
|
716
|
+
vh: "vh";
|
|
717
|
+
vw: "vw";
|
|
718
|
+
}>;
|
|
719
|
+
value: z.ZodNumber;
|
|
720
|
+
}, z.core.$strip>>;
|
|
721
|
+
min: z.ZodOptional<z.ZodObject<{
|
|
722
|
+
unit: z.ZodEnum<{
|
|
723
|
+
px: "px";
|
|
724
|
+
"%": "%";
|
|
725
|
+
em: "em";
|
|
726
|
+
rem: "rem";
|
|
727
|
+
vh: "vh";
|
|
728
|
+
vw: "vw";
|
|
729
|
+
}>;
|
|
730
|
+
value: z.ZodNumber;
|
|
731
|
+
}, z.core.$strip>>;
|
|
732
|
+
orientation: z.ZodEnum<{
|
|
733
|
+
row: "row";
|
|
734
|
+
column: "column";
|
|
735
|
+
}>;
|
|
736
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
737
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
738
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
739
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
740
|
+
}, z.core.$strip>>;
|
|
741
|
+
type: z.ZodLiteral<"row">;
|
|
742
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
743
|
+
}, z.core.$strip>;
|
|
669
744
|
minimized: z.ZodOptional<z.ZodBoolean>;
|
|
670
745
|
name: z.ZodOptional<z.ZodString>;
|
|
671
746
|
type: z.ZodLiteral<"float">;
|
|
@@ -690,7 +765,43 @@ declare const dashfooSchema: z.ZodObject<{
|
|
|
690
765
|
tabSetEnableTabStrip: z.ZodOptional<z.ZodBoolean>;
|
|
691
766
|
tabSetMinSize: z.ZodOptional<z.ZodNumber>;
|
|
692
767
|
}, z.core.$strip>;
|
|
693
|
-
layout: z.
|
|
768
|
+
layout: z.ZodObject<{
|
|
769
|
+
children: z.ZodArray<z.ZodUnion<[typeof rowNodeSchema, typeof tabsetNodeSchema]>>;
|
|
770
|
+
id: z.ZodString;
|
|
771
|
+
max: z.ZodOptional<z.ZodObject<{
|
|
772
|
+
unit: z.ZodEnum<{
|
|
773
|
+
px: "px";
|
|
774
|
+
"%": "%";
|
|
775
|
+
em: "em";
|
|
776
|
+
rem: "rem";
|
|
777
|
+
vh: "vh";
|
|
778
|
+
vw: "vw";
|
|
779
|
+
}>;
|
|
780
|
+
value: z.ZodNumber;
|
|
781
|
+
}, z.core.$strip>>;
|
|
782
|
+
min: z.ZodOptional<z.ZodObject<{
|
|
783
|
+
unit: z.ZodEnum<{
|
|
784
|
+
px: "px";
|
|
785
|
+
"%": "%";
|
|
786
|
+
em: "em";
|
|
787
|
+
rem: "rem";
|
|
788
|
+
vh: "vh";
|
|
789
|
+
vw: "vw";
|
|
790
|
+
}>;
|
|
791
|
+
value: z.ZodNumber;
|
|
792
|
+
}, z.core.$strip>>;
|
|
793
|
+
orientation: z.ZodEnum<{
|
|
794
|
+
row: "row";
|
|
795
|
+
column: "column";
|
|
796
|
+
}>;
|
|
797
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
798
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
799
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
800
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
801
|
+
}, z.core.$strip>>;
|
|
802
|
+
type: z.ZodLiteral<"row">;
|
|
803
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
804
|
+
}, z.core.$strip>;
|
|
694
805
|
maximizedTabsetId: z.ZodOptional<z.ZodString>;
|
|
695
806
|
version: z.ZodLiteral<1>;
|
|
696
807
|
}, z.core.$strip>;
|
|
@@ -763,12 +874,6 @@ type Rect = {
|
|
|
763
874
|
x: number;
|
|
764
875
|
y: number;
|
|
765
876
|
};
|
|
766
|
-
type DockTarget = {
|
|
767
|
-
kind: "tab";
|
|
768
|
-
} | {
|
|
769
|
-
edge: Edge;
|
|
770
|
-
kind: "split";
|
|
771
|
-
};
|
|
772
877
|
type BandOptions = {
|
|
773
878
|
bandFraction?: number;
|
|
774
879
|
};
|
|
@@ -776,21 +881,25 @@ type DockZone = {
|
|
|
776
881
|
location: DockLocation;
|
|
777
882
|
points: Array<Point>;
|
|
778
883
|
};
|
|
779
|
-
declare const dockLocationFor: (target: DockTarget) => DockLocation;
|
|
780
884
|
declare const splitEdge: (location: DockLocation) => Edge | undefined;
|
|
781
|
-
declare const resolveDockTarget: (pointer: Point, rect: Rect, opts?: BandOptions) =>
|
|
885
|
+
declare const resolveDockTarget: (pointer: Point, rect: Rect, opts?: BandOptions) => DockLocation;
|
|
782
886
|
declare const dockZonePolygons: (rect: Rect, opts?: BandOptions) => Array<DockZone>;
|
|
783
887
|
declare const zoneRect: (rect: Rect, location: DockLocation) => Rect;
|
|
784
888
|
//#endregion
|
|
785
889
|
//#region src/geometry/snap.d.ts
|
|
786
890
|
declare const DEFAULT_SNAP_THRESHOLD = 4;
|
|
787
891
|
declare const resolveSnapTargets: (config: SnapConfig, panelCount: number) => Array<number>;
|
|
788
|
-
|
|
892
|
+
type SnapGrid = {
|
|
893
|
+
targets: Array<number>;
|
|
894
|
+
threshold: number;
|
|
895
|
+
};
|
|
896
|
+
declare const resolveSnapGrid: (config: SnapConfig | null, panelCount: number) => SnapGrid;
|
|
897
|
+
declare const snapEnabled: (grid: SnapGrid) => boolean;
|
|
789
898
|
type SnapResult = {
|
|
790
899
|
sizes: Array<number>;
|
|
791
900
|
snapped: boolean;
|
|
792
901
|
};
|
|
793
|
-
declare const snapSizes: (sizes: Array<number>, boundaryIndex: number,
|
|
902
|
+
declare const snapSizes: (sizes: Array<number>, boundaryIndex: number, grid: SnapGrid) => SnapResult;
|
|
794
903
|
type SnapDecision = {
|
|
795
904
|
kind: "inactive";
|
|
796
905
|
} | {
|
|
@@ -799,8 +908,8 @@ type SnapDecision = {
|
|
|
799
908
|
kind: "engage";
|
|
800
909
|
sizes: Array<number>;
|
|
801
910
|
};
|
|
802
|
-
declare const decideSnap: (sizes: Array<number>, boundaryIndex: number | null,
|
|
803
|
-
declare const settleSnap: (sizes: Array<number>, boundaryIndex: number | null,
|
|
911
|
+
declare const decideSnap: (sizes: Array<number>, boundaryIndex: number | null, grid: SnapGrid) => SnapDecision;
|
|
912
|
+
declare const settleSnap: (sizes: Array<number>, boundaryIndex: number | null, grid: SnapGrid) => Array<number>;
|
|
804
913
|
//#endregion
|
|
805
914
|
//#region src/state/history.d.ts
|
|
806
915
|
type History = {
|
|
@@ -812,6 +921,11 @@ declare const HISTORY_LIMIT = 100;
|
|
|
812
921
|
declare const createHistory: (present: Dashfoo) => History;
|
|
813
922
|
declare const canUndo: (history: History) => boolean;
|
|
814
923
|
declare const canRedo: (history: History) => boolean;
|
|
924
|
+
/**
|
|
925
|
+
* An action that changed nothing is not an edit: recording it would spend an
|
|
926
|
+
* undo slot and clear a redo stack the user just built. Not coalescing (ADR
|
|
927
|
+
* 0002): two distinct edits are still two entries.
|
|
928
|
+
*/
|
|
815
929
|
declare const dispatch: (history: History, action: Action) => History;
|
|
816
930
|
declare const undo: (history: History) => History;
|
|
817
931
|
declare const redo: (history: History) => History;
|
|
@@ -827,17 +941,6 @@ declare const normalize: (model: Dashfoo) => Dashfoo;
|
|
|
827
941
|
type DashfooContext = {
|
|
828
942
|
history: History;
|
|
829
943
|
};
|
|
830
|
-
type DashfooEvent = {
|
|
831
|
-
action: Action;
|
|
832
|
-
type: "DISPATCH";
|
|
833
|
-
} | {
|
|
834
|
-
model: Dashfoo;
|
|
835
|
-
type: "SET_MODEL";
|
|
836
|
-
} | {
|
|
837
|
-
type: "REDO";
|
|
838
|
-
} | {
|
|
839
|
-
type: "UNDO";
|
|
840
|
-
};
|
|
841
944
|
type DashfooMachineInput = {
|
|
842
945
|
model: Dashfoo;
|
|
843
946
|
};
|
|
@@ -867,27 +970,34 @@ type DragSubject = {
|
|
|
867
970
|
kind: "external";
|
|
868
971
|
tab: TabNode;
|
|
869
972
|
};
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
973
|
+
/** `scope` names whoever resolved the intent, echoed back on `COMMIT` so the host can route the action. */
|
|
974
|
+
type DropResolution = {
|
|
975
|
+
intent: DropIntent;
|
|
976
|
+
scope: string;
|
|
873
977
|
};
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
978
|
+
/** One value, so a drop target without a subject is unrepresentable. See ADR 0002. */
|
|
979
|
+
type DragState = {
|
|
980
|
+
drop: DropResolution | null;
|
|
981
|
+
kind: "dragging";
|
|
878
982
|
subject: DragSubject;
|
|
879
|
-
type: "START";
|
|
880
|
-
} | {
|
|
881
|
-
type: "CANCEL";
|
|
882
983
|
} | {
|
|
883
|
-
|
|
984
|
+
kind: "idle";
|
|
985
|
+
};
|
|
986
|
+
type DragContext = {
|
|
987
|
+
drag: DragState;
|
|
884
988
|
};
|
|
885
989
|
type DragEmitted = {
|
|
886
990
|
action: Action;
|
|
991
|
+
scope: string;
|
|
887
992
|
type: "COMMIT";
|
|
888
993
|
};
|
|
994
|
+
/** One definition of both "is this drop valid" and "what does it do", so the guard and the emit agree. */
|
|
995
|
+
declare const dropAction: (drag: DragState) => {
|
|
996
|
+
action: Action;
|
|
997
|
+
scope: string;
|
|
998
|
+
} | null;
|
|
889
999
|
declare const dragDockMachine: import("xstate").StateMachine<DragContext, {
|
|
890
|
-
|
|
1000
|
+
drop: DropResolution | null;
|
|
891
1001
|
type: "OVER";
|
|
892
1002
|
} | {
|
|
893
1003
|
subject: DragSubject;
|
|
@@ -899,7 +1009,7 @@ declare const dragDockMachine: import("xstate").StateMachine<DragContext, {
|
|
|
899
1009
|
}, {}, never, never, {
|
|
900
1010
|
type: "hasValidDrop";
|
|
901
1011
|
params: unknown;
|
|
902
|
-
}, never, "
|
|
1012
|
+
}, never, "dragging" | "idle", string, import("xstate").NonReducibleUnknown, import("xstate").NonReducibleUnknown, DragEmitted, import("xstate").MetaObject, {
|
|
903
1013
|
id: "dragDock";
|
|
904
1014
|
states: {
|
|
905
1015
|
readonly dragging: {};
|
|
@@ -908,6 +1018,8 @@ declare const dragDockMachine: import("xstate").StateMachine<DragContext, {
|
|
|
908
1018
|
}>;
|
|
909
1019
|
//#endregion
|
|
910
1020
|
//#region src/state/reducer.d.ts
|
|
1021
|
+
/** Identity-equal output means "no edit". A rejected action skips `normalize`, so
|
|
1022
|
+
* pass a model that has already been through it. */
|
|
911
1023
|
declare const reducer: (model: Dashfoo, action: Action) => Dashfoo;
|
|
912
1024
|
//#endregion
|
|
913
1025
|
//#region src/model/serialize.d.ts
|
|
@@ -933,14 +1045,14 @@ declare const collectTabsets: (model: Dashfoo) => Array<TabsetNode>;
|
|
|
933
1045
|
declare const getFirstTabset: (model: Dashfoo) => TabsetNode | undefined;
|
|
934
1046
|
declare const findTabset: (model: Dashfoo, tabsetId: string) => TabsetNode | undefined;
|
|
935
1047
|
declare const findTab: (model: Dashfoo, tabId: string) => TabLocation | undefined;
|
|
936
|
-
declare const findRow: (
|
|
1048
|
+
declare const findRow: (model: Dashfoo, id: string) => RowNode | undefined;
|
|
937
1049
|
declare const findAttributedNode: (model: Dashfoo, id: string) => AttributedNode | undefined;
|
|
938
1050
|
declare const findRootContaining: (model: Dashfoo, nodeId: string) => RowNode | undefined;
|
|
939
|
-
declare const findTabsetParent: (
|
|
1051
|
+
declare const findTabsetParent: (model: Dashfoo, tabsetId: string) => {
|
|
940
1052
|
index: number;
|
|
941
1053
|
parent: RowNode;
|
|
942
1054
|
} | undefined;
|
|
943
1055
|
declare const findDuplicateIds: (model: Dashfoo) => Array<string>;
|
|
944
1056
|
//#endregion
|
|
945
|
-
export { type Action, type AttributedNode, type BandOptions, DEFAULT_SNAP_THRESHOLD, DEFAULT_WEIGHT, type Dashfoo, type
|
|
1057
|
+
export { type Action, type AttributedNode, type BandOptions, DEFAULT_SNAP_THRESHOLD, DEFAULT_WEIGHT, type Dashfoo, type DashfooInput, type Dimension, type DockLocation, type DockZone, type DragState, type DragSubject, type DropIntent, type DropResolution, type Edge, type FloatNode, type FloatOptions, type Geometry, type GlobalAttributes, HISTORY_LIMIT, type History, type Json, type ModelOptions, type MutableNodeAttrs, type Node, type Orientation, type Point, type Rect, type RowNode, type RowNodeInput, type RowOptions, type SnapConfig, type SnapDecision, type SnapGrid, type SnapResult, type TabContainer, type TabLocation, type TabNode, type TabOptions, type TabsetNode, type TabsetOptions, type Unit, actionSchema, canRedo, canUndo, collectRoots, collectTabsets, collectTabsetsInRow, createHistory, createNodeId, createTabId, dashfooMachine, dashfooSchema, decideSnap, dimensionSchema, dispatch, dockLocationSchema, dockZonePolygons, dragDockMachine, dropAction, edgeSchema, findAttributedNode, findDuplicateIds, findFloat, findRootContaining, findRow, findTab, findTabset, findTabsetParent, floatNode, floatNodeSchema, fromJSON, geometrySchema, getFirstTabset, globalAttributesSchema, jsonValueSchema, model, mutableNodeAttrsSchema, normalize, orientationSchema, parseModel, redo, reducer, resolveDockTarget, resolveSnapGrid, resolveSnapTargets, row, rowNodeSchema, settleSnap, snapEnabled, snapSchema, snapSizes, splitEdge, stackModel, tab, tabNodeSchema, tabset, tabsetNodeObjectSchema, tabsetNodeSchema, toJSON, undo, unitSchema, zoneRect };
|
|
946
1058
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state/node-attrs.ts","../src/state/actions.ts","../src/model/schema.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/geometry/snap.ts","../src/state/history.ts","../src/model/ids.ts","../src/model/invariants.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/state/reducer.ts","../src/model/serialize.ts","../src/model/stack.ts","../src/model/tree.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state/node-attrs.ts","../src/state/actions.ts","../src/model/schema.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/geometry/snap.ts","../src/state/history.ts","../src/model/ids.ts","../src/model/invariants.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/state/reducer.ts","../src/model/serialize.ts","../src/model/stack.ts","../src/model/tree.ts"],"mappings":";;;;;;cA8CM,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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