@unson/brainbase-mcp 0.50.20 → 0.50.22
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 +150 -9
- package/ui/workspace-kit.js +426 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.22",
|
|
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": "f419a25d1acca1bc6548a4419968efdfca053c42"
|
|
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; }
|
|
@@ -1022,9 +1050,15 @@
|
|
|
1022
1050
|
.bb-ws-filter-anchor[data-pointer-focus] .bb-ws-filter-popover select:focus-visible { outline: none; box-shadow: none; }
|
|
1023
1051
|
|
|
1024
1052
|
/* Common page chrome; caller-owned tabs and tools retain their lifecycle. */
|
|
1025
|
-
.bb-ws-topbar {
|
|
1026
|
-
.bb-ws-topbar.has-query {
|
|
1027
|
-
.bb-ws-topbar
|
|
1053
|
+
.bb-ws-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; height: auto; min-height: var(--bb-page-header-height); padding: 0 var(--bb-space-6); column-gap: var(--bb-space-2); row-gap: 0; box-shadow: none; }
|
|
1054
|
+
.bb-ws-topbar:is(.has-tabs, .has-query, .has-tools) { grid-template-rows: var(--bb-page-header-height) minmax(var(--bb-page-header-height), auto); }
|
|
1055
|
+
.bb-ws-topbar > h1 { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; min-width: 0; min-height: var(--bb-page-header-height); border: 0; box-shadow: none; }
|
|
1056
|
+
.bb-ws-topbar > .bb-ws-topbar-tabs { grid-column: 1; grid-row: 2; }
|
|
1057
|
+
.bb-ws-topbar > .bb-ws-search-control { grid-column: 2; grid-row: 2; align-self: center; }
|
|
1058
|
+
.bb-ws-topbar > .bb-ws-topbar-tools { grid-column: 3; grid-row: 2; }
|
|
1059
|
+
.bb-ws-topbar.has-tabs { box-shadow: inset 0 -1px 0 var(--bb-color-border); }
|
|
1060
|
+
.bb-ws-topbar.has-query { column-gap: var(--bb-space-2); row-gap: 0; padding: 0 var(--bb-space-6); padding-inline-end:var(--bb-page-header-inline-end, var(--bb-space-5)); }
|
|
1061
|
+
/* Tabs do not hide the page title; the second grid row owns all controls. */
|
|
1028
1062
|
.bb-ws-topbar-tabs { display: flex; align-self: stretch; min-width: 0; }
|
|
1029
1063
|
.bb-ws-topbar-tools { display: flex; align-items: center; flex: none; gap: 8px; margin-left: auto; }
|
|
1030
1064
|
.bb-ws-topbar.has-query .bb-ws-topbar-tools { margin-left: 0; }
|
|
@@ -1128,11 +1162,12 @@
|
|
|
1128
1162
|
.bb-ws-input-footer > button.is-primary { background:var(--bb-color-action); color:var(--bb-color-action-text); font-weight:600; }
|
|
1129
1163
|
.bb-ws-input-footer > button.is-primary:hover { background:var(--bb-color-action-hover); }
|
|
1130
1164
|
.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; }
|
|
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; }
|
|
1132
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)); }
|
|
1133
1167
|
.bb-ws-card-row:hover { box-shadow:var(--bb-shadow-card-row-hover); }
|
|
1134
1168
|
.bb-ws-card-row.is-selected { box-shadow:0 0 0 2px var(--bb-color-action); }
|
|
1135
|
-
.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); }
|
|
1136
1171
|
.bb-ws-card-cell { min-width:0; }
|
|
1137
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; }
|
|
1138
1173
|
@media (prefers-reduced-motion:reduce) { .bb-ws-card-row { transition:none; } }
|
|
@@ -1193,9 +1228,11 @@
|
|
|
1193
1228
|
.bb-ws-tabs--header > :is([role="tab"],a,button) { display:block; line-height:1.6; }
|
|
1194
1229
|
.bb-ws-tabs--header .bb-ws-tab-count { line-height:1.6; }
|
|
1195
1230
|
@media(max-width:1200px) {
|
|
1196
|
-
.bb-ws-topbar.bb-ws-topbar--wrap {
|
|
1197
|
-
.bb-ws-topbar--wrap
|
|
1198
|
-
.bb-ws-topbar--wrap .bb-ws-
|
|
1231
|
+
.bb-ws-topbar.bb-ws-topbar--wrap { grid-template-columns: minmax(0, 1fr) auto; height:auto; min-height:var(--bb-page-header-height); padding-bottom:0; }
|
|
1232
|
+
.bb-ws-topbar--wrap.has-tabs:is(.has-query, .has-tools) { grid-template-rows: var(--bb-page-header-height) var(--bb-page-header-height) minmax(var(--bb-page-header-height), auto); }
|
|
1233
|
+
.bb-ws-topbar--wrap.has-tabs > .bb-ws-topbar-tabs { grid-column: 1 / -1; }
|
|
1234
|
+
.bb-ws-topbar--wrap.has-tabs > .bb-ws-search-control { grid-column: 1; grid-row: 3; min-width: 0; width: auto; margin-left: 0; }
|
|
1235
|
+
.bb-ws-topbar--wrap.has-tabs > .bb-ws-topbar-tools { grid-column: 2; grid-row: 3; }
|
|
1199
1236
|
}
|
|
1200
1237
|
|
|
1201
1238
|
.bb-ws-tabs--header .bb-ws-tab-count { font-feature-settings:normal; font-variant-numeric:normal; }
|
|
@@ -1209,7 +1246,7 @@
|
|
|
1209
1246
|
.bb-ws-anchored-popover:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1210
1247
|
@keyframes bb-ws-anchored-in { from { transform:scale(.94); opacity:0; } to { transform:none; opacity:1; } }
|
|
1211
1248
|
|
|
1212
|
-
.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); }
|
|
1213
1250
|
.bb-ws-dialog--compact::backdrop { background:color-mix(in srgb,var(--bb-color-ink) 18%,transparent); }
|
|
1214
1251
|
.bb-ws-dialog--compact .bb-ws-dialog-head { align-items:center; gap:0; margin-bottom:4px; padding:0; border:0; }
|
|
1215
1252
|
.bb-ws-dialog--compact .bb-ws-dialog-head h2 { flex:1; font-size:16px; font-weight:600; line-height:1.6; }
|
|
@@ -1277,3 +1314,107 @@
|
|
|
1277
1314
|
.bb-ws-button.is-icon .bb-ws-action-icon,
|
|
1278
1315
|
.bb-ws-topbar.has-tabs .bb-ws-topbar-tools > .bb-ws-button.is-icon .bb-ws-action-icon { width:16px; height:16px; }
|
|
1279
1316
|
.bb-ws-button.is-icon:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
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
|
+
|
|
1324
|
+
.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; }
|
|
1325
|
+
.bb-ws-checkbox:hover:not(:disabled) { box-shadow:inset 0 0 0 1.5px var(--bb-color-muted); }
|
|
1326
|
+
.bb-ws-checkbox:checked, .bb-ws-checkbox:indeterminate { background:var(--bb-color-action); box-shadow:none; color:var(--bb-color-action-text); }
|
|
1327
|
+
.bb-ws-checkbox:checked::before { content:''; width:4px; height:8px; border:solid currentColor; border-width:0 2px 2px 0; transform:translateY(-1px) rotate(45deg); }
|
|
1328
|
+
.bb-ws-checkbox:indeterminate::before { content:''; width:8px; height:2px; border-radius:1px; background:currentColor; }
|
|
1329
|
+
.bb-ws-checkbox:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1330
|
+
.bb-ws-checkbox:disabled { cursor:default; opacity:.5; }
|
|
1331
|
+
|
|
1332
|
+
.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; }
|
|
1333
|
+
.bb-ws-selection-bar-count { flex:none; margin-right:12px; font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }
|
|
1334
|
+
.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; }
|
|
1335
|
+
.bb-ws-selection-bar-dismiss:not(:disabled):hover { border:0; background:color-mix(in srgb,var(--bb-color-action-text) 12%,transparent); color:inherit; }
|
|
1336
|
+
.bb-ws-selection-bar-actions { display:flex; align-items:center; gap:4px; min-width:0; }
|
|
1337
|
+
.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; }
|
|
1338
|
+
.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); }
|
|
1339
|
+
.bb-ws-selection-bar-actions > .bb-ws-button.is-primary { background:var(--bb-color-mint); color:var(--bb-color-action); font-weight:700; }
|
|
1340
|
+
.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); }
|
|
1341
|
+
.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; }
|
|
1342
|
+
.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); }
|
|
1343
|
+
.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; }
|
|
1344
|
+
.bb-ws-selection-bar .bb-ws-selection-bar-actions > .bb-ws-combobox .bb-ws-combobox-chevron::after { color:var(--bb-color-action-text); }
|
|
1345
|
+
.bb-ws-selection-bar :focus-visible { outline:2px solid var(--bb-color-mint); outline-offset:2px; }
|
|
1346
|
+
|
|
1347
|
+
.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; }
|
|
1348
|
+
.bb-ws-inline-notice.is-danger { background:var(--bb-color-danger-soft); }
|
|
1349
|
+
.bb-ws-inline-notice-icon { display:grid; place-items:center; flex:none; width:16px; height:16px; color:var(--bb-color-success); }
|
|
1350
|
+
.bb-ws-inline-notice.is-danger .bb-ws-inline-notice-icon { color:var(--bb-color-danger); }
|
|
1351
|
+
.bb-ws-inline-notice-icon .bb-ws-action-icon { width:16px; height:16px; stroke-width:2; }
|
|
1352
|
+
.bb-ws-inline-notice-text { flex:1; min-width:0; line-height:1.6; }
|
|
1353
|
+
.bb-ws-inline-notice-actions { display:inline-flex; align-items:center; flex:none; gap:4px; }
|
|
1354
|
+
.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; }
|
|
1355
|
+
.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; }
|
|
1356
|
+
.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); }
|
|
1357
|
+
.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; }
|
|
1358
|
+
|
|
1359
|
+
.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; }
|
|
1360
|
+
.bb-ws-card-row--soft-selected.is-selected:hover { box-shadow:var(--bb-shadow-card-row-hover); }
|
|
1361
|
+
.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; }
|
|
1362
|
+
.bb-ws-card-row.bb-ws-card-row--compact-panel:hover { box-shadow:none; }
|
|
1363
|
+
.bb-ws-card-row--skeleton { pointer-events:none; box-shadow:none; }
|
|
1364
|
+
.bb-ws-card-row--skeleton:hover { box-shadow:none; }
|
|
1365
|
+
.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; }
|
|
1366
|
+
@keyframes bb-ws-card-skeleton-sweep { to { background-position:100% 0; } }
|
|
1367
|
+
|
|
1368
|
+
.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; }
|
|
1369
|
+
.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); }
|
|
1370
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless .bb-ws-combobox-trigger:focus-visible { outline:2px solid var(--bb-color-focus); outline-offset:2px; }
|
|
1371
|
+
.bb-ws-combobox--compact.bb-ws-combobox--suggested .bb-ws-combobox-trigger,
|
|
1372
|
+
.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; }
|
|
1373
|
+
.bb-ws-combobox-suggestion-mark { display:grid; place-items:center; flex:none; width:14px; height:14px; color:var(--bb-color-mint); }
|
|
1374
|
+
.bb-ws-combobox-suggestion-mark .bb-ws-action-icon { width:14px; height:14px; stroke-width:2; }
|
|
1375
|
+
.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); }
|
|
1376
|
+
.bb-ws-combobox-group { margin:0; padding:0; list-style:none; }
|
|
1377
|
+
.bb-ws-combobox-group-options { margin:0; padding:0; list-style:none; }
|
|
1378
|
+
.bb-ws-combobox-group-label { display:block; padding:10px 16px 4px; color:var(--bb-color-action); font-size:12px; font-weight:700; }
|
|
1379
|
+
.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); }
|
|
1380
|
+
.bb-ws-selection-bar:not(.has-dismiss) .bb-ws-selection-bar-count { grid-column:1 / -1; }
|
|
1381
|
+
.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); }
|
|
1382
|
+
.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; }
|
|
1383
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-head h2,
|
|
1384
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-body > h3:first-child,
|
|
1385
|
+
.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; }
|
|
1386
|
+
.bb-ws-dialog.bb-ws-dialog--compact.bb-ws-dialog--confirmation > .bb-ws-dialog-body { padding:0; }
|
|
1387
|
+
.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; }
|
|
1388
|
+
.bb-ws-dialog.bb-ws-dialog--confirmation::backdrop { background:var(--bb-color-dialog-overlay); }
|
|
1389
|
+
.bb-ws-combobox--compact.bb-ws-combobox--borderless.bb-ws-combobox--suggested .bb-ws-combobox-trigger { font-weight:500; }
|
|
1390
|
+
.bb-ws-combobox-portal { display:contents; position:static; }
|
|
1391
|
+
.bb-ws-combobox-popup--viewport { position:fixed; z-index:45; top:0; left:0; right:auto; bottom:auto; max-width:calc(100vw - 16px); }
|
|
1392
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport { display:flex; flex-direction:column; min-height:0; overflow-y:hidden; }
|
|
1393
|
+
.bb-ws-combobox--compact.bb-ws-combobox--control-panel .bb-ws-combobox-popup--viewport { overflow-y:hidden; }
|
|
1394
|
+
.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; }
|
|
1395
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport > .bb-ws-combobox-search,
|
|
1396
|
+
.bb-ws-combobox-portal .bb-ws-combobox-popup--viewport > .bb-ws-combobox-status { flex:none; }
|
|
1397
|
+
|
|
1398
|
+
@media(max-width:600px) {
|
|
1399
|
+
.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; }
|
|
1400
|
+
.bb-ws-selection-bar-count { margin:0; }
|
|
1401
|
+
.bb-ws-selection-bar-actions { grid-column:1 / -1; display:flex; flex-wrap:wrap; justify-content:flex-end; }
|
|
1402
|
+
}
|
|
1403
|
+
@media(prefers-reduced-motion:reduce) { .bb-ws-card-skeleton-line { animation:none; } }
|
|
1404
|
+
|
|
1405
|
+
/* Content alignment changes only desktop horizontal gutters; the header preset owns sizing. */
|
|
1406
|
+
@media (min-width: 761px) {
|
|
1407
|
+
.bb-ws-topbar.bb-ws-topbar--content-aligned { padding-inline: var(--bb-space-5); }
|
|
1408
|
+
.bb-ws-topbar.bb-ws-topbar--content-aligned.has-tabs > h1 { padding-inline-start: calc(var(--bb-space-6) - var(--bb-space-5)); }
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/* A narrow header keeps the title and tabs full width before its controls. */
|
|
1412
|
+
@media (max-width: 760px) {
|
|
1413
|
+
.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)); }
|
|
1414
|
+
.bb-ws-topbar > .bb-ws-search-control { grid-column: 1; min-width: 0; width: auto; margin-left: 0; }
|
|
1415
|
+
.bb-ws-topbar > .bb-ws-topbar-tools { grid-column: 2; min-width: 0; }
|
|
1416
|
+
.bb-ws-topbar.has-tabs > .bb-ws-topbar-tabs { grid-column: 1 / -1; }
|
|
1417
|
+
.bb-ws-topbar.has-tabs:is(.has-query, .has-tools) { grid-template-rows: var(--bb-page-header-height) var(--bb-page-header-height) minmax(var(--bb-page-header-height), auto); }
|
|
1418
|
+
.bb-ws-topbar.has-tabs > :is(.bb-ws-search-control, .bb-ws-topbar-tools) { grid-row: 3; }
|
|
1419
|
+
.bb-ws-topbar.has-tabs:not(.has-query) > .bb-ws-topbar-tools { grid-column: 1 / -1; justify-content: flex-end; }
|
|
1420
|
+
}
|
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,45 @@ 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, attrs = {} } = {}) {
|
|
277
|
+
const tones = new Set(['neutral', 'success', 'warning', 'danger']);
|
|
278
|
+
const appearance = tones.has(tone) ? tone : 'neutral';
|
|
279
|
+
const pill = el(doc, 'span', { className: `bb-ws-status-pill is-${appearance}`, text: label, attrs });
|
|
280
|
+
if (Number.isFinite(width) && width > 0) pill.style?.setProperty('--bb-status-pill-width', `${width}px`);
|
|
281
|
+
return pill;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Native checkbox with the shared compact mark and caller-owned selection. */
|
|
285
|
+
export function workspaceCheckbox(doc, { label, checked = false, indeterminate = false, disabled = false, onChange, attrs = {} } = {}) {
|
|
286
|
+
const checkbox = el(doc, 'input', { className: 'bb-ws-checkbox', attrs: {
|
|
287
|
+
...attrs, type: 'checkbox', 'aria-label': attrs['aria-label'] ?? label, checked: Boolean(checked), disabled: Boolean(disabled),
|
|
288
|
+
} });
|
|
289
|
+
checkbox.checked = Boolean(checked);
|
|
290
|
+
checkbox.indeterminate = Boolean(indeterminate);
|
|
291
|
+
checkbox.addEventListener('change', () => onChange?.(checkbox.checked, checkbox.indeterminate, checkbox));
|
|
292
|
+
return checkbox;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Shared selection bar; the host owns its placement and action callbacks. */
|
|
296
|
+
export function workspaceSelectionBar(doc, { count = 0, actions = [], onDismiss, label = '選択中の項目', announce = false } = {}) {
|
|
297
|
+
const root = el(doc, 'div', { className: `bb-ws-selection-bar${onDismiss ? ' has-dismiss' : ''}`, attrs: { role: 'region', 'aria-label': label } });
|
|
298
|
+
if (onDismiss) {
|
|
299
|
+
const dismiss = workspaceButton(doc, { variant: 'quiet', attrs: { 'aria-label': '選択を解除' }, onClick: onDismiss });
|
|
300
|
+
dismiss.classList?.add('bb-ws-selection-bar-dismiss');
|
|
301
|
+
dismiss.append(workspaceActionIcon(doc, 'close'));
|
|
302
|
+
root.append(dismiss);
|
|
303
|
+
}
|
|
304
|
+
const countLabel = typeof count === 'number' && Number.isFinite(count) ? `${count}件を選択中` : String(count ?? '');
|
|
305
|
+
root.append(el(doc, 'span', { className: 'bb-ws-selection-bar-count', text: countLabel, attrs: { 'aria-live': announce ? 'polite' : undefined } }));
|
|
306
|
+
const actionSlot = el(doc, 'div', { className: 'bb-ws-selection-bar-actions' });
|
|
307
|
+
for (const action of actions) {
|
|
308
|
+
if (action) actionSlot.append(typeof action.tagName === 'string' ? action : workspaceButton(doc, action));
|
|
309
|
+
}
|
|
310
|
+
root.append(actionSlot);
|
|
311
|
+
return root;
|
|
312
|
+
}
|
|
313
|
+
|
|
236
314
|
/** Summary metrics in one ruled row. `value` null means 未確認, never zero. */
|
|
237
315
|
export function workspaceMetrics(doc, items = [], { ariaLabel = '集計' } = {}) {
|
|
238
316
|
const summary = el(doc, 'section', { className: `bb-ws-summary is-${Math.min(Math.max(items.length, 1), 6)}`, attrs: { 'aria-label': ariaLabel } });
|
|
@@ -447,9 +525,9 @@ export function workspaceCloseDrawer(dialog, finish) {
|
|
|
447
525
|
}
|
|
448
526
|
|
|
449
527
|
/** 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 } = {}) {
|
|
528
|
+
export function workspaceDialog(doc, { title, content, opener, presentation = 'center', onClose, appearance, headerTools, compactWidth } = {}) {
|
|
451
529
|
const dialog = el(doc, 'dialog', { className: 'bb-ws-dialog' });
|
|
452
|
-
|
|
530
|
+
workspaceDialogAppearance(dialog, { appearance, compactWidth });
|
|
453
531
|
if (presentation === 'drawer') workspaceApplyDrawer(dialog);
|
|
454
532
|
const headingId = `bb-ws-dialog-${nextWorkspaceSequence()}`;
|
|
455
533
|
dialog.setAttribute('aria-labelledby', headingId);
|
|
@@ -500,6 +578,19 @@ export function workspaceDialog(doc, { title, content, opener, presentation = 'c
|
|
|
500
578
|
return dialog;
|
|
501
579
|
}
|
|
502
580
|
|
|
581
|
+
/** Apply shared dialog appearance to a host-owned native dialog without owning its lifecycle. */
|
|
582
|
+
export function workspaceDialogAppearance(dialog, { appearance, compactWidth } = {}) {
|
|
583
|
+
if (!dialog || typeof dialog.setAttribute !== 'function') throw new TypeError('dialog_element_required');
|
|
584
|
+
const isConfirmation = appearance === 'confirmation';
|
|
585
|
+
const isCompact = appearance === 'compact' || isConfirmation;
|
|
586
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog', true);
|
|
587
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog--compact', isCompact);
|
|
588
|
+
toggleWorkspaceClass(dialog, 'bb-ws-dialog--confirmation', isConfirmation);
|
|
589
|
+
if (isCompact && Number.isFinite(compactWidth) && compactWidth > 0) dialog.style?.setProperty('--bb-dialog-compact-width', `${compactWidth}px`);
|
|
590
|
+
else dialog.style?.removeProperty?.('--bb-dialog-compact-width');
|
|
591
|
+
return dialog;
|
|
592
|
+
}
|
|
593
|
+
|
|
503
594
|
/** Applied condition with an explicit, individually removable value. */
|
|
504
595
|
export function workspaceFilterChip(doc, { label, onRemove, attrs = {} } = {}) {
|
|
505
596
|
const chip = workspaceButton(doc, { text: `${label} ×`, attrs: { 'aria-label': `${label}を解除`, ...attrs }, onClick: onRemove });
|
|
@@ -509,6 +600,52 @@ export function workspaceFilterChip(doc, { label, onRemove, attrs = {} } = {}) {
|
|
|
509
600
|
|
|
510
601
|
const anchoredPopoverBindings = new WeakMap();
|
|
511
602
|
|
|
603
|
+
function workspacePositionAnchoredElement(element, positionAnchor, {
|
|
604
|
+
align = 'start', placement = 'bottom', gap = 4, inset = 8, view, doc, flip = false, clampHeight = false, clampOverflow = 'auto', preciseWidth = false, bounds,
|
|
605
|
+
} = {}) {
|
|
606
|
+
const at = positionAnchor.getBoundingClientRect();
|
|
607
|
+
const box = element.getBoundingClientRect();
|
|
608
|
+
const viewportWidth = view?.innerWidth || doc?.documentElement?.clientWidth || 1024;
|
|
609
|
+
const viewportHeight = view?.innerHeight || doc?.documentElement?.clientHeight || 768;
|
|
610
|
+
const boundary = bounds?.getBoundingClientRect?.() ?? bounds;
|
|
611
|
+
const leftInset = Math.max(inset, boundary?.left + inset || inset);
|
|
612
|
+
const topInset = Math.max(inset, boundary?.top + inset || inset);
|
|
613
|
+
const rightEdge = Math.min(viewportWidth - inset, boundary?.right - inset || viewportWidth - inset);
|
|
614
|
+
const bottomEdge = Math.min(viewportHeight - inset, boundary?.bottom - inset || viewportHeight - inset);
|
|
615
|
+
const computedWidth = preciseWidth ? Number.parseFloat(view?.getComputedStyle?.(element)?.width) : NaN;
|
|
616
|
+
const panelWidth = (Number.isFinite(computedWidth) && computedWidth > 0 ? computedWidth : 0) || element.offsetWidth || box.width || box.right - box.left;
|
|
617
|
+
let panelHeight = element.offsetHeight || box.height || box.bottom - box.top;
|
|
618
|
+
const anchorLeft = at.left ?? at.x ?? 0;
|
|
619
|
+
const anchorRight = at.right ?? anchorLeft + (at.width ?? 0);
|
|
620
|
+
const anchorTop = at.top ?? at.y ?? 0;
|
|
621
|
+
const anchorBottom = at.bottom ?? anchorTop + (at.height ?? 0);
|
|
622
|
+
const anchorWidth = at.width ?? anchorRight - anchorLeft;
|
|
623
|
+
const x = align === 'end' ? anchorRight - panelWidth : align === 'center' ? anchorLeft + (anchorWidth - panelWidth) / 2 : anchorLeft;
|
|
624
|
+
let y;
|
|
625
|
+
let side = placement;
|
|
626
|
+
if (flip) {
|
|
627
|
+
const availableBelow = Math.max(0, bottomEdge - anchorBottom - gap);
|
|
628
|
+
const availableAbove = Math.max(0, anchorTop - topInset - gap);
|
|
629
|
+
side = placement === 'top' ? 'top' : 'bottom';
|
|
630
|
+
if (side !== 'top' && panelHeight > availableBelow && availableAbove > availableBelow) side = 'top';
|
|
631
|
+
const available = side === 'top' ? availableAbove : availableBelow;
|
|
632
|
+
if (clampHeight && panelHeight > available) {
|
|
633
|
+
element.style?.setProperty('max-height', `${available}px`);
|
|
634
|
+
element.style?.setProperty('overflow-y', clampOverflow);
|
|
635
|
+
panelHeight = element.offsetHeight || Math.min(panelHeight, available);
|
|
636
|
+
} else if (clampHeight) {
|
|
637
|
+
element.style?.removeProperty?.('max-height');
|
|
638
|
+
element.style?.removeProperty?.('overflow-y');
|
|
639
|
+
}
|
|
640
|
+
y = side === 'top' ? anchorTop - gap - panelHeight : anchorBottom + gap;
|
|
641
|
+
} else y = placement === 'overlap' ? anchorTop - 10 : anchorBottom + gap;
|
|
642
|
+
return {
|
|
643
|
+
left: Math.max(leftInset, Math.min(x, rightEdge - panelWidth)),
|
|
644
|
+
top: Math.max(topInset, Math.min(y, bottomEdge - panelHeight)),
|
|
645
|
+
width: panelWidth, height: panelHeight, side, viewportWidth, viewportHeight,
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
|
|
512
649
|
/** Non-modal anchored surface. Content and visibility have independent lifecycles. */
|
|
513
650
|
export function workspaceAnchoredPopover(doc, {
|
|
514
651
|
anchor, positionAnchor = anchor, content, label, surface = 'default', width = 276, placement = 'bottom', align = 'start', padding, onClose,
|
|
@@ -540,17 +677,9 @@ export function workspaceAnchoredPopover(doc, {
|
|
|
540
677
|
const reposition = () => {
|
|
541
678
|
if (!opened || destroyed) return;
|
|
542
679
|
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`);
|
|
680
|
+
const point = workspacePositionAnchoredElement(element, positionAnchor, { align, placement, gap: 4, inset: 8, view, doc });
|
|
681
|
+
element.style?.setProperty('left', `${point.left}px`);
|
|
682
|
+
element.style?.setProperty('top', `${point.top}px`);
|
|
554
683
|
};
|
|
555
684
|
const removeListeners = () => {
|
|
556
685
|
doc.removeEventListener?.('pointerdown', outside); doc.removeEventListener?.('keydown', escape);
|
|
@@ -797,10 +926,12 @@ export function workspaceErrorCard(doc, { title, message, tone = 'danger', onRet
|
|
|
797
926
|
return card;
|
|
798
927
|
}
|
|
799
928
|
|
|
800
|
-
export function workspaceDisclosure(doc, { title, help, content, open = false, onToggle } = {}) {
|
|
801
|
-
const
|
|
929
|
+
export function workspaceDisclosure(doc, { title, help, content, open = false, onToggle, appearance, headingLevel = 2 } = {}) {
|
|
930
|
+
const compact = appearance === 'compact';
|
|
931
|
+
const level = [2, 3, 4, 5, 6].includes(headingLevel) ? headingLevel : 2;
|
|
932
|
+
const details = el(doc, 'details', { className: `bb-ws-disclosure${compact ? ' bb-ws-disclosure--compact' : ''}` }); details.open = open;
|
|
802
933
|
const summary = el(doc, 'summary');
|
|
803
|
-
summary.append(el(doc,
|
|
934
|
+
summary.append(el(doc, `h${level}`, { text: title }));
|
|
804
935
|
if (help) summary.append(workspaceHelp(doc, { label: title, text: help }));
|
|
805
936
|
details.append(summary, content);
|
|
806
937
|
if (onToggle) details.addEventListener('toggle', () => onToggle(details.open));
|
|
@@ -822,14 +953,20 @@ function comboboxText(value) {
|
|
|
822
953
|
*/
|
|
823
954
|
export function workspaceCombobox(doc, {
|
|
824
955
|
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,
|
|
956
|
+
emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange, onSelect,
|
|
957
|
+
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,
|
|
958
|
+
popupPlacement,
|
|
827
959
|
} = {}) {
|
|
828
960
|
const sequence = nextWorkspaceSequence();
|
|
829
961
|
const listId = `bb-ws-combobox-${sequence}-list`;
|
|
830
962
|
const root = el(doc, 'span', { className: ['bb-ws-combobox', className].filter(Boolean).join(' ') });
|
|
963
|
+
const useViewportPopup = popupPlacement === 'viewport';
|
|
964
|
+
if (useViewportPopup) toggleWorkspaceClass(root, 'bb-ws-combobox--viewport-popup', true);
|
|
831
965
|
if (appearance === 'compact') toggleWorkspaceClass(root, 'bb-ws-combobox--compact', true);
|
|
832
966
|
if (boxed) { toggleWorkspaceClass(root, 'is-boxed', true); toggleWorkspaceClass(root, 'bb-ws-combobox--stable-box', true); }
|
|
967
|
+
if (borderless) toggleWorkspaceClass(root, 'bb-ws-combobox--borderless', true);
|
|
968
|
+
if (popupAppearance === 'control-panel') toggleWorkspaceClass(root, 'bb-ws-combobox--control-panel', true);
|
|
969
|
+
if (suggested) toggleWorkspaceClass(root, 'bb-ws-combobox--suggested', true);
|
|
833
970
|
if (active) toggleWorkspaceClass(root, 'is-active', true);
|
|
834
971
|
if (matchTriggerWidth) toggleWorkspaceClass(root, 'bb-ws-combobox--match-width', true);
|
|
835
972
|
if (triggerHeight === 32) toggleWorkspaceClass(root, 'bb-ws-combobox--tall', true);
|
|
@@ -841,7 +978,9 @@ export function workspaceCombobox(doc, {
|
|
|
841
978
|
if (align === 'end') root.classList?.add('bb-ws-combobox-align-end');
|
|
842
979
|
const trigger = el(doc, 'button', { className: 'bb-ws-combobox-trigger', attrs: { type: 'button', 'aria-haspopup': 'listbox', 'aria-expanded': 'false', 'aria-controls': listId } });
|
|
843
980
|
const triggerText = el(doc, 'span', { className: 'bb-ws-combobox-value' });
|
|
844
|
-
|
|
981
|
+
const chevron = workspaceDropdownChevron(doc);
|
|
982
|
+
let suggestionMark;
|
|
983
|
+
trigger.append(triggerText, chevron);
|
|
845
984
|
const popup = el(doc, 'div', { className: 'bb-ws-combobox-popup' });
|
|
846
985
|
popup.hidden = true;
|
|
847
986
|
const search = el(doc, 'input', { className: 'bb-ws-combobox-search', attrs: {
|
|
@@ -854,19 +993,136 @@ export function workspaceCombobox(doc, {
|
|
|
854
993
|
popup.append(search, list, status);
|
|
855
994
|
root.append(trigger, popup);
|
|
856
995
|
|
|
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 };
|
|
996
|
+
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) };
|
|
997
|
+
let optionNodes = [];
|
|
998
|
+
let portal;
|
|
999
|
+
let modalHost;
|
|
1000
|
+
let portalMotionPending = false;
|
|
1001
|
+
let pendingPortalFocus = false;
|
|
1002
|
+
let portalMotionTimer;
|
|
1003
|
+
let destroyed = false;
|
|
858
1004
|
let exitTimer;
|
|
859
1005
|
const cancelExit = () => { clearTimeout(exitTimer); exitTimer = undefined; popup.removeEventListener?.('animationend', exitEnded); toggleWorkspaceClass(popup, 'is-closing', false); };
|
|
860
|
-
const finishExit = () => {
|
|
1006
|
+
const finishExit = () => {
|
|
1007
|
+
cancelExit();
|
|
1008
|
+
if (!state.open) { popup.hidden = true; if (useViewportPopup) restoreViewportPopup(); }
|
|
1009
|
+
};
|
|
861
1010
|
const exitEnded = event => { if (event.target === popup && event.animationName === 'bb-ws-compact-dropdown-out') finishExit(); };
|
|
862
1011
|
const usesSearch = () => searchable === true || (searchable === 'auto' && state.options.length > 8);
|
|
863
1012
|
const focusTarget = () => (usesSearch() ? search : list);
|
|
864
1013
|
const chosen = () => state.options.find(option => option.value === state.value);
|
|
865
1014
|
|
|
1015
|
+
function syncPortalClasses() {
|
|
1016
|
+
if (!portal) return;
|
|
1017
|
+
portal.className = `${root.className} bb-ws-combobox-portal`;
|
|
1018
|
+
if (Number.isFinite(popupWidth) && popupWidth > 0) portal.style?.setProperty('--bb-combobox-popup-width', `${popupWidth}px`);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
function clearPortalMotionTimer() {
|
|
1022
|
+
clearTimeout(portalMotionTimer); portalMotionTimer = undefined;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
function dialogHasRunningTransform() {
|
|
1026
|
+
if (!modalHost) return false;
|
|
1027
|
+
const active = modalHost.getAnimations?.().some(animation => animation.effect?.target === modalHost && animation.playState === 'running') === true;
|
|
1028
|
+
const transform = doc.defaultView?.getComputedStyle?.(modalHost)?.transform;
|
|
1029
|
+
return active && transform !== 'none';
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function repositionViewportPopup() {
|
|
1033
|
+
if (!useViewportPopup || !state.open || !portal || portalMotionPending) return;
|
|
1034
|
+
if (root.isConnected === false || trigger.isConnected === false || (modalHost && !modalHost.open)) { close(false, true); return; }
|
|
1035
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
1036
|
+
const viewportWidth = doc.defaultView?.innerWidth || doc.documentElement?.clientWidth || 1024;
|
|
1037
|
+
const dialogRect = modalHost?.getBoundingClientRect?.();
|
|
1038
|
+
const listScrollTop = list.scrollTop;
|
|
1039
|
+
const maxWidth = Math.max(0, Math.min(viewportWidth - 16, dialogRect ? dialogRect.width - 16 : viewportWidth - 16));
|
|
1040
|
+
popup.style?.setProperty('max-width', `${maxWidth}px`);
|
|
1041
|
+
if (matchTriggerWidth) popup.style?.setProperty('width', `${Math.max(0, Math.min(triggerRect.width || 0, maxWidth))}px`);
|
|
1042
|
+
else popup.style?.removeProperty?.('width');
|
|
1043
|
+
popup.style?.removeProperty?.('max-height');
|
|
1044
|
+
popup.style?.removeProperty?.('overflow-y');
|
|
1045
|
+
const point = workspacePositionAnchoredElement(popup, trigger, {
|
|
1046
|
+
align, placement: 'bottom', gap: 6, inset: 8, view: doc.defaultView, doc, flip: true, clampHeight: true, clampOverflow: 'hidden', preciseWidth: true, bounds: dialogRect,
|
|
1047
|
+
});
|
|
1048
|
+
popup.style?.setProperty('left', `${point.left}px`);
|
|
1049
|
+
popup.style?.setProperty('top', `${point.top}px`);
|
|
1050
|
+
if (Number.isFinite(listScrollTop)) list.scrollTop = listScrollTop;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function finishPortalMotion() {
|
|
1054
|
+
if (!portalMotionPending || !state.open) return;
|
|
1055
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1056
|
+
if (dialogHasRunningTransform()) return;
|
|
1057
|
+
clearPortalMotionTimer(); portalMotionPending = false;
|
|
1058
|
+
repositionViewportPopup();
|
|
1059
|
+
popup.style?.removeProperty?.('visibility');
|
|
1060
|
+
if (pendingPortalFocus) { pendingPortalFocus = false; focusTarget().focus?.({ preventScroll: true }); }
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function portalDialogAnimationStart(event) {
|
|
1064
|
+
if (event.target !== modalHost) return;
|
|
1065
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1066
|
+
if (doc.defaultView?.getComputedStyle?.(modalHost)?.transform !== 'none') {
|
|
1067
|
+
portalMotionPending = true; pendingPortalFocus = true;
|
|
1068
|
+
popup.style?.setProperty('visibility', 'hidden');
|
|
1069
|
+
clearPortalMotionTimer(); portalMotionTimer = setTimeout(finishPortalMotion, animationFallback(modalHost, 24, 240));
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function portalDialogAnimationEnd(event) {
|
|
1074
|
+
if (event.target !== modalHost) return;
|
|
1075
|
+
if (modalHost?.classList?.contains('is-closing')) { close(false, true); return; }
|
|
1076
|
+
finishPortalMotion();
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
function mountViewportPopup() {
|
|
1080
|
+
if (!useViewportPopup) return;
|
|
1081
|
+
modalHost = root.closest?.('dialog[open]') || null;
|
|
1082
|
+
if (!portal) {
|
|
1083
|
+
portal = el(doc, 'span', { className: `${root.className} bb-ws-combobox-portal` });
|
|
1084
|
+
portal.style?.setProperty('display', 'contents');
|
|
1085
|
+
}
|
|
1086
|
+
syncPortalClasses();
|
|
1087
|
+
toggleWorkspaceClass(popup, 'bb-ws-combobox-popup--viewport', true);
|
|
1088
|
+
const portalParent = modalHost || doc.body;
|
|
1089
|
+
if (portal.parentNode !== portalParent) portalParent.append(portal);
|
|
1090
|
+
if (popup.parentNode !== portal) portal.append(popup);
|
|
1091
|
+
doc.addEventListener?.('scroll', repositionViewportPopup, true);
|
|
1092
|
+
doc.defaultView?.addEventListener?.('resize', repositionViewportPopup);
|
|
1093
|
+
doc.defaultView?.visualViewport?.addEventListener?.('resize', repositionViewportPopup);
|
|
1094
|
+
doc.defaultView?.visualViewport?.addEventListener?.('scroll', repositionViewportPopup);
|
|
1095
|
+
if (modalHost) {
|
|
1096
|
+
modalHost.addEventListener?.('close', closeForDialog);
|
|
1097
|
+
modalHost.addEventListener?.('cancel', closeForDialog);
|
|
1098
|
+
modalHost.addEventListener?.('animationstart', portalDialogAnimationStart);
|
|
1099
|
+
modalHost.addEventListener?.('animationend', portalDialogAnimationEnd);
|
|
1100
|
+
modalHost.addEventListener?.('transitionrun', portalDialogAnimationStart);
|
|
1101
|
+
modalHost.addEventListener?.('transitionstart', portalDialogAnimationStart);
|
|
1102
|
+
modalHost.addEventListener?.('transitionend', portalDialogAnimationEnd);
|
|
1103
|
+
}
|
|
1104
|
+
if (dialogHasRunningTransform()) {
|
|
1105
|
+
portalMotionPending = true; pendingPortalFocus = true;
|
|
1106
|
+
popup.style?.setProperty('visibility', 'hidden');
|
|
1107
|
+
portalMotionTimer = setTimeout(finishPortalMotion, animationFallback(modalHost, 24, 240));
|
|
1108
|
+
} else repositionViewportPopup();
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function returnViewportPopupToRoot({ hide = true } = {}) {
|
|
1112
|
+
if (!useViewportPopup) return;
|
|
1113
|
+
if (hide) popup.hidden = true;
|
|
1114
|
+
toggleWorkspaceClass(popup, 'bb-ws-combobox-popup--viewport', false);
|
|
1115
|
+
for (const property of ['left', 'top', 'width', 'max-width', 'max-height', 'overflow-y', 'visibility']) popup.style?.removeProperty?.(property);
|
|
1116
|
+
if (portal) { root.append(popup); portal.remove(); portal = undefined; }
|
|
1117
|
+
modalHost = undefined; portalMotionPending = false; pendingPortalFocus = false; clearPortalMotionTimer();
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function restoreViewportPopup() { returnViewportPopupToRoot({ hide: true }); }
|
|
1121
|
+
|
|
866
1122
|
function setOptions(next) {
|
|
867
1123
|
state.options = (Array.isArray(next) ? next : []).map(option => ({
|
|
868
1124
|
...option, value: String(option?.value ?? ''), label: String(option?.label ?? option?.value ?? ''),
|
|
869
|
-
hint: option?.hint ? String(option.hint) : '', keywords: option?.keywords ? String(option.keywords) : '',
|
|
1125
|
+
hint: option?.hint ? String(option.hint) : '', keywords: option?.keywords ? String(option.keywords) : '', group: option?.group ? String(option.group) : '',
|
|
870
1126
|
}));
|
|
871
1127
|
}
|
|
872
1128
|
|
|
@@ -874,15 +1130,27 @@ export function workspaceCombobox(doc, {
|
|
|
874
1130
|
const option = multiple ? (state.values.length === 1 ? state.options.find(option => option.value === state.values[0]) : state.options.find(option => !option.value)) : chosen();
|
|
875
1131
|
const summary = multiple && state.values.length > 1 ? `${state.values.length}件選択中` : null;
|
|
876
1132
|
const text = state.selectionLabel || summary || (option ? option.label : multiple ? state.values.join('、') || placeholder : state.value || placeholder);
|
|
1133
|
+
if (state.suggested) {
|
|
1134
|
+
if (!suggestionMark) {
|
|
1135
|
+
suggestionMark = el(doc, 'span', { className: 'bb-ws-combobox-suggestion-mark', attrs: { 'aria-hidden': 'true' } });
|
|
1136
|
+
suggestionMark.append(workspaceActionIcon(doc, 'sparkles'));
|
|
1137
|
+
}
|
|
1138
|
+
trigger.insertBefore(suggestionMark, triggerText);
|
|
1139
|
+
} else suggestionMark?.remove();
|
|
877
1140
|
triggerText.textContent = text;
|
|
878
|
-
if (!state.selectionLabel && !summary && option && typeof
|
|
1141
|
+
if (!state.selectionLabel && !summary && option && typeof renderValue === 'function') {
|
|
1142
|
+
triggerText.textContent = '';
|
|
1143
|
+
appendContent(triggerText, doc, renderValue(option));
|
|
1144
|
+
} else if (!state.selectionLabel && !summary && option && typeof renderIcon === 'function') {
|
|
879
1145
|
const icon = renderIcon(option);
|
|
880
1146
|
if (icon) { triggerText.textContent = ''; triggerText.append(icon, el(doc, 'span', { className: 'bb-ws-combobox-text', text })); }
|
|
881
1147
|
}
|
|
882
1148
|
toggleWorkspaceClass(root, 'is-multi-selected', Boolean(summary));
|
|
883
|
-
|
|
1149
|
+
const accessibleText = !state.selectionLabel && !summary && option?.group ? `${option.group}・${option.label}` : text;
|
|
1150
|
+
trigger.setAttribute('aria-label', `${label ? `${label}: ` : ''}${accessibleText}`);
|
|
884
1151
|
trigger.setAttribute('data-empty', String(multiple ? !state.values.length : !option && !state.value));
|
|
885
1152
|
if (state.disabled) trigger.setAttribute('disabled', ''); else trigger.removeAttribute('disabled');
|
|
1153
|
+
syncPortalClasses();
|
|
886
1154
|
}
|
|
887
1155
|
|
|
888
1156
|
function activeDescendant(node) {
|
|
@@ -896,13 +1164,23 @@ export function workspaceCombobox(doc, {
|
|
|
896
1164
|
const scrollTop = list.scrollTop;
|
|
897
1165
|
const terms = comboboxText(state.query).split(/\s+/u).filter(Boolean);
|
|
898
1166
|
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)); })
|
|
1167
|
+
? 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
1168
|
: state.options;
|
|
901
1169
|
const max = Math.max(1, Number(limit) || 100);
|
|
902
1170
|
state.shown = matches.slice(0, max);
|
|
903
1171
|
if (state.active >= state.shown.length) state.active = state.shown.length - 1;
|
|
904
|
-
list.replaceChildren();
|
|
1172
|
+
list.replaceChildren(); optionNodes = [];
|
|
1173
|
+
let groupName = '';
|
|
1174
|
+
let groupNode;
|
|
1175
|
+
let groupOptions;
|
|
905
1176
|
state.shown.forEach((option, index) => {
|
|
1177
|
+
if (option.group && option.group !== groupName) {
|
|
1178
|
+
groupName = option.group;
|
|
1179
|
+
groupNode = el(doc, 'li', { className: 'bb-ws-combobox-group', attrs: { role: 'group', 'aria-label': groupName } });
|
|
1180
|
+
groupOptions = el(doc, 'ul', { className: 'bb-ws-combobox-group-options', attrs: { role: 'presentation' } });
|
|
1181
|
+
groupNode.append(el(doc, 'span', { className: 'bb-ws-combobox-group-label', text: groupName, attrs: { 'aria-hidden': 'true' } }), groupOptions);
|
|
1182
|
+
list.append(groupNode);
|
|
1183
|
+
} else if (!option.group) { groupName = ''; groupNode = undefined; groupOptions = undefined; }
|
|
906
1184
|
const selected = multiple ? option.value ? state.values.includes(option.value) : state.values.length === 0 : option.value === state.value;
|
|
907
1185
|
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
1186
|
const optionLabel = el(doc, 'span', { className: 'bb-ws-combobox-option-label', text: option.label });
|
|
@@ -915,9 +1193,9 @@ export function workspaceCombobox(doc, {
|
|
|
915
1193
|
if (showHints && option.hint) item.append(el(doc, 'span', { className: 'bb-ws-combobox-option-hint', text: option.hint }));
|
|
916
1194
|
item.addEventListener('pointerdown', event => event.preventDefault?.());
|
|
917
1195
|
item.addEventListener('click', () => choose(option));
|
|
918
|
-
list.append(item);
|
|
1196
|
+
(groupOptions || list).append(item); optionNodes.push(item);
|
|
919
1197
|
});
|
|
920
|
-
const active =
|
|
1198
|
+
const active = optionNodes[state.active];
|
|
921
1199
|
activeDescendant(active);
|
|
922
1200
|
if (scrollTop !== undefined) list.scrollTop = scrollTop;
|
|
923
1201
|
if (reveal) {
|
|
@@ -932,6 +1210,7 @@ export function workspaceCombobox(doc, {
|
|
|
932
1210
|
const rest = matches.length - state.shown.length;
|
|
933
1211
|
status.hidden = !showCount && matches.length > 0 && rest === 0;
|
|
934
1212
|
status.textContent = !matches.length ? emptyText : rest > 0 ? `${matches.length}件中${state.shown.length}件を表示。ほか${rest}件は絞り込むと出ます` : `${matches.length}件`;
|
|
1213
|
+
if (state.open && useViewportPopup) repositionViewportPopup();
|
|
935
1214
|
}
|
|
936
1215
|
|
|
937
1216
|
function move(index) {
|
|
@@ -940,29 +1219,56 @@ export function workspaceCombobox(doc, {
|
|
|
940
1219
|
renderList({ reveal: true });
|
|
941
1220
|
}
|
|
942
1221
|
|
|
943
|
-
function
|
|
944
|
-
|
|
1222
|
+
function closeForDialog() { close(false, true); }
|
|
1223
|
+
|
|
1224
|
+
function removeListeners() {
|
|
1225
|
+
doc.removeEventListener?.('pointerdown', outside);
|
|
1226
|
+
if (!useViewportPopup) return;
|
|
1227
|
+
doc.removeEventListener?.('scroll', repositionViewportPopup, true);
|
|
1228
|
+
doc.defaultView?.removeEventListener?.('resize', repositionViewportPopup);
|
|
1229
|
+
doc.defaultView?.visualViewport?.removeEventListener?.('resize', repositionViewportPopup);
|
|
1230
|
+
doc.defaultView?.visualViewport?.removeEventListener?.('scroll', repositionViewportPopup);
|
|
1231
|
+
modalHost?.removeEventListener?.('close', closeForDialog);
|
|
1232
|
+
modalHost?.removeEventListener?.('cancel', closeForDialog);
|
|
1233
|
+
modalHost?.removeEventListener?.('animationstart', portalDialogAnimationStart);
|
|
1234
|
+
modalHost?.removeEventListener?.('animationend', portalDialogAnimationEnd);
|
|
1235
|
+
modalHost?.removeEventListener?.('transitionrun', portalDialogAnimationStart);
|
|
1236
|
+
modalHost?.removeEventListener?.('transitionstart', portalDialogAnimationStart);
|
|
1237
|
+
modalHost?.removeEventListener?.('transitionend', portalDialogAnimationEnd);
|
|
1238
|
+
clearPortalMotionTimer(); portalMotionPending = false; pendingPortalFocus = false;
|
|
1239
|
+
popup.style?.removeProperty?.('visibility');
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
function outside(event) {
|
|
1243
|
+
if (!root.contains?.(event.target) && !popup.contains?.(event.target) && !portal?.contains?.(event.target)) close(false);
|
|
1244
|
+
}
|
|
945
1245
|
|
|
946
1246
|
function open(query = '') {
|
|
947
|
-
if (state.disabled) return;
|
|
1247
|
+
if (state.disabled || (useViewportPopup && destroyed)) return;
|
|
948
1248
|
cancelExit(); popup.inert = false; popup.removeAttribute?.('inert'); popup.removeAttribute?.('aria-hidden');
|
|
949
1249
|
if (!state.open) { state.open = true; doc.addEventListener?.('pointerdown', outside); }
|
|
950
1250
|
state.query = query; search.value = query; search.hidden = !usesSearch();
|
|
951
1251
|
const selectedIndex = state.options.findIndex(option => multiple ? state.values.includes(option.value) : option.value === state.value);
|
|
952
1252
|
state.active = query ? 0 : Math.max(0, selectedIndex);
|
|
953
1253
|
popup.hidden = false; trigger.setAttribute('aria-expanded', 'true');
|
|
1254
|
+
if (useViewportPopup) mountViewportPopup();
|
|
954
1255
|
renderList({ reveal: true });
|
|
955
|
-
|
|
1256
|
+
if (useViewportPopup) repositionViewportPopup();
|
|
1257
|
+
if (!portalMotionPending) focusTarget().focus?.({ preventScroll: true });
|
|
956
1258
|
}
|
|
957
1259
|
|
|
958
|
-
function close(returnFocus = true) {
|
|
1260
|
+
function close(returnFocus = true, immediate = false) {
|
|
959
1261
|
if (!state.open) return;
|
|
960
1262
|
state.open = false; removeListeners();
|
|
961
|
-
if (
|
|
1263
|
+
if (useViewportPopup && !immediate) returnViewportPopupToRoot({ hide: false });
|
|
1264
|
+
if (immediate) {
|
|
1265
|
+
cancelExit(); popup.hidden = true;
|
|
1266
|
+
if (useViewportPopup) restoreViewportPopup();
|
|
1267
|
+
} else if (appearance === 'compact' && !reducedMotion(popup) && popup.isConnected !== false) {
|
|
962
1268
|
popup.inert = true; popup.setAttribute('inert', ''); popup.setAttribute('aria-hidden', 'true');
|
|
963
1269
|
toggleWorkspaceClass(popup, 'is-closing', true); popup.addEventListener?.('animationend', exitEnded);
|
|
964
1270
|
exitTimer = setTimeout(finishExit, animationFallback(popup, 50, 190));
|
|
965
|
-
} else popup.hidden = true;
|
|
1271
|
+
} else { popup.hidden = true; if (useViewportPopup) restoreViewportPopup(); }
|
|
966
1272
|
trigger.setAttribute('aria-expanded', 'false'); activeDescendant(null);
|
|
967
1273
|
if (returnFocus) trigger.focus?.();
|
|
968
1274
|
}
|
|
@@ -976,6 +1282,26 @@ export function workspaceCombobox(doc, {
|
|
|
976
1282
|
const changed = option.value !== state.value;
|
|
977
1283
|
state.value = option.value; renderTrigger(); close(true);
|
|
978
1284
|
if (changed) onChange?.(option.value, option);
|
|
1285
|
+
onSelect?.(option.value, option);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
function viewportTabTarget(backward) {
|
|
1289
|
+
const scope = modalHost?.open ? modalHost : doc;
|
|
1290
|
+
const selector = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1291
|
+
const candidates = Array.from(scope.querySelectorAll?.(selector) ?? []).filter(node => {
|
|
1292
|
+
if (node === popup || popup.contains?.(node) || portal?.contains?.(node)) return false;
|
|
1293
|
+
if (node.disabled || node.hidden || node.matches?.(':disabled') || node.getAttribute?.('aria-hidden') === 'true') return false;
|
|
1294
|
+
const style = doc.defaultView?.getComputedStyle?.(node);
|
|
1295
|
+
if (style?.display === 'none' || style?.visibility === 'hidden' || node.getClientRects?.().length === 0) return false;
|
|
1296
|
+
return true;
|
|
1297
|
+
});
|
|
1298
|
+
const index = candidates.indexOf(trigger);
|
|
1299
|
+
if (index < 0) return modalHost?.open ? trigger : null;
|
|
1300
|
+
const direction = backward ? -1 : 1;
|
|
1301
|
+
const adjacent = candidates[index + direction];
|
|
1302
|
+
if (adjacent) return adjacent;
|
|
1303
|
+
if (modalHost?.open && candidates.length > 1) return candidates[backward ? candidates.length - 1 : 0];
|
|
1304
|
+
return null;
|
|
979
1305
|
}
|
|
980
1306
|
|
|
981
1307
|
function keydown(event) {
|
|
@@ -988,7 +1314,15 @@ export function workspaceCombobox(doc, {
|
|
|
988
1314
|
};
|
|
989
1315
|
// Home and End move the caret while a search box is shown.
|
|
990
1316
|
if (!usesSearch()) Object.assign(keys, { Home: () => move(0), End: () => move(state.shown.length - 1) });
|
|
991
|
-
if (event.key === 'Tab') {
|
|
1317
|
+
if (event.key === 'Tab') {
|
|
1318
|
+
if (useViewportPopup) {
|
|
1319
|
+
const target = viewportTabTarget(Boolean(event.shiftKey));
|
|
1320
|
+
close(false, true);
|
|
1321
|
+
if (target) { event.preventDefault?.(); target.focus?.({ preventScroll: true }); }
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
close(false); return;
|
|
1325
|
+
}
|
|
992
1326
|
if (multiple && event.key === ' ' && !usesSearch()) keys[' '] = keys.Enter;
|
|
993
1327
|
const action = keys[event.key];
|
|
994
1328
|
if (!action) return;
|
|
@@ -1013,19 +1347,33 @@ export function workspaceCombobox(doc, {
|
|
|
1013
1347
|
get values() { return [...state.values]; },
|
|
1014
1348
|
get isOpen() { return state.open; },
|
|
1015
1349
|
open, close,
|
|
1016
|
-
update({ options: nextOptions, value: nextValue, values: nextValues, selectionLabel: nextSelectionLabel, disabled, active: nextActive } = {}) {
|
|
1350
|
+
update({ options: nextOptions, value: nextValue, values: nextValues, selectionLabel: nextSelectionLabel, disabled, active: nextActive, suggested: nextSuggested } = {}) {
|
|
1017
1351
|
if (nextActive !== undefined) toggleWorkspaceClass(root, 'is-active', Boolean(nextActive));
|
|
1018
|
-
const previous = JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled]);
|
|
1352
|
+
const previous = JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled, state.suggested]);
|
|
1353
|
+
if (nextSuggested !== undefined) {
|
|
1354
|
+
state.suggested = Boolean(nextSuggested);
|
|
1355
|
+
toggleWorkspaceClass(root, 'bb-ws-combobox--suggested', state.suggested);
|
|
1356
|
+
}
|
|
1357
|
+
syncPortalClasses();
|
|
1019
1358
|
if (nextOptions !== undefined) setOptions(nextOptions);
|
|
1020
1359
|
if (nextSelectionLabel !== undefined) state.selectionLabel = String(nextSelectionLabel ?? '');
|
|
1021
1360
|
if (nextValue !== undefined) state.value = String(nextValue ?? '');
|
|
1022
1361
|
if (nextValues !== undefined) state.values = [...new Set((Array.isArray(nextValues) ? nextValues : []).map(String))].filter(Boolean);
|
|
1023
1362
|
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;
|
|
1363
|
+
if (previous === JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled, state.suggested])) return;
|
|
1025
1364
|
renderTrigger();
|
|
1026
1365
|
if (state.open) { search.hidden = !usesSearch(); renderList(); }
|
|
1027
1366
|
},
|
|
1028
|
-
destroy() {
|
|
1367
|
+
destroy() {
|
|
1368
|
+
if (useViewportPopup) {
|
|
1369
|
+
if (destroyed) return;
|
|
1370
|
+
destroyed = true;
|
|
1371
|
+
if (state.open) close(false, true);
|
|
1372
|
+
removeListeners(); cancelExit(); restoreViewportPopup();
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
close(false); removeListeners(); cancelExit(); popup.hidden = true;
|
|
1376
|
+
},
|
|
1029
1377
|
};
|
|
1030
1378
|
}
|
|
1031
1379
|
|
|
@@ -1034,8 +1382,9 @@ export function workspaceActionIcon(doc, name) {
|
|
|
1034
1382
|
const svg = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'svg') : doc.createElement('svg');
|
|
1035
1383
|
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
1384
|
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' };
|
|
1385
|
+
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
1386
|
Object.assign(paths, {
|
|
1387
|
+
lock: 'M6 10h12v11H6z M8 10V7a4 4 0 1 1 8 0v3',
|
|
1039
1388
|
clock: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0 M12 7v5l3 2',
|
|
1040
1389
|
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
1390
|
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',
|
|
@@ -1332,19 +1681,48 @@ export function workspaceInputFrame(doc, { title, opener, onClose, beforeClose,
|
|
|
1332
1681
|
};
|
|
1333
1682
|
}
|
|
1334
1683
|
|
|
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' : ''}`,
|
|
1684
|
+
export function workspaceCardRow(doc, { cells = [], stripe, selected = false, key, onSelect, label, preview = false, columnGap, selectionAppearance, appearance } = {}) {
|
|
1685
|
+
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
1686
|
attrs: { type: onSelect ? 'button' : undefined, 'data-key': key, 'aria-label': label, 'aria-pressed': onSelect ? String(selected) : undefined } });
|
|
1338
1687
|
if (stripe) root.style.setProperty('--bb-card-stripe', stripe);
|
|
1688
|
+
if (Number.isFinite(columnGap) && columnGap >= 0) root.style?.setProperty('--bb-ws-card-column-gap', `${columnGap}px`);
|
|
1339
1689
|
for (const cell of cells) {
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1690
|
+
const descriptor = cell && typeof cell === 'object' && typeof cell.tagName !== 'string' && ('className' in cell || 'content' in cell) ? cell : null;
|
|
1691
|
+
const cellClass = typeof descriptor?.className === 'string' && descriptor.className.trim() ? ` ${descriptor.className.trim()}` : '';
|
|
1692
|
+
const slot = el(doc, 'span', { className: `bb-ws-card-cell${cellClass}` });
|
|
1693
|
+
if (descriptor) appendContent(slot, doc, descriptor.content);
|
|
1694
|
+
else if (cell && typeof cell === 'object' && typeof cell.tagName === 'string') slot.append(cell);
|
|
1695
|
+
else slot.textContent = String(cell ?? '');
|
|
1342
1696
|
root.append(slot);
|
|
1343
1697
|
}
|
|
1344
1698
|
if (onSelect) root.addEventListener('click', () => onSelect(key));
|
|
1345
1699
|
return root;
|
|
1346
1700
|
}
|
|
1347
1701
|
|
|
1702
|
+
function workspaceCardLength(value, fallback) {
|
|
1703
|
+
if (Number.isFinite(value) && value >= 0) return `${value}px`;
|
|
1704
|
+
if (typeof value === 'string' && /^(?:\d+(?:\.\d+)?)(?:px|%|rem|em|ch)$/u.test(value.trim())) return value.trim();
|
|
1705
|
+
return fallback;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/** Skeleton rows use the same caller-provided column grid as card rows. */
|
|
1709
|
+
export function workspaceCardRowSkeleton(doc, { cells = [], stripe, columnGap } = {}) {
|
|
1710
|
+
const root = el(doc, 'div', { className: 'bb-ws-card-row bb-ws-card-row--skeleton', attrs: { 'aria-hidden': 'true', role: 'presentation' } });
|
|
1711
|
+
if (stripe) root.style?.setProperty('--bb-card-stripe', stripe);
|
|
1712
|
+
if (Number.isFinite(columnGap) && columnGap >= 0) root.style?.setProperty('--bb-ws-card-column-gap', `${columnGap}px`);
|
|
1713
|
+
for (const item of cells) {
|
|
1714
|
+
const config = typeof item === 'object' && item !== null ? item : { width: item };
|
|
1715
|
+
const slot = el(doc, 'span', { className: 'bb-ws-card-cell' });
|
|
1716
|
+
const line = el(doc, 'span', { className: 'bb-ws-card-skeleton-line' });
|
|
1717
|
+
line.style?.setProperty('--bb-card-skeleton-width', workspaceCardLength(config.width, '100%'));
|
|
1718
|
+
const height = workspaceCardLength(config.height, '10px');
|
|
1719
|
+
line.style?.setProperty('--bb-card-skeleton-height', height);
|
|
1720
|
+
if (parseFloat(height) > 12) line.style?.setProperty('--bb-card-skeleton-radius', '7px');
|
|
1721
|
+
slot.append(line); root.append(slot);
|
|
1722
|
+
}
|
|
1723
|
+
return root;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1348
1726
|
/** FLIP keyed retained or redrawn rows; capture immediately before a host redraw. */
|
|
1349
1727
|
export function workspaceRowMotion(root) {
|
|
1350
1728
|
let previous = new Map();
|