@innovatorved/code-lab 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/README.md +38 -1
  4. package/dist/code-lab-sql.css +87 -64
  5. package/dist/code-lab-sql.esm.js +109 -86
  6. package/dist/code-lab-sql.umd.js +110 -87
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +19 -1
  9. package/dist/code-lab.esm.js +1261 -900
  10. package/dist/code-lab.js +1260 -899
  11. package/dist/code-lab.umd.js +1260 -899
  12. package/dist/extensions/cpp.esm.js +9 -0
  13. package/dist/extensions/cpp.js +9 -0
  14. package/dist/extensions/guided-lab.esm.js +9 -0
  15. package/dist/extensions/guided-lab.js +9 -0
  16. package/dist/extensions/python.esm.js +9 -0
  17. package/dist/extensions/python.js +9 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/packages/sql/src/styles.d.ts +1 -1
  20. package/dist/packages/ui/src/settings-dialog.d.ts +2 -0
  21. package/dist/preview-sw.js +1 -1
  22. package/dist/runtime.esm.js +70 -70
  23. package/dist/runtime.js +70 -70
  24. package/dist/schemas.d.ts +13 -1
  25. package/dist/schemas.esm.js +9 -0
  26. package/dist/schemas.js +9 -0
  27. package/dist/shell.esm.js +250 -244
  28. package/dist/shell.js +250 -244
  29. package/dist/terminal.esm.js +1 -1
  30. package/dist/terminal.js +1 -1
  31. package/dist/workbench/index.d.ts +1 -1
  32. package/dist/workbench/intellisense.d.ts +1 -1
  33. package/dist/workbench/styles.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/packages/commands/package.json +1 -1
  36. package/packages/core/package.json +1 -1
  37. package/packages/editor/package.json +1 -1
  38. package/packages/fs/package.json +1 -1
  39. package/packages/preview/package.json +1 -1
  40. package/packages/runtime/package.json +1 -1
  41. package/packages/settings/package.json +1 -1
  42. package/packages/settings/src/builtin-schemas.ts +16 -0
  43. package/packages/sql/package.json +1 -1
  44. package/packages/sql/src/styles.ts +87 -64
  45. package/packages/terminal/package.json +1 -1
  46. package/packages/ui/package.json +1 -1
  47. package/packages/ui/src/observability.ts +12 -14
  48. package/packages/ui/src/settings-dialog.ts +409 -57
  49. package/packages/ui/src/themes.ts +78 -78
  50. package/src/code-lab.css +757 -310
  51. package/src/index.ts +1 -1
  52. package/src/runtime.ts +29 -3
  53. package/src/schemas.ts +10 -1
  54. package/src/shell.ts +106 -16
  55. package/src/workbench/diff-editor.ts +5 -1
  56. package/src/workbench/drawer.ts +5 -5
  57. package/src/workbench/icons.ts +5 -5
  58. package/src/workbench/intellisense.ts +94 -82
  59. package/src/workbench/styles.ts +58 -54
  60. package/src/workbench/toolbar.ts +1 -1
  61. package/src/workbench/xterm-adapter.ts +61 -56
  62. package/src/workbench.ts +462 -173
@@ -41,18 +41,352 @@ const ALL_CATEGORIES: ReadonlyArray<'All' | SettingCategory> = [
41
41
  'SQL'
42
42
  ];
43
43
 
44
- const FONT_SANS =
45
- "var(--cl-font-sans,-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif)";
44
+ const SETTINGS_STYLE_ID = 'codelab-ui-settings-styles';
45
+
46
+ export const SETTINGS_COMPONENT_CSS = `/* @innovatorved/code-lab/ui — Tokenized Settings & Control Components */
47
+ .cl-settings-dialog,
48
+ .cl-settings-editor {
49
+ --cl-ui-sans: var(--cl-font-sans, var(--ds-font-sans, var(--font-sans, "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif)));
50
+ --cl-ui-mono: var(--cl-font-mono, var(--ds-font-mono, var(--font-mono, "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace)));
51
+ --cl-ui-text-2xs: var(--cl-text-2xs, var(--ds-text-2xs, 0.6875rem));
52
+ --cl-ui-text-xs: var(--cl-text-xs, var(--ds-text-xs, 0.75rem));
53
+ --cl-ui-text-sm: var(--cl-text-sm, var(--ds-text-sm, 0.8125rem));
54
+ --cl-ui-text-base: var(--cl-text-base, var(--ds-text-base, 0.875rem));
55
+ font-family: var(--cl-ui-sans);
56
+ color: var(--cl-fg, #f4f4f5);
57
+ }
58
+
59
+ .cl-settings-editor.cl-settings-inline {
60
+ display: flex;
61
+ flex-direction: column;
62
+ height: 100%;
63
+ min-height: 0;
64
+ background: var(--cl-editor-bg, var(--cl-bg, #0f0f10));
65
+ }
66
+
67
+ .cl-settings-header {
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: space-between;
71
+ gap: 12px;
72
+ padding: 12px 20px;
73
+ border-bottom: 1px solid var(--cl-border, #27272a);
74
+ background: var(--cl-surface, var(--cl-bg-elevated, #141415));
75
+ flex-wrap: wrap;
76
+ }
77
+
78
+ .cl-settings-title {
79
+ margin: 0;
80
+ font-size: var(--cl-ui-text-base);
81
+ font-weight: 600;
82
+ letter-spacing: -0.015em;
83
+ color: var(--cl-fg-active, var(--cl-fg, #f4f4f5));
84
+ }
85
+
86
+ .cl-settings-actions {
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 6px;
90
+ flex-wrap: wrap;
91
+ }
46
92
 
47
- const BTN_STYLE =
48
- 'padding:4px 10px;border-radius:2px;border:1px solid var(--cl-input-border,var(--cl-border,#3c3c3c));background:var(--cl-input-bg,#313131);color:var(--cl-fg,#cccccc);cursor:pointer;font-size:12px;font-family:' +
49
- FONT_SANS +
50
- ';line-height:18px;';
93
+ .cl-settings-toolbar {
94
+ padding: 12px 20px 0 20px;
95
+ border-bottom: 1px solid var(--cl-border, #27272a);
96
+ background: var(--cl-surface, var(--cl-bg-elevated, #141415));
97
+ display: flex;
98
+ flex-direction: column;
99
+ gap: 10px;
100
+ }
101
+
102
+ .cl-settings-search {
103
+ width: 100%;
104
+ height: 32px;
105
+ padding: 0 10px;
106
+ border-radius: var(--cl-radius-md, 6px);
107
+ border: 1px solid var(--cl-input-border, var(--cl-border, #27272a));
108
+ background: var(--cl-input-bg, var(--cl-bg, #0f0f10));
109
+ color: var(--cl-fg, #f4f4f5);
110
+ font-family: var(--cl-ui-sans);
111
+ font-size: var(--cl-ui-text-sm);
112
+ outline: none;
113
+ transition: border-color 120ms ease;
114
+ }
51
115
 
52
- const CONTROL_STYLE =
53
- 'padding:4px 8px;border-radius:2px;border:1px solid var(--cl-input-border,var(--cl-border,#3c3c3c));background:var(--cl-input-bg,#313131);color:var(--cl-fg,#cccccc);font-size:13px;font-family:' +
54
- FONT_SANS +
55
- ';line-height:18px;';
116
+ .cl-settings-search::placeholder {
117
+ color: var(--cl-fg-faint, var(--cl-fg-muted, #8e8e97));
118
+ }
119
+
120
+ .cl-settings-search:focus {
121
+ border-color: var(--cl-focus-border, #a1a1aa);
122
+ }
123
+
124
+ .cl-settings-scopes {
125
+ display: flex;
126
+ align-items: center;
127
+ gap: 4px;
128
+ overflow-x: auto;
129
+ }
130
+
131
+ .cl-settings-scope-tab {
132
+ flex: none;
133
+ padding: 6px 12px;
134
+ border: none;
135
+ border-bottom: 2px solid transparent;
136
+ background: transparent;
137
+ color: var(--cl-fg-muted, #a1a1aa);
138
+ font-family: var(--cl-ui-sans);
139
+ font-size: var(--cl-ui-text-xs);
140
+ font-weight: 500;
141
+ cursor: pointer;
142
+ transition: color 120ms ease, border-color 120ms ease;
143
+ }
144
+
145
+ .cl-settings-scope-tab:hover {
146
+ color: var(--cl-fg, #f4f4f5);
147
+ }
148
+
149
+ .cl-settings-scope-tab[aria-selected="true"] {
150
+ color: var(--cl-fg-active, var(--cl-fg, #f4f4f5));
151
+ font-weight: 600;
152
+ border-bottom-color: var(--cl-accent, #f4f4f5);
153
+ }
154
+
155
+ .cl-settings-body {
156
+ display: grid;
157
+ grid-template-columns: 180px minmax(0, 1fr);
158
+ }
159
+
160
+ .cl-settings-body--dialog {
161
+ min-height: 320px;
162
+ max-height: 62vh;
163
+ }
164
+
165
+ .cl-settings-body--inline {
166
+ flex: 1;
167
+ min-height: 0;
168
+ overflow: hidden;
169
+ }
170
+
171
+ .cl-settings-categories {
172
+ border-right: 1px solid var(--cl-border, #27272a);
173
+ background: var(--cl-surface, var(--cl-bg-elevated, #141415));
174
+ padding: 10px 8px;
175
+ display: flex;
176
+ flex-direction: column;
177
+ gap: 2px;
178
+ overflow-y: auto;
179
+ }
180
+
181
+ .cl-settings-cat-btn {
182
+ text-align: left;
183
+ padding: 6px 10px;
184
+ border: 1px solid transparent;
185
+ border-radius: var(--cl-radius-md, 6px);
186
+ background: transparent;
187
+ color: var(--cl-fg-muted, #a1a1aa);
188
+ font-family: var(--cl-ui-sans);
189
+ font-size: var(--cl-ui-text-sm);
190
+ font-weight: 500;
191
+ line-height: 1.35;
192
+ cursor: pointer;
193
+ transition: background 120ms ease, color 120ms ease;
194
+ }
195
+
196
+ .cl-settings-cat-btn:hover {
197
+ background: var(--cl-list-hover, var(--cl-bg-hover, #1f1f22));
198
+ color: var(--cl-fg, #f4f4f5);
199
+ }
200
+
201
+ .cl-settings-cat-btn[aria-current="true"] {
202
+ background: var(--cl-list-active, var(--cl-bg-active, #28282b));
203
+ color: var(--cl-list-active-fg, var(--cl-fg, #f4f4f5));
204
+ font-weight: 600;
205
+ }
206
+
207
+ .cl-settings-list {
208
+ padding: 14px 24px 28px 20px;
209
+ overflow-y: auto;
210
+ display: flex;
211
+ flex-direction: column;
212
+ gap: 8px;
213
+ }
214
+
215
+ .cl-settings-empty {
216
+ padding: 16px 4px;
217
+ color: var(--cl-fg-muted, #a1a1aa);
218
+ font-size: var(--cl-ui-text-sm);
219
+ }
220
+
221
+ .cl-setting-item {
222
+ padding: 14px 16px;
223
+ border: 1px solid var(--cl-border, #27272a);
224
+ border-radius: var(--cl-radius-lg, 8px);
225
+ background: var(--cl-widget-bg, var(--cl-bg-panel, #18181a));
226
+ display: flex;
227
+ flex-direction: column;
228
+ gap: 6px;
229
+ transition: border-color 120ms ease;
230
+ }
231
+
232
+ .cl-setting-item--modified {
233
+ border-color: var(--cl-border-strong, #3a3a3e);
234
+ }
235
+
236
+ .cl-setting-item__top {
237
+ display: flex;
238
+ align-items: center;
239
+ justify-content: space-between;
240
+ gap: 12px;
241
+ flex-wrap: wrap;
242
+ }
243
+
244
+ .cl-setting-item__heading {
245
+ display: flex;
246
+ align-items: center;
247
+ gap: 6px;
248
+ flex-wrap: wrap;
249
+ min-width: 0;
250
+ }
251
+
252
+ .cl-setting-item__cat {
253
+ font-size: var(--cl-ui-text-xs);
254
+ color: var(--cl-fg-muted, #a1a1aa);
255
+ font-weight: 500;
256
+ }
257
+
258
+ .cl-setting-item__title {
259
+ font-size: var(--cl-ui-text-sm);
260
+ font-weight: 600;
261
+ color: var(--cl-fg-active, var(--cl-fg, #f4f4f5));
262
+ }
263
+
264
+ .cl-setting-item__key {
265
+ font-family: var(--cl-ui-mono);
266
+ font-size: var(--cl-ui-text-2xs);
267
+ padding: 1px 5px;
268
+ border-radius: var(--cl-radius-sm, 4px);
269
+ border: 1px solid var(--cl-border, #27272a);
270
+ background: var(--cl-input-bg, var(--cl-bg, #0f0f10));
271
+ color: var(--cl-fg-muted, #a1a1aa);
272
+ }
273
+
274
+ .cl-setting-badge {
275
+ font-family: var(--cl-ui-mono);
276
+ font-size: var(--cl-ui-text-2xs);
277
+ font-weight: 600;
278
+ padding: 1px 6px;
279
+ border-radius: 999px;
280
+ background: var(--cl-btn-primary-bg, var(--cl-accent, #f4f4f5));
281
+ color: var(--cl-btn-primary-fg, var(--cl-accent-fg, #0f0f10));
282
+ }
283
+
284
+ .cl-setting-item__desc {
285
+ font-size: var(--cl-ui-text-xs);
286
+ line-height: 1.5;
287
+ color: var(--cl-fg-muted, #a1a1aa);
288
+ }
289
+
290
+ .cl-setting-item__control {
291
+ display: flex;
292
+ align-items: center;
293
+ gap: 8px;
294
+ margin-top: 2px;
295
+ }
296
+
297
+ .cl-ui-btn {
298
+ display: inline-flex;
299
+ align-items: center;
300
+ justify-content: center;
301
+ gap: 6px;
302
+ height: 28px;
303
+ padding: 0 10px;
304
+ border-radius: var(--cl-radius-md, 6px);
305
+ border: 1px solid var(--cl-input-border, var(--cl-border, #27272a));
306
+ background: var(--cl-input-bg, var(--cl-bg, #0f0f10));
307
+ color: var(--cl-fg, #f4f4f5);
308
+ font-family: var(--cl-ui-sans);
309
+ font-size: var(--cl-ui-text-xs);
310
+ font-weight: 500;
311
+ line-height: 1;
312
+ cursor: pointer;
313
+ transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
314
+ }
315
+
316
+ .cl-ui-btn:hover {
317
+ background: var(--cl-list-hover, var(--cl-bg-hover, #1f1f22));
318
+ border-color: var(--cl-border-strong, #3a3a3e);
319
+ }
320
+
321
+ .cl-ui-control {
322
+ height: 30px;
323
+ padding: 0 9px;
324
+ border-radius: var(--cl-radius-md, 6px);
325
+ border: 1px solid var(--cl-input-border, var(--cl-border, #27272a));
326
+ background: var(--cl-input-bg, var(--cl-bg, #0f0f10));
327
+ color: var(--cl-fg, #f4f4f5);
328
+ font-family: var(--cl-ui-sans);
329
+ font-size: var(--cl-ui-text-sm);
330
+ outline: none;
331
+ transition: border-color 120ms ease;
332
+ }
333
+
334
+ .cl-ui-control:focus {
335
+ border-color: var(--cl-focus-border, #a1a1aa);
336
+ }
337
+
338
+ .cl-ui-control--num {
339
+ width: 104px;
340
+ font-family: var(--cl-ui-mono);
341
+ font-variant-numeric: tabular-nums;
342
+ }
343
+
344
+ .cl-ui-control--array {
345
+ width: min(280px, 100%);
346
+ font-family: var(--cl-ui-mono);
347
+ font-size: var(--cl-ui-text-xs);
348
+ }
349
+
350
+ .cl-ui-control--text {
351
+ width: min(200px, 100%);
352
+ }
353
+
354
+ .cl-ui-checkbox {
355
+ width: 16px;
356
+ height: 16px;
357
+ accent-color: var(--cl-accent, #f4f4f5);
358
+ cursor: pointer;
359
+ }
360
+
361
+ @media (max-width: 640px) {
362
+ .cl-settings-body {
363
+ grid-template-columns: minmax(0, 1fr);
364
+ }
365
+ .cl-settings-categories {
366
+ flex-direction: row;
367
+ border-right: none;
368
+ border-bottom: 1px solid var(--cl-border, #27272a);
369
+ overflow-x: auto;
370
+ }
371
+ }
372
+ `;
373
+
374
+ export function ensureSettingsStylesInjected(doc?: Document): void {
375
+ const targetDoc = doc ?? (typeof document !== 'undefined' ? document : undefined);
376
+ if (!targetDoc || !targetDoc.head) return;
377
+ const existing =
378
+ typeof targetDoc.getElementById === 'function'
379
+ ? targetDoc.getElementById(SETTINGS_STYLE_ID)
380
+ : typeof targetDoc.head.querySelector === 'function'
381
+ ? targetDoc.head.querySelector(`#${SETTINGS_STYLE_ID}`)
382
+ : null;
383
+ if (existing) return;
384
+ if (typeof targetDoc.createElement !== 'function') return;
385
+ const styleEl = targetDoc.createElement('style');
386
+ styleEl.id = SETTINGS_STYLE_ID;
387
+ styleEl.textContent = SETTINGS_COMPONENT_CSS;
388
+ targetDoc.head.appendChild(styleEl);
389
+ }
56
390
 
57
391
  function isDomHostElement(candidate: unknown): candidate is HTMLElement {
58
392
  return Boolean(
@@ -98,32 +432,29 @@ export class SettingsDialogController implements IDisposable {
98
432
 
99
433
  private buildSurfaceInnerHtml(mode: 'dialog' | 'inline'): string {
100
434
  const titleId = mode === 'dialog' ? 'cl-settings-dialog-title' : 'cl-settings-inline-title';
101
- const bodyHeightStyle =
102
- mode === 'dialog'
103
- ? 'min-height:320px;max-height:62vh;'
104
- : 'flex:1;min-height:0;overflow:hidden;';
435
+ const bodyModeClass = mode === 'dialog' ? 'cl-settings-body--dialog' : 'cl-settings-body--inline';
105
436
  const closeBtnHtml =
106
437
  mode === 'dialog'
107
- ? `<button type="button" class="codelab-btn" data-settings-action="close" aria-label="Close Settings" style="${BTN_STYLE}">✕</button>`
438
+ ? `<button type="button" class="codelab-btn cl-ui-btn" data-settings-action="close" aria-label="Close Settings">✕</button>`
108
439
  : '';
109
440
 
110
441
  return (
111
- `<div class="cl-settings-header" style="display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 20px;border-bottom:1px solid var(--cl-border,#2b2b2b);flex-wrap:wrap;font-family:${FONT_SANS};">` +
112
- `<h2 id="${titleId}" style="margin:0;font-size:13px;font-weight:600;color:var(--cl-fg-active,var(--cl-fg,#cccccc));letter-spacing:0.01em;">Settings</h2>` +
113
- `<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap;">` +
114
- `<button type="button" class="codelab-btn" data-settings-action="open-json" aria-label="Open Settings (JSON)" title="Open .codelab/settings.json" style="${BTN_STYLE}">Open Settings (JSON)</button>` +
115
- `<button type="button" class="codelab-btn" data-settings-action="reset-all" aria-label="Reset All Settings" title="Reset all settings to defaults" style="${BTN_STYLE}">Reset All Settings</button>` +
116
- `<button type="button" class="codelab-btn" data-settings-action="export" title="Export Settings JSON" style="${BTN_STYLE}">Export</button>` +
442
+ `<div class="cl-settings-header">` +
443
+ `<h2 id="${titleId}" class="cl-settings-title">Settings</h2>` +
444
+ `<div class="cl-settings-actions">` +
445
+ `<button type="button" class="codelab-btn cl-ui-btn" data-settings-action="open-json" aria-label="Open Settings (JSON)" title="Open .codelab/settings.json">Open Settings (JSON)</button>` +
446
+ `<button type="button" class="codelab-btn cl-ui-btn" data-settings-action="reset-all" aria-label="Reset All Settings" title="Reset all settings to defaults">Reset All Settings</button>` +
447
+ `<button type="button" class="codelab-btn cl-ui-btn" data-settings-action="export" title="Export Settings JSON">Export</button>` +
117
448
  closeBtnHtml +
118
449
  `</div>` +
119
450
  `</div>` +
120
- `<div style="padding:10px 20px 0 20px;border-bottom:1px solid var(--cl-border,#2b2b2b);display:flex;flex-direction:column;gap:8px;font-family:${FONT_SANS};">` +
121
- `<input type="search" data-role="settings-search" aria-label="Search settings" value="${escapeAttr(this.searchQuery)}" placeholder="Search settings" style="width:100%;height:26px;padding:3px 8px;border-radius:2px;border:1px solid var(--cl-input-border,var(--cl-border,#3c3c3c));background:var(--cl-input-bg,#313131);color:var(--cl-fg,#cccccc);font-size:13px;font-family:${FONT_SANS};box-sizing:border-box;" />` +
122
- `<div role="tablist" aria-label="Settings scope" data-role="settings-scopes" style="display:flex;align-items:center;gap:2px;overflow-x:auto;"></div>` +
451
+ `<div class="cl-settings-toolbar">` +
452
+ `<input type="search" class="cl-settings-search" data-role="settings-search" aria-label="Search settings" value="${escapeAttr(this.searchQuery)}" placeholder="Search settings…" />` +
453
+ `<div role="tablist" aria-label="Settings scope" class="cl-settings-scopes" data-role="settings-scopes"></div>` +
123
454
  `</div>` +
124
- `<div class="cl-settings-body" style="display:grid;grid-template-columns:180px minmax(0,1fr);font-family:${FONT_SANS};${bodyHeightStyle}">` +
125
- `<nav data-role="settings-categories" aria-label="Setting categories" style="border-right:1px solid var(--cl-border,#2b2b2b);padding:8px 0;display:flex;flex-direction:column;gap:1px;overflow-y:auto;"></nav>` +
126
- `<div data-role="settings-list" style="padding:8px 24px 24px 20px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;"></div>` +
455
+ `<div class="cl-settings-body ${bodyModeClass}">` +
456
+ `<nav class="cl-settings-categories" data-role="settings-categories" aria-label="Setting categories"></nav>` +
457
+ `<div class="cl-settings-list" data-role="settings-list"></div>` +
127
458
  `</div>`
128
459
  );
129
460
  }
@@ -292,19 +623,41 @@ export class SettingsDialogController implements IDisposable {
292
623
  nextValue = el.value;
293
624
  }
294
625
 
626
+ let applied = false;
295
627
  if (hasValidValue) {
296
628
  if (this.activeScope === 'workspace') {
297
- if (this.config.setWorkspaceSetting(key, nextValue)) {
629
+ applied = this.config.setWorkspaceSetting(key, nextValue);
630
+ if (applied) {
298
631
  this.notifyWorkspaceMutated(mode);
299
632
  }
300
633
  } else {
301
634
  const hadWorkspaceOverride = this.config.inspect(key).workspaceValue !== undefined;
302
- if (this.config.setUserSetting(key, nextValue) && hadWorkspaceOverride) {
635
+ applied = this.config.setUserSetting(key, nextValue);
636
+ if (applied && hadWorkspaceOverride) {
303
637
  this.config.setWorkspaceSetting(key, nextValue);
304
638
  this.notifyWorkspaceMutated(mode);
305
639
  }
306
640
  }
307
641
  }
642
+ if (!applied) {
643
+ const min = desc.schema.minimum;
644
+ const max = desc.schema.maximum;
645
+ const rangeHint =
646
+ min !== undefined && max !== undefined
647
+ ? `Value must be between ${min} and ${max}.`
648
+ : min !== undefined
649
+ ? `Value must be at least ${min}.`
650
+ : max !== undefined
651
+ ? `Value must be at most ${max}.`
652
+ : 'Invalid setting value.';
653
+ if ('setCustomValidity' in el && typeof (el as HTMLInputElement).setCustomValidity === 'function') {
654
+ (el as HTMLInputElement).setCustomValidity(rangeHint);
655
+ if (typeof (el as HTMLInputElement).reportValidity === 'function') {
656
+ (el as HTMLInputElement).reportValidity();
657
+ }
658
+ (el as HTMLInputElement).setCustomValidity('');
659
+ }
660
+ }
308
661
  this.renderAllActiveSurfaces('items');
309
662
  };
310
663
  surfaceEl.addEventListener('change', onChange);
@@ -325,6 +678,7 @@ export class SettingsDialogController implements IDisposable {
325
678
  this.dialogDisposables.clear();
326
679
  this.dialogEl?.remove();
327
680
  const doc = hostRoot.ownerDocument ?? document;
681
+ ensureSettingsStylesInjected(doc);
328
682
  const dialog = doc.createElement('dialog');
329
683
  dialog.className = 'codelab-dialog cl-settings-dialog';
330
684
  dialog.setAttribute('closedby', 'any');
@@ -334,7 +688,6 @@ export class SettingsDialogController implements IDisposable {
334
688
  hostRoot.appendChild(dialog);
335
689
  this.dialogEl = dialog;
336
690
 
337
- // Reset returnValue on close + Safari fallback for `closedby="any"` light dismiss
338
691
  const onClose = (): void => {
339
692
  dialog.returnValue = '';
340
693
  };
@@ -411,13 +764,10 @@ export class SettingsDialogController implements IDisposable {
411
764
  this.inlineCallbacks = options;
412
765
 
413
766
  const doc = container.ownerDocument ?? document;
767
+ ensureSettingsStylesInjected(doc);
414
768
  const root = doc.createElement('div');
415
769
  root.className = 'cl-settings-editor cl-settings-inline';
416
770
  root.setAttribute('data-role', 'settings-inline-root');
417
- root.setAttribute(
418
- 'style',
419
- `display:flex;flex-direction:column;height:100%;min-height:0;background:var(--cl-editor-bg,var(--cl-bg,#1f1f1f));color:var(--cl-fg,#cccccc);font-family:${FONT_SANS};`
420
- );
421
771
  root.innerHTML = this.buildSurfaceInnerHtml('inline');
422
772
 
423
773
  container.appendChild(root);
@@ -464,8 +814,7 @@ export class SettingsDialogController implements IDisposable {
464
814
  .map((tab) => {
465
815
  const selected = this.activeScope === tab.id;
466
816
  return (
467
- `<button type="button" role="tab" data-settings-scope="${tab.id}" aria-selected="${selected ? 'true' : 'false'}" ` +
468
- `style="flex:none;padding:6px 12px;border:none;border-bottom:2px solid ${selected ? 'var(--cl-btn-primary-bg,var(--cl-accent,#0078d4))' : 'transparent'};background:transparent;color:${selected ? 'var(--cl-fg-active,var(--cl-fg,#ffffff))' : 'var(--cl-fg-muted,var(--cl-muted,#9d9d9d))'};cursor:pointer;font-size:13px;font-weight:${selected ? '600' : '400'};font-family:${FONT_SANS};">` +
817
+ `<button type="button" role="tab" class="cl-settings-scope-tab" data-settings-scope="${tab.id}" aria-selected="${selected ? 'true' : 'false'}">` +
469
818
  `${escapeAttr(tab.label)}` +
470
819
  `</button>`
471
820
  );
@@ -479,8 +828,7 @@ export class SettingsDialogController implements IDisposable {
479
828
  nav.innerHTML = ALL_CATEGORIES.map((cat) => {
480
829
  const selected = cat === this.activeCategory;
481
830
  return (
482
- `<button type="button" data-settings-cat="${cat}" aria-current="${selected ? 'true' : 'false'}" ` +
483
- `style="text-align:left;padding:4px 16px;border:none;border-left:2px solid ${selected ? 'var(--cl-btn-primary-bg,var(--cl-accent,#0078d4))' : 'transparent'};background:${selected ? 'var(--cl-list-active,#04395e)' : 'transparent'};color:${selected ? 'var(--cl-list-active-fg,#ffffff)' : 'var(--cl-fg,#cccccc)'};cursor:pointer;font-size:13px;font-weight:${selected ? '600' : '400'};font-family:${FONT_SANS};line-height:22px;">` +
831
+ `<button type="button" class="cl-settings-cat-btn" data-settings-cat="${cat}" aria-current="${selected ? 'true' : 'false'}">` +
484
832
  `${escapeAttr(cat)}` +
485
833
  `</button>`
486
834
  );
@@ -497,22 +845,22 @@ export class SettingsDialogController implements IDisposable {
497
845
  return `<option value="${escapeAttr(str)}"${sel}>${escapeAttr(str)}</option>`;
498
846
  })
499
847
  .join('');
500
- return `<select data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" style="${CONTROL_STYLE}">${opts}</select>`;
848
+ return `<select class="cl-ui-control" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}">${opts}</select>`;
501
849
  }
502
850
  if (desc.schema.type === 'boolean') {
503
851
  const checked = Boolean(currentVal) ? ' checked' : '';
504
- return `<input type="checkbox" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}"${checked} />`;
852
+ return `<input type="checkbox" class="cl-ui-checkbox" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}"${checked} />`;
505
853
  }
506
854
  if (desc.schema.type === 'integer' || desc.schema.type === 'number') {
507
855
  const min = desc.schema.minimum !== undefined ? ` min="${desc.schema.minimum}"` : '';
508
856
  const max = desc.schema.maximum !== undefined ? ` max="${desc.schema.maximum}"` : '';
509
- return `<input type="number" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(String(currentVal ?? ''))}"${min}${max} style="width:100px;${CONTROL_STYLE}" />`;
857
+ return `<input type="number" class="cl-ui-control cl-ui-control--num" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(String(currentVal ?? ''))}"${min}${max} />`;
510
858
  }
511
859
  if (desc.schema.type === 'array') {
512
860
  const joined = Array.isArray(currentVal) ? currentVal.join(', ') : '';
513
- return `<input type="text" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(joined)}" style="width:260px;${CONTROL_STYLE}" />`;
861
+ return `<input type="text" class="cl-ui-control cl-ui-control--array" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(joined)}" />`;
514
862
  }
515
- return `<input type="text" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(String(currentVal ?? ''))}" style="width:180px;${CONTROL_STYLE}" />`;
863
+ return `<input type="text" class="cl-ui-control cl-ui-control--text" data-setting-key="${keyAttr}" aria-label="${escapeAttr(desc.title)}" value="${escapeAttr(String(currentVal ?? ''))}" />`;
516
864
  }
517
865
 
518
866
  private renderItems(root: HTMLElement): void {
@@ -526,7 +874,7 @@ export class SettingsDialogController implements IDisposable {
526
874
  });
527
875
 
528
876
  if (descriptors.length === 0) {
529
- listEl.innerHTML = `<div style="color:var(--cl-fg-muted,var(--cl-muted,#64748b));font-size:13px;">No matching settings found.</div>`;
877
+ listEl.innerHTML = `<div class="cl-settings-empty">No matching settings found.</div>`;
530
878
  return;
531
879
  }
532
880
 
@@ -546,27 +894,31 @@ export class SettingsDialogController implements IDisposable {
546
894
  ? (insp.workspaceValue !== undefined ? 'workspace' : '')
547
895
  : (insp.effectiveSource !== 'default' ? insp.effectiveSource : '');
548
896
 
549
- const modifiedBorder = canReset
550
- ? '2px solid var(--cl-btn-primary-bg,var(--cl-accent,#0078d4))'
551
- : '2px solid transparent';
897
+ const hasWorkspaceOverrideNotice =
898
+ this.activeScope === 'user' && insp.workspaceValue !== undefined;
899
+
900
+ const modClass = canReset ? ' cl-setting-item--modified' : '';
552
901
 
553
902
  return (
554
- `<div class="cl-setting-item" data-setting-row="${escapeAttr(desc.key)}" style="padding:12px 12px 12px 14px;border-left:${modifiedBorder};border-bottom:1px solid var(--cl-border,#2b2b2b);display:flex;flex-direction:column;gap:6px;font-family:${FONT_SANS};">` +
555
- `<div style="display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;">` +
556
- `<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0;">` +
557
- `<span style="font-size:12px;color:var(--cl-fg-muted,var(--cl-muted,#9d9d9d));font-weight:500;">${escapeAttr(desc.category)}:</span>` +
558
- `<strong style="font-size:13px;font-weight:600;color:var(--cl-fg-active,var(--cl-fg,#ffffff));">${escapeAttr(desc.title)}</strong>` +
559
- `<code style="font-size:11.5px;color:var(--cl-fg-muted,var(--cl-muted,#9d9d9d));font-family:var(--cl-font-mono,monospace);">${escapeAttr(desc.key)}</code>` +
903
+ `<div class="cl-setting-item${modClass}" data-setting-row="${escapeAttr(desc.key)}">` +
904
+ `<div class="cl-setting-item__top">` +
905
+ `<div class="cl-setting-item__heading">` +
906
+ `<span class="cl-setting-item__cat">${escapeAttr(desc.category)}:</span>` +
907
+ `<strong class="cl-setting-item__title">${escapeAttr(desc.title)}</strong>` +
908
+ `<code class="cl-setting-item__key">${escapeAttr(desc.key)}</code>` +
560
909
  (badgeLabel
561
- ? `<span data-role="setting-badge" style="font-size:10px;padding:1px 6px;border-radius:2px;background:var(--cl-btn-primary-bg,var(--cl-accent,#0078d4));color:var(--cl-btn-primary-fg,#ffffff);font-weight:600;">${escapeAttr(badgeLabel)}</span>`
910
+ ? `<span class="cl-setting-badge" data-role="setting-badge">${escapeAttr(badgeLabel)}</span>`
911
+ : '') +
912
+ (hasWorkspaceOverrideNotice
913
+ ? `<span class="cl-setting-badge" data-role="setting-workspace-override" title="Overridden in .codelab/settings.json">Modified in Workspace</span>`
562
914
  : '') +
563
915
  `</div>` +
564
916
  (canReset
565
- ? `<button type="button" class="codelab-btn" data-reset-key="${escapeAttr(desc.key)}" title="Reset to Default (${escapeAttr(JSON.stringify(desc.defaultValue))})" style="${BTN_STYLE}">Reset</button>`
917
+ ? `<button type="button" class="codelab-btn cl-ui-btn" data-reset-key="${escapeAttr(desc.key)}" title="Reset to Default (${escapeAttr(JSON.stringify(desc.defaultValue))})">Reset</button>`
566
918
  : '') +
567
919
  `</div>` +
568
- `<div style="font-size:13px;line-height:1.45;color:var(--cl-fg-muted,var(--cl-muted,#9d9d9d));">${escapeAttr(desc.description)}</div>` +
569
- `<div style="display:flex;align-items:center;gap:8px;margin-top:2px;">` +
920
+ `<div class="cl-setting-item__desc">${escapeAttr(desc.description)}</div>` +
921
+ `<div class="cl-setting-item__control">` +
570
922
  this.renderControl(desc, displayedVal) +
571
923
  `</div>` +
572
924
  `</div>`