Skip to content

Commit cc97ed1

Browse files
committed
Add pre-size and inverse coordinates calculation APIs
1 parent 17a47b8 commit cc97ed1

41 files changed

Lines changed: 1760 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!/.gitignore
33
!/.github
44

5+
build
56
dist
67
node_modules
78
playwright-report

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
],
2020
"scripts": {
2121
"build": "tsx build.ts",
22-
"build:watch": "tsx build.ts --watch",
22+
"watch": "tsx build.ts --watch",
2323
"clean": "rm -rf dist",
24-
"test": "playwright test tests/integration tests/unit",
25-
"test:perf": "playwright test --workers=1 ./benchmarks",
24+
"test": "tsx test.ts",
25+
"bench": "playwright test --workers=1 ./benchmarks",
2626
"example": "tsx serve.ts",
2727
"deploy": "tsx deploy.ts",
2828
"lint": "biome lint src tests",
@@ -34,6 +34,7 @@
3434
"@playwright/test": "^1.57.0",
3535
"@types/node": "^22.10.5",
3636
"esbuild": "^0.27.2",
37+
"monocart-coverage-reports": "^2.12.2",
3738
"tsx": "^4.21.0",
3839
"typescript": "^5.9.3"
3940
}

pnpm-lock.yaml

Lines changed: 189 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ export interface LayoutPath {
9595
layout: Layout;
9696
}
9797

98+
/**
99+
* The detail payload of the `regular-layout-resize-before` event.
100+
*/
101+
export interface PresizeDetail {
102+
calculatePresizePaths(): Record<string, LayoutPath>;
103+
}
104+
98105
/**
99106
* An empty `Layout` with no panels.
100107
*/

src/extensions.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import { RegularLayout } from "./regular-layout.ts";
1313
import { RegularLayoutFrame } from "./regular-layout-frame.ts";
14-
import type { Layout } from "./layout/types.ts";
14+
import type { Layout, PresizeDetail } from "./core/types.ts";
1515
import { RegularLayoutTab } from "./regular-layout-tab.ts";
1616

1717
customElements.define("regular-layout", RegularLayout);
@@ -59,6 +59,12 @@ declare global {
5959
options?: { signal: AbortSignal },
6060
): void;
6161

62+
addEventListener(
63+
name: "regular-layout-resize-before",
64+
cb: (e: RegularLayoutPresizeEvent) => void,
65+
options?: { signal: AbortSignal },
66+
): void;
67+
6268
removeEventListener(
6369
name: "regular-layout-update",
6470
cb: (e: RegularLayoutEvent) => void,
@@ -68,7 +74,13 @@ declare global {
6874
name: "regular-layout-before-update",
6975
cb: (e: RegularLayoutEvent) => void,
7076
): void;
77+
78+
removeEventListener(
79+
name: "regular-layout-resize-before",
80+
cb: (e: RegularLayoutPresizeEvent) => void,
81+
): void;
7182
}
7283
}
7384

7485
export type RegularLayoutEvent = CustomEvent<Layout>;
86+
export type RegularLayoutPresizeEvent = CustomEvent<PresizeDetail>;

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@
5959
* @packageDocumentation
6060
*/
6161

62-
export type * from "./layout/types.ts";
62+
export type * from "./core/types.ts";
6363

6464
export { RegularLayout } from "./regular-layout.ts";
6565
export { RegularLayoutFrame } from "./regular-layout-frame.ts";
6666

67+
export type * from "./extensions.ts";
68+
6769
// Side effects
6870
import "./extensions.ts";

src/layout/calculate_edge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
1010
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1111

12-
import { DEFAULT_PHYSICS, type Physics } from "./constants";
12+
import { DEFAULT_PHYSICS, type Physics } from "../core/constants";
1313
import { insert_child } from "./insert_child";
1414
import type {
1515
Layout,
1616
LayoutPath,
1717
LayoutPathTraversal,
1818
Orientation,
1919
ViewWindow,
20-
} from "./types";
20+
} from "../core/types";
2121

2222
/**
2323
* Calculates an insertion point (which may involve splitting a single

src/layout/calculate_intersect.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
Layout,
1616
ViewWindow,
1717
LayoutPathTraversal,
18-
} from "./types.ts";
18+
} from "../core/types.ts";
1919

2020
const VIEW_WINDOW = {
2121
row_start: 0,
@@ -130,7 +130,10 @@ function calculate_intersection_recursive(
130130
}
131131

132132
// Check if position falls within this child's bounds
133-
if (position >= current_pos && position < next_pos) {
133+
if (
134+
position >= current_pos &&
135+
(position < next_pos || i === panel.children.length - 1)
136+
) {
134137
return calculate_intersection_recursive(
135138
column,
136139
row,

0 commit comments

Comments
 (0)