@singapore-editor/panes 0.1.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/README.md +30 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +564 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +46 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @singapore-editor/panes
|
|
2
|
+
|
|
3
|
+
Small DOM utility for resizable pane groups.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @singapore-editor/panes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { ResizablePaneGroup } from '@singapore-editor/panes'
|
|
15
|
+
import '@singapore-editor/panes/style.css'
|
|
16
|
+
|
|
17
|
+
const group = new ResizablePaneGroup(document.querySelector('#panes')!, {
|
|
18
|
+
orientation: 'horizontal',
|
|
19
|
+
panes: [
|
|
20
|
+
{ id: 'left', element: document.querySelector('#left')!, defaultSize: 40 },
|
|
21
|
+
{ id: 'right', element: document.querySelector('#right')!, defaultSize: 60 },
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Exports
|
|
27
|
+
|
|
28
|
+
- `ResizablePaneGroup` mounts accessible split handles and manages percentage layouts.
|
|
29
|
+
- `ResizablePaneGroupOptions`, `ResizablePaneLayout`, and related types describe pane and handle
|
|
30
|
+
configuration.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
export type ResizablePaneOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
export type ResizablePaneLayout = Readonly<Record<string, number>>;
|
|
4
|
+
export type ResizablePane = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly element: HTMLElement;
|
|
7
|
+
readonly defaultSize?: number;
|
|
8
|
+
readonly minSize?: number;
|
|
9
|
+
readonly maxSize?: number;
|
|
10
|
+
readonly disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type ResizablePaneHandleContext = {
|
|
13
|
+
readonly document: Document;
|
|
14
|
+
readonly groupId: string;
|
|
15
|
+
readonly handleId: string;
|
|
16
|
+
readonly index: number;
|
|
17
|
+
readonly beforePaneId: string;
|
|
18
|
+
readonly afterPaneId: string;
|
|
19
|
+
readonly orientation: ResizablePaneOrientation;
|
|
20
|
+
};
|
|
21
|
+
export type ResizablePaneHandleFactory = (context: ResizablePaneHandleContext) => HTMLElement;
|
|
22
|
+
export type ResizablePaneGroupOptions = {
|
|
23
|
+
readonly id?: string;
|
|
24
|
+
readonly orientation?: ResizablePaneOrientation;
|
|
25
|
+
readonly panes: readonly ResizablePane[];
|
|
26
|
+
readonly defaultLayout?: ResizablePaneLayout;
|
|
27
|
+
readonly createHandle?: ResizablePaneHandleFactory;
|
|
28
|
+
readonly onLayoutChange?: (layout: ResizablePaneLayout) => void;
|
|
29
|
+
readonly onLayoutChanged?: (layout: ResizablePaneLayout) => void;
|
|
30
|
+
readonly keyboardStep?: number;
|
|
31
|
+
readonly disabled?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare class ResizablePaneGroup {
|
|
34
|
+
private readonly container;
|
|
35
|
+
private readonly document;
|
|
36
|
+
private readonly groupId;
|
|
37
|
+
private readonly orientation;
|
|
38
|
+
private readonly keyboardStep;
|
|
39
|
+
private readonly disabled;
|
|
40
|
+
private readonly panes;
|
|
41
|
+
private readonly handles;
|
|
42
|
+
private readonly onDocumentPointerMove;
|
|
43
|
+
private readonly onDocumentPointerUp;
|
|
44
|
+
private readonly onLayoutChange?;
|
|
45
|
+
private readonly onLayoutChanged?;
|
|
46
|
+
private dragState;
|
|
47
|
+
private disposed;
|
|
48
|
+
private layout;
|
|
49
|
+
constructor(container: HTMLElement, options: ResizablePaneGroupOptions);
|
|
50
|
+
getLayout(): ResizablePaneLayout;
|
|
51
|
+
setLayout(layout: ResizablePaneLayout): ResizablePaneLayout;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
private mountPanesAndHandles;
|
|
54
|
+
private mountHandle;
|
|
55
|
+
private createMountedHandle;
|
|
56
|
+
private handlePointerDown;
|
|
57
|
+
private handleDocumentPointerMove;
|
|
58
|
+
private handleDocumentPointerUp;
|
|
59
|
+
private handleKeyDown;
|
|
60
|
+
private focusSiblingHandle;
|
|
61
|
+
private applyHandleDelta;
|
|
62
|
+
private applyLayout;
|
|
63
|
+
private updateHandles;
|
|
64
|
+
private updateHandle;
|
|
65
|
+
private canStartInteraction;
|
|
66
|
+
private pointerDeltaPercent;
|
|
67
|
+
private groupSize;
|
|
68
|
+
private separatorOrientation;
|
|
69
|
+
private installDocumentDragListeners;
|
|
70
|
+
private uninstallDocumentDragListeners;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,UAAU,CAAA;AAEhE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,MAAM,MAA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
+
var FLOAT_TOLERANCE = .001;
|
|
5
|
+
var nextPaneGroupId = 0;
|
|
6
|
+
var ResizablePaneGroup = class {
|
|
7
|
+
container;
|
|
8
|
+
document;
|
|
9
|
+
groupId;
|
|
10
|
+
orientation;
|
|
11
|
+
keyboardStep;
|
|
12
|
+
disabled;
|
|
13
|
+
panes;
|
|
14
|
+
handles = [];
|
|
15
|
+
onDocumentPointerMove = (event) => {
|
|
16
|
+
this.handleDocumentPointerMove(event);
|
|
17
|
+
};
|
|
18
|
+
onDocumentPointerUp = (event) => {
|
|
19
|
+
this.handleDocumentPointerUp(event);
|
|
20
|
+
};
|
|
21
|
+
onLayoutChange;
|
|
22
|
+
onLayoutChanged;
|
|
23
|
+
dragState = null;
|
|
24
|
+
disposed = false;
|
|
25
|
+
layout;
|
|
26
|
+
constructor(container, options) {
|
|
27
|
+
this.container = container;
|
|
28
|
+
this.document = container.ownerDocument;
|
|
29
|
+
this.groupId = options.id ?? `editor-pane-group-${nextPaneGroupId++}`;
|
|
30
|
+
this.orientation = options.orientation ?? "horizontal";
|
|
31
|
+
this.keyboardStep = normalizeKeyboardStep(options.keyboardStep);
|
|
32
|
+
this.disabled = options.disabled === true;
|
|
33
|
+
this.onLayoutChange = options.onLayoutChange;
|
|
34
|
+
this.onLayoutChanged = options.onLayoutChanged;
|
|
35
|
+
this.panes = normalizePanes(options.panes);
|
|
36
|
+
this.layout = createInitialLayout(this.panes, options.defaultLayout);
|
|
37
|
+
mountContainer(this.container, this.groupId, this.orientation);
|
|
38
|
+
this.mountPanesAndHandles(options.createHandle);
|
|
39
|
+
this.applyLayout(this.layout, "silent");
|
|
40
|
+
}
|
|
41
|
+
getLayout() {
|
|
42
|
+
return { ...this.layout };
|
|
43
|
+
}
|
|
44
|
+
setLayout(layout) {
|
|
45
|
+
if (this.disposed) return this.getLayout();
|
|
46
|
+
const nextLayout = normalizeLayout(layout, this.panes);
|
|
47
|
+
this.applyLayout(nextLayout, "both");
|
|
48
|
+
return this.getLayout();
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
if (this.disposed) return;
|
|
52
|
+
this.disposed = true;
|
|
53
|
+
this.uninstallDocumentDragListeners();
|
|
54
|
+
for (const handle of this.handles) disposeHandle(handle);
|
|
55
|
+
this.handles.length = 0;
|
|
56
|
+
for (const pane of this.panes) unmountPane(pane);
|
|
57
|
+
unmountContainer(this.container);
|
|
58
|
+
}
|
|
59
|
+
mountPanesAndHandles(createHandle) {
|
|
60
|
+
for (const [index, pane] of this.panes.entries()) {
|
|
61
|
+
mountPane(this.container, pane, this.groupId, index);
|
|
62
|
+
if (index === 0) continue;
|
|
63
|
+
this.mountHandle(index - 1, createHandle);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
mountHandle(index, createHandle) {
|
|
67
|
+
const beforePane = this.panes[index];
|
|
68
|
+
const afterPane = this.panes[index + 1];
|
|
69
|
+
if (!beforePane || !afterPane) return;
|
|
70
|
+
const handleId = `${this.groupId}-handle-${index}`;
|
|
71
|
+
const element = createHandle?.({
|
|
72
|
+
document: this.document,
|
|
73
|
+
groupId: this.groupId,
|
|
74
|
+
handleId,
|
|
75
|
+
index,
|
|
76
|
+
beforePaneId: beforePane.id,
|
|
77
|
+
afterPaneId: afterPane.id,
|
|
78
|
+
orientation: this.orientation
|
|
79
|
+
}) ?? createDefaultHandle(this.document);
|
|
80
|
+
const handle = this.createMountedHandle(element, handleId, index);
|
|
81
|
+
this.handles.push(handle);
|
|
82
|
+
configureHandle(handle, this.separatorOrientation(), this.disabled);
|
|
83
|
+
this.container.insertBefore(element, afterPane.element);
|
|
84
|
+
}
|
|
85
|
+
createMountedHandle(element, id, index) {
|
|
86
|
+
const handle = {
|
|
87
|
+
id,
|
|
88
|
+
element,
|
|
89
|
+
index,
|
|
90
|
+
onKeyDown: (event) => this.handleKeyDown(handle, event),
|
|
91
|
+
onPointerDown: (event) => this.handlePointerDown(handle, event),
|
|
92
|
+
onPointerEnter: () => setHandleState(handle, "hover"),
|
|
93
|
+
onPointerLeave: () => setHandleState(handle, "inactive"),
|
|
94
|
+
onBlur: () => setHandleState(handle, "inactive"),
|
|
95
|
+
onFocus: () => setHandleState(handle, "focus")
|
|
96
|
+
};
|
|
97
|
+
element.addEventListener("keydown", handle.onKeyDown);
|
|
98
|
+
element.addEventListener("pointerdown", handle.onPointerDown);
|
|
99
|
+
element.addEventListener("pointerenter", handle.onPointerEnter);
|
|
100
|
+
element.addEventListener("pointerleave", handle.onPointerLeave);
|
|
101
|
+
element.addEventListener("blur", handle.onBlur);
|
|
102
|
+
element.addEventListener("focus", handle.onFocus);
|
|
103
|
+
return handle;
|
|
104
|
+
}
|
|
105
|
+
handlePointerDown(handle, event) {
|
|
106
|
+
if (!this.canStartInteraction(event)) return;
|
|
107
|
+
const groupSize = this.groupSize();
|
|
108
|
+
if (groupSize <= 0) return;
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
handle.element.focus({ preventScroll: true });
|
|
111
|
+
setHandleState(handle, "dragging");
|
|
112
|
+
this.dragState = {
|
|
113
|
+
handle,
|
|
114
|
+
initialLayout: this.getLayout(),
|
|
115
|
+
pointerId: pointerIdFromEvent(event),
|
|
116
|
+
startX: event.clientX,
|
|
117
|
+
startY: event.clientY,
|
|
118
|
+
groupSize,
|
|
119
|
+
changed: false
|
|
120
|
+
};
|
|
121
|
+
capturePointer(handle.element, event);
|
|
122
|
+
this.installDocumentDragListeners();
|
|
123
|
+
}
|
|
124
|
+
handleDocumentPointerMove(event) {
|
|
125
|
+
const drag = this.dragState;
|
|
126
|
+
if (!drag) return;
|
|
127
|
+
if (!matchesPointer(drag, event)) return;
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
const delta = this.pointerDeltaPercent(drag, event);
|
|
130
|
+
const changed = this.applyHandleDelta(drag.handle.index, delta, drag.initialLayout, "change");
|
|
131
|
+
drag.changed ||= changed;
|
|
132
|
+
}
|
|
133
|
+
handleDocumentPointerUp(event) {
|
|
134
|
+
const drag = this.dragState;
|
|
135
|
+
if (!drag) return;
|
|
136
|
+
if (!matchesPointer(drag, event)) return;
|
|
137
|
+
this.dragState = null;
|
|
138
|
+
this.uninstallDocumentDragListeners();
|
|
139
|
+
releasePointer(drag.handle.element, event);
|
|
140
|
+
setHandleState(drag.handle, "focus");
|
|
141
|
+
if (drag.changed) this.onLayoutChanged?.(this.getLayout());
|
|
142
|
+
}
|
|
143
|
+
handleKeyDown(handle, event) {
|
|
144
|
+
if (this.disabled) return;
|
|
145
|
+
if (event.key === "F6") {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
this.focusSiblingHandle(handle, event.shiftKey);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const delta = keyboardDelta(event, this.orientation, this.keyboardStep);
|
|
151
|
+
if (delta === null) return;
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
if (this.applyHandleDelta(handle.index, delta, this.layout, "both")) setHandleState(handle, "focus");
|
|
154
|
+
}
|
|
155
|
+
focusSiblingHandle(handle, reverse) {
|
|
156
|
+
nextFocusableHandle(this.handles, handle, reverse)?.element.focus({ preventScroll: true });
|
|
157
|
+
}
|
|
158
|
+
applyHandleDelta(handleIndex, delta, initialLayout, mode) {
|
|
159
|
+
const nextLayout = adjustLayoutByDelta({
|
|
160
|
+
delta,
|
|
161
|
+
initialLayout,
|
|
162
|
+
panes: this.panes,
|
|
163
|
+
pivotIndex: handleIndex,
|
|
164
|
+
prevLayout: this.layout
|
|
165
|
+
});
|
|
166
|
+
return this.applyLayout(nextLayout, mode);
|
|
167
|
+
}
|
|
168
|
+
applyLayout(layout, mode) {
|
|
169
|
+
const nextLayout = normalizeLayout(layout, this.panes);
|
|
170
|
+
if (layoutsEqual(this.layout, nextLayout)) {
|
|
171
|
+
this.updateHandles();
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
this.layout = nextLayout;
|
|
175
|
+
for (const pane of this.panes) applyPaneLayout(pane, nextLayout[pane.id] ?? 0);
|
|
176
|
+
this.updateHandles();
|
|
177
|
+
notifyLayoutChange(mode, nextLayout, this.onLayoutChange, this.onLayoutChanged);
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
updateHandles() {
|
|
181
|
+
for (const handle of this.handles) this.updateHandle(handle);
|
|
182
|
+
}
|
|
183
|
+
updateHandle(handle) {
|
|
184
|
+
const beforePane = this.panes[handle.index];
|
|
185
|
+
if (!beforePane) return;
|
|
186
|
+
const aria = calculateHandleAria({
|
|
187
|
+
handleIndex: handle.index,
|
|
188
|
+
layout: this.layout,
|
|
189
|
+
panes: this.panes
|
|
190
|
+
});
|
|
191
|
+
handle.element.id = handle.id;
|
|
192
|
+
handle.element.setAttribute("aria-controls", beforePane.element.id);
|
|
193
|
+
handle.element.setAttribute("aria-valuemin", formatAriaNumber(aria.min));
|
|
194
|
+
handle.element.setAttribute("aria-valuemax", formatAriaNumber(aria.max));
|
|
195
|
+
handle.element.setAttribute("aria-valuenow", formatAriaNumber(aria.now));
|
|
196
|
+
}
|
|
197
|
+
canStartInteraction(event) {
|
|
198
|
+
if (this.disabled || this.disposed || event.defaultPrevented) return false;
|
|
199
|
+
if (event.pointerType === "mouse" && event.button > 0) return false;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
pointerDeltaPercent(drag, event) {
|
|
203
|
+
if (this.orientation === "horizontal") return (event.clientX - drag.startX) / drag.groupSize * 100;
|
|
204
|
+
return (event.clientY - drag.startY) / drag.groupSize * 100;
|
|
205
|
+
}
|
|
206
|
+
groupSize() {
|
|
207
|
+
const rect = this.container.getBoundingClientRect();
|
|
208
|
+
if (this.orientation === "horizontal") return rect.width;
|
|
209
|
+
return rect.height;
|
|
210
|
+
}
|
|
211
|
+
separatorOrientation() {
|
|
212
|
+
if (this.orientation === "horizontal") return "vertical";
|
|
213
|
+
return "horizontal";
|
|
214
|
+
}
|
|
215
|
+
installDocumentDragListeners() {
|
|
216
|
+
this.document.addEventListener("pointermove", this.onDocumentPointerMove);
|
|
217
|
+
this.document.addEventListener("pointerup", this.onDocumentPointerUp, true);
|
|
218
|
+
}
|
|
219
|
+
uninstallDocumentDragListeners() {
|
|
220
|
+
this.document.removeEventListener("pointermove", this.onDocumentPointerMove);
|
|
221
|
+
this.document.removeEventListener("pointerup", this.onDocumentPointerUp, true);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
function mountContainer(container, groupId, orientation) {
|
|
225
|
+
container.classList.add("editor-resizable-pane-group");
|
|
226
|
+
container.dataset.editorPaneGroup = groupId;
|
|
227
|
+
container.dataset.editorPaneOrientation = orientation;
|
|
228
|
+
container.style.display = "flex";
|
|
229
|
+
container.style.flexDirection = orientation === "horizontal" ? "row" : "column";
|
|
230
|
+
container.style.flexWrap = "nowrap";
|
|
231
|
+
container.style.overflow = "hidden";
|
|
232
|
+
container.style.touchAction = orientation === "horizontal" ? "pan-y" : "pan-x";
|
|
233
|
+
}
|
|
234
|
+
function unmountContainer(container) {
|
|
235
|
+
container.classList.remove("editor-resizable-pane-group");
|
|
236
|
+
delete container.dataset.editorPaneGroup;
|
|
237
|
+
delete container.dataset.editorPaneOrientation;
|
|
238
|
+
}
|
|
239
|
+
function mountPane(container, pane, groupId, index) {
|
|
240
|
+
ensureElementId(pane.element, `${groupId}-pane-${pane.id}`);
|
|
241
|
+
pane.element.classList.add("editor-resizable-pane");
|
|
242
|
+
pane.element.dataset.editorPane = pane.id;
|
|
243
|
+
pane.element.dataset.editorPaneIndex = String(index);
|
|
244
|
+
pane.element.style.minHeight = "0";
|
|
245
|
+
pane.element.style.minWidth = "0";
|
|
246
|
+
if (pane.disabled) pane.element.dataset.disabled = "true";
|
|
247
|
+
container.appendChild(pane.element);
|
|
248
|
+
}
|
|
249
|
+
function unmountPane(pane) {
|
|
250
|
+
pane.element.classList.remove("editor-resizable-pane");
|
|
251
|
+
delete pane.element.dataset.editorPane;
|
|
252
|
+
delete pane.element.dataset.editorPaneIndex;
|
|
253
|
+
delete pane.element.dataset.disabled;
|
|
254
|
+
}
|
|
255
|
+
function applyPaneLayout(pane, size) {
|
|
256
|
+
pane.element.style.flexGrow = formatFlexNumber(size);
|
|
257
|
+
pane.element.style.flexShrink = "1";
|
|
258
|
+
pane.element.style.flexBasis = "0";
|
|
259
|
+
}
|
|
260
|
+
function createDefaultHandle(document) {
|
|
261
|
+
const handle = document.createElement("div");
|
|
262
|
+
handle.className = "editor-resizable-pane-handle";
|
|
263
|
+
return handle;
|
|
264
|
+
}
|
|
265
|
+
function configureHandle(handle, orientation, disabled) {
|
|
266
|
+
handle.element.classList.add("editor-resizable-pane-handle");
|
|
267
|
+
handle.element.dataset.editorPaneHandle = handle.id;
|
|
268
|
+
handle.element.dataset.editorPaneHandleState = "inactive";
|
|
269
|
+
handle.element.setAttribute("aria-disabled", disabled ? "true" : "false");
|
|
270
|
+
handle.element.setAttribute("aria-orientation", orientation);
|
|
271
|
+
handle.element.setAttribute("role", "separator");
|
|
272
|
+
handle.element.style.flexGrow = "0";
|
|
273
|
+
handle.element.style.flexShrink = "0";
|
|
274
|
+
handle.element.style.touchAction = "none";
|
|
275
|
+
applyHandleOrientationStyle(handle.element, orientation, disabled);
|
|
276
|
+
handle.element.tabIndex = disabled ? -1 : 0;
|
|
277
|
+
}
|
|
278
|
+
function applyHandleOrientationStyle(element, orientation, disabled) {
|
|
279
|
+
if (orientation === "vertical") {
|
|
280
|
+
element.style.width = element.style.width || "8px";
|
|
281
|
+
element.style.cursor = disabled ? "default" : "ew-resize";
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
element.style.height = element.style.height || "8px";
|
|
285
|
+
element.style.cursor = disabled ? "default" : "ns-resize";
|
|
286
|
+
}
|
|
287
|
+
function disposeHandle(handle) {
|
|
288
|
+
handle.element.removeEventListener("keydown", handle.onKeyDown);
|
|
289
|
+
handle.element.removeEventListener("pointerdown", handle.onPointerDown);
|
|
290
|
+
handle.element.removeEventListener("pointerenter", handle.onPointerEnter);
|
|
291
|
+
handle.element.removeEventListener("pointerleave", handle.onPointerLeave);
|
|
292
|
+
handle.element.removeEventListener("blur", handle.onBlur);
|
|
293
|
+
handle.element.removeEventListener("focus", handle.onFocus);
|
|
294
|
+
handle.element.remove();
|
|
295
|
+
}
|
|
296
|
+
function setHandleState(handle, state) {
|
|
297
|
+
if (handle.element.dataset.editorPaneHandleState === "dragging" && state === "inactive") return;
|
|
298
|
+
handle.element.dataset.editorPaneHandleState = state;
|
|
299
|
+
}
|
|
300
|
+
function normalizePanes(panes) {
|
|
301
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
302
|
+
return panes.map((pane) => normalizePane(pane, seenIds));
|
|
303
|
+
}
|
|
304
|
+
function normalizePane(pane, seenIds) {
|
|
305
|
+
const id = String(pane.id);
|
|
306
|
+
if (!id) throw new Error("Resizable panes must have an id");
|
|
307
|
+
if (seenIds.has(id)) throw new Error(`Duplicate resizable pane id "${id}"`);
|
|
308
|
+
seenIds.add(id);
|
|
309
|
+
const minSize = clampPercent(pane.minSize ?? 0);
|
|
310
|
+
const maxSize = Math.max(minSize, clampPercent(pane.maxSize ?? 100));
|
|
311
|
+
return {
|
|
312
|
+
id,
|
|
313
|
+
element: pane.element,
|
|
314
|
+
defaultSize: optionalPercent(pane.defaultSize),
|
|
315
|
+
minSize,
|
|
316
|
+
maxSize,
|
|
317
|
+
disabled: pane.disabled === true
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function createInitialLayout(panes, defaultLayout) {
|
|
321
|
+
const configured = layoutFromDefaultLayout(panes, defaultLayout);
|
|
322
|
+
if (configured) return configured;
|
|
323
|
+
const paneDefaults = layoutFromPaneDefaults(panes);
|
|
324
|
+
if (paneDefaults) return paneDefaults;
|
|
325
|
+
return equalLayout(panes);
|
|
326
|
+
}
|
|
327
|
+
function layoutFromDefaultLayout(panes, defaultLayout) {
|
|
328
|
+
if (!defaultLayout) return null;
|
|
329
|
+
if (!panes.every((pane) => finiteNumber(defaultLayout[pane.id]))) return null;
|
|
330
|
+
return normalizeLayout(defaultLayout, panes);
|
|
331
|
+
}
|
|
332
|
+
function layoutFromPaneDefaults(panes) {
|
|
333
|
+
if (!panes.some((pane) => pane.defaultSize !== void 0)) return null;
|
|
334
|
+
const fixedTotal = sumValues(panes.map((pane) => pane.defaultSize ?? 0));
|
|
335
|
+
const flexiblePanes = panes.filter((pane) => pane.defaultSize === void 0);
|
|
336
|
+
const flexibleSize = flexiblePanes.length > 0 ? Math.max(0, 100 - fixedTotal) / flexiblePanes.length : 0;
|
|
337
|
+
const layout = {};
|
|
338
|
+
for (const pane of panes) layout[pane.id] = pane.defaultSize ?? flexibleSize;
|
|
339
|
+
return normalizeLayout(layout, panes);
|
|
340
|
+
}
|
|
341
|
+
function equalLayout(panes) {
|
|
342
|
+
const size = panes.length > 0 ? 100 / panes.length : 0;
|
|
343
|
+
const layout = {};
|
|
344
|
+
for (const pane of panes) layout[pane.id] = size;
|
|
345
|
+
return normalizeLayout(layout, panes);
|
|
346
|
+
}
|
|
347
|
+
function normalizeLayout(layout, panes) {
|
|
348
|
+
return freezeLayout(rebalanceLayout(mutableLayout(layout, panes), panes));
|
|
349
|
+
}
|
|
350
|
+
function mutableLayout(layout, panes) {
|
|
351
|
+
const nextLayout = {};
|
|
352
|
+
for (const pane of panes) nextLayout[pane.id] = clampToPane(layout[pane.id], pane);
|
|
353
|
+
return nextLayout;
|
|
354
|
+
}
|
|
355
|
+
function rebalanceLayout(layout, panes) {
|
|
356
|
+
let remaining = 100 - sumValues(Object.values(layout));
|
|
357
|
+
let iterations = 0;
|
|
358
|
+
while (Math.abs(remaining) > FLOAT_TOLERANCE && iterations < panes.length * 3) {
|
|
359
|
+
const applied = distributeRebalanceDelta(layout, panes, remaining);
|
|
360
|
+
if (Math.abs(applied) <= FLOAT_TOLERANCE) break;
|
|
361
|
+
remaining -= applied;
|
|
362
|
+
iterations += 1;
|
|
363
|
+
}
|
|
364
|
+
return layout;
|
|
365
|
+
}
|
|
366
|
+
function distributeRebalanceDelta(layout, panes, remaining) {
|
|
367
|
+
const candidates = rebalanceCandidates(layout, panes, remaining);
|
|
368
|
+
if (candidates.length === 0) return 0;
|
|
369
|
+
const share = remaining / candidates.length;
|
|
370
|
+
let applied = 0;
|
|
371
|
+
for (const pane of candidates) applied += applyRebalanceShare(layout, pane, share);
|
|
372
|
+
return applied;
|
|
373
|
+
}
|
|
374
|
+
function rebalanceCandidates(layout, panes, remaining) {
|
|
375
|
+
if (remaining > 0) return panes.filter((pane) => layout[pane.id] < pane.maxSize);
|
|
376
|
+
return panes.filter((pane) => layout[pane.id] > pane.minSize);
|
|
377
|
+
}
|
|
378
|
+
function applyRebalanceShare(layout, pane, share) {
|
|
379
|
+
const current = layout[pane.id] ?? 0;
|
|
380
|
+
const next = clampToPane(current + share, pane);
|
|
381
|
+
layout[pane.id] = next;
|
|
382
|
+
return next - current;
|
|
383
|
+
}
|
|
384
|
+
function adjustLayoutByDelta(options) {
|
|
385
|
+
const { delta, initialLayout, panes, pivotIndex, prevLayout } = options;
|
|
386
|
+
if (Math.abs(delta) <= FLOAT_TOLERANCE) return prevLayout;
|
|
387
|
+
const nextLayout = mutableLayout(initialLayout, panes);
|
|
388
|
+
const amount = Math.abs(delta);
|
|
389
|
+
const shrinkIndices = shrinkCandidateIndices(delta, panes, pivotIndex);
|
|
390
|
+
const growIndices = growCandidateIndices(delta, panes, pivotIndex);
|
|
391
|
+
const applicableDelta = Math.min(amount, totalShrinkCapacity(nextLayout, panes, shrinkIndices), totalGrowCapacity(nextLayout, panes, growIndices));
|
|
392
|
+
if (applicableDelta <= FLOAT_TOLERANCE) return prevLayout;
|
|
393
|
+
distributeResizeDelta(nextLayout, panes, shrinkIndices, -applicableDelta);
|
|
394
|
+
distributeResizeDelta(nextLayout, panes, growIndices, applicableDelta);
|
|
395
|
+
const next = freezeLayout(nextLayout);
|
|
396
|
+
if (layoutsEqual(prevLayout, next)) return prevLayout;
|
|
397
|
+
return next;
|
|
398
|
+
}
|
|
399
|
+
function shrinkCandidateIndices(delta, panes, pivotIndex) {
|
|
400
|
+
if (delta > 0) return forwardIndices(pivotIndex + 1, panes.length);
|
|
401
|
+
return reverseIndices(pivotIndex);
|
|
402
|
+
}
|
|
403
|
+
function growCandidateIndices(delta, panes, pivotIndex) {
|
|
404
|
+
if (delta > 0) return reverseIndices(pivotIndex);
|
|
405
|
+
return forwardIndices(pivotIndex + 1, panes.length);
|
|
406
|
+
}
|
|
407
|
+
function forwardIndices(start, length) {
|
|
408
|
+
const indices = [];
|
|
409
|
+
for (let index = start; index < length; index += 1) indices.push(index);
|
|
410
|
+
return indices;
|
|
411
|
+
}
|
|
412
|
+
function reverseIndices(start) {
|
|
413
|
+
const indices = [];
|
|
414
|
+
for (let index = start; index >= 0; index -= 1) indices.push(index);
|
|
415
|
+
return indices;
|
|
416
|
+
}
|
|
417
|
+
function totalShrinkCapacity(layout, panes, indices) {
|
|
418
|
+
return indices.reduce((total, index) => {
|
|
419
|
+
const pane = panes[index];
|
|
420
|
+
if (!pane || pane.disabled) return total;
|
|
421
|
+
return total + Math.max(0, (layout[pane.id] ?? 0) - pane.minSize);
|
|
422
|
+
}, 0);
|
|
423
|
+
}
|
|
424
|
+
function totalGrowCapacity(layout, panes, indices) {
|
|
425
|
+
return indices.reduce((total, index) => {
|
|
426
|
+
const pane = panes[index];
|
|
427
|
+
if (!pane || pane.disabled) return total;
|
|
428
|
+
return total + Math.max(0, pane.maxSize - (layout[pane.id] ?? 0));
|
|
429
|
+
}, 0);
|
|
430
|
+
}
|
|
431
|
+
function distributeResizeDelta(layout, panes, indices, delta) {
|
|
432
|
+
let remaining = Math.abs(delta);
|
|
433
|
+
const direction = delta < 0 ? -1 : 1;
|
|
434
|
+
for (const index of indices) {
|
|
435
|
+
const pane = panes[index];
|
|
436
|
+
if (!pane || pane.disabled) continue;
|
|
437
|
+
remaining = applyResizeDelta(layout, pane, remaining, direction);
|
|
438
|
+
if (remaining <= FLOAT_TOLERANCE) return;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
function applyResizeDelta(layout, pane, remaining, direction) {
|
|
442
|
+
const current = layout[pane.id] ?? 0;
|
|
443
|
+
const next = clampToPane(current + remaining * direction, pane);
|
|
444
|
+
layout[pane.id] = next;
|
|
445
|
+
return remaining - Math.abs(next - current);
|
|
446
|
+
}
|
|
447
|
+
function calculateHandleAria(options) {
|
|
448
|
+
const pane = options.panes[options.handleIndex];
|
|
449
|
+
if (!pane) return {
|
|
450
|
+
min: 0,
|
|
451
|
+
max: 100,
|
|
452
|
+
now: 0
|
|
453
|
+
};
|
|
454
|
+
const now = options.layout[pane.id] ?? 0;
|
|
455
|
+
const minLayout = adjustLayoutByDelta({
|
|
456
|
+
delta: pane.minSize - now,
|
|
457
|
+
initialLayout: options.layout,
|
|
458
|
+
panes: options.panes,
|
|
459
|
+
pivotIndex: options.handleIndex,
|
|
460
|
+
prevLayout: options.layout
|
|
461
|
+
});
|
|
462
|
+
const maxLayout = adjustLayoutByDelta({
|
|
463
|
+
delta: pane.maxSize - now,
|
|
464
|
+
initialLayout: options.layout,
|
|
465
|
+
panes: options.panes,
|
|
466
|
+
pivotIndex: options.handleIndex,
|
|
467
|
+
prevLayout: options.layout
|
|
468
|
+
});
|
|
469
|
+
return {
|
|
470
|
+
min: minLayout[pane.id] ?? pane.minSize,
|
|
471
|
+
max: maxLayout[pane.id] ?? pane.maxSize,
|
|
472
|
+
now
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function keyboardDelta(event, orientation, keyboardStep) {
|
|
476
|
+
if (event.key === "Home") return -100;
|
|
477
|
+
if (event.key === "End") return 100;
|
|
478
|
+
if (orientation === "horizontal") return horizontalKeyboardDelta(event.key, keyboardStep);
|
|
479
|
+
return verticalKeyboardDelta(event.key, keyboardStep);
|
|
480
|
+
}
|
|
481
|
+
function horizontalKeyboardDelta(key, keyboardStep) {
|
|
482
|
+
if (key === "ArrowLeft") return -keyboardStep;
|
|
483
|
+
if (key === "ArrowRight") return keyboardStep;
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
function verticalKeyboardDelta(key, keyboardStep) {
|
|
487
|
+
if (key === "ArrowUp") return -keyboardStep;
|
|
488
|
+
if (key === "ArrowDown") return keyboardStep;
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
function nextFocusableHandle(handles, current, reverse) {
|
|
492
|
+
if (handles.length === 0) return null;
|
|
493
|
+
const index = handles.indexOf(current);
|
|
494
|
+
if (index === -1) return handles[0] ?? null;
|
|
495
|
+
return handles[(index + (reverse ? -1 : 1) + handles.length) % handles.length] ?? null;
|
|
496
|
+
}
|
|
497
|
+
function notifyLayoutChange(mode, layout, onLayoutChange, onLayoutChanged) {
|
|
498
|
+
if (mode === "silent") return;
|
|
499
|
+
if (mode === "change" || mode === "both") onLayoutChange?.({ ...layout });
|
|
500
|
+
if (mode === "changed" || mode === "both") onLayoutChanged?.({ ...layout });
|
|
501
|
+
}
|
|
502
|
+
function layoutsEqual(a, b) {
|
|
503
|
+
const keys = new Set(Object.keys(a).concat(Object.keys(b)));
|
|
504
|
+
for (const key of keys) if (Math.abs((a[key] ?? 0) - (b[key] ?? 0)) > FLOAT_TOLERANCE) return false;
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
function freezeLayout(layout) {
|
|
508
|
+
return Object.freeze({ ...layout });
|
|
509
|
+
}
|
|
510
|
+
function clampToPane(value, pane) {
|
|
511
|
+
if (!finiteNumber(value)) return pane.minSize;
|
|
512
|
+
return clamp(value, pane.minSize, pane.maxSize);
|
|
513
|
+
}
|
|
514
|
+
function clampPercent(value) {
|
|
515
|
+
if (!finiteNumber(value)) return 0;
|
|
516
|
+
return clamp(value, 0, 100);
|
|
517
|
+
}
|
|
518
|
+
function optionalPercent(value) {
|
|
519
|
+
if (value === void 0) return void 0;
|
|
520
|
+
return clampPercent(value);
|
|
521
|
+
}
|
|
522
|
+
function clamp(value, min, max) {
|
|
523
|
+
return Math.min(max, Math.max(min, value));
|
|
524
|
+
}
|
|
525
|
+
function finiteNumber(value) {
|
|
526
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
527
|
+
}
|
|
528
|
+
function sumValues(values) {
|
|
529
|
+
return values.reduce((total, value) => total + value, 0);
|
|
530
|
+
}
|
|
531
|
+
function normalizeKeyboardStep(value) {
|
|
532
|
+
if (!finiteNumber(value) || value <= 0) return DEFAULT_KEYBOARD_STEP;
|
|
533
|
+
return value;
|
|
534
|
+
}
|
|
535
|
+
function ensureElementId(element, fallback) {
|
|
536
|
+
if (element.id) return;
|
|
537
|
+
element.id = fallback.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
538
|
+
}
|
|
539
|
+
function formatFlexNumber(value) {
|
|
540
|
+
return Number(value.toFixed(4)).toString();
|
|
541
|
+
}
|
|
542
|
+
function formatAriaNumber(value) {
|
|
543
|
+
return Number(value.toFixed(2)).toString();
|
|
544
|
+
}
|
|
545
|
+
function pointerIdFromEvent(event) {
|
|
546
|
+
if (typeof event.pointerId !== "number") return null;
|
|
547
|
+
return event.pointerId;
|
|
548
|
+
}
|
|
549
|
+
function matchesPointer(drag, event) {
|
|
550
|
+
if (drag.pointerId === null) return true;
|
|
551
|
+
return event.pointerId === drag.pointerId;
|
|
552
|
+
}
|
|
553
|
+
function capturePointer(element, event) {
|
|
554
|
+
if (typeof event.pointerId !== "number") return;
|
|
555
|
+
element.setPointerCapture?.(event.pointerId);
|
|
556
|
+
}
|
|
557
|
+
function releasePointer(element, event) {
|
|
558
|
+
if (typeof event.pointerId !== "number") return;
|
|
559
|
+
element.releasePointerCapture?.(event.pointerId);
|
|
560
|
+
}
|
|
561
|
+
//#endregion
|
|
562
|
+
export { ResizablePaneGroup };
|
|
563
|
+
|
|
564
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import './style.css'\n\nexport type ResizablePaneOrientation = 'horizontal' | 'vertical'\n\nexport type ResizablePaneLayout = Readonly<Record<string, number>>\n\nexport type ResizablePane = {\n readonly id: string\n readonly element: HTMLElement\n readonly defaultSize?: number\n readonly minSize?: number\n readonly maxSize?: number\n readonly disabled?: boolean\n}\n\nexport type ResizablePaneHandleContext = {\n readonly document: Document\n readonly groupId: string\n readonly handleId: string\n readonly index: number\n readonly beforePaneId: string\n readonly afterPaneId: string\n readonly orientation: ResizablePaneOrientation\n}\n\nexport type ResizablePaneHandleFactory = (context: ResizablePaneHandleContext) => HTMLElement\n\nexport type ResizablePaneGroupOptions = {\n readonly id?: string\n readonly orientation?: ResizablePaneOrientation\n readonly panes: readonly ResizablePane[]\n readonly defaultLayout?: ResizablePaneLayout\n readonly createHandle?: ResizablePaneHandleFactory\n readonly onLayoutChange?: (layout: ResizablePaneLayout) => void\n readonly onLayoutChanged?: (layout: ResizablePaneLayout) => void\n readonly keyboardStep?: number\n readonly disabled?: boolean\n}\n\ntype NormalizedPane = {\n readonly id: string\n readonly element: HTMLElement\n readonly defaultSize?: number\n readonly minSize: number\n readonly maxSize: number\n readonly disabled: boolean\n}\n\ntype MountedHandle = {\n readonly id: string\n readonly element: HTMLElement\n readonly index: number\n readonly onKeyDown: (event: KeyboardEvent) => void\n readonly onPointerDown: (event: PointerEvent) => void\n readonly onPointerEnter: () => void\n readonly onPointerLeave: () => void\n readonly onBlur: () => void\n readonly onFocus: () => void\n}\n\ntype DragState = {\n readonly handle: MountedHandle\n readonly initialLayout: ResizablePaneLayout\n readonly pointerId: number | null\n readonly startX: number\n readonly startY: number\n readonly groupSize: number\n changed: boolean\n}\n\ntype LayoutApplyMode = 'silent' | 'change' | 'changed' | 'both'\n\nconst DEFAULT_KEYBOARD_STEP = 5\nconst FLOAT_TOLERANCE = 0.001\nlet nextPaneGroupId = 0\n\nexport class ResizablePaneGroup {\n private readonly container: HTMLElement\n private readonly document: Document\n private readonly groupId: string\n private readonly orientation: ResizablePaneOrientation\n private readonly keyboardStep: number\n private readonly disabled: boolean\n private readonly panes: readonly NormalizedPane[]\n private readonly handles: MountedHandle[] = []\n private readonly onDocumentPointerMove = (event: PointerEvent): void => {\n this.handleDocumentPointerMove(event)\n }\n private readonly onDocumentPointerUp = (event: PointerEvent): void => {\n this.handleDocumentPointerUp(event)\n }\n private readonly onLayoutChange?: (layout: ResizablePaneLayout) => void\n private readonly onLayoutChanged?: (layout: ResizablePaneLayout) => void\n private dragState: DragState | null = null\n private disposed = false\n private layout: ResizablePaneLayout\n\n public constructor(container: HTMLElement, options: ResizablePaneGroupOptions) {\n this.container = container\n this.document = container.ownerDocument\n this.groupId = options.id ?? `editor-pane-group-${nextPaneGroupId++}`\n this.orientation = options.orientation ?? 'horizontal'\n this.keyboardStep = normalizeKeyboardStep(options.keyboardStep)\n this.disabled = options.disabled === true\n this.onLayoutChange = options.onLayoutChange\n this.onLayoutChanged = options.onLayoutChanged\n this.panes = normalizePanes(options.panes)\n this.layout = createInitialLayout(this.panes, options.defaultLayout)\n\n mountContainer(this.container, this.groupId, this.orientation)\n this.mountPanesAndHandles(options.createHandle)\n this.applyLayout(this.layout, 'silent')\n }\n\n public getLayout(): ResizablePaneLayout {\n return { ...this.layout }\n }\n\n public setLayout(layout: ResizablePaneLayout): ResizablePaneLayout {\n if (this.disposed) return this.getLayout()\n\n const nextLayout = normalizeLayout(layout, this.panes)\n this.applyLayout(nextLayout, 'both')\n return this.getLayout()\n }\n\n public dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n this.uninstallDocumentDragListeners()\n for (const handle of this.handles) disposeHandle(handle)\n this.handles.length = 0\n for (const pane of this.panes) unmountPane(pane)\n unmountContainer(this.container)\n }\n\n private mountPanesAndHandles(createHandle: ResizablePaneHandleFactory | undefined): void {\n for (const [index, pane] of this.panes.entries()) {\n mountPane(this.container, pane, this.groupId, index)\n if (index === 0) continue\n this.mountHandle(index - 1, createHandle)\n }\n }\n\n private mountHandle(index: number, createHandle: ResizablePaneHandleFactory | undefined): void {\n const beforePane = this.panes[index]\n const afterPane = this.panes[index + 1]\n if (!beforePane || !afterPane) return\n\n const handleId = `${this.groupId}-handle-${index}`\n const element =\n createHandle?.({\n document: this.document,\n groupId: this.groupId,\n handleId,\n index,\n beforePaneId: beforePane.id,\n afterPaneId: afterPane.id,\n orientation: this.orientation,\n }) ?? createDefaultHandle(this.document)\n const handle = this.createMountedHandle(element, handleId, index)\n this.handles.push(handle)\n configureHandle(handle, this.separatorOrientation(), this.disabled)\n this.container.insertBefore(element, afterPane.element)\n }\n\n private createMountedHandle(element: HTMLElement, id: string, index: number): MountedHandle {\n const handle: MountedHandle = {\n id,\n element,\n index,\n onKeyDown: (event) => this.handleKeyDown(handle, event),\n onPointerDown: (event) => this.handlePointerDown(handle, event),\n onPointerEnter: () => setHandleState(handle, 'hover'),\n onPointerLeave: () => setHandleState(handle, 'inactive'),\n onBlur: () => setHandleState(handle, 'inactive'),\n onFocus: () => setHandleState(handle, 'focus'),\n }\n element.addEventListener('keydown', handle.onKeyDown)\n element.addEventListener('pointerdown', handle.onPointerDown)\n element.addEventListener('pointerenter', handle.onPointerEnter)\n element.addEventListener('pointerleave', handle.onPointerLeave)\n element.addEventListener('blur', handle.onBlur)\n element.addEventListener('focus', handle.onFocus)\n return handle\n }\n\n private handlePointerDown(handle: MountedHandle, event: PointerEvent): void {\n if (!this.canStartInteraction(event)) return\n\n const groupSize = this.groupSize()\n if (groupSize <= 0) return\n\n event.preventDefault()\n handle.element.focus({ preventScroll: true })\n setHandleState(handle, 'dragging')\n this.dragState = {\n handle,\n initialLayout: this.getLayout(),\n pointerId: pointerIdFromEvent(event),\n startX: event.clientX,\n startY: event.clientY,\n groupSize,\n changed: false,\n }\n capturePointer(handle.element, event)\n this.installDocumentDragListeners()\n }\n\n private handleDocumentPointerMove(event: PointerEvent): void {\n const drag = this.dragState\n if (!drag) return\n if (!matchesPointer(drag, event)) return\n\n event.preventDefault()\n const delta = this.pointerDeltaPercent(drag, event)\n const changed = this.applyHandleDelta(drag.handle.index, delta, drag.initialLayout, 'change')\n drag.changed ||= changed\n }\n\n private handleDocumentPointerUp(event: PointerEvent): void {\n const drag = this.dragState\n if (!drag) return\n if (!matchesPointer(drag, event)) return\n\n this.dragState = null\n this.uninstallDocumentDragListeners()\n releasePointer(drag.handle.element, event)\n setHandleState(drag.handle, 'focus')\n if (drag.changed) this.onLayoutChanged?.(this.getLayout())\n }\n\n private handleKeyDown(handle: MountedHandle, event: KeyboardEvent): void {\n if (this.disabled) return\n if (event.key === 'F6') {\n event.preventDefault()\n this.focusSiblingHandle(handle, event.shiftKey)\n return\n }\n\n const delta = keyboardDelta(event, this.orientation, this.keyboardStep)\n if (delta === null) return\n\n event.preventDefault()\n const changed = this.applyHandleDelta(handle.index, delta, this.layout, 'both')\n if (changed) setHandleState(handle, 'focus')\n }\n\n private focusSiblingHandle(handle: MountedHandle, reverse: boolean): void {\n const nextHandle = nextFocusableHandle(this.handles, handle, reverse)\n nextHandle?.element.focus({ preventScroll: true })\n }\n\n private applyHandleDelta(\n handleIndex: number,\n delta: number,\n initialLayout: ResizablePaneLayout,\n mode: LayoutApplyMode,\n ): boolean {\n const nextLayout = adjustLayoutByDelta({\n delta,\n initialLayout,\n panes: this.panes,\n pivotIndex: handleIndex,\n prevLayout: this.layout,\n })\n return this.applyLayout(nextLayout, mode)\n }\n\n private applyLayout(layout: ResizablePaneLayout, mode: LayoutApplyMode): boolean {\n const nextLayout = normalizeLayout(layout, this.panes)\n if (layoutsEqual(this.layout, nextLayout)) {\n this.updateHandles()\n return false\n }\n\n this.layout = nextLayout\n for (const pane of this.panes) applyPaneLayout(pane, nextLayout[pane.id] ?? 0)\n this.updateHandles()\n notifyLayoutChange(mode, nextLayout, this.onLayoutChange, this.onLayoutChanged)\n return true\n }\n\n private updateHandles(): void {\n for (const handle of this.handles) this.updateHandle(handle)\n }\n\n private updateHandle(handle: MountedHandle): void {\n const beforePane = this.panes[handle.index]\n if (!beforePane) return\n\n const aria = calculateHandleAria({\n handleIndex: handle.index,\n layout: this.layout,\n panes: this.panes,\n })\n handle.element.id = handle.id\n handle.element.setAttribute('aria-controls', beforePane.element.id)\n handle.element.setAttribute('aria-valuemin', formatAriaNumber(aria.min))\n handle.element.setAttribute('aria-valuemax', formatAriaNumber(aria.max))\n handle.element.setAttribute('aria-valuenow', formatAriaNumber(aria.now))\n }\n\n private canStartInteraction(event: PointerEvent): boolean {\n if (this.disabled || this.disposed || event.defaultPrevented) return false\n if (event.pointerType === 'mouse' && event.button > 0) return false\n return true\n }\n\n private pointerDeltaPercent(drag: DragState, event: PointerEvent): number {\n if (this.orientation === 'horizontal')\n return ((event.clientX - drag.startX) / drag.groupSize) * 100\n return ((event.clientY - drag.startY) / drag.groupSize) * 100\n }\n\n private groupSize(): number {\n const rect = this.container.getBoundingClientRect()\n if (this.orientation === 'horizontal') return rect.width\n return rect.height\n }\n\n private separatorOrientation(): 'horizontal' | 'vertical' {\n if (this.orientation === 'horizontal') return 'vertical'\n return 'horizontal'\n }\n\n private installDocumentDragListeners(): void {\n this.document.addEventListener('pointermove', this.onDocumentPointerMove)\n this.document.addEventListener('pointerup', this.onDocumentPointerUp, true)\n }\n\n private uninstallDocumentDragListeners(): void {\n this.document.removeEventListener('pointermove', this.onDocumentPointerMove)\n this.document.removeEventListener('pointerup', this.onDocumentPointerUp, true)\n }\n}\n\nfunction mountContainer(\n container: HTMLElement,\n groupId: string,\n orientation: ResizablePaneOrientation,\n): void {\n container.classList.add('editor-resizable-pane-group')\n container.dataset.editorPaneGroup = groupId\n container.dataset.editorPaneOrientation = orientation\n container.style.display = 'flex'\n container.style.flexDirection = orientation === 'horizontal' ? 'row' : 'column'\n container.style.flexWrap = 'nowrap'\n container.style.overflow = 'hidden'\n container.style.touchAction = orientation === 'horizontal' ? 'pan-y' : 'pan-x'\n}\n\nfunction unmountContainer(container: HTMLElement): void {\n container.classList.remove('editor-resizable-pane-group')\n delete container.dataset.editorPaneGroup\n delete container.dataset.editorPaneOrientation\n}\n\nfunction mountPane(\n container: HTMLElement,\n pane: NormalizedPane,\n groupId: string,\n index: number,\n): void {\n ensureElementId(pane.element, `${groupId}-pane-${pane.id}`)\n pane.element.classList.add('editor-resizable-pane')\n pane.element.dataset.editorPane = pane.id\n pane.element.dataset.editorPaneIndex = String(index)\n pane.element.style.minHeight = '0'\n pane.element.style.minWidth = '0'\n if (pane.disabled) pane.element.dataset.disabled = 'true'\n container.appendChild(pane.element)\n}\n\nfunction unmountPane(pane: NormalizedPane): void {\n pane.element.classList.remove('editor-resizable-pane')\n delete pane.element.dataset.editorPane\n delete pane.element.dataset.editorPaneIndex\n delete pane.element.dataset.disabled\n}\n\nfunction applyPaneLayout(pane: NormalizedPane, size: number): void {\n pane.element.style.flexGrow = formatFlexNumber(size)\n pane.element.style.flexShrink = '1'\n pane.element.style.flexBasis = '0'\n}\n\nfunction createDefaultHandle(document: Document): HTMLElement {\n const handle = document.createElement('div')\n handle.className = 'editor-resizable-pane-handle'\n return handle\n}\n\nfunction configureHandle(\n handle: MountedHandle,\n orientation: 'horizontal' | 'vertical',\n disabled: boolean,\n): void {\n handle.element.classList.add('editor-resizable-pane-handle')\n handle.element.dataset.editorPaneHandle = handle.id\n handle.element.dataset.editorPaneHandleState = 'inactive'\n handle.element.setAttribute('aria-disabled', disabled ? 'true' : 'false')\n handle.element.setAttribute('aria-orientation', orientation)\n handle.element.setAttribute('role', 'separator')\n handle.element.style.flexGrow = '0'\n handle.element.style.flexShrink = '0'\n handle.element.style.touchAction = 'none'\n applyHandleOrientationStyle(handle.element, orientation, disabled)\n handle.element.tabIndex = disabled ? -1 : 0\n}\n\nfunction applyHandleOrientationStyle(\n element: HTMLElement,\n orientation: 'horizontal' | 'vertical',\n disabled: boolean,\n): void {\n if (orientation === 'vertical') {\n element.style.width = element.style.width || '8px'\n element.style.cursor = disabled ? 'default' : 'ew-resize'\n return\n }\n\n element.style.height = element.style.height || '8px'\n element.style.cursor = disabled ? 'default' : 'ns-resize'\n}\n\nfunction disposeHandle(handle: MountedHandle): void {\n handle.element.removeEventListener('keydown', handle.onKeyDown)\n handle.element.removeEventListener('pointerdown', handle.onPointerDown)\n handle.element.removeEventListener('pointerenter', handle.onPointerEnter)\n handle.element.removeEventListener('pointerleave', handle.onPointerLeave)\n handle.element.removeEventListener('blur', handle.onBlur)\n handle.element.removeEventListener('focus', handle.onFocus)\n handle.element.remove()\n}\n\nfunction setHandleState(handle: MountedHandle, state: string): void {\n if (handle.element.dataset.editorPaneHandleState === 'dragging' && state === 'inactive') return\n handle.element.dataset.editorPaneHandleState = state\n}\n\nfunction normalizePanes(panes: readonly ResizablePane[]): readonly NormalizedPane[] {\n const seenIds = new Set<string>()\n return panes.map((pane) => normalizePane(pane, seenIds))\n}\n\nfunction normalizePane(pane: ResizablePane, seenIds: Set<string>): NormalizedPane {\n const id = String(pane.id)\n if (!id) throw new Error('Resizable panes must have an id')\n if (seenIds.has(id)) throw new Error(`Duplicate resizable pane id \"${id}\"`)\n seenIds.add(id)\n\n const minSize = clampPercent(pane.minSize ?? 0)\n const maxSize = Math.max(minSize, clampPercent(pane.maxSize ?? 100))\n return {\n id,\n element: pane.element,\n defaultSize: optionalPercent(pane.defaultSize),\n minSize,\n maxSize,\n disabled: pane.disabled === true,\n }\n}\n\nfunction createInitialLayout(\n panes: readonly NormalizedPane[],\n defaultLayout: ResizablePaneLayout | undefined,\n): ResizablePaneLayout {\n const configured = layoutFromDefaultLayout(panes, defaultLayout)\n if (configured) return configured\n\n const paneDefaults = layoutFromPaneDefaults(panes)\n if (paneDefaults) return paneDefaults\n\n return equalLayout(panes)\n}\n\nfunction layoutFromDefaultLayout(\n panes: readonly NormalizedPane[],\n defaultLayout: ResizablePaneLayout | undefined,\n): ResizablePaneLayout | null {\n if (!defaultLayout) return null\n if (!panes.every((pane) => finiteNumber(defaultLayout[pane.id]))) return null\n return normalizeLayout(defaultLayout, panes)\n}\n\nfunction layoutFromPaneDefaults(panes: readonly NormalizedPane[]): ResizablePaneLayout | null {\n if (!panes.some((pane) => pane.defaultSize !== undefined)) return null\n\n const fixedTotal = sumValues(panes.map((pane) => pane.defaultSize ?? 0))\n const flexiblePanes = panes.filter((pane) => pane.defaultSize === undefined)\n const flexibleSize =\n flexiblePanes.length > 0 ? Math.max(0, 100 - fixedTotal) / flexiblePanes.length : 0\n const layout: Record<string, number> = {}\n for (const pane of panes) layout[pane.id] = pane.defaultSize ?? flexibleSize\n return normalizeLayout(layout, panes)\n}\n\nfunction equalLayout(panes: readonly NormalizedPane[]): ResizablePaneLayout {\n const size = panes.length > 0 ? 100 / panes.length : 0\n const layout: Record<string, number> = {}\n for (const pane of panes) layout[pane.id] = size\n return normalizeLayout(layout, panes)\n}\n\nfunction normalizeLayout(\n layout: ResizablePaneLayout,\n panes: readonly NormalizedPane[],\n): ResizablePaneLayout {\n const nextLayout = mutableLayout(layout, panes)\n return freezeLayout(rebalanceLayout(nextLayout, panes))\n}\n\nfunction mutableLayout(\n layout: ResizablePaneLayout,\n panes: readonly NormalizedPane[],\n): Record<string, number> {\n const nextLayout: Record<string, number> = {}\n for (const pane of panes) nextLayout[pane.id] = clampToPane(layout[pane.id], pane)\n return nextLayout\n}\n\nfunction rebalanceLayout(\n layout: Record<string, number>,\n panes: readonly NormalizedPane[],\n): Record<string, number> {\n let remaining = 100 - sumValues(Object.values(layout))\n let iterations = 0\n while (Math.abs(remaining) > FLOAT_TOLERANCE && iterations < panes.length * 3) {\n const applied = distributeRebalanceDelta(layout, panes, remaining)\n if (Math.abs(applied) <= FLOAT_TOLERANCE) break\n remaining -= applied\n iterations += 1\n }\n return layout\n}\n\nfunction distributeRebalanceDelta(\n layout: Record<string, number>,\n panes: readonly NormalizedPane[],\n remaining: number,\n): number {\n const candidates = rebalanceCandidates(layout, panes, remaining)\n if (candidates.length === 0) return 0\n\n const share = remaining / candidates.length\n let applied = 0\n for (const pane of candidates) applied += applyRebalanceShare(layout, pane, share)\n return applied\n}\n\nfunction rebalanceCandidates(\n layout: Record<string, number>,\n panes: readonly NormalizedPane[],\n remaining: number,\n): readonly NormalizedPane[] {\n if (remaining > 0) return panes.filter((pane) => layout[pane.id] < pane.maxSize)\n return panes.filter((pane) => layout[pane.id] > pane.minSize)\n}\n\nfunction applyRebalanceShare(\n layout: Record<string, number>,\n pane: NormalizedPane,\n share: number,\n): number {\n const current = layout[pane.id] ?? 0\n const next = clampToPane(current + share, pane)\n layout[pane.id] = next\n return next - current\n}\n\nfunction adjustLayoutByDelta(options: {\n readonly delta: number\n readonly initialLayout: ResizablePaneLayout\n readonly panes: readonly NormalizedPane[]\n readonly pivotIndex: number\n readonly prevLayout: ResizablePaneLayout\n}): ResizablePaneLayout {\n const { delta, initialLayout, panes, pivotIndex, prevLayout } = options\n if (Math.abs(delta) <= FLOAT_TOLERANCE) return prevLayout\n\n const nextLayout = mutableLayout(initialLayout, panes)\n const amount = Math.abs(delta)\n const shrinkIndices = shrinkCandidateIndices(delta, panes, pivotIndex)\n const growIndices = growCandidateIndices(delta, panes, pivotIndex)\n const applicableDelta = Math.min(\n amount,\n totalShrinkCapacity(nextLayout, panes, shrinkIndices),\n totalGrowCapacity(nextLayout, panes, growIndices),\n )\n if (applicableDelta <= FLOAT_TOLERANCE) return prevLayout\n\n distributeResizeDelta(nextLayout, panes, shrinkIndices, -applicableDelta)\n distributeResizeDelta(nextLayout, panes, growIndices, applicableDelta)\n const next = freezeLayout(nextLayout)\n if (layoutsEqual(prevLayout, next)) return prevLayout\n return next\n}\n\nfunction shrinkCandidateIndices(\n delta: number,\n panes: readonly NormalizedPane[],\n pivotIndex: number,\n): readonly number[] {\n if (delta > 0) return forwardIndices(pivotIndex + 1, panes.length)\n return reverseIndices(pivotIndex)\n}\n\nfunction growCandidateIndices(\n delta: number,\n panes: readonly NormalizedPane[],\n pivotIndex: number,\n): readonly number[] {\n if (delta > 0) return reverseIndices(pivotIndex)\n return forwardIndices(pivotIndex + 1, panes.length)\n}\n\nfunction forwardIndices(start: number, length: number): readonly number[] {\n const indices: number[] = []\n for (let index = start; index < length; index += 1) indices.push(index)\n return indices\n}\n\nfunction reverseIndices(start: number): readonly number[] {\n const indices: number[] = []\n for (let index = start; index >= 0; index -= 1) indices.push(index)\n return indices\n}\n\nfunction totalShrinkCapacity(\n layout: ResizablePaneLayout,\n panes: readonly NormalizedPane[],\n indices: readonly number[],\n): number {\n return indices.reduce((total, index) => {\n const pane = panes[index]\n if (!pane || pane.disabled) return total\n return total + Math.max(0, (layout[pane.id] ?? 0) - pane.minSize)\n }, 0)\n}\n\nfunction totalGrowCapacity(\n layout: ResizablePaneLayout,\n panes: readonly NormalizedPane[],\n indices: readonly number[],\n): number {\n return indices.reduce((total, index) => {\n const pane = panes[index]\n if (!pane || pane.disabled) return total\n return total + Math.max(0, pane.maxSize - (layout[pane.id] ?? 0))\n }, 0)\n}\n\nfunction distributeResizeDelta(\n layout: Record<string, number>,\n panes: readonly NormalizedPane[],\n indices: readonly number[],\n delta: number,\n): void {\n let remaining = Math.abs(delta)\n const direction = delta < 0 ? -1 : 1\n for (const index of indices) {\n const pane = panes[index]\n if (!pane || pane.disabled) continue\n remaining = applyResizeDelta(layout, pane, remaining, direction)\n if (remaining <= FLOAT_TOLERANCE) return\n }\n}\n\nfunction applyResizeDelta(\n layout: Record<string, number>,\n pane: NormalizedPane,\n remaining: number,\n direction: number,\n): number {\n const current = layout[pane.id] ?? 0\n const target = current + remaining * direction\n const next = clampToPane(target, pane)\n layout[pane.id] = next\n return remaining - Math.abs(next - current)\n}\n\nfunction calculateHandleAria(options: {\n readonly handleIndex: number\n readonly layout: ResizablePaneLayout\n readonly panes: readonly NormalizedPane[]\n}): { readonly min: number; readonly max: number; readonly now: number } {\n const pane = options.panes[options.handleIndex]\n if (!pane) return { min: 0, max: 100, now: 0 }\n\n const now = options.layout[pane.id] ?? 0\n const minLayout = adjustLayoutByDelta({\n delta: pane.minSize - now,\n initialLayout: options.layout,\n panes: options.panes,\n pivotIndex: options.handleIndex,\n prevLayout: options.layout,\n })\n const maxLayout = adjustLayoutByDelta({\n delta: pane.maxSize - now,\n initialLayout: options.layout,\n panes: options.panes,\n pivotIndex: options.handleIndex,\n prevLayout: options.layout,\n })\n return {\n min: minLayout[pane.id] ?? pane.minSize,\n max: maxLayout[pane.id] ?? pane.maxSize,\n now,\n }\n}\n\nfunction keyboardDelta(\n event: KeyboardEvent,\n orientation: ResizablePaneOrientation,\n keyboardStep: number,\n): number | null {\n if (event.key === 'Home') return -100\n if (event.key === 'End') return 100\n if (orientation === 'horizontal') return horizontalKeyboardDelta(event.key, keyboardStep)\n return verticalKeyboardDelta(event.key, keyboardStep)\n}\n\nfunction horizontalKeyboardDelta(key: string, keyboardStep: number): number | null {\n if (key === 'ArrowLeft') return -keyboardStep\n if (key === 'ArrowRight') return keyboardStep\n return null\n}\n\nfunction verticalKeyboardDelta(key: string, keyboardStep: number): number | null {\n if (key === 'ArrowUp') return -keyboardStep\n if (key === 'ArrowDown') return keyboardStep\n return null\n}\n\nfunction nextFocusableHandle(\n handles: readonly MountedHandle[],\n current: MountedHandle,\n reverse: boolean,\n): MountedHandle | null {\n if (handles.length === 0) return null\n\n const index = handles.indexOf(current)\n if (index === -1) return handles[0] ?? null\n const offset = reverse ? -1 : 1\n const nextIndex = (index + offset + handles.length) % handles.length\n return handles[nextIndex] ?? null\n}\n\nfunction notifyLayoutChange(\n mode: LayoutApplyMode,\n layout: ResizablePaneLayout,\n onLayoutChange: ((layout: ResizablePaneLayout) => void) | undefined,\n onLayoutChanged: ((layout: ResizablePaneLayout) => void) | undefined,\n): void {\n if (mode === 'silent') return\n if (mode === 'change' || mode === 'both') onLayoutChange?.({ ...layout })\n if (mode === 'changed' || mode === 'both') onLayoutChanged?.({ ...layout })\n}\n\nfunction layoutsEqual(a: ResizablePaneLayout, b: ResizablePaneLayout): boolean {\n const keys = new Set(Object.keys(a).concat(Object.keys(b)))\n for (const key of keys) {\n if (Math.abs((a[key] ?? 0) - (b[key] ?? 0)) > FLOAT_TOLERANCE) return false\n }\n return true\n}\n\nfunction freezeLayout(layout: Record<string, number>): ResizablePaneLayout {\n return Object.freeze({ ...layout })\n}\n\nfunction clampToPane(value: number | undefined, pane: NormalizedPane): number {\n if (!finiteNumber(value)) return pane.minSize\n return clamp(value, pane.minSize, pane.maxSize)\n}\n\nfunction clampPercent(value: number): number {\n if (!finiteNumber(value)) return 0\n return clamp(value, 0, 100)\n}\n\nfunction optionalPercent(value: number | undefined): number | undefined {\n if (value === undefined) return undefined\n return clampPercent(value)\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value))\n}\n\nfunction finiteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value)\n}\n\nfunction sumValues(values: readonly number[]): number {\n return values.reduce((total, value) => total + value, 0)\n}\n\nfunction normalizeKeyboardStep(value: number | undefined): number {\n if (!finiteNumber(value) || value <= 0) return DEFAULT_KEYBOARD_STEP\n return value\n}\n\nfunction ensureElementId(element: HTMLElement, fallback: string): void {\n if (element.id) return\n element.id = fallback.replace(/[^a-zA-Z0-9_-]/g, '-')\n}\n\nfunction formatFlexNumber(value: number): string {\n return Number(value.toFixed(4)).toString()\n}\n\nfunction formatAriaNumber(value: number): string {\n return Number(value.toFixed(2)).toString()\n}\n\nfunction pointerIdFromEvent(event: PointerEvent): number | null {\n if (typeof event.pointerId !== 'number') return null\n return event.pointerId\n}\n\nfunction matchesPointer(drag: DragState, event: PointerEvent): boolean {\n if (drag.pointerId === null) return true\n return event.pointerId === drag.pointerId\n}\n\nfunction capturePointer(element: HTMLElement, event: PointerEvent): void {\n if (typeof event.pointerId !== 'number') return\n element.setPointerCapture?.(event.pointerId)\n}\n\nfunction releasePointer(element: HTMLElement, event: PointerEvent): void {\n if (typeof event.pointerId !== 'number') return\n element.releasePointerCapture?.(event.pointerId)\n}\n"],"mappings":";;AAwEA,IAAM,wBAAwB;AAC9B,IAAM,kBAAkB;AACxB,IAAI,kBAAkB;AAEtB,IAAa,qBAAb,MAAgC;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA,UAA4C,CAAC;CAC7C,yBAA0C,UAA8B;EACtE,KAAK,0BAA0B,KAAK;CACtC;CACA,uBAAwC,UAA8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
|
1
|
+
.editor-resizable-pane-group {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: nowrap;
|
|
4
|
+
height: 100%;
|
|
5
|
+
min-height: 0;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.editor-resizable-pane-group[data-editor-pane-orientation='horizontal'] {
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
touch-action: pan-y;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.editor-resizable-pane-group[data-editor-pane-orientation='vertical'] {
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
touch-action: pan-x;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.editor-resizable-pane {
|
|
22
|
+
min-height: 0;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.editor-resizable-pane-handle {
|
|
27
|
+
background: transparent;
|
|
28
|
+
flex: 0 0 auto;
|
|
29
|
+
outline: none;
|
|
30
|
+
position: relative;
|
|
31
|
+
touch-action: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.editor-resizable-pane-handle[aria-orientation='vertical'] {
|
|
35
|
+
cursor: ew-resize;
|
|
36
|
+
width: 6px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.editor-resizable-pane-handle[aria-orientation='horizontal'] {
|
|
40
|
+
cursor: ns-resize;
|
|
41
|
+
height: 6px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.editor-resizable-pane-handle[aria-disabled='true'] {
|
|
45
|
+
cursor: default;
|
|
46
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@singapore-editor/panes",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"README.md",
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/style.css"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./style.css": "./dist/style.css"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bun ../../scripts/build-package.ts",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"typecheck": "tsgo --noEmit",
|
|
28
|
+
"lint": "oxlint .",
|
|
29
|
+
"format": "oxfmt --write .",
|
|
30
|
+
"format:check": "oxfmt --check ."
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
34
|
+
"happy-dom": "^20.14.5",
|
|
35
|
+
"oxfmt": "0.70.0",
|
|
36
|
+
"oxlint": "1.85.0",
|
|
37
|
+
"typescript": "~6.0.3",
|
|
38
|
+
"vitest": "^5.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|