regular-layout 0.0.2 → 0.2.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/LICENSE.md +1 -1
- package/README.md +20 -6
- package/dist/extensions.d.ts +10 -11
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -10
- package/dist/index.js.map +4 -4
- package/dist/{common/calculate_split.d.ts → layout/calculate_edge.d.ts} +2 -2
- package/dist/{common → layout}/calculate_intersect.d.ts +7 -9
- package/dist/layout/constants.d.ts +43 -0
- package/dist/{common → layout}/flatten.d.ts +1 -1
- package/dist/{common → layout}/generate_grid.d.ts +3 -3
- package/dist/layout/generate_overlay.d.ts +2 -0
- package/dist/{common → layout}/insert_child.d.ts +3 -2
- package/dist/{common → layout}/redistribute_panel_sizes.d.ts +1 -1
- package/dist/{common → layout}/remove_child.d.ts +1 -1
- package/dist/{common/layout_config.d.ts → layout/types.d.ts} +9 -31
- package/dist/regular-layout-frame.d.ts +2 -2
- package/dist/regular-layout-tab.d.ts +26 -0
- package/dist/regular-layout.d.ts +61 -27
- package/package.json +9 -6
- package/src/extensions.ts +25 -15
- package/src/index.ts +3 -7
- package/src/layout/calculate_edge.ts +209 -0
- package/src/{common → layout}/calculate_intersect.ts +61 -100
- package/src/layout/constants.ts +63 -0
- package/src/{common → layout}/flatten.ts +2 -1
- package/src/{common → layout}/generate_grid.ts +77 -106
- package/src/{common → layout}/generate_overlay.ts +27 -12
- package/src/{common → layout}/insert_child.ts +105 -50
- package/src/{common → layout}/redistribute_panel_sizes.ts +2 -4
- package/src/{common → layout}/remove_child.ts +3 -2
- package/src/{common/layout_config.ts → layout/types.ts} +9 -44
- package/src/regular-layout-frame.ts +83 -68
- package/src/regular-layout-tab.ts +103 -0
- package/src/regular-layout.ts +257 -175
- package/themes/chicago.css +89 -0
- package/themes/fluxbox.css +110 -0
- package/themes/gibson.css +264 -0
- package/themes/hotdog.css +88 -0
- package/themes/lorax.css +129 -0
- package/dist/common/generate_overlay.d.ts +0 -2
- package/src/common/calculate_split.ts +0 -185
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Layout, LayoutPath } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Calculates an insertion point (which may involve splitting a single
|
|
4
4
|
* `"child-panel"` into a new `"split-panel"`), based on the cursor position.
|
|
@@ -12,4 +12,4 @@ import { type Layout, type LayoutPath } from "./layout_config";
|
|
|
12
12
|
* @returns A new `LayoutPath` reflecting the updated (maybe) `"split-panel"`,
|
|
13
13
|
* which is enough to draw the overlay.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function calculate_edge(col: number, row: number, panel: Layout, slot: string, drop_target: LayoutPath, box?: DOMRect): LayoutPath;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import type { LayoutPath, LayoutDivider, Layout } from "./
|
|
1
|
+
import type { LayoutPath, LayoutDivider, Layout } from "./types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Determines which panel or divider is located at a given position in the
|
|
4
4
|
* layout.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* height
|
|
8
|
-
* @param column - Horizontal position as a fraction (0-1) of the
|
|
9
|
-
* container width
|
|
6
|
+
* @param column - Horizontal position as a fraction (0-1) of the container width
|
|
7
|
+
* @param row - Vertical position as a fraction (0-1) of the container height
|
|
10
8
|
* @param layout - The layout tree to search
|
|
11
9
|
* @param check_dividers - Whether `LayoutDivider` intersection should be
|
|
12
|
-
* checked, which
|
|
10
|
+
* checked, which you may not want for e.g. `drop` actions.
|
|
13
11
|
* @returns The panel path if over a panel, a divider if over a resizable
|
|
14
12
|
* boundary, or null if outside all panels
|
|
15
13
|
*/
|
|
16
|
-
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers
|
|
17
|
-
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers
|
|
18
|
-
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?:
|
|
14
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: null): LayoutPath | null;
|
|
15
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: DOMRect): LayoutPath | null | LayoutDivider;
|
|
16
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: DOMRect | null): LayoutPath | null | LayoutDivider;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { OverlayMode } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.
|
|
4
|
+
* `"regular-layout-before-update"`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CUSTOM_EVENT_NAME_PREFIX = "regular-layout";
|
|
7
|
+
/**
|
|
8
|
+
* The minimum number of pixels the mouse must move to be considered a drag.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MIN_DRAG_DISTANCE = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Class name to use for child elements in overlay position (dragging).
|
|
13
|
+
*/
|
|
14
|
+
export declare const OVERLAY_CLASSNAME = "overlay";
|
|
15
|
+
/**
|
|
16
|
+
* The percentage of the maximum resize distance that will be clamped.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;
|
|
20
|
+
/**
|
|
21
|
+
* Threshold from panel edge that is considered a split vs drop action.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SPLIT_EDGE_TOLERANCE = 0.25;
|
|
24
|
+
/**
|
|
25
|
+
* Threshold from _container_ edge that is considered a split action on the root
|
|
26
|
+
* node.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SPLIT_ROOT_EDGE_TOLERANCE = 0.01;
|
|
29
|
+
/**
|
|
30
|
+
* Tolerance threshold for considering two grid track positions as identical.
|
|
31
|
+
*
|
|
32
|
+
* When collecting and deduplicating track positions, any positions closer than
|
|
33
|
+
* this value are treated as the same position to avoid redundant grid tracks.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;
|
|
36
|
+
/**
|
|
37
|
+
* The overlay default behavior.
|
|
38
|
+
*/
|
|
39
|
+
export declare const OVERLAY_DEFAULT: OverlayMode;
|
|
40
|
+
/**
|
|
41
|
+
* Width of split panel dividers in pixels (for hit-test purposes).
|
|
42
|
+
*/
|
|
43
|
+
export declare const GRID_DIVIDER_SIZE = 6;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Layout } from "./types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Generates CSS Grid styles to render a layout tree.
|
|
4
4
|
* Creates grid-template-rows, grid-template-columns, and positioning rules for
|
|
@@ -25,8 +25,8 @@ import { type Layout } from "./layout_config.ts";
|
|
|
25
25
|
* const css = create_css_grid_layout(layout);
|
|
26
26
|
* // Returns CSS like:
|
|
27
27
|
* // :host { display: grid; grid-template-columns: 25% 75%; ... }
|
|
28
|
-
* // :host ::slotted([
|
|
29
|
-
* // :host ::slotted([
|
|
28
|
+
* // :host ::slotted([name=sidebar]) { grid-column: 1; grid-row: 1; }
|
|
29
|
+
* // :host ::slotted([name=main]) { grid-column: 2; grid-row: 1; }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare function create_css_grid_layout(layout: Layout, round?: boolean, overlay?: [string, string]): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Layout } from "./
|
|
1
|
+
import type { Layout } from "./types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Inserts a new child panel into the layout tree at a specified location.
|
|
4
4
|
* Creates a split panel if necessary and redistributes sizes equally among all
|
|
@@ -10,6 +10,7 @@ import type { Layout } from "./layout_config.ts";
|
|
|
10
10
|
* at root level.
|
|
11
11
|
* @param orientation - Orientation for newly created split panels. Defaults to
|
|
12
12
|
* "horizontal".
|
|
13
|
+
* @param is_edge - If true, create the split at the parent level.
|
|
13
14
|
* @returns A new layout tree with the child inserted (original is not mutated).
|
|
14
15
|
*/
|
|
15
|
-
export declare function insert_child(panel: Layout, child: string, path: number[], orientation?: "horizontal" | "vertical"
|
|
16
|
+
export declare function insert_child(panel: Layout, child: string, path: number[], orientation?: "horizontal" | "vertical"): Layout;
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The percentage of the maximum resize distance that will be clamped.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export declare const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;
|
|
6
|
-
/**
|
|
7
|
-
* Threshold from panel edge that is considered a split vs drop action.
|
|
8
|
-
*/
|
|
9
|
-
export declare const SPLIT_EDGE_TOLERANCE = 0.25;
|
|
10
|
-
/**
|
|
11
|
-
* Tolerance threshold for considering two grid track positions as identical.
|
|
12
|
-
*
|
|
13
|
-
* When collecting and deduplicating track positions, any positions closer than
|
|
14
|
-
* this value are treated as the same position to avoid redundant grid tracks.
|
|
15
|
-
*/
|
|
16
|
-
export declare const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;
|
|
17
|
-
/**
|
|
18
|
-
* The overlay default behavior.
|
|
19
|
-
*/
|
|
20
|
-
export declare const OVERLAY_DEFAULT: OverlayMode;
|
|
21
1
|
/**
|
|
22
2
|
* The overlay behavior type.
|
|
23
3
|
*/
|
|
24
|
-
export type OverlayMode = "grid" | "absolute"
|
|
4
|
+
export type OverlayMode = "grid" | "absolute";
|
|
25
5
|
/**
|
|
26
6
|
* The representation of a CSS grid, in JSON form.
|
|
27
7
|
*/
|
|
@@ -45,6 +25,11 @@ export interface ViewWindow {
|
|
|
45
25
|
* Child panels are arranged either horizontally (side by side) or vertically
|
|
46
26
|
* (stacked), via the `orientation` property `"horizzontal"` and `"vertical"`
|
|
47
27
|
* (respectively).
|
|
28
|
+
*
|
|
29
|
+
* While the type structure of `SplitLayout` allows nesting levels with the same
|
|
30
|
+
* `orientation`, calling `RegularLayout.restore` with such a `Layout` will be
|
|
31
|
+
* flattened to the equivalent layout with every child guaranteed to have the
|
|
32
|
+
* opposite `orientation` as its parent.
|
|
48
33
|
*/
|
|
49
34
|
export interface SplitLayout {
|
|
50
35
|
type: "split-panel";
|
|
@@ -80,23 +65,16 @@ export interface LayoutDivider {
|
|
|
80
65
|
export interface LayoutPath<T = undefined> {
|
|
81
66
|
type: "layout-path";
|
|
82
67
|
slot: string;
|
|
83
|
-
panel: TabLayout;
|
|
84
68
|
path: number[];
|
|
85
69
|
view_window: ViewWindow;
|
|
70
|
+
column: number;
|
|
71
|
+
row: number;
|
|
86
72
|
column_offset: number;
|
|
87
73
|
row_offset: number;
|
|
88
74
|
orientation: Orientation;
|
|
89
75
|
is_edge: boolean;
|
|
90
|
-
|
|
76
|
+
layout: T;
|
|
91
77
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Recursively iterates over all child panel names in the layout tree, yielding
|
|
94
|
-
* panel names in depth-first order.
|
|
95
|
-
*
|
|
96
|
-
* @param panel - The layout tree to iterate over
|
|
97
|
-
* @returns Generator yielding child panel names
|
|
98
|
-
*/
|
|
99
|
-
export declare function iter_panel_children(panel: Layout): Generator<string>;
|
|
100
78
|
/**
|
|
101
79
|
* An empty `Layout` with no panels.
|
|
102
80
|
*/
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```html
|
|
19
19
|
* <regular-layout>
|
|
20
|
-
* <regular-layout-frame
|
|
20
|
+
* <regular-layout-frame name="panel-1">
|
|
21
21
|
* <!-- Panel content here -->
|
|
22
22
|
* </regular-layout-frame>
|
|
23
23
|
* </regular-layout>
|
|
@@ -34,9 +34,9 @@ export declare class RegularLayoutFrame extends HTMLElement {
|
|
|
34
34
|
constructor();
|
|
35
35
|
connectedCallback(): void;
|
|
36
36
|
disconnectedCallback(): void;
|
|
37
|
-
private drawTabs;
|
|
38
37
|
private onPointerDown;
|
|
39
38
|
private onPointerMove;
|
|
40
39
|
private onPointerUp;
|
|
41
40
|
private onPointerLost;
|
|
41
|
+
private drawTabs;
|
|
42
42
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TabLayout } from "./layout/types.ts";
|
|
2
|
+
import type { RegularLayout } from "./regular-layout.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A custom HTML element representing an individual tab in a tab panel.
|
|
5
|
+
*
|
|
6
|
+
* This element manages the visual representation and interactions for a single tab,
|
|
7
|
+
* including selection state, close functionality, and content display.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RegularLayoutTab extends HTMLElement {
|
|
10
|
+
private _layout?;
|
|
11
|
+
private _tab_panel?;
|
|
12
|
+
private _index?;
|
|
13
|
+
/**
|
|
14
|
+
* Populates or updates the tab with layout information.
|
|
15
|
+
*
|
|
16
|
+
* This method initializes the tab's content and event listeners on first call,
|
|
17
|
+
* and efficiently updates only the changed properties on subsequent calls.
|
|
18
|
+
*
|
|
19
|
+
* @param layout - The parent RegularLayout instance managing this tab.
|
|
20
|
+
* @param tab_panel - The tab panel layout containing this tab.
|
|
21
|
+
* @param index - The index of this tab within the tab panel.
|
|
22
|
+
*/
|
|
23
|
+
populate: (layout: RegularLayout, tab_panel: TabLayout, index: number) => void;
|
|
24
|
+
private onTabClose;
|
|
25
|
+
private onTabClick;
|
|
26
|
+
}
|
package/dist/regular-layout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LayoutPath, Layout, TabLayout } from "./
|
|
1
|
+
import type { LayoutPath, Layout, TabLayout, OverlayMode, Orientation } from "./layout/types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* A Web Component that provides a resizable panel layout system.
|
|
4
4
|
* Panels are arranged using CSS Grid and can be resized by dragging dividers.
|
|
@@ -8,8 +8,8 @@ import type { LayoutPath, Layout, TabLayout } from "./common/layout_config.ts";
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```html
|
|
10
10
|
* <regular-layout>
|
|
11
|
-
* <div
|
|
12
|
-
* <div
|
|
11
|
+
* <div name="sidebar">Sidebar content</div>
|
|
12
|
+
* <div name="main">Main content</div>
|
|
13
13
|
* </regular-layout>
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
@@ -36,58 +36,79 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
36
36
|
private _shadowRoot;
|
|
37
37
|
private _panel;
|
|
38
38
|
private _stylesheet;
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
39
|
+
private _cursor_stylesheet;
|
|
40
|
+
private _drag_target?;
|
|
41
|
+
private _cursor_override;
|
|
42
|
+
private _dimensions?;
|
|
42
43
|
constructor();
|
|
43
44
|
connectedCallback(): void;
|
|
44
45
|
disconnectedCallback(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Determines which panel is at a given screen coordinate.
|
|
48
|
+
*
|
|
49
|
+
* @param column - X coordinate in screen pixels.
|
|
50
|
+
* @param row - Y coordinate in screen pixels.
|
|
51
|
+
* @returns Panel information if a panel is at that position, null otherwise.
|
|
52
|
+
*/
|
|
53
|
+
calculateIntersect: (x: number, y: number, check_dividers?: boolean) => LayoutPath<Layout> | null;
|
|
45
54
|
/**
|
|
46
55
|
* Sets the visual overlay state during drag-and-drop operations.
|
|
47
56
|
* Displays a preview of where a panel would be placed at the given coordinates.
|
|
48
57
|
*
|
|
49
58
|
* @param x - X coordinate in screen pixels.
|
|
50
59
|
* @param y - Y coordinate in screen pixels.
|
|
51
|
-
* @param
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
60
|
+
* @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)
|
|
61
|
+
* which points to the drag element in the current layout.
|
|
62
|
+
* @param className - The CSS class name to use for the overlay panel
|
|
63
|
+
* (defaults to "overlay").
|
|
64
|
+
* @param mode - Overlay rendering mode: "grid" uses CSS grid to position
|
|
65
|
+
* the target, "absolute" positions the panel absolutely. Defaults to
|
|
66
|
+
* "absolute".
|
|
55
67
|
*/
|
|
56
|
-
setOverlayState
|
|
68
|
+
setOverlayState: (x: number, y: number, { slot }: LayoutPath<unknown>, className?: string, mode?: OverlayMode) => void;
|
|
57
69
|
/**
|
|
58
70
|
* Clears the overlay state and commits the panel placement.
|
|
59
71
|
*
|
|
60
72
|
* @param x - X coordinate in screen pixels.
|
|
61
73
|
* @param y - Y coordinate in screen pixels.
|
|
62
|
-
* @param
|
|
74
|
+
* @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)
|
|
75
|
+
* which points to the drag element in the current layout.
|
|
76
|
+
* @param className - The CSS class name to use for the overlay panel
|
|
77
|
+
* (defaults to "overlay").
|
|
63
78
|
* @param mode - Overlay rendering mode that was used, must match the mode
|
|
64
|
-
*
|
|
79
|
+
* passed to `setOverlayState`. Defaults to "absolute".
|
|
65
80
|
*/
|
|
66
|
-
clearOverlayState
|
|
81
|
+
clearOverlayState: (x: number, y: number, drag_target: LayoutPath<Layout>, className?: string) => void;
|
|
67
82
|
/**
|
|
68
83
|
* Inserts a new panel into the layout at a specified path.
|
|
69
84
|
*
|
|
70
85
|
* @param name - Unique identifier for the new panel.
|
|
71
86
|
* @param path - Index path defining where to insert.
|
|
87
|
+
* @param split - Force a split in the layout at the end of `path`
|
|
88
|
+
* regardless if there is a leaf at this position or not. Optionally,
|
|
89
|
+
*. `split` may be your preferred `Orientation`, which will be used by
|
|
90
|
+
* the new `SplitPanel` _if_ there is an option of orientation (e.g. if
|
|
91
|
+
* the layout had no pre-existing `SplitPanel`)
|
|
72
92
|
*/
|
|
73
|
-
insertPanel(name: string, path?: number[])
|
|
93
|
+
insertPanel: (name: string, path?: number[], split?: boolean | Orientation) => void;
|
|
74
94
|
/**
|
|
75
95
|
* Removes a panel from the layout by name.
|
|
76
96
|
*
|
|
77
97
|
* @param name - Name of the panel to remove
|
|
78
98
|
*/
|
|
79
|
-
removePanel(name: string)
|
|
80
|
-
getPanel(name: string, layout?: Layout): TabLayout | null;
|
|
99
|
+
removePanel: (name: string) => void;
|
|
81
100
|
/**
|
|
82
|
-
*
|
|
83
|
-
* Useful for drag-and-drop operations or custom interactions.
|
|
101
|
+
* Retrieves a panel by name from the layout tree.
|
|
84
102
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @returns
|
|
103
|
+
* @param name - Name of the panel to find.
|
|
104
|
+
* @param layout - Optional layout tree to search in (defaults to current layout).
|
|
105
|
+
* @returns The TabLayout containing the panel if found, null otherwise.
|
|
106
|
+
*/
|
|
107
|
+
getPanel: (name: string, layout?: Layout) => TabLayout | null;
|
|
108
|
+
/**
|
|
109
|
+
* Clears the entire layout, unslotting all panels.
|
|
88
110
|
*/
|
|
89
|
-
|
|
90
|
-
clear(): void;
|
|
111
|
+
clear: () => void;
|
|
91
112
|
/**
|
|
92
113
|
* Restores the layout from a saved state.
|
|
93
114
|
*
|
|
@@ -100,7 +121,7 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
100
121
|
* layout.restore(savedState);
|
|
101
122
|
* ```
|
|
102
123
|
*/
|
|
103
|
-
restore(layout: Layout, _is_flattened?: boolean)
|
|
124
|
+
restore: (layout: Layout, _is_flattened?: boolean) => void;
|
|
104
125
|
/**
|
|
105
126
|
* Serializes the current layout state, which can be restored via `restore`.
|
|
106
127
|
*
|
|
@@ -113,8 +134,21 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
113
134
|
* localStorage.setItem('layout', JSON.stringify(state));
|
|
114
135
|
* ```
|
|
115
136
|
*/
|
|
116
|
-
save()
|
|
117
|
-
|
|
137
|
+
save: () => Layout;
|
|
138
|
+
/**
|
|
139
|
+
* Converts screen coordinates to relative layout coordinates.
|
|
140
|
+
*
|
|
141
|
+
* Transforms absolute pixel positions into normalized coordinates (0-1 range)
|
|
142
|
+
* relative to the layout's bounding box.
|
|
143
|
+
*
|
|
144
|
+
* @param clientX - X coordinate in screen pixels (client space).
|
|
145
|
+
* @param clientY - Y coordinate in screen pixels (client space).
|
|
146
|
+
* @returns A tuple containing:
|
|
147
|
+
* - col: Normalized X coordinate (0 = left edge, 1 = right edge)
|
|
148
|
+
* - row: Normalized Y coordinate (0 = top edge, 1 = bottom edge)
|
|
149
|
+
* - box: The layout element's bounding rectangle
|
|
150
|
+
*/
|
|
151
|
+
relativeCoordinates: (clientX: number, clientY: number, recalculate_bounds?: boolean) => [number, number, DOMRect, CSSStyleDeclaration];
|
|
118
152
|
private onPointerDown;
|
|
119
153
|
private onPointerMove;
|
|
120
154
|
private onPointerUp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "regular-layout",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A regular CSS `grid` container",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,17 +9,20 @@
|
|
|
9
9
|
"url": "https://github.com/texodus/regular-layout"
|
|
10
10
|
},
|
|
11
11
|
"browser": "dist/index.js",
|
|
12
|
+
"main": "dist/index.js",
|
|
12
13
|
"type": "module",
|
|
13
14
|
"files": [
|
|
14
15
|
"dist/**/*",
|
|
15
|
-
"src/**/*"
|
|
16
|
+
"src/**/*",
|
|
17
|
+
"themes/**/*"
|
|
16
18
|
],
|
|
17
19
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
-
"build:watch": "
|
|
20
|
+
"build": "tsx build.ts",
|
|
21
|
+
"build:watch": "tsx build.ts --watch",
|
|
20
22
|
"clean": "rm -rf dist",
|
|
21
23
|
"test": "playwright test",
|
|
22
|
-
"example": "
|
|
24
|
+
"example": "tsx serve.ts",
|
|
25
|
+
"deploy": "tsx deploy.ts",
|
|
23
26
|
"lint": "biome lint src tests",
|
|
24
27
|
"format": "biome format --write src tests",
|
|
25
28
|
"check": "biome check --write src tests"
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
"@playwright/test": "^1.57.0",
|
|
30
33
|
"@types/node": "^22.10.5",
|
|
31
34
|
"esbuild": "^0.27.2",
|
|
32
|
-
"
|
|
35
|
+
"tsx": "^4.21.0",
|
|
33
36
|
"typescript": "^5.9.3"
|
|
34
37
|
}
|
|
35
38
|
}
|
package/src/extensions.ts
CHANGED
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
import { RegularLayout } from "./regular-layout.ts";
|
|
13
13
|
import { RegularLayoutFrame } from "./regular-layout-frame.ts";
|
|
14
|
-
import { Layout } from "./
|
|
14
|
+
import type { Layout } from "./layout/types.ts";
|
|
15
|
+
import { RegularLayoutTab } from "./regular-layout-tab.ts";
|
|
15
16
|
|
|
16
17
|
customElements.define("regular-layout", RegularLayout);
|
|
17
18
|
customElements.define("regular-layout-frame", RegularLayoutFrame);
|
|
19
|
+
customElements.define("regular-layout-tab", RegularLayoutTab);
|
|
18
20
|
|
|
19
21
|
declare global {
|
|
20
22
|
interface Document {
|
|
@@ -28,9 +30,15 @@ declare global {
|
|
|
28
30
|
options?: ElementCreationOptions,
|
|
29
31
|
): RegularLayoutFrame;
|
|
30
32
|
|
|
33
|
+
createElement(
|
|
34
|
+
tagName: "regular-layout-tab",
|
|
35
|
+
options?: ElementCreationOptions,
|
|
36
|
+
): RegularLayoutTab;
|
|
37
|
+
|
|
31
38
|
querySelector<E extends Element = Element>(selectors: string): E | null;
|
|
32
39
|
querySelector(selectors: "regular-layout"): RegularLayout | null;
|
|
33
40
|
querySelector(selectors: "regular-layout-frame"): RegularLayoutFrame | null;
|
|
41
|
+
querySelector(selectors: "regular-layout-tab"): RegularLayoutTab | null;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
interface CustomElementRegistry {
|
|
@@ -45,20 +53,22 @@ declare global {
|
|
|
45
53
|
options?: { signal: AbortSignal },
|
|
46
54
|
): void;
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
detail: Layout;
|
|
54
|
-
}
|
|
56
|
+
addEventListener(
|
|
57
|
+
name: "regular-layout-before-update",
|
|
58
|
+
cb: (e: RegularLayoutEvent) => void,
|
|
59
|
+
options?: { signal: AbortSignal },
|
|
60
|
+
): void;
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
options?: { signal: AbortSignal },
|
|
61
|
-
): void;
|
|
62
|
+
removeEventListener(
|
|
63
|
+
name: "regular-layout-update",
|
|
64
|
+
cb: (e: RegularLayoutEvent) => void,
|
|
65
|
+
): void;
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
removeEventListener(
|
|
68
|
+
name: "regular-layout-before-update",
|
|
69
|
+
cb: (e: RegularLayoutEvent) => void,
|
|
70
|
+
): void;
|
|
71
|
+
}
|
|
64
72
|
}
|
|
73
|
+
|
|
74
|
+
export type RegularLayoutEvent = CustomEvent<Layout>;
|
package/src/index.ts
CHANGED
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
*
|
|
20
20
|
* ```html
|
|
21
21
|
* <regular-layout>
|
|
22
|
-
* <regular-layout-frame
|
|
23
|
-
* <regular-layout-frame
|
|
22
|
+
* <regular-layout-frame name="sidebar">Sidebar content</regular-layout-frame>
|
|
23
|
+
* <regular-layout-frame name="main">Main content</regular-layout-frame>
|
|
24
24
|
* </regular-layout>
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
@@ -59,11 +59,7 @@
|
|
|
59
59
|
* @packageDocumentation
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
|
-
export type
|
|
63
|
-
LayoutPath,
|
|
64
|
-
Layout,
|
|
65
|
-
LayoutDivider,
|
|
66
|
-
} from "./common/layout_config.ts";
|
|
62
|
+
export type * from "./layout/types.ts";
|
|
67
63
|
|
|
68
64
|
export { RegularLayout } from "./regular-layout.ts";
|
|
69
65
|
export { RegularLayoutFrame } from "./regular-layout-frame.ts";
|