sliced-areas 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pavel Voronin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # sliced-areas
2
+
3
+ Blender-like “Areas” layout system as a Web Component with an optional Vue 3 wrapper.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install sliced-areas
9
+ ```
10
+
11
+ ## Web Component Setup
12
+
13
+ ```ts
14
+ import 'sliced-areas'
15
+ import 'sliced-areas/styles.css'
16
+ import type { AreasLayout, SlicedAreasElement } from 'sliced-areas'
17
+
18
+ const layout: AreasLayout = {
19
+ areas: [{ tag: 'viewport', rect: { left: 0, right: 1, top: 1, bottom: 0 } }],
20
+ }
21
+
22
+ const areas = document.querySelector('sliced-areas') as SlicedAreasElement
23
+ areas.setResolver((tag) => document.querySelector(`[data-area-tag="${tag}"]`))
24
+ areas.layout = layout
25
+ ```
26
+
27
+ ```html
28
+ <sliced-areas style="height: 100%;"></sliced-areas>
29
+ <div data-area-tag="viewport">Viewport content</div>
30
+ ```
31
+
32
+ ## Vue 3 Setup
33
+
34
+ ```ts
35
+ import { createApp } from 'vue'
36
+ import App from './App.vue'
37
+ import { SlicedAreasPlugin } from 'sliced-areas/vue'
38
+ import 'sliced-areas/styles.css'
39
+
40
+ const app = createApp(App)
41
+ app.use(SlicedAreasPlugin)
42
+ app.mount('#app')
43
+ ```
44
+
45
+ ```vue
46
+ <template>
47
+ <SlicedAreas
48
+ class="layout-root"
49
+ :layout="layout"
50
+ :resolver="resolveArea"
51
+ @layoutchange="onLayoutChange"
52
+ @cornerclick="onCornerClick"
53
+ />
54
+ </template>
55
+ ```
56
+
57
+ ## Layout Format
58
+
59
+ `AreasLayout` uses normalized coordinates (0..1) and tags for content lookup:
60
+
61
+ ```ts
62
+ type AreasLayout = {
63
+ areas: Array<{
64
+ tag: string
65
+ rect: { left: number; right: number; top: number; bottom: number }
66
+ }>
67
+ }
68
+ ```
69
+
70
+ - Area ids are internal and auto-generated; only tags are persistent.
71
+ - The layout always fills the component bounds.
72
+
73
+ ## Gestures and Operations
74
+
75
+ - Resize: drag splitters between areas.
76
+ - Move/Split/Join/Replace: drag an area corner into another area.
77
+ - Split orientation is inferred from drag direction.
78
+ - Swap: hold `Ctrl` while dragging an area into another.
79
+ - Maximize/Restore: use the API methods.
80
+
81
+ ## Events
82
+
83
+ - `sliced-areas:layoutchange` → `{ layout: AreasLayout }`
84
+ - `sliced-areas:cornerclick` → `{ areaId, corner, clientX, clientY }`
85
+
86
+ Vue emits `layoutchange` and `cornerclick` with the same payloads.
87
+
88
+ ## API (Element)
89
+
90
+ ```ts
91
+ element.layout: AreasLayout | null
92
+ element.setResolver(resolver: (tag: string) => HTMLElement | null | undefined): void
93
+ element.split(areaId, zone?, clientX?, clientY?): void
94
+ element.join(sourceAreaId, targetAreaId): void
95
+ element.replace(sourceAreaId, targetAreaId): void
96
+ element.swap(sourceAreaId, targetAreaId): void
97
+ element.move(sourceAreaId, targetAreaId, overlayRect, remainderRect): void
98
+ element.close(areaId): void
99
+ element.retag(areaId, tag): void
100
+ element.maximize(areaId): void
101
+ element.restore(): void
102
+ ```
103
+
104
+ ## Retagging from Area Content
105
+
106
+ Dispatch a bubbling event from inside an area node to update its tag:
107
+
108
+ ```ts
109
+ node.dispatchEvent(
110
+ new CustomEvent('sliced-areas:retag', { bubbles: true, detail: { tag: 'viewport' } }),
111
+ )
112
+ ```
@@ -0,0 +1,2 @@
1
+ export { SlicedAreasElement } from './sliced-areas';
2
+ export type { AreaId, AreaRect, AreaTag, AreasGraph, AreasLayout, GraphArea, GraphEdge, GraphVert, AreaResolver, } from './sliced-areas';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as SlicedAreasElement } from "./sliced-areas-WnMrbsZg.js";
2
+ export { SlicedAreasElement };