Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!/.gitignore
!/.github

build
dist
node_modules
playwright-report
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
],
"scripts": {
"build": "tsx build.ts",
"build:watch": "tsx build.ts --watch",
"watch": "tsx build.ts --watch",
"clean": "rm -rf dist",
"test": "playwright test tests/integration tests/unit",
"test:perf": "playwright test --workers=1 ./benchmarks",
"test": "tsx test.ts",
"bench": "playwright test --workers=1 ./benchmarks",
"example": "tsx serve.ts",
"deploy": "tsx deploy.ts",
"lint": "biome lint src tests",
Expand All @@ -34,6 +34,7 @@
"@playwright/test": "^1.57.0",
"@types/node": "^22.10.5",
"esbuild": "^0.27.2",
"monocart-coverage-reports": "^2.12.2",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
}
Expand Down
189 changes: 189 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
7 changes: 7 additions & 0 deletions src/layout/types.ts → src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export interface LayoutPath {
layout: Layout;
}

/**
* The detail payload of the `regular-layout-resize-before` event.
*/
export interface PresizeDetail {
calculatePresizePaths(): Record<string, LayoutPath>;
}

/**
* An empty `Layout` with no panels.
*/
Expand Down
14 changes: 13 additions & 1 deletion src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { RegularLayout } from "./regular-layout.ts";
import { RegularLayoutFrame } from "./regular-layout-frame.ts";
import type { Layout } from "./layout/types.ts";
import type { Layout, PresizeDetail } from "./core/types.ts";
import { RegularLayoutTab } from "./regular-layout-tab.ts";

customElements.define("regular-layout", RegularLayout);
Expand Down Expand Up @@ -59,6 +59,12 @@ declare global {
options?: { signal: AbortSignal },
): void;

addEventListener(
name: "regular-layout-resize-before",
cb: (e: RegularLayoutPresizeEvent) => void,
options?: { signal: AbortSignal },
): void;

removeEventListener(
name: "regular-layout-update",
cb: (e: RegularLayoutEvent) => void,
Expand All @@ -68,7 +74,13 @@ declare global {
name: "regular-layout-before-update",
cb: (e: RegularLayoutEvent) => void,
): void;

removeEventListener(
name: "regular-layout-resize-before",
cb: (e: RegularLayoutPresizeEvent) => void,
): void;
}
}

export type RegularLayoutEvent = CustomEvent<Layout>;
export type RegularLayoutPresizeEvent = CustomEvent<PresizeDetail>;
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@
* @packageDocumentation
*/

export type * from "./layout/types.ts";
export type * from "./core/types.ts";

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

export type * from "./extensions.ts";

// Side effects
import "./extensions.ts";
4 changes: 2 additions & 2 deletions src/layout/calculate_edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import { DEFAULT_PHYSICS, type Physics } from "./constants";
import { DEFAULT_PHYSICS, type Physics } from "../core/constants";
import { insert_child } from "./insert_child";
import type {
Layout,
LayoutPath,
LayoutPathTraversal,
Orientation,
ViewWindow,
} from "./types";
} from "../core/types";

/**
* Calculates an insertion point (which may involve splitting a single
Expand Down
7 changes: 5 additions & 2 deletions src/layout/calculate_intersect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
Layout,
ViewWindow,
LayoutPathTraversal,
} from "./types.ts";
} from "../core/types.ts";

const VIEW_WINDOW = {
row_start: 0,
Expand Down Expand Up @@ -130,7 +130,10 @@ function calculate_intersection_recursive(
}

// Check if position falls within this child's bounds
if (position >= current_pos && position < next_pos) {
if (
position >= current_pos &&
(position < next_pos || i === panel.children.length - 1)
) {
return calculate_intersection_recursive(
column,
row,
Expand Down
Loading
Loading