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.
- package/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/extensions.d.ts +5 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -10
- package/dist/index.js.map +4 -4
- package/dist/{common → layout}/calculate_edge.d.ts +3 -2
- package/dist/{common → layout}/calculate_intersect.d.ts +13 -9
- package/dist/layout/constants.d.ts +81 -0
- package/dist/{common → layout}/flatten.d.ts +1 -1
- package/dist/{common → layout}/generate_grid.d.ts +5 -4
- 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 +2 -2
- package/dist/{common → layout}/remove_child.d.ts +1 -1
- package/dist/{common/layout_config.d.ts → layout/types.d.ts} +6 -10
- package/dist/regular-layout-frame.d.ts +1 -4
- package/dist/regular-layout-tab.d.ts +26 -0
- package/dist/regular-layout.d.ts +37 -18
- package/package.json +9 -7
- package/src/extensions.ts +10 -4
- package/src/index.ts +3 -7
- package/src/layout/calculate_edge.ts +217 -0
- package/src/{common → layout}/calculate_intersect.ts +61 -101
- package/src/layout/constants.ts +119 -0
- package/src/{common → layout}/flatten.ts +1 -1
- package/src/{common → layout}/generate_grid.ts +120 -106
- package/src/{common → layout}/generate_overlay.ts +26 -12
- package/src/{common → layout}/insert_child.ts +105 -51
- package/src/{common → layout}/redistribute_panel_sizes.ts +11 -4
- package/src/{common → layout}/remove_child.ts +2 -2
- package/src/{common/layout_config.ts → layout/types.ts} +7 -19
- package/src/regular-layout-frame.ts +40 -74
- package/src/regular-layout-tab.ts +103 -0
- package/src/regular-layout.ts +260 -148
- 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 +130 -0
- package/dist/common/constants.d.ts +0 -29
- package/dist/common/generate_overlay.d.ts +0 -2
- package/src/common/calculate_edge.ts +0 -104
- package/src/common/constants.ts +0 -46
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Physics } from "./constants";
|
|
2
|
+
import type { Layout, LayoutPath } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* Calculates an insertion point (which may involve splitting a single
|
|
4
5
|
* `"child-panel"` into a new `"split-panel"`), based on the cursor position.
|
|
@@ -12,4 +13,4 @@ import type { Layout, LayoutPath } from "./layout_config";
|
|
|
12
13
|
* @returns A new `LayoutPath` reflecting the updated (maybe) `"split-panel"`,
|
|
13
14
|
* which is enough to draw the overlay.
|
|
14
15
|
*/
|
|
15
|
-
export declare function calculate_edge(col: number, row: number, panel: Layout, slot: string, drop_target: LayoutPath): LayoutPath;
|
|
16
|
+
export declare function calculate_edge(col: number, row: number, panel: Layout, slot: string, drop_target: LayoutPath, box?: DOMRect, physics?: Physics): LayoutPath;
|
|
@@ -1,18 +1,22 @@
|
|
|
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
|
-
|
|
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?: {
|
|
16
|
+
rect: DOMRect;
|
|
17
|
+
size: number;
|
|
18
|
+
}): LayoutPath | null | LayoutDivider;
|
|
19
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: {
|
|
20
|
+
rect: DOMRect;
|
|
21
|
+
size: number;
|
|
22
|
+
} | null): LayoutPath | null | LayoutDivider;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { OverlayMode } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Instance-specific constants which define the behavior and rendering details
|
|
4
|
+
* of a `<regular-layout>`.
|
|
5
|
+
*/
|
|
6
|
+
export interface Physics {
|
|
7
|
+
/**
|
|
8
|
+
* The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.
|
|
9
|
+
* `"regular-layout-before-update"`.
|
|
10
|
+
*/
|
|
11
|
+
CUSTOM_EVENT_NAME_PREFIX: string;
|
|
12
|
+
/**
|
|
13
|
+
* The attribute name to use for matching child `Element`s to grid
|
|
14
|
+
* positions.
|
|
15
|
+
*/
|
|
16
|
+
CHILD_ATTRIBUTE_NAME: string;
|
|
17
|
+
/**
|
|
18
|
+
* The minimum number of pixels the mouse must move to be considered a drag.
|
|
19
|
+
*/
|
|
20
|
+
MIN_DRAG_DISTANCE: number;
|
|
21
|
+
/**
|
|
22
|
+
* Should floating point pixel calculations be rounded. Useful for testing.
|
|
23
|
+
*/
|
|
24
|
+
SHOULD_ROUND: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Class name to use for child elements in overlay position (dragging).
|
|
27
|
+
*/
|
|
28
|
+
OVERLAY_CLASSNAME: string;
|
|
29
|
+
/**
|
|
30
|
+
* The percentage of the maximum resize distance that will be clamped.
|
|
31
|
+
*/
|
|
32
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: number;
|
|
33
|
+
/**
|
|
34
|
+
* Threshold from panel edge that is considered a split vs drop action.
|
|
35
|
+
*/
|
|
36
|
+
SPLIT_EDGE_TOLERANCE: number;
|
|
37
|
+
/**
|
|
38
|
+
* Threshold from _container_ edge that is considered a split action on the root
|
|
39
|
+
* node.
|
|
40
|
+
*/
|
|
41
|
+
SPLIT_ROOT_EDGE_TOLERANCE: number;
|
|
42
|
+
/**
|
|
43
|
+
* Tolerance threshold for considering two grid track positions as identical.
|
|
44
|
+
*
|
|
45
|
+
* When collecting and deduplicating track positions, any positions closer than
|
|
46
|
+
* this value are treated as the same position to avoid redundant grid tracks.
|
|
47
|
+
*/
|
|
48
|
+
GRID_TRACK_COLLAPSE_TOLERANCE: number;
|
|
49
|
+
/**
|
|
50
|
+
* The overlay default behavior.
|
|
51
|
+
*/
|
|
52
|
+
OVERLAY_DEFAULT: OverlayMode;
|
|
53
|
+
/**
|
|
54
|
+
* Width of split panel dividers in pixels (for hit-test purposes).
|
|
55
|
+
*/
|
|
56
|
+
GRID_DIVIDER_SIZE: number;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the grid should trigger column resize if the grid itself is not
|
|
59
|
+
* the `event.target`.
|
|
60
|
+
*/
|
|
61
|
+
GRID_DIVIDER_CHECK_TARGET: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Like `GlobalPhysics`, but suitable for partial definition for incremental
|
|
65
|
+
* updates.
|
|
66
|
+
*/
|
|
67
|
+
export interface PhysicsUpdate {
|
|
68
|
+
CUSTOM_EVENT_NAME_PREFIX?: string;
|
|
69
|
+
CHILD_ATTRIBUTE_NAME?: string;
|
|
70
|
+
MIN_DRAG_DISTANCE?: number;
|
|
71
|
+
SHOULD_ROUND?: boolean;
|
|
72
|
+
OVERLAY_CLASSNAME?: string;
|
|
73
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD?: number;
|
|
74
|
+
SPLIT_EDGE_TOLERANCE?: number;
|
|
75
|
+
SPLIT_ROOT_EDGE_TOLERANCE?: number;
|
|
76
|
+
GRID_TRACK_COLLAPSE_TOLERANCE?: number;
|
|
77
|
+
OVERLAY_DEFAULT?: OverlayMode;
|
|
78
|
+
GRID_DIVIDER_SIZE?: number;
|
|
79
|
+
GRID_DIVIDER_CHECK_TARGET?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare const DEFAULT_PHYSICS: Physics;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Physics } from "./constants.ts";
|
|
2
|
+
import type { Layout } from "./types.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Generates CSS Grid styles to render a layout tree.
|
|
4
5
|
* Creates grid-template-rows, grid-template-columns, and positioning rules for
|
|
@@ -25,8 +26,8 @@ import type { Layout } from "./layout_config.ts";
|
|
|
25
26
|
* const css = create_css_grid_layout(layout);
|
|
26
27
|
* // Returns CSS like:
|
|
27
28
|
* // :host { display: grid; grid-template-columns: 25% 75%; ... }
|
|
28
|
-
* // :host ::slotted([
|
|
29
|
-
* // :host ::slotted([
|
|
29
|
+
* // :host ::slotted([name=sidebar]) { grid-column: 1; grid-row: 1; }
|
|
30
|
+
* // :host ::slotted([name=main]) { grid-column: 2; grid-row: 1; }
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare function create_css_grid_layout(layout: Layout,
|
|
33
|
+
export declare function create_css_grid_layout(layout: Layout, overlay?: [string, string], physics?: Physics): 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,4 +1,4 @@
|
|
|
1
|
-
import type { Layout } from "./
|
|
1
|
+
import type { Layout } from "./types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Adjusts panel sizes during a drag operation on a divider.
|
|
4
4
|
*
|
|
@@ -16,4 +16,4 @@ import type { Layout } from "./layout_config.ts";
|
|
|
16
16
|
* @returns A new layout tree with updated sizes (original is not mutated).
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function redistribute_panel_sizes(panel: Layout, path: number[], delta: number): Layout;
|
|
19
|
+
export declare function redistribute_panel_sizes(panel: Layout, path: number[], delta: number, physics?: import("./constants.ts").Physics): Layout;
|
|
@@ -25,6 +25,11 @@ export interface ViewWindow {
|
|
|
25
25
|
* Child panels are arranged either horizontally (side by side) or vertically
|
|
26
26
|
* (stacked), via the `orientation` property `"horizzontal"` and `"vertical"`
|
|
27
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.
|
|
28
33
|
*/
|
|
29
34
|
export interface SplitLayout {
|
|
30
35
|
type: "split-panel";
|
|
@@ -60,7 +65,6 @@ export interface LayoutDivider {
|
|
|
60
65
|
export interface LayoutPath<T = undefined> {
|
|
61
66
|
type: "layout-path";
|
|
62
67
|
slot: string;
|
|
63
|
-
panel: TabLayout;
|
|
64
68
|
path: number[];
|
|
65
69
|
view_window: ViewWindow;
|
|
66
70
|
column: number;
|
|
@@ -69,16 +73,8 @@ export interface LayoutPath<T = undefined> {
|
|
|
69
73
|
row_offset: number;
|
|
70
74
|
orientation: Orientation;
|
|
71
75
|
is_edge: boolean;
|
|
72
|
-
|
|
76
|
+
layout: T;
|
|
73
77
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Recursively iterates over all child panel names in the layout tree, yielding
|
|
76
|
-
* panel names in depth-first order.
|
|
77
|
-
*
|
|
78
|
-
* @param panel - The layout tree to iterate over
|
|
79
|
-
* @returns Generator yielding child panel names
|
|
80
|
-
*/
|
|
81
|
-
export declare function iter_panel_children(panel: Layout): Generator<string>;
|
|
82
78
|
/**
|
|
83
79
|
* An empty `Layout` with no panels.
|
|
84
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>
|
|
@@ -31,7 +31,6 @@ export declare class RegularLayoutFrame extends HTMLElement {
|
|
|
31
31
|
private _drag_state;
|
|
32
32
|
private _drag_moved;
|
|
33
33
|
private _tab_to_index_map;
|
|
34
|
-
private _tab_panel_state;
|
|
35
34
|
constructor();
|
|
36
35
|
connectedCallback(): void;
|
|
37
36
|
disconnectedCallback(): void;
|
|
@@ -40,6 +39,4 @@ export declare class RegularLayoutFrame extends HTMLElement {
|
|
|
40
39
|
private onPointerUp;
|
|
41
40
|
private onPointerLost;
|
|
42
41
|
private drawTabs;
|
|
43
|
-
private createTab;
|
|
44
|
-
private onTabClick;
|
|
45
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,5 @@
|
|
|
1
|
-
import type { LayoutPath, Layout, TabLayout, OverlayMode } from "./
|
|
1
|
+
import type { LayoutPath, Layout, TabLayout, OverlayMode, Orientation } from "./layout/types.ts";
|
|
2
|
+
import { type PhysicsUpdate, type Physics } from "./layout/constants.ts";
|
|
2
3
|
/**
|
|
3
4
|
* A Web Component that provides a resizable panel layout system.
|
|
4
5
|
* Panels are arranged using CSS Grid and can be resized by dragging dividers.
|
|
@@ -8,8 +9,8 @@ import type { LayoutPath, Layout, TabLayout, OverlayMode } from "./common/layout
|
|
|
8
9
|
* @example
|
|
9
10
|
* ```html
|
|
10
11
|
* <regular-layout>
|
|
11
|
-
* <div
|
|
12
|
-
* <div
|
|
12
|
+
* <div name="sidebar">Sidebar content</div>
|
|
13
|
+
* <div name="main">Main content</div>
|
|
13
14
|
* </regular-layout>
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
@@ -36,12 +37,22 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
36
37
|
private _shadowRoot;
|
|
37
38
|
private _panel;
|
|
38
39
|
private _stylesheet;
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
40
|
+
private _cursor_stylesheet;
|
|
41
|
+
private _drag_target?;
|
|
42
|
+
private _cursor_override;
|
|
43
|
+
private _dimensions?;
|
|
44
|
+
private _physics;
|
|
42
45
|
constructor();
|
|
43
46
|
connectedCallback(): void;
|
|
44
47
|
disconnectedCallback(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Determines which panel is at a given screen coordinate.
|
|
50
|
+
*
|
|
51
|
+
* @param column - X coordinate in screen pixels.
|
|
52
|
+
* @param row - Y coordinate in screen pixels.
|
|
53
|
+
* @returns Panel information if a panel is at that position, null otherwise.
|
|
54
|
+
*/
|
|
55
|
+
calculateIntersect: (x: number, y: number, check_dividers?: boolean) => LayoutPath<Layout> | null;
|
|
45
56
|
/**
|
|
46
57
|
* Sets the visual overlay state during drag-and-drop operations.
|
|
47
58
|
* Displays a preview of where a panel would be placed at the given coordinates.
|
|
@@ -69,14 +80,19 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
69
80
|
* @param mode - Overlay rendering mode that was used, must match the mode
|
|
70
81
|
* passed to `setOverlayState`. Defaults to "absolute".
|
|
71
82
|
*/
|
|
72
|
-
clearOverlayState: (x: number, y: number, drag_target: LayoutPath<
|
|
83
|
+
clearOverlayState: (x: number, y: number, drag_target: LayoutPath<Layout>, className?: string) => void;
|
|
73
84
|
/**
|
|
74
85
|
* Inserts a new panel into the layout at a specified path.
|
|
75
86
|
*
|
|
76
87
|
* @param name - Unique identifier for the new panel.
|
|
77
88
|
* @param path - Index path defining where to insert.
|
|
89
|
+
* @param split - Force a split in the layout at the end of `path`
|
|
90
|
+
* regardless if there is a leaf at this position or not. Optionally,
|
|
91
|
+
*. `split` may be your preferred `Orientation`, which will be used by
|
|
92
|
+
* the new `SplitPanel` _if_ there is an option of orientation (e.g. if
|
|
93
|
+
* the layout had no pre-existing `SplitPanel`)
|
|
78
94
|
*/
|
|
79
|
-
insertPanel: (name: string, path?: number[]) => void;
|
|
95
|
+
insertPanel: (name: string, path?: number[], split?: boolean | Orientation) => void;
|
|
80
96
|
/**
|
|
81
97
|
* Removes a panel from the layout by name.
|
|
82
98
|
*
|
|
@@ -91,14 +107,6 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
91
107
|
* @returns The TabLayout containing the panel if found, null otherwise.
|
|
92
108
|
*/
|
|
93
109
|
getPanel: (name: string, layout?: Layout) => TabLayout | null;
|
|
94
|
-
/**
|
|
95
|
-
* Determines which panel is at a given screen coordinate.
|
|
96
|
-
*
|
|
97
|
-
* @param column - X coordinate in screen pixels.
|
|
98
|
-
* @param row - Y coordinate in screen pixels.
|
|
99
|
-
* @returns Panel information if a panel is at that position, null otherwise.
|
|
100
|
-
*/
|
|
101
|
-
calculateIntersect: (x: number, y: number, check_dividers?: boolean) => LayoutPath<DOMRect> | null;
|
|
102
110
|
/**
|
|
103
111
|
* Clears the entire layout, unslotting all panels.
|
|
104
112
|
*/
|
|
@@ -129,6 +137,18 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
129
137
|
* ```
|
|
130
138
|
*/
|
|
131
139
|
save: () => Layout;
|
|
140
|
+
/**
|
|
141
|
+
* Override this instance's global constants.
|
|
142
|
+
*
|
|
143
|
+
* @param physics
|
|
144
|
+
*/
|
|
145
|
+
restorePhysics(physics: PhysicsUpdate): void;
|
|
146
|
+
/**
|
|
147
|
+
* Get this instance's constants.
|
|
148
|
+
*
|
|
149
|
+
* @returns The current constants
|
|
150
|
+
*/
|
|
151
|
+
savePhysics(): Physics;
|
|
132
152
|
/**
|
|
133
153
|
* Converts screen coordinates to relative layout coordinates.
|
|
134
154
|
*
|
|
@@ -142,8 +162,7 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
142
162
|
* - row: Normalized Y coordinate (0 = top edge, 1 = bottom edge)
|
|
143
163
|
* - box: The layout element's bounding rectangle
|
|
144
164
|
*/
|
|
145
|
-
relativeCoordinates: (clientX: number, clientY: number) => [number, number, DOMRect];
|
|
146
|
-
private updateSlots;
|
|
165
|
+
relativeCoordinates: (clientX: number, clientY: number, recalculate_bounds?: boolean) => [number, number, DOMRect, CSSStyleDeclaration];
|
|
147
166
|
private onPointerDown;
|
|
148
167
|
private onPointerMove;
|
|
149
168
|
private onPointerUp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "regular-layout",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A regular CSS `grid` container",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,18 +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": "
|
|
23
|
-
"deploy": "
|
|
24
|
+
"example": "tsx serve.ts",
|
|
25
|
+
"deploy": "tsx deploy.ts",
|
|
24
26
|
"lint": "biome lint src tests",
|
|
25
27
|
"format": "biome format --write src tests",
|
|
26
28
|
"check": "biome check --write src tests"
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
"@playwright/test": "^1.57.0",
|
|
31
33
|
"@types/node": "^22.10.5",
|
|
32
34
|
"esbuild": "^0.27.2",
|
|
33
|
-
"
|
|
35
|
+
"tsx": "^4.21.0",
|
|
34
36
|
"typescript": "^5.9.3"
|
|
35
37
|
}
|
|
36
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 type { 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 {
|
|
@@ -63,6 +71,4 @@ declare global {
|
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
export
|
|
67
|
-
detail: Layout;
|
|
68
|
-
}
|
|
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";
|