@unson/brainbase-mcp 0.47.2 → 0.47.4

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Reusable, host-independent entity index cache.
3
+ *
4
+ * A host that resolves entity indexes (search, list_entities, get_entity,
5
+ * resolve_entity) rebuilds the whole index on every call today. This cache
6
+ * keeps a single in-memory index and only rebuilds when the TTL expires, the
7
+ * caller invalidates it, or an optional revision marker changes. It is
8
+ * provider-agnostic and stores no tenant, member, role, approval, or audit
9
+ * data; the caller supplies both the index builder and the optional revision
10
+ * change detector.
11
+ */
12
+ export interface EntityIndexCacheOptions<T> {
13
+ build: () => Promise<T>;
14
+ ttlMs: number;
15
+ now?: () => number;
16
+ revision?: () => Promise<string | null | undefined>;
17
+ }
18
+ export interface EntityIndexCachePeek<T> {
19
+ value: T;
20
+ builtAt: number;
21
+ revision?: string;
22
+ }
23
+ export interface EntityIndexCacheStats {
24
+ builds: number;
25
+ hits: number;
26
+ invalidations: number;
27
+ }
28
+ export interface EntityIndexCache<T> {
29
+ get(): Promise<T>;
30
+ invalidate(reason?: string): void;
31
+ peek(): EntityIndexCachePeek<T> | null;
32
+ stats(): EntityIndexCacheStats;
33
+ }
34
+ export declare class EntityIndexUnstableError extends Error {
35
+ readonly code = "entity_index_unstable";
36
+ constructor(message: string);
37
+ }
38
+ export declare function createEntityIndexCache<T>(options: EntityIndexCacheOptions<T>): EntityIndexCache<T>;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Reusable, host-independent entity index cache.
3
+ *
4
+ * A host that resolves entity indexes (search, list_entities, get_entity,
5
+ * resolve_entity) rebuilds the whole index on every call today. This cache
6
+ * keeps a single in-memory index and only rebuilds when the TTL expires, the
7
+ * caller invalidates it, or an optional revision marker changes. It is
8
+ * provider-agnostic and stores no tenant, member, role, approval, or audit
9
+ * data; the caller supplies both the index builder and the optional revision
10
+ * change detector.
11
+ */
12
+ export class EntityIndexUnstableError extends Error {
13
+ code = 'entity_index_unstable';
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = 'EntityIndexUnstableError';
17
+ }
18
+ }
19
+ export function createEntityIndexCache(options) {
20
+ if (typeof options?.build !== 'function') {
21
+ throw new TypeError('entity index cache requires a build function');
22
+ }
23
+ if (typeof options.ttlMs !== 'number' || !Number.isFinite(options.ttlMs) || options.ttlMs <= 0) {
24
+ throw new TypeError('entity index cache ttlMs must be a positive finite number');
25
+ }
26
+ const now = options.now ?? Date.now;
27
+ const revisionFn = options.revision;
28
+ const MAX_STABLE_BUILD_ATTEMPTS = 3;
29
+ const MAX_RESOLVE_ATTEMPTS = 3;
30
+ let entry = null;
31
+ let inflightGet = null;
32
+ let generation = 0;
33
+ let builds = 0;
34
+ let hits = 0;
35
+ let invalidations = 0;
36
+ async function readRevision() {
37
+ if (!revisionFn) {
38
+ return { ok: true, value: undefined };
39
+ }
40
+ try {
41
+ return { ok: true, value: await revisionFn() };
42
+ }
43
+ catch {
44
+ return { ok: false, value: undefined };
45
+ }
46
+ }
47
+ async function buildStable() {
48
+ for (let attempt = 1;; attempt++) {
49
+ let before = { ok: true, value: undefined };
50
+ if (revisionFn) {
51
+ before = await readRevision();
52
+ }
53
+ builds++;
54
+ const value = await options.build();
55
+ let after = { ok: true, value: undefined };
56
+ if (revisionFn) {
57
+ after = await readRevision();
58
+ }
59
+ if (!before.ok || !after.ok) {
60
+ // Fail-closed: when the revision cannot be read before or after the
61
+ // build we cannot prove the index is current, so it is never cached.
62
+ // The freshly built value is still returned to this caller (matching
63
+ // the serve path, which rebuilds rather than rejects on a revision
64
+ // read failure), but the next get() rebuilds instead of serving an
65
+ // unverified index within the TTL.
66
+ return { value, revision: undefined, commit: false };
67
+ }
68
+ if (before.value === after.value) {
69
+ return { value, revision: after.value, commit: true };
70
+ }
71
+ if (attempt >= MAX_STABLE_BUILD_ATTEMPTS) {
72
+ throw new EntityIndexUnstableError(`entity index did not stabilize after ${MAX_STABLE_BUILD_ATTEMPTS} builds: revision kept changing`);
73
+ }
74
+ }
75
+ }
76
+ async function resolve() {
77
+ for (let attempt = 1;; attempt++) {
78
+ const startedGeneration = generation;
79
+ if (entry && now() - entry.builtAt < options.ttlMs) {
80
+ let serve = true;
81
+ if (revisionFn) {
82
+ try {
83
+ const revision = await revisionFn();
84
+ if (revision !== entry.revision) {
85
+ serve = false;
86
+ }
87
+ }
88
+ catch {
89
+ serve = false;
90
+ }
91
+ }
92
+ if (serve && startedGeneration === generation) {
93
+ hits++;
94
+ return entry.value;
95
+ }
96
+ }
97
+ let built;
98
+ try {
99
+ built = await buildStable();
100
+ }
101
+ catch (error) {
102
+ entry = null;
103
+ throw error;
104
+ }
105
+ if (startedGeneration !== generation) {
106
+ if (attempt >= MAX_RESOLVE_ATTEMPTS) {
107
+ throw new EntityIndexUnstableError(`entity index was invalidated ${MAX_RESOLVE_ATTEMPTS} times while resolving; giving up`);
108
+ }
109
+ continue;
110
+ }
111
+ if (built.commit) {
112
+ entry = { value: built.value, builtAt: now(), revision: built.revision };
113
+ }
114
+ return built.value;
115
+ }
116
+ }
117
+ function get() {
118
+ if (inflightGet) {
119
+ return inflightGet;
120
+ }
121
+ const promise = resolve().finally(() => {
122
+ inflightGet = null;
123
+ });
124
+ inflightGet = promise;
125
+ return promise;
126
+ }
127
+ function invalidate(_reason) {
128
+ invalidations++;
129
+ entry = null;
130
+ generation++;
131
+ }
132
+ function peek() {
133
+ if (!entry) {
134
+ return null;
135
+ }
136
+ const result = { value: entry.value, builtAt: entry.builtAt };
137
+ if (typeof entry.revision === 'string') {
138
+ result.revision = entry.revision;
139
+ }
140
+ return result;
141
+ }
142
+ function stats() {
143
+ return { builds, hits, invalidations };
144
+ }
145
+ return { get, invalidate, peek, stats };
146
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.47.2",
3
+ "version": "0.47.4",
4
4
  "description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js"
17
17
  },
18
+ "./entity-index-cache": {
19
+ "types": "./dist/entity-index-cache.d.ts",
20
+ "import": "./dist/entity-index-cache.js"
21
+ },
18
22
  "./judgment-dag": {
19
23
  "types": "./dist/judgment-dag.d.ts",
20
24
  "import": "./dist/judgment-dag.js"
@@ -620,5 +624,5 @@
620
624
  "url": "https://github.com/Unson-LLC/brainbase/issues"
621
625
  },
622
626
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
623
- "gitHead": "60ba965941afae0dd44967bec67703fbc5e78e8c"
627
+ "gitHead": "6a7f9223419008f3fa0cc57b19cadf2ca0a9ae52"
624
628
  }
package/ui/area-nav.css CHANGED
@@ -60,8 +60,7 @@
60
60
  .bb-area-link[hidden],
61
61
  .bb-area-section[hidden],
62
62
  .bb-area-section-label[hidden],
63
- .bb-area-section-links[hidden],
64
- .bb-area-tabs[hidden] {
63
+ .bb-area-section-links[hidden] {
65
64
  display: none;
66
65
  }
67
66
 
@@ -83,49 +82,11 @@
83
82
  text-align: center;
84
83
  }
85
84
 
86
- .bb-area-tabs {
87
- display: flex;
88
- gap: var(--bb-space-1);
89
- overflow-x: auto;
90
- border-bottom: 1px solid var(--bb-color-border);
91
- padding: 0 var(--bb-space-5);
92
- background: var(--bb-color-paper);
93
- scrollbar-width: none;
94
- }
95
-
96
- .bb-area-tab {
97
- min-height: 44px;
98
- display: inline-flex;
99
- flex: 0 0 auto;
100
- align-items: center;
101
- gap: var(--bb-space-2);
102
- border-bottom: 2px solid transparent;
103
- padding: 0 var(--bb-space-3);
104
- color: var(--bb-color-muted);
105
- font-size: 13px;
106
- font-weight: 620;
107
- text-decoration: none;
108
- white-space: nowrap;
109
- }
110
-
111
- .bb-area-tab:hover {
112
- color: var(--bb-color-ink);
113
- }
114
-
115
- .bb-area-tab[aria-current="page"] {
116
- border-bottom-color: var(--bb-color-accent);
117
- color: var(--bb-color-accent);
118
- }
119
-
120
- .bb-area-tab:focus-visible,
121
85
  .bb-area-link:focus-visible,
122
86
  .bb-area-section-link:focus-visible {
123
87
  outline: 2px solid var(--bb-color-accent);
124
88
  outline-offset: -2px;
125
89
  }
126
90
 
127
- @media (max-width: 760px) {
128
- .bb-area-tabs {
129
- padding: 0 var(--bb-space-4);
130
- }
131
- }
91
+ .bb-area-tabs { padding-inline: var(--bb-space-5); background: var(--bb-color-paper); }
92
+ @media (max-width: 760px) { .bb-area-tabs { padding-inline: var(--bb-space-4); } }
package/ui/area-nav.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { workspaceTabList } from './workspace-kit.js';
1
2
  /*
2
3
  * Area navigation shared by OSS Personal and the organization edition
3
4
  * (brainbase-project ledger D10).
@@ -148,14 +149,15 @@ export function createAreaNav({
148
149
  const screenHref = (screen) => screen.href ?? hrefFor(screen.id);
149
150
  const areaLabel = (area) => area.label ?? area.screens[0].label;
150
151
 
151
- const countBadge = (count, ariaLabel) => makeElement(doc, 'span', {
152
- className: 'bb-area-count',
152
+ const countBadge = (count, ariaLabel, tab = false) => makeElement(doc, 'span', {
153
+ className: tab ? 'bb-area-count bb-ws-tab-count' : 'bb-area-count',
153
154
  text: count,
154
155
  attrs: { 'aria-label': ariaLabel },
155
156
  });
156
157
 
157
158
  const nav = makeElement(doc, 'nav', { className: 'bb-area-nav', attrs: { 'aria-label': label, 'data-contract-version': AREA_NAV_CONTRACT_VERSION } });
158
159
  const tabs = makeElement(doc, 'nav', { className: 'bb-area-tabs' });
160
+ workspaceTabList(tabs);
159
161
  tabs.hidden = true;
160
162
  const areaLinks = new Map();
161
163
  const linkClass = ['bb-area-link', linkClassName].filter(Boolean).join(' ');
@@ -295,7 +297,7 @@ export function createAreaNav({
295
297
  });
296
298
  tab.append(makeElement(doc, 'span', { text: screen.label }));
297
299
  if (Number.isInteger(screen.count)) {
298
- tab.append(countBadge(screen.count, screen.waiting ? `待っているもの${screen.count}件` : `${screen.count}件`));
300
+ tab.append(countBadge(screen.count, screen.waiting ? `待っているもの${screen.count}件` : `${screen.count}件`, true));
299
301
  }
300
302
  if (!screen.external) tab.addEventListener('click', (event) => onSelect?.(screen.id, event));
301
303
  return tab;
@@ -97,4 +97,32 @@
97
97
  --bb-toolbar-caret-y: -3px;
98
98
  --bb-radius-menu: 4px;
99
99
  --bb-color-filter-selected: color-mix(in srgb, var(--bb-color-brand-indigo) 10%, var(--bb-color-paper));
100
+ /* Explicitly opted-in tab strips. */
101
+ --bb-tab-height: 44px;
102
+ --bb-tab-font-size: 13px;
103
+ --bb-tab-line-height: 20px;
104
+ --bb-tab-font-weight: 500;
105
+ --bb-tab-indicator-size: 2px;
106
+ --bb-tab-count-size: 20px;
107
+ --bb-tab-count-font-size: 12px;
108
+ /* Opt-in search band: dimensions and interaction surfaces. */
109
+ --bb-search-band-query-width: 180px;
110
+ --bb-search-band-placeholder: #9b9ba3;
111
+ --bb-search-band-selected: var(--bb-color-interaction-hover, #e5f8e1);
112
+ --bb-search-band-icon-width: 24px;
113
+ --bb-search-band-icon-stroke: 1.5;
114
+ --bb-search-band-icon-selected-stroke: 2;
115
+ --bb-search-band-chevron-width: 10px;
116
+ --bb-search-band-chevron-height: 6px;
117
+ --bb-search-band-chevron-stroke: 1.2;
118
+ --bb-search-band-header-height: 44px;
119
+ --bb-search-band-scope-padding: 13px;
120
+ --bb-search-band-scope-viewport-reserve: 192px;
121
+ --bb-search-band-scope-popup-width: 260px;
122
+ --bb-search-band-project-icon-size: 18px;
123
+ --bb-control-small-height: 28px;
124
+ --bb-create-background: #24324b;
125
+ --bb-create-hover: #1b263a;
126
+ --bb-radius-pill: 999px;
127
+
100
128
  }
@@ -14,43 +14,6 @@
14
14
  }
15
15
 
16
16
  /* The kinds as tabs, with their counts. */
17
- .bb-gr-tabs {
18
- display: flex;
19
- flex-wrap: wrap;
20
- gap: 4px;
21
- margin-top: 14px;
22
- border-bottom: 1px solid var(--bb-color-border);
23
- }
24
-
25
- .bb-gr-tab {
26
- display: inline-flex;
27
- align-items: baseline;
28
- gap: 6px;
29
- margin-bottom: -1px;
30
- border: 0;
31
- border-bottom: 2px solid transparent;
32
- padding: 8px 12px;
33
- background: transparent;
34
- color: var(--bb-color-muted);
35
- font: inherit;
36
- font-size: 13px;
37
- cursor: pointer;
38
- }
39
-
40
- .bb-gr-tab:hover {
41
- color: var(--bb-color-ink);
42
- }
43
-
44
- .bb-gr-tab.is-selected {
45
- border-bottom-color: var(--bb-color-accent);
46
- color: var(--bb-color-ink);
47
- font-weight: 680;
48
- }
49
-
50
- .bb-gr-tab:focus-visible {
51
- outline: 2px solid var(--bb-color-focus);
52
- outline-offset: -2px;
53
- }
54
17
 
55
18
  .bb-gr-tab-count {
56
19
  color: var(--bb-color-quiet);
@@ -321,3 +284,5 @@
321
284
  color: var(--bb-color-quiet);
322
285
  font-size: 12px;
323
286
  }
287
+
288
+ .bb-gr-tabs { margin-top: 14px; }
@@ -1,3 +1,4 @@
1
+ import { workspaceTabList } from './workspace-kit.js';
1
2
  /*
2
3
  * 「情報と関係」: what the local Graph holds, how records are connected, and
3
4
  * where to correct a mistake so the next MCP use sees the fix.
@@ -468,6 +469,7 @@ export function createGraphRegistryView({
468
469
  .map(({ id }) => id)
469
470
  .filter((id) => id === selected || counts.get(id)?.count !== 0);
470
471
  const tabs = makeElement(doc, 'div', { className: 'bb-gr-tabs', attrs: { role: 'tablist', 'aria-label': '種類' } });
472
+ workspaceTabList(tabs);
471
473
  for (const id of ['', ...ids]) {
472
474
  const item = counts.get(id);
473
475
  const count = Number.isInteger(item?.count) ? String(item.count)
@@ -477,7 +479,7 @@ export function createGraphRegistryView({
477
479
  attrs: { type: 'button', role: 'tab', 'aria-selected': id === selected ? 'true' : 'false', 'data-type': id, 'data-focus-key': `type:${id}` },
478
480
  });
479
481
  tab.append(makeElement(doc, 'span', { text: id ? kindLabel(id) : 'すべて' }));
480
- if (count) tab.append(makeElement(doc, 'span', { className: 'bb-gr-tab-count', text: count }));
482
+ if (count) tab.append(makeElement(doc, 'span', { className: 'bb-gr-tab-count bb-ws-tab-count', text: count }));
481
483
  tab.addEventListener('click', () => {
482
484
  if (state.query.type === id) return;
483
485
  state.query.type = id;
package/ui/inbox.css CHANGED
@@ -6,33 +6,6 @@
6
6
  * warning tone, never left out. Uses only the shared tokens in
7
7
  * brainbase-tokens.css.
8
8
  */
9
- .bb-inbox-tabs {
10
- display: flex;
11
- gap: var(--bb-space-1);
12
- margin: 0 0 var(--bb-space-4);
13
- border-bottom: 1px solid var(--bb-color-border);
14
- }
15
-
16
- .bb-inbox-tab {
17
- display: inline-flex;
18
- align-items: center;
19
- gap: 6px;
20
- margin-bottom: -1px;
21
- border: 0;
22
- border-bottom: 2px solid transparent;
23
- padding: 8px 12px;
24
- background: transparent;
25
- color: var(--bb-color-muted);
26
- font: inherit;
27
- font-size: 14px;
28
- cursor: pointer;
29
- }
30
-
31
- .bb-inbox-tab.is-selected {
32
- border-bottom-color: var(--bb-color-accent);
33
- color: var(--bb-color-ink);
34
- font-weight: 600;
35
- }
36
9
 
37
10
  .bb-inbox-count {
38
11
  min-width: 20px;
@@ -187,3 +160,5 @@ a.bb-inbox-title:focus-visible {
187
160
  width: 100%;
188
161
  }
189
162
  }
163
+
164
+ .bb-inbox-tabs { margin: 0 0 var(--bb-space-4); }
package/ui/inbox.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { workspaceTabList } from './workspace-kit.js';
1
2
  /*
2
3
  * 受信箱 (story-inbox-stage1-v1, docs/specs/inbox-stage1.md).
3
4
  *
@@ -386,6 +387,7 @@ export function createInboxUI({
386
387
 
387
388
  function renderTabs(waitingCount) {
388
389
  const bar = el(doc, 'div', { className: 'bb-inbox-tabs', attrs: { role: 'tablist', 'aria-label': '受信箱' } });
390
+ workspaceTabList(bar);
389
391
  for (const [id, label] of [['waiting', '対応待ち'], ['notices', 'お知らせ']]) {
390
392
  const selected = state.route.tab === id;
391
393
  const tab = el(doc, 'button', {
@@ -394,7 +396,7 @@ export function createInboxUI({
394
396
  attrs: { type: 'button', role: 'tab', 'aria-selected': selected ? 'true' : 'false' },
395
397
  });
396
398
  if (id === 'waiting' && Number.isInteger(waitingCount) && waitingCount > 0) {
397
- tab.append(el(doc, 'span', { className: 'bb-inbox-count', text: waitingCount, attrs: { 'aria-label': `${waitingCount}件` } }));
399
+ tab.append(el(doc, 'span', { className: 'bb-inbox-count bb-ws-tab-count', text: waitingCount, attrs: { 'aria-label': `${waitingCount}件` } }));
398
400
  }
399
401
  tab.addEventListener('click', () => go({ tab: id, view: 'waiting' }));
400
402
  bar.append(tab);
@@ -108,7 +108,7 @@
108
108
  color: var(--bb-color-danger);
109
109
  }
110
110
 
111
- .bb-minutes-toolbar {
111
+ .bb-minutes-toolbar:not(.bb-ws-search-band) {
112
112
  display: flex;
113
113
  flex-wrap: wrap;
114
114
  gap: 8px 12px;
@@ -828,7 +828,7 @@
828
828
  /* Explicit compact mode keeps other hosts' expanded presentation compatible. */
829
829
  .bb-minutes-screen.bb-minutes-compact { display: flex; flex-direction: column; gap: var(--bb-space-1); overflow: visible; }
830
830
  .bb-minutes-compact > .bb-minutes-heading, .bb-minutes-compact > .bb-minutes-status[hidden] { display: none; }
831
- .bb-minutes-compact > .bb-minutes-toolbar { flex: none; align-items: center; }
831
+ .bb-minutes-compact > .bb-minutes-toolbar:not(.bb-ws-search-band) { flex: none; align-items: center; }
832
832
  .bb-minutes-compact > .bb-minutes-columns { flex: 1; min-height: 0; }
833
833
  .bb-minutes-compact .bb-minutes-list-pane { display: block; }
834
834
  .bb-minutes-compact .bb-ws-toolbar-primary > .bb-minutes-pane-head { flex-wrap: nowrap; padding: 0; gap: var(--bb-space-2); }
@@ -843,4 +843,19 @@
843
843
 
844
844
  .bb-minutes-compact .bb-ws-toolbar-primary > .bb-minutes-pane-head { position: relative; }
845
845
  .bb-minutes-compact .bb-ws-toolbar-primary > .bb-minutes-pane-head:is(:hover, :focus) .bb-minutes-create-reason { position: absolute; z-index: 48; left: 0; top: calc(100% + var(--bb-space-2)); width: max-content; max-width: var(--bb-toolbar-popover-width); height: auto; overflow: visible; clip-path: none; padding: var(--bb-space-2) var(--bb-space-3); background: var(--bb-color-panel); border: 1px solid var(--bb-color-border); border-radius: var(--bb-radius-sm); }
846
- .bb-minutes-compact > .bb-minutes-toolbar { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: var(--bb-space-3); min-height: var(--bb-toolbar-height); padding: 0; margin: 0 0 var(--bb-space-2); border: 0; border-radius: 0; background: transparent; overflow: visible; }
846
+ .bb-minutes-compact > .bb-minutes-toolbar:not(.bb-ws-search-band) { display: flex; flex-wrap: nowrap; justify-content: space-between; gap: var(--bb-space-3); min-height: var(--bb-toolbar-height); padding: 0; margin: 0 0 var(--bb-space-2); border: 0; border-radius: 0; background: transparent; overflow: visible; }
847
+
848
+ /* Explicit search-band composition. Legacy expanded/compact presentation stays intact. */
849
+ .bb-minutes-search-band { gap: 0; overflow: visible; }
850
+ .bb-minutes-search-band .bb-ws-toolbar-primary > .bb-minutes-pane-head { flex-wrap: nowrap; padding: 0; gap: var(--bb-space-2); }
851
+ .bb-minutes-search-band .bb-ws-toolbar-primary .bb-minutes-button { display: inline-flex; align-items: center; gap: var(--bb-space-1); white-space: nowrap; min-height: var(--bb-control-compact-height); height: var(--bb-control-compact-height); padding: var(--bb-space-1) var(--bb-space-2); box-sizing: border-box; font-size: var(--bb-toolbar-font-size); }
852
+ .bb-minutes-search-band .bb-ws-toolbar-primary .bb-ws-action-icon { order: -1; }
853
+ .bb-minutes-search-band .bb-minutes-button.is-primary { background: var(--bb-create-background); border-color: var(--bb-create-background); color: var(--bb-color-paper); }
854
+ .bb-minutes-search-band .bb-minutes-button.is-primary:hover { background: var(--bb-create-hover); border-color: var(--bb-create-hover); }
855
+ .bb-minutes-search-band .bb-minutes-filter-reset { width: auto; min-width: 0; height: var(--bb-control-small-height); padding: var(--bb-space-1) var(--bb-space-2); border: 0; background: transparent; color: var(--bb-color-brand-indigo); }
856
+ @media (max-width: 760px) {
857
+ .bb-minutes-search-band .bb-ws-toolbar-primary .bb-minutes-button.is-primary { width: var(--bb-control-compact-height); min-width: var(--bb-control-compact-height); padding: var(--bb-space-2); font-size: 0; gap: 0; }
858
+ .bb-minutes-search-band .bb-ws-toolbar-primary .bb-minutes-sort-note { display: none; }
859
+ }
860
+
861
+ .bb-ws-search-band .bb-minutes-filter-reset[hidden] { display: none; }
@@ -11,7 +11,7 @@
11
11
  * changes what it asks the server for (story-meeting-minutes-list-filters-v1).
12
12
  */
13
13
 
14
- import { workspaceActionIcon, workspaceCompactToolbar, workspaceCombobox, workspaceDetailDrawer } from './workspace-kit.js';
14
+ import { workspaceActionIcon, workspaceSearchBand, workspaceCompactToolbar, workspaceCombobox, workspaceDetailDrawer } from './workspace-kit.js';
15
15
 
16
16
  export const MEETING_MINUTES_UI_CONTRACT_VERSION = 'brainbase.meeting-minutes-ui.v1';
17
17
 
@@ -686,6 +686,10 @@ export function createMeetingMinutesUI({
686
686
  meetingConnections,
687
687
  meetingParticipants,
688
688
  canCreateMeeting,
689
+ createProjectOptions,
690
+ createProjectValue,
691
+ createMeeting,
692
+ shouldOpenCreatedMeeting,
689
693
  createUnavailableReason,
690
694
  canEditMinutes,
691
695
  hostFilters = [],
@@ -727,8 +731,10 @@ export function createMeetingMinutesUI({
727
731
  let railProjectSlot = null;
728
732
  let railProjectMeeting = null;
729
733
 
730
- const compact = toolbarPresentation === 'compact';
734
+ const searchBand = toolbarPresentation === 'search-band';
735
+ const compact = searchBand || toolbarPresentation === 'compact';
731
736
  const screen = makeElement(doc, 'div', { className: `bb-minutes-screen${compact ? ' bb-minutes-compact bb-ws-neutral-controls' : ''}`, attrs: { 'data-contract-version': MEETING_MINUTES_UI_CONTRACT_VERSION } });
737
+ if (searchBand) screen.classList.add('bb-minutes-search-band');
732
738
  const heading = makeElement(doc, 'header', { className: 'bb-minutes-heading' });
733
739
  heading.append(
734
740
  makeElement(doc, 'div', { className: 'bb-minutes-eyebrow', textContent: page?.source ?? '正本の議事録' }),
@@ -746,10 +752,13 @@ export function createMeetingMinutesUI({
746
752
  attrs: { 'aria-label': '議事録', tabindex: '-1' },
747
753
  });
748
754
  const detailPane = makeElement(doc, 'section', { className: 'bb-minutes-detail-pane', attrs: { 'aria-label': '議事録詳細' } });
755
+ let createProjectBox = null;
756
+ const cleanupCreateProject = () => { createProjectBox?.destroy(); createProjectBox = null; };
749
757
  const detailDrawer = detailPresentation === 'drawer' ? workspaceDetailDrawer(doc, {
750
- title: '議事録の詳細', opener: () => listPane.querySelector('.bb-minutes-meeting-item.is-selected') ?? listPane,
758
+ title: '議事録の詳細', onClose: cleanupCreateProject, opener: () => detailPane.querySelector('.bb-minutes-create-form') ? toolbar.querySelector('.bb-minutes-button.is-primary') : listPane.querySelector('.bb-minutes-meeting-item.is-selected') ?? listPane,
751
759
  }) : null;
752
760
  if (detailDrawer) {
761
+ if (searchBand) detailDrawer.dialog.classList.add('bb-ws-search-band-drawer');
753
762
  columns.classList.add('bb-minutes-details-in-drawer');
754
763
  columns.append(listPane);
755
764
  const scope = makeElement(doc, 'div', { className: 'bb-minutes-screen bb-minutes-drawer-content' });
@@ -767,7 +776,7 @@ export function createMeetingMinutesUI({
767
776
  }
768
777
 
769
778
  function filterCombobox(label, options, value, onChange) {
770
- return workspaceCombobox(doc, { label, options, value, className: 'bb-minutes-filter-combobox', onChange });
779
+ return workspaceCombobox(doc, { label, options, value, showCount: !searchBand, className: 'bb-minutes-filter-combobox', onChange });
771
780
  }
772
781
 
773
782
  const keyword = makeElement(doc, 'input', {
@@ -795,7 +804,7 @@ export function createMeetingMinutesUI({
795
804
  if (compact) {
796
805
  const filters = makeElement(doc, 'div', { className: 'bb-minutes-compact-filters' });
797
806
  filters.append(hostSlot, filterField('期間', period, 'is-period'), participantField, statusField);
798
- compactToolbar = workspaceCompactToolbar(doc, { root: toolbar, query: keyword, filters, sort: sortBox, reset });
807
+ compactToolbar = searchBand ? workspaceSearchBand(doc, { root: toolbar, query: keyword, filters, sort: sortBox, reset, onResetSort: () => { state.sort = SORTS[0].value; renderList(); } }) : workspaceCompactToolbar(doc, { root: toolbar, query: keyword, filters, sort: sortBox, reset });
799
808
  } else toolbar.append(keywordField, hostSlot, filterField('期間', period, 'is-period'), participantField, statusField, sortField, reset);
800
809
  const hostBoxes = new Map();
801
810
 
@@ -812,16 +821,18 @@ export function createMeetingMinutesUI({
812
821
  }
813
822
 
814
823
  function filtersActive() {
815
- return clientFiltersActive() || currentHostFilters().some((filter) => text(filter.value));
824
+ const local = searchBand ? Object.keys(EMPTY_FILTERS).some(key => key !== 'query' && Boolean(state.filters[key])) : clientFiltersActive();
825
+ return local || currentHostFilters().some(filter => filter.placement !== 'scope' && (filter.multiple ? filter.values?.length : text(filter.value)));
816
826
  }
817
827
 
818
828
  function clearFilters() {
819
- state.filters = { ...EMPTY_FILTERS };
820
- keyword.value = '';
829
+ state.filters = { ...EMPTY_FILTERS, ...(searchBand ? { query: state.filters.query } : {}) };
830
+ keyword.value = state.filters.query;
821
831
  fromInput.value = '';
822
832
  toInput.value = '';
823
833
  for (const filter of currentHostFilters()) {
824
- if (text(filter.value) && typeof filter.onChange === 'function') filter.onChange('');
834
+ if (searchBand && filter.placement === 'scope') continue;
835
+ if (typeof filter.onChange === 'function' && (filter.multiple ? filter.values?.length : text(filter.value))) filter.onChange(filter.multiple ? [] : '');
825
836
  }
826
837
  renderList();
827
838
  }
@@ -839,7 +850,11 @@ export function createMeetingMinutesUI({
839
850
  const box = workspaceCombobox(doc, {
840
851
  label: text(filter.label, id),
841
852
  options,
842
- value,
853
+ value, multiple: filter.multiple === true, values: filter.values,
854
+ renderIcon: filter.renderIcon, showHints: filter.showHints !== false,
855
+ showCount: searchBand ? false : filter.showCount !== false,
856
+ align: filter.placement === 'scope' ? 'end' : 'start',
857
+ searchable: filter.placement === 'scope' ? false : 'auto',
843
858
  placeholder: text(filter.placeholder, '選択してください'),
844
859
  className: 'bb-minutes-filter-combobox',
845
860
  onChange: (next) => {
@@ -850,15 +865,22 @@ export function createMeetingMinutesUI({
850
865
  entry = { box, field: filterField(text(filter.label, id), box.root) };
851
866
  hostBoxes.set(id, entry);
852
867
  }
853
- entry.box.update({ options, value, disabled: filter.disabled === true });
868
+ entry.box.update({ options, value, values: filter.values, disabled: filter.disabled === true });
854
869
  }
855
870
  for (const [id, entry] of hostBoxes) {
856
871
  if (seen.has(id)) continue;
857
872
  entry.box.destroy();
858
873
  hostBoxes.delete(id);
859
874
  }
860
- hostSlot.replaceChildren(...hosts.map((filter) => hostBoxes.get(text(filter.id)).field));
861
- hostSlot.hidden = hosts.length === 0;
875
+ const inlineHosts = hosts.filter(filter => !searchBand || filter.placement !== 'scope');
876
+ const scopeHosts = searchBand ? hosts.filter(filter => filter.placement === 'scope') : [];
877
+ const reconcile = (parent, children) => {
878
+ if (!parent) return;
879
+ if (children.length !== parent.children.length || children.some((child, index) => parent.children[index] !== child)) parent.replaceChildren(...children);
880
+ };
881
+ reconcile(hostSlot, inlineHosts.map(filter => hostBoxes.get(text(filter.id)).field));
882
+ reconcile(compactToolbar?.scopeSlot, scopeHosts.map(filter => hostBoxes.get(text(filter.id)).box.root));
883
+ hostSlot.hidden = inlineHosts.length === 0;
862
884
 
863
885
  // Offer only the conditions the loaded records can answer (P9).
864
886
  const participants = [...new Set(meetings.flatMap(participantsOf))]
@@ -876,6 +898,7 @@ export function createMeetingMinutesUI({
876
898
  sortBox.update({ value: state.sort });
877
899
  reset.hidden = !filtersActive();
878
900
  compactToolbar?.setFiltered(filtersActive());
901
+ compactToolbar?.setSorted?.(state.sort !== SORTS[0].value);
879
902
  }
880
903
 
881
904
  function clock() {
@@ -919,7 +942,7 @@ export function createMeetingMinutesUI({
919
942
  });
920
943
  }
921
944
 
922
- function clear(node) { node.replaceChildren(); return node; }
945
+ function clear(node) { if (node === detailPane) cleanupCreateProject(); node.replaceChildren(); return node; }
923
946
 
924
947
  function canCreate() {
925
948
  if (typeof canCreateMeeting === 'function') {
@@ -1426,7 +1449,7 @@ export function createMeetingMinutesUI({
1426
1449
  const head = makeElement(doc, 'div', { className: 'bb-minutes-pane-head' });
1427
1450
  const meetings = state.meetings.filter((entry) => isRecord(entry?.meeting) && typeof entry.meeting.meeting_id === 'string');
1428
1451
  renderToolbar(meetings);
1429
- const visible = sortMeetings(meetings.filter((entry) => matchesFilters(entry, state.filters)), state.sort);
1452
+ const visible = sortMeetings(meetings.filter(entry => matchesFilters(entry, state.filters) && currentHostFilters().every(filter => typeof filter.matches !== 'function' || filter.matches(entry, filter.multiple ? filter.values ?? [] : filter.value))), state.sort);
1430
1453
  if (canCreate()) {
1431
1454
  head.append(button(doc, '会議を作成', () => renderCreateForm(), { className: 'bb-minutes-button is-primary' }));
1432
1455
  } else {
@@ -1777,6 +1800,7 @@ export function createMeetingMinutesUI({
1777
1800
  }
1778
1801
 
1779
1802
  function renderDetail(detail, documentRecord = null, selectedVersion = null) {
1803
+ detailDrawer?.setTitle('議事録の詳細');
1780
1804
  clear(detailPane);
1781
1805
  connectionsSlot = null;
1782
1806
  participantsSlot = null;
@@ -1854,6 +1878,8 @@ export function createMeetingMinutesUI({
1854
1878
  }
1855
1879
 
1856
1880
  function renderCreateForm() {
1881
+ detailDrawer?.setTitle('会議を作成');
1882
+ detailRequestGeneration += 1;
1857
1883
  detailDrawer?.open();
1858
1884
  clear(detailPane);
1859
1885
  if (!canCreate()) {
@@ -1861,7 +1887,16 @@ export function createMeetingMinutesUI({
1861
1887
  return;
1862
1888
  }
1863
1889
  const form = makeElement(doc, 'form', { className: 'bb-minutes-create-form' });
1864
- form.append(makeElement(doc, 'h2', { textContent: '会議を作成' }), makeElement(doc, 'p', { className: 'bb-minutes-item-meta', textContent: '外部サービスを接続しなくても、会議と議事録を保存できます。' }));
1890
+ form.append(makeElement(doc, 'h2', { textContent: '会議を作成' }));
1891
+ const projectOptions = typeof createProjectOptions === 'function' ? createProjectOptions() : null;
1892
+ const initialProject = typeof createProjectValue === 'function' ? createProjectValue() : '';
1893
+ let projectCode = Array.isArray(projectOptions) && projectOptions.some(option => option.value === initialProject) ? initialProject : '';
1894
+ const projectError = makeElement(doc, 'p', { className: 'bb-minutes-warning', attrs: { role: 'alert' } }); projectError.hidden = true;
1895
+ if (Array.isArray(projectOptions)) {
1896
+ createProjectBox = workspaceCombobox(doc, { label: 'プロジェクト', options: [{ value: '', label: 'プロジェクトを選択' }, ...projectOptions], value: projectCode,
1897
+ showCount: false, searchable: true, onChange: value => { projectCode = value; projectError.hidden = true; } });
1898
+ form.append(filterField('プロジェクト', createProjectBox.root), projectError);
1899
+ }
1865
1900
  const title = labelInput(doc, '会議名', { name: 'title', placeholder: '例: 週次定例' });
1866
1901
  const date = labelInput(doc, '日時(任意)', { type: 'datetime-local', name: 'scheduled_at' });
1867
1902
  const participants = labelInput(doc, '参加者(任意・カンマ区切り)', { name: 'participant_ids' });
@@ -1869,6 +1904,7 @@ export function createMeetingMinutesUI({
1869
1904
  const body = labelInput(doc, '本文(任意)', { type: 'textarea', name: 'initial_body', placeholder: '会議の本文を入力' });
1870
1905
  body.input.rows = 8;
1871
1906
  const save = makeElement(doc, 'button', { className: 'bb-minutes-button is-primary', textContent: '会議を保存', type: 'submit' });
1907
+ title.input.required = true;
1872
1908
  form.append(title.wrapper, date.wrapper, participants.wrapper, minutesTitle.wrapper, body.wrapper, save);
1873
1909
  form.addEventListener('submit', async (event) => {
1874
1910
  event.preventDefault();
@@ -1878,6 +1914,10 @@ export function createMeetingMinutesUI({
1878
1914
  renderCreateUnavailable();
1879
1915
  return;
1880
1916
  }
1917
+ if (Array.isArray(projectOptions) && !projectOptions.some(option => option.value === projectCode)) {
1918
+ projectError.textContent = 'プロジェクトを選択してください。'; projectError.hidden = false;
1919
+ createProjectBox?.trigger.focus({ preventScroll: true }); return;
1920
+ }
1881
1921
  save.disabled = true;
1882
1922
  try {
1883
1923
  const scheduledAt = date.input.value ? new Date(date.input.value).toISOString() : undefined;
@@ -1888,11 +1928,14 @@ export function createMeetingMinutesUI({
1888
1928
  minutes_title: minutesTitle.input.value,
1889
1929
  initial_body: body.input.value,
1890
1930
  };
1891
- const created = await mutate('', payload);
1931
+ const created = typeof createMeeting === 'function' && Array.isArray(projectOptions) ? await createMeeting(payload, projectCode) : await mutate('', payload);
1892
1932
  const id = created?.meeting?.meeting_id;
1893
1933
  setStatus('会議を保存しました。', 'success');
1894
1934
  await loadMeetings();
1895
- if (typeof id === 'string') await loadDetail(id);
1935
+ if (typeof id === 'string') {
1936
+ if (typeof shouldOpenCreatedMeeting !== 'function' || shouldOpenCreatedMeeting(created, projectCode) !== false) await loadDetail(id);
1937
+ else { detailDrawer?.close(); renderDetail(null); if (!state.listError) setStatus('会議を保存しました。', 'success'); }
1938
+ }
1896
1939
  } catch (error) {
1897
1940
  save.disabled = false;
1898
1941
  setStatus(error instanceof Error ? error.message : '会議を保存できませんでした。', 'error');
@@ -1901,11 +1944,11 @@ export function createMeetingMinutesUI({
1901
1944
  detailPane.append(form);
1902
1945
  }
1903
1946
 
1904
- async function loadMeetings({ restoreFocus = false } = {}) {
1947
+ async function loadMeetings({ restoreFocus = false, quiet = false } = {}) {
1905
1948
  const requestGeneration = ++listRequestGeneration;
1906
1949
  const isCurrentRequest = () => !disposed && requestGeneration === listRequestGeneration;
1907
1950
  state.loading = true;
1908
- setStatus('会議一覧を読み込んでいます。');
1951
+ if (!quiet) setStatus('会議一覧を読み込んでいます。');
1909
1952
  try {
1910
1953
  const payload = await call('');
1911
1954
  if (!isCurrentRequest()) return state.meetings;
@@ -1957,6 +2000,7 @@ export function createMeetingMinutesUI({
1957
2000
 
1958
2001
  async function loadDetail(meetingId) {
1959
2002
  if (disposed) return null;
2003
+ cleanupCreateProject();
1960
2004
  detailDrawer?.open();
1961
2005
  const requestGeneration = ++detailRequestGeneration;
1962
2006
  const isCurrentRequest = () => !disposed && requestGeneration === detailRequestGeneration
@@ -2003,6 +2047,7 @@ export function createMeetingMinutesUI({
2003
2047
  openMeeting: loadDetail,
2004
2048
  destroy() {
2005
2049
  disposed = true; listRequestGeneration += 1; detailRequestGeneration += 1;
2050
+ cleanupCreateProject();
2006
2051
  detailDrawer?.dispose();
2007
2052
  compactToolbar?.destroy();
2008
2053
  participantBox.destroy(); statusBox.destroy(); sortBox.destroy();
@@ -67,32 +67,6 @@
67
67
  gap: var(--bb-space-1);
68
68
  }
69
69
 
70
- .bb-pkw-tabs {
71
- display: flex;
72
- flex-wrap: wrap;
73
- gap: var(--bb-space-1);
74
- border-bottom: 1px solid var(--bb-color-border-strong);
75
- }
76
-
77
- .bb-pkw-tab {
78
- border: 0;
79
- border-bottom: 2px solid transparent;
80
- padding: 10px 14px;
81
- color: var(--bb-color-muted);
82
- background: transparent;
83
- font: inherit;
84
- font-size: 12px;
85
- font-weight: 720;
86
- cursor: pointer;
87
- }
88
-
89
- .bb-pkw-tab:hover,
90
- .bb-pkw-tab.is-active {
91
- border-bottom-color: var(--bb-color-accent);
92
- color: var(--bb-color-accent-strong);
93
- }
94
-
95
- .bb-pkw-tab:focus-visible,
96
70
  .bb-pkw-graph-item:focus-visible,
97
71
  .bb-pkw-record-link:focus-visible {
98
72
  outline: 3px solid color-mix(in srgb, var(--bb-color-focus) 45%, var(--bb-color-panel));
@@ -1,3 +1,4 @@
1
+ import { workspaceTabList } from './workspace-kit.js';
1
2
  /*
2
3
  * Shared project knowledge workspace.
3
4
  *
@@ -1253,6 +1254,7 @@ export function createProjectKnowledgeWorkspace({
1253
1254
  });
1254
1255
  const body = makeElement(doc, 'div', { className: 'bb-pkw-body' });
1255
1256
  const tabs = makeElement(doc, 'div', { className: 'bb-pkw-tabs', attrs: { role: 'tablist', 'aria-label': 'プロジェクト情報の表示' } });
1257
+ workspaceTabList(tabs);
1256
1258
  const panels = makeElement(doc, 'div', { className: 'bb-pkw-panels' });
1257
1259
  root.append(makeElement(doc, 'div', { className: 'bb-pkw-kicker', text: 'プロジェクトの記録' }));
1258
1260
  const header = makeElement(doc, 'header', { className: 'bb-pkw-header' });
@@ -544,7 +544,7 @@
544
544
  }
545
545
  .bb-ws-notification-symbol {
546
546
  display: grid; place-items: center; flex: none;
547
- width: 18px; height: 18px; border-radius: 3px;
547
+ width: var(--bb-search-band-project-icon-size); height: var(--bb-search-band-project-icon-size); border-radius: 3px;
548
548
  border: 1px solid var(--bb-notification-symbol-border);
549
549
  color: var(--bb-notification-symbol-text);
550
550
  font-size: 11px; font-weight: 700;
@@ -623,7 +623,7 @@
623
623
  .bb-ws-combobox-chevron::after { content: '⌄'; color: var(--bb-color-muted); }
624
624
  .bb-ws-combobox-popup {
625
625
  position: absolute; z-index: 45; top: calc(100% + 6px); left: 0; display: grid; gap: var(--bb-space-2);
626
- box-sizing: border-box; width: max(100%, 260px); max-width: calc(100vw - 32px); padding: 8px;
626
+ box-sizing: border-box; width: max(100%, var(--bb-search-band-scope-popup-width)); max-width: calc(100vw - 32px); padding: 8px;
627
627
  border: 1px solid var(--bb-color-border); border-radius: var(--bb-radius-md); background: var(--bb-color-panel); color: var(--bb-color-ink);
628
628
  box-shadow: var(--bb-shadow-popover); animation: bb-ws-filter-enter 140ms ease-out; transform-origin: top left;
629
629
  }
@@ -737,3 +737,142 @@
737
737
  .bb-ws-compact-toolbar .bb-ws-toolbar-filter-group.is-filtered .bb-ws-toolbar-filter, .bb-ws-compact-toolbar .bb-ws-toolbar-sort-trigger { width: calc(var(--bb-control-compact-height) + var(--bb-space-1)); padding: var(--bb-space-1); }
738
738
  .bb-ws-compact-toolbar .bb-ws-toolbar-filter-panel { position: fixed; top: calc(var(--bb-toolbar-height) * 2 + var(--bb-space-5)); right: var(--bb-space-4); width: calc(100vw - var(--bb-space-6)); max-width: none; max-height: calc(100dvh - var(--bb-toolbar-height) * 2 - var(--bb-space-6) - var(--bb-space-4)); overflow-y: auto; }
739
739
  }
740
+
741
+ /* Opt-in tab appearance. The caller owns selection, keyboard input and navigation. */
742
+ .bb-ws-tabs {
743
+ display: flex;
744
+ flex-wrap: nowrap;
745
+ align-items: stretch;
746
+ justify-content: flex-start;
747
+ gap: 0;
748
+ min-width: 0;
749
+ max-width: 100%;
750
+ min-height: var(--bb-tab-height);
751
+ padding: 0;
752
+ border: 0;
753
+ border-radius: 0;
754
+ background: transparent;
755
+ box-shadow: inset 0 -1px 0 var(--bb-color-border);
756
+ overflow-x: auto;
757
+ overflow-y: hidden;
758
+ scrollbar-width: none;
759
+ }
760
+ .bb-ws-tabs > :is([role="tab"], a, button) {
761
+ position: relative;
762
+ flex: 0 0 auto;
763
+ display: inline-flex;
764
+ align-items: center;
765
+ justify-content: center;
766
+ gap: 6px;
767
+ box-sizing: border-box;
768
+ width: auto;
769
+ height: var(--bb-tab-height);
770
+ min-height: var(--bb-tab-height);
771
+ margin: 0;
772
+ padding: 0 var(--bb-space-3);
773
+ border: 0;
774
+ border-radius: 0;
775
+ background: transparent;
776
+ box-shadow: none;
777
+ color: var(--bb-color-muted);
778
+ font-family: var(--bb-font-sans);
779
+ font-size: var(--bb-tab-font-size);
780
+ line-height: var(--bb-tab-line-height);
781
+ font-weight: var(--bb-tab-font-weight);
782
+ white-space: nowrap;
783
+ text-decoration: none;
784
+ }
785
+ .bb-ws-tabs > :is([role="tab"], a, button):hover {
786
+ color: var(--bb-color-muted);
787
+ background: transparent;
788
+ box-shadow: none;
789
+ }
790
+ .bb-ws-tabs > :is([role="tab"], a, button):is([aria-selected="true"], [aria-current="page"], [aria-pressed="true"]),
791
+ .bb-ws-tabs > :is([role="tab"], a, button):is([aria-selected="true"], [aria-current="page"], [aria-pressed="true"]):hover {
792
+ color: var(--bb-color-ink);
793
+ background: transparent;
794
+ box-shadow: inset 0 calc(-1 * var(--bb-tab-indicator-size)) 0 var(--bb-color-ink);
795
+ }
796
+ .bb-ws-tabs > :is([role="tab"], a, button):focus-visible {
797
+ outline: var(--bb-tab-indicator-size) solid var(--bb-color-ink);
798
+ outline-offset: -4px;
799
+ }
800
+ .bb-ws-tabs .bb-ws-tab-count {
801
+ display: inline-flex;
802
+ align-items: center;
803
+ justify-content: center;
804
+ box-sizing: border-box;
805
+ min-width: var(--bb-tab-count-size);
806
+ height: var(--bb-tab-count-size);
807
+ padding: 0 6px;
808
+ border-radius: var(--bb-tab-count-size);
809
+ color: var(--bb-color-ink);
810
+ background: var(--bb-color-canvas);
811
+ font-size: var(--bb-tab-count-font-size);
812
+ line-height: var(--bb-tab-count-size);
813
+ font-weight: var(--bb-tab-font-weight);
814
+ }
815
+ .bb-ws-tabs::-webkit-scrollbar { display: none; }
816
+ .bb-ws-tabs[hidden],
817
+ .bb-ws-tabs > [hidden] { display: none; }
818
+ .bb-ws-tabs--summary > [role="tab"] { flex-direction: column; align-items: flex-start; gap: 0; }
819
+ .bb-ws-tabs--summary > [role="tab"] strong { font: inherit; }
820
+ .bb-ws-tabs--summary > [role="tab"] small { margin: 0; }
821
+
822
+ /* Shared dropdown symbol; pointer/keyboard behavior remains on its trigger. */
823
+ .bb-ws-combobox-chevron { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
824
+ .bb-ws-combobox-chevron::after { content: none; }
825
+ .bb-ws-dropdown-chevron { display: block; width: var(--bb-search-band-chevron-width); height: var(--bb-search-band-chevron-height); fill: none; stroke: currentColor; stroke-width: var(--bb-search-band-chevron-stroke); stroke-linecap: round; stroke-linejoin: round; }
826
+ .bb-ws-combobox-align-end .bb-ws-combobox-popup { left: auto; right: 0; transform-origin: top right; }
827
+ .bb-ws-combobox-multiple .bb-ws-combobox-list { scrollbar-gutter: stable both-edges; }
828
+ .bb-ws-combobox-multiple .bb-ws-combobox-value,
829
+ .bb-ws-combobox-multiple .bb-ws-combobox-option-label { display: flex; align-items: center; gap: var(--bb-space-1); }
830
+ .bb-ws-combobox-multiple .bb-project-icon { flex: none; width: var(--bb-search-band-project-icon-size); height: var(--bb-search-band-project-icon-size); }
831
+ .bb-ws-combobox-multiple .bb-ws-combobox-option,
832
+ .bb-ws-combobox-multiple .bb-ws-combobox-option.is-active,
833
+ .bb-ws-combobox-multiple .bb-ws-combobox-option[aria-selected='true'] { background: transparent; box-shadow: none; }
834
+ .bb-ws-combobox-multiple .bb-ws-combobox-option:hover { background: var(--bb-color-surface); }
835
+ .bb-ws-combobox-multiple .bb-ws-combobox-list:focus-visible .bb-ws-combobox-option.is-active { outline: 1px solid var(--bb-color-muted); outline-offset: -1px; }
836
+ .bb-ws-combobox-status[hidden] { display: none; }
837
+
838
+ /* Opt-in shared one-row search band. No host-specific selectors or DOM observers. */
839
+ .bb-ws-search-band { flex-wrap: nowrap; border: 0; border-radius: 0; position: sticky; top: var(--bb-search-band-header-height); z-index: 17; display: flex; align-items: center; gap: var(--bb-space-2); box-sizing: border-box; min-height: calc(var(--bb-control-compact-height) + var(--bb-space-3) * 2); margin-bottom: var(--bb-space-3); padding-block: var(--bb-space-3); background: var(--bb-color-panel); box-shadow: inset 0 -1px var(--bb-color-border); overflow: visible; }
840
+ .bb-ws-search-band .bb-ws-toolbar-controls { margin-left: auto; gap: var(--bb-space-2); }
841
+ .bb-ws-search-band .bb-ws-toolbar-query { width: var(--bb-search-band-query-width); max-width: var(--bb-search-band-query-width); }
842
+ .bb-ws-search-band .bb-ws-toolbar-query input { width: 100%; min-width: 0; height: var(--bb-control-compact-height); min-height: var(--bb-control-compact-height); box-sizing: border-box; padding: var(--bb-space-1) var(--bb-space-2) var(--bb-space-1) calc(var(--bb-space-2) * 2 + var(--bb-toolbar-icon-size)); font-size: var(--bb-toolbar-font-size); border: 0; border-radius: var(--bb-radius-pill); background: var(--bb-color-canvas); box-shadow: none; }
843
+ .bb-ws-search-band .bb-ws-toolbar-query input::placeholder { color: var(--bb-search-band-placeholder); opacity: 1; }
844
+ .bb-ws-search-band .bb-ws-toolbar-query input:not(:placeholder-shown) { background: var(--bb-search-band-selected); }
845
+ .bb-ws-search-band .bb-ws-toolbar-scope { display: inline-flex; flex: none; min-width: 0; max-width: min(var(--bb-toolbar-popover-width), calc(100vw - var(--bb-search-band-scope-viewport-reserve))); }
846
+ .bb-ws-search-band .bb-ws-toolbar-scope > .bb-ws-combobox { width: max-content; min-width: 0; max-width: 100%; }
847
+ .bb-ws-search-band .bb-ws-toolbar-scope .bb-ws-combobox-trigger { width: auto; max-width: 100%; min-height: var(--bb-control-compact-height); height: var(--bb-control-compact-height); padding-inline: var(--bb-search-band-scope-padding); border: 0; border-radius: var(--bb-radius-pill); background: var(--bb-color-canvas); }
848
+ .bb-ws-search-band .bb-ws-toolbar-scope .is-multi-selected .bb-ws-combobox-trigger { background: var(--bb-search-band-selected); color: var(--bb-color-brand-indigo); }
849
+ .bb-ws-search-band .bb-ws-toolbar-scope .bb-ws-combobox-popup { width: max(100%, var(--bb-search-band-scope-popup-width)); }
850
+ .bb-ws-search-band .bb-ws-toolbar-filter-group,
851
+ .bb-ws-search-band .bb-ws-toolbar-sort { display: inline-flex; flex: none; border-radius: var(--bb-radius-sm); }
852
+ .bb-ws-search-band .bb-ws-toolbar-sort { margin-left: calc(var(--bb-space-1) * -1); }
853
+ .bb-ws-search-band .bb-ws-toolbar-filter,
854
+ .bb-ws-search-band .bb-ws-toolbar-sort-trigger { display: inline-flex; align-items: center; justify-content: center; width: var(--bb-search-band-icon-width); min-width: var(--bb-search-band-icon-width); height: var(--bb-control-compact-height); min-height: var(--bb-control-compact-height); box-sizing: border-box; padding: var(--bb-space-1); border: 0; border-radius: var(--bb-radius-sm); background: transparent; color: var(--bb-color-muted); box-shadow: none; }
855
+ .bb-ws-search-band .bb-ws-toolbar-filter:hover,
856
+ .bb-ws-search-band .bb-ws-toolbar-sort-trigger:hover { background: transparent; color: var(--bb-color-brand-indigo); }
857
+ .bb-ws-search-band .is-filtered .bb-ws-toolbar-filter,
858
+ .bb-ws-search-band .is-sorted .bb-ws-toolbar-sort-trigger { background: var(--bb-search-band-selected); color: var(--bb-color-brand-indigo); }
859
+ .bb-ws-search-band .bb-ws-action-icon { stroke-width: var(--bb-search-band-icon-stroke); }
860
+ .bb-ws-search-band :is(.is-filtered, .is-sorted) .bb-ws-action-icon { stroke-width: var(--bb-search-band-icon-selected-stroke); }
861
+ .bb-ws-search-band .bb-ws-toolbar-filter-panel { width: var(--bb-toolbar-popover-width); }
862
+ .bb-ws-search-band .bb-ws-menu-reset { display: flex; justify-content: center; }
863
+ .bb-ws-search-band .bb-ws-toolbar-sort .bb-ws-button { margin-inline: auto; border: 0; background: transparent; }
864
+ .bb-ws-search-band :is(.bb-ws-toolbar-filter, .bb-ws-toolbar-sort-trigger, .bb-ws-toolbar-scope .bb-ws-combobox-trigger):focus-visible { outline: 2px solid var(--bb-control-edge, var(--bb-color-muted)); outline-offset: 2px; }
865
+ @media (max-width: 760px) {
866
+ .bb-ws-search-band .bb-ws-toolbar-controls { flex: 1; min-width: 0; gap: var(--bb-space-1); }
867
+ .bb-ws-search-band .bb-ws-toolbar-query { flex: 1; width: auto; min-width: var(--bb-toolbar-height); }
868
+ .bb-ws-search-band .bb-ws-toolbar-sort { margin-left: 0; }
869
+ .bb-ws-search-band .bb-ws-toolbar-filter-panel { position: fixed; top: calc(var(--bb-search-band-header-height) + var(--bb-control-compact-height) + var(--bb-space-3) * 2); right: var(--bb-space-4); width: calc(100vw - var(--bb-space-6)); max-height: calc(100dvh - 140px); overflow-y: auto; }
870
+ .bb-ws-search-band .bb-ws-toolbar-sort .bb-ws-combobox-popup { left: auto; right: 0; width: min(var(--bb-search-band-scope-popup-width), calc(100vw - var(--bb-space-6))); }
871
+ }
872
+
873
+ /* Opaque entry prevents fixed chrome rules from shining through an inspector. */
874
+ @keyframes bb-ws-drawer-opaque-in { from { transform: translateX(24px); } to { transform: none; } }
875
+ .bb-ws-search-band-drawer[open]:not(.is-closing) { animation-name: bb-ws-drawer-opaque-in; }
876
+ .bb-ws-search-band-drawer .bb-ws-detail-closebar { border-bottom: 0; box-shadow: none; }
877
+
878
+ .bb-ws-search-band .bb-ws-toolbar-filter::after { content: none; margin: 0; }
@@ -25,6 +25,13 @@ export function makeWorkspaceElement(doc, tag, { className, text, attrs = {} } =
25
25
 
26
26
  const el = makeWorkspaceElement;
27
27
 
28
+ function toggleWorkspaceClass(node, name, active) {
29
+ if (!node) return;
30
+ const names = new Set(String(node.className || '').split(/\s+/u).filter(Boolean));
31
+ if (active) names.add(name); else names.delete(name);
32
+ node.className = [...names].join(' ');
33
+ }
34
+
28
35
  function appendContent(parent, doc, content) {
29
36
  if (content === undefined || content === null || content === false) return;
30
37
  if (Array.isArray(content)) {
@@ -109,6 +116,7 @@ export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose }
109
116
  return {
110
117
  dialog,
111
118
  setContent(...content) { if (!disposed) body.replaceChildren(...content); },
119
+ setTitle(title) { if (!disposed) label.textContent = String(title); },
112
120
  open(target) {
113
121
  if (disposed) return;
114
122
  cancelClosing?.(); cancelClosing = null;
@@ -505,13 +513,16 @@ function comboboxText(value) {
505
513
  export function workspaceCombobox(doc, {
506
514
  label, options = [], value = '', placeholder = '選択してください', searchLabel, searchPlaceholder = '絞り込む',
507
515
  emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange,
516
+ multiple = false, values = [], renderIcon, showCount = true, showHints = true, align = 'start',
508
517
  } = {}) {
509
518
  const sequence = ++workspaceSequence;
510
519
  const listId = `bb-ws-combobox-${sequence}-list`;
511
520
  const root = el(doc, 'span', { className: ['bb-ws-combobox', className].filter(Boolean).join(' ') });
521
+ if (multiple) root.classList?.add('bb-ws-combobox-multiple');
522
+ if (align === 'end') root.classList?.add('bb-ws-combobox-align-end');
512
523
  const trigger = el(doc, 'button', { className: 'bb-ws-combobox-trigger', attrs: { type: 'button', 'aria-haspopup': 'listbox', 'aria-expanded': 'false', 'aria-controls': listId } });
513
524
  const triggerText = el(doc, 'span', { className: 'bb-ws-combobox-value' });
514
- trigger.append(triggerText, el(doc, 'span', { className: 'bb-ws-combobox-chevron', attrs: { 'aria-hidden': 'true' } }));
525
+ trigger.append(triggerText, workspaceDropdownChevron(doc));
515
526
  const popup = el(doc, 'div', { className: 'bb-ws-combobox-popup' });
516
527
  popup.hidden = true;
517
528
  const search = el(doc, 'input', { className: 'bb-ws-combobox-search', attrs: {
@@ -519,29 +530,35 @@ export function workspaceCombobox(doc, {
519
530
  'aria-label': searchLabel || `${label || '候補'}を絞り込む`, placeholder: searchPlaceholder, autocomplete: 'off', spellcheck: 'false',
520
531
  } });
521
532
  const list = el(doc, 'ul', { className: 'bb-ws-combobox-list', attrs: { id: listId, role: 'listbox', 'aria-label': label || '候補', tabindex: '-1' } });
533
+ if (multiple) list.setAttribute('aria-multiselectable', 'true');
522
534
  const status = el(doc, 'p', { className: 'bb-ws-combobox-status', attrs: { role: 'status', 'aria-live': 'polite' } });
523
535
  popup.append(search, list, status);
524
536
  root.append(trigger, popup);
525
537
 
526
- const state = { options: [], value: String(value ?? ''), query: '', active: -1, shown: [], open: false, disabled: false };
538
+ const state = { options: [], values: [...new Set((Array.isArray(values) ? values : []).map(String))].filter(Boolean), value: String(value ?? ''), query: '', active: -1, shown: [], open: false, disabled: false };
527
539
  const usesSearch = () => searchable === true || (searchable === 'auto' && state.options.length > 8);
528
540
  const focusTarget = () => (usesSearch() ? search : list);
529
541
  const chosen = () => state.options.find(option => option.value === state.value);
530
542
 
531
543
  function setOptions(next) {
532
544
  state.options = (Array.isArray(next) ? next : []).map(option => ({
533
- value: String(option?.value ?? ''), label: String(option?.label ?? option?.value ?? ''),
545
+ ...option, value: String(option?.value ?? ''), label: String(option?.label ?? option?.value ?? ''),
534
546
  hint: option?.hint ? String(option.hint) : '', keywords: option?.keywords ? String(option.keywords) : '',
535
547
  }));
536
548
  }
537
549
 
538
550
  function renderTrigger() {
539
- const option = chosen();
540
- // A value the list does not offer stays visible instead of looking unset.
541
- const text = option ? option.label : state.value || placeholder;
551
+ const option = multiple ? (state.values.length === 1 ? state.options.find(option => option.value === state.values[0]) : state.options.find(option => !option.value)) : chosen();
552
+ const summary = multiple && state.values.length > 1 ? `${state.values.length}件選択中` : null;
553
+ const text = summary || (option ? option.label : multiple ? state.values.join('、') || placeholder : state.value || placeholder);
542
554
  triggerText.textContent = text;
555
+ if (!summary && option && typeof renderIcon === 'function') {
556
+ const icon = renderIcon(option);
557
+ if (icon) { triggerText.textContent = ''; triggerText.append(icon, el(doc, 'span', { className: 'bb-ws-combobox-text', text })); }
558
+ }
559
+ toggleWorkspaceClass(root, 'is-multi-selected', Boolean(summary));
543
560
  trigger.setAttribute('aria-label', `${label ? `${label}: ` : ''}${text}`);
544
- trigger.setAttribute('data-empty', String(!option && !state.value));
561
+ trigger.setAttribute('data-empty', String(multiple ? !state.values.length : !option && !state.value));
545
562
  if (state.disabled) trigger.setAttribute('disabled', ''); else trigger.removeAttribute('disabled');
546
563
  }
547
564
 
@@ -552,7 +569,8 @@ export function workspaceCombobox(doc, {
552
569
  }
553
570
  }
554
571
 
555
- function renderList() {
572
+ function renderList({ reveal = false } = {}) {
573
+ const scrollTop = list.scrollTop;
556
574
  const terms = comboboxText(state.query).split(/\s+/u).filter(Boolean);
557
575
  const matches = terms.length
558
576
  ? state.options.filter(option => { const text = comboboxText(`${option.label}\n${option.hint}\n${option.keywords}`); return terms.every(term => text.includes(term)); })
@@ -562,25 +580,37 @@ export function workspaceCombobox(doc, {
562
580
  if (state.active >= state.shown.length) state.active = state.shown.length - 1;
563
581
  list.replaceChildren();
564
582
  state.shown.forEach((option, index) => {
565
- const selected = option.value === state.value;
583
+ const selected = multiple ? option.value ? state.values.includes(option.value) : state.values.length === 0 : option.value === state.value;
566
584
  const item = el(doc, 'li', { className: `bb-ws-combobox-option${index === state.active ? ' is-active' : ''}`, attrs: { id: `bb-ws-combobox-${sequence}-option-${index}`, role: 'option', 'aria-selected': String(selected), 'data-value': option.value } });
567
- item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-label', text: option.label }));
568
- if (option.hint) item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-hint', text: option.hint }));
585
+ const optionLabel = el(doc, 'span', { className: 'bb-ws-combobox-option-label', text: option.label });
586
+ if (typeof renderIcon === 'function') { const icon = renderIcon(option); if (icon) { optionLabel.textContent = ''; optionLabel.append(icon, el(doc, 'span', { className: 'bb-ws-combobox-text', text: option.label })); } }
587
+ item.append(optionLabel);
588
+ if (showHints && option.hint) item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-hint', text: option.hint }));
569
589
  item.addEventListener('pointerdown', event => event.preventDefault?.());
570
590
  item.addEventListener('click', () => choose(option));
571
591
  list.append(item);
572
592
  });
573
593
  const active = list.children?.[state.active];
574
594
  activeDescendant(active);
575
- active?.scrollIntoView?.({ block: 'nearest' });
595
+ if (scrollTop !== undefined) list.scrollTop = scrollTop;
596
+ if (reveal) {
597
+ const activeRect = active?.getBoundingClientRect?.(), listRect = list.getBoundingClientRect?.();
598
+ const top = activeRect && listRect ? activeRect.top - listRect.top + list.scrollTop : active?.offsetTop;
599
+ const height = activeRect?.height ?? active?.offsetHeight;
600
+ if (Number.isFinite(top) && Number.isFinite(height)) {
601
+ if (top < list.scrollTop) list.scrollTop = top;
602
+ else if (top + height > list.scrollTop + list.clientHeight) list.scrollTop = top + height - list.clientHeight;
603
+ }
604
+ }
576
605
  const rest = matches.length - state.shown.length;
606
+ status.hidden = !showCount && matches.length > 0 && rest === 0;
577
607
  status.textContent = !matches.length ? emptyText : rest > 0 ? `${matches.length}件中${state.shown.length}件を表示。ほか${rest}件は絞り込むと出ます` : `${matches.length}件`;
578
608
  }
579
609
 
580
610
  function move(index) {
581
611
  if (!state.shown.length) return;
582
612
  state.active = Math.min(state.shown.length - 1, Math.max(0, index));
583
- renderList();
613
+ renderList({ reveal: true });
584
614
  }
585
615
 
586
616
  function removeListeners() { doc.removeEventListener?.('pointerdown', outside); }
@@ -590,11 +620,11 @@ export function workspaceCombobox(doc, {
590
620
  if (state.disabled) return;
591
621
  if (!state.open) { state.open = true; doc.addEventListener?.('pointerdown', outside); }
592
622
  state.query = query; search.value = query; search.hidden = !usesSearch();
593
- const selectedIndex = state.options.findIndex(option => option.value === state.value);
623
+ const selectedIndex = state.options.findIndex(option => multiple ? state.values.includes(option.value) : option.value === state.value);
594
624
  state.active = query ? 0 : Math.max(0, selectedIndex);
595
625
  popup.hidden = false; trigger.setAttribute('aria-expanded', 'true');
596
- renderList();
597
- focusTarget().focus?.();
626
+ renderList({ reveal: true });
627
+ focusTarget().focus?.({ preventScroll: true });
598
628
  }
599
629
 
600
630
  function close(returnFocus = true) {
@@ -605,6 +635,11 @@ export function workspaceCombobox(doc, {
605
635
  }
606
636
 
607
637
  function choose(option) {
638
+ if (multiple) {
639
+ state.active = state.shown.findIndex(candidate => candidate.value === option.value);
640
+ state.values = !option.value ? [] : state.values.includes(option.value) ? state.values.filter(value => value !== option.value) : [...state.values, option.value];
641
+ renderTrigger(); renderList(); onChange?.([...state.values], option); return;
642
+ }
608
643
  const changed = option.value !== state.value;
609
644
  state.value = option.value; renderTrigger(); close(true);
610
645
  if (changed) onChange?.(option.value, option);
@@ -621,6 +656,7 @@ export function workspaceCombobox(doc, {
621
656
  // Home and End move the caret while a search box is shown.
622
657
  if (!usesSearch()) Object.assign(keys, { Home: () => move(0), End: () => move(state.shown.length - 1) });
623
658
  if (event.key === 'Tab') { close(false); return; }
659
+ if (multiple && event.key === ' ' && !usesSearch()) keys[' '] = keys.Enter;
624
660
  const action = keys[event.key];
625
661
  if (!action) return;
626
662
  event.preventDefault?.(); event.stopPropagation?.();
@@ -641,12 +677,16 @@ export function workspaceCombobox(doc, {
641
677
  return {
642
678
  root, trigger, popup, search, list,
643
679
  get value() { return state.value; },
680
+ get values() { return [...state.values]; },
644
681
  get isOpen() { return state.open; },
645
682
  open, close,
646
- update({ options: nextOptions, value: nextValue, disabled } = {}) {
683
+ update({ options: nextOptions, value: nextValue, values: nextValues, disabled } = {}) {
684
+ const previous = JSON.stringify([state.options, state.value, state.values, state.disabled]);
647
685
  if (nextOptions !== undefined) setOptions(nextOptions);
648
686
  if (nextValue !== undefined) state.value = String(nextValue ?? '');
687
+ if (nextValues !== undefined) state.values = [...new Set((Array.isArray(nextValues) ? nextValues : []).map(String))].filter(Boolean);
649
688
  if (disabled !== undefined) { state.disabled = Boolean(disabled); if (state.disabled) close(false); }
689
+ if (previous === JSON.stringify([state.options, state.value, state.values, state.disabled])) return;
650
690
  renderTrigger();
651
691
  if (state.open) { search.hidden = !usesSearch(); renderList(); }
652
692
  },
@@ -707,3 +747,59 @@ export function workspaceCompactToolbar(doc, { root, query, filters, sort, reset
707
747
  filter.destroy(); reset?.removeEventListener('click', clear); sort?.trigger.removeEventListener('click', sortClick); sort?.trigger.removeEventListener('keydown', sortClick);
708
748
  } };
709
749
  }
750
+
751
+ /** Apply the common tab appearance without changing semantics, state or handlers.
752
+ * Hosts may also use the documented bb-ws-tabs CSS class directly.
753
+ */
754
+ export function workspaceTabList(root) {
755
+ if (!root || typeof root.className !== 'string') throw new TypeError('tab_root_required');
756
+ const classes = root.className.split(/\s+/u).filter(Boolean);
757
+ if (!classes.includes('bb-ws-tabs')) classes.push('bb-ws-tabs');
758
+ root.className = classes.join(' ');
759
+ return root;
760
+ }
761
+
762
+ /** The shared shallow dropdown chevron, sized and colored through shared CSS. */
763
+ export function workspaceDropdownChevron(doc) {
764
+ const wrap = el(doc, 'span', { className: 'bb-ws-combobox-chevron', attrs: { 'aria-hidden': 'true' } });
765
+ const create = tag => typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', tag) : doc.createElement(tag);
766
+ const svg = create('svg'); svg.setAttribute('viewBox', '0 0 12 8'); svg.setAttribute('class', 'bb-ws-dropdown-chevron');
767
+ const path = create('path'); path.setAttribute('d', 'M1 2.5l5 3 5-3'); svg.append(path); wrap.append(svg); return wrap;
768
+ }
769
+
770
+ /** Opt-in shared search band. The host retains scope options and query handlers. */
771
+ export function workspaceSearchBand(doc, { root, query, filters, sort, reset, onResetSort } = {}) {
772
+ root ||= el(doc, 'div'); root.classList.add('bb-ws-search-band');
773
+ const primary = el(doc, 'div', { className: 'bb-ws-toolbar-primary' });
774
+ const controls = el(doc, 'div', { className: 'bb-ws-toolbar-controls' });
775
+ const search = el(doc, 'span', { className: 'bb-ws-toolbar-query' }); search.append(workspaceActionIcon(doc, 'search'), query);
776
+ const scopeSlot = el(doc, 'span', { className: 'bb-ws-toolbar-scope' });
777
+ const trigger = workspaceButton(doc, { variant: 'quiet', attrs: { 'aria-label': 'フィルター', title: 'フィルター' } });
778
+ trigger.classList.add('bb-ws-toolbar-filter'); trigger.append(workspaceActionIcon(doc, 'filter'));
779
+ const filter = workspaceFilterPopover(doc, { content: filters, trigger,
780
+ onToggle: open => { if (open) sort?.close(false); },
781
+ });
782
+ filter.root.classList.add('bb-ws-toolbar-filter-group'); filter.panel.classList.add('bb-ws-toolbar-filter-panel');
783
+ if (reset) {
784
+ reset.textContent = 'フィルターを解除'; reset.setAttribute('aria-label', 'フィルターを解除');
785
+ const footer = el(doc, 'div', { className: 'bb-ws-menu-reset' }); footer.append(reset); filters.append(footer);
786
+ }
787
+ const closeFilter = () => { if (!filter.panel.hidden) trigger.click(); };
788
+ const clear = () => { closeFilter(); trigger.focus({ preventScroll: true }); };
789
+ const sortClick = () => closeFilter();
790
+ const sortReset = workspaceButton(doc, { text: '初期順に戻す', attrs: { 'aria-label': '並べ替えを初期順に戻す' } });
791
+ const resetSort = () => { sort?.close(false); onResetSort?.(); sort?.trigger.focus({ preventScroll: true }); };
792
+ if (sort) {
793
+ sort.root.classList.add('bb-ws-toolbar-sort'); sort.trigger.classList.add('bb-ws-toolbar-sort-trigger');
794
+ sort.trigger.replaceChildren(workspaceActionIcon(doc, 'sort')); sort.trigger.setAttribute('title', '並べ替え');
795
+ sort.popup.append(sortReset); sortReset.addEventListener('click', resetSort);
796
+ sort.trigger.addEventListener('click', sortClick); sort.trigger.addEventListener('keydown', sortClick);
797
+ }
798
+ controls.append(search, scopeSlot, filter.root); if (sort) controls.append(sort.root); root.replaceChildren(primary, controls);
799
+ reset?.addEventListener('click', clear);
800
+ return { root, primary, scopeSlot, filter,
801
+ setFiltered(active) { toggleWorkspaceClass(filter.root, 'is-filtered', Boolean(active)); trigger.setAttribute('aria-label', active ? 'フィルター(適用中)' : 'フィルター'); },
802
+ setSorted(active) { toggleWorkspaceClass(sort?.root, 'is-sorted', Boolean(active)); sortReset.hidden = !active; },
803
+ destroy() { filter.destroy(); reset?.removeEventListener('click', clear); sortReset.removeEventListener('click', resetSort); sort?.trigger.removeEventListener('click', sortClick); sort?.trigger.removeEventListener('keydown', sortClick); },
804
+ };
805
+ }