@unson/brainbase-mcp 0.50.11 → 0.50.13
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/dist/judgment-frame-evidence.d.ts +63 -0
- package/dist/judgment-frame-evidence.js +161 -0
- package/package.json +6 -2
- package/ui/brainbase-tokens.css +27 -3
- package/ui/workspace-kit.css +164 -0
- package/ui/workspace-kit.js +164 -10
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type JudgmentFrameEvidenceKind = 'philosophy' | 'objective' | 'model';
|
|
2
|
+
export type JudgmentFrameEvidenceRole = 'constraint' | 'criterion' | 'prediction';
|
|
3
|
+
export interface JudgmentFrameReadEvidence {
|
|
4
|
+
catalog_digest: string;
|
|
5
|
+
records: Array<{
|
|
6
|
+
kind: JudgmentFrameEvidenceKind;
|
|
7
|
+
ref: string;
|
|
8
|
+
body_digest: string;
|
|
9
|
+
version: string;
|
|
10
|
+
version_source: string;
|
|
11
|
+
applicability_scope_source: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export interface JudgmentFrameApplicationEvidence {
|
|
15
|
+
selections: Array<{
|
|
16
|
+
kind: unknown;
|
|
17
|
+
ref: unknown;
|
|
18
|
+
}>;
|
|
19
|
+
chosen_option_digest: string | null;
|
|
20
|
+
applications: Array<{
|
|
21
|
+
kind: JudgmentFrameEvidenceKind;
|
|
22
|
+
ref: string;
|
|
23
|
+
role: JudgmentFrameEvidenceRole;
|
|
24
|
+
note_digest: string;
|
|
25
|
+
verdict?: string;
|
|
26
|
+
}>;
|
|
27
|
+
non_applicability: Array<{
|
|
28
|
+
kind: JudgmentFrameEvidenceKind;
|
|
29
|
+
reason_digest: string;
|
|
30
|
+
}>;
|
|
31
|
+
application_complete: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** The fields of a Host event this module reads. Other fields are ignored. */
|
|
34
|
+
export interface JudgmentFrameEvidenceEvent {
|
|
35
|
+
event_kind?: unknown;
|
|
36
|
+
success?: unknown;
|
|
37
|
+
safe_metadata?: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** Digest-only evidence of a frame_read result, or null when the result does not answer the request. */
|
|
40
|
+
export declare function frameReadMetadata(value: unknown, input: unknown): JudgmentFrameReadEvidence | null;
|
|
41
|
+
/** Digest-only evidence of a frame_record call: which references the adopted option used, and how. */
|
|
42
|
+
export declare function frameApplicationMetadata(frame: unknown, input: unknown): JudgmentFrameApplicationEvidence;
|
|
43
|
+
/**
|
|
44
|
+
* Whether this turn's events hold a complete frame: a catalog, a body read of
|
|
45
|
+
* every selected reference, then a record that applies them, in that order.
|
|
46
|
+
*
|
|
47
|
+
* The catalog is tens of thousands of characters and rarely changes inside one
|
|
48
|
+
* conversation. frame_read and frame_record rebuild the current catalog on the
|
|
49
|
+
* server and reject a stale digest, so a successful read and record with a
|
|
50
|
+
* digest this conversation has already been shown prove the same list is still
|
|
51
|
+
* current. `sessionCatalogDigests` names those digests; with them, a turn that
|
|
52
|
+
* did not read the catalog again is still complete.
|
|
53
|
+
*/
|
|
54
|
+
export declare function hasCompleteJudgmentFrame(events: readonly JudgmentFrameEvidenceEvent[], { sessionCatalogDigests }?: {
|
|
55
|
+
sessionCatalogDigests?: readonly string[];
|
|
56
|
+
}): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Digests of the catalogs the other turns of one conversation read
|
|
59
|
+
* successfully. The Host passes the directory that holds one `<turn>.events`
|
|
60
|
+
* directory per turn and the current turn's own events directory, which is
|
|
61
|
+
* skipped. An unreadable file or directory contributes nothing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function sessionFrameCatalogDigests(sessionDirectory: string, currentEventsDirectory: string): string[];
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Frame evidence a Host keeps for one turn. It persists references and
|
|
2
|
+
// digests, never Graph bodies, option labels, or the reasons the model wrote.
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
const roles = {
|
|
7
|
+
philosophy: 'constraint', objective: 'criterion', model: 'prediction',
|
|
8
|
+
};
|
|
9
|
+
const kinds = Object.keys(roles);
|
|
10
|
+
const verdicts = ['satisfied', 'violated', 'tension'];
|
|
11
|
+
const text = (value) => typeof value === 'string' && value.trim().length > 0;
|
|
12
|
+
const digest = (value) => `sha256:${createHash('sha256').update(value).digest('hex')}`;
|
|
13
|
+
const validDigest = (value) => /^sha256:[a-f0-9]{64}$/u.test(String(value));
|
|
14
|
+
const key = (item) => `${item?.kind}:${item?.ref}`;
|
|
15
|
+
const lastIndexOf = (events, kind) => {
|
|
16
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
17
|
+
if (events[index]?.success && events[index].event_kind === kind)
|
|
18
|
+
return index;
|
|
19
|
+
}
|
|
20
|
+
return -1;
|
|
21
|
+
};
|
|
22
|
+
/** Digest-only evidence of a frame_read result, or null when the result does not answer the request. */
|
|
23
|
+
export function frameReadMetadata(value, input) {
|
|
24
|
+
const result = value;
|
|
25
|
+
const request = input;
|
|
26
|
+
if (result?.schema_version !== 'brainbase-judgment-frame-read-v1'
|
|
27
|
+
|| !validDigest(result.catalog_digest) || result.catalog_digest !== request?.catalog_digest
|
|
28
|
+
|| !Array.isArray(result.records) || !Array.isArray(request?.selections)
|
|
29
|
+
|| result.records.length === 0 || result.records.length !== request.selections.length
|
|
30
|
+
|| result.records.length > 24)
|
|
31
|
+
return null;
|
|
32
|
+
const requested = new Set(request.selections.map(key));
|
|
33
|
+
if (requested.size !== request.selections.length)
|
|
34
|
+
return null;
|
|
35
|
+
const records = [];
|
|
36
|
+
for (const item of result.records) {
|
|
37
|
+
if (!Object.hasOwn(roles, item?.kind) || !text(item.ref) || !requested.delete(key(item))
|
|
38
|
+
|| !text(item.body) || item.body_digest !== digest(item.body)
|
|
39
|
+
|| !text(item.version) || !text(item.applicability_scope)
|
|
40
|
+
|| !['graph', 'body_digest'].includes(item.version_source)
|
|
41
|
+
|| !['graph', 'unspecified'].includes(item.applicability_scope_source)
|
|
42
|
+
|| (item.version_source === 'body_digest' && item.version !== item.body_digest))
|
|
43
|
+
return null;
|
|
44
|
+
records.push({
|
|
45
|
+
kind: item.kind, ref: item.ref, body_digest: item.body_digest,
|
|
46
|
+
version: item.version, version_source: item.version_source,
|
|
47
|
+
applicability_scope_source: item.applicability_scope_source,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return { catalog_digest: result.catalog_digest, records };
|
|
51
|
+
}
|
|
52
|
+
/** Digest-only evidence of a frame_record call: which references the adopted option used, and how. */
|
|
53
|
+
export function frameApplicationMetadata(frame, input) {
|
|
54
|
+
const recorded = frame;
|
|
55
|
+
const request = input;
|
|
56
|
+
const selections = Array.isArray(request?.selections) ? request.selections : [];
|
|
57
|
+
const chosen = Array.isArray(request?.options)
|
|
58
|
+
? request.options.find((option) => option?.label === request.chosen_option) : null;
|
|
59
|
+
const returned = new Set((Array.isArray(recorded?.selections) ? recorded.selections : []).map(key));
|
|
60
|
+
const selected = new Set(selections.map(key));
|
|
61
|
+
const validSelections = Array.isArray(request?.selections) && selections.length <= 24
|
|
62
|
+
&& selected.size === selections.length && returned.size === selections.length
|
|
63
|
+
&& selections.every((item) => Object.hasOwn(roles, item?.kind) && text(item.ref)
|
|
64
|
+
&& text(item.why) && returned.has(key(item)));
|
|
65
|
+
const kindsAddressed = kinds.every((kind) => selections.some((item) => item?.kind === kind)
|
|
66
|
+
? !text(request?.none?.[kind]) : text(request?.none?.[kind]));
|
|
67
|
+
const usedBy = (item) => (use) => use?.ref === item?.ref
|
|
68
|
+
&& use?.role === roles[item?.kind] && text(use?.note)
|
|
69
|
+
&& (item.kind !== 'philosophy' || verdicts.includes(use.verdict));
|
|
70
|
+
const applied = validSelections && Array.isArray(chosen?.uses)
|
|
71
|
+
&& selections.every((item) => chosen.uses.some(usedBy(item)));
|
|
72
|
+
return {
|
|
73
|
+
selections: selections.map((item) => ({ kind: item?.kind, ref: item?.ref })),
|
|
74
|
+
chosen_option_digest: text(request?.chosen_option) ? digest(request.chosen_option) : null,
|
|
75
|
+
applications: validSelections && applied ? selections.map((item) => {
|
|
76
|
+
const use = chosen.uses.find(usedBy(item));
|
|
77
|
+
return {
|
|
78
|
+
kind: item.kind, ref: item.ref, role: use.role, note_digest: digest(use.note),
|
|
79
|
+
...(item.kind === 'philosophy' ? { verdict: use.verdict } : {}),
|
|
80
|
+
};
|
|
81
|
+
}) : [],
|
|
82
|
+
non_applicability: kinds.filter((kind) => !selections.some((item) => item?.kind === kind)
|
|
83
|
+
&& text(request?.none?.[kind])).map((kind) => ({ kind, reason_digest: digest(request.none[kind]) })),
|
|
84
|
+
application_complete: Boolean(validSelections && kindsAddressed && applied
|
|
85
|
+
&& text(request?.chosen_option) && recorded?.chosen_option === request.chosen_option),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Whether this turn's events hold a complete frame: a catalog, a body read of
|
|
90
|
+
* every selected reference, then a record that applies them, in that order.
|
|
91
|
+
*
|
|
92
|
+
* The catalog is tens of thousands of characters and rarely changes inside one
|
|
93
|
+
* conversation. frame_read and frame_record rebuild the current catalog on the
|
|
94
|
+
* server and reject a stale digest, so a successful read and record with a
|
|
95
|
+
* digest this conversation has already been shown prove the same list is still
|
|
96
|
+
* current. `sessionCatalogDigests` names those digests; with them, a turn that
|
|
97
|
+
* did not read the catalog again is still complete.
|
|
98
|
+
*/
|
|
99
|
+
export function hasCompleteJudgmentFrame(events, { sessionCatalogDigests = [] } = {}) {
|
|
100
|
+
const list = events;
|
|
101
|
+
const catalogIndex = lastIndexOf(list, 'frame_catalog');
|
|
102
|
+
const frameIndex = lastIndexOf(list, 'frame');
|
|
103
|
+
if (frameIndex < 0 || frameIndex <= catalogIndex)
|
|
104
|
+
return false;
|
|
105
|
+
const frame = list[frameIndex].safe_metadata?.judgment_frame;
|
|
106
|
+
if (!validDigest(frame?.catalog_digest) || frame.application_complete !== true)
|
|
107
|
+
return false;
|
|
108
|
+
// A catalog read on this turn is the one the record must match. Without
|
|
109
|
+
// one, only a digest read earlier in the same conversation is accepted.
|
|
110
|
+
const catalogDigest = catalogIndex >= 0
|
|
111
|
+
? list[catalogIndex].safe_metadata?.judgment_frame_catalog?.catalog_digest
|
|
112
|
+
: sessionCatalogDigests.includes(frame.catalog_digest) ? frame.catalog_digest : null;
|
|
113
|
+
if (!validDigest(catalogDigest) || frame.catalog_digest !== catalogDigest)
|
|
114
|
+
return false;
|
|
115
|
+
const reads = new Set(list.slice(catalogIndex + 1, frameIndex)
|
|
116
|
+
.filter((event) => event.success && event.event_kind === 'frame_read'
|
|
117
|
+
&& event.safe_metadata?.judgment_frame_read?.catalog_digest === catalogDigest)
|
|
118
|
+
.flatMap((event) => Array.isArray(event.safe_metadata.judgment_frame_read?.records)
|
|
119
|
+
? event.safe_metadata.judgment_frame_read.records.map(key) : []));
|
|
120
|
+
return Array.isArray(frame.selections) && frame.selections.every((item) => reads.has(key(item)));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Digests of the catalogs the other turns of one conversation read
|
|
124
|
+
* successfully. The Host passes the directory that holds one `<turn>.events`
|
|
125
|
+
* directory per turn and the current turn's own events directory, which is
|
|
126
|
+
* skipped. An unreadable file or directory contributes nothing.
|
|
127
|
+
*/
|
|
128
|
+
export function sessionFrameCatalogDigests(sessionDirectory, currentEventsDirectory) {
|
|
129
|
+
const digests = new Set();
|
|
130
|
+
let turns;
|
|
131
|
+
try {
|
|
132
|
+
turns = readdirSync(sessionDirectory).filter((name) => name.endsWith('.events')).sort();
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
for (const turn of turns) {
|
|
138
|
+
const directory = join(sessionDirectory, turn);
|
|
139
|
+
if (resolve(directory) === resolve(currentEventsDirectory))
|
|
140
|
+
continue;
|
|
141
|
+
let names;
|
|
142
|
+
try {
|
|
143
|
+
names = readdirSync(directory).filter((name) => name.endsWith('.json'));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
for (const name of names) {
|
|
149
|
+
try {
|
|
150
|
+
const event = JSON.parse(readFileSync(join(directory, name), 'utf8'));
|
|
151
|
+
const value = event?.safe_metadata?.judgment_frame_catalog?.catalog_digest;
|
|
152
|
+
if (event?.success === true && event.event_kind === 'frame_catalog' && validDigest(value))
|
|
153
|
+
digests.add(value);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Not a readable event.
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return [...digests].sort();
|
|
161
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.13",
|
|
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",
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"types": "./dist/judgment-node-evidence.d.ts",
|
|
68
68
|
"import": "./dist/judgment-node-evidence.js"
|
|
69
69
|
},
|
|
70
|
+
"./judgment-frame-evidence": {
|
|
71
|
+
"types": "./dist/judgment-frame-evidence.d.ts",
|
|
72
|
+
"import": "./dist/judgment-frame-evidence.js"
|
|
73
|
+
},
|
|
70
74
|
"./judgment-event-adapter": {
|
|
71
75
|
"types": "./dist/judgment-event-adapter.d.ts",
|
|
72
76
|
"import": "./dist/judgment-event-adapter.js"
|
|
@@ -645,5 +649,5 @@
|
|
|
645
649
|
"url": "https://github.com/Unson-LLC/brainbase/issues"
|
|
646
650
|
},
|
|
647
651
|
"homepage": "https://github.com/Unson-LLC/brainbase#readme",
|
|
648
|
-
"gitHead": "
|
|
652
|
+
"gitHead": "6a83008e1e11d2393b708f66f207755241da8956"
|
|
649
653
|
}
|
package/ui/brainbase-tokens.css
CHANGED
|
@@ -177,9 +177,9 @@
|
|
|
177
177
|
--bb-page-title-font-size: 20px;
|
|
178
178
|
--bb-page-title-line-height: 28px;
|
|
179
179
|
--bb-page-title-font-weight: 600;
|
|
180
|
-
--bb-page-header-padding-top:
|
|
181
|
-
--bb-page-header-padding-bottom:
|
|
182
|
-
--bb-page-header-height:
|
|
180
|
+
--bb-page-header-padding-top: 0px;
|
|
181
|
+
--bb-page-header-padding-bottom: 0px;
|
|
182
|
+
--bb-page-header-height: 52px;
|
|
183
183
|
--bb-search-band-header-height: var(--bb-page-header-height);
|
|
184
184
|
--bb-search-band-scope-padding: 13px;
|
|
185
185
|
--bb-search-band-scope-viewport-reserve: 192px;
|
|
@@ -190,4 +190,28 @@
|
|
|
190
190
|
--bb-create-hover: var(--bb-color-action-hover);
|
|
191
191
|
--bb-radius-pill: 999px;
|
|
192
192
|
|
|
193
|
+
/* Additive neutral compositions; existing palette aliases retain their values. */
|
|
194
|
+
--bb-color-slate: #475569;
|
|
195
|
+
--bb-color-line-soft: var(--bb-inbox-border-subtle);
|
|
196
|
+
--bb-color-placeholder: #9aa3af;
|
|
197
|
+
--bb-composed-chip-hover: rgb(36 50 75 / .1);
|
|
198
|
+
--bb-shadow-card-row-hover: 0 8px 18px -10px rgb(36 50 75 / .45);
|
|
199
|
+
--bb-shadow-card-preview: 0 8px 18px -12px rgb(36 50 75 / .45);
|
|
200
|
+
--bb-row-move-duration: 320ms;
|
|
201
|
+
--bb-row-move-ease: cubic-bezier(.2,.8,.2,1);
|
|
202
|
+
--bb-shadow-compact-dropdown: 0 0 0 1px rgb(27 36 51 / .08), 0 12px 28px rgb(27 36 51 / .18);
|
|
203
|
+
--bb-shadow-control-panel: 0 0 0 1px rgb(27 36 51 / .08), 0 20px 44px -12px rgb(27 36 51 / .28);
|
|
204
|
+
--bb-input-frame-width: 600px;
|
|
205
|
+
--bb-control-panel-width: 372px;
|
|
206
|
+
--bb-control-panel-duration: 160ms;
|
|
207
|
+
--bb-compact-dropdown-duration: 140ms;
|
|
208
|
+
--bb-compact-dropdown-offset: -6px;
|
|
209
|
+
--bb-compact-dropdown-scale: .98;
|
|
210
|
+
--bb-header-tab-color-duration: 200ms;
|
|
211
|
+
--bb-header-tab-duration: 300ms;
|
|
212
|
+
--bb-header-tab-ease: cubic-bezier(.3,1.4,.5,1);
|
|
213
|
+
--bb-input-frame-duration: 220ms;
|
|
214
|
+
--bb-input-frame-ease: cubic-bezier(.2,.7,.2,1);
|
|
215
|
+
--bb-shadow-input-frame: -12px 0 40px rgb(36 50 75 / .12);
|
|
216
|
+
--bb-color-input-frame-overlay: rgb(32 41 57 / .18);
|
|
193
217
|
}
|
package/ui/workspace-kit.css
CHANGED
|
@@ -1020,3 +1020,167 @@
|
|
|
1020
1020
|
|
|
1021
1021
|
.bb-ws-button.bb-ws-filter-chip:focus-visible { outline: 2px solid var(--bb-color-mint); outline-offset: 2px; }
|
|
1022
1022
|
.bb-ws-filter-anchor[data-pointer-focus] .bb-ws-filter-popover select:focus-visible { outline: none; box-shadow: none; }
|
|
1023
|
+
|
|
1024
|
+
/* Common page chrome; caller-owned tabs and tools retain their lifecycle. */
|
|
1025
|
+
.bb-ws-topbar { height: var(--bb-page-header-height); min-height: var(--bb-page-header-height); padding: 0 24px; gap: 8px; box-shadow: inset 0 -1px 0 var(--bb-color-border); }
|
|
1026
|
+
.bb-ws-topbar.has-query { gap: 8px; padding: 0 24px; padding-inline-end:var(--bb-page-header-inline-end, var(--bb-space-5)); }
|
|
1027
|
+
.bb-ws-topbar.has-tabs > h1 { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
1028
|
+
.bb-ws-topbar-tabs { display: flex; align-self: stretch; min-width: 0; }
|
|
1029
|
+
.bb-ws-topbar-tools { display: flex; align-items: center; flex: none; gap: 8px; margin-left: auto; }
|
|
1030
|
+
.bb-ws-topbar.has-query .bb-ws-topbar-tools { margin-left: 0; }
|
|
1031
|
+
.bb-ws-topbar.has-tabs .bb-ws-search-control { width: 210px; height: 32px; padding: 0 10px; gap: 8px; border-radius: 7px; }
|
|
1032
|
+
.bb-ws-topbar.has-tabs .bb-ws-search-control > .bb-ws-action-icon { width: 14px; height: 14px; }
|
|
1033
|
+
.bb-ws-topbar.has-tabs .bb-ws-search-control > input { font-size: 12.5px; }
|
|
1034
|
+
.bb-ws-topbar-tools > .bb-ws-button { height: 32px; min-height: 32px; padding: 0 12px 0 9px; gap: 5px; border-radius: 7px; font-size: 12.5px; }
|
|
1035
|
+
.bb-ws-topbar-tools > .bb-ws-button .bb-ws-action-icon { width: 14px; height: 14px; }
|
|
1036
|
+
.bb-ws-topbar.has-tabs { flex-wrap: nowrap; }
|
|
1037
|
+
@media (max-width: 600px) {
|
|
1038
|
+
.bb-ws-topbar.has-query:not(.has-tabs) { height: auto; min-height: var(--bb-page-header-height); }
|
|
1039
|
+
.bb-ws-topbar.has-tabs .bb-ws-search-control { flex: 1; min-width: 72px; }
|
|
1040
|
+
.bb-ws-topbar.has-tabs { padding-inline: 12px; }
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
/* Explicit header view tabs; all other strip appearances stay unchanged. */
|
|
1044
|
+
.bb-ws-tabs.bb-ws-tabs--header { --bb-tab-indicator-duration: var(--bb-header-tab-duration); --bb-tab-indicator-ease: var(--bb-header-tab-ease); gap: 2px; height: 100%; min-height: 52px; box-shadow: none; --bb-tab-indicator-size: 3px; }
|
|
1045
|
+
.bb-ws-tabs--header > :is([role="tab"],a,button) { transition:color var(--bb-header-tab-color-duration); gap: normal; height: 100%; min-height: 52px; padding: 0 14px; font-size: 15px; font-weight: 600; }
|
|
1046
|
+
.bb-ws-tabs--header > :is([role="tab"],a,button):is([aria-selected="true"],[aria-current="page"],[aria-pressed="true"]) { color: var(--bb-color-action); font-weight: 700; }
|
|
1047
|
+
.bb-ws-tabs--header > :is([role="tab"],a,button):is([aria-selected="true"],[aria-current="page"],[aria-pressed="true"]),
|
|
1048
|
+
.bb-ws-tabs--header > :is([role="tab"],a,button):is([aria-selected="true"],[aria-current="page"],[aria-pressed="true"]):hover { box-shadow: inset 0 -3px 0 var(--bb-color-action); }
|
|
1049
|
+
.bb-ws-tabs--header.is-indicator-ready > :is([role="tab"],a,button):is([aria-selected="true"],[aria-current="page"],[aria-pressed="true"]),
|
|
1050
|
+
.bb-ws-tabs--header.is-indicator-ready > :is([role="tab"],a,button):is([aria-selected="true"],[aria-current="page"],[aria-pressed="true"]):hover { box-shadow: none; }
|
|
1051
|
+
.bb-ws-tabs--header.is-indicator-ready::after { height: 3px; border-radius: 3px 3px 0 0; background: var(--bb-color-action); }
|
|
1052
|
+
.bb-ws-tabs--header .bb-ws-tab-count { min-height:0; display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 7px; padding: 0 7px; border-radius: 999px; background: var(--bb-color-accent-soft); color: var(--bb-color-action); font-size: 11.5px; font-weight: 600; }
|
|
1053
|
+
.bb-ws-tabs--header [aria-selected="true"] .bb-ws-tab-count,
|
|
1054
|
+
.bb-ws-tabs--header [aria-current="page"] .bb-ws-tab-count,
|
|
1055
|
+
.bb-ws-tabs--header [aria-pressed="true"] .bb-ws-tab-count { background: var(--bb-color-mint); }
|
|
1056
|
+
|
|
1057
|
+
/* Compact choices opt in to the sample's surface and motion. */
|
|
1058
|
+
.bb-ws-combobox--compact .bb-ws-combobox-trigger { width: auto; min-height: 28px; height: 28px; gap: 8px; padding: 0 8px 0 10px; border: 0; border-radius: 6px; box-shadow: none; background: transparent; color: var(--bb-color-ink); font: 500 13px/1.6 var(--bb-font-sans); }
|
|
1059
|
+
.bb-ws-combobox--compact .bb-ws-combobox-trigger[aria-expanded="true"] { color: var(--bb-color-action); }
|
|
1060
|
+
.bb-ws-combobox--compact .bb-ws-combobox-popup { top: calc(100% + 4px); width: max-content; min-width: 150px; max-height: 260px; padding: 4px; gap: 4px; border: 0; border-radius: 10px; box-shadow: var(--bb-shadow-compact-dropdown); animation: bb-ws-compact-dropdown-in var(--bb-compact-dropdown-duration) ease-out; }
|
|
1061
|
+
.bb-ws-combobox--compact .bb-ws-combobox-list { max-height: 240px; }
|
|
1062
|
+
.bb-ws-combobox--compact .bb-ws-combobox-option { min-height: 32px; padding: 0 10px; gap: 8px; border-radius: 8px; background: transparent; box-shadow: none; color: var(--bb-color-ink); font: 400 13px/1.6 var(--bb-font-sans); }
|
|
1063
|
+
.bb-ws-combobox--compact .bb-ws-combobox-option:hover { background: var(--bb-color-canvas); }
|
|
1064
|
+
.bb-ws-combobox--compact .bb-ws-combobox-option.is-active { outline: 1px solid var(--bb-color-action); outline-offset: -1px; box-shadow: none; }
|
|
1065
|
+
.bb-ws-combobox--compact .bb-ws-combobox-option[aria-selected="true"] { font-weight: 600; }
|
|
1066
|
+
.bb-ws-combobox--compact .bb-ws-combobox-option::before { color: var(--bb-color-action); }
|
|
1067
|
+
.bb-ws-combobox--compact .bb-ws-combobox-popup.is-closing { pointer-events: none; animation: bb-ws-compact-dropdown-out var(--bb-compact-dropdown-duration) ease-out forwards; }
|
|
1068
|
+
@keyframes bb-ws-compact-dropdown-in { from { transform: translateY(var(--bb-compact-dropdown-offset)) scale(var(--bb-compact-dropdown-scale)); opacity: 0; } to { transform: none; opacity: 1; } }
|
|
1069
|
+
@keyframes bb-ws-compact-dropdown-out { from { transform: none; opacity: 1; } to { transform: translateY(var(--bb-compact-dropdown-offset)) scale(var(--bb-compact-dropdown-scale)); opacity: 0; } }
|
|
1070
|
+
|
|
1071
|
+
/* Two-column panel content remains caller supplied. */
|
|
1072
|
+
.bb-ws-filter-popover.bb-ws-filter-popover--panel { top: 40px; display: block; width: var(--bb-control-panel-width); padding: 6px 0; border: 0; border-radius: 14px; overflow: visible; box-shadow: var(--bb-shadow-control-panel); animation: bb-ws-compact-dropdown-in var(--bb-control-panel-duration) var(--bb-filter-enter-ease); }
|
|
1073
|
+
.bb-ws-filter-popover--panel.is-closing { animation: bb-ws-filter-exit var(--bb-control-panel-duration) var(--bb-filter-enter-ease) forwards; --bb-filter-exit-distance: -6px; }
|
|
1074
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1075
|
+
.bb-ws-combobox--compact .bb-ws-combobox-popup,
|
|
1076
|
+
.bb-ws-combobox--compact .bb-ws-combobox-popup.is-closing,
|
|
1077
|
+
.bb-ws-filter-popover.bb-ws-filter-popover--panel,
|
|
1078
|
+
.bb-ws-filter-popover--panel.is-closing { animation: none; }
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
.bb-ws-search-control.bb-ws-search-control--compact { width: 210px; height: 32px; padding: 0 10px; gap: 8px; border-radius: 7px; }
|
|
1082
|
+
.bb-ws-search-control--compact > .bb-ws-action-icon { width: 14px; height: 14px; }
|
|
1083
|
+
.bb-ws-search-control.bb-ws-search-control--compact > input { font-size: 12.5px; }
|
|
1084
|
+
|
|
1085
|
+
.bb-ws-topbar-tools .bb-ws-filter-icon-trigger { min-width:32px; width:32px; height:32px; min-height:32px; border-radius:7px; }
|
|
1086
|
+
|
|
1087
|
+
/* Explicit compositions; no screen-specific or business selectors. */
|
|
1088
|
+
.bb-ws-condition-chips { display:flex; flex-wrap:wrap; align-items:center; gap:6px; min-width:0; }
|
|
1089
|
+
.bb-ws-condition-chip { display:inline-flex; align-items:center; gap:2px; height:24px; padding:0 3px 0 10px; border-radius:6px; background:var(--bb-color-accent-soft); color:var(--bb-color-action); font-size:12px; font-weight:500; white-space:nowrap; }
|
|
1090
|
+
.bb-ws-condition-chip > button { display:grid; place-items:center; width:18px; min-height:0; height:18px; padding:0; border:0; border-radius:4px; background:none; color:inherit; }
|
|
1091
|
+
.bb-ws-condition-chip > button:hover { background:var(--bb-composed-chip-hover); }
|
|
1092
|
+
.bb-ws-condition-chip svg { width:10px; height:10px; stroke:currentColor; stroke-width:2.2; fill:none; stroke-linecap:round; }
|
|
1093
|
+
.bb-ws-condition-reset { display:grid; place-items:center; flex:none; width:24px; height:24px; padding:0; border:0; border-radius:6px; background:none; color:var(--bb-color-slate); }
|
|
1094
|
+
.bb-ws-condition-reset:hover { background:var(--bb-color-line-soft); color:var(--bb-color-action); }
|
|
1095
|
+
.bb-ws-condition-reset svg { width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
|
|
1096
|
+
.bb-ws-pills { display:flex; gap:2px; }
|
|
1097
|
+
.bb-ws-pills > button { display:inline-flex; align-items:center; gap:8px; width:auto; min-height:0; height:28px; padding:0 11px; border:0; border-radius:var(--bb-radius-pill); background:none; color:var(--bb-color-slate); font:500 12.5px var(--bb-font-sans); white-space:nowrap; }
|
|
1098
|
+
.bb-ws-pills > button:not(:disabled):hover { background:var(--bb-color-canvas); }
|
|
1099
|
+
.bb-ws-pills > button[aria-pressed="true"] { background:var(--bb-color-action); color:var(--bb-color-action-text); font-weight:600; }
|
|
1100
|
+
.bb-ws-pills > button:disabled { opacity:.35; cursor:default; }
|
|
1101
|
+
|
|
1102
|
+
.bb-ws-control-row { display:grid; grid-template-columns:92px minmax(0,1fr); align-items:center; min-height:44px; padding:0 16px; }
|
|
1103
|
+
.bb-ws-control-row + .bb-ws-control-row { box-shadow:inset 0 1px 0 var(--bb-color-line-soft); }
|
|
1104
|
+
.bb-ws-control-row.is-tight { min-height:38px; box-shadow:none; }
|
|
1105
|
+
.bb-ws-control-label { color:var(--bb-color-slate); font-size:12.5px; }
|
|
1106
|
+
.bb-ws-control-slot { display:flex; align-items:center; justify-content:flex-end; gap:6px; min-width:0; }
|
|
1107
|
+
.bb-ws-form-row { display:grid; grid-template-columns:96px minmax(0,1fr); align-items:center; min-height:52px; box-shadow:inset 0 -1px 0 var(--bb-color-line-soft); }
|
|
1108
|
+
.bb-ws-form-row.is-top { align-items:start; padding:14px 0; }
|
|
1109
|
+
.bb-ws-form-label { display:flex; align-items:center; gap:3px; color:var(--bb-color-slate); font-size:12.5px; white-space:nowrap; }
|
|
1110
|
+
.bb-ws-form-required { color:var(--bb-color-review); font-size:13.5px; font-weight:700; -webkit-text-stroke:.7px currentColor; }
|
|
1111
|
+
.bb-ws-form-row:focus-within { box-shadow:inset 0 -2px 0 var(--bb-color-action); }
|
|
1112
|
+
.bb-ws-input-frame { width:600px; background:var(--bb-color-canvas); }
|
|
1113
|
+
.bb-ws-input-frame .bb-ws-detail-content { display:flex; flex-direction:column; min-height:calc(100% - 52px); padding:0; }
|
|
1114
|
+
.bb-ws-input-frame .bb-ws-detail-closebar { height:52px; min-height:52px; padding:12px 14px; background:var(--bb-color-canvas); border:0; }
|
|
1115
|
+
.bb-ws-input-tools { display:flex; align-items:center; gap:8px; margin-left:auto; }
|
|
1116
|
+
.bb-ws-input-top { padding:0 28px 20px; }
|
|
1117
|
+
.bb-ws-input-top > h2 { margin:0 0 14px; color:var(--bb-color-action); font-size:17px; font-weight:700; }
|
|
1118
|
+
.bb-ws-input-fields { flex:1; padding:6px 28px 24px; background:var(--bb-color-paper); box-shadow:inset 0 1px 0 var(--bb-color-border); }
|
|
1119
|
+
.bb-ws-input-fields input[type="text"], .bb-ws-input-fields textarea { box-sizing:border-box; width:100%; border:0; outline:0; background:none; color:var(--bb-color-ink); font:inherit; font-size:14px; }
|
|
1120
|
+
.bb-ws-input-fields input[type="text"] { height:52px; font-size:15px; font-weight:600; }
|
|
1121
|
+
.bb-ws-input-fields input::placeholder, .bb-ws-input-fields textarea::placeholder { color:var(--bb-color-placeholder); font-weight:400; }
|
|
1122
|
+
.bb-ws-input-fields textarea { min-height:120px; resize:vertical; line-height:1.8; }
|
|
1123
|
+
.bb-ws-input-fields input[type="date"], .bb-ws-input-fields input[type="datetime-local"] { width:auto; height:32px; padding:0 8px; border:0; border-radius:7px; outline:0; background:none; box-shadow:inset 0 0 0 1px var(--bb-color-border); color:var(--bb-color-ink); font:inherit; font-size:13px; }
|
|
1124
|
+
.bb-ws-input-fields .bb-ws-pills > button { height:30px; padding:0 12px; font-size:13px; }
|
|
1125
|
+
.bb-ws-input-footer { justify-content:flex-end; position:sticky; bottom:0; display:flex; align-items:center; gap:10px; padding:14px 28px; background:var(--bb-color-paper); box-shadow:inset 0 1px 0 var(--bb-color-border); }
|
|
1126
|
+
.bb-ws-input-footer > button { height:36px; min-height:0; padding:0 16px; border:0; border-radius:8px; background:none; color:var(--bb-color-slate); font-size:13px; font-weight:500; }
|
|
1127
|
+
.bb-ws-input-footer > button:hover { background:var(--bb-color-canvas); }
|
|
1128
|
+
.bb-ws-input-footer > button.is-primary { background:var(--bb-color-action); color:var(--bb-color-action-text); font-weight:600; }
|
|
1129
|
+
.bb-ws-input-footer > button.is-primary:hover { background:var(--bb-color-action-hover); }
|
|
1130
|
+
.bb-ws-input-footer > button:disabled { opacity:.4; cursor:default; }
|
|
1131
|
+
.bb-ws-card-row { box-sizing:border-box; position:relative; display:grid; grid-template-columns:var(--bb-card-columns,minmax(0,1fr)); column-gap:20px; align-items:center; width:100%; min-height:48px; margin-bottom:3px; padding:0 16px 0 22px; border:0; border-radius:8px; background:var(--bb-color-paper); color:var(--bb-color-ink); font:400 13px/1.6 var(--bb-font-sans); text-align:left; transition:box-shadow 150ms; }
|
|
1132
|
+
.bb-ws-card-row::before { content:""; position:absolute; left:0; top:0; bottom:0; width:5px; border-radius:8px 0 0 8px; background:var(--bb-card-stripe,var(--bb-color-border)); }
|
|
1133
|
+
.bb-ws-card-row:hover { box-shadow:var(--bb-shadow-card-row-hover); }
|
|
1134
|
+
.bb-ws-card-row.is-selected { box-shadow:0 0 0 2px var(--bb-color-action); }
|
|
1135
|
+
.bb-ws-card-row.is-preview { margin-bottom:0; min-height:52px; column-gap:16px; box-shadow:var(--bb-shadow-card-preview); }
|
|
1136
|
+
.bb-ws-card-cell { min-width:0; }
|
|
1137
|
+
.bb-ws-pills > button:focus-visible, .bb-ws-card-row:focus-visible, .bb-ws-condition-chips button:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1138
|
+
@media (prefers-reduced-motion:reduce) { .bb-ws-card-row { transition:none; } }
|
|
1139
|
+
@media (max-width:600px) { .bb-ws-input-frame { width:100%; } .bb-ws-input-fields { padding-inline:16px; } .bb-ws-input-top, .bb-ws-input-footer { padding-inline:16px; } }
|
|
1140
|
+
|
|
1141
|
+
.bb-ws-input-frame.bb-ws-drawer { width:var(--bb-input-frame-width); background:var(--bb-color-canvas); }
|
|
1142
|
+
.bb-ws-topbar.has-tabs .bb-ws-search-control, .bb-ws-search-control.bb-ws-search-control--compact { border:0; box-shadow:inset 0 0 0 1px var(--bb-color-border); font-size:12.5px; }
|
|
1143
|
+
.bb-ws-filter-popover.bb-ws-filter-popover--panel { gap:normal; }
|
|
1144
|
+
|
|
1145
|
+
/* The form frame uses the selected full-width slide, with the shared lifecycle. */
|
|
1146
|
+
.bb-ws-input-frame.bb-ws-drawer { border-left:0; box-shadow:var(--bb-shadow-input-frame); }
|
|
1147
|
+
.bb-ws-input-frame.bb-ws-drawer[open] { animation:bb-ws-input-frame-in var(--bb-input-frame-duration) var(--bb-input-frame-ease); }
|
|
1148
|
+
.bb-ws-input-frame.bb-ws-drawer.is-closing { animation:bb-ws-input-frame-out var(--bb-input-frame-duration) var(--bb-input-frame-ease) both; }
|
|
1149
|
+
.bb-ws-input-frame.bb-ws-drawer::backdrop { background:var(--bb-color-input-frame-overlay); }
|
|
1150
|
+
@keyframes bb-ws-input-frame-in { from { transform:translateX(100%); } to { transform:none; } }
|
|
1151
|
+
@keyframes bb-ws-input-frame-out { from { transform:none; } to { transform:translateX(100%); } }
|
|
1152
|
+
.bb-ws-input-frame .bb-ws-detail-closebar > .bb-ws-button { width:30px; height:30px; min-height:0; padding:0; border:0; border-radius:6px; background:none; font-size:0; color:var(--bb-color-muted); }
|
|
1153
|
+
.bb-ws-input-frame .bb-ws-detail-closebar > .bb-ws-button::before { content:'×'; font-size:22px; }
|
|
1154
|
+
.bb-ws-input-frame .bb-ws-detail-closebar > .bb-ws-button:hover { background:var(--bb-color-canvas); }
|
|
1155
|
+
.bb-ws-topbar-tools .bb-ws-filter-anchor > .bb-ws-button { width:32px; height:32px; min-height:0; padding:0; border:0; border-radius:7px; background:none; }
|
|
1156
|
+
.bb-ws-topbar-tools .bb-ws-filter-anchor > .bb-ws-button::after { display:none; }
|
|
1157
|
+
.bb-ws-input-fields .bb-ws-combobox--compact .bb-ws-combobox-trigger { height:32px; border-radius:7px; }
|
|
1158
|
+
.bb-ws-input-fields .bb-ws-combobox--compact .bb-ws-combobox-popup { min-width:200px; }
|
|
1159
|
+
.bb-ws-input-fields .bb-ws-combobox--compact .bb-ws-combobox-option { min-height:34px; }
|
|
1160
|
+
@media(prefers-reduced-motion:reduce) { .bb-ws-input-frame.bb-ws-drawer[open], .bb-ws-input-frame.bb-ws-drawer.is-closing { animation:none; } }
|
|
1161
|
+
@media(max-width:600px) { .bb-ws-input-frame.bb-ws-drawer { width:100vw; } }
|
|
1162
|
+
|
|
1163
|
+
.bb-ws-input-frame .bb-ws-detail-closebar { position:absolute; left:0; right:0; top:0; background:transparent; pointer-events:none; }
|
|
1164
|
+
.bb-ws-input-frame .bb-ws-detail-closebar button, .bb-ws-input-frame .bb-ws-input-tools { pointer-events:auto; }
|
|
1165
|
+
.bb-ws-input-frame .bb-ws-input-top { padding-top:22px; }
|
|
1166
|
+
.bb-ws-input-frame.has-tools .bb-ws-input-top { padding-top:52px; }
|
|
1167
|
+
.bb-ws-input-frame .bb-ws-input-top > h2 { padding-right:24px; }
|
|
1168
|
+
.bb-ws-input-frame .bb-ws-detail-content { min-height:100dvh; }
|
|
1169
|
+
|
|
1170
|
+
.bb-ws-combobox--compact.is-boxed .bb-ws-combobox-trigger,
|
|
1171
|
+
.bb-ws-input-fields .bb-ws-combobox--compact .bb-ws-combobox-trigger { box-shadow:inset 0 0 0 1px var(--bb-color-border); }
|
|
1172
|
+
.bb-ws-combobox--compact.is-active .bb-ws-combobox-trigger { background:var(--bb-color-accent-soft); color:var(--bb-color-action); font-weight:500; }
|
|
1173
|
+
|
|
1174
|
+
@media(prefers-reduced-motion:reduce) { .bb-ws-tabs--header > :is([role="tab"],a,button) { transition:none; } }
|
|
1175
|
+
|
|
1176
|
+
.bb-ws-combobox--compact.bb-ws-combobox-multiple .bb-ws-combobox-option { grid-template-columns:15px minmax(0,1fr) auto; }
|
|
1177
|
+
.bb-ws-combobox--compact.bb-ws-combobox-multiple .bb-ws-combobox-option::before { display:none; }
|
|
1178
|
+
.bb-ws-combobox-check { display:grid; place-items:center; width:15px; height:15px; border-radius:4px; box-shadow:inset 0 0 0 1.5px var(--bb-color-placeholder); color:transparent; }
|
|
1179
|
+
.bb-ws-combobox-check .bb-ws-action-icon { width:11px; height:11px; stroke-width:3; }
|
|
1180
|
+
.bb-ws-combobox-option[aria-selected="true"] > .bb-ws-combobox-check { background:var(--bb-color-action); color:var(--bb-color-action-text); box-shadow:none; }
|
|
1181
|
+
|
|
1182
|
+
.bb-ws-combobox--compact:not(.bb-ws-combobox-multiple) .bb-ws-combobox-option { grid-template-columns:14px minmax(0,1fr) auto; }
|
|
1183
|
+
.bb-ws-combobox--compact:not(.bb-ws-combobox-multiple) .bb-ws-combobox-option::before { display:none; }
|
|
1184
|
+
.bb-ws-combobox-mark { display:grid; place-items:center; width:14px; height:14px; color:var(--bb-color-action); }
|
|
1185
|
+
.bb-ws-combobox-mark .bb-ws-action-icon { width:14px; height:14px; stroke-width:2.4; visibility:hidden; }
|
|
1186
|
+
.bb-ws-combobox-option[aria-selected="true"] .bb-ws-combobox-mark .bb-ws-action-icon { visibility:visible; }
|
package/ui/workspace-kit.js
CHANGED
|
@@ -84,26 +84,46 @@ export function workspacePageHeader(doc, { crumbs = [], title, lead, help, prese
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/** Shared search presentation. The caller keeps the input, value and handlers. */
|
|
87
|
-
export function workspaceSearchControl(doc, { input } = {}) {
|
|
87
|
+
export function workspaceSearchControl(doc, { input, appearance } = {}) {
|
|
88
88
|
if (!input || typeof input.tagName !== 'string') throw new TypeError('search_input_required');
|
|
89
89
|
const search = el(doc, 'label', { className: 'bb-ws-search-control' });
|
|
90
|
+
if (appearance === 'compact') toggleWorkspaceClass(search, 'bb-ws-search-control--compact', true);
|
|
90
91
|
search.append(workspaceActionIcon(doc, 'search'), input);
|
|
91
92
|
return search;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
/** A shared title bar, with an optional search input owned by the caller. */
|
|
95
|
-
export function workspaceTopbar(doc, { title = '', query } = {}) {
|
|
96
|
+
export function workspaceTopbar(doc, { title = '', query, tabs, tools } = {}) {
|
|
96
97
|
const header = el(doc, 'header', { className: 'bb-ws-topbar' });
|
|
97
98
|
header.append(el(doc, 'h1', { text: title }));
|
|
98
99
|
let search;
|
|
99
100
|
let currentQuery;
|
|
101
|
+
let tabsSlot;
|
|
102
|
+
let toolsSlot;
|
|
103
|
+
header.setTabs = content => {
|
|
104
|
+
if (Array.isArray(content) && !content.some(Boolean)) content = null;
|
|
105
|
+
tabsSlot?.remove(); tabsSlot = null;
|
|
106
|
+
if (content) {
|
|
107
|
+
tabsSlot = el(doc, 'div', { className: 'bb-ws-topbar-tabs' });
|
|
108
|
+
appendContent(tabsSlot, doc, content); header.append(tabsSlot);
|
|
109
|
+
if (search) header.append(search);
|
|
110
|
+
if (toolsSlot) header.append(toolsSlot);
|
|
111
|
+
}
|
|
112
|
+
toggleWorkspaceClass(header, 'has-tabs', Boolean(content));
|
|
113
|
+
};
|
|
114
|
+
header.setTools = content => {
|
|
115
|
+
if (Array.isArray(content) && !content.some(Boolean)) content = null;
|
|
116
|
+
toolsSlot?.remove(); toolsSlot = null;
|
|
117
|
+
if (content) { toolsSlot = el(doc, 'div', { className: 'bb-ws-topbar-tools' }); appendContent(toolsSlot, doc, content); header.append(toolsSlot); }
|
|
118
|
+
toggleWorkspaceClass(header, 'has-tools', Boolean(content));
|
|
119
|
+
};
|
|
100
120
|
header.setQuery = input => {
|
|
101
121
|
if (input === currentQuery) return;
|
|
102
122
|
search?.remove(); search = null; currentQuery = input;
|
|
103
|
-
if (input) { search = workspaceSearchControl(doc, { input }); header.append(search); }
|
|
123
|
+
if (input) { search = workspaceSearchControl(doc, { input }); header.append(search); if (toolsSlot) header.append(toolsSlot); }
|
|
104
124
|
toggleWorkspaceClass(header, 'has-query', Boolean(input));
|
|
105
125
|
};
|
|
106
|
-
header.setQuery(query);
|
|
126
|
+
header.setTabs(tabs); header.setQuery(query); header.setTools(tools);
|
|
107
127
|
return header;
|
|
108
128
|
}
|
|
109
129
|
|
|
@@ -398,7 +418,7 @@ export function workspaceCloseDrawer(dialog, finish) {
|
|
|
398
418
|
};
|
|
399
419
|
const complete = () => { if (!active) return; cancel(); finish(); };
|
|
400
420
|
const ended = event => {
|
|
401
|
-
if (event.target === dialog &&
|
|
421
|
+
if (event.target === dialog && ['bb-ws-drawer-out', 'bb-ws-input-frame-out'].includes(event.animationName)) complete();
|
|
402
422
|
};
|
|
403
423
|
drawerClosings.set(dialog, cancel);
|
|
404
424
|
dialog.addEventListener('animationend', ended);
|
|
@@ -472,6 +492,7 @@ export function workspaceFilterPopover(doc, { content, open = false, onToggle, t
|
|
|
472
492
|
const panel = suppliedPanel || el(doc, 'div', { className: 'bb-ws-filter-popover', attrs: { id: `bb-ws-filter-${nextWorkspaceSequence()}`, role: 'region', 'aria-label': '詳細検索' } });
|
|
473
493
|
if (!panel.id && !panel.getAttribute?.('id')) panel.setAttribute('id', `bb-ws-filter-${nextWorkspaceSequence()}`);
|
|
474
494
|
panel.classList?.add('bb-ws-filter-popover');
|
|
495
|
+
if (appearance === 'panel') toggleWorkspaceClass(panel, 'bb-ws-filter-popover--panel', true);
|
|
475
496
|
const control = trigger || workspaceButton(doc, { text: appearance === 'icon' ? undefined : '詳細検索', variant: 'quiet' });
|
|
476
497
|
if (appearance === 'icon') {
|
|
477
498
|
control.classList?.add('bb-ws-filter-icon-trigger');
|
|
@@ -512,7 +533,7 @@ export function workspaceFilterPopover(doc, { content, open = false, onToggle, t
|
|
|
512
533
|
panel.setAttribute('inert', ''); panel.setAttribute('aria-hidden', 'true');
|
|
513
534
|
if (wasOpen && panel.isConnected !== false && panel.classList && !reducedMotion(panel)) {
|
|
514
535
|
panel.classList.add('is-closing'); panel.addEventListener('animationend', ended);
|
|
515
|
-
timer = setTimeout(finishExit, animationFallback(panel, 50, 230));
|
|
536
|
+
timer = setTimeout(finishExit, animationFallback(panel, 50, appearance === 'panel' ? 210 : 230));
|
|
516
537
|
} else panel.hidden = true;
|
|
517
538
|
}
|
|
518
539
|
onToggle?.(next);
|
|
@@ -632,11 +653,12 @@ function comboboxText(value) {
|
|
|
632
653
|
export function workspaceCombobox(doc, {
|
|
633
654
|
label, options = [], value = '', placeholder = '選択してください', searchLabel, searchPlaceholder = '絞り込む',
|
|
634
655
|
emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange,
|
|
635
|
-
multiple = false, values = [], renderIcon, showCount = true, showHints = true, align = 'start',
|
|
656
|
+
multiple = false, values = [], renderIcon, showCount = true, showHints = true, align = 'start', appearance,
|
|
636
657
|
} = {}) {
|
|
637
658
|
const sequence = nextWorkspaceSequence();
|
|
638
659
|
const listId = `bb-ws-combobox-${sequence}-list`;
|
|
639
660
|
const root = el(doc, 'span', { className: ['bb-ws-combobox', className].filter(Boolean).join(' ') });
|
|
661
|
+
if (appearance === 'compact') toggleWorkspaceClass(root, 'bb-ws-combobox--compact', true);
|
|
640
662
|
if (multiple) root.classList?.add('bb-ws-combobox-multiple');
|
|
641
663
|
if (align === 'end') root.classList?.add('bb-ws-combobox-align-end');
|
|
642
664
|
const trigger = el(doc, 'button', { className: 'bb-ws-combobox-trigger', attrs: { type: 'button', 'aria-haspopup': 'listbox', 'aria-expanded': 'false', 'aria-controls': listId } });
|
|
@@ -655,6 +677,10 @@ export function workspaceCombobox(doc, {
|
|
|
655
677
|
root.append(trigger, popup);
|
|
656
678
|
|
|
657
679
|
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 };
|
|
680
|
+
let exitTimer;
|
|
681
|
+
const cancelExit = () => { clearTimeout(exitTimer); exitTimer = undefined; popup.removeEventListener?.('animationend', exitEnded); toggleWorkspaceClass(popup, 'is-closing', false); };
|
|
682
|
+
const finishExit = () => { cancelExit(); if (!state.open) popup.hidden = true; };
|
|
683
|
+
const exitEnded = event => { if (event.target === popup && event.animationName === 'bb-ws-compact-dropdown-out') finishExit(); };
|
|
658
684
|
const usesSearch = () => searchable === true || (searchable === 'auto' && state.options.length > 8);
|
|
659
685
|
const focusTarget = () => (usesSearch() ? search : list);
|
|
660
686
|
const chosen = () => state.options.find(option => option.value === state.value);
|
|
@@ -703,6 +729,10 @@ export function workspaceCombobox(doc, {
|
|
|
703
729
|
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 } });
|
|
704
730
|
const optionLabel = el(doc, 'span', { className: 'bb-ws-combobox-option-label', text: option.label });
|
|
705
731
|
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 })); } }
|
|
732
|
+
if (appearance === 'compact') {
|
|
733
|
+
const check = el(doc, 'span', { className: multiple ? 'bb-ws-combobox-check' : 'bb-ws-combobox-mark', attrs: { 'aria-hidden': 'true' } });
|
|
734
|
+
check.append(workspaceActionIcon(doc, 'check')); item.append(check);
|
|
735
|
+
}
|
|
706
736
|
item.append(optionLabel);
|
|
707
737
|
if (showHints && option.hint) item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-hint', text: option.hint }));
|
|
708
738
|
item.addEventListener('pointerdown', event => event.preventDefault?.());
|
|
@@ -737,6 +767,7 @@ export function workspaceCombobox(doc, {
|
|
|
737
767
|
|
|
738
768
|
function open(query = '') {
|
|
739
769
|
if (state.disabled) return;
|
|
770
|
+
cancelExit(); popup.inert = false; popup.removeAttribute?.('inert'); popup.removeAttribute?.('aria-hidden');
|
|
740
771
|
if (!state.open) { state.open = true; doc.addEventListener?.('pointerdown', outside); }
|
|
741
772
|
state.query = query; search.value = query; search.hidden = !usesSearch();
|
|
742
773
|
const selectedIndex = state.options.findIndex(option => multiple ? state.values.includes(option.value) : option.value === state.value);
|
|
@@ -749,7 +780,12 @@ export function workspaceCombobox(doc, {
|
|
|
749
780
|
function close(returnFocus = true) {
|
|
750
781
|
if (!state.open) return;
|
|
751
782
|
state.open = false; removeListeners();
|
|
752
|
-
|
|
783
|
+
if (appearance === 'compact' && !reducedMotion(popup) && popup.isConnected !== false) {
|
|
784
|
+
popup.inert = true; popup.setAttribute('inert', ''); popup.setAttribute('aria-hidden', 'true');
|
|
785
|
+
toggleWorkspaceClass(popup, 'is-closing', true); popup.addEventListener?.('animationend', exitEnded);
|
|
786
|
+
exitTimer = setTimeout(finishExit, animationFallback(popup, 50, 190));
|
|
787
|
+
} else popup.hidden = true;
|
|
788
|
+
trigger.setAttribute('aria-expanded', 'false'); activeDescendant(null);
|
|
753
789
|
if (returnFocus) trigger.focus?.();
|
|
754
790
|
}
|
|
755
791
|
|
|
@@ -809,7 +845,7 @@ export function workspaceCombobox(doc, {
|
|
|
809
845
|
renderTrigger();
|
|
810
846
|
if (state.open) { search.hidden = !usesSearch(); renderList(); }
|
|
811
847
|
},
|
|
812
|
-
destroy() { close(false); removeListeners(); },
|
|
848
|
+
destroy() { close(false); removeListeners(); cancelExit(); popup.hidden = true; },
|
|
813
849
|
};
|
|
814
850
|
}
|
|
815
851
|
|
|
@@ -818,7 +854,7 @@ export function workspaceActionIcon(doc, name) {
|
|
|
818
854
|
const svg = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'svg') : doc.createElement('svg');
|
|
819
855
|
for (const [key, value] of Object.entries({ class: 'bb-ws-action-icon', viewBox: '0 0 24 24', 'aria-hidden': 'true' })) svg.setAttribute(key, value);
|
|
820
856
|
const path = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'path') : doc.createElement('path');
|
|
821
|
-
const paths = { plus: 'M12 5v14M5 12h14', search: 'M21 21l-4.35-4.35M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0', filter: 'M4 7h16M7 12h10M10 17h4', sort: 'M8 4v16m-3-3 3 3 3-3M16 20V4m-3 3 3-3 3 3' };
|
|
857
|
+
const paths = { check: 'M5 12l5 5 9-10', sliders: 'M4 8h8M18 8h2M4 16h2M12 16h8 M17.4 8a2.4 2.4 0 1 1-4.8 0 2.4 2.4 0 0 1 4.8 0 M11.4 16a2.4 2.4 0 1 1-4.8 0 2.4 2.4 0 0 1 4.8 0', plus: 'M12 5v14M5 12h14', search: 'M21 21l-4.35-4.35M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0', filter: 'M4 7h16M7 12h10M10 17h4', sort: 'M8 4v16m-3-3 3 3 3-3M16 20V4m-3 3 3-3 3 3' };
|
|
822
858
|
path.setAttribute('d', paths[name] || paths.filter); svg.append(path); return svg;
|
|
823
859
|
}
|
|
824
860
|
|
|
@@ -895,6 +931,7 @@ export function workspaceTabStrip(root, { memoryKey, appearance } = {}) {
|
|
|
895
931
|
workspaceTabList(root);
|
|
896
932
|
if (appearance === 'prominent') toggleWorkspaceClass(root, 'bb-ws-tabs--prominent', true);
|
|
897
933
|
if (appearance === 'segmented') toggleWorkspaceClass(root, 'bb-ws-tabs--segmented', true);
|
|
934
|
+
if (appearance === 'header') toggleWorkspaceClass(root, 'bb-ws-tabs--header', true);
|
|
898
935
|
if (tabStrips.has(root)) return tabStrips.get(root);
|
|
899
936
|
const doc = root.ownerDocument;
|
|
900
937
|
const view = doc?.defaultView;
|
|
@@ -1030,3 +1067,120 @@ export function workspaceSearchBand(doc, { root, query, filters, sort, reset, on
|
|
|
1030
1067
|
destroy() { filter.destroy(); reset?.removeEventListener('click', clear); sortReset.removeEventListener('click', resetSort); sort?.trigger.removeEventListener('click', sortClick); sort?.trigger.removeEventListener('keydown', sortClick); },
|
|
1031
1068
|
};
|
|
1032
1069
|
}
|
|
1070
|
+
|
|
1071
|
+
/** Business-neutral compositions. Labels, values and mutations belong to the host. */
|
|
1072
|
+
|
|
1073
|
+
export function workspaceConditionChips(doc, { items = [], reset, resetLabel = '初めの状態に戻す' } = {}) {
|
|
1074
|
+
const root = el(doc, 'div', { className: 'bb-ws-condition-chips' });
|
|
1075
|
+
for (const { label, onRemove } of items) {
|
|
1076
|
+
const chip = el(doc, 'span', { className: 'bb-ws-condition-chip' });
|
|
1077
|
+
chip.append(el(doc, 'span', { text: label }));
|
|
1078
|
+
const remove = workspaceButton(doc, { attrs: { 'aria-label': `${label}を解除` }, onClick: onRemove });
|
|
1079
|
+
const svg = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
1080
|
+
svg.setAttribute('viewBox', '0 0 24 24'); svg.setAttribute('aria-hidden', 'true');
|
|
1081
|
+
const path = doc.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
1082
|
+
path.setAttribute('d', 'M6 6l12 12M18 6L6 18'); svg.append(path); remove.append(svg);
|
|
1083
|
+
chip.append(remove); root.append(chip);
|
|
1084
|
+
}
|
|
1085
|
+
if (reset) {
|
|
1086
|
+
const button = workspaceButton(doc, { attrs: { 'aria-label': resetLabel, title: resetLabel }, onClick: reset });
|
|
1087
|
+
button.className = 'bb-ws-condition-reset';
|
|
1088
|
+
const svg = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
1089
|
+
svg.setAttribute('viewBox', '0 0 24 24'); svg.setAttribute('aria-hidden', 'true');
|
|
1090
|
+
const path = doc.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
1091
|
+
path.setAttribute('d', 'M4 5v5h5 M4.6 10A8 8 0 1 1 6.3 17.7'); svg.append(path); button.append(svg); root.append(button);
|
|
1092
|
+
}
|
|
1093
|
+
return root;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
export function workspacePills(doc, { label, items = [], value, onChange } = {}) {
|
|
1097
|
+
const root = el(doc, 'div', { className: 'bb-ws-pills', attrs: { role: 'group', 'aria-label': label } });
|
|
1098
|
+
const buttons = items.map(item => {
|
|
1099
|
+
const button = workspaceButton(doc, { text: item.label, disabled: Boolean(item.disabled),
|
|
1100
|
+
attrs: { 'aria-pressed': String(item.value === value) }, onClick: () => onChange?.(item.value, item) });
|
|
1101
|
+
if (item.icon) button.prepend(item.icon);
|
|
1102
|
+
root.append(button); return button;
|
|
1103
|
+
});
|
|
1104
|
+
root.update = next => buttons.forEach((button, i) => button.setAttribute('aria-pressed', String(items[i].value === next)));
|
|
1105
|
+
return root;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
export function workspaceControlRow(doc, { label, control, tight = false } = {}) {
|
|
1109
|
+
const root = el(doc, 'div', { className: `bb-ws-control-row${tight ? ' is-tight' : ''}` });
|
|
1110
|
+
const slot = el(doc, 'div', { className: 'bb-ws-control-slot' });
|
|
1111
|
+
if (control) slot.append(control);
|
|
1112
|
+
root.append(el(doc, 'span', { className: 'bb-ws-control-label', text: label }), slot);
|
|
1113
|
+
return root;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
export function workspaceFormRow(doc, { label, control, required = false, top = false } = {}) {
|
|
1117
|
+
const root = el(doc, 'div', { className: `bb-ws-form-row${top ? ' is-top' : ''}` });
|
|
1118
|
+
const caption = el(doc, control?.id ? 'label' : 'span', { className: 'bb-ws-form-label', text: label,
|
|
1119
|
+
attrs: { for: control?.id || undefined } });
|
|
1120
|
+
if (required) {
|
|
1121
|
+
caption.append(el(doc, 'span', { className: 'bb-ws-form-required', text: '※', attrs: { 'aria-label': '必須' } }));
|
|
1122
|
+
control?.setAttribute('aria-required', 'true');
|
|
1123
|
+
if (control && ['INPUT', 'TEXTAREA', 'SELECT'].includes(control.tagName)) control.required = true;
|
|
1124
|
+
}
|
|
1125
|
+
if (control && !control.id && !control.getAttribute('aria-label') && !control.getAttribute('aria-labelledby')) control.setAttribute('aria-label', label);
|
|
1126
|
+
root.append(caption); if (control) root.append(control);
|
|
1127
|
+
return root;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/** Uses the canonical modal, Escape/backdrop/close animation and focus return. */
|
|
1131
|
+
export function workspaceInputFrame(doc, { title, opener, onClose, tools = [], preview, rows = [], footer = [], showTitle = true } = {}) {
|
|
1132
|
+
const drawer = workspaceDetailDrawer(doc, { title, opener, onClose });
|
|
1133
|
+
drawer.dialog.classList.add('bb-ws-input-frame');
|
|
1134
|
+
if (tools.length) drawer.dialog.classList.add('has-tools');
|
|
1135
|
+
drawer.dialog.querySelector('.bb-ws-detail-closebar > button')?.setAttribute('aria-label', '閉じる');
|
|
1136
|
+
const top = el(doc, 'div', { className: 'bb-ws-input-top' });
|
|
1137
|
+
const toolRow = el(doc, 'div', { className: 'bb-ws-input-tools' }); toolRow.append(...tools);
|
|
1138
|
+
const heading = el(doc, 'h2', { text: title }); if (showTitle) top.append(heading); if (preview) top.append(preview);
|
|
1139
|
+
const form = el(doc, 'div', { className: 'bb-ws-input-fields' }); form.append(...rows);
|
|
1140
|
+
const foot = el(doc, 'div', { className: 'bb-ws-input-footer' }); foot.append(...footer);
|
|
1141
|
+
drawer.dialog.querySelector('.bb-ws-detail-closebar').prepend(toolRow);
|
|
1142
|
+
drawer.setContent(top, form, foot);
|
|
1143
|
+
return { ...drawer, top, tools: toolRow, fields: form, footer: foot,
|
|
1144
|
+
setTitle(next) { drawer.setTitle(next); heading.textContent = String(next); },
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
export function workspaceCardRow(doc, { cells = [], stripe, selected = false, key, onSelect, label, preview = false } = {}) {
|
|
1149
|
+
const root = el(doc, onSelect ? 'button' : 'div', { className: `bb-ws-card-row${selected ? ' is-selected' : ''}${preview ? ' is-preview' : ''}`,
|
|
1150
|
+
attrs: { type: onSelect ? 'button' : undefined, 'data-key': key, 'aria-label': label, 'aria-pressed': onSelect ? String(selected) : undefined } });
|
|
1151
|
+
if (stripe) root.style.setProperty('--bb-card-stripe', stripe);
|
|
1152
|
+
for (const cell of cells) {
|
|
1153
|
+
const slot = el(doc, 'span', { className: 'bb-ws-card-cell' });
|
|
1154
|
+
if (cell && typeof cell === 'object' && cell.tagName) slot.append(cell); else slot.textContent = String(cell ?? '');
|
|
1155
|
+
root.append(slot);
|
|
1156
|
+
}
|
|
1157
|
+
if (onSelect) root.addEventListener('click', () => onSelect(key));
|
|
1158
|
+
return root;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/** FLIP keyed retained or redrawn rows; capture immediately before a host redraw. */
|
|
1162
|
+
export function workspaceRowMotion(root) {
|
|
1163
|
+
let previous = new Map();
|
|
1164
|
+
const animations = new Set();
|
|
1165
|
+
return {
|
|
1166
|
+
capture() { previous = new Map(Array.from(root.querySelectorAll('[data-key]'), node => [node.getAttribute('data-key'), node.getBoundingClientRect().top])); },
|
|
1167
|
+
play() {
|
|
1168
|
+
for (const animation of animations) animation.cancel(); animations.clear();
|
|
1169
|
+
if (root.ownerDocument.defaultView?.matchMedia?.('(prefers-reduced-motion: reduce)').matches) { previous.clear(); return; }
|
|
1170
|
+
const style = root.ownerDocument.defaultView?.getComputedStyle(root);
|
|
1171
|
+
const rawDuration = style?.getPropertyValue('--bb-row-move-duration').trim();
|
|
1172
|
+
const amount = parseFloat(rawDuration);
|
|
1173
|
+
const duration = Number.isFinite(amount) && amount >= 0 ? amount * (rawDuration.endsWith('ms') ? 1 : 1000) : 320;
|
|
1174
|
+
const easing = style?.getPropertyValue('--bb-row-move-ease').trim() || 'cubic-bezier(.2,.8,.2,1)';
|
|
1175
|
+
for (const node of root.querySelectorAll('[data-key]')) {
|
|
1176
|
+
const old = previous.get(node.getAttribute('data-key'));
|
|
1177
|
+
const dy = old === undefined ? 0 : old - node.getBoundingClientRect().top;
|
|
1178
|
+
if (!dy || !node.animate) continue;
|
|
1179
|
+
const animation = node.animate([{ transform: `translateY(${dy}px)` }, { transform: 'none' }], { duration, easing });
|
|
1180
|
+
animations.add(animation); animation.finished?.then(() => animations.delete(animation), () => animations.delete(animation));
|
|
1181
|
+
}
|
|
1182
|
+
previous.clear();
|
|
1183
|
+
},
|
|
1184
|
+
destroy() { for (const animation of animations) animation.cancel(); animations.clear(); previous.clear(); },
|
|
1185
|
+
};
|
|
1186
|
+
}
|