@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.
Files changed (39) hide show
  1. package/dist/Desktop/Desktop.svelte +423 -0
  2. package/dist/Desktop/Desktop.svelte.d.ts +26 -0
  3. package/dist/Desktop/Grid/Half.svelte +50 -0
  4. package/dist/Desktop/Grid/Half.svelte.d.ts +29 -0
  5. package/dist/Desktop/Grid/Quarter.svelte +103 -0
  6. package/dist/Desktop/Grid/Quarter.svelte.d.ts +27 -0
  7. package/dist/Desktop/Grid/README.md +331 -0
  8. package/dist/Desktop/Grid/ResizeHandle.svelte +118 -0
  9. package/dist/Desktop/Grid/ResizeHandle.svelte.d.ts +23 -0
  10. package/dist/Desktop/Grid/index.d.ts +4 -0
  11. package/dist/Desktop/Grid/index.js +4 -0
  12. package/dist/Desktop/Grid/resizeStore.d.ts +16 -0
  13. package/dist/Desktop/Grid/resizeStore.js +39 -0
  14. package/dist/Desktop/GridRenderer.svelte +328 -0
  15. package/dist/Desktop/GridRenderer.svelte.d.ts +25 -0
  16. package/dist/Desktop/GridSelector/ComponentPalette.svelte +243 -0
  17. package/dist/Desktop/GridSelector/ComponentPalette.svelte.d.ts +27 -0
  18. package/dist/Desktop/GridSelector/ConfigurationPanel.svelte +242 -0
  19. package/dist/Desktop/GridSelector/ConfigurationPanel.svelte.d.ts +28 -0
  20. package/dist/Desktop/GridSelector/GridSelector.svelte +232 -0
  21. package/dist/Desktop/GridSelector/GridSelector.svelte.d.ts +43 -0
  22. package/dist/Desktop/GridSelector/LayoutPicker.svelte +241 -0
  23. package/dist/Desktop/GridSelector/LayoutPicker.svelte.d.ts +28 -0
  24. package/dist/Desktop/GridSelector/LayoutPreview.svelte +309 -0
  25. package/dist/Desktop/GridSelector/LayoutPreview.svelte.d.ts +32 -0
  26. package/dist/Desktop/GridSelector/index.d.ts +4 -0
  27. package/dist/Desktop/GridSelector/index.js +4 -0
  28. package/dist/Desktop/GridViewer.svelte +125 -0
  29. package/dist/Desktop/GridViewer.svelte.d.ts +21 -0
  30. package/dist/Desktop/README.md +279 -0
  31. package/dist/Desktop/gridLayouts.d.ts +76 -0
  32. package/dist/Desktop/gridLayouts.js +351 -0
  33. package/dist/Desktop/index.d.ts +7 -0
  34. package/dist/Desktop/index.js +7 -0
  35. package/dist/Desktop/launchHelpers.d.ts +25 -0
  36. package/dist/Desktop/launchHelpers.js +77 -0
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +1 -0
  39. package/package.json +65 -0
@@ -0,0 +1,125 @@
1
+ <script lang="ts">
2
+ /**
3
+ * GridViewer Component
4
+ *
5
+ * Standalone component for viewing grids in fullscreen mode.
6
+ * Reads grid configuration from localStorage and renders using GridRenderer.
7
+ * Used in dedicated routes for new window/tab grid viewing.
8
+ */
9
+ import { onMount } from 'svelte';
10
+ import { GridRenderer } from './index.js';
11
+ import type { GridConfiguration } from './gridLayouts.js';
12
+ import type { ComponentConfig } from './GridSelector/index.js';
13
+
14
+ // Accept available components as props
15
+ export let availableComponents: ComponentConfig[] = [];
16
+
17
+ let grid: GridConfiguration | null = null;
18
+ let componentMap: Record<string, any> = {};
19
+ let isLoading = true;
20
+ let error: string | null = null;
21
+
22
+ onMount(() => {
23
+ try {
24
+ const urlParams = new URLSearchParams(window.location.search);
25
+ const gridKey = urlParams.get('key');
26
+
27
+ if (gridKey) {
28
+ const storedData = localStorage.getItem(gridKey);
29
+ if (storedData) {
30
+ const data = JSON.parse(storedData);
31
+ grid = data.grid;
32
+
33
+ // Build componentMap from available components
34
+ componentMap = availableComponents.reduce((map, comp) => {
35
+ map[comp.id] = comp.component;
36
+ return map;
37
+ }, {} as Record<string, any>);
38
+
39
+ // Clean up localStorage
40
+ localStorage.removeItem(gridKey);
41
+ } else {
42
+ error = 'Grid data not found or expired';
43
+ }
44
+ } else {
45
+ error = 'No grid key provided';
46
+ }
47
+ } catch (err) {
48
+ error = 'Failed to load grid configuration';
49
+ console.error('GridViewer error:', err);
50
+ } finally {
51
+ isLoading = false;
52
+ }
53
+ });
54
+ </script>
55
+
56
+ <svelte:head>
57
+ <title>{grid ? grid.name : 'Grid Viewer'}</title>
58
+ <style>
59
+ body {
60
+ margin: 0;
61
+ padding: 0;
62
+ overflow: hidden;
63
+ }
64
+ </style>
65
+ </svelte:head>
66
+
67
+ {#if isLoading}
68
+ <div class="loading-screen">
69
+ <div class="loading-content">
70
+ <div class="spinner-border text-primary" role="status">
71
+ <span class="visually-hidden">Loading...</span>
72
+ </div>
73
+ <p class="mt-3">Loading grid...</p>
74
+ </div>
75
+ </div>
76
+ {:else if error}
77
+ <div class="error-screen">
78
+ <div class="error-content">
79
+ <div class="error-icon">⚠️</div>
80
+ <h3>Grid Not Found</h3>
81
+ <p class="text-muted">{error}</p>
82
+ <button class="btn btn-primary" on:click={() => window.close()}>
83
+ Close Window
84
+ </button>
85
+ </div>
86
+ </div>
87
+ {:else if grid}
88
+ <GridRenderer {grid} {componentMap} fullscreen={true} enableResize={true} />
89
+ {:else}
90
+ <div class="error-screen">
91
+ <div class="error-content">
92
+ <div class="error-icon">🤷</div>
93
+ <h3>No Grid Available</h3>
94
+ <p class="text-muted">No grid configuration available to display</p>
95
+ </div>
96
+ </div>
97
+ {/if}
98
+
99
+ <style>
100
+ .loading-screen,
101
+ .error-screen {
102
+ height: 100vh;
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ background: #f8f9fa;
107
+ }
108
+
109
+ .loading-content,
110
+ .error-content {
111
+ text-align: center;
112
+ max-width: 400px;
113
+ padding: 2rem;
114
+ }
115
+
116
+ .error-icon {
117
+ font-size: 4rem;
118
+ margin-bottom: 1rem;
119
+ }
120
+
121
+ .spinner-border {
122
+ width: 3rem;
123
+ height: 3rem;
124
+ }
125
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { ComponentConfig } from './GridSelector/index.js';
2
+ 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> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const GridViewer: $$__sveltets_2_IsomorphicComponent<{
16
+ availableComponents?: ComponentConfig[];
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type GridViewer = InstanceType<typeof GridViewer>;
21
+ export default GridViewer;
@@ -0,0 +1,279 @@
1
+ # Desktop Component - Grid Orchestrator
2
+
3
+ ## Overview
4
+
5
+ The **Desktop component** acts as a powerful orchestrator for managing multiple grid layouts within your application. It serves as a launchpad that allows users to create, configure, and switch between different grid-based layouts, each containing various components.
6
+
7
+ ## Architecture
8
+
9
+ ### Core Components
10
+
11
+ 1. **Desktop (Launcher)** - Main orchestrator component
12
+ 2. **Grid Selector** - Configuration interface for creating new grids
13
+ 3. **Grid** - Individual layout engine (implemented in `/Grid/`)
14
+
15
+ ### How It Works
16
+
17
+ ```
18
+ Desktop (Orchestrator)
19
+ ├── Stores multiple grid configurations
20
+ ├── Displays launcher interface
21
+ └── Manages grid lifecycle
22
+
23
+ Grid Selector
24
+ ├── Layout type selection
25
+ ├── Component assignment
26
+ └── Grid naming
27
+
28
+ Grid (Layout Engine)
29
+ ├── Renders chosen layout
30
+ ├── Handles component placement
31
+ └── Supports resizing & fullscreen
32
+ ```
33
+
34
+ ## Features
35
+
36
+ ### ✅ Multi-Grid Management
37
+ - **Grid Storage**: Persists multiple grid configurations with unique names
38
+ - **Launcher View**: Visual interface showing all available grids
39
+ - **Grid Switching**: Seamless switching between different layouts
40
+
41
+ ### ✅ Grid Creation & Configuration
42
+ - **Layout Types**: Pre-built options (half-half, half+quarters, etc.)
43
+ - **Component Assignment**: Drag-and-drop component placement into grid cells
44
+ - **Custom Naming**: User-defined names for each grid configuration
45
+
46
+ ### ✅ Reusability & Isolation
47
+ - **Namespace Support**: App-specific prefixes for data isolation
48
+ - **Component Injection**: Parent app provides available components
49
+ - **State Management**: Isolated settings per application instance
50
+
51
+ ## Usage
52
+
53
+ ### Basic Setup
54
+
55
+ ```svelte
56
+ <script lang="ts">
57
+ import { Desktop } from '$lib/Desktop/index.js';
58
+
59
+ // Available components for grid cells
60
+ const availableComponents = [
61
+ { id: 'chart', name: 'Chart', component: Chart },
62
+ { id: 'list', name: 'Task List', component: List },
63
+ { id: 'form', name: 'Contact Form', component: Form }
64
+ ];
65
+
66
+ // App-specific namespace
67
+ const namespace = 'myApp-desktop';
68
+ </script>
69
+
70
+ <Desktop {availableComponents} {namespace} />
71
+ ```
72
+
73
+ ### Component Registration
74
+
75
+ ```typescript
76
+ const availableComponents = [
77
+ {
78
+ id: 'chart',
79
+ name: 'Analytics Chart',
80
+ component: ChartComponent,
81
+ icon: '📊',
82
+ description: 'Data visualization component'
83
+ },
84
+ {
85
+ id: 'tasks',
86
+ name: 'Task Manager',
87
+ component: TaskListComponent,
88
+ icon: '✅',
89
+ description: 'Project task management'
90
+ }
91
+ ];
92
+ ```
93
+
94
+ ## Grid Layout Types
95
+
96
+ ### Built-in Layouts
97
+
98
+ 1. **Half-Half** - Two equal vertical sections
99
+ 2. **Half+Quarters** - Left half + right stacked quarters
100
+ 3. **Quarters+Half** - Left stacked quarters + right half
101
+ 4. **All-Quarters** - Four equal quadrants
102
+
103
+ ### Custom Layouts
104
+
105
+ The system supports extending with custom layout types by implementing the Grid interface.
106
+
107
+ ## Data Management
108
+
109
+ ### Namespace Isolation
110
+
111
+ ```typescript
112
+ // Each app gets its own data space
113
+ const namespace = 'myApp-desktop';
114
+
115
+ // Data is stored as:
116
+ // myApp-desktop:grids
117
+ // myApp-desktop:settings
118
+ // myApp-desktop:layouts
119
+ ```
120
+
121
+ ### Grid Configuration Storage
122
+
123
+ ```json
124
+ {
125
+ "id": "dashboard-grid",
126
+ "name": "Main Dashboard",
127
+ "layout": "half-quarters",
128
+ "components": {
129
+ "top-left": "chart",
130
+ "bottom-left": "tasks",
131
+ "top-right": "form",
132
+ "bottom-right": "text"
133
+ },
134
+ "created": "2025-01-15T10:30:00Z"
135
+ }
136
+ ```
137
+
138
+ ## API Reference
139
+
140
+ ### Desktop Props
141
+
142
+ | Prop | Type | Required | Description |
143
+ |------|------|----------|-------------|
144
+ | `availableComponents` | `ComponentConfig[]` | ✅ | Components available for grid cells |
145
+ | `namespace` | `string` | ✅ | App-specific identifier for data isolation |
146
+ | `theme` | `string` | ❌ | Visual theme ('light', 'dark', 'auto') |
147
+ | `maxGrids` | `number` | ❌ | Maximum number of grids (default: 10) |
148
+
149
+ ### ComponentConfig Interface
150
+
151
+ ```typescript
152
+ interface ComponentConfig {
153
+ id: string; // Unique identifier
154
+ name: string; // Display name
155
+ component: any; // Svelte component
156
+ icon?: string; // Icon emoji or URL
157
+ description?: string; // Help text
158
+ category?: string; // Grouping category
159
+ }
160
+ ```
161
+
162
+ ## Integration Examples
163
+
164
+ ### With SvelteKit
165
+
166
+ ```svelte
167
+ <!-- +page.svelte -->
168
+ <script lang="ts">
169
+ import { Desktop } from '$lib/Desktop/index.js';
170
+ import { Chart, List, Form } from '$lib/components/index.js';
171
+
172
+ const components = [
173
+ { id: 'chart', name: 'Chart', component: Chart },
174
+ { id: 'list', name: 'List', component: List },
175
+ { id: 'form', name: 'Form', component: Form }
176
+ ];
177
+ </script>
178
+
179
+ <svelte:head>
180
+ <title>My App - Desktop</title>
181
+ </svelte:head>
182
+
183
+ <Desktop {components} namespace="my-svelte-app" />
184
+ ```
185
+
186
+ ### With Custom Components
187
+
188
+ ```svelte
189
+ <script lang="ts">
190
+ import { Desktop } from '$lib/Desktop/index.js';
191
+ import CustomChart from './components/CustomChart.svelte';
192
+ import UserProfile from './components/UserProfile.svelte';
193
+
194
+ const components = [
195
+ {
196
+ id: 'custom-chart',
197
+ name: 'Custom Analytics',
198
+ component: CustomChart,
199
+ icon: '📈',
200
+ category: 'Analytics'
201
+ },
202
+ {
203
+ id: 'user-profile',
204
+ name: 'User Profile',
205
+ component: UserProfile,
206
+ icon: '👤',
207
+ category: 'User Management'
208
+ }
209
+ ];
210
+ </script>
211
+
212
+ <Desktop {components} namespace="enterprise-app" />
213
+ ```
214
+
215
+ ## Current Implementation Status
216
+
217
+ ### ✅ Completed Features
218
+ - Grid layout engine with resizing
219
+ - Component assignment system
220
+ - Basic launcher interface
221
+ - Namespace-based data isolation
222
+
223
+ ### 🔄 In Development
224
+ - Visual grid selector interface
225
+ - Drag-and-drop component assignment
226
+ - Grid naming and management
227
+ - Advanced layout customization
228
+
229
+ ### 📋 Planned Features
230
+ - Grid templates and presets
231
+ - Component marketplace
232
+ - Grid sharing and export
233
+ - Advanced theming options
234
+
235
+ ## Best Practices
236
+
237
+ ### Component Design
238
+ - **Keep components focused** - Each component should have a single responsibility
239
+ - **Handle resize events** - Components should respond to container size changes
240
+ - **Use consistent APIs** - Follow established prop and event patterns
241
+
242
+ ### Performance
243
+ - **Lazy loading** - Load components only when needed
244
+ - **Memoization** - Cache expensive computations
245
+ - **Virtual scrolling** - For large component lists
246
+
247
+ ### User Experience
248
+ - **Clear naming** - Use descriptive names for grids and components
249
+ - **Visual feedback** - Show loading states and transitions
250
+ - **Error handling** - Graceful fallbacks for missing components
251
+
252
+ ## Troubleshooting
253
+
254
+ ### Common Issues
255
+
256
+ **Components not loading**
257
+ - Check component registration in `availableComponents`
258
+ - Verify component exports and imports
259
+
260
+ **Grid configurations not saving**
261
+ - Ensure namespace is properly set
262
+ - Check browser storage permissions
263
+
264
+ **Layout not responsive**
265
+ - Verify Grid component implementation
266
+ - Check CSS Grid support in target browsers
267
+
268
+ ## Contributing
269
+
270
+ When adding new features:
271
+
272
+ 1. **Follow the orchestrator pattern** - Desktop manages, Grid renders
273
+ 2. **Maintain namespace isolation** - All data operations use the provided namespace
274
+ 3. **Test component compatibility** - Ensure new components work with the Grid system
275
+ 4. **Update documentation** - Keep README and API docs current
276
+
277
+ ---
278
+
279
+ **Is this clear enough?** The Desktop component acts as an orchestrator that manages multiple Grid instances, providing a launcher interface for users to create, configure, and switch between different grid layouts. Each grid can contain different components arranged in various layout patterns, with all configurations isolated by namespace for multi-app reusability.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Grid Layout Configurations
3
+ *
4
+ * Defines all available grid layout types that can be created using the existing
5
+ * Half and Quarter components. Each layout specifies the component structure,
6
+ * slots for content assignment, and metadata for the Grid Selector.
7
+ */
8
+ export interface GridSlot {
9
+ id: string;
10
+ name: string;
11
+ description: string;
12
+ position: {
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ };
18
+ }
19
+ export interface GridLayoutDefinition {
20
+ id: string;
21
+ name: string;
22
+ description: string;
23
+ icon: string;
24
+ category: 'basic' | 'asymmetric' | 'symmetric';
25
+ slots: GridSlot[];
26
+ componentStructure: {
27
+ type: 'Half' | 'Quarter' | 'Container';
28
+ position?: 'left' | 'right' | 'top' | 'bottom';
29
+ children?: any[];
30
+ }[];
31
+ previewSvg: string;
32
+ }
33
+ export interface ComponentAssignment {
34
+ slotId: string;
35
+ componentId: string;
36
+ }
37
+ export interface GridConfiguration {
38
+ id: string;
39
+ name: string;
40
+ layoutId: string;
41
+ componentAssignments: ComponentAssignment[];
42
+ created: string;
43
+ modified: string;
44
+ }
45
+ /**
46
+ * All available grid layout definitions
47
+ * Based on the existing Half and Quarter components
48
+ */
49
+ export declare const GRID_LAYOUTS: Record<string, GridLayoutDefinition>;
50
+ /**
51
+ * Get layout by ID
52
+ */
53
+ export declare function getLayoutById(id: string): GridLayoutDefinition | undefined;
54
+ /**
55
+ * Get all layouts by category
56
+ */
57
+ export declare function getLayoutsByCategory(category: 'basic' | 'asymmetric' | 'symmetric'): GridLayoutDefinition[];
58
+ /**
59
+ * Get all available layouts
60
+ */
61
+ export declare function getAllLayouts(): GridLayoutDefinition[];
62
+ /**
63
+ * Get layouts ordered by complexity (basic -> asymmetric -> symmetric)
64
+ */
65
+ export declare function getLayoutsOrdered(): GridLayoutDefinition[];
66
+ /**
67
+ * Validate if a component assignment is complete
68
+ */
69
+ export declare function validateComponentAssignments(layoutId: string, assignments: ComponentAssignment[]): {
70
+ isValid: boolean;
71
+ missingSlots: string[];
72
+ };
73
+ /**
74
+ * Create a new grid configuration
75
+ */
76
+ export declare function createGridConfiguration(name: string, layoutId: string, assignments: ComponentAssignment[]): GridConfiguration;