|
2 | 2 | <!-- |
3 | 3 | YASGUI Table Plugin - Demo Page |
4 | 4 | |
5 | | - Demonstrates the advanced table plugin for YASGUI with virtual scrolling, |
6 | | - search, filtering, column management, cell selection, and export features. |
| 5 | + This demo automatically detects the environment: |
| 6 | + - Development (localhost/file): Loads ES modules from src/ for live reload |
| 7 | + - Production (GitHub Pages): Loads minified bundle from dist/ |
| 8 | + |
| 9 | + To develop locally: Open this file directly or run: npm run dev |
| 10 | + For production builds: npm run build |
7 | 11 | --> |
8 | 12 | <html lang="en"> |
9 | 13 | <head> |
|
12 | 16 | <title>YASGUI Table Plugin Demo</title> |
13 | 17 |
|
14 | 18 | <!-- YASGUI CSS --> |
15 | | - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.5.0/build/yasgui.min.css"> |
| 19 | + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.css"> |
16 | 20 |
|
17 | 21 | <!-- Table Plugin CSS --> |
18 | 22 | <link rel="stylesheet" href="../dist/table-plugin.css"> |
|
98 | 102 | box-shadow: 0 2px 8px rgba(0,0,0,0.1); |
99 | 103 | } |
100 | 104 | </style> |
| 105 | + |
101 | 106 | </head> |
102 | 107 | <body> |
103 | 108 | <h1>🔷 YASGUI TABLE Plugin Demo</h1> |
@@ -133,34 +138,41 @@ <h2 onclick="toggleInstructions()"> |
133 | 138 | <div id="yasgui"></div> |
134 | 139 |
|
135 | 140 | <!-- YASGUI JavaScript --> |
136 | | - <script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.5.0/build/yasgui.min.js"></script> |
| 141 | + <script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui@5.6.0/build/yasgui.min.js"></script> |
137 | 142 |
|
138 | 143 | <!-- Table Plugin JavaScript --> |
139 | 144 | <!-- Vite will automatically replace this with ES modules during dev, or use the built version for production --> |
140 | 145 | <script type="module"> |
141 | 146 | // Detect if running in Vite dev server (module system available) |
142 | 147 | const isViteDev = import.meta.env?.DEV; |
143 | 148 |
|
| 149 | + let pluginLoaded = false; |
| 150 | + |
144 | 151 | if (isViteDev) { |
145 | 152 | // Development mode: Load plugin from source |
146 | | - const { TablePlugin } = await import('@matdata/yasgui-table-plugin'); |
| 153 | + const { default: TablePlugin } = await import('@matdata/yasgui-table-plugin'); |
147 | 154 | window.YasguiTablePlugin = { TablePlugin }; |
| 155 | + pluginLoaded = true; |
148 | 156 | console.log('✅ Table Plugin loaded from source (Vite dev mode)'); |
149 | | - } else { |
150 | | - // Production mode: Load from built UMD bundle |
151 | | - // This runs when opening index.html directly in browser |
152 | | - if (!window.YasguiTablePlugin) { |
153 | | - const script = document.createElement('script'); |
154 | | - script.src = '../dist/table-plugin.umd.js'; |
155 | | - await new Promise((resolve, reject) => { |
156 | | - script.onload = resolve; |
157 | | - script.onerror = reject; |
158 | | - document.head.appendChild(script); |
159 | | - }); |
160 | | - console.log('✅ Table Plugin loaded from bundle (production mode)'); |
161 | | - } |
162 | | - } |
| 157 | + } |
163 | 158 |
|
| 159 | + // In production mode or if dev load failed, load the bundle |
| 160 | + if (!pluginLoaded) { |
| 161 | + const script = document.createElement('script'); |
| 162 | + await new Promise((resolve, reject) => { |
| 163 | + script.onload = () => { |
| 164 | + console.log('✅ Table Plugin loaded from bundle (production mode)'); |
| 165 | + resolve(); |
| 166 | + }; |
| 167 | + script.onerror = () => { |
| 168 | + console.error('❌ Failed to load Table Plugin bundle'); |
| 169 | + reject(); |
| 170 | + }; |
| 171 | + document.head.appendChild(script); |
| 172 | + script.src = './dist/yasgui-table-plugin.min.js'; |
| 173 | + }); |
| 174 | + } |
| 175 | + |
164 | 176 | // Initialize demo after plugin is loaded |
165 | 177 | // Sample SELECT queries for testing the table plugin |
166 | 178 | const queries = { |
|
0 commit comments