@smartnet360/svelte-components 0.0.1-beta.2
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/dist/Desktop/Desktop.svelte +423 -0
- package/dist/Desktop/Desktop.svelte.d.ts +26 -0
- package/dist/Desktop/Grid/Half.svelte +50 -0
- package/dist/Desktop/Grid/Half.svelte.d.ts +29 -0
- package/dist/Desktop/Grid/Quarter.svelte +103 -0
- package/dist/Desktop/Grid/Quarter.svelte.d.ts +27 -0
- package/dist/Desktop/Grid/README.md +331 -0
- package/dist/Desktop/Grid/ResizeHandle.svelte +118 -0
- package/dist/Desktop/Grid/ResizeHandle.svelte.d.ts +23 -0
- package/dist/Desktop/Grid/index.d.ts +4 -0
- package/dist/Desktop/Grid/index.js +4 -0
- package/dist/Desktop/Grid/resizeStore.d.ts +16 -0
- package/dist/Desktop/Grid/resizeStore.js +39 -0
- package/dist/Desktop/GridRenderer.svelte +328 -0
- package/dist/Desktop/GridRenderer.svelte.d.ts +25 -0
- package/dist/Desktop/GridSelector/ComponentPalette.svelte +243 -0
- package/dist/Desktop/GridSelector/ComponentPalette.svelte.d.ts +27 -0
- package/dist/Desktop/GridSelector/ConfigurationPanel.svelte +242 -0
- package/dist/Desktop/GridSelector/ConfigurationPanel.svelte.d.ts +28 -0
- package/dist/Desktop/GridSelector/GridSelector.svelte +232 -0
- package/dist/Desktop/GridSelector/GridSelector.svelte.d.ts +43 -0
- package/dist/Desktop/GridSelector/LayoutPicker.svelte +241 -0
- package/dist/Desktop/GridSelector/LayoutPicker.svelte.d.ts +28 -0
- package/dist/Desktop/GridSelector/LayoutPreview.svelte +309 -0
- package/dist/Desktop/GridSelector/LayoutPreview.svelte.d.ts +32 -0
- package/dist/Desktop/GridSelector/index.d.ts +4 -0
- package/dist/Desktop/GridSelector/index.js +4 -0
- package/dist/Desktop/GridViewer.svelte +125 -0
- package/dist/Desktop/GridViewer.svelte.d.ts +21 -0
- package/dist/Desktop/README.md +279 -0
- package/dist/Desktop/gridLayouts.d.ts +76 -0
- package/dist/Desktop/gridLayouts.js +351 -0
- package/dist/Desktop/index.d.ts +7 -0
- package/dist/Desktop/index.js +7 -0
- package/dist/Desktop/launchHelpers.d.ts +25 -0
- package/dist/Desktop/launchHelpers.js +77 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +65 -0
@@ -0,0 +1,331 @@
|
|
1
|
+
# Desktop Grid Component
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
The Desktop Grid component provides a flexible, component-based approach to creating complex desktop layouts with dynamic resizing capabilities. The system uses composable Half and Quarter components that can be nested to build any desired layout, combined with a ResizeHandle for interactive resizing.
|
6
|
+
|
7
|
+
## Component-Based Approach
|
8
|
+
|
9
|
+
### Core Components
|
10
|
+
|
11
|
+
- **Half**: Flexible component for splitting space in half (left, right, top, bottom)
|
12
|
+
- **Quarter**: Component that renders two quarters inside one half with dynamic internal proportions
|
13
|
+
- **ResizeHandle**: Interactive draggable handle for resizing grid areas
|
14
|
+
- **resizeStore**: Svelte store for managing resize state across components
|
15
|
+
|
16
|
+
### Advantages
|
17
|
+
|
18
|
+
- **Explicit**: Code clearly shows the intended layout
|
19
|
+
- **Interactive**: Built-in resize handles for dynamic layout changes
|
20
|
+
- **Reusable**: Components can be combined in various ways
|
21
|
+
- **Maintainable**: Each component handles one specific responsibility
|
22
|
+
- **Flexible**: Easy to nest and compose complex layouts
|
23
|
+
- **Stateful**: Shared store manages resize state across components
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Half Component
|
28
|
+
|
29
|
+
```svelte
|
30
|
+
<script lang="ts">
|
31
|
+
export let position: 'left' | 'right' | 'top' | 'bottom' = 'left';
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<div class="half {position}">
|
35
|
+
<slot />
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<style>
|
39
|
+
.half {
|
40
|
+
display: grid;
|
41
|
+
place-items: center;
|
42
|
+
border: 1px solid #ccc;
|
43
|
+
}
|
44
|
+
|
45
|
+
/* Positions */
|
46
|
+
.left { grid-column: 1 / 2; grid-row: 1 / -1; }
|
47
|
+
.right { grid-column: 2 / 3; grid-row: 1 / -1; }
|
48
|
+
.top { grid-row: 1 / 2; grid-column: 1 / -1; }
|
49
|
+
.bottom{ grid-row: 2 / 3; grid-column: 1 / -1; }
|
50
|
+
</style>
|
51
|
+
```
|
52
|
+
|
53
|
+
### Quarter Component
|
54
|
+
|
55
|
+
```svelte
|
56
|
+
<script lang="ts">
|
57
|
+
export let position: 'left' | 'right' | 'top' | 'bottom';
|
58
|
+
export let topHeight: number = 50; // Percentage for top/left section
|
59
|
+
export let bottomHeight: number = 50; // Percentage for bottom/right section
|
60
|
+
</script>
|
61
|
+
|
62
|
+
<div class="quarters {position}" style="--top-height: {topHeight}%; --bottom-height: {bottomHeight}%">
|
63
|
+
<div class="quarter top-or-left">
|
64
|
+
<slot name="top-or-left" />
|
65
|
+
</div>
|
66
|
+
<div class="quarter bottom-or-right">
|
67
|
+
<slot name="bottom-or-right" />
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<style>
|
72
|
+
.quarters {
|
73
|
+
border: 1px solid #aaa;
|
74
|
+
display: grid;
|
75
|
+
overflow: hidden;
|
76
|
+
width: 100%;
|
77
|
+
height: 100%;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* Left and Right quarters are stacked (vertical split) */
|
81
|
+
.quarters.left,
|
82
|
+
.quarters.right {
|
83
|
+
grid-template-rows: var(--top-height) var(--bottom-height);
|
84
|
+
grid-template-columns: 1fr;
|
85
|
+
}
|
86
|
+
|
87
|
+
/* Top and Bottom quarters are side-by-side (horizontal split) */
|
88
|
+
.quarters.top,
|
89
|
+
.quarters.bottom {
|
90
|
+
grid-template-columns: var(--top-height) var(--bottom-height);
|
91
|
+
grid-template-rows: 1fr;
|
92
|
+
}
|
93
|
+
|
94
|
+
### ResizeHandle Component
|
95
|
+
|
96
|
+
```svelte
|
97
|
+
<script lang="ts">
|
98
|
+
import { createEventDispatcher } from 'svelte';
|
99
|
+
|
100
|
+
export let position: 'center' | 'left' | 'right' | 'top' | 'bottom' = 'center';
|
101
|
+
export let horizontalSize: number = 50;
|
102
|
+
export let verticalSize: number = 50;
|
103
|
+
|
104
|
+
const dispatch = createEventDispatcher();
|
105
|
+
</script>
|
106
|
+
|
107
|
+
<div
|
108
|
+
class="resize-handle {position}"
|
109
|
+
class:dragging={isDragging}
|
110
|
+
style="cursor: {cursorStyle}"
|
111
|
+
on:mousedown={handleMouseDown}
|
112
|
+
role="button"
|
113
|
+
tabindex="0"
|
114
|
+
aria-label="Resize handle"
|
115
|
+
>
|
116
|
+
<div class="handle-indicator"></div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
<!-- Dispatches 'resize' event with { horizontalSize, verticalSize } -->
|
120
|
+
```
|
121
|
+
|
122
|
+
### resizeStore
|
123
|
+
|
124
|
+
```typescript
|
125
|
+
import { writable } from 'svelte/store';
|
126
|
+
|
127
|
+
export interface ResizeState {
|
128
|
+
leftWidth: number;
|
129
|
+
rightWidth: number;
|
130
|
+
topHeight: number;
|
131
|
+
bottomHeight: number;
|
132
|
+
quarterSplit: number;
|
133
|
+
}
|
134
|
+
|
135
|
+
const resizeStore = createResizeStore();
|
136
|
+
|
137
|
+
export const resizeStore = {
|
138
|
+
subscribe: resizeStore.subscribe,
|
139
|
+
set: resizeStore.set,
|
140
|
+
update,
|
141
|
+
reset: () => set(initialState),
|
142
|
+
updateLeftWidth: (width: number) => update(state => ({...})),
|
143
|
+
updateTopHeight: (height: number) => update(state => ({...})),
|
144
|
+
update2D: (horizontalSize: number, verticalSize: number) => update(state => ({
|
145
|
+
...state,
|
146
|
+
leftWidth: Math.max(10, Math.min(90, horizontalSize)),
|
147
|
+
rightWidth: 100 - Math.max(10, Math.min(90, horizontalSize)),
|
148
|
+
topHeight: Math.max(10, Math.min(90, verticalSize)),
|
149
|
+
bottomHeight: 100 - Math.max(10, Math.min(90, verticalSize))
|
150
|
+
}))
|
151
|
+
};
|
152
|
+
```
|
153
|
+
|
154
|
+
## Usage Examples
|
155
|
+
|
156
|
+
### Basic Resizable Layout with Store
|
157
|
+
|
158
|
+
```svelte
|
159
|
+
<script lang="ts">
|
160
|
+
import { Quarter, ResizeHandle, resizeStore } from './lib/index.js';
|
161
|
+
|
162
|
+
let leftWidth = 50;
|
163
|
+
let rightWidth = 50;
|
164
|
+
let topHeight = 50;
|
165
|
+
let bottomHeight = 50;
|
166
|
+
|
167
|
+
// Subscribe to store changes
|
168
|
+
resizeStore.subscribe((state) => {
|
169
|
+
leftWidth = state.leftWidth;
|
170
|
+
rightWidth = state.rightWidth;
|
171
|
+
topHeight = state.topHeight;
|
172
|
+
bottomHeight = state.bottomHeight;
|
173
|
+
});
|
174
|
+
|
175
|
+
function handleResize(event: CustomEvent) {
|
176
|
+
const { horizontalSize, verticalSize } = event.detail;
|
177
|
+
resizeStore.update2D(horizontalSize, verticalSize);
|
178
|
+
}
|
179
|
+
</script>
|
180
|
+
|
181
|
+
<div class="desktop" style="grid-template-columns: {leftWidth}% {rightWidth}%; grid-template-rows: {topHeight}% {bottomHeight}%">
|
182
|
+
<Quarter position="left" {topHeight} {bottomHeight}>
|
183
|
+
<Chart slot="top-or-left" />
|
184
|
+
<List slot="bottom-or-right" />
|
185
|
+
</Quarter>
|
186
|
+
|
187
|
+
<Quarter position="right" {topHeight} {bottomHeight}>
|
188
|
+
<Form slot="top-or-left" />
|
189
|
+
<Text slot="bottom-or-right" />
|
190
|
+
</Quarter>
|
191
|
+
|
192
|
+
<ResizeHandle
|
193
|
+
position="center"
|
194
|
+
horizontalSize={leftWidth}
|
195
|
+
verticalSize={topHeight}
|
196
|
+
on:resize={handleResize}
|
197
|
+
/>
|
198
|
+
</div>
|
199
|
+
```
|
200
|
+
|
201
|
+
### Left Half + Right Quarters with Resizing
|
202
|
+
|
203
|
+
```svelte
|
204
|
+
<div class="desktop" style="grid-template-columns: {leftWidth}% {rightWidth}%; grid-template-rows: {topHeight}% {bottomHeight}%">
|
205
|
+
<Half position="left">
|
206
|
+
<Chart />
|
207
|
+
</Half>
|
208
|
+
|
209
|
+
<Quarter position="right" {topHeight} {bottomHeight}>
|
210
|
+
<Map slot="top-or-left" />
|
211
|
+
<Table slot="bottom-or-right" />
|
212
|
+
</Quarter>
|
213
|
+
|
214
|
+
<ResizeHandle
|
215
|
+
position="center"
|
216
|
+
horizontalSize={leftWidth}
|
217
|
+
verticalSize={topHeight}
|
218
|
+
on:resize={handleResize}
|
219
|
+
/>
|
220
|
+
</div>
|
221
|
+
```
|
222
|
+
|
223
|
+
## Visual Examples
|
224
|
+
|
225
|
+
### Dynamic Resizable Layout
|
226
|
+
```
|
227
|
+
+---------+----+ +-----+--+ +---+-----+
|
228
|
+
| | 25 | | |25| | | 75 |
|
229
|
+
| 50% +----+ → | 60% +--+ → |50%|+----+
|
230
|
+
| | 25 | | |25| | | 25 |
|
231
|
+
+---------+----+ +-----+--+ +---+-----+
|
232
|
+
```
|
233
|
+
|
234
|
+
### Desktop Container Setup
|
235
|
+
```css
|
236
|
+
.desktop {
|
237
|
+
display: grid;
|
238
|
+
/* Dynamic columns and rows controlled by store */
|
239
|
+
grid-template-columns: var(--left-width, 50%) var(--right-width, 50%);
|
240
|
+
grid-template-rows: var(--top-height, 50%) var(--bottom-height, 50%);
|
241
|
+
height: 100vh;
|
242
|
+
position: relative; /* For absolute positioned resize handle */
|
243
|
+
}
|
244
|
+
```
|
245
|
+
|
246
|
+
### Resize Handle Positioning
|
247
|
+
```css
|
248
|
+
.resize-handle.center {
|
249
|
+
position: absolute;
|
250
|
+
top: 50%;
|
251
|
+
left: 50%;
|
252
|
+
transform: translate(-50%, -50%);
|
253
|
+
z-index: 1000;
|
254
|
+
}
|
255
|
+
```
|
256
|
+
|
257
|
+
## Features
|
258
|
+
|
259
|
+
### ✅ Dynamic Resizing
|
260
|
+
- **ResizeHandle**: Interactive draggable handle for 2D resizing
|
261
|
+
- **Real-time Updates**: Components respond immediately to size changes
|
262
|
+
- **Constrained Values**: Automatic min/max limits (10%-90%)
|
263
|
+
- **Smooth Animation**: CSS transitions for visual feedback
|
264
|
+
|
265
|
+
### ✅ State Management
|
266
|
+
- **Shared Store**: Centralized resize state across all components
|
267
|
+
- **Reactive Updates**: Automatic UI updates when store changes
|
268
|
+
- **TypeScript Support**: Full type safety for resize operations
|
269
|
+
|
270
|
+
### ✅ Flexible Layouts
|
271
|
+
- **Dynamic Proportions**: Quarter components accept custom height ratios
|
272
|
+
- **Nested Components**: Combine Half and Quarter components freely
|
273
|
+
- **CSS Grid**: Modern layout system with full browser support
|
274
|
+
|
275
|
+
### ✅ Component Architecture
|
276
|
+
- **Slot-based**: Flexible content insertion with named slots
|
277
|
+
- **Composable**: Easy to combine and nest components
|
278
|
+
- **Accessible**: Proper ARIA labels and keyboard navigation
|
279
|
+
|
280
|
+
## Current Implementation Status
|
281
|
+
|
282
|
+
### ✅ Completed Features
|
283
|
+
- Half and Quarter layout components
|
284
|
+
- Interactive ResizeHandle with mouse/touch support
|
285
|
+
- Svelte store for state management
|
286
|
+
- Dynamic Quarter component proportions
|
287
|
+
- Test page with dummy components
|
288
|
+
- Full TypeScript support
|
289
|
+
- CSS Grid responsive layouts
|
290
|
+
|
291
|
+
### 🔄 Future Enhancements
|
292
|
+
- Add keyboard navigation for resize handles
|
293
|
+
- Implement maximize/fullscreen functionality
|
294
|
+
- Add animation presets for smooth transitions
|
295
|
+
- Create additional layout primitives (thirds, fifths)
|
296
|
+
- Add drag-to-resize from component edges
|
297
|
+
|
298
|
+
## Test Implementation
|
299
|
+
|
300
|
+
The system includes a comprehensive test page (`/src/routes/test/+page.svelte`) that demonstrates:
|
301
|
+
|
302
|
+
### Dummy Components
|
303
|
+
- **Chart**: Interactive bar chart with customizable data
|
304
|
+
- **List**: Task list with checkboxes for project management
|
305
|
+
- **Form**: Working contact form with validation
|
306
|
+
- **Text**: Scrollable content area for documentation
|
307
|
+
|
308
|
+
### Test Features
|
309
|
+
- **Live Resizing**: Drag the center handle to resize all quadrants
|
310
|
+
- **Debug Info**: Real-time display of current proportions
|
311
|
+
- **Responsive Design**: Components adapt to size changes
|
312
|
+
- **Interactive Content**: All dummy components are fully functional
|
313
|
+
|
314
|
+
### Usage in Test
|
315
|
+
```svelte
|
316
|
+
<Quarter position="left" {topHeight} {bottomHeight}>
|
317
|
+
<Chart slot="top-or-left" title="Sales Analytics" data={[25, 45, 30, 60, 40]} />
|
318
|
+
<List slot="bottom-or-right" title="Project Tasks" items={["Design review", "Code review", "Testing", "Deployment"]} />
|
319
|
+
</Quarter>
|
320
|
+
|
321
|
+
<Quarter position="right" {topHeight} {bottomHeight}>
|
322
|
+
<Form slot="top-or-left" title="Contact Support" />
|
323
|
+
<Text slot="bottom-or-right" title="System Status" content="All systems operational..." />
|
324
|
+
</Quarter>
|
325
|
+
```
|
326
|
+
|
327
|
+
## Trade-offs
|
328
|
+
|
329
|
+
- May require more components than a single grid engine
|
330
|
+
- Resizing logic coordination may need shared state management
|
331
|
+
- Nesting complexity for very complex layouts
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
3
|
+
|
4
|
+
export let horizontalSize: number = 50;
|
5
|
+
export let verticalSize: number = 50;
|
6
|
+
|
7
|
+
const dispatch = createEventDispatcher();
|
8
|
+
|
9
|
+
let isDragging = false;
|
10
|
+
let startX = 0;
|
11
|
+
let startY = 0;
|
12
|
+
let startHorizontalSize = horizontalSize;
|
13
|
+
let startVerticalSize = verticalSize;
|
14
|
+
|
15
|
+
function handleMouseDown(event: MouseEvent) {
|
16
|
+
isDragging = true;
|
17
|
+
startX = event.clientX;
|
18
|
+
startY = event.clientY;
|
19
|
+
startHorizontalSize = horizontalSize;
|
20
|
+
startVerticalSize = verticalSize;
|
21
|
+
|
22
|
+
console.log('MouseDown:', { startX, startY, startHorizontalSize, startVerticalSize });
|
23
|
+
|
24
|
+
document.addEventListener('mousemove', handleMouseMove);
|
25
|
+
document.addEventListener('mouseup', handleMouseUp);
|
26
|
+
|
27
|
+
event.preventDefault();
|
28
|
+
}
|
29
|
+
|
30
|
+
function handleMouseMove(event: MouseEvent) {
|
31
|
+
if (!isDragging) return;
|
32
|
+
|
33
|
+
const deltaX = event.clientX - startX;
|
34
|
+
const deltaY = event.clientY - startY;
|
35
|
+
|
36
|
+
console.log('MouseMove:', { deltaX, deltaY });
|
37
|
+
|
38
|
+
// Always calculate both dimensions - let the layout decide what to do
|
39
|
+
const newHorizontalSize = Math.max(10, Math.min(90, startHorizontalSize + (deltaX / 4)));
|
40
|
+
const newVerticalSize = Math.max(10, Math.min(90, startVerticalSize + (deltaY / 4)));
|
41
|
+
|
42
|
+
console.log('Resize:', { newHorizontalSize, newVerticalSize });
|
43
|
+
|
44
|
+
dispatch('resize', {
|
45
|
+
horizontalSize: newHorizontalSize,
|
46
|
+
verticalSize: newVerticalSize
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
function handleMouseUp() {
|
51
|
+
console.log('MouseUp - stopping drag');
|
52
|
+
isDragging = false;
|
53
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
54
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
55
|
+
}
|
56
|
+
|
57
|
+
$: cursorStyle = isDragging ? 'move' : 'move';
|
58
|
+
|
59
|
+
$: dynamicPosition = {
|
60
|
+
left: `${horizontalSize}%`,
|
61
|
+
top: `${verticalSize}%`,
|
62
|
+
transform: 'translate(-50%, -50%)'
|
63
|
+
};
|
64
|
+
</script>
|
65
|
+
|
66
|
+
<div
|
67
|
+
class="resize-handle"
|
68
|
+
class:dragging={isDragging}
|
69
|
+
style="cursor: {cursorStyle}; left: {dynamicPosition.left}; top: {dynamicPosition.top}; transform: {dynamicPosition.transform}"
|
70
|
+
on:mousedown={handleMouseDown}
|
71
|
+
role="button"
|
72
|
+
tabindex="0"
|
73
|
+
aria-label="Resize handle"
|
74
|
+
>
|
75
|
+
<div class="handle-indicator"></div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<style>
|
79
|
+
.resize-handle {
|
80
|
+
position: absolute;
|
81
|
+
z-index: 1000;
|
82
|
+
background: rgba(255, 255, 255, 0.9);
|
83
|
+
border: 2px solid #007acc;
|
84
|
+
border-radius: 50%;
|
85
|
+
width: 20px;
|
86
|
+
height: 20px;
|
87
|
+
display: flex;
|
88
|
+
align-items: center;
|
89
|
+
justify-content: center;
|
90
|
+
transition: all 0.2s ease;
|
91
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
92
|
+
}
|
93
|
+
|
94
|
+
.resize-handle:hover {
|
95
|
+
transform: scale(1.1);
|
96
|
+
background: rgba(255, 255, 255, 1);
|
97
|
+
}
|
98
|
+
|
99
|
+
.resize-handle.dragging {
|
100
|
+
transform: scale(1.2);
|
101
|
+
background: #007acc;
|
102
|
+
border-color: #005999;
|
103
|
+
}
|
104
|
+
|
105
|
+
.handle-indicator {
|
106
|
+
width: 8px;
|
107
|
+
height: 8px;
|
108
|
+
background: #007acc;
|
109
|
+
border-radius: 50%;
|
110
|
+
transition: background-color 0.2s ease;
|
111
|
+
}
|
112
|
+
|
113
|
+
.resize-handle.dragging .handle-indicator {
|
114
|
+
background: white;
|
115
|
+
}
|
116
|
+
|
117
|
+
/* Dynamic positioning handled via inline styles */
|
118
|
+
</style>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
3
|
+
$$bindings?: Bindings;
|
4
|
+
} & Exports;
|
5
|
+
(internal: unknown, props: Props & {
|
6
|
+
$$events?: Events;
|
7
|
+
$$slots?: Slots;
|
8
|
+
}): Exports & {
|
9
|
+
$set?: any;
|
10
|
+
$on?: any;
|
11
|
+
};
|
12
|
+
z_$$bindings?: Bindings;
|
13
|
+
}
|
14
|
+
declare const ResizeHandle: $$__sveltets_2_IsomorphicComponent<{
|
15
|
+
horizontalSize?: number;
|
16
|
+
verticalSize?: number;
|
17
|
+
}, {
|
18
|
+
resize: CustomEvent<any>;
|
19
|
+
} & {
|
20
|
+
[evt: string]: CustomEvent<any>;
|
21
|
+
}, {}, {}, string>;
|
22
|
+
type ResizeHandle = InstanceType<typeof ResizeHandle>;
|
23
|
+
export default ResizeHandle;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export interface ResizeState {
|
2
|
+
leftWidth: number;
|
3
|
+
rightWidth: number;
|
4
|
+
topHeight: number;
|
5
|
+
bottomHeight: number;
|
6
|
+
quarterSplit: number;
|
7
|
+
}
|
8
|
+
export declare const resizeStore: {
|
9
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<ResizeState>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
10
|
+
set: (this: void, value: ResizeState) => void;
|
11
|
+
update: (this: void, updater: import("svelte/store").Updater<ResizeState>) => void;
|
12
|
+
reset: () => void;
|
13
|
+
updateLeftWidth: (width: number) => void;
|
14
|
+
updateTopHeight: (height: number) => void;
|
15
|
+
update2D: (horizontalSize: number, verticalSize: number) => void;
|
16
|
+
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { writable } from 'svelte/store';
|
2
|
+
function createResizeStore() {
|
3
|
+
const initialState = {
|
4
|
+
leftWidth: 50,
|
5
|
+
rightWidth: 50,
|
6
|
+
topHeight: 50,
|
7
|
+
bottomHeight: 50,
|
8
|
+
quarterSplit: 50
|
9
|
+
};
|
10
|
+
const { subscribe, set, update } = writable(initialState);
|
11
|
+
return {
|
12
|
+
subscribe,
|
13
|
+
set,
|
14
|
+
update,
|
15
|
+
reset: () => set(initialState),
|
16
|
+
updateLeftWidth: (width) => update(state => ({
|
17
|
+
...state,
|
18
|
+
leftWidth: Math.max(10, Math.min(90, width)),
|
19
|
+
rightWidth: 100 - Math.max(10, Math.min(90, width))
|
20
|
+
})),
|
21
|
+
updateTopHeight: (height) => update(state => ({
|
22
|
+
...state,
|
23
|
+
topHeight: Math.max(10, Math.min(90, height)),
|
24
|
+
bottomHeight: 100 - Math.max(10, Math.min(90, height))
|
25
|
+
})),
|
26
|
+
update2D: (horizontalSize, verticalSize) => update(state => {
|
27
|
+
const newState = {
|
28
|
+
...state,
|
29
|
+
leftWidth: Math.max(10, Math.min(90, horizontalSize)),
|
30
|
+
rightWidth: 100 - Math.max(10, Math.min(90, horizontalSize)),
|
31
|
+
topHeight: Math.max(10, Math.min(90, verticalSize)),
|
32
|
+
bottomHeight: 100 - Math.max(10, Math.min(90, verticalSize))
|
33
|
+
};
|
34
|
+
console.log('Store update2D:', { horizontalSize, verticalSize, newState });
|
35
|
+
return newState;
|
36
|
+
})
|
37
|
+
};
|
38
|
+
}
|
39
|
+
export const resizeStore = createResizeStore();
|