regular-layout 0.1.0 → 0.2.1

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 (44) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/extensions.d.ts +5 -4
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.js +15 -10
  6. package/dist/index.js.map +4 -4
  7. package/dist/{common → layout}/calculate_edge.d.ts +3 -2
  8. package/dist/{common → layout}/calculate_intersect.d.ts +13 -9
  9. package/dist/layout/constants.d.ts +81 -0
  10. package/dist/{common → layout}/flatten.d.ts +1 -1
  11. package/dist/{common → layout}/generate_grid.d.ts +5 -4
  12. package/dist/layout/generate_overlay.d.ts +2 -0
  13. package/dist/{common → layout}/insert_child.d.ts +3 -2
  14. package/dist/{common → layout}/redistribute_panel_sizes.d.ts +2 -2
  15. package/dist/{common → layout}/remove_child.d.ts +1 -1
  16. package/dist/{common/layout_config.d.ts → layout/types.d.ts} +6 -10
  17. package/dist/regular-layout-frame.d.ts +1 -4
  18. package/dist/regular-layout-tab.d.ts +26 -0
  19. package/dist/regular-layout.d.ts +37 -18
  20. package/package.json +9 -7
  21. package/src/extensions.ts +10 -4
  22. package/src/index.ts +3 -7
  23. package/src/layout/calculate_edge.ts +217 -0
  24. package/src/{common → layout}/calculate_intersect.ts +61 -101
  25. package/src/layout/constants.ts +119 -0
  26. package/src/{common → layout}/flatten.ts +1 -1
  27. package/src/{common → layout}/generate_grid.ts +120 -106
  28. package/src/{common → layout}/generate_overlay.ts +26 -12
  29. package/src/{common → layout}/insert_child.ts +105 -51
  30. package/src/{common → layout}/redistribute_panel_sizes.ts +11 -4
  31. package/src/{common → layout}/remove_child.ts +2 -2
  32. package/src/{common/layout_config.ts → layout/types.ts} +7 -19
  33. package/src/regular-layout-frame.ts +40 -74
  34. package/src/regular-layout-tab.ts +103 -0
  35. package/src/regular-layout.ts +260 -148
  36. package/themes/chicago.css +89 -0
  37. package/themes/fluxbox.css +110 -0
  38. package/themes/gibson.css +264 -0
  39. package/themes/hotdog.css +88 -0
  40. package/themes/lorax.css +130 -0
  41. package/dist/common/constants.d.ts +0 -29
  42. package/dist/common/generate_overlay.d.ts +0 -2
  43. package/src/common/calculate_edge.ts +0 -104
  44. package/src/common/constants.ts +0 -46
@@ -1,104 +0,0 @@
1
- // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2
- // ░░░░░░░░▄▀░█▀▄░█▀▀░█▀▀░█░█░█░░░█▀█░█▀▄░░░░░█░░░█▀█░█░█░█▀█░█░█░▀█▀░▀▄░░░░░░░░
3
- // ░░░░░░░▀▄░░█▀▄░█▀▀░█░█░█░█░█░░░█▀█░█▀▄░▀▀▀░█░░░█▀█░░█░░█░█░█░█░░█░░░▄▀░░░░░░░
4
- // ░░░░░░░░░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░▀░░░░░▀▀▀░▀░▀░░▀░░▀▀▀░▀▀▀░░▀░░▀░░░░░░░░░
5
- // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
6
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
7
- // ┃ * Copyright (c) 2026, the Regular Layout Authors. This file is part * ┃
8
- // ┃ * of the Regular Layout library, distributed under the terms of the * ┃
9
- // ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
10
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
11
-
12
- import { calculate_intersection } from "./calculate_intersect";
13
- import { SPLIT_EDGE_TOLERANCE } from "./constants";
14
- import { insert_child } from "./insert_child";
15
- import type { Layout, LayoutPath, Orientation } from "./layout_config";
16
-
17
- /**
18
- * Calculates an insertion point (which may involve splitting a single
19
- * `"child-panel"` into a new `"split-panel"`), based on the cursor position.
20
- * *
21
- * @param col - The cursor column.
22
- * @param row - The cursor row.
23
- * @param panel - The `Layout` to insert into.
24
- * @param slot - The slot identifier where the insert should occur
25
- * @param drop_target - The `LayoutPath` (from `calculateIntersect`) of the
26
- * panel to either insert next to, or split by.
27
- * @returns A new `LayoutPath` reflecting the updated (maybe) `"split-panel"`,
28
- * which is enough to draw the overlay.
29
- */
30
- export function calculate_edge(
31
- col: number,
32
- row: number,
33
- panel: Layout,
34
- slot: string,
35
- drop_target: LayoutPath,
36
- ): LayoutPath {
37
- const is_column_edge =
38
- drop_target.column_offset < SPLIT_EDGE_TOLERANCE ||
39
- drop_target.column_offset > 1 - SPLIT_EDGE_TOLERANCE;
40
-
41
- const is_row_edge =
42
- drop_target.row_offset < SPLIT_EDGE_TOLERANCE ||
43
- drop_target.row_offset > 1 - SPLIT_EDGE_TOLERANCE;
44
-
45
- if (is_column_edge) {
46
- return handle_axis(
47
- col,
48
- row,
49
- panel,
50
- slot,
51
- drop_target,
52
- drop_target.column_offset,
53
- "horizontal",
54
- );
55
- } else if (is_row_edge) {
56
- return handle_axis(
57
- col,
58
- row,
59
- panel,
60
- slot,
61
- drop_target,
62
- drop_target.row_offset,
63
- "vertical",
64
- );
65
- }
66
-
67
- return drop_target;
68
- }
69
-
70
- function handle_axis(
71
- col: number,
72
- row: number,
73
- panel: Layout,
74
- slot: string,
75
- drop_target: LayoutPath,
76
- axis_offset: number,
77
- axis_orientation: Orientation,
78
- ): LayoutPath {
79
- const is_before = axis_offset < SPLIT_EDGE_TOLERANCE;
80
- if (drop_target.orientation === axis_orientation) {
81
- if (drop_target.path.length === 0) {
82
- const insert_index = is_before ? 0 : 1;
83
- const new_panel = insert_child(panel, slot, [insert_index]);
84
- drop_target = calculate_intersection(col, row, new_panel, false);
85
- } else {
86
- const path_without_last = drop_target.path.slice(0, -1);
87
- const last_index = drop_target.path[drop_target.path.length - 1];
88
- const insert_index = is_before ? last_index : last_index + 1;
89
- const new_panel = insert_child(panel, slot, [
90
- ...path_without_last,
91
- insert_index,
92
- ]);
93
-
94
- drop_target = calculate_intersection(col, row, new_panel, false);
95
- }
96
- } else {
97
- const path = [...drop_target.path, is_before ? 0 : 1];
98
- const new_panel = insert_child(panel, slot, path, axis_orientation);
99
- drop_target = calculate_intersection(col, row, new_panel, false);
100
- }
101
-
102
- drop_target.is_edge = true;
103
- return drop_target;
104
- }
@@ -1,46 +0,0 @@
1
- // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2
- // ░░░░░░░░▄▀░█▀▄░█▀▀░█▀▀░█░█░█░░░█▀█░█▀▄░░░░░█░░░█▀█░█░█░█▀█░█░█░▀█▀░▀▄░░░░░░░░
3
- // ░░░░░░░▀▄░░█▀▄░█▀▀░█░█░█░█░█░░░█▀█░█▀▄░▀▀▀░█░░░█▀█░░█░░█░█░█░█░░█░░░▄▀░░░░░░░
4
- // ░░░░░░░░░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░▀░░░░░▀▀▀░▀░▀░░▀░░▀▀▀░▀▀▀░░▀░░▀░░░░░░░░░
5
- // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
6
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
7
- // ┃ * Copyright (c) 2026, the Regular Layout Authors. This file is part * ┃
8
- // ┃ * of the Regular Layout library, distributed under the terms of the * ┃
9
- // ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
10
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
11
-
12
- import type { OverlayMode } from "./layout_config";
13
-
14
- /**
15
- * The minimum number of pixels the mouse must move to be considered a drag.
16
- */
17
- export const MIN_DRAG_DISTANCE = 10;
18
-
19
- /**
20
- * Class name to use for child elements in overlay position (dragging).
21
- */
22
- export const OVERLAY_CLASSNAME = "overlay";
23
-
24
- /**
25
- * The percentage of the maximum resize distance that will be clamped.
26
- *
27
- */
28
- export const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;
29
-
30
- /**
31
- * Threshold from panel edge that is considered a split vs drop action.
32
- */
33
- export const SPLIT_EDGE_TOLERANCE = 0.25;
34
-
35
- /**
36
- * Tolerance threshold for considering two grid track positions as identical.
37
- *
38
- * When collecting and deduplicating track positions, any positions closer than
39
- * this value are treated as the same position to avoid redundant grid tracks.
40
- */
41
- export const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;
42
-
43
- /**
44
- * The overlay default behavior.
45
- */
46
- export const OVERLAY_DEFAULT: OverlayMode = "absolute";