@unson/brainbase-mcp 0.50.21 → 0.50.23
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/package.json +2 -2
- package/ui/workspace-kit.css +142 -3
- package/ui/workspace-kit.js +470 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.23",
|
|
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",
|
|
@@ -657,5 +657,5 @@
|
|
|
657
657
|
"url": "https://github.com/Unson-LLC/brainbase/issues"
|
|
658
658
|
},
|
|
659
659
|
"homepage": "https://github.com/Unson-LLC/brainbase#readme",
|
|
660
|
-
"gitHead": "
|
|
660
|
+
"gitHead": "49263ad02569eb3b2cccc652cade085502f82d4d"
|
|
661
661
|
}
|
package/ui/workspace-kit.css
CHANGED
|
@@ -169,6 +169,8 @@
|
|
|
169
169
|
border-color: var(--bb-color-action-hover);
|
|
170
170
|
background: var(--bb-color-action-hover);
|
|
171
171
|
}
|
|
172
|
+
.bb-ws-button.is-accent { border: 0; background: var(--bb-color-accent-soft); color: var(--bb-color-action); box-shadow: none; }
|
|
173
|
+
.bb-ws-button.is-accent:hover:not(:disabled) { border: 0; background: var(--bb-color-accent-soft); color: var(--bb-color-action); box-shadow: none; }
|
|
172
174
|
|
|
173
175
|
.bb-ws-button.is-danger {
|
|
174
176
|
color: var(--bb-color-danger);
|
|
@@ -180,6 +182,27 @@
|
|
|
180
182
|
font-size: 12px;
|
|
181
183
|
}
|
|
182
184
|
|
|
185
|
+
/* Small row actions are opt-in; existing buttons keep their 38px default. */
|
|
186
|
+
.bb-ws-button.bb-ws-button--compact {
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
height: 32px;
|
|
190
|
+
min-height: 32px;
|
|
191
|
+
padding: 0 12px;
|
|
192
|
+
border-radius: 7px;
|
|
193
|
+
font-size: 12.5px;
|
|
194
|
+
font-weight: 500;
|
|
195
|
+
line-height: 1;
|
|
196
|
+
}
|
|
197
|
+
.bb-ws-button.bb-ws-button--compact.is-primary:disabled {
|
|
198
|
+
border: 0;
|
|
199
|
+
background: var(--bb-color-canvas);
|
|
200
|
+
color: var(--bb-color-muted);
|
|
201
|
+
box-shadow: none;
|
|
202
|
+
opacity: 1;
|
|
203
|
+
}
|
|
204
|
+
.bb-ws-button.bb-ws-button--compact:disabled { border: 0; background: var(--bb-color-canvas); color: var(--bb-color-muted); box-shadow: none; opacity: 1; }
|
|
205
|
+
|
|
183
206
|
.bb-ws-button:disabled {
|
|
184
207
|
cursor: not-allowed;
|
|
185
208
|
opacity: .58;
|
|
@@ -513,6 +536,11 @@
|
|
|
513
536
|
.bb-ws-disclosure[open] > summary::before { transform: rotate(90deg); }
|
|
514
537
|
.bb-ws-disclosure > summary h2 { margin: 0; font-size: 22px; line-height: 1.4; }
|
|
515
538
|
.bb-ws-disclosure > :not(summary) { margin: 0 0 18px 25px; }
|
|
539
|
+
.bb-ws-disclosure--compact { border-top: 0; }
|
|
540
|
+
.bb-ws-disclosure--compact > summary { gap: var(--bb-space-2); padding: 0; }
|
|
541
|
+
.bb-ws-disclosure--compact > summary::before { font-size: 16px; }
|
|
542
|
+
.bb-ws-disclosure--compact > summary :is(h2,h3,h4,h5,h6) { margin: 0; font-size: 14px; line-height: 1.4; }
|
|
543
|
+
.bb-ws-disclosure--compact > :not(summary) { margin: var(--bb-space-1) 0 0 var(--bb-space-4); }
|
|
516
544
|
.bb-ws-disclosure > summary:focus-visible, .bb-ws-help-button:focus-visible { outline: 2px solid var(--bb-color-focus); outline-offset: 3px; }
|
|
517
545
|
.bb-ws-error-stack { position: absolute; z-index: 55; top: 0; right: 0; width: min(300px,100%); max-height: none; padding-bottom: 64px; pointer-events: none; box-sizing: border-box; overflow: visible; }
|
|
518
546
|
.bb-ws-error-list { display: grid; gap: 6px; }
|
|
@@ -1134,11 +1162,12 @@
|
|
|
1134
1162
|
.bb-ws-input-footer > button.is-primary { background:var(--bb-color-action); color:var(--bb-color-action-text); font-weight:600; }
|
|
1135
1163
|
.bb-ws-input-footer > button.is-primary:hover { background:var(--bb-color-action-hover); }
|
|
1136
1164
|
.bb-ws-input-footer > button:disabled { opacity:.4; cursor:default; }
|
|
1137
|
-
.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; }
|
|
1165
|
+
.bb-ws-card-row { box-sizing:border-box; position:relative; display:grid; grid-template-columns:var(--bb-card-columns,minmax(0,1fr)); column-gap:var(--bb-ws-card-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; }
|
|
1138
1166
|
.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)); }
|
|
1139
1167
|
.bb-ws-card-row:hover { box-shadow:var(--bb-shadow-card-row-hover); }
|
|
1140
1168
|
.bb-ws-card-row.is-selected { box-shadow:0 0 0 2px var(--bb-color-action); }
|
|
1141
|
-
.bb-ws-card-row
|
|
1169
|
+
.bb-ws-card-row--busy { opacity:.72; }
|
|
1170
|
+
.bb-ws-card-row.is-preview { margin-bottom:0; min-height:52px; column-gap:var(--bb-ws-card-column-gap,16px); box-shadow:var(--bb-shadow-card-preview); }
|
|
1142
1171
|
.bb-ws-card-cell { min-width:0; }
|
|
1143
1172
|
.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; }
|
|
1144
1173
|
@media (prefers-reduced-motion:reduce) { .bb-ws-card-row { transition:none; } }
|
|
@@ -1217,7 +1246,7 @@
|
|
|
1217
1246
|
.bb-ws-anchored-popover:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1218
1247
|
@keyframes bb-ws-anchored-in { from { transform:scale(.94); opacity:0; } to { transform:none; opacity:1; } }
|
|
1219
1248
|
|
|
1220
|
-
.bb-ws-dialog.bb-ws-dialog--compact { width:min(440px,calc(100vw - 32px)); padding:20px 20px 18px; border:0; border-radius:16px; background:var(--bb-color-paper); box-shadow:var(--bb-shadow-compact-dialog); animation:bb-ws-compact-dialog-in 200ms cubic-bezier(.2,.8,.2,1); }
|
|
1249
|
+
.bb-ws-dialog.bb-ws-dialog--compact { width:min(var(--bb-dialog-compact-width,440px),calc(100vw - 32px)); padding:20px 20px 18px; border:0; border-radius:16px; background:var(--bb-color-paper); box-shadow:var(--bb-shadow-compact-dialog); animation:bb-ws-compact-dialog-in 200ms cubic-bezier(.2,.8,.2,1); }
|
|
1221
1250
|
.bb-ws-dialog--compact::backdrop { background:color-mix(in srgb,var(--bb-color-ink) 18%,transparent); }
|
|
1222
1251
|
.bb-ws-dialog--compact .bb-ws-dialog-head { align-items:center; gap:0; margin-bottom:4px; padding:0; border:0; }
|
|
1223
1252
|
.bb-ws-dialog--compact .bb-ws-dialog-head h2 { flex:1; font-size:16px; font-weight:600; line-height:1.6; }
|
|
@@ -1286,6 +1315,116 @@
|
|
|
1286
1315
|
.bb-ws-topbar.has-tabs .bb-ws-topbar-tools > .bb-ws-button.is-icon .bb-ws-action-icon { width:16px; height:16px; }
|
|
1287
1316
|
.bb-ws-button.is-icon:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1288
1317
|
|
|
1318
|
+
/* Explicit shared parts for reviewable rows and their transient states. */
|
|
1319
|
+
.bb-ws-status-pill { display:inline-grid; place-items:center; box-sizing:border-box; width:var(--bb-status-pill-width,max-content); min-height:22px; height:22px; padding:0 8px; border-radius:var(--bb-radius-pill); background:var(--bb-color-canvas); color:var(--bb-color-slate); font-size:11.5px; font-weight:500; white-space:nowrap; }
|
|
1320
|
+
.bb-ws-status-pill.is-success { background:var(--bb-color-accent-soft); color:var(--bb-color-success); }
|
|
1321
|
+
.bb-ws-status-pill.is-warning { background:var(--bb-color-warning-soft); color:var(--bb-color-warning); font-weight:600; }
|
|
1322
|
+
.bb-ws-status-pill.is-danger { background:var(--bb-color-danger-soft); color:var(--bb-color-danger); }
|
|
1323
|
+
.bb-ws-status-pill.bb-ws-status-pill--compact { min-height:20px; height:20px; padding:0 8px; font-size:11px; }
|
|
1324
|
+
.bb-ws-tabs--header .bb-ws-tab-count.is-zero { background:none; color:var(--bb-color-muted); font-weight:400; }
|
|
1325
|
+
.bb-ws-progress-bar { display:block; width:100%; height:6px; overflow:hidden; border-radius:3px; background:var(--bb-color-canvas); }
|
|
1326
|
+
.bb-ws-progress-segment.is-done { fill:var(--bb-color-action); }
|
|
1327
|
+
.bb-ws-progress-segment.is-remaining { fill:var(--bb-color-mint); opacity:.55; }
|
|
1328
|
+
.bb-ws-progress-segment.is-review { fill:var(--bb-color-review); }
|
|
1329
|
+
.bb-ws-empty-state { display:grid; justify-items:center; gap:14px; padding:0; color:var(--bb-color-slate); font-size:13.5px; text-align:center; }
|
|
1330
|
+
.bb-ws-empty-state > p { margin:0; }
|
|
1331
|
+
.bb-ws-empty-state-mark { display:grid; place-items:center; width:48px; height:48px; border-radius:var(--bb-radius-pill); background:var(--bb-color-accent-soft); color:var(--bb-color-mint); }
|
|
1332
|
+
.bb-ws-empty-state-mark .bb-ws-action-icon { width:22px; height:22px; stroke-width:2.2; }
|
|
1333
|
+
.bb-ws-empty-state-action { margin-top:4px; }
|
|
1334
|
+
.bb-ws-form-row.is-stacked { display:grid; grid-template-columns:minmax(0,1fr); align-items:start; min-height:0; gap:6px; padding:0; box-shadow:none; }
|
|
1335
|
+
.bb-ws-form-row.is-stacked:focus-within { box-shadow:none; }
|
|
1336
|
+
.bb-ws-form-row.is-stacked > :is(input,textarea) { box-sizing:border-box; width:100%; min-width:0; height:36px; margin:0; padding:0 12px; border:0; border-radius:7px; background:var(--bb-color-canvas); color:var(--bb-color-ink); font:400 13.5px/1.6 var(--bb-font-sans); outline:none; box-shadow:none; }
|
|
1337
|
+
.bb-ws-form-row.is-stacked > textarea { height:auto; min-height:84px; padding-block:8px; resize:vertical; }
|
|
1338
|
+
.bb-ws-form-row.is-stacked > :is(input,textarea):focus { border:0; outline:none; background:var(--bb-color-accent-soft); box-shadow:none; }
|
|
1339
|
+
.bb-ws-form-row.is-stacked > small { color:var(--bb-color-muted); font-size:11.5px; }
|
|
1340
|
+
|
|
1341
|
+
.bb-ws-checkbox { appearance:none; display:inline-grid; place-items:center; flex:none; box-sizing:border-box; width:16px; min-width:16px; height:16px; margin:0; padding:0; border:0; border-radius:4px; background:var(--bb-color-paper); box-shadow:inset 0 0 0 1.5px var(--bb-color-border); color:transparent; vertical-align:middle; cursor:pointer; }
|
|
1342
|
+
.bb-ws-checkbox:hover:not(:disabled) { box-shadow:inset 0 0 0 1.5px var(--bb-color-muted); }
|
|
1343
|
+
.bb-ws-checkbox:checked, .bb-ws-checkbox:indeterminate { background:var(--bb-color-action); box-shadow:none; color:var(--bb-color-action-text); }
|
|
1344
|
+
.bb-ws-checkbox:checked::before { content:''; width:4px; height:8px; border:solid currentColor; border-width:0 2px 2px 0; transform:translateY(-1px) rotate(45deg); }
|
|
1345
|
+
.bb-ws-checkbox:indeterminate::before { content:''; width:8px; height:2px; border-radius:1px; background:currentColor; }
|
|
1346
|
+
.bb-ws-checkbox:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1347
|
+
.bb-ws-checkbox:disabled { cursor:default; opacity:.5; }
|
|
1348
|
+
|
|
1349
|
+
.bb-ws-selection-bar { display:flex; align-items:center; gap:8px; box-sizing:border-box; width:max-content; max-width:calc(100vw - 32px); min-height:52px; padding:0 10px 0 8px; border-radius:14px; background:var(--bb-color-action); color:var(--bb-color-action-text); box-shadow:var(--bb-shadow-control-panel); white-space:nowrap; }
|
|
1350
|
+
.bb-ws-selection-bar-count { flex:none; margin-right:12px; font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }
|
|
1351
|
+
.bb-ws-selection-bar-dismiss { display:grid; place-items:center; flex:none; width:32px; min-width:32px; height:32px; min-height:32px; padding:0; border:0; border-radius:7px; background:transparent; color:inherit; font-size:20px; }
|
|
1352
|
+
.bb-ws-selection-bar-dismiss:not(:disabled):hover { border:0; background:color-mix(in srgb,var(--bb-color-action-text) 12%,transparent); color:inherit; }
|
|
1353
|
+
.bb-ws-selection-bar-actions { display:flex; align-items:center; gap:4px; min-width:0; }
|
|
1354
|
+
.bb-ws-selection-bar-actions > .bb-ws-button { flex:none; height:32px; min-height:32px; padding:0 12px; border:0; border-radius:7px; background:color-mix(in srgb,var(--bb-color-action-text) 12%,transparent); color:var(--bb-color-action-text); font-size:12.5px; font-weight:500; white-space:nowrap; }
|
|
1355
|
+
.bb-ws-selection-bar-actions > .bb-ws-button:not(:disabled):hover { border:0; background:color-mix(in srgb,var(--bb-color-action-text) 22%,transparent); color:var(--bb-color-action-text); }
|
|
1356
|
+
.bb-ws-selection-bar-actions > .bb-ws-button.is-primary { background:var(--bb-color-mint); color:var(--bb-color-action); font-weight:700; }
|
|
1357
|
+
.bb-ws-selection-bar-actions > .bb-ws-button.is-primary:not(:disabled):hover { background:color-mix(in srgb,var(--bb-color-mint) 86%,var(--bb-color-paper)); color:var(--bb-color-action); }
|
|
1358
|
+
.bb-ws-selection-bar .bb-ws-selection-bar-actions > .bb-ws-combobox .bb-ws-combobox-trigger { height:32px; min-height:32px; padding:0 12px; border:0; border-radius:7px; background:color-mix(in srgb,var(--bb-color-action-text) 12%,transparent); box-shadow:none; color:var(--bb-color-action-text); font-size:12.5px; font-weight:500; }
|
|
1359
|
+
.bb-ws-selection-bar .bb-ws-selection-bar-actions > .bb-ws-combobox .bb-ws-combobox-trigger:is(:hover,[aria-expanded="true"]) { border:0; background:color-mix(in srgb,var(--bb-color-action-text) 22%,transparent); box-shadow:none; color:var(--bb-color-action-text); }
|
|
1360
|
+
.bb-ws-selection-bar .bb-ws-selection-bar-actions > .bb-ws-combobox .bb-ws-combobox-trigger[data-empty="true"] .bb-ws-combobox-value { color:inherit; }
|
|
1361
|
+
.bb-ws-selection-bar .bb-ws-selection-bar-actions > .bb-ws-combobox .bb-ws-combobox-chevron::after { color:var(--bb-color-action-text); }
|
|
1362
|
+
.bb-ws-selection-bar :focus-visible { outline:2px solid var(--bb-color-mint); outline-offset:2px; }
|
|
1363
|
+
|
|
1364
|
+
.bb-ws-inline-notice { display:flex; align-items:center; gap:10px; box-sizing:border-box; min-height:40px; margin:0 0 12px; padding:6px 8px 6px 14px; border-radius:8px; background:var(--bb-color-paper); color:var(--bb-color-ink); font-size:13px; }
|
|
1365
|
+
.bb-ws-inline-notice.is-danger { background:var(--bb-color-danger-soft); }
|
|
1366
|
+
.bb-ws-inline-notice-icon { display:grid; place-items:center; flex:none; width:16px; height:16px; color:var(--bb-color-success); }
|
|
1367
|
+
.bb-ws-inline-notice.is-danger .bb-ws-inline-notice-icon { color:var(--bb-color-danger); }
|
|
1368
|
+
.bb-ws-inline-notice-icon .bb-ws-action-icon { width:16px; height:16px; stroke-width:2; }
|
|
1369
|
+
.bb-ws-inline-notice-text { flex:1; min-width:0; line-height:1.6; }
|
|
1370
|
+
.bb-ws-inline-notice-actions { display:inline-flex; align-items:center; flex:none; gap:4px; }
|
|
1371
|
+
.bb-ws-inline-notice-actions > .bb-ws-button { width:auto; height:28px; min-height:28px; padding:0 12px; border-radius:7px; font-size:12.5px; }
|
|
1372
|
+
.bb-ws-inline-notice-actions > .bb-ws-button.bb-ws-inline-notice-dismiss { display:grid; place-items:center; width:28px; min-width:28px; padding:0; border:0; background:transparent; color:var(--bb-color-muted); font-size:0; }
|
|
1373
|
+
.bb-ws-inline-notice-actions > .bb-ws-button.bb-ws-inline-notice-dismiss:hover { border:0; background:var(--bb-color-canvas); color:var(--bb-color-ink); }
|
|
1374
|
+
.bb-ws-inline-notice-dismiss .bb-ws-action-icon, .bb-ws-selection-bar-dismiss .bb-ws-action-icon { width:14px; height:14px; stroke-width:2.2; }
|
|
1375
|
+
|
|
1376
|
+
.bb-ws-card-row--soft-selected.is-selected { background:color-mix(in srgb,var(--bb-color-accent-soft) 55%,var(--bb-color-paper)); box-shadow:none; }
|
|
1377
|
+
.bb-ws-card-row--soft-selected.is-selected:hover { box-shadow:var(--bb-shadow-card-row-hover); }
|
|
1378
|
+
.bb-ws-card-row.bb-ws-card-row--compact-panel { grid-template-columns:minmax(0,1fr); min-height:0; margin-bottom:6px; padding:12px 14px 12px 19px; align-items:stretch; background:var(--bb-color-canvas); box-shadow:none; }
|
|
1379
|
+
.bb-ws-card-row.bb-ws-card-row--compact-panel:hover { box-shadow:none; }
|
|
1380
|
+
.bb-ws-card-row--skeleton { pointer-events:none; box-shadow:none; }
|
|
1381
|
+
.bb-ws-card-row--skeleton:hover { box-shadow:none; }
|
|
1382
|
+
.bb-ws-card-skeleton-line { display:block; width:var(--bb-card-skeleton-width,100%); height:var(--bb-card-skeleton-height,10px); border-radius:var(--bb-card-skeleton-radius,5px); background:linear-gradient(100deg,var(--bb-color-canvas) 30%,var(--bb-color-line-soft) 50%,var(--bb-color-canvas) 70%) 0 0 / 240% 100%; animation:bb-ws-card-skeleton-sweep 1.4s linear infinite; }
|
|
1383
|
+
@keyframes bb-ws-card-skeleton-sweep { to { background-position:100% 0; } }
|
|
1384
|
+
|
|
1385
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless .bb-ws-combobox-trigger { height:32px; min-height:32px; padding:0 10px; border:0; border-radius:7px; background:var(--bb-color-canvas); box-shadow:none; color:var(--bb-color-ink); font-weight:500; }
|
|
1386
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless .bb-ws-combobox-trigger:is(:hover,[aria-expanded="true"]) { border:0; background:var(--bb-color-canvas); box-shadow:none; color:var(--bb-color-ink); }
|
|
1387
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless .bb-ws-combobox-trigger:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1388
|
+
.bb-ws-combobox--compact.bb-ws-combobox--suggested .bb-ws-combobox-trigger,
|
|
1389
|
+
.bb-ws-combobox--compact.bb-ws-combobox--suggested .bb-ws-combobox-trigger:is(:hover,[aria-expanded="true"]) { border:0; background:var(--bb-color-accent-soft); box-shadow:none; color:var(--bb-color-action); font-weight:600; }
|
|
1390
|
+
.bb-ws-combobox-suggestion-mark { display:grid; place-items:center; flex:none; width:14px; height:14px; color:var(--bb-color-mint); }
|
|
1391
|
+
.bb-ws-combobox-suggestion-mark .bb-ws-action-icon { width:14px; height:14px; stroke-width:2; }
|
|
1392
|
+
.bb-ws-combobox--compact.bb-ws-combobox--control-panel .bb-ws-combobox-popup { box-sizing:border-box; gap:0; max-height:300px; overflow-y:auto; padding:6px 0; border:0; border-radius:14px; background:var(--bb-color-paper); box-shadow:var(--bb-shadow-control-panel); }
|
|
1393
|
+
.bb-ws-combobox-group { margin:0; padding:0; list-style:none; }
|
|
1394
|
+
.bb-ws-combobox-group-options { margin:0; padding:0; list-style:none; }
|
|
1395
|
+
.bb-ws-combobox-group-label { display:block; padding:10px 16px 4px; color:var(--bb-color-action); font-size:12px; font-weight:700; }
|
|
1396
|
+
.bb-ws-combobox-group + .bb-ws-combobox-group > .bb-ws-combobox-group-label { margin-top:6px; box-shadow:inset 0 1px 0 var(--bb-color-line-soft); }
|
|
1397
|
+
.bb-ws-selection-bar:not(.has-dismiss) .bb-ws-selection-bar-count { grid-column:1 / -1; }
|
|
1398
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation { width:min(var(--bb-dialog-compact-width,520px),calc(100vw - 32px)); padding:24px 24px 20px; border:0; border-radius:16px; background:var(--bb-color-paper); box-shadow:var(--bb-shadow-compact-dialog); }
|
|
1399
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-head { align-items:center; gap:0; margin:0 0 4px; padding:0; border:0; }
|
|
1400
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-head h2,
|
|
1401
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-body > h3:first-child,
|
|
1402
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > h3:first-child { margin:0; font-size:16px; font-weight:600; line-height:1.6; }
|
|
1403
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-body { padding:0; }
|
|
1404
|
+
.bb-ws-dialog--confirmation .bb-ws-actions > .bb-ws-button { box-sizing:border-box; min-width:88px; height:36px; min-height:36px; padding:0 16px; border-radius:7px; font-size:13px; font-weight:var(--bb-font-weight-medium); justify-content:center; }
|
|
1405
|
+
.bb-ws-dialog.bb-ws-dialog--confirmation::backdrop { background:var(--bb-color-dialog-overlay); }
|
|
1406
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless.bb-ws-combobox--suggested .bb-ws-combobox-trigger { font-weight:500; }
|
|
1407
|
+
.bb-ws-combobox-portal { display:contents; position:static; }
|
|
1408
|
+
.bb-ws-combobox-popup--viewport { position:fixed; z-index:45; top:0; left:0; right:auto; bottom:auto; max-width:calc(100vw - 16px); }
|
|
1409
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport { display:flex; flex-direction:column; min-height:0; overflow-y:hidden; }
|
|
1410
|
+
.bb-ws-combobox--compact.bb-ws-combobox--control-panel .bb-ws-combobox-popup--viewport { overflow-y:hidden; }
|
|
1411
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport > .bb-ws-combobox-list { flex:1 1 auto; min-height:0; max-height:100%; overflow-y:auto; }
|
|
1412
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport > .bb-ws-combobox-search,
|
|
1413
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport > .bb-ws-combobox-status { flex:none; }
|
|
1414
|
+
|
|
1415
|
+
@media(max-width:600px) {
|
|
1416
|
+
.bb-ws-selection-bar { display:grid; grid-template-columns:32px minmax(0,1fr); width:calc(100vw - 24px); max-width:calc(100vw - 24px); padding:8px; white-space:normal; }
|
|
1417
|
+
.bb-ws-selection-bar-count { margin:0; }
|
|
1418
|
+
.bb-ws-selection-bar-actions { grid-column:1 / -1; display:flex; flex-wrap:wrap; justify-content:flex-end; }
|
|
1419
|
+
}
|
|
1420
|
+
@media(prefers-reduced-motion:reduce) { .bb-ws-card-skeleton-line { animation:none; } }
|
|
1421
|
+
|
|
1422
|
+
/* Content alignment changes only desktop horizontal gutters; the header preset owns sizing. */
|
|
1423
|
+
@media (min-width: 761px) {
|
|
1424
|
+
.bb-ws-topbar.bb-ws-topbar--content-aligned { padding-inline: var(--bb-space-5); }
|
|
1425
|
+
.bb-ws-topbar.bb-ws-topbar--content-aligned.has-tabs > h1 { padding-inline-start: calc(var(--bb-space-6) - var(--bb-space-5)); }
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1289
1428
|
/* A narrow header keeps the title and tabs full width before its controls. */
|
|
1290
1429
|
@media (max-width: 760px) {
|
|
1291
1430
|
.bb-ws-topbar, .bb-ws-topbar.has-query { grid-template-columns: minmax(0, 1fr) auto; padding-inline: var(--bb-space-3); padding-inline-start: var(--bb-page-header-inline-start, var(--bb-space-3)); }
|
package/ui/workspace-kit.js
CHANGED
|
@@ -93,7 +93,7 @@ export function workspaceSearchControl(doc, { input, appearance } = {}) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** A shared title bar, with an optional search input owned by the caller. */
|
|
96
|
-
export function workspaceTopbar(doc, { title = '', query, tabs, tools, wrap = false } = {}) {
|
|
96
|
+
export function workspaceTopbar(doc, { title = '', query, tabs, tools, wrap = false, alignment } = {}) {
|
|
97
97
|
const header = el(doc, 'header', { className: `bb-ws-topbar${wrap ? ' bb-ws-topbar--wrap' : ''}` });
|
|
98
98
|
header.append(el(doc, 'h1', { text: title }));
|
|
99
99
|
let search;
|
|
@@ -123,6 +123,11 @@ export function workspaceTopbar(doc, { title = '', query, tabs, tools, wrap = fa
|
|
|
123
123
|
if (input) { search = workspaceSearchControl(doc, { input }); header.append(search); if (toolsSlot) header.append(toolsSlot); }
|
|
124
124
|
toggleWorkspaceClass(header, 'has-query', Boolean(input));
|
|
125
125
|
};
|
|
126
|
+
header.setAlignment = value => {
|
|
127
|
+
toggleWorkspaceClass(header, 'bb-ws-topbar--content-aligned', value === 'content');
|
|
128
|
+
return header;
|
|
129
|
+
};
|
|
130
|
+
header.setAlignment(alignment);
|
|
126
131
|
header.setTabs(tabs); header.setQuery(query); header.setTools(tools);
|
|
127
132
|
return header;
|
|
128
133
|
}
|
|
@@ -196,6 +201,33 @@ export function workspaceNotice(doc, { label, text, tone = 'info', role } = {})
|
|
|
196
201
|
return notice;
|
|
197
202
|
}
|
|
198
203
|
|
|
204
|
+
/** One-line status/alert surface with optional icon, action and dismissal. */
|
|
205
|
+
export function workspaceInlineNotice(doc, { text, tone = 'success', icon, action, onDismiss, role } = {}) {
|
|
206
|
+
const appearance = tone === 'danger' ? 'danger' : 'success';
|
|
207
|
+
const notice = el(doc, 'div', { className: `bb-ws-inline-notice is-${appearance}`, attrs: {
|
|
208
|
+
role: role || (appearance === 'danger' ? 'alert' : 'status'),
|
|
209
|
+
'aria-live': appearance === 'danger' ? 'assertive' : 'polite',
|
|
210
|
+
'aria-atomic': 'true',
|
|
211
|
+
} });
|
|
212
|
+
if (icon) {
|
|
213
|
+
const mark = el(doc, 'span', { className: 'bb-ws-inline-notice-icon', attrs: { 'aria-hidden': 'true' } });
|
|
214
|
+
appendContent(mark, doc, icon); notice.append(mark);
|
|
215
|
+
}
|
|
216
|
+
const message = el(doc, 'span', { className: 'bb-ws-inline-notice-text' });
|
|
217
|
+
appendContent(message, doc, text); notice.append(message);
|
|
218
|
+
if (action || onDismiss) {
|
|
219
|
+
const actions = el(doc, 'span', { className: 'bb-ws-inline-notice-actions' });
|
|
220
|
+
if (action) actions.append(typeof action.tagName === 'string' ? action : workspaceButton(doc, action));
|
|
221
|
+
if (onDismiss) {
|
|
222
|
+
const dismiss = workspaceButton(doc, { variant: 'quiet', attrs: { 'aria-label': 'お知らせを閉じる' }, onClick: onDismiss });
|
|
223
|
+
dismiss.classList?.add('bb-ws-inline-notice-dismiss'); actions.append(dismiss);
|
|
224
|
+
dismiss.append(workspaceActionIcon(doc, 'close'));
|
|
225
|
+
}
|
|
226
|
+
notice.append(actions);
|
|
227
|
+
}
|
|
228
|
+
return notice;
|
|
229
|
+
}
|
|
230
|
+
|
|
199
231
|
/**
|
|
200
232
|
* The notice a host passes to a part in place of (or in addition to) the
|
|
201
233
|
* part's own: `{ label, text }`, where `text` is a string or an element. Null
|
|
@@ -215,9 +247,16 @@ export function workspaceHostActions(actions) {
|
|
|
215
247
|
.map(({ text, variant, onClick, disabled }) => ({ text, variant, onClick, disabled: disabled === true }));
|
|
216
248
|
}
|
|
217
249
|
|
|
218
|
-
export function workspaceButton(doc, { text, variant = 'default', onClick, disabled = false, attrs = {} } = {}) {
|
|
250
|
+
export function workspaceButton(doc, { text, variant = 'default', size, onClick, disabled = false, attrs = {} } = {}) {
|
|
251
|
+
const classes = ['bb-ws-button'];
|
|
252
|
+
if (variant === 'primary') classes.push('is-primary');
|
|
253
|
+
else if (variant === 'danger') classes.push('is-danger');
|
|
254
|
+
else if (variant === 'accent') classes.push('is-accent');
|
|
255
|
+
else if (variant === 'quiet') classes.push('is-quiet');
|
|
256
|
+
else if (variant === 'icon') classes.push('is-icon');
|
|
257
|
+
if (size === 'compact') classes.push('bb-ws-button--compact');
|
|
219
258
|
const button = el(doc, 'button', {
|
|
220
|
-
className:
|
|
259
|
+
className: classes.join(' '),
|
|
221
260
|
text,
|
|
222
261
|
attrs: { type: 'button', disabled, ...attrs },
|
|
223
262
|
});
|
|
@@ -233,6 +272,87 @@ export function workspaceActions(doc, buttons = []) {
|
|
|
233
272
|
return actions;
|
|
234
273
|
}
|
|
235
274
|
|
|
275
|
+
/** A business-neutral status label. The host supplies its text and meaning. */
|
|
276
|
+
export function workspaceStatusPill(doc, { label, tone = 'neutral', width, appearance, attrs = {} } = {}) {
|
|
277
|
+
const tones = new Set(['neutral', 'success', 'warning', 'danger']);
|
|
278
|
+
const pill = el(doc, 'span', { className: `bb-ws-status-pill is-${tones.has(tone) ? tone : 'neutral'}${appearance === 'compact' ? ' bb-ws-status-pill--compact' : ''}`, text: label, attrs });
|
|
279
|
+
if (Number.isFinite(width) && width > 0) pill.style?.setProperty('--bb-status-pill-width', `${width}px`);
|
|
280
|
+
return pill;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A segmented visual proportion. Hosts supply confirmed quantities and meaning. */
|
|
284
|
+
export function workspaceProgressBar(doc, { segments = [], label } = {}) {
|
|
285
|
+
const tones = new Set(['done', 'remaining', 'review']);
|
|
286
|
+
if (!Array.isArray(segments) || !segments.length || segments.some(segment =>
|
|
287
|
+
!segment || !Number.isFinite(segment.value) || segment.value < 0 || !tones.has(segment.tone))) {
|
|
288
|
+
throw new TypeError('workspace_progress_segments_required');
|
|
289
|
+
}
|
|
290
|
+
const total = segments.reduce((sum, segment) => sum + segment.value, 0);
|
|
291
|
+
if (!Number.isFinite(total) || total <= 0) throw new RangeError('workspace_progress_total_must_be_positive');
|
|
292
|
+
const svgElement = (name, attrs) => {
|
|
293
|
+
const node = typeof doc.createElementNS === 'function'
|
|
294
|
+
? doc.createElementNS('http://www.w3.org/2000/svg', name) : doc.createElement(name);
|
|
295
|
+
for (const [key, value] of Object.entries(attrs)) node.setAttribute(key, String(value));
|
|
296
|
+
return node;
|
|
297
|
+
};
|
|
298
|
+
const root = svgElement('svg', { class: 'bb-ws-progress-bar', viewBox: '0 0 100 6', preserveAspectRatio: 'none',
|
|
299
|
+
...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': 'true' }) });
|
|
300
|
+
let offset = 0;
|
|
301
|
+
// Review is always the final portion; the caller's array is never mutated.
|
|
302
|
+
const ordered = [...segments.filter(segment => segment.tone !== 'review'), ...segments.filter(segment => segment.tone === 'review')];
|
|
303
|
+
for (const segment of ordered) {
|
|
304
|
+
if (segment.value === 0) continue;
|
|
305
|
+
const width = segment.value / total * 100;
|
|
306
|
+
root.append(svgElement('rect', { class: `bb-ws-progress-segment is-${segment.tone}`, x: offset, y: 0, width, height: 6 }));
|
|
307
|
+
offset += width;
|
|
308
|
+
}
|
|
309
|
+
return root;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** An empty list invitation. Copy and action remain owned by the host. */
|
|
313
|
+
export function workspaceEmptyState(doc, { text, icon = 'folder', action } = {}) {
|
|
314
|
+
const root = el(doc, 'div', { className: 'bb-ws-empty-state' });
|
|
315
|
+
const mark = el(doc, 'span', { className: 'bb-ws-empty-state-mark', attrs: { 'aria-hidden': 'true' } });
|
|
316
|
+
mark.append(workspaceActionIcon(doc, icon));
|
|
317
|
+
root.append(mark, el(doc, 'p', { text }));
|
|
318
|
+
if (action) {
|
|
319
|
+
const actions = el(doc, 'div', { className: 'bb-ws-empty-state-action' });
|
|
320
|
+
appendContent(actions, doc, action);
|
|
321
|
+
root.append(actions);
|
|
322
|
+
}
|
|
323
|
+
return root;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Native checkbox with the shared compact mark and caller-owned selection. */
|
|
327
|
+
export function workspaceCheckbox(doc, { label, checked = false, indeterminate = false, disabled = false, onChange, attrs = {} } = {}) {
|
|
328
|
+
const checkbox = el(doc, 'input', { className: 'bb-ws-checkbox', attrs: {
|
|
329
|
+
...attrs, type: 'checkbox', 'aria-label': attrs['aria-label'] ?? label, checked: Boolean(checked), disabled: Boolean(disabled),
|
|
330
|
+
} });
|
|
331
|
+
checkbox.checked = Boolean(checked);
|
|
332
|
+
checkbox.indeterminate = Boolean(indeterminate);
|
|
333
|
+
checkbox.addEventListener('change', () => onChange?.(checkbox.checked, checkbox.indeterminate, checkbox));
|
|
334
|
+
return checkbox;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Shared selection bar; the host owns its placement and action callbacks. */
|
|
338
|
+
export function workspaceSelectionBar(doc, { count = 0, actions = [], onDismiss, label = '選択中の項目', announce = false } = {}) {
|
|
339
|
+
const root = el(doc, 'div', { className: `bb-ws-selection-bar${onDismiss ? ' has-dismiss' : ''}`, attrs: { role: 'region', 'aria-label': label } });
|
|
340
|
+
if (onDismiss) {
|
|
341
|
+
const dismiss = workspaceButton(doc, { variant: 'quiet', attrs: { 'aria-label': '選択を解除' }, onClick: onDismiss });
|
|
342
|
+
dismiss.classList?.add('bb-ws-selection-bar-dismiss');
|
|
343
|
+
dismiss.append(workspaceActionIcon(doc, 'close'));
|
|
344
|
+
root.append(dismiss);
|
|
345
|
+
}
|
|
346
|
+
const countLabel = typeof count === 'number' && Number.isFinite(count) ? `${count}件を選択中` : String(count ?? '');
|
|
347
|
+
root.append(el(doc, 'span', { className: 'bb-ws-selection-bar-count', text: countLabel, attrs: { 'aria-live': announce ? 'polite' : undefined } }));
|
|
348
|
+
const actionSlot = el(doc, 'div', { className: 'bb-ws-selection-bar-actions' });
|
|
349
|
+
for (const action of actions) {
|
|
350
|
+
if (action) actionSlot.append(typeof action.tagName === 'string' ? action : workspaceButton(doc, action));
|
|
351
|
+
}
|
|
352
|
+
root.append(actionSlot);
|
|
353
|
+
return root;
|
|
354
|
+
}
|
|
355
|
+
|
|
236
356
|
/** Summary metrics in one ruled row. `value` null means 未確認, never zero. */
|
|
237
357
|
export function workspaceMetrics(doc, items = [], { ariaLabel = '集計' } = {}) {
|
|
238
358
|
const summary = el(doc, 'section', { className: `bb-ws-summary is-${Math.min(Math.max(items.length, 1), 6)}`, attrs: { 'aria-label': ariaLabel } });
|
|
@@ -447,9 +567,9 @@ export function workspaceCloseDrawer(dialog, finish) {
|
|
|
447
567
|
}
|
|
448
568
|
|
|
449
569
|
/** Native modal, optionally a right drawer. close() animates; dispose() tears down immediately. */
|
|
450
|
-
export function workspaceDialog(doc, { title, content, opener, presentation = 'center', onClose, appearance, headerTools } = {}) {
|
|
570
|
+
export function workspaceDialog(doc, { title, content, opener, presentation = 'center', onClose, appearance, headerTools, compactWidth } = {}) {
|
|
451
571
|
const dialog = el(doc, 'dialog', { className: 'bb-ws-dialog' });
|
|
452
|
-
|
|
572
|
+
workspaceDialogAppearance(dialog, { appearance, compactWidth });
|
|
453
573
|
if (presentation === 'drawer') workspaceApplyDrawer(dialog);
|
|
454
574
|
const headingId = `bb-ws-dialog-${nextWorkspaceSequence()}`;
|
|
455
575
|
dialog.setAttribute('aria-labelledby', headingId);
|
|
@@ -500,6 +620,19 @@ export function workspaceDialog(doc, { title, content, opener, presentation = 'c
|
|
|
500
620
|
return dialog;
|
|
501
621
|
}
|
|
502
622
|
|
|
623
|
+
/** Apply shared dialog appearance to a host-owned native dialog without owning its lifecycle. */
|
|
624
|
+
export function workspaceDialogAppearance(dialog, { appearance, compactWidth } = {}) {
|
|
625
|
+
if (!dialog || typeof dialog.setAttribute !== 'function') throw new TypeError('dialog_element_required');
|
|
626
|
+
const isConfirmation = appearance === 'confirmation';
|
|
627
|
+
const isCompact = appearance === 'compact' || isConfirmation;
|
|
628
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog', true);
|
|
629
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog--compact', isCompact);
|
|
630
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog--confirmation', isConfirmation);
|
|
631
|
+
if (isCompact && Number.isFinite(compactWidth) && compactWidth > 0) dialog.style?.setProperty('--bb-dialog-compact-width', `${compactWidth}px`);
|
|
632
|
+
else dialog.style?.removeProperty?.('--bb-dialog-compact-width');
|
|
633
|
+
return dialog;
|
|
634
|
+
}
|
|
635
|
+
|
|
503
636
|
/** Applied condition with an explicit, individually removable value. */
|
|
504
637
|
export function workspaceFilterChip(doc, { label, onRemove, attrs = {} } = {}) {
|
|
505
638
|
const chip = workspaceButton(doc, { text: `${label} ×`, attrs: { 'aria-label': `${label}を解除`, ...attrs }, onClick: onRemove });
|
|
@@ -509,6 +642,52 @@ export function workspaceFilterChip(doc, { label, onRemove, attrs = {} } = {}) {
|
|
|
509
642
|
|
|
510
643
|
const anchoredPopoverBindings = new WeakMap();
|
|
511
644
|
|
|
645
|
+
function workspacePositionAnchoredElement(element, positionAnchor, {
|
|
646
|
+
align = 'start', placement = 'bottom', gap = 4, inset = 8, view, doc, flip = false, clampHeight = false, clampOverflow = 'auto', preciseWidth = false, bounds,
|
|
647
|
+
} = {}) {
|
|
648
|
+
const at = positionAnchor.getBoundingClientRect();
|
|
649
|
+
const box = element.getBoundingClientRect();
|
|
650
|
+
const viewportWidth = view?.innerWidth || doc?.documentElement?.clientWidth || 1024;
|
|
651
|
+
const viewportHeight = view?.innerHeight || doc?.documentElement?.clientHeight || 768;
|
|
652
|
+
const boundary = bounds?.getBoundingClientRect?.() ?? bounds;
|
|
653
|
+
const leftInset = Math.max(inset, boundary?.left + inset || inset);
|
|
654
|
+
const topInset = Math.max(inset, boundary?.top + inset || inset);
|
|
655
|
+
const rightEdge = Math.min(viewportWidth - inset, boundary?.right - inset || viewportWidth - inset);
|
|
656
|
+
const bottomEdge = Math.min(viewportHeight - inset, boundary?.bottom - inset || viewportHeight - inset);
|
|
657
|
+
const computedWidth = preciseWidth ? Number.parseFloat(view?.getComputedStyle?.(element)?.width) : NaN;
|
|
658
|
+
const panelWidth = (Number.isFinite(computedWidth) && computedWidth > 0 ? computedWidth : 0) || element.offsetWidth || box.width || box.right - box.left;
|
|
659
|
+
let panelHeight = element.offsetHeight || box.height || box.bottom - box.top;
|
|
660
|
+
const anchorLeft = at.left ?? at.x ?? 0;
|
|
661
|
+
const anchorRight = at.right ?? anchorLeft + (at.width ?? 0);
|
|
662
|
+
const anchorTop = at.top ?? at.y ?? 0;
|
|
663
|
+
const anchorBottom = at.bottom ?? anchorTop + (at.height ?? 0);
|
|
664
|
+
const anchorWidth = at.width ?? anchorRight - anchorLeft;
|
|
665
|
+
const x = align === 'end' ? anchorRight - panelWidth : align === 'center' ? anchorLeft + (anchorWidth - panelWidth) / 2 : anchorLeft;
|
|
666
|
+
let y;
|
|
667
|
+
let side = placement;
|
|
668
|
+
if (flip) {
|
|
669
|
+
const availableBelow = Math.max(0, bottomEdge - anchorBottom - gap);
|
|
670
|
+
const availableAbove = Math.max(0, anchorTop - topInset - gap);
|
|
671
|
+
side = placement === 'top' ? 'top' : 'bottom';
|
|
672
|
+
if (side !== 'top' && panelHeight > availableBelow && availableAbove > availableBelow) side = 'top';
|
|
673
|
+
const available = side === 'top' ? availableAbove : availableBelow;
|
|
674
|
+
if (clampHeight && panelHeight > available) {
|
|
675
|
+
element.style?.setProperty('max-height', `${available}px`);
|
|
676
|
+
element.style?.setProperty('overflow-y', clampOverflow);
|
|
677
|
+
panelHeight = element.offsetHeight || Math.min(panelHeight, available);
|
|
678
|
+
} else if (clampHeight) {
|
|
679
|
+
element.style?.removeProperty?.('max-height');
|
|
680
|
+
element.style?.removeProperty?.('overflow-y');
|
|
681
|
+
}
|
|
682
|
+
y = side === 'top' ? anchorTop - gap - panelHeight : anchorBottom + gap;
|
|
683
|
+
} else y = placement === 'overlap' ? anchorTop - 10 : anchorBottom + gap;
|
|
684
|
+
return {
|
|
685
|
+
left: Math.max(leftInset, Math.min(x, rightEdge - panelWidth)),
|
|
686
|
+
top: Math.max(topInset, Math.min(y, bottomEdge - panelHeight)),
|
|
687
|
+
width: panelWidth, height: panelHeight, side, viewportWidth, viewportHeight,
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
|
|
512
691
|
/** Non-modal anchored surface. Content and visibility have independent lifecycles. */
|
|
513
692
|
export function workspaceAnchoredPopover(doc, {
|
|
514
693
|
anchor, positionAnchor = anchor, content, label, surface = 'default', width = 276, placement = 'bottom', align = 'start', padding, onClose,
|
|
@@ -540,17 +719,9 @@ export function workspaceAnchoredPopover(doc, {
|
|
|
540
719
|
const reposition = () => {
|
|
541
720
|
if (!opened || destroyed) return;
|
|
542
721
|
if (anchor.isConnected === false || positionAnchor.isConnected === false) { close({ restoreFocus: false }); return; }
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const viewportHeight = view?.innerHeight || doc.documentElement?.clientHeight || 768;
|
|
547
|
-
// offset dimensions are layout sizes, unaffected by the entrance transform.
|
|
548
|
-
const panelWidth = element.offsetWidth || box.width || box.right - box.left;
|
|
549
|
-
const panelHeight = element.offsetHeight || box.height || box.bottom - box.top;
|
|
550
|
-
const x = align === 'end' ? at.right - panelWidth : align === 'center' ? at.left + ((at.width ?? at.right - at.left) - panelWidth) / 2 : at.left;
|
|
551
|
-
const y = placement === 'overlap' ? at.top - 10 : at.bottom + 4;
|
|
552
|
-
element.style?.setProperty('left', `${Math.max(8, Math.min(x, viewportWidth - panelWidth - 8))}px`);
|
|
553
|
-
element.style?.setProperty('top', `${Math.max(8, Math.min(y, viewportHeight - panelHeight - 8))}px`);
|
|
722
|
+
const point = workspacePositionAnchoredElement(element, positionAnchor, { align, placement, gap: 4, inset: 8, view, doc });
|
|
723
|
+
element.style?.setProperty('left', `${point.left}px`);
|
|
724
|
+
element.style?.setProperty('top', `${point.top}px`);
|
|
554
725
|
};
|
|
555
726
|
const removeListeners = () => {
|
|
556
727
|
doc.removeEventListener?.('pointerdown', outside); doc.removeEventListener?.('keydown', escape);
|
|
@@ -797,10 +968,12 @@ export function workspaceErrorCard(doc, { title, message, tone = 'danger', onRet
|
|
|
797
968
|
return card;
|
|
798
969
|
}
|
|
799
970
|
|
|
800
|
-
export function workspaceDisclosure(doc, { title, help, content, open = false, onToggle } = {}) {
|
|
801
|
-
const
|
|
971
|
+
export function workspaceDisclosure(doc, { title, help, content, open = false, onToggle, appearance, headingLevel = 2 } = {}) {
|
|
972
|
+
const compact = appearance === 'compact';
|
|
973
|
+
const level = [2, 3, 4, 5, 6].includes(headingLevel) ? headingLevel : 2;
|
|
974
|
+
const details = el(doc, 'details', { className: `bb-ws-disclosure${compact ? ' bb-ws-disclosure--compact' : ''}` }); details.open = open;
|
|
802
975
|
const summary = el(doc, 'summary');
|
|
803
|
-
summary.append(el(doc,
|
|
976
|
+
summary.append(el(doc, `h${level}`, { text: title }));
|
|
804
977
|
if (help) summary.append(workspaceHelp(doc, { label: title, text: help }));
|
|
805
978
|
details.append(summary, content);
|
|
806
979
|
if (onToggle) details.addEventListener('toggle', () => onToggle(details.open));
|
|
@@ -822,14 +995,20 @@ function comboboxText(value) {
|
|
|
822
995
|
*/
|
|
823
996
|
export function workspaceCombobox(doc, {
|
|
824
997
|
label, options = [], value = '', placeholder = '選択してください', searchLabel, searchPlaceholder = '絞り込む',
|
|
825
|
-
emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange,
|
|
826
|
-
multiple = false, values = [], selectionLabel = '', renderIcon, showCount = true, showHints = true, align = 'start', appearance, boxed = false, matchTriggerWidth = false, triggerHeight, popupWidth, active = false,
|
|
998
|
+
emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange, onSelect,
|
|
999
|
+
multiple = false, values = [], selectionLabel = '', renderIcon, renderValue, showCount = true, showHints = true, align = 'start', appearance, boxed = false, borderless = false, popupAppearance, suggested = false, matchTriggerWidth = false, triggerHeight, popupWidth, active = false,
|
|
1000
|
+
popupPlacement,
|
|
827
1001
|
} = {}) {
|
|
828
1002
|
const sequence = nextWorkspaceSequence();
|
|
829
1003
|
const listId = `bb-ws-combobox-${sequence}-list`;
|
|
830
1004
|
const root = el(doc, 'span', { className: ['bb-ws-combobox', className].filter(Boolean).join(' ') });
|
|
1005
|
+
const useViewportPopup = popupPlacement === 'viewport';
|
|
1006
|
+
if (useViewportPopup) toggleWorkspaceClass(root, 'bb-ws-combobox--viewport-popup', true);
|
|
831
1007
|
if (appearance === 'compact') toggleWorkspaceClass(root, 'bb-ws-combobox--compact', true);
|
|
832
1008
|
if (boxed) { toggleWorkspaceClass(root, 'is-boxed', true); toggleWorkspaceClass(root, 'bb-ws-combobox--stable-box', true); }
|
|
1009
|
+
if (borderless) toggleWorkspaceClass(root, 'bb-ws-combobox--borderless', true);
|
|
1010
|
+
if (popupAppearance === 'control-panel') toggleWorkspaceClass(root, 'bb-ws-combobox--control-panel', true);
|
|
1011
|
+
if (suggested) toggleWorkspaceClass(root, 'bb-ws-combobox--suggested', true);
|
|
833
1012
|
if (active) toggleWorkspaceClass(root, 'is-active', true);
|
|
834
1013
|
if (matchTriggerWidth) toggleWorkspaceClass(root, 'bb-ws-combobox--match-width', true);
|
|
835
1014
|
if (triggerHeight === 32) toggleWorkspaceClass(root, 'bb-ws-combobox--tall', true);
|
|
@@ -841,7 +1020,9 @@ export function workspaceCombobox(doc, {
|
|
|
841
1020
|
if (align === 'end') root.classList?.add('bb-ws-combobox-align-end');
|
|
842
1021
|
const trigger = el(doc, 'button', { className: 'bb-ws-combobox-trigger', attrs: { type: 'button', 'aria-haspopup': 'listbox', 'aria-expanded': 'false', 'aria-controls': listId } });
|
|
843
1022
|
const triggerText = el(doc, 'span', { className: 'bb-ws-combobox-value' });
|
|
844
|
-
|
|
1023
|
+
const chevron = workspaceDropdownChevron(doc);
|
|
1024
|
+
let suggestionMark;
|
|
1025
|
+
trigger.append(triggerText, chevron);
|
|
845
1026
|
const popup = el(doc, 'div', { className: 'bb-ws-combobox-popup' });
|
|
846
1027
|
popup.hidden = true;
|
|
847
1028
|
const search = el(doc, 'input', { className: 'bb-ws-combobox-search', attrs: {
|
|
@@ -854,19 +1035,136 @@ export function workspaceCombobox(doc, {
|
|
|
854
1035
|
popup.append(search, list, status);
|
|
855
1036
|
root.append(trigger, popup);
|
|
856
1037
|
|
|
857
|
-
const state = { selectionLabel: String(selectionLabel ?? ''), options: [], values: [...new Set((Array.isArray(values) ? values : []).map(String))].filter(Boolean), value: String(value ?? ''), query: '', active: -1, shown: [], open: false, disabled: false };
|
|
1038
|
+
const state = { selectionLabel: String(selectionLabel ?? ''), options: [], values: [...new Set((Array.isArray(values) ? values : []).map(String))].filter(Boolean), value: String(value ?? ''), query: '', active: -1, shown: [], open: false, disabled: false, suggested: Boolean(suggested) };
|
|
1039
|
+
let optionNodes = [];
|
|
1040
|
+
let portal;
|
|
1041
|
+
let modalHost;
|
|
1042
|
+
let portalMotionPending = false;
|
|
1043
|
+
let pendingPortalFocus = false;
|
|
1044
|
+
let portalMotionTimer;
|
|
1045
|
+
let destroyed = false;
|
|
858
1046
|
let exitTimer;
|
|
859
1047
|
const cancelExit = () => { clearTimeout(exitTimer); exitTimer = undefined; popup.removeEventListener?.('animationend', exitEnded); toggleWorkspaceClass(popup, 'is-closing', false); };
|
|
860
|
-
const finishExit = () => {
|
|
1048
|
+
const finishExit = () => {
|
|
1049
|
+
cancelExit();
|
|
1050
|
+
if (!state.open) { popup.hidden = true; if (useViewportPopup) restoreViewportPopup(); }
|
|
1051
|
+
};
|
|
861
1052
|
const exitEnded = event => { if (event.target === popup && event.animationName === 'bb-ws-compact-dropdown-out') finishExit(); };
|
|
862
1053
|
const usesSearch = () => searchable === true || (searchable === 'auto' && state.options.length > 8);
|
|
863
1054
|
const focusTarget = () => (usesSearch() ? search : list);
|
|
864
1055
|
const chosen = () => state.options.find(option => option.value === state.value);
|
|
865
1056
|
|
|
1057
|
+
function syncPortalClasses() {
|
|
1058
|
+
if (!portal) return;
|
|
1059
|
+
portal.className = `${root.className} bb-ws-combobox-portal`;
|
|
1060
|
+
if (Number.isFinite(popupWidth) && popupWidth > 0) portal.style?.setProperty('--bb-combobox-popup-width', `${popupWidth}px`);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function clearPortalMotionTimer() {
|
|
1064
|
+
clearTimeout(portalMotionTimer); portalMotionTimer = undefined;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function dialogHasRunningTransform() {
|
|
1068
|
+
if (!modalHost) return false;
|
|
1069
|
+
const active = modalHost.getAnimations?.().some(animation => animation.effect?.target === modalHost && animation.playState === 'running') === true;
|
|
1070
|
+
const transform = doc.defaultView?.getComputedStyle?.(modalHost)?.transform;
|
|
1071
|
+
return active && transform !== 'none';
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function repositionViewportPopup() {
|
|
1075
|
+
if (!useViewportPopup || !state.open || !portal || portalMotionPending) return;
|
|
1076
|
+
if (root.isConnected === false || trigger.isConnected === false || (modalHost && !modalHost.open)) { close(false, true); return; }
|
|
1077
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
1078
|
+
const viewportWidth = doc.defaultView?.innerWidth || doc.documentElement?.clientWidth || 1024;
|
|
1079
|
+
const dialogRect = modalHost?.getBoundingClientRect?.();
|
|
1080
|
+
const listScrollTop = list.scrollTop;
|
|
1081
|
+
const maxWidth = Math.max(0, Math.min(viewportWidth - 16, dialogRect ? dialogRect.width - 16 : viewportWidth - 16));
|
|
1082
|
+
popup.style?.setProperty('max-width', `${maxWidth}px`);
|
|
1083
|
+
if (matchTriggerWidth) popup.style?.setProperty('width', `${Math.max(0, Math.min(triggerRect.width || 0, maxWidth))}px`);
|
|
1084
|
+
else popup.style?.removeProperty?.('width');
|
|
1085
|
+
popup.style?.removeProperty?.('max-height');
|
|
1086
|
+
popup.style?.removeProperty?.('overflow-y');
|
|
1087
|
+
const point = workspacePositionAnchoredElement(popup, trigger, {
|
|
1088
|
+
align, placement: 'bottom', gap: 6, inset: 8, view: doc.defaultView, doc, flip: true, clampHeight: true, clampOverflow: 'hidden', preciseWidth: true, bounds: dialogRect,
|
|
1089
|
+
});
|
|
1090
|
+
popup.style?.setProperty('left', `${point.left}px`);
|
|
1091
|
+
popup.style?.setProperty('top', `${point.top}px`);
|
|
1092
|
+
if (Number.isFinite(listScrollTop)) list.scrollTop = listScrollTop;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function finishPortalMotion() {
|
|
1096
|
+
if (!portalMotionPending || !state.open) return;
|
|
1097
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1098
|
+
if (dialogHasRunningTransform()) return;
|
|
1099
|
+
clearPortalMotionTimer(); portalMotionPending = false;
|
|
1100
|
+
repositionViewportPopup();
|
|
1101
|
+
popup.style?.removeProperty?.('visibility');
|
|
1102
|
+
if (pendingPortalFocus) { pendingPortalFocus = false; focusTarget().focus?.({ preventScroll: true }); }
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
function portalDialogAnimationStart(event) {
|
|
1106
|
+
if (event.target !== modalHost) return;
|
|
1107
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1108
|
+
if (doc.defaultView?.getComputedStyle?.(modalHost)?.transform !== 'none') {
|
|
1109
|
+
portalMotionPending = true; pendingPortalFocus = true;
|
|
1110
|
+
popup.style?.setProperty('visibility', 'hidden');
|
|
1111
|
+
clearPortalMotionTimer(); portalMotionTimer = setTimeout(finishPortalMotion, animationFallback(modalHost, 24, 240));
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
function portalDialogAnimationEnd(event) {
|
|
1116
|
+
if (event.target !== modalHost) return;
|
|
1117
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1118
|
+
finishPortalMotion();
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function mountViewportPopup() {
|
|
1122
|
+
if (!useViewportPopup) return;
|
|
1123
|
+
modalHost = root.closest?.('dialog[open]') || null;
|
|
1124
|
+
if (!portal) {
|
|
1125
|
+
portal = el(doc, 'span', { className: `${root.className} bb-ws-combobox-portal` });
|
|
1126
|
+
portal.style?.setProperty('display', 'contents');
|
|
1127
|
+
}
|
|
1128
|
+
syncPortalClasses();
|
|
1129
|
+
toggleWorkspaceClass(popup, 'bb-ws-combobox-popup--viewport', true);
|
|
1130
|
+
const portalParent = modalHost || doc.body;
|
|
1131
|
+
if (portal.parentNode !== portalParent) portalParent.append(portal);
|
|
1132
|
+
if (popup.parentNode !== portal) portal.append(popup);
|
|
1133
|
+
doc.addEventListener?.('scroll', repositionViewportPopup, true);
|
|
1134
|
+
doc.defaultView?.addEventListener?.('resize', repositionViewportPopup);
|
|
1135
|
+
doc.defaultView?.visualViewport?.addEventListener?.('resize', repositionViewportPopup);
|
|
1136
|
+
doc.defaultView?.visualViewport?.addEventListener?.('scroll', repositionViewportPopup);
|
|
1137
|
+
if (modalHost) {
|
|
1138
|
+
modalHost.addEventListener?.('close', closeForDialog);
|
|
1139
|
+
modalHost.addEventListener?.('cancel', closeForDialog);
|
|
1140
|
+
modalHost.addEventListener?.('animationstart', portalDialogAnimationStart);
|
|
1141
|
+
modalHost.addEventListener?.('animationend', portalDialogAnimationEnd);
|
|
1142
|
+
modalHost.addEventListener?.('transitionrun', portalDialogAnimationStart);
|
|
1143
|
+
modalHost.addEventListener?.('transitionstart', portalDialogAnimationStart);
|
|
1144
|
+
modalHost.addEventListener?.('transitionend', portalDialogAnimationEnd);
|
|
1145
|
+
}
|
|
1146
|
+
if (dialogHasRunningTransform()) {
|
|
1147
|
+
portalMotionPending = true; pendingPortalFocus = true;
|
|
1148
|
+
popup.style?.setProperty('visibility', 'hidden');
|
|
1149
|
+
portalMotionTimer = setTimeout(finishPortalMotion, animationFallback(modalHost, 24, 240));
|
|
1150
|
+
} else repositionViewportPopup();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function returnViewportPopupToRoot({ hide = true } = {}) {
|
|
1154
|
+
if (!useViewportPopup) return;
|
|
1155
|
+
if (hide) popup.hidden = true;
|
|
1156
|
+
toggleWorkspaceClass(popup, 'bb-ws-combobox-popup--viewport', false);
|
|
1157
|
+
for (const property of ['left', 'top', 'width', 'max-width', 'max-height', 'overflow-y', 'visibility']) popup.style?.removeProperty?.(property);
|
|
1158
|
+
if (portal) { root.append(popup); portal.remove(); portal = undefined; }
|
|
1159
|
+
modalHost = undefined; portalMotionPending = false; pendingPortalFocus = false; clearPortalMotionTimer();
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function restoreViewportPopup() { returnViewportPopupToRoot({ hide: true }); }
|
|
1163
|
+
|
|
866
1164
|
function setOptions(next) {
|
|
867
1165
|
state.options = (Array.isArray(next) ? next : []).map(option => ({
|
|
868
1166
|
...option, value: String(option?.value ?? ''), label: String(option?.label ?? option?.value ?? ''),
|
|
869
|
-
hint: option?.hint ? String(option.hint) : '', keywords: option?.keywords ? String(option.keywords) : '',
|
|
1167
|
+
hint: option?.hint ? String(option.hint) : '', keywords: option?.keywords ? String(option.keywords) : '', group: option?.group ? String(option.group) : '',
|
|
870
1168
|
}));
|
|
871
1169
|
}
|
|
872
1170
|
|
|
@@ -874,15 +1172,27 @@ export function workspaceCombobox(doc, {
|
|
|
874
1172
|
const option = multiple ? (state.values.length === 1 ? state.options.find(option => option.value === state.values[0]) : state.options.find(option => !option.value)) : chosen();
|
|
875
1173
|
const summary = multiple && state.values.length > 1 ? `${state.values.length}件選択中` : null;
|
|
876
1174
|
const text = state.selectionLabel || summary || (option ? option.label : multiple ? state.values.join('、') || placeholder : state.value || placeholder);
|
|
1175
|
+
if (state.suggested) {
|
|
1176
|
+
if (!suggestionMark) {
|
|
1177
|
+
suggestionMark = el(doc, 'span', { className: 'bb-ws-combobox-suggestion-mark', attrs: { 'aria-hidden': 'true' } });
|
|
1178
|
+
suggestionMark.append(workspaceActionIcon(doc, 'sparkles'));
|
|
1179
|
+
}
|
|
1180
|
+
trigger.insertBefore(suggestionMark, triggerText);
|
|
1181
|
+
} else suggestionMark?.remove();
|
|
877
1182
|
triggerText.textContent = text;
|
|
878
|
-
if (!state.selectionLabel && !summary && option && typeof
|
|
1183
|
+
if (!state.selectionLabel && !summary && option && typeof renderValue === 'function') {
|
|
1184
|
+
triggerText.textContent = '';
|
|
1185
|
+
appendContent(triggerText, doc, renderValue(option));
|
|
1186
|
+
} else if (!state.selectionLabel && !summary && option && typeof renderIcon === 'function') {
|
|
879
1187
|
const icon = renderIcon(option);
|
|
880
1188
|
if (icon) { triggerText.textContent = ''; triggerText.append(icon, el(doc, 'span', { className: 'bb-ws-combobox-text', text })); }
|
|
881
1189
|
}
|
|
882
1190
|
toggleWorkspaceClass(root, 'is-multi-selected', Boolean(summary));
|
|
883
|
-
|
|
1191
|
+
const accessibleText = !state.selectionLabel && !summary && option?.group ? `${option.group}・${option.label}` : text;
|
|
1192
|
+
trigger.setAttribute('aria-label', `${label ? `${label}: ` : ''}${accessibleText}`);
|
|
884
1193
|
trigger.setAttribute('data-empty', String(multiple ? !state.values.length : !option && !state.value));
|
|
885
1194
|
if (state.disabled) trigger.setAttribute('disabled', ''); else trigger.removeAttribute('disabled');
|
|
1195
|
+
syncPortalClasses();
|
|
886
1196
|
}
|
|
887
1197
|
|
|
888
1198
|
function activeDescendant(node) {
|
|
@@ -896,13 +1206,23 @@ export function workspaceCombobox(doc, {
|
|
|
896
1206
|
const scrollTop = list.scrollTop;
|
|
897
1207
|
const terms = comboboxText(state.query).split(/\s+/u).filter(Boolean);
|
|
898
1208
|
const matches = terms.length
|
|
899
|
-
? state.options.filter(option => { const text = comboboxText(`${option.label}\n${option.hint}\n${option.keywords}`); return terms.every(term => text.includes(term)); })
|
|
1209
|
+
? state.options.filter(option => { const text = comboboxText(`${option.label}\n${option.hint}\n${option.keywords}\n${option.group}`); return terms.every(term => text.includes(term)); })
|
|
900
1210
|
: state.options;
|
|
901
1211
|
const max = Math.max(1, Number(limit) || 100);
|
|
902
1212
|
state.shown = matches.slice(0, max);
|
|
903
1213
|
if (state.active >= state.shown.length) state.active = state.shown.length - 1;
|
|
904
|
-
list.replaceChildren();
|
|
1214
|
+
list.replaceChildren(); optionNodes = [];
|
|
1215
|
+
let groupName = '';
|
|
1216
|
+
let groupNode;
|
|
1217
|
+
let groupOptions;
|
|
905
1218
|
state.shown.forEach((option, index) => {
|
|
1219
|
+
if (option.group && option.group !== groupName) {
|
|
1220
|
+
groupName = option.group;
|
|
1221
|
+
groupNode = el(doc, 'li', { className: 'bb-ws-combobox-group', attrs: { role: 'group', 'aria-label': groupName } });
|
|
1222
|
+
groupOptions = el(doc, 'ul', { className: 'bb-ws-combobox-group-options', attrs: { role: 'presentation' } });
|
|
1223
|
+
groupNode.append(el(doc, 'span', { className: 'bb-ws-combobox-group-label', text: groupName, attrs: { 'aria-hidden': 'true' } }), groupOptions);
|
|
1224
|
+
list.append(groupNode);
|
|
1225
|
+
} else if (!option.group) { groupName = ''; groupNode = undefined; groupOptions = undefined; }
|
|
906
1226
|
const selected = multiple ? option.value ? state.values.includes(option.value) : state.values.length === 0 : option.value === state.value;
|
|
907
1227
|
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 } });
|
|
908
1228
|
const optionLabel = el(doc, 'span', { className: 'bb-ws-combobox-option-label', text: option.label });
|
|
@@ -915,9 +1235,9 @@ export function workspaceCombobox(doc, {
|
|
|
915
1235
|
if (showHints && option.hint) item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-hint', text: option.hint }));
|
|
916
1236
|
item.addEventListener('pointerdown', event => event.preventDefault?.());
|
|
917
1237
|
item.addEventListener('click', () => choose(option));
|
|
918
|
-
list.append(item);
|
|
1238
|
+
(groupOptions || list).append(item); optionNodes.push(item);
|
|
919
1239
|
});
|
|
920
|
-
const active =
|
|
1240
|
+
const active = optionNodes[state.active];
|
|
921
1241
|
activeDescendant(active);
|
|
922
1242
|
if (scrollTop !== undefined) list.scrollTop = scrollTop;
|
|
923
1243
|
if (reveal) {
|
|
@@ -932,6 +1252,7 @@ export function workspaceCombobox(doc, {
|
|
|
932
1252
|
const rest = matches.length - state.shown.length;
|
|
933
1253
|
status.hidden = !showCount && matches.length > 0 && rest === 0;
|
|
934
1254
|
status.textContent = !matches.length ? emptyText : rest > 0 ? `${matches.length}件中${state.shown.length}件を表示。ほか${rest}件は絞り込むと出ます` : `${matches.length}件`;
|
|
1255
|
+
if (state.open && useViewportPopup) repositionViewportPopup();
|
|
935
1256
|
}
|
|
936
1257
|
|
|
937
1258
|
function move(index) {
|
|
@@ -940,29 +1261,56 @@ export function workspaceCombobox(doc, {
|
|
|
940
1261
|
renderList({ reveal: true });
|
|
941
1262
|
}
|
|
942
1263
|
|
|
943
|
-
function
|
|
944
|
-
|
|
1264
|
+
function closeForDialog() { close(false, true); }
|
|
1265
|
+
|
|
1266
|
+
function removeListeners() {
|
|
1267
|
+
doc.removeEventListener?.('pointerdown', outside);
|
|
1268
|
+
if (!useViewportPopup) return;
|
|
1269
|
+
doc.removeEventListener?.('scroll', repositionViewportPopup, true);
|
|
1270
|
+
doc.defaultView?.removeEventListener?.('resize', repositionViewportPopup);
|
|
1271
|
+
doc.defaultView?.visualViewport?.removeEventListener?.('resize', repositionViewportPopup);
|
|
1272
|
+
doc.defaultView?.visualViewport?.removeEventListener?.('scroll', repositionViewportPopup);
|
|
1273
|
+
modalHost?.removeEventListener?.('close', closeForDialog);
|
|
1274
|
+
modalHost?.removeEventListener?.('cancel', closeForDialog);
|
|
1275
|
+
modalHost?.removeEventListener?.('animationstart', portalDialogAnimationStart);
|
|
1276
|
+
modalHost?.removeEventListener?.('animationend', portalDialogAnimationEnd);
|
|
1277
|
+
modalHost?.removeEventListener?.('transitionrun', portalDialogAnimationStart);
|
|
1278
|
+
modalHost?.removeEventListener?.('transitionstart', portalDialogAnimationStart);
|
|
1279
|
+
modalHost?.removeEventListener?.('transitionend', portalDialogAnimationEnd);
|
|
1280
|
+
clearPortalMotionTimer(); portalMotionPending = false; pendingPortalFocus = false;
|
|
1281
|
+
popup.style?.removeProperty?.('visibility');
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function outside(event) {
|
|
1285
|
+
if (!root.contains?.(event.target) && !popup.contains?.(event.target) && !portal?.contains?.(event.target)) close(false);
|
|
1286
|
+
}
|
|
945
1287
|
|
|
946
1288
|
function open(query = '') {
|
|
947
|
-
if (state.disabled) return;
|
|
1289
|
+
if (state.disabled || (useViewportPopup && destroyed)) return;
|
|
948
1290
|
cancelExit(); popup.inert = false; popup.removeAttribute?.('inert'); popup.removeAttribute?.('aria-hidden');
|
|
949
1291
|
if (!state.open) { state.open = true; doc.addEventListener?.('pointerdown', outside); }
|
|
950
1292
|
state.query = query; search.value = query; search.hidden = !usesSearch();
|
|
951
1293
|
const selectedIndex = state.options.findIndex(option => multiple ? state.values.includes(option.value) : option.value === state.value);
|
|
952
1294
|
state.active = query ? 0 : Math.max(0, selectedIndex);
|
|
953
1295
|
popup.hidden = false; trigger.setAttribute('aria-expanded', 'true');
|
|
1296
|
+
if (useViewportPopup) mountViewportPopup();
|
|
954
1297
|
renderList({ reveal: true });
|
|
955
|
-
|
|
1298
|
+
if (useViewportPopup) repositionViewportPopup();
|
|
1299
|
+
if (!portalMotionPending) focusTarget().focus?.({ preventScroll: true });
|
|
956
1300
|
}
|
|
957
1301
|
|
|
958
|
-
function close(returnFocus = true) {
|
|
1302
|
+
function close(returnFocus = true, immediate = false) {
|
|
959
1303
|
if (!state.open) return;
|
|
960
1304
|
state.open = false; removeListeners();
|
|
961
|
-
if (
|
|
1305
|
+
if (useViewportPopup && !immediate) returnViewportPopupToRoot({ hide: false });
|
|
1306
|
+
if (immediate) {
|
|
1307
|
+
cancelExit(); popup.hidden = true;
|
|
1308
|
+
if (useViewportPopup) restoreViewportPopup();
|
|
1309
|
+
} else if (appearance === 'compact' && !reducedMotion(popup) && popup.isConnected !== false) {
|
|
962
1310
|
popup.inert = true; popup.setAttribute('inert', ''); popup.setAttribute('aria-hidden', 'true');
|
|
963
1311
|
toggleWorkspaceClass(popup, 'is-closing', true); popup.addEventListener?.('animationend', exitEnded);
|
|
964
1312
|
exitTimer = setTimeout(finishExit, animationFallback(popup, 50, 190));
|
|
965
|
-
} else popup.hidden = true;
|
|
1313
|
+
} else { popup.hidden = true; if (useViewportPopup) restoreViewportPopup(); }
|
|
966
1314
|
trigger.setAttribute('aria-expanded', 'false'); activeDescendant(null);
|
|
967
1315
|
if (returnFocus) trigger.focus?.();
|
|
968
1316
|
}
|
|
@@ -976,6 +1324,26 @@ export function workspaceCombobox(doc, {
|
|
|
976
1324
|
const changed = option.value !== state.value;
|
|
977
1325
|
state.value = option.value; renderTrigger(); close(true);
|
|
978
1326
|
if (changed) onChange?.(option.value, option);
|
|
1327
|
+
onSelect?.(option.value, option);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
function viewportTabTarget(backward) {
|
|
1331
|
+
const scope = modalHost?.open ? modalHost : doc;
|
|
1332
|
+
const selector = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1333
|
+
const candidates = Array.from(scope.querySelectorAll?.(selector) ?? []).filter(node => {
|
|
1334
|
+
if (node === popup || popup.contains?.(node) || portal?.contains?.(node)) return false;
|
|
1335
|
+
if (node.disabled || node.hidden || node.matches?.(':disabled') || node.getAttribute?.('aria-hidden') === 'true') return false;
|
|
1336
|
+
const style = doc.defaultView?.getComputedStyle?.(node);
|
|
1337
|
+
if (style?.display === 'none' || style?.visibility === 'hidden' || node.getClientRects?.().length === 0) return false;
|
|
1338
|
+
return true;
|
|
1339
|
+
});
|
|
1340
|
+
const index = candidates.indexOf(trigger);
|
|
1341
|
+
if (index < 0) return modalHost?.open ? trigger : null;
|
|
1342
|
+
const direction = backward ? -1 : 1;
|
|
1343
|
+
const adjacent = candidates[index + direction];
|
|
1344
|
+
if (adjacent) return adjacent;
|
|
1345
|
+
if (modalHost?.open && candidates.length > 1) return candidates[backward ? candidates.length - 1 : 0];
|
|
1346
|
+
return null;
|
|
979
1347
|
}
|
|
980
1348
|
|
|
981
1349
|
function keydown(event) {
|
|
@@ -988,7 +1356,15 @@ export function workspaceCombobox(doc, {
|
|
|
988
1356
|
};
|
|
989
1357
|
// Home and End move the caret while a search box is shown.
|
|
990
1358
|
if (!usesSearch()) Object.assign(keys, { Home: () => move(0), End: () => move(state.shown.length - 1) });
|
|
991
|
-
if (event.key === 'Tab') {
|
|
1359
|
+
if (event.key === 'Tab') {
|
|
1360
|
+
if (useViewportPopup) {
|
|
1361
|
+
const target = viewportTabTarget(Boolean(event.shiftKey));
|
|
1362
|
+
close(false, true);
|
|
1363
|
+
if (target) { event.preventDefault?.(); target.focus?.({ preventScroll: true }); }
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
close(false); return;
|
|
1367
|
+
}
|
|
992
1368
|
if (multiple && event.key === ' ' && !usesSearch()) keys[' '] = keys.Enter;
|
|
993
1369
|
const action = keys[event.key];
|
|
994
1370
|
if (!action) return;
|
|
@@ -1013,19 +1389,33 @@ export function workspaceCombobox(doc, {
|
|
|
1013
1389
|
get values() { return [...state.values]; },
|
|
1014
1390
|
get isOpen() { return state.open; },
|
|
1015
1391
|
open, close,
|
|
1016
|
-
update({ options: nextOptions, value: nextValue, values: nextValues, selectionLabel: nextSelectionLabel, disabled, active: nextActive } = {}) {
|
|
1392
|
+
update({ options: nextOptions, value: nextValue, values: nextValues, selectionLabel: nextSelectionLabel, disabled, active: nextActive, suggested: nextSuggested } = {}) {
|
|
1017
1393
|
if (nextActive !== undefined) toggleWorkspaceClass(root, 'is-active', Boolean(nextActive));
|
|
1018
|
-
const previous = JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled]);
|
|
1394
|
+
const previous = JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled, state.suggested]);
|
|
1395
|
+
if (nextSuggested !== undefined) {
|
|
1396
|
+
state.suggested = Boolean(nextSuggested);
|
|
1397
|
+
toggleWorkspaceClass(root, 'bb-ws-combobox--suggested', state.suggested);
|
|
1398
|
+
}
|
|
1399
|
+
syncPortalClasses();
|
|
1019
1400
|
if (nextOptions !== undefined) setOptions(nextOptions);
|
|
1020
1401
|
if (nextSelectionLabel !== undefined) state.selectionLabel = String(nextSelectionLabel ?? '');
|
|
1021
1402
|
if (nextValue !== undefined) state.value = String(nextValue ?? '');
|
|
1022
1403
|
if (nextValues !== undefined) state.values = [...new Set((Array.isArray(nextValues) ? nextValues : []).map(String))].filter(Boolean);
|
|
1023
1404
|
if (disabled !== undefined) { state.disabled = Boolean(disabled); if (state.disabled) close(false); }
|
|
1024
|
-
if (previous === JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled])) return;
|
|
1405
|
+
if (previous === JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled, state.suggested])) return;
|
|
1025
1406
|
renderTrigger();
|
|
1026
1407
|
if (state.open) { search.hidden = !usesSearch(); renderList(); }
|
|
1027
1408
|
},
|
|
1028
|
-
destroy() {
|
|
1409
|
+
destroy() {
|
|
1410
|
+
if (useViewportPopup) {
|
|
1411
|
+
if (destroyed) return;
|
|
1412
|
+
destroyed = true;
|
|
1413
|
+
if (state.open) close(false, true);
|
|
1414
|
+
removeListeners(); cancelExit(); restoreViewportPopup();
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
close(false); removeListeners(); cancelExit(); popup.hidden = true;
|
|
1418
|
+
},
|
|
1029
1419
|
};
|
|
1030
1420
|
}
|
|
1031
1421
|
|
|
@@ -1034,8 +1424,10 @@ export function workspaceActionIcon(doc, name) {
|
|
|
1034
1424
|
const svg = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'svg') : doc.createElement('svg');
|
|
1035
1425
|
for (const [key, value] of Object.entries({ class: 'bb-ws-action-icon', viewBox: '0 0 24 24', 'aria-hidden': 'true' })) svg.setAttribute(key, value);
|
|
1036
1426
|
const path = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'path') : doc.createElement('path');
|
|
1037
|
-
const paths = { edit: 'M4 20h4L19 9l-4-4L4 16z M13.5 6.5l4 4', undo: 'M4 5v5h5 M4.6 10A8 8 0 1 1 6.3 17.7', 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' };
|
|
1427
|
+
const paths = { edit: 'M4 20h4L19 9l-4-4L4 16z M13.5 6.5l4 4', undo: 'M4 5v5h5 M4.6 10A8 8 0 1 1 6.3 17.7', 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', close: 'M6 6l12 12M18 6L6 18', sparkles: 'M12 3l1.8 6.7 6.7 1.8-6.7 1.8L12 20l-1.8-6.7-6.7-1.8 6.7-1.8z M19 2v4 M17 4h4' };
|
|
1038
1428
|
Object.assign(paths, {
|
|
1429
|
+
copy: 'M9 9h12v12H9z M5 15H3V3h12v2',
|
|
1430
|
+
lock: 'M6 10h12v11H6z M8 10V7a4 4 0 1 1 8 0v3',
|
|
1039
1431
|
clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0 M12 7v5l3 2',
|
|
1040
1432
|
users: 'M12.2 8a3.2 3.2 0 1 1-6.4 0 3.2 3.2 0 0 1 6.4 0 M3 20c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5 M16 5.2a3.2 3.2 0 0 1 0 5.6 M18 14.8c1.9.7 3 2.5 3 5.2',
|
|
1041
1433
|
calendar: 'M5 4h14a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2 M8 2v4 M16 2v4 M3 10h18',
|
|
@@ -1301,7 +1693,7 @@ export function workspaceControlRow(doc, { label, control, tight = false } = {})
|
|
|
1301
1693
|
}
|
|
1302
1694
|
|
|
1303
1695
|
export function workspaceFormRow(doc, { label, control, required = false, top = false, appearance } = {}) {
|
|
1304
|
-
const root = el(doc, 'div', { className: `bb-ws-form-row${top ? ' is-top' : ''}${appearance === 'quiet' ? ' is-quiet' : ''}` });
|
|
1696
|
+
const root = el(doc, 'div', { className: `bb-ws-form-row${top ? ' is-top' : ''}${appearance === 'quiet' ? ' is-quiet' : ''}${appearance === 'stacked' ? ' is-stacked' : ''}` });
|
|
1305
1697
|
const caption = el(doc, control?.id ? 'label' : 'span', { className: 'bb-ws-form-label', text: label,
|
|
1306
1698
|
attrs: { for: control?.id || undefined } });
|
|
1307
1699
|
if (required) {
|
|
@@ -1332,19 +1724,48 @@ export function workspaceInputFrame(doc, { title, opener, onClose, beforeClose,
|
|
|
1332
1724
|
};
|
|
1333
1725
|
}
|
|
1334
1726
|
|
|
1335
|
-
export function workspaceCardRow(doc, { cells = [], stripe, selected = false, key, onSelect, label, preview = false } = {}) {
|
|
1336
|
-
const root = el(doc, onSelect ? 'button' : 'div', { className: `bb-ws-card-row${selected ? ' is-selected' : ''}${preview ? ' is-preview' : ''}`,
|
|
1727
|
+
export function workspaceCardRow(doc, { cells = [], stripe, selected = false, key, onSelect, label, preview = false, columnGap, selectionAppearance, appearance } = {}) {
|
|
1728
|
+
const root = el(doc, onSelect ? 'button' : 'div', { className: `bb-ws-card-row${selected ? ' is-selected' : ''}${preview ? ' is-preview' : ''}${selectionAppearance === 'soft' ? ' bb-ws-card-row--soft-selected' : ''}${appearance === 'compact-panel' ? ' bb-ws-card-row--compact-panel' : ''}${appearance === 'busy' ? ' bb-ws-card-row--busy' : ''}`,
|
|
1337
1729
|
attrs: { type: onSelect ? 'button' : undefined, 'data-key': key, 'aria-label': label, 'aria-pressed': onSelect ? String(selected) : undefined } });
|
|
1338
1730
|
if (stripe) root.style.setProperty('--bb-card-stripe', stripe);
|
|
1731
|
+
if (Number.isFinite(columnGap) && columnGap >= 0) root.style?.setProperty('--bb-ws-card-column-gap', `${columnGap}px`);
|
|
1339
1732
|
for (const cell of cells) {
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1733
|
+
const descriptor = cell && typeof cell === 'object' && typeof cell.tagName !== 'string' && ('className' in cell || 'content' in cell) ? cell : null;
|
|
1734
|
+
const cellClass = typeof descriptor?.className === 'string' && descriptor.className.trim() ? ` ${descriptor.className.trim()}` : '';
|
|
1735
|
+
const slot = el(doc, 'span', { className: `bb-ws-card-cell${cellClass}` });
|
|
1736
|
+
if (descriptor) appendContent(slot, doc, descriptor.content);
|
|
1737
|
+
else if (cell && typeof cell === 'object' && typeof cell.tagName === 'string') slot.append(cell);
|
|
1738
|
+
else slot.textContent = String(cell ?? '');
|
|
1342
1739
|
root.append(slot);
|
|
1343
1740
|
}
|
|
1344
1741
|
if (onSelect) root.addEventListener('click', () => onSelect(key));
|
|
1345
1742
|
return root;
|
|
1346
1743
|
}
|
|
1347
1744
|
|
|
1745
|
+
function workspaceCardLength(value, fallback) {
|
|
1746
|
+
if (Number.isFinite(value) && value >= 0) return `${value}px`;
|
|
1747
|
+
if (typeof value === 'string' && /^(?:\d+(?:\.\d+)?)(?:px|%|rem|em|ch)$/u.test(value.trim())) return value.trim();
|
|
1748
|
+
return fallback;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
/** Skeleton rows use the same caller-provided column grid as card rows. */
|
|
1752
|
+
export function workspaceCardRowSkeleton(doc, { cells = [], stripe, columnGap } = {}) {
|
|
1753
|
+
const root = el(doc, 'div', { className: 'bb-ws-card-row bb-ws-card-row--skeleton', attrs: { 'aria-hidden': 'true', role: 'presentation' } });
|
|
1754
|
+
if (stripe) root.style?.setProperty('--bb-card-stripe', stripe);
|
|
1755
|
+
if (Number.isFinite(columnGap) && columnGap >= 0) root.style?.setProperty('--bb-ws-card-column-gap', `${columnGap}px`);
|
|
1756
|
+
for (const item of cells) {
|
|
1757
|
+
const config = typeof item === 'object' && item !== null ? item : { width: item };
|
|
1758
|
+
const slot = el(doc, 'span', { className: 'bb-ws-card-cell' });
|
|
1759
|
+
const line = el(doc, 'span', { className: 'bb-ws-card-skeleton-line' });
|
|
1760
|
+
line.style?.setProperty('--bb-card-skeleton-width', workspaceCardLength(config.width, '100%'));
|
|
1761
|
+
const height = workspaceCardLength(config.height, '10px');
|
|
1762
|
+
line.style?.setProperty('--bb-card-skeleton-height', height);
|
|
1763
|
+
if (parseFloat(height) > 12) line.style?.setProperty('--bb-card-skeleton-radius', '7px');
|
|
1764
|
+
slot.append(line); root.append(slot);
|
|
1765
|
+
}
|
|
1766
|
+
return root;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1348
1769
|
/** FLIP keyed retained or redrawn rows; capture immediately before a host redraw. */
|
|
1349
1770
|
export function workspaceRowMotion(root) {
|
|
1350
1771
|
let previous = new Map();
|