@unson/brainbase-mcp 0.50.13 → 0.50.16

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.
@@ -93,8 +93,8 @@ 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 } = {}) {
97
- const header = el(doc, 'header', { className: 'bb-ws-topbar' });
96
+ export function workspaceTopbar(doc, { title = '', query, tabs, tools, wrap = false } = {}) {
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;
100
100
  let currentQuery;
@@ -143,7 +143,7 @@ function workspaceLightDismiss(doc, dialog, close) {
143
143
  }
144
144
 
145
145
  /** A reusable right inspector whose content can refresh without replacing the modal. */
146
- export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose } = {}) {
146
+ export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose, beforeClose } = {}) {
147
147
  const dialog = workspaceApplyDrawer(el(doc, 'dialog', { className: 'bb-ws-dialog bb-ws-detail-drawer' }));
148
148
  const titleId = `bb-ws-inspector-${nextWorkspaceSequence()}`;
149
149
  dialog.setAttribute('aria-labelledby', titleId);
@@ -161,6 +161,7 @@ export function workspaceDetailDrawer(doc, { title = '詳細', opener, onClose }
161
161
  };
162
162
  const close = ({ restoreFocus = true, immediate = false } = {}) => {
163
163
  if (!dialog.open) return;
164
+ if (!immediate && beforeClose?.() === false) return;
164
165
  // Clear the caller's open state before an asynchronous content update arrives.
165
166
  if (cancelClosing && !immediate) return;
166
167
  if (!cancelClosing) onClose?.();
@@ -653,7 +654,7 @@ function comboboxText(value) {
653
654
  export function workspaceCombobox(doc, {
654
655
  label, options = [], value = '', placeholder = '選択してください', searchLabel, searchPlaceholder = '絞り込む',
655
656
  emptyText = '一致する候補はありません', limit = 100, searchable = 'auto', className, onChange,
656
- multiple = false, values = [], renderIcon, showCount = true, showHints = true, align = 'start', appearance,
657
+ multiple = false, values = [], selectionLabel = '', renderIcon, showCount = true, showHints = true, align = 'start', appearance,
657
658
  } = {}) {
658
659
  const sequence = nextWorkspaceSequence();
659
660
  const listId = `bb-ws-combobox-${sequence}-list`;
@@ -676,7 +677,7 @@ export function workspaceCombobox(doc, {
676
677
  popup.append(search, list, status);
677
678
  root.append(trigger, popup);
678
679
 
679
- const state = { options: [], values: [...new Set((Array.isArray(values) ? values : []).map(String))].filter(Boolean), value: String(value ?? ''), query: '', active: -1, shown: [], open: false, disabled: false };
680
+ 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 };
680
681
  let exitTimer;
681
682
  const cancelExit = () => { clearTimeout(exitTimer); exitTimer = undefined; popup.removeEventListener?.('animationend', exitEnded); toggleWorkspaceClass(popup, 'is-closing', false); };
682
683
  const finishExit = () => { cancelExit(); if (!state.open) popup.hidden = true; };
@@ -695,9 +696,9 @@ export function workspaceCombobox(doc, {
695
696
  function renderTrigger() {
696
697
  const option = multiple ? (state.values.length === 1 ? state.options.find(option => option.value === state.values[0]) : state.options.find(option => !option.value)) : chosen();
697
698
  const summary = multiple && state.values.length > 1 ? `${state.values.length}件選択中` : null;
698
- const text = summary || (option ? option.label : multiple ? state.values.join('、') || placeholder : state.value || placeholder);
699
+ const text = state.selectionLabel || summary || (option ? option.label : multiple ? state.values.join('、') || placeholder : state.value || placeholder);
699
700
  triggerText.textContent = text;
700
- if (!summary && option && typeof renderIcon === 'function') {
701
+ if (!state.selectionLabel && !summary && option && typeof renderIcon === 'function') {
701
702
  const icon = renderIcon(option);
702
703
  if (icon) { triggerText.textContent = ''; triggerText.append(icon, el(doc, 'span', { className: 'bb-ws-combobox-text', text })); }
703
704
  }
@@ -835,13 +836,14 @@ export function workspaceCombobox(doc, {
835
836
  get values() { return [...state.values]; },
836
837
  get isOpen() { return state.open; },
837
838
  open, close,
838
- update({ options: nextOptions, value: nextValue, values: nextValues, disabled } = {}) {
839
- const previous = JSON.stringify([state.options, state.value, state.values, state.disabled]);
839
+ update({ options: nextOptions, value: nextValue, values: nextValues, selectionLabel: nextSelectionLabel, disabled } = {}) {
840
+ const previous = JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled]);
840
841
  if (nextOptions !== undefined) setOptions(nextOptions);
842
+ if (nextSelectionLabel !== undefined) state.selectionLabel = String(nextSelectionLabel ?? '');
841
843
  if (nextValue !== undefined) state.value = String(nextValue ?? '');
842
844
  if (nextValues !== undefined) state.values = [...new Set((Array.isArray(nextValues) ? nextValues : []).map(String))].filter(Boolean);
843
845
  if (disabled !== undefined) { state.disabled = Boolean(disabled); if (state.disabled) close(false); }
844
- if (previous === JSON.stringify([state.options, state.value, state.values, state.disabled])) return;
846
+ if (previous === JSON.stringify([state.options, state.value, state.values, state.selectionLabel, state.disabled])) return;
845
847
  renderTrigger();
846
848
  if (state.open) { search.hidden = !usesSearch(); renderList(); }
847
849
  },
@@ -854,7 +856,7 @@ export function workspaceActionIcon(doc, name) {
854
856
  const svg = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'svg') : doc.createElement('svg');
855
857
  for (const [key, value] of Object.entries({ class: 'bb-ws-action-icon', viewBox: '0 0 24 24', 'aria-hidden': 'true' })) svg.setAttribute(key, value);
856
858
  const path = typeof doc.createElementNS === 'function' ? doc.createElementNS('http://www.w3.org/2000/svg', 'path') : doc.createElement('path');
857
- const paths = { check: 'M5 12l5 5 9-10', sliders: 'M4 8h8M18 8h2M4 16h2M12 16h8 M17.4 8a2.4 2.4 0 1 1-4.8 0 2.4 2.4 0 0 1 4.8 0 M11.4 16a2.4 2.4 0 1 1-4.8 0 2.4 2.4 0 0 1 4.8 0', plus: 'M12 5v14M5 12h14', search: 'M21 21l-4.35-4.35M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0', filter: 'M4 7h16M7 12h10M10 17h4', sort: 'M8 4v16m-3-3 3 3 3-3M16 20V4m-3 3 3-3 3 3' };
859
+ 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' };
858
860
  path.setAttribute('d', paths[name] || paths.filter); svg.append(path); return svg;
859
861
  }
860
862
 
@@ -1113,8 +1115,8 @@ export function workspaceControlRow(doc, { label, control, tight = false } = {})
1113
1115
  return root;
1114
1116
  }
1115
1117
 
1116
- export function workspaceFormRow(doc, { label, control, required = false, top = false } = {}) {
1117
- const root = el(doc, 'div', { className: `bb-ws-form-row${top ? ' is-top' : ''}` });
1118
+ export function workspaceFormRow(doc, { label, control, required = false, top = false, appearance } = {}) {
1119
+ const root = el(doc, 'div', { className: `bb-ws-form-row${top ? ' is-top' : ''}${appearance === 'quiet' ? ' is-quiet' : ''}` });
1118
1120
  const caption = el(doc, control?.id ? 'label' : 'span', { className: 'bb-ws-form-label', text: label,
1119
1121
  attrs: { for: control?.id || undefined } });
1120
1122
  if (required) {
@@ -1128,8 +1130,8 @@ export function workspaceFormRow(doc, { label, control, required = false, top =
1128
1130
  }
1129
1131
 
1130
1132
  /** Uses the canonical modal, Escape/backdrop/close animation and focus return. */
1131
- export function workspaceInputFrame(doc, { title, opener, onClose, tools = [], preview, rows = [], footer = [], showTitle = true } = {}) {
1132
- const drawer = workspaceDetailDrawer(doc, { title, opener, onClose });
1133
+ export function workspaceInputFrame(doc, { title, opener, onClose, beforeClose, tools = [], preview, rows = [], footer = [], showTitle = true } = {}) {
1134
+ const drawer = workspaceDetailDrawer(doc, { title, opener, onClose, beforeClose });
1133
1135
  drawer.dialog.classList.add('bb-ws-input-frame');
1134
1136
  if (tools.length) drawer.dialog.classList.add('has-tools');
1135
1137
  drawer.dialog.querySelector('.bb-ws-detail-closebar > button')?.setAttribute('aria-label', '閉じる');