quilt-vanilla 0.3.0 → 0.5.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 (50) hide show
  1. package/dist/actions.d.ts +17 -0
  2. package/dist/actions.d.ts.map +1 -0
  3. package/dist/actions.js +146 -0
  4. package/dist/actions.js.map +1 -0
  5. package/dist/command-registry.d.ts +39 -0
  6. package/dist/command-registry.d.ts.map +1 -0
  7. package/dist/command-registry.js +202 -0
  8. package/dist/command-registry.js.map +1 -0
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/menu.d.ts +9 -3
  14. package/dist/menu.d.ts.map +1 -1
  15. package/dist/menu.js +110 -37
  16. package/dist/menu.js.map +1 -1
  17. package/dist/renderer.d.ts.map +1 -1
  18. package/dist/renderer.js +42 -8
  19. package/dist/renderer.js.map +1 -1
  20. package/dist/shortcut-registration.d.ts +10 -0
  21. package/dist/shortcut-registration.d.ts.map +1 -0
  22. package/dist/shortcut-registration.js +105 -0
  23. package/dist/shortcut-registration.js.map +1 -0
  24. package/dist/shortcuts.d.ts +7 -6
  25. package/dist/shortcuts.d.ts.map +1 -1
  26. package/dist/shortcuts.js +27 -50
  27. package/dist/shortcuts.js.map +1 -1
  28. package/dist/styles.css +25 -9
  29. package/dist/tabs.d.ts.map +1 -1
  30. package/dist/tabs.js +10 -12
  31. package/dist/tabs.js.map +1 -1
  32. package/dist/types.d.ts +52 -5
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js.map +1 -1
  35. package/dist/workspace-api.d.ts +20 -2
  36. package/dist/workspace-api.d.ts.map +1 -1
  37. package/dist/workspace-api.js +64 -0
  38. package/dist/workspace-api.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/actions.ts +163 -0
  41. package/src/command-registry.ts +248 -0
  42. package/src/index.ts +15 -0
  43. package/src/menu.ts +123 -43
  44. package/src/renderer.ts +48 -7
  45. package/src/shortcut-registration.ts +120 -0
  46. package/src/shortcuts.ts +43 -64
  47. package/src/styles.css +25 -9
  48. package/src/tabs.ts +9 -11
  49. package/src/types.ts +74 -5
  50. package/src/workspace-api.ts +83 -1
package/dist/menu.js CHANGED
@@ -2,10 +2,13 @@ import { message } from './messages.js';
2
2
  import { actionIcon } from './action-icons.js';
3
3
  import { fillTabPicker } from './picker.js';
4
4
  import { findNode, findParent, groups, paneIds } from 'quilt-core';
5
+ import { formatShortcut, ariaShortcut } from './shortcut-registration.js';
5
6
  import { el, Scope } from './lifetime.js';
6
- export function createPaneMenu(root, options, windows, refresh, report, requestClose) {
7
+ export function createPaneMenu(root, options, refresh, report, actions) {
7
8
  const doc = root.ownerDocument, win = doc.defaultView;
8
9
  let current;
10
+ let shortcutTarget;
11
+ let refreshShortcuts = () => { };
9
12
  const persistentPickers = new Map();
10
13
  const act = (fn) => {
11
14
  try {
@@ -15,11 +18,10 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
15
18
  report(error);
16
19
  }
17
20
  };
18
- function button(text, title, action) {
21
+ function button(text, label, action) {
19
22
  const b = el(doc, 'button', 'layouts-button', text);
20
23
  b.type = 'button';
21
- b.title = title;
22
- b.setAttribute('aria-label', title);
24
+ b.setAttribute('aria-label', label);
23
25
  b.onclick = () => act(action);
24
26
  return b;
25
27
  }
@@ -38,17 +40,35 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
38
40
  ? message(options, '{title} actions', { title: pane.title })
39
41
  : message(options, 'Empty pane actions'));
40
42
  local.add(() => dialog.remove());
41
- const add = (icon, label, enabled, fn) => {
43
+ const context = {
44
+ groupId: group.id,
45
+ ...(pane && group.panes.includes(pane.id) ? { paneId: pane.id } : {}),
46
+ };
47
+ const hints = [];
48
+ const bindAction = (element, action) => {
49
+ hints.push({ element, action });
50
+ element.disabled = !actions.canExecuteAction(action, context);
51
+ element.onclick = () => {
52
+ local.dispose();
53
+ void actions.executeAction(action, context);
54
+ };
55
+ };
56
+ const add = (icon, label, enabled, fn, target = dialog) => {
42
57
  const b = button(label, label, () => {
43
58
  local.dispose();
44
- act(fn);
59
+ if (typeof fn === 'function')
60
+ act(fn);
45
61
  });
46
62
  const glyph = el(doc, 'span', 'layouts-tab-icon');
47
63
  glyph.setAttribute('aria-hidden', 'true');
48
64
  act(() => glyph.append(actionIcon(doc, icon, options)));
49
65
  b.replaceChildren(glyph, el(doc, 'span', '', label.replace(/^\+ /, '')));
50
66
  b.disabled = !enabled;
51
- dialog.append(b);
67
+ if (typeof fn === 'string')
68
+ bindAction(b, fn);
69
+ if (target !== dialog)
70
+ b.setAttribute('role', 'menuitem');
71
+ target.append(b);
52
72
  return b;
53
73
  };
54
74
  const allowed = (cap) => group.panes.every((id) => options.store.can(id, cap));
@@ -151,7 +171,7 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
151
171
  create(direction === 'left' || direction === 'right' ? 'horizontal' : 'vertical', direction === 'left' || direction === 'top');
152
172
  return;
153
173
  }
154
- add('add-tab', message(options, '+ Add tab'), available && allowed('move'), () => create());
174
+ add('add-tab', message(options, '+ Add tab'), available && allowed('move'), 'addTab');
155
175
  const canCreate = !group.panes.length || available;
156
176
  const flyouts = [];
157
177
  let positionMenus = () => { };
@@ -170,7 +190,14 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
170
190
  flyout.setAttribute('role', 'menu');
171
191
  flyout.setAttribute('aria-label', label);
172
192
  flyouts.push({ trigger, flyout });
193
+ let closeTimer;
194
+ const cancelClose = () => {
195
+ win.clearTimeout(closeTimer);
196
+ closeTimer = undefined;
197
+ };
198
+ local.add(cancelClose);
173
199
  const setOpen = (open) => {
200
+ cancelClose();
174
201
  if (open) {
175
202
  for (const other of flyouts) {
176
203
  other.flyout.hidden = true;
@@ -186,7 +213,11 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
186
213
  if (!trigger.disabled)
187
214
  setOpen(true);
188
215
  });
189
- local.listen(container, 'pointerleave', () => setOpen(false));
216
+ // Allow the pointer to cross the dialog padding or move diagonally into the flyout.
217
+ local.listen(container, 'pointerleave', () => {
218
+ cancelClose();
219
+ closeTimer = win.setTimeout(() => setOpen(false), 300);
220
+ });
190
221
  local.listen(trigger, 'keydown', (event) => {
191
222
  if (event.key === 'ArrowRight') {
192
223
  event.preventDefault();
@@ -206,16 +237,14 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
206
237
  return flyout;
207
238
  }
208
239
  const flyout = submenu(message(options, 'Split'), 'split-right', canCreate && allowed('split'));
209
- for (const [label, axis, before] of [
210
- [message(options, 'Split left'), 'horizontal', true],
211
- [message(options, 'Split right'), 'horizontal', false],
212
- [message(options, 'Split up'), 'vertical', true],
213
- [message(options, 'Split down'), 'vertical', false],
240
+ for (const [label, axis, action] of [
241
+ [message(options, 'Split left'), 'horizontal', 'splitLeft'],
242
+ [message(options, 'Split right'), 'horizontal', 'splitRight'],
243
+ [message(options, 'Split up'), 'vertical', 'splitUp'],
244
+ [message(options, 'Split down'), 'vertical', 'splitDown'],
214
245
  ]) {
215
- const option = button(label, label, () => {
216
- local.dispose();
217
- create(axis, before);
218
- });
246
+ const option = button(label, label, () => { });
247
+ bindAction(option, action);
219
248
  const icon = el(doc, 'span', 'layouts-tab-icon');
220
249
  icon.setAttribute('aria-hidden', 'true');
221
250
  icon.append(actionIcon(doc, axis === 'horizontal' ? 'split-right' : 'split-below', options));
@@ -224,7 +253,7 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
224
253
  flyout.append(option);
225
254
  }
226
255
  const joinParent = findParent(options.store.getSnapshot().root, group.id);
227
- const join = add('join', message(options, 'Join sibling region'), Boolean(joinParent) && paneIds(joinParent).every((id) => options.store.can(id, 'join')), () => options.store.join(group.id, { source: 'user' }));
256
+ const join = add('join', message(options, 'Join sibling region'), Boolean(joinParent) && paneIds(joinParent).every((id) => options.store.can(id, 'join')), 'joinSiblingRegion');
228
257
  let preview;
229
258
  const clearPreview = () => {
230
259
  preview?.dispose();
@@ -284,12 +313,9 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
284
313
  local.listen(join, 'blur', clearPreview);
285
314
  add(options.store.getSnapshot().maximized === group.id ? 'restore' : 'maximize', options.store.getSnapshot().maximized === group.id
286
315
  ? message(options, 'Restore region')
287
- : message(options, 'Maximize region'), true, () => options.store.maximize(options.store.getSnapshot().maximized === group.id ? null : group.id));
316
+ : message(options, 'Maximize region'), true, 'maximize');
288
317
  if (group.panes.length && pane && options.popouts !== false) {
289
- add('popout', message(options, 'Open in window'), options.store.can(pane.id, 'popout'), () => {
290
- void windows.open(pane.id);
291
- refresh();
292
- });
318
+ add('popout', message(options, 'Open in window'), options.store.can(pane.id, 'popout'), 'popout');
293
319
  }
294
320
  const orientation = submenu(message(options, 'Tab orientation'), 'tab-orientation');
295
321
  for (const [value, label] of [
@@ -298,10 +324,12 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
298
324
  ['left', message(options, 'Vertical')],
299
325
  ]) {
300
326
  const selected = group.tabPlacement === value;
301
- const option = button(label, label, () => {
302
- options.store.setTabPlacement(group.id, value);
303
- local.dispose();
304
- });
327
+ const option = button(label, label, () => { });
328
+ bindAction(option, value === 'top'
329
+ ? 'tabOrientationHorizontal'
330
+ : value === 'left'
331
+ ? 'tabOrientationVertical'
332
+ : 'tabOrientationDefault');
305
333
  option.setAttribute('role', 'menuitemradio');
306
334
  option.setAttribute('aria-checked', String(selected));
307
335
  const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');
@@ -316,10 +344,12 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
316
344
  ['compact', message(options, 'Compact')],
317
345
  ]) {
318
346
  const selected = group.tabDisplay === value;
319
- const option = button(label, label, () => {
320
- options.store.setTabDisplay(group.id, value);
321
- local.dispose();
322
- });
347
+ const option = button(label, label, () => { });
348
+ bindAction(option, value === 'automatic'
349
+ ? 'tabDisplayAutomatic'
350
+ : value === 'compact'
351
+ ? 'tabDisplayCompact'
352
+ : 'tabDisplayDefault');
323
353
  option.setAttribute('role', 'menuitemradio');
324
354
  option.setAttribute('aria-checked', String(selected));
325
355
  const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');
@@ -328,13 +358,14 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
328
358
  display.append(option);
329
359
  }
330
360
  if (group.panes.length && pane) {
331
- add('close', message(options, 'Close active tab'), options.store.can(pane.id, 'close'), () => void requestClose(pane.id));
332
- add('close', message(options, 'Close pane'), group.panes.every((id) => options.store.can(id, 'close')), () => void requestClose(group.id, 'group'));
361
+ const close = submenu(message(options, 'Close'), 'close');
362
+ add('close', message(options, 'Close active tab'), options.store.can(pane.id, 'close'), 'closeActiveTab', close);
363
+ add('close', message(options, 'Close pane'), group.panes.every((id) => options.store.can(id, 'close')), 'closePane', close);
333
364
  }
334
365
  else {
335
- add('close', message(options, 'Close empty pane'), options.store.getSnapshot().root.id !== group.id, () => options.store.removeEmptyGroup(group.id));
366
+ add('close', message(options, 'Close empty pane'), options.store.getSnapshot().root.id !== group.id, 'closeEmptyPane');
336
367
  }
337
- add('restore', message(options, 'Restore closed tab'), options.store.canRestoreClosedTab(), () => options.store.restoreClosedTab());
368
+ add('restore', message(options, 'Restore closed tab'), options.store.canRestoreClosedTab(), 'restoreClosedTab');
338
369
  add('cancel', message(options, 'Cancel'), true, () => { });
339
370
  root.append(dialog);
340
371
  // Measure after opening: theme density, labels, and available actions change the size.
@@ -380,8 +411,48 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
380
411
  local.dispose();
381
412
  }
382
413
  });
414
+ const updateHints = () => {
415
+ const registrations = actions.getShortcuts();
416
+ for (const { element, action } of hints) {
417
+ element.querySelector('.layouts-shortcut')?.remove();
418
+ element.removeAttribute('aria-keyshortcuts');
419
+ element.disabled = !actions.canExecuteAction(action, context);
420
+ const label = element.getAttribute('aria-label') ?? '';
421
+ const registration = registrations.find((entry) => entry.action === action);
422
+ element.removeAttribute('title');
423
+ if (!registration)
424
+ continue;
425
+ const labels = registration.bindings.map((binding) => {
426
+ try {
427
+ return options.formatShortcut?.(binding) ?? formatShortcut(binding);
428
+ }
429
+ catch (error) {
430
+ report(error);
431
+ return formatShortcut(binding);
432
+ }
433
+ });
434
+ const badge = el(doc, 'kbd', 'layouts-shortcut', labels[0]);
435
+ badge.setAttribute('aria-hidden', 'true');
436
+ element.append(badge);
437
+ element.title = `${label} (${labels.join(' / ')})`;
438
+ if (!element.disabled)
439
+ element.setAttribute('aria-keyshortcuts', registration.bindings.map(ariaShortcut).join(' '));
440
+ }
441
+ positionMenus();
442
+ };
443
+ refreshShortcuts = updateHints;
444
+ local.add(() => {
445
+ if (refreshShortcuts === updateHints)
446
+ refreshShortcuts = () => { };
447
+ });
448
+ const target = { dialog, context, close: () => local.dispose() };
449
+ shortcutTarget = target;
450
+ local.add(() => {
451
+ if (shortcutTarget === target)
452
+ shortcutTarget = undefined;
453
+ });
383
454
  dialog.showModal();
384
- positionMenus();
455
+ updateHints();
385
456
  const observer = new win.ResizeObserver(positionMenus);
386
457
  observer.observe(dialog);
387
458
  observer.observe(anchor);
@@ -397,6 +468,8 @@ export function createPaneMenu(root, options, windows, refresh, report, requestC
397
468
  dialog.focus({ preventScroll: true });
398
469
  }
399
470
  return {
471
+ getShortcutTarget: () => shortcutTarget,
472
+ refreshShortcuts: () => refreshShortcuts(),
400
473
  open,
401
474
  addTab(anchor, group) {
402
475
  const layout = options.store.getSnapshot();
package/dist/menu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAInE,OAAO,EA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KAAK,EACL,IAAI,CACL,CAAC;QACJ,CAAC;QACD,SAAS,CAAC,MAAmB,EAAE,KAAY;YACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAClE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,CAChC,CAAC;YACF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC;QACD,OAAO;YACL,OAAO,EAAE,OAAO,EAAE,CAAC;YACnB,KAAK,MAAM,MAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACpE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { message } from './messages.js';\nimport { actionIcon } from './action-icons.js';\nimport type { ActionIcon } from './action-icons.js';\nimport { fillTabPicker } from './picker.js';\nimport { findNode, findParent, groups, paneIds } from 'quilt-core';\nimport type { Group, Pane } from 'quilt-core';\nimport type { ResolvedLayoutOptions } from './types.js';\nimport type { Windows } from './windows.js';\nimport { el, Scope } from './lifetime.js';\nexport function createPaneMenu(\n root: HTMLElement,\n options: ResolvedLayoutOptions,\n windows: Pick<Windows, 'open'>,\n refresh: () => void,\n report: (e: unknown) => void,\n requestClose: (id: string, kind?: 'pane' | 'group') => Promise<boolean>,\n) {\n const doc = root.ownerDocument,\n win = doc.defaultView!;\n let current: Scope | undefined;\n const persistentPickers = new Map<string, Scope>();\n const act = (fn: () => void) => {\n try {\n fn();\n } catch (error) {\n report(error);\n }\n };\n function button(text: string, title: string, action: () => void) {\n const b = el(doc, 'button', 'layouts-button', text);\n b.type = 'button';\n b.title = title;\n b.setAttribute('aria-label', title);\n b.onclick = () => act(action);\n return b;\n }\n function open(\n anchor: HTMLElement,\n pane: Pane | undefined,\n group: Group,\n direction?: 'left' | 'right' | 'top' | 'bottom',\n ratio = 0.5,\n groupActions = false,\n addTab = false,\n ) {\n current?.dispose();\n const latestGroup = findNode(options.store.getSnapshot().root, group.id);\n if (latestGroup?.kind !== 'group') return;\n group = latestGroup;\n const local = new Scope();\n current = local;\n const dialog = el(doc, 'dialog', 'layouts-menu');\n dialog.tabIndex = -1;\n dialog.autofocus = true;\n dialog.setAttribute(\n 'aria-label',\n pane && !groupActions\n ? message(options, '{title} actions', { title: pane.title })\n : message(options, 'Empty pane actions'),\n );\n local.add(() => dialog.remove());\n const add = (icon: ActionIcon, label: string, enabled: boolean, fn: () => void) => {\n const b = button(label, label, () => {\n local.dispose();\n act(fn);\n });\n const glyph = el(doc, 'span', 'layouts-tab-icon');\n glyph.setAttribute('aria-hidden', 'true');\n act(() => glyph.append(actionIcon(doc, icon, options)));\n b.replaceChildren(glyph, el(doc, 'span', '', label.replace(/^\\+ /, '')));\n b.disabled = !enabled;\n dialog.append(b);\n return b;\n };\n const allowed = (cap: 'split' | 'join' | 'move') =>\n group.panes.every((id) => options.store.can(id, cap));\n const available = Boolean(options.tabs?.list().length);\n const create = (axis?: 'horizontal' | 'vertical', before = false) => {\n if (!axis && !pane && !options.tabs) return;\n let destination = group;\n if (axis && (options.tabs || !pane)) {\n const id = options.store.split(group.id, axis, null, { source: 'user', before, ratio });\n destination = findNode(options.store.getSnapshot().root, id) as Group;\n refresh();\n if (!options.tabs) return;\n }\n const commit = (fresh: Pane) => options.store.add(fresh, destination.id, { source: 'user' });\n if (options.tabs) {\n if ((axis || !group.panes.length) && options.store.getAutoCollapse() === 'disabled') {\n if (persistentPickers.has(destination.id)) {\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n region?.querySelector<HTMLInputElement>('.layouts-picker-search')?.focus();\n return;\n }\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n if (!region) return;\n const pickerScope = new Scope();\n persistentPickers.set(destination.id, pickerScope);\n const picker = el(doc, 'div', 'layouts-menu layouts-picker layouts-picker-persistent');\n picker.setAttribute('role', 'dialog');\n region.append(picker);\n pickerScope.listen(\n doc,\n 'pointerdown',\n (event) => {\n if (!event.composedPath().includes(region)) pickerScope.dispose();\n },\n { capture: true },\n );\n pickerScope.add(() => {\n picker.remove();\n persistentPickers.delete(destination.id);\n });\n pickerScope.add(\n options.store.subscribe(() => {\n const group = findNode(options.store.getSnapshot().root, destination.id);\n if (group?.kind !== 'group' || group.panes.length) pickerScope.dispose();\n }),\n );\n fillTabPicker(picker, pickerScope, options, pane, destination, commit, report, true);\n return;\n }\n const pickerScope = new Scope();\n current = pickerScope;\n const picker = el(doc, 'dialog', 'layouts-menu layouts-picker');\n if (axis)\n pickerScope.add(() => {\n if (options.store.getAutoCollapse() !== 'disabled')\n options.store.removeEmptyGroup(destination.id);\n });\n pickerScope.add(() => picker.remove());\n pickerScope.listen(picker, 'close', () => pickerScope.dispose());\n root.append(picker);\n pickerScope.listen(picker, 'click', (event) => {\n const e = event as MouseEvent;\n const bounds = picker.getBoundingClientRect();\n if (\n e.target === picker &&\n (e.clientX < bounds.left ||\n e.clientX > bounds.right ||\n e.clientY < bounds.top ||\n e.clientY > bounds.bottom)\n )\n pickerScope.dispose();\n });\n picker.showModal();\n fillTabPicker(picker, pickerScope, options, pane, destination, commit, report);\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n if (region) {\n const position = () => {\n const bounds = region.getBoundingClientRect();\n picker.style.width = `${Math.max(0, Math.min(340, bounds.width - 16))}px`;\n picker.style.maxHeight = `${Math.max(0, bounds.height - 16)}px`;\n picker.style.left = `${bounds.left + (bounds.width - picker.offsetWidth) / 2}px`;\n picker.style.top = `${bounds.top + (bounds.height - picker.offsetHeight) / 2}px`;\n };\n position();\n const observer = new ResizeObserver(position);\n observer.observe(region);\n observer.observe(picker);\n pickerScope.add(() => observer.disconnect());\n pickerScope.listen(win, 'resize', position);\n pickerScope.add(\n options.store.subscribe(() => {\n if (!findNode(options.store.getSnapshot().root, destination.id))\n pickerScope.dispose();\n }),\n );\n }\n }\n };\n if (addTab || (!direction && !group.panes.length && !groupActions)) {\n local.dispose();\n create();\n return;\n }\n if (direction) {\n local.dispose();\n create(\n direction === 'left' || direction === 'right' ? 'horizontal' : 'vertical',\n direction === 'left' || direction === 'top',\n );\n return;\n }\n add('add-tab', message(options, '+ Add tab'), available && allowed('move'), () => create());\n const canCreate = !group.panes.length || available;\n const flyouts: { trigger: HTMLElement; flyout: HTMLElement }[] = [];\n let positionMenus = () => {};\n function submenu(label: string, icon: ActionIcon, enabled = true) {\n const container = el(doc, 'div', 'layouts-submenu');\n const trigger = button(`${label} ▸`, label, () => setOpen(true));\n const glyph = el(doc, 'span', 'layouts-tab-icon');\n glyph.setAttribute('aria-hidden', 'true');\n glyph.append(actionIcon(doc, icon, options));\n trigger.prepend(glyph);\n trigger.disabled = !enabled;\n trigger.setAttribute('aria-haspopup', 'menu');\n trigger.setAttribute('aria-expanded', 'false');\n const flyout = el(doc, 'div', 'layouts-submenu-content');\n flyout.hidden = true;\n flyout.setAttribute('role', 'menu');\n flyout.setAttribute('aria-label', label);\n flyouts.push({ trigger, flyout });\n const setOpen = (open: boolean) => {\n if (open) {\n for (const other of flyouts) {\n other.flyout.hidden = true;\n other.trigger.setAttribute('aria-expanded', 'false');\n }\n }\n flyout.hidden = !open;\n trigger.setAttribute('aria-expanded', String(open));\n if (open) positionMenus();\n };\n local.listen(container, 'pointerenter', () => {\n if (!trigger.disabled) setOpen(true);\n });\n local.listen(container, 'pointerleave', () => setOpen(false));\n local.listen(trigger, 'keydown', (event) => {\n if ((event as KeyboardEvent).key === 'ArrowRight') {\n event.preventDefault();\n setOpen(true);\n (flyout.firstElementChild as HTMLElement)?.focus();\n }\n });\n local.listen(flyout, 'keydown', (event) => {\n if ((event as KeyboardEvent).key === 'ArrowLeft') {\n event.preventDefault();\n setOpen(false);\n trigger.focus();\n }\n });\n container.append(trigger, flyout);\n dialog.append(container);\n return flyout;\n }\n const flyout = submenu(message(options, 'Split'), 'split-right', canCreate && allowed('split'));\n for (const [label, axis, before] of [\n [message(options, 'Split left'), 'horizontal', true],\n [message(options, 'Split right'), 'horizontal', false],\n [message(options, 'Split up'), 'vertical', true],\n [message(options, 'Split down'), 'vertical', false],\n ] as const) {\n const option = button(label, label, () => {\n local.dispose();\n create(axis, before);\n });\n const icon = el(doc, 'span', 'layouts-tab-icon');\n icon.setAttribute('aria-hidden', 'true');\n icon.append(actionIcon(doc, axis === 'horizontal' ? 'split-right' : 'split-below', options));\n option.prepend(icon);\n option.setAttribute('role', 'menuitem');\n flyout.append(option);\n }\n const joinParent = findParent(options.store.getSnapshot().root, group.id);\n const join = add(\n 'join',\n message(options, 'Join sibling region'),\n Boolean(joinParent) && paneIds(joinParent!).every((id) => options.store.can(id, 'join')),\n () => options.store.join(group.id, { source: 'user' }),\n );\n let preview: Scope | undefined;\n const clearPreview = () => {\n preview?.dispose();\n preview = undefined;\n };\n local.add(clearPreview);\n const showPreview = () => {\n clearPreview();\n const layout = options.store.getSnapshot();\n const parent = findParent(layout.root, group.id);\n if (join.disabled || !parent) return;\n const scope = new Scope();\n preview = scope;\n const overlay = el(doc, 'div', 'layouts-corner-overlay');\n overlay.setAttribute('aria-hidden', 'true');\n root.append(overlay);\n scope.add(() => overlay.remove());\n const targetTitle =\n layout.panes[group.active ?? '']?.title ?? message(options, 'This region');\n const regions = groups(parent).map((region) => ({\n region,\n element: Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === region.id && element.closest('.layouts') === root,\n ),\n }));\n const position = () => {\n overlay.replaceChildren();\n for (const { region, element } of regions) {\n if (!element || !element.getClientRects().length) continue;\n const rect = element.getBoundingClientRect();\n const box = el(doc, 'div', 'layouts-corner-preview');\n box.dataset.cornerPreview = region.id === group.id ? 'join-target' : 'join-source';\n Object.assign(box.style, {\n left: `${rect.left}px`,\n top: `${rect.top}px`,\n width: `${rect.width}px`,\n height: `${rect.height}px`,\n });\n box.append(\n el(\n doc,\n 'span',\n 'layouts-corner-label',\n region.id === group.id\n ? message(options, '{target} keeps all tabs', { target: targetTitle })\n : message(options, 'Joins {target}', { target: targetTitle }),\n ),\n );\n overlay.append(box);\n }\n };\n position();\n const observer = new win.ResizeObserver(position);\n for (const { element } of regions) if (element) observer.observe(element);\n scope.add(() => observer.disconnect());\n scope.listen(win, 'resize', position);\n scope.listen(doc, 'scroll', position, { capture: true });\n scope.add(options.store.subscribe(clearPreview));\n };\n local.listen(join, 'pointerenter', showPreview);\n local.listen(join, 'pointerleave', clearPreview);\n local.listen(join, 'focus', showPreview);\n local.listen(join, 'blur', clearPreview);\n add(\n options.store.getSnapshot().maximized === group.id ? 'restore' : 'maximize',\n options.store.getSnapshot().maximized === group.id\n ? message(options, 'Restore region')\n : message(options, 'Maximize region'),\n true,\n () =>\n options.store.maximize(\n options.store.getSnapshot().maximized === group.id ? null : group.id,\n ),\n );\n if (group.panes.length && pane && options.popouts !== false) {\n add(\n 'popout',\n message(options, 'Open in window'),\n options.store.can(pane.id, 'popout'),\n () => {\n void windows.open(pane.id);\n refresh();\n },\n );\n }\n const orientation = submenu(message(options, 'Tab orientation'), 'tab-orientation');\n for (const [value, label] of [\n [undefined, message(options, 'Workspace default')],\n ['top', message(options, 'Horizontal')],\n ['left', message(options, 'Vertical')],\n ] as const) {\n const selected = group.tabPlacement === value;\n const option = button(label, label, () => {\n options.store.setTabPlacement(group.id, value);\n local.dispose();\n });\n option.setAttribute('role', 'menuitemradio');\n option.setAttribute('aria-checked', String(selected));\n const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');\n mark.setAttribute('aria-hidden', 'true');\n option.prepend(mark);\n orientation.append(option);\n }\n const display = submenu(message(options, 'Tab display'), 'tab-orientation');\n for (const [value, label] of [\n [undefined, message(options, 'Workspace default')],\n ['automatic', message(options, 'Automatic')],\n ['compact', message(options, 'Compact')],\n ] as const) {\n const selected = group.tabDisplay === value;\n const option = button(label, label, () => {\n options.store.setTabDisplay(group.id, value);\n local.dispose();\n });\n option.setAttribute('role', 'menuitemradio');\n option.setAttribute('aria-checked', String(selected));\n const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');\n mark.setAttribute('aria-hidden', 'true');\n option.prepend(mark);\n display.append(option);\n }\n if (group.panes.length && pane) {\n add(\n 'close',\n message(options, 'Close active tab'),\n options.store.can(pane.id, 'close'),\n () => void requestClose(pane.id),\n );\n add(\n 'close',\n message(options, 'Close pane'),\n group.panes.every((id) => options.store.can(id, 'close')),\n () => void requestClose(group.id, 'group'),\n );\n } else {\n add(\n 'close',\n message(options, 'Close empty pane'),\n options.store.getSnapshot().root.id !== group.id,\n () => options.store.removeEmptyGroup(group.id),\n );\n }\n add(\n 'restore',\n message(options, 'Restore closed tab'),\n options.store.canRestoreClosedTab(),\n () => options.store.restoreClosedTab(),\n );\n add('cancel', message(options, 'Cancel'), true, () => {});\n root.append(dialog);\n // Measure after opening: theme density, labels, and available actions change the size.\n // Fixed flyouts escape the scrolling dialog while retaining its modal focus scope.\n positionMenus = () => {\n const viewport = win.visualViewport;\n const left = (viewport?.offsetLeft ?? 0) + 8;\n const top = (viewport?.offsetTop ?? 0) + 8;\n const width = Math.max(0, (viewport?.width ?? doc.documentElement.clientWidth) - 16);\n const height = Math.max(0, (viewport?.height ?? doc.documentElement.clientHeight) - 16);\n const fit = (element: HTMLElement) => {\n element.style.maxWidth = `${width}px`;\n element.style.maxHeight = `${height}px`;\n };\n const place = (element: HTMLElement, x: number, y: number) => {\n const bounds = element.getBoundingClientRect();\n element.style.left = `${Math.max(left, Math.min(x, left + width - bounds.width))}px`;\n element.style.top = `${Math.max(top, Math.min(y, top + height - bounds.height))}px`;\n };\n fit(dialog);\n const rect = anchor.getBoundingClientRect();\n const bounds = dialog.getBoundingClientRect();\n const below = rect.bottom + 4;\n const above = rect.top - bounds.height - 4;\n place(\n dialog,\n rect.right - bounds.width,\n below + bounds.height <= top + height || above < top ? below : above,\n );\n for (const { trigger, flyout } of flyouts) {\n if (flyout.hidden) continue;\n fit(flyout);\n const row = trigger.getBoundingClientRect();\n const menu = dialog.getBoundingClientRect();\n const size = flyout.getBoundingClientRect();\n const x =\n menu.right - 1 + size.width <= left + width ? menu.right - 1 : menu.left - size.width + 1;\n place(flyout, x, row.top);\n }\n };\n local.listen(dialog, 'close', () => local.dispose());\n local.listen(dialog, 'click', (event) => {\n if (event.target === dialog) {\n const r = dialog.getBoundingClientRect();\n const e = event as MouseEvent;\n if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom)\n local.dispose();\n }\n });\n dialog.showModal();\n positionMenus();\n const observer = new win.ResizeObserver(positionMenus);\n observer.observe(dialog);\n observer.observe(anchor);\n for (const { flyout } of flyouts) observer.observe(flyout);\n local.add(() => observer.disconnect());\n local.listen(win, 'resize', positionMenus);\n local.listen(doc, 'scroll', positionMenus, { capture: true });\n if (win.visualViewport) {\n local.listen(win.visualViewport, 'resize', positionMenus);\n local.listen(win.visualViewport, 'scroll', positionMenus);\n }\n dialog.focus({ preventScroll: true });\n }\n return {\n open,\n addTab(anchor: HTMLElement, group: Group) {\n const layout = options.store.getSnapshot();\n open(\n anchor,\n group.active ? layout.panes[group.active] : undefined,\n group,\n undefined,\n 0.5,\n false,\n true,\n );\n },\n openEmpty(anchor: HTMLElement, group: Group) {\n const source = Object.values(options.store.getSnapshot().panes).find(\n (pane) => pane.header !== false,\n );\n open(anchor, source, group, undefined, 0.5, true);\n },\n dispose() {\n current?.dispose();\n for (const picker of persistentPickers.values()) picker.dispose();\n },\n };\n}\n"]}
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,mBA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E;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACpE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { message } from './messages.js';\nimport { actionIcon } from './action-icons.js';\nimport type { ActionIcon } from './action-icons.js';\nimport { fillTabPicker } from './picker.js';\nimport { findNode, findParent, groups, paneIds } from 'quilt-core';\nimport type { Group, Pane } from 'quilt-core';\nimport type { ResolvedLayoutOptions, WorkspaceAction, ActionContext } from './types.js';\nimport type { createActions } from './actions.js';\nimport { formatShortcut, ariaShortcut } from './shortcut-registration.js';\nimport { el, Scope } from './lifetime.js';\nexport function createPaneMenu(\n root: HTMLElement,\n options: ResolvedLayoutOptions,\n refresh: () => void,\n report: (e: unknown) => void,\n actions: ReturnType<typeof createActions>,\n) {\n const doc = root.ownerDocument,\n win = doc.defaultView!;\n let current: Scope | undefined;\n let shortcutTarget:\n { dialog: HTMLDialogElement; context: ActionContext; close(): void } | undefined;\n let refreshShortcuts = () => {};\n const persistentPickers = new Map<string, Scope>();\n const act = (fn: () => void) => {\n try {\n fn();\n } catch (error) {\n report(error);\n }\n };\n function button(text: string, label: string, action: () => void) {\n const b = el(doc, 'button', 'layouts-button', text);\n b.type = 'button';\n b.setAttribute('aria-label', label);\n b.onclick = () => act(action);\n return b;\n }\n function open(\n anchor: HTMLElement,\n pane: Pane | undefined,\n group: Group,\n direction?: 'left' | 'right' | 'top' | 'bottom',\n ratio = 0.5,\n groupActions = false,\n addTab = false,\n ) {\n current?.dispose();\n const latestGroup = findNode(options.store.getSnapshot().root, group.id);\n if (latestGroup?.kind !== 'group') return;\n group = latestGroup;\n const local = new Scope();\n current = local;\n const dialog = el(doc, 'dialog', 'layouts-menu');\n dialog.tabIndex = -1;\n dialog.autofocus = true;\n dialog.setAttribute(\n 'aria-label',\n pane && !groupActions\n ? message(options, '{title} actions', { title: pane.title })\n : message(options, 'Empty pane actions'),\n );\n local.add(() => dialog.remove());\n const context = {\n groupId: group.id,\n ...(pane && group.panes.includes(pane.id) ? { paneId: pane.id } : {}),\n };\n const hints: { element: HTMLButtonElement; action: WorkspaceAction }[] = [];\n const bindAction = (element: HTMLButtonElement, action: WorkspaceAction) => {\n hints.push({ element, action });\n element.disabled = !actions.canExecuteAction(action, context);\n element.onclick = () => {\n local.dispose();\n void actions.executeAction(action, context);\n };\n };\n const add = (\n icon: ActionIcon,\n label: string,\n enabled: boolean,\n fn: (() => void) | WorkspaceAction,\n target: HTMLElement = dialog,\n ) => {\n const b = button(label, label, () => {\n local.dispose();\n if (typeof fn === 'function') act(fn);\n });\n const glyph = el(doc, 'span', 'layouts-tab-icon');\n glyph.setAttribute('aria-hidden', 'true');\n act(() => glyph.append(actionIcon(doc, icon, options)));\n b.replaceChildren(glyph, el(doc, 'span', '', label.replace(/^\\+ /, '')));\n b.disabled = !enabled;\n if (typeof fn === 'string') bindAction(b, fn);\n if (target !== dialog) b.setAttribute('role', 'menuitem');\n target.append(b);\n return b;\n };\n const allowed = (cap: 'split' | 'join' | 'move') =>\n group.panes.every((id) => options.store.can(id, cap));\n const available = Boolean(options.tabs?.list().length);\n const create = (axis?: 'horizontal' | 'vertical', before = false) => {\n if (!axis && !pane && !options.tabs) return;\n let destination = group;\n if (axis && (options.tabs || !pane)) {\n const id = options.store.split(group.id, axis, null, { source: 'user', before, ratio });\n destination = findNode(options.store.getSnapshot().root, id) as Group;\n refresh();\n if (!options.tabs) return;\n }\n const commit = (fresh: Pane) => options.store.add(fresh, destination.id, { source: 'user' });\n if (options.tabs) {\n if ((axis || !group.panes.length) && options.store.getAutoCollapse() === 'disabled') {\n if (persistentPickers.has(destination.id)) {\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n region?.querySelector<HTMLInputElement>('.layouts-picker-search')?.focus();\n return;\n }\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n if (!region) return;\n const pickerScope = new Scope();\n persistentPickers.set(destination.id, pickerScope);\n const picker = el(doc, 'div', 'layouts-menu layouts-picker layouts-picker-persistent');\n picker.setAttribute('role', 'dialog');\n region.append(picker);\n pickerScope.listen(\n doc,\n 'pointerdown',\n (event) => {\n if (!event.composedPath().includes(region)) pickerScope.dispose();\n },\n { capture: true },\n );\n pickerScope.add(() => {\n picker.remove();\n persistentPickers.delete(destination.id);\n });\n pickerScope.add(\n options.store.subscribe(() => {\n const group = findNode(options.store.getSnapshot().root, destination.id);\n if (group?.kind !== 'group' || group.panes.length) pickerScope.dispose();\n }),\n );\n fillTabPicker(picker, pickerScope, options, pane, destination, commit, report, true);\n return;\n }\n const pickerScope = new Scope();\n current = pickerScope;\n const picker = el(doc, 'dialog', 'layouts-menu layouts-picker');\n if (axis)\n pickerScope.add(() => {\n if (options.store.getAutoCollapse() !== 'disabled')\n options.store.removeEmptyGroup(destination.id);\n });\n pickerScope.add(() => picker.remove());\n pickerScope.listen(picker, 'close', () => pickerScope.dispose());\n root.append(picker);\n pickerScope.listen(picker, 'click', (event) => {\n const e = event as MouseEvent;\n const bounds = picker.getBoundingClientRect();\n if (\n e.target === picker &&\n (e.clientX < bounds.left ||\n e.clientX > bounds.right ||\n e.clientY < bounds.top ||\n e.clientY > bounds.bottom)\n )\n pickerScope.dispose();\n });\n picker.showModal();\n fillTabPicker(picker, pickerScope, options, pane, destination, commit, report);\n const region = Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === destination.id,\n );\n if (region) {\n const position = () => {\n const bounds = region.getBoundingClientRect();\n picker.style.width = `${Math.max(0, Math.min(340, bounds.width - 16))}px`;\n picker.style.maxHeight = `${Math.max(0, bounds.height - 16)}px`;\n picker.style.left = `${bounds.left + (bounds.width - picker.offsetWidth) / 2}px`;\n picker.style.top = `${bounds.top + (bounds.height - picker.offsetHeight) / 2}px`;\n };\n position();\n const observer = new ResizeObserver(position);\n observer.observe(region);\n observer.observe(picker);\n pickerScope.add(() => observer.disconnect());\n pickerScope.listen(win, 'resize', position);\n pickerScope.add(\n options.store.subscribe(() => {\n if (!findNode(options.store.getSnapshot().root, destination.id))\n pickerScope.dispose();\n }),\n );\n }\n }\n };\n if (addTab || (!direction && !group.panes.length && !groupActions)) {\n local.dispose();\n create();\n return;\n }\n if (direction) {\n local.dispose();\n create(\n direction === 'left' || direction === 'right' ? 'horizontal' : 'vertical',\n direction === 'left' || direction === 'top',\n );\n return;\n }\n add('add-tab', message(options, '+ Add tab'), available && allowed('move'), 'addTab');\n const canCreate = !group.panes.length || available;\n const flyouts: { trigger: HTMLElement; flyout: HTMLElement }[] = [];\n let positionMenus = () => {};\n function submenu(label: string, icon: ActionIcon, enabled = true) {\n const container = el(doc, 'div', 'layouts-submenu');\n const trigger = button(`${label} ▸`, label, () => setOpen(true));\n const glyph = el(doc, 'span', 'layouts-tab-icon');\n glyph.setAttribute('aria-hidden', 'true');\n glyph.append(actionIcon(doc, icon, options));\n trigger.prepend(glyph);\n trigger.disabled = !enabled;\n trigger.setAttribute('aria-haspopup', 'menu');\n trigger.setAttribute('aria-expanded', 'false');\n const flyout = el(doc, 'div', 'layouts-submenu-content');\n flyout.hidden = true;\n flyout.setAttribute('role', 'menu');\n flyout.setAttribute('aria-label', label);\n flyouts.push({ trigger, flyout });\n let closeTimer: number | undefined;\n const cancelClose = () => {\n win.clearTimeout(closeTimer);\n closeTimer = undefined;\n };\n local.add(cancelClose);\n const setOpen = (open: boolean) => {\n cancelClose();\n if (open) {\n for (const other of flyouts) {\n other.flyout.hidden = true;\n other.trigger.setAttribute('aria-expanded', 'false');\n }\n }\n flyout.hidden = !open;\n trigger.setAttribute('aria-expanded', String(open));\n if (open) positionMenus();\n };\n local.listen(container, 'pointerenter', () => {\n if (!trigger.disabled) setOpen(true);\n });\n // Allow the pointer to cross the dialog padding or move diagonally into the flyout.\n local.listen(container, 'pointerleave', () => {\n cancelClose();\n closeTimer = win.setTimeout(() => setOpen(false), 300);\n });\n local.listen(trigger, 'keydown', (event) => {\n if ((event as KeyboardEvent).key === 'ArrowRight') {\n event.preventDefault();\n setOpen(true);\n (flyout.firstElementChild as HTMLElement)?.focus();\n }\n });\n local.listen(flyout, 'keydown', (event) => {\n if ((event as KeyboardEvent).key === 'ArrowLeft') {\n event.preventDefault();\n setOpen(false);\n trigger.focus();\n }\n });\n container.append(trigger, flyout);\n dialog.append(container);\n return flyout;\n }\n const flyout = submenu(message(options, 'Split'), 'split-right', canCreate && allowed('split'));\n for (const [label, axis, action] of [\n [message(options, 'Split left'), 'horizontal', 'splitLeft'],\n [message(options, 'Split right'), 'horizontal', 'splitRight'],\n [message(options, 'Split up'), 'vertical', 'splitUp'],\n [message(options, 'Split down'), 'vertical', 'splitDown'],\n ] as const) {\n const option = button(label, label, () => {});\n bindAction(option, action);\n const icon = el(doc, 'span', 'layouts-tab-icon');\n icon.setAttribute('aria-hidden', 'true');\n icon.append(actionIcon(doc, axis === 'horizontal' ? 'split-right' : 'split-below', options));\n option.prepend(icon);\n option.setAttribute('role', 'menuitem');\n flyout.append(option);\n }\n const joinParent = findParent(options.store.getSnapshot().root, group.id);\n const join = add(\n 'join',\n message(options, 'Join sibling region'),\n Boolean(joinParent) && paneIds(joinParent!).every((id) => options.store.can(id, 'join')),\n 'joinSiblingRegion',\n );\n let preview: Scope | undefined;\n const clearPreview = () => {\n preview?.dispose();\n preview = undefined;\n };\n local.add(clearPreview);\n const showPreview = () => {\n clearPreview();\n const layout = options.store.getSnapshot();\n const parent = findParent(layout.root, group.id);\n if (join.disabled || !parent) return;\n const scope = new Scope();\n preview = scope;\n const overlay = el(doc, 'div', 'layouts-corner-overlay');\n overlay.setAttribute('aria-hidden', 'true');\n root.append(overlay);\n scope.add(() => overlay.remove());\n const targetTitle =\n layout.panes[group.active ?? '']?.title ?? message(options, 'This region');\n const regions = groups(parent).map((region) => ({\n region,\n element: Array.from(root.querySelectorAll<HTMLElement>('[data-node-id]')).find(\n (element) => element.dataset.nodeId === region.id && element.closest('.layouts') === root,\n ),\n }));\n const position = () => {\n overlay.replaceChildren();\n for (const { region, element } of regions) {\n if (!element || !element.getClientRects().length) continue;\n const rect = element.getBoundingClientRect();\n const box = el(doc, 'div', 'layouts-corner-preview');\n box.dataset.cornerPreview = region.id === group.id ? 'join-target' : 'join-source';\n Object.assign(box.style, {\n left: `${rect.left}px`,\n top: `${rect.top}px`,\n width: `${rect.width}px`,\n height: `${rect.height}px`,\n });\n box.append(\n el(\n doc,\n 'span',\n 'layouts-corner-label',\n region.id === group.id\n ? message(options, '{target} keeps all tabs', { target: targetTitle })\n : message(options, 'Joins {target}', { target: targetTitle }),\n ),\n );\n overlay.append(box);\n }\n };\n position();\n const observer = new win.ResizeObserver(position);\n for (const { element } of regions) if (element) observer.observe(element);\n scope.add(() => observer.disconnect());\n scope.listen(win, 'resize', position);\n scope.listen(doc, 'scroll', position, { capture: true });\n scope.add(options.store.subscribe(clearPreview));\n };\n local.listen(join, 'pointerenter', showPreview);\n local.listen(join, 'pointerleave', clearPreview);\n local.listen(join, 'focus', showPreview);\n local.listen(join, 'blur', clearPreview);\n add(\n options.store.getSnapshot().maximized === group.id ? 'restore' : 'maximize',\n options.store.getSnapshot().maximized === group.id\n ? message(options, 'Restore region')\n : message(options, 'Maximize region'),\n true,\n 'maximize',\n );\n if (group.panes.length && pane && options.popouts !== false) {\n add(\n 'popout',\n message(options, 'Open in window'),\n options.store.can(pane.id, 'popout'),\n 'popout',\n );\n }\n const orientation = submenu(message(options, 'Tab orientation'), 'tab-orientation');\n for (const [value, label] of [\n [undefined, message(options, 'Workspace default')],\n ['top', message(options, 'Horizontal')],\n ['left', message(options, 'Vertical')],\n ] as const) {\n const selected = group.tabPlacement === value;\n const option = button(label, label, () => {});\n bindAction(\n option,\n value === 'top'\n ? 'tabOrientationHorizontal'\n : value === 'left'\n ? 'tabOrientationVertical'\n : 'tabOrientationDefault',\n );\n option.setAttribute('role', 'menuitemradio');\n option.setAttribute('aria-checked', String(selected));\n const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');\n mark.setAttribute('aria-hidden', 'true');\n option.prepend(mark);\n orientation.append(option);\n }\n const display = submenu(message(options, 'Tab display'), 'tab-orientation');\n for (const [value, label] of [\n [undefined, message(options, 'Workspace default')],\n ['automatic', message(options, 'Automatic')],\n ['compact', message(options, 'Compact')],\n ] as const) {\n const selected = group.tabDisplay === value;\n const option = button(label, label, () => {});\n bindAction(\n option,\n value === 'automatic'\n ? 'tabDisplayAutomatic'\n : value === 'compact'\n ? 'tabDisplayCompact'\n : 'tabDisplayDefault',\n );\n option.setAttribute('role', 'menuitemradio');\n option.setAttribute('aria-checked', String(selected));\n const mark = el(doc, 'span', 'layouts-tab-icon', selected ? '✓' : '');\n mark.setAttribute('aria-hidden', 'true');\n option.prepend(mark);\n display.append(option);\n }\n if (group.panes.length && pane) {\n const close = submenu(message(options, 'Close'), 'close');\n add(\n 'close',\n message(options, 'Close active tab'),\n options.store.can(pane.id, 'close'),\n 'closeActiveTab',\n close,\n );\n add(\n 'close',\n message(options, 'Close pane'),\n group.panes.every((id) => options.store.can(id, 'close')),\n 'closePane',\n close,\n );\n } else {\n add(\n 'close',\n message(options, 'Close empty pane'),\n options.store.getSnapshot().root.id !== group.id,\n 'closeEmptyPane',\n );\n }\n add(\n 'restore',\n message(options, 'Restore closed tab'),\n options.store.canRestoreClosedTab(),\n 'restoreClosedTab',\n );\n add('cancel', message(options, 'Cancel'), true, () => {});\n root.append(dialog);\n // Measure after opening: theme density, labels, and available actions change the size.\n // Fixed flyouts escape the scrolling dialog while retaining its modal focus scope.\n positionMenus = () => {\n const viewport = win.visualViewport;\n const left = (viewport?.offsetLeft ?? 0) + 8;\n const top = (viewport?.offsetTop ?? 0) + 8;\n const width = Math.max(0, (viewport?.width ?? doc.documentElement.clientWidth) - 16);\n const height = Math.max(0, (viewport?.height ?? doc.documentElement.clientHeight) - 16);\n const fit = (element: HTMLElement) => {\n element.style.maxWidth = `${width}px`;\n element.style.maxHeight = `${height}px`;\n };\n const place = (element: HTMLElement, x: number, y: number) => {\n const bounds = element.getBoundingClientRect();\n element.style.left = `${Math.max(left, Math.min(x, left + width - bounds.width))}px`;\n element.style.top = `${Math.max(top, Math.min(y, top + height - bounds.height))}px`;\n };\n fit(dialog);\n const rect = anchor.getBoundingClientRect();\n const bounds = dialog.getBoundingClientRect();\n const below = rect.bottom + 4;\n const above = rect.top - bounds.height - 4;\n place(\n dialog,\n rect.right - bounds.width,\n below + bounds.height <= top + height || above < top ? below : above,\n );\n for (const { trigger, flyout } of flyouts) {\n if (flyout.hidden) continue;\n fit(flyout);\n const row = trigger.getBoundingClientRect();\n const menu = dialog.getBoundingClientRect();\n const size = flyout.getBoundingClientRect();\n const x =\n menu.right - 1 + size.width <= left + width ? menu.right - 1 : menu.left - size.width + 1;\n place(flyout, x, row.top);\n }\n };\n local.listen(dialog, 'close', () => local.dispose());\n local.listen(dialog, 'click', (event) => {\n if (event.target === dialog) {\n const r = dialog.getBoundingClientRect();\n const e = event as MouseEvent;\n if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom)\n local.dispose();\n }\n });\n const updateHints = () => {\n const registrations = actions.getShortcuts();\n for (const { element, action } of hints) {\n element.querySelector('.layouts-shortcut')?.remove();\n element.removeAttribute('aria-keyshortcuts');\n element.disabled = !actions.canExecuteAction(action, context);\n const label = element.getAttribute('aria-label') ?? '';\n const registration = registrations.find((entry) => entry.action === action);\n element.removeAttribute('title');\n if (!registration) continue;\n const labels = registration.bindings.map((binding) => {\n try {\n return options.formatShortcut?.(binding) ?? formatShortcut(binding);\n } catch (error) {\n report(error);\n return formatShortcut(binding);\n }\n });\n const badge = el(doc, 'kbd', 'layouts-shortcut', labels[0]);\n badge.setAttribute('aria-hidden', 'true');\n element.append(badge);\n element.title = `${label} (${labels.join(' / ')})`;\n if (!element.disabled)\n element.setAttribute(\n 'aria-keyshortcuts',\n registration.bindings.map(ariaShortcut).join(' '),\n );\n }\n positionMenus();\n };\n refreshShortcuts = updateHints;\n local.add(() => {\n if (refreshShortcuts === updateHints) refreshShortcuts = () => {};\n });\n const target = { dialog, context, close: () => local.dispose() };\n shortcutTarget = target;\n local.add(() => {\n if (shortcutTarget === target) shortcutTarget = undefined;\n });\n dialog.showModal();\n updateHints();\n const observer = new win.ResizeObserver(positionMenus);\n observer.observe(dialog);\n observer.observe(anchor);\n for (const { flyout } of flyouts) observer.observe(flyout);\n local.add(() => observer.disconnect());\n local.listen(win, 'resize', positionMenus);\n local.listen(doc, 'scroll', positionMenus, { capture: true });\n if (win.visualViewport) {\n local.listen(win.visualViewport, 'resize', positionMenus);\n local.listen(win.visualViewport, 'scroll', positionMenus);\n }\n dialog.focus({ preventScroll: true });\n }\n return {\n getShortcutTarget: () => shortcutTarget,\n refreshShortcuts: () => refreshShortcuts(),\n open,\n addTab(anchor: HTMLElement, group: Group) {\n const layout = options.store.getSnapshot();\n open(\n anchor,\n group.active ? layout.panes[group.active] : undefined,\n group,\n undefined,\n 0.5,\n false,\n true,\n );\n },\n openEmpty(anchor: HTMLElement, group: Group) {\n const source = Object.values(options.store.getSnapshot().panes).find(\n (pane) => pane.header !== false,\n );\n open(anchor, source, group, undefined, 0.5, true);\n },\n dispose() {\n current?.dispose();\n for (const picker of persistentPickers.values()) picker.dispose();\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAyB,aAAa,EAAe,MAAM,YAAY,CAAC;AAkBnG,wBAAgB,WAAW,CAAC,KAAK,GAAG,OAAO,EACzC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,GAC1B,aAAa,CAAC,KAAK,CAAC,CAgCtB"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,aAAa,EAAyB,aAAa,EAAe,MAAM,YAAY,CAAC;AAkBnG,wBAAgB,WAAW,CAAC,KAAK,GAAG,OAAO,EACzC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,GAC1B,aAAa,CAAC,KAAK,CAAC,CAgCtB"}
package/dist/renderer.js CHANGED
@@ -10,6 +10,8 @@ import { bindCorners } from './corners.js';
10
10
  import { applyTheme } from './theme.js';
11
11
  import { fillTabs } from './tabs.js';
12
12
  import { bindShortcuts } from './shortcuts.js';
13
+ import { createActions } from './actions.js';
14
+ import { CommandRegistry } from './command-registry.js';
13
15
  import { LayoutStore, createLayout, allocate, bounds as modelBounds, DIVIDER, findNode, groups, paneIds, } from 'quilt-core';
14
16
  import { Scope, el, syncChildren } from './lifetime.js';
15
17
  import { mountPane } from './panes.js';
@@ -102,14 +104,39 @@ function mountLayoutInternal(host, input, scope) {
102
104
  region.scope.dispose();
103
105
  regions.clear();
104
106
  });
105
- const menu = createPaneMenu(root, options, windows, render, error, requestClose);
107
+ const commands = new CommandRegistry(options, error);
108
+ scope.add(() => commands.dispose());
109
+ const actions = createActions(options, {
110
+ registry: commands,
111
+ context: () => shortcutContext(),
112
+ disposed: () => disposed,
113
+ close: requestClose,
114
+ popout: (id) => windows.open(id),
115
+ report: error,
116
+ create(action, group, pane) {
117
+ const region = regions.get(group.id);
118
+ if (!region)
119
+ throw new Error('Region is not mounted');
120
+ const anchor = region.header ?? region.element;
121
+ if (action === 'addTab')
122
+ menu.addTab(anchor, group);
123
+ else {
124
+ const direction = action === 'splitLeft'
125
+ ? 'left'
126
+ : action === 'splitRight'
127
+ ? 'right'
128
+ : action === 'splitUp'
129
+ ? 'top'
130
+ : 'bottom';
131
+ menu.open(anchor, pane, group, direction);
132
+ }
133
+ },
134
+ });
135
+ const menu = createPaneMenu(root, options, render, error, actions);
136
+ scope.add(commands.subscribe(menu.refreshShortcuts));
106
137
  scope.add(() => menu.dispose());
107
138
  scope.add(() => dragScope?.dispose());
108
- bindShortcuts(root, options, scope, act, (group) => {
109
- const region = regions.get(group.id);
110
- if (region)
111
- menu.addTab(region.header ?? region.element, group);
112
- });
139
+ const shortcutContext = bindShortcuts(root, actions.getShortcuts, scope, actions.canExecuteAction, actions.executeAction, menu.getShortcutTarget);
113
140
  const renderOptions = { ...options, onError: error };
114
141
  function button(text, title, action) {
115
142
  const b = el(doc, 'button', 'layouts-button', text);
@@ -668,6 +695,11 @@ function mountLayoutInternal(host, input, scope) {
668
695
  render();
669
696
  return {
670
697
  store: options.store,
698
+ ...actions,
699
+ getShortcutConflicts: () => commands.getShortcutConflicts(),
700
+ getCommands: () => commands.getCommands(),
701
+ registerShortcut: (action, registration) => commands.registerShortcut(action, registration),
702
+ registerCommand: (command) => commands.registerCommand(command),
671
703
  requestClose,
672
704
  refreshTheme,
673
705
  updateOptions(next) {
@@ -678,6 +710,7 @@ function mountLayoutInternal(host, input, scope) {
678
710
  const candidate = { ...options, ...next };
679
711
  if (candidate.registry && (next.renderers || next.tabs))
680
712
  throw new Error('registry cannot be combined with renderers or tabs');
713
+ const commitCommands = commands.prepare(next);
681
714
  validateTheme(candidate.theme ?? {});
682
715
  validateTabBar(candidate.tabBar ?? {});
683
716
  const sameRegistrations = candidate.registry === options.registry ||
@@ -699,19 +732,20 @@ function mountLayoutInternal(host, input, scope) {
699
732
  (!candidate.registry && candidate.tabs !== options.tabs) ||
700
733
  candidate.renderIcon !== options.renderIcon ||
701
734
  candidate.popouts !== options.popouts ||
702
- JSON.stringify(candidate.messages) !== JSON.stringify(options.messages) ||
703
- JSON.stringify(candidate.shortcuts) !== JSON.stringify(options.shortcuts);
735
+ JSON.stringify(candidate.messages) !== JSON.stringify(options.messages);
704
736
  // Clear maps derived from the old registry when returning to low-level registration.
705
737
  if ('registry' in next && !next.registry && options.registry) {
706
738
  Object.assign(options, { renderers: undefined, tabs: undefined });
707
739
  }
708
740
  Object.assign(options, next);
741
+ commitCommands();
709
742
  if ('theme' in next)
710
743
  applyTheme(root, options.theme ?? {});
711
744
  if ('tabBar' in next)
712
745
  tabBar = structuredClone(options.tabBar ?? {});
713
746
  bindRegistry();
714
747
  refreshOptions(repaintChrome);
748
+ menu.refreshShortcuts();
715
749
  refreshTheme();
716
750
  },
717
751
  exportWorkspace() {