flexdesk 0.17.1 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +206 -1
- package/css/base.css +23 -1
- package/css/flexdesk.css +37 -1
- package/dist/flexdesk.css +37 -1
- package/dist/widgets.js +188 -74
- package/dist/widgets.js.map +2 -2
- package/dist/wm.js +90 -10
- package/dist/wm.js.map +2 -2
- package/package.json +1 -1
- package/src/tiling/command_palette.js +46 -7
- package/src/tiling/content_registry.js +3 -0
- package/src/tiling/entity_sources.js +10 -0
- package/src/tiling/wm.js +65 -3
- package/src/ui/components/notification_history.js +17 -24
- package/src/ui/components/settings_view.js +192 -51
- package/src/ui/notification_center.js +46 -8
package/package.json
CHANGED
|
@@ -72,6 +72,17 @@
|
|
|
72
72
|
* drillLabel the Tab hint ("search rows"); Tab is offered only with it
|
|
73
73
|
* shortcut a key binding drawn on the right
|
|
74
74
|
* verb the Enter hint ('open' by default, 'run' for a command)
|
|
75
|
+
* enabled `() => boolean` (0.17.2). False: the row is still listed and
|
|
76
|
+
* the arrows still reach it, but it is drawn greyed
|
|
77
|
+
* (`twm-cmdpal__item--disabled`, aria-disabled="true") and
|
|
78
|
+
* picking it — click, Enter, Ctrl/Shift+Enter — does nothing and
|
|
79
|
+
* leaves the palette open. Asked on every draw and every pick.
|
|
80
|
+
* disabledReason the disabled row's tooltip (its `title`)
|
|
81
|
+
*
|
|
82
|
+
* A catalog source with `scopedOnly: true` (0.17.2) contributes no rows to a
|
|
83
|
+
* plain typed query, in either layout: its rows are listed only once its
|
|
84
|
+
* prefix has made the type chip (`help: solver`).
|
|
85
|
+
*
|
|
75
86
|
* `hint` keeps its old meaning — drawn AND searched — for a row that sets
|
|
76
87
|
* neither `context` nor `keywords`. A group's header is the taxonomy's
|
|
77
88
|
* `plural` for the kind, else its `label`.
|
|
@@ -281,8 +292,7 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
281
292
|
const render = () => {
|
|
282
293
|
if (grouped) { renderGrouped(); return; }
|
|
283
294
|
list.innerHTML = filtered.slice(0, MAX_ROWS).map((e, i) => `
|
|
284
|
-
|
|
285
|
-
data-idx="${i}">
|
|
295
|
+
${_itemOpen(e, i === active ? ' twm-cmdpal__item--active' : '', `data-idx="${i}"`)}
|
|
286
296
|
<span class="material-symbols-outlined twm-cmdpal__icon">${e.icon || 'arrow_right'}</span>
|
|
287
297
|
<span class="twm-cmdpal__label">${_esc(e.label || e.id)}</span>
|
|
288
298
|
<span class="twm-cmdpal__kind">${e.kind}</span>
|
|
@@ -343,7 +353,7 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
343
353
|
const side = r.shortcut
|
|
344
354
|
? `<kbd class="twm-cmdpal__shortcut">${_esc(r.shortcut)}</kbd>`
|
|
345
355
|
: `<span class="twm-cmdpal__kind">${_esc(kindLabel(r))}</span>`;
|
|
346
|
-
return
|
|
356
|
+
return `${_itemOpen(r, on, `data-idx="${i}" role="option"`)}
|
|
347
357
|
<span class="material-symbols-outlined twm-cmdpal__icon">${_esc(r.icon || 'arrow_right')}</span>
|
|
348
358
|
<span class="twm-cmdpal__main"><span class="twm-cmdpal__label">${_mark(r.label || r.id, r._hits)}</span>${ctx}</span>
|
|
349
359
|
<span class="twm-cmdpal__side">${side}<span class="twm-cmdpal__acts">${acts.join('')}</span></span>
|
|
@@ -453,6 +463,9 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
453
463
|
const picked = filtered[i];
|
|
454
464
|
if (!picked) return;
|
|
455
465
|
if (picked.more) { showAll(picked.more); return; }
|
|
466
|
+
// A disabled row is listed so it can say why; picking it runs
|
|
467
|
+
// nothing and the palette stays open on it.
|
|
468
|
+
if (_isDisabled(picked)) return;
|
|
456
469
|
// Split and window open a COPY; a single kind refuses both, and the
|
|
457
470
|
// palette stays open on the row whose hints say why.
|
|
458
471
|
if (mode !== 'open' && isSingle(picked)) return;
|
|
@@ -585,6 +598,7 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
585
598
|
return;
|
|
586
599
|
}
|
|
587
600
|
let pool = entities;
|
|
601
|
+
if (!filterSet) pool = pool.filter((e) => !e._scopedOnly);
|
|
588
602
|
if (commandsOnly) pool = pool.filter((e) => e.kind === 'command');
|
|
589
603
|
else if (filterSet) pool = pool.filter((e) => filterSet.has(_groupOf(e)) || filterSet.has(e.kind));
|
|
590
604
|
else if (q.length < commandMinChars) pool = pool.filter((e) => e.kind !== 'command');
|
|
@@ -649,7 +663,7 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
649
663
|
const filterSet = typeFilter ? new Set(typeFilter) : null;
|
|
650
664
|
const pool = filterSet
|
|
651
665
|
? entities.filter((e) => filterSet.has(e.kind))
|
|
652
|
-
: entities;
|
|
666
|
+
: entities.filter((e) => !e._scopedOnly);
|
|
653
667
|
if (!q) {
|
|
654
668
|
// Scoped + empty query → list every entity of that
|
|
655
669
|
// kind so the user sees what's available. Unscoped +
|
|
@@ -715,10 +729,18 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
715
729
|
}
|
|
716
730
|
return [...staticCommands, ...extra];
|
|
717
731
|
};
|
|
732
|
+
// A `scopedOnly` source's rows are marked here, from the catalog's
|
|
733
|
+
// own source list, so only the rows the catalog produced are held
|
|
734
|
+
// back — a command or a Recent row of the same kind is not.
|
|
735
|
+
const scopedKinds = new Set((catalog?.sources || [])
|
|
736
|
+
.filter((s) => s?.scopedOnly === true).map((s) => s.navKind));
|
|
737
|
+
const tagScoped = (rows) => (scopedKinds.size
|
|
738
|
+
? rows.map((r) => (scopedKinds.has(r.kind) ? { ...r, _scopedOnly: true } : r))
|
|
739
|
+
: rows);
|
|
718
740
|
// Objects before commands in the grouped layout, so that a tie that
|
|
719
741
|
// survives every rule goes to the object (first seen wins).
|
|
720
742
|
const withCommands = (rows) => (grouped ? [...rows, ...commandRows()] : [...commandRows(), ...rows]);
|
|
721
|
-
entities = _decorateIcons(withCommands(cache && cached ? cached : []), taxonomy);
|
|
743
|
+
entities = _decorateIcons(withCommands(tagScoped(cache && cached ? cached : [])), taxonomy);
|
|
722
744
|
if (grouped) {
|
|
723
745
|
refilter();
|
|
724
746
|
if (typeof empty === 'function') {
|
|
@@ -735,7 +757,7 @@ export function createCommandPalette({ wm, api, taxonomy, catalog, placeholder =
|
|
|
735
757
|
const loaded = await catalog.loadAll(api);
|
|
736
758
|
if (cache) cached = loaded;
|
|
737
759
|
if (overlay !== mine) return;
|
|
738
|
-
entities = _decorateIcons(withCommands(loaded), taxonomy);
|
|
760
|
+
entities = _decorateIcons(withCommands(tagScoped(loaded)), taxonomy);
|
|
739
761
|
if (grouped ? (!scope && (input.value || typeFilter)) : input.value) refilter();
|
|
740
762
|
} catch (err) {
|
|
741
763
|
console.warn('[cmdpal] entity load failed', err);
|
|
@@ -859,9 +881,26 @@ function _searched(r) {
|
|
|
859
881
|
}
|
|
860
882
|
function _groupOf(r) { return r.group || r.kind; }
|
|
861
883
|
|
|
884
|
+
/** 0.17.2. `enabled` is asked each time; one that throws counts as no. */
|
|
885
|
+
function _isDisabled(r) {
|
|
886
|
+
if (!r || typeof r.enabled !== 'function') return false;
|
|
887
|
+
try { return !r.enabled(); }
|
|
888
|
+
catch (err) { console.warn('[cmdpal] enabled() threw', err); return true; }
|
|
889
|
+
}
|
|
890
|
+
/** A row's opening `<div>` with its classes (`twm-cmdpal__item` plus `extra`)
|
|
891
|
+
* and attributes. A disabled row adds its class, `aria-disabled` and, given a
|
|
892
|
+
* `disabledReason`, the reason as its `title`. */
|
|
893
|
+
function _itemOpen(r, extra, attrs) {
|
|
894
|
+
const off = _isDisabled(r);
|
|
895
|
+
const cls = 'twm-cmdpal__item' + extra + (off ? ' twm-cmdpal__item--disabled' : '');
|
|
896
|
+
const refused = !off ? ''
|
|
897
|
+
: ' aria-disabled="true"' + (r.disabledReason ? ` title="${_esc(r.disabledReason)}"` : '');
|
|
898
|
+
return `<div class="${cls}"${refused} ${attrs}>`;
|
|
899
|
+
}
|
|
900
|
+
|
|
862
901
|
/** Strip the palette's private fields before a row leaves it. */
|
|
863
902
|
function _public(r) {
|
|
864
|
-
const { _hits, _score, ...rest } = r;
|
|
903
|
+
const { _hits, _score, _scopedOnly, ...rest } = r;
|
|
865
904
|
return rest;
|
|
866
905
|
}
|
|
867
906
|
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* The tile renderer calls the factory once when the leaf is first
|
|
10
10
|
* mounted with a given (kind, props) pair, and `destroy()` on unmount.
|
|
11
|
+
* A content of a `single` kind may return `navigate(props)`: an open path
|
|
12
|
+
* that reveals the instance instead of mounting it hands it the new props
|
|
13
|
+
* (`wm.revealInstance`, 0.17.2).
|
|
11
14
|
*
|
|
12
15
|
* `ctx` is the shell's ctx plus, per leaf, `leafId` and `setTitle(text)` —
|
|
13
16
|
* rename the pane's chrome title from inside the content, at mount or any
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
* row to the record shape every search surface consumes.
|
|
28
28
|
* Return `null` to skip the row.
|
|
29
29
|
*
|
|
30
|
+
* scopedOnly? `true` keeps the source's rows out of a plain typed query:
|
|
31
|
+
* the command palette lists them only behind the source's
|
|
32
|
+
* prefix (`<navKind>:` or an alias that resolves to it). For a
|
|
33
|
+
* source too broad to compete with everything else — help
|
|
34
|
+
* topics, say. Absent or `false`: searched as always (0.17.2).
|
|
35
|
+
*
|
|
30
36
|
* ## Aggregation
|
|
31
37
|
*
|
|
32
38
|
* An embedder whose backend can answer for every source in ONE call
|
|
@@ -48,6 +54,10 @@ export function createEntityCatalog({ sources, aliases = {}, aggregate = null }
|
|
|
48
54
|
throw new TypeError(
|
|
49
55
|
`createEntityCatalog: source '${s?.navKind ?? '?'}' needs navKind + list() + shape()`);
|
|
50
56
|
}
|
|
57
|
+
if (s.scopedOnly != null && typeof s.scopedOnly !== 'boolean') {
|
|
58
|
+
throw new TypeError(
|
|
59
|
+
`createEntityCatalog: source '${s.navKind}' \`scopedOnly\` must be a boolean when present`);
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
if (aggregate != null && typeof aggregate !== 'function') {
|
|
53
63
|
throw new TypeError('createEntityCatalog: `aggregate` must be a function when present');
|
package/src/tiling/wm.js
CHANGED
|
@@ -348,10 +348,57 @@ export class WindowManager {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
/** Reveal the instance of a single kind that is open: answers whether
|
|
351
|
-
* there was one. Every open path asks this first.
|
|
351
|
+
* there was one. Every open path asks this first.
|
|
352
|
+
*
|
|
353
|
+
* An open path names props too, and revealing alone would drop them: the
|
|
354
|
+
* instance keeps showing what it was opened with. So a revealed content
|
|
355
|
+
* that returned a `navigate(props)` hook from its mount is handed the new
|
|
356
|
+
* props — once per open, the same props twice are two calls — and they
|
|
357
|
+
* are recorded on its tab, so a page restore or a reload mounts it with
|
|
358
|
+
* the latest. A content without the hook is revealed as it is: its tab
|
|
359
|
+
* keeps its props and nothing is called. So is every content when the
|
|
360
|
+
* open names no props at all — a top-nav button, `openInPrimary(kind)` —
|
|
361
|
+
* which asks to SEE the instance, not to empty it. */
|
|
352
362
|
revealInstance(kind, props = {}) {
|
|
353
363
|
const loc = this.findInstance(kind, props);
|
|
354
|
-
|
|
364
|
+
if (!loc || !this._revealAt(loc)) return false;
|
|
365
|
+
if (props && Object.keys(props).length) this._deliverProps(kind, props);
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Hand a revealed instance the props it was opened with, and record them
|
|
370
|
+
* on its tab (and the tile's `content` mirror of it, re-baselining the
|
|
371
|
+
* tile so the write does not rebuild it). Looks
|
|
372
|
+
* the instance up again: a reveal from a page archive moved it into the
|
|
373
|
+
* tile's tabs. A throwing hook is a warning, never a crash. */
|
|
374
|
+
_deliverProps(kind, props) {
|
|
375
|
+
const loc = this.findInstance(kind, props);
|
|
376
|
+
if (!loc || loc.where === 'archive') return;
|
|
377
|
+
const scope = loc.where === 'window' ? { windowId: loc.windowId } : { leafId: loc.leafId };
|
|
378
|
+
const content = this._scopeContent(scope);
|
|
379
|
+
if (typeof content?.navigate !== 'function') return;
|
|
380
|
+
const next = { ...(props || {}) };
|
|
381
|
+
if (loc.where === 'window') {
|
|
382
|
+
const rec = this._windowToLeaf.get(loc.windowId);
|
|
383
|
+
const tab = Array.isArray(rec.tabs) ? rec.tabs[loc.idx] : null;
|
|
384
|
+
if (tab) tab.props = { ...next };
|
|
385
|
+
if (rec.original) rec.original = { ...rec.original, props: { ...next } };
|
|
386
|
+
} else {
|
|
387
|
+
const leaf = this._tree().get(loc.leafId);
|
|
388
|
+
const expected = this.renderer?.leafKey?.(loc.leafId) ?? undefined;
|
|
389
|
+
leaf.tabs[loc.idx].props = { ...next };
|
|
390
|
+
// The tab is the active one now, and `content` mirrors it: the
|
|
391
|
+
// next tab activation re-mirrors it anyway, and a mirror left
|
|
392
|
+
// behind would change the tile's key then and rebuild it.
|
|
393
|
+
if (leaf.content?.kind === kind) leaf.content = { ...leaf.content, props: { ...next } };
|
|
394
|
+
this.renderer?.rebaselineLeaf?.(loc.leafId, expected);
|
|
395
|
+
}
|
|
396
|
+
this._persist();
|
|
397
|
+
try {
|
|
398
|
+
content.navigate({ ...next });
|
|
399
|
+
} catch (err) {
|
|
400
|
+
console.warn('[wm] content navigate threw', err);
|
|
401
|
+
}
|
|
355
402
|
}
|
|
356
403
|
|
|
357
404
|
/** A leaf's archived pages that can come back — every `pageTabs` entry
|
|
@@ -4106,8 +4153,23 @@ export class WindowManager {
|
|
|
4106
4153
|
*
|
|
4107
4154
|
* The lower-level primitives (`openFromContext`,
|
|
4108
4155
|
* `openInTabFromContext`, `openInTabInPrimary`, `openInPrimary`,
|
|
4109
|
-
* `openInWindow`) stay internal; callers prefer `wm.navigate(...)`.
|
|
4156
|
+
* `openInWindow`) stay internal; callers prefer `wm.navigate(...)`.
|
|
4157
|
+
*
|
|
4158
|
+
* Returns `true` once the navigation is routed. A kind the shell's
|
|
4159
|
+
* content registry has no factory for is refused instead: one
|
|
4160
|
+
* `console.warn` naming it, no tile, tab, window or history touched, and
|
|
4161
|
+
* `false` — never a placeholder tile, never a throw. */
|
|
4110
4162
|
navigate(kind, props = {}, opts = {}) {
|
|
4163
|
+
if (!this.content.has(kind)) {
|
|
4164
|
+
console.warn(`[wm] navigate: no content registered for kind "${String(kind)}"`);
|
|
4165
|
+
return false;
|
|
4166
|
+
}
|
|
4167
|
+
this._route(kind, props, opts);
|
|
4168
|
+
return true;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
/** The routing behind `navigate`, for a kind known to be registered. */
|
|
4172
|
+
_route(kind, props, opts) {
|
|
4111
4173
|
const { ctx = null, transient = false } = opts;
|
|
4112
4174
|
// Append the tab but stay where you are. Only meaningful with `newTab`.
|
|
4113
4175
|
const background = !!opts.background;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* NotificationHistory - Bottom bar notification history panel
|
|
3
3
|
*
|
|
4
4
|
* Bell icon in the global-bottom-bar that opens a popover listing past notifications.
|
|
5
|
-
* Reads from NotificationCenter.history
|
|
6
|
-
*
|
|
5
|
+
* Reads from NotificationCenter.history and follows it through
|
|
6
|
+
* `notificationCenter.subscribe()` (0.17.3): every entry the centre records — a
|
|
7
|
+
* toast from `show()`/`warn()`/... or from the bus — is one unread, until the
|
|
8
|
+
* popover is opened. The bus is not watched for toasts.
|
|
7
9
|
*
|
|
8
10
|
* THREE OPTIONS, all additive (FlexDesk STORY-0020); without them it is the bell
|
|
9
11
|
* it always was:
|
|
@@ -34,7 +36,8 @@ export class NotificationHistory {
|
|
|
34
36
|
|
|
35
37
|
this.triggerEl = null;
|
|
36
38
|
this.badgeEl = null;
|
|
37
|
-
|
|
39
|
+
/** Entries recorded since the popover was last opened. */
|
|
40
|
+
this.unreadCount = 0;
|
|
38
41
|
this._popoverCleanup = null;
|
|
39
42
|
this._subscriptions = [];
|
|
40
43
|
}
|
|
@@ -80,10 +83,14 @@ export class NotificationHistory {
|
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
//
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
// What is in the history at mount is not unread.
|
|
87
|
+
this.unreadCount = 0;
|
|
88
|
+
const unsubscribe = this.notificationCenter?.subscribe?.(() => {
|
|
89
|
+
this.unreadCount += 1;
|
|
90
|
+
this.#updateBadge();
|
|
91
|
+
});
|
|
92
|
+
if (typeof unsubscribe === 'function') this._subscriptions.push(unsubscribe);
|
|
93
|
+
this.#updateBadge();
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
unmount() {
|
|
@@ -99,20 +106,6 @@ export class NotificationHistory {
|
|
|
99
106
|
this.badgeEl = null;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
|
-
#subscribeEvents() {
|
|
103
|
-
if (!this.eventBus) return;
|
|
104
|
-
|
|
105
|
-
// Update badge whenever a new notification comes in
|
|
106
|
-
const badgeUpdate = () => queueMicrotask(() => this.#updateBadge());
|
|
107
|
-
const events = ['toast:show', 'notification:show', 'log:entry',
|
|
108
|
-
'workspace:save:failed', 'workspace:import:failed'];
|
|
109
|
-
|
|
110
|
-
events.forEach(name => {
|
|
111
|
-
const handle = this.eventBus.on(name, badgeUpdate);
|
|
112
|
-
this._subscriptions.push(() => handle?.dispose?.());
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
109
|
/** The Alerts tab, asked for on the bus — or the embedder's own verb. */
|
|
117
110
|
#openAlerts() {
|
|
118
111
|
if (this.onOpen) {
|
|
@@ -126,7 +119,7 @@ export class NotificationHistory {
|
|
|
126
119
|
const historyLen = this.notificationCenter?.history?.length ?? 0;
|
|
127
120
|
const unread = this.alertLog
|
|
128
121
|
? this.alertLog.unreadCount()
|
|
129
|
-
: Math.
|
|
122
|
+
: Math.min(this.unreadCount, historyLen);
|
|
130
123
|
|
|
131
124
|
if (!this.badgeEl) return;
|
|
132
125
|
|
|
@@ -164,7 +157,7 @@ export class NotificationHistory {
|
|
|
164
157
|
this.#closePanel();
|
|
165
158
|
|
|
166
159
|
// Mark all as seen
|
|
167
|
-
this.
|
|
160
|
+
this.unreadCount = 0;
|
|
168
161
|
this.#updateBadge();
|
|
169
162
|
|
|
170
163
|
const panel = document.createElement('div');
|
|
@@ -197,7 +190,7 @@ export class NotificationHistory {
|
|
|
197
190
|
header.querySelector('.twm-notification-history__clear-btn')
|
|
198
191
|
.addEventListener('click', () => {
|
|
199
192
|
this.notificationCenter.history.splice(0);
|
|
200
|
-
this.
|
|
193
|
+
this.unreadCount = 0;
|
|
201
194
|
this.#updateBadge();
|
|
202
195
|
this.#renderList(list);
|
|
203
196
|
});
|