@bagelink/vue 1.20.85 → 1.20.89

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.20.85",
4
+ "version": "1.20.89",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -63,7 +63,7 @@
63
63
  "@types/signature_pad": "^4.0.0",
64
64
  "vue": "^3.5.43",
65
65
  "vue-component-type-helpers": "^2.2.12",
66
- "@bagelink/sdk": "1.20.85"
66
+ "@bagelink/sdk": "1.20.89"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@bagelink/sdk": "*",
@@ -31,6 +31,11 @@ const props = defineProps({
31
31
  folding: { type: Boolean, default: false },
32
32
  /** Show an explicit Format action; downloads the formatter only when clicked. */
33
33
  formatting: { type: Boolean, default: false },
34
+ /**
35
+ * Toolbar chrome: `bar` keeps language + actions above the editor;
36
+ * `hover` reveals them on hover/focus. Terminal mode always uses the title bar.
37
+ */
38
+ toolbarMode: { type: String as PropType<'bar' | 'hover'>, default: 'bar' },
34
39
  singleLine: { type: Boolean, default: false },
35
40
  /** Legacy highlight.js theme names now map to light/dark appearance. */
36
41
  theme: { type: String as PropType<HighlightTheme>, default: 'dark' },
@@ -67,6 +72,8 @@ const isLightTheme = computed(() => {
67
72
  'school-book', 'routeros', 'purebasic',
68
73
  ].includes(theme)
69
74
  })
75
+ /** Terminal shells are always dark — force matching syntax colors. */
76
+ const editorDark = computed(() => props.terminal || !isLightTheme.value)
70
77
 
71
78
  function updateCode(value: string) {
72
79
  code.value = value
@@ -96,19 +103,12 @@ watch(() => props.modelValue, value => {
96
103
 
97
104
  <template>
98
105
  <div
99
- class="bagel-input code-editor-container ltr flex flex-column"
106
+ class="bagel-input code-editor-container ltr display-flex flex-column"
100
107
  :class="[shellClass, { 'has-value': hasCodeValue, 'single-line': singleLine, terminal }]"
101
108
  :style="[{ height: editorHeight, '--code-max-height': maxHeight }, shellStyle]"
102
109
  >
103
- <label v-if="label" class="code-label">{{ label }}</label>
104
- <div v-if="terminal" class="code-terminal-bar monospace flex flex-shrink-0 gap-05 py-05 px-075 txt11 line-height-1 border-bottom">
105
- <span class="inline-flex gap-025 flex-shrink-0" aria-hidden="true">
106
- <span class="square-10 round bg-red" />
107
- <span class="square-10 round bg-yellow" />
108
- <span class="square-10 round bg-green" />
109
- </span>
110
- <span v-if="title" class="opacity-5 ellipsis-1">{{ title }}</span>
111
- </div>
110
+ <!-- Bar mode puts the form label on the toolbar row; other modes keep it above. -->
111
+ <label v-if="label && (toolbarMode === 'hover' || singleLine || terminal)" class="label">{{ label }}</label>
112
112
  <StructuredEditor
113
113
  :model-value="code"
114
114
  :language="objectMode && language === 'html' ? 'json' : language"
@@ -121,7 +121,10 @@ watch(() => props.modelValue, value => {
121
121
  :single-line="singleLine"
122
122
  :placeholder="placeholder"
123
123
  :label="label"
124
- :dark="!isLightTheme"
124
+ :dark="editorDark"
125
+ :terminal="terminal"
126
+ :title="title"
127
+ :toolbar-mode="toolbarMode"
125
128
  @update:model-value="updateCode"
126
129
  @focus="isFocused = true"
127
130
  @blur="handleBlur"
@@ -137,11 +140,13 @@ watch(() => props.modelValue, value => {
137
140
  }
138
141
  .code-editor-container > :deep(.structured-editor) {
139
142
  flex: 1;
143
+ min-height: 0;
140
144
  }
141
- .code-label {
142
- flex-shrink: 0;
143
- margin-bottom: 0.25rem;
144
- text-align: left;
145
+ /* Focus ring only while the CodeMirror surface is focused — not toolbar buttons (e.g. Copy). */
146
+ .code-editor-container:not(.frame):not(.bgl-outline):not(.terminal):not(.single-line) > :deep(.structured-editor:not(.toolbar-hover):has(.cm-focused) .structured-editor-host),
147
+ .code-editor-container:not(.frame):not(.bgl-outline):not(.terminal):not(.single-line) > :deep(.structured-editor.toolbar-hover:has(.cm-focused)) {
148
+ outline: solid 1px var(--bgl-border-color, #4f575f);
149
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.13);
145
150
  }
146
151
  .code-editor-container.single-line {
147
152
  height: auto;
@@ -156,6 +161,7 @@ watch(() => props.modelValue, value => {
156
161
  }
157
162
  .single-line :deep(.cm-content) {
158
163
  padding-block: 0;
164
+ padding-inline: 0.7rem;
159
165
  line-height: var(--bgl-input-height);
160
166
  }
161
167
  .code-editor-container.terminal {
@@ -167,7 +173,19 @@ watch(() => props.modelValue, value => {
167
173
  border: 1px solid var(--bgl-border-color);
168
174
  border-radius: calc(var(--bgl-radius, 6px) * 2);
169
175
  }
170
- .code-terminal-bar {
171
- background: rgba(255, 255, 255, 0.04);
176
+ /* Let the terminal shell paint the surface — don't leave Atom One's panel bg. */
177
+ .terminal > :deep(.structured-editor),
178
+ .terminal :deep(.cm-editor),
179
+ .terminal :deep(.cm-gutters),
180
+ .terminal :deep(.cm-gutterElement),
181
+ .terminal :deep(.cm-activeLineGutter) {
182
+ background: transparent !important;
183
+ }
184
+ .terminal > :deep(.structured-editor) {
185
+ border-radius: 0;
186
+ color: inherit;
187
+ }
188
+ .terminal :deep(.cm-content) {
189
+ padding: 0.75rem;
172
190
  }
173
191
  </style>
@@ -24,6 +24,15 @@ const props = defineProps<{
24
24
  placeholder: string
25
25
  label: string
26
26
  dark: boolean
27
+ terminal?: boolean
28
+ /** Shown in the terminal title bar. */
29
+ title?: string
30
+ /**
31
+ * `bar` (default) — language label + actions always visible above the editor.
32
+ * `hover` — immersive surface; chrome appears on hover/focus.
33
+ * Terminal mode always uses the title-bar row for chrome.
34
+ */
35
+ toolbarMode?: 'bar' | 'hover'
27
36
  }>()
28
37
  const emit = defineEmits<{
29
38
  'update:modelValue': [value: string]
@@ -40,6 +49,10 @@ let copyTimer: ReturnType<typeof setTimeout> | undefined
40
49
  const languageNames: Record<string, string> = { javascript: 'JS', typescript: 'TS' }
41
50
  const languageLabel = computed(() => languageNames[props.language] || props.language.toUpperCase())
42
51
  const canFormat = computed(() => props.formatting && !props.singleLine && supportsFormatting(props.language))
52
+ const toolbarMode = computed(() => props.toolbarMode ?? 'bar')
53
+ const hoverToolbar = computed(() => !props.terminal && toolbarMode.value === 'hover')
54
+ const toolbarPinned = computed(() => formattingBusy.value || copied.value || Boolean(formatError.value || copyError.value))
55
+ const showToolbar = computed(() => !props.singleLine)
43
56
  const config = new Compartment()
44
57
  const languageConfig = new Compartment()
45
58
  const externalUpdate = Annotation.define<boolean>()
@@ -94,6 +107,7 @@ function createSearchPanel(editor: EditorView) {
94
107
  }
95
108
 
96
109
  function extensions(): Extension[] {
110
+ const contentPad = props.singleLine ? '0' : '0.75em 1ch 1.5em 2ch'
97
111
  return [
98
112
  props.dark ? atomone : atomLight,
99
113
  props.lineNumbers && !props.singleLine ? numberGutter() : [],
@@ -107,10 +121,30 @@ function extensions(): Extension[] {
107
121
  }),
108
122
  editorPlaceholder(props.placeholder),
109
123
  EditorView.theme({
110
- '&': { height: '100%' },
111
- '.cm-scroller': { overflow: 'auto', fontFamily: 'inherit', lineHeight: '1.5' },
112
- '.cm-content': { padding: '8px 0' },
124
+ '&': {
125
+ height: '100%',
126
+ ...(props.terminal ? { backgroundColor: 'transparent' } : {}),
127
+ },
128
+ '.cm-scroller': {
129
+ overflow: 'auto',
130
+ fontFamily: 'inherit',
131
+ lineHeight: '1.5',
132
+ overscrollBehavior: 'contain',
133
+ },
134
+ '.cm-content': {
135
+ padding: contentPad,
136
+ fontVariantLigatures: 'none',
137
+ tabSize: 2,
138
+ caretColor: props.dark ? '#fff' : '#1b1f23',
139
+ },
140
+ '.cm-gutters': props.terminal
141
+ ? { backgroundColor: 'transparent', border: 'none' }
142
+ : {},
143
+ '.cm-activeLineGutter': props.terminal ? { backgroundColor: 'transparent' } : {},
113
144
  '&.cm-focused': { outline: 'none' },
145
+ '.cm-selectionBackground, &.cm-focused .cm-selectionBackground': {
146
+ backgroundColor: props.dark ? 'rgba(36, 102, 188, 0.35)' : 'rgba(36, 102, 188, 0.3)',
147
+ },
114
148
  }, { dark: props.dark }),
115
149
  ]
116
150
  }
@@ -215,7 +249,7 @@ watch(() => props.modelValue, value => {
215
249
  })
216
250
  })
217
251
  watch(() => props.language, requestLanguage)
218
- watch(() => [props.lineNumbers, props.folding, props.readonly, props.disabled, props.wrap, props.singleLine, props.placeholder, props.label, props.dark], () => {
252
+ watch(() => [props.lineNumbers, props.folding, props.readonly, props.disabled, props.wrap, props.singleLine, props.placeholder, props.label, props.dark, props.terminal], () => {
219
253
  view?.dispatch({ effects: config.reconfigure(extensions()) })
220
254
  })
221
255
  onBeforeUnmount(() => {
@@ -227,40 +261,144 @@ onBeforeUnmount(() => {
227
261
  </script>
228
262
 
229
263
  <template>
230
- <div class="structured-editor monospace">
231
- <div v-if="!singleLine" class="flex flex-shrink-0 align-items-center space-between gap-05 px-075 py-025">
232
- <span class="txt11 opacity-5" aria-label="Code language">{{ languageLabel }}</span>
233
- <div class="flex align-items-center gap-025">
264
+ <div
265
+ class="structured-editor"
266
+ :class="{
267
+ terminal,
268
+ 'toolbar-hover': hoverToolbar,
269
+ 'toolbar-pinned': toolbarPinned,
270
+ 'single-line': singleLine,
271
+ }"
272
+ >
273
+ <!-- Terminal: language + actions live in the title bar -->
274
+ <div
275
+ v-if="terminal && showToolbar"
276
+ class="code-terminal-bar monospace flex flex-shrink-0 space-between gap-05 py-025 px-075 txt11 line-height-1 border-bottom"
277
+ >
278
+ <div class="flex gap-05 min-w-0">
279
+ <span class="inline-flex gap-025 flex-shrink-0" aria-hidden="true">
280
+ <span class="square-10 round bg-red" />
281
+ <span class="square-10 round bg-yellow" />
282
+ <span class="square-10 round bg-green" />
283
+ </span>
284
+ <span v-if="title" class="opacity-5 ellipsis-1">{{ title }}</span>
285
+ </div>
286
+ <div class="flex align-items-center gap-025 flex-shrink-0">
287
+ <span class="opacity-5 px-05" aria-label="Code language">{{ languageLabel }}</span>
234
288
  <Btn
235
289
  v-if="canFormat" v-tooltip="formattingBusy ? 'Formatting…' : 'Format code'" thin flat
290
+ icon-size="1"
236
291
  icon="format_align_left" aria-label="Format code" :aria-busy="formattingBusy"
237
292
  :disabled="readonly || disabled || formattingBusy" @click="format"
238
293
  />
239
294
  <Btn
240
295
  v-tooltip="copied ? 'Copied!' : 'Copy code'" thin flat
296
+ icon-size="1"
241
297
  :icon="copied ? 'check' : 'content_copy'" :aria-label="copied ? 'Copied!' : 'Copy code'"
242
298
  @click="copy"
243
299
  />
244
300
  <span class="hide" role="status">{{ copied ? 'Copied to clipboard' : '' }}</span>
245
301
  </div>
246
302
  </div>
247
- <span v-if="formatError || copyError" role="alert" class="txt12 color-red px-075">{{ formatError || copyError }}</span>
303
+
304
+ <!-- Bar / hover chrome. With a form label: label · language · actions share one row above the input. -->
305
+ <div
306
+ v-else-if="showToolbar"
307
+ class="code-toolbar flex flex-shrink-0 align-items-center space-between gap-05 py-025"
308
+ >
309
+ <label v-if="label && !hoverToolbar" class="label mb-0">{{ label }}</label>
310
+ <span v-else class="txt11 opacity-5" aria-label="Code language">{{ languageLabel }}</span>
311
+ <div class="flex align-items-center gap-025 ms-auto">
312
+ <span v-if="label && !hoverToolbar" class="txt11 opacity-5 px-05" aria-label="Code language">{{ languageLabel }}</span>
313
+ <Btn
314
+ v-if="canFormat" v-tooltip="formattingBusy ? 'Formatting…' : 'Format code'" thin flat
315
+ icon-size="1"
316
+ icon="format_align_left" aria-label="Format code" :aria-busy="formattingBusy"
317
+ :disabled="readonly || disabled || formattingBusy" @click="format"
318
+ />
319
+ <Btn
320
+ v-tooltip="copied ? 'Copied!' : 'Copy code'" thin flat icon-size="1"
321
+ :icon="copied ? 'check' : 'content_copy'" :aria-label="copied ? 'Copied!' : 'Copy code'"
322
+ @click="copy"
323
+ />
324
+ <span class="hide" role="status">{{ copied ? 'Copied to clipboard' : '' }}</span>
325
+ </div>
326
+ </div>
327
+
328
+ <span v-if="formatError || copyError" role="alert" class="code-alert txt12 color-red px-075">{{ formatError || copyError }}</span>
248
329
  <div ref="host" class="structured-editor-host" />
249
330
  </div>
250
331
  </template>
251
332
 
252
333
  <style scoped>
253
334
  .structured-editor {
335
+ position: relative;
254
336
  display: flex;
255
337
  flex-direction: column;
256
338
  height: 100%;
257
339
  min-height: 0;
258
340
  max-height: var(--code-max-height, none);
259
341
  overflow: hidden;
342
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
343
+ font-variant-ligatures: none;
260
344
  }
261
345
  .structured-editor-host {
262
346
  flex: 1;
263
347
  min-height: 0;
264
348
  overflow: auto;
265
349
  }
350
+ /* Bar mode: chrome (label/language/actions) sits above; the code surface is the rounded input. */
351
+ .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
352
+ border-radius: var(--code-border-radius, 0.25rem);
353
+ overflow: hidden;
354
+ }
355
+ /* Hover / single-line: round the whole editor shell (chrome overlays or is absent). */
356
+ .toolbar-hover,
357
+ .structured-editor.single-line {
358
+ border-radius: var(--code-border-radius, 0.25rem);
359
+ }
360
+ .structured-editor.single-line {
361
+ border-radius: var(--bgl-input-border-radius);
362
+ }
363
+ .code-terminal-bar {
364
+ background: rgba(255, 255, 255, 0.04);
365
+ }
366
+ /* Default: always-visible chrome above the editor. */
367
+ .code-toolbar {
368
+ position: relative;
369
+ z-index: 1;
370
+ }
371
+ /* Optional immersive mode: overlay chrome until hover/focus. */
372
+ .toolbar-hover .code-toolbar {
373
+ position: absolute;
374
+ inset-block-start: 0;
375
+ inset-inline: 0;
376
+ z-index: 3;
377
+ opacity: 0;
378
+ padding-inline: 0.5rem;
379
+ pointer-events: none;
380
+ transition: opacity 0.15s ease;
381
+ background: linear-gradient(
382
+ to bottom,
383
+ color-mix(in srgb, var(--bgl-box-bg, #fff) 92%, transparent),
384
+ color-mix(in srgb, var(--bgl-box-bg, #fff) 55%, transparent),
385
+ transparent
386
+ );
387
+ }
388
+ .toolbar-hover:hover .code-toolbar,
389
+ .toolbar-hover:focus-within .code-toolbar,
390
+ .toolbar-hover.toolbar-pinned .code-toolbar {
391
+ opacity: 1;
392
+ pointer-events: auto;
393
+ }
394
+ .code-alert {
395
+ position: relative;
396
+ z-index: 2;
397
+ }
398
+ .toolbar-hover .code-alert {
399
+ position: absolute;
400
+ inset-block-start: 2rem;
401
+ inset-inline: 0;
402
+ z-index: 3;
403
+ }
266
404
  </style>
@@ -428,10 +428,13 @@ background: var(--bgl-selected);
428
428
  <style>
429
429
 
430
430
  /* Unscoped: `.selectinput` is applied via Dropdown $attrs on an inner node,
431
- so scoped selectors (which require this SFC's data-v attr) never match it. */
431
+ so scoped selectors (which require this SFC's data-v attr) never match it.
432
+ `width: auto` overrides `.bagel-input { width: 100% }`:
433
+ - block/grid/stretched parents → still fills the slot (forms)
434
+ - flex row with no grow → hugs content (Pagination) */
432
435
  .bagel-input.selectinput,
433
436
  .selectinput {
434
- width: 100%;
437
+ width: auto;
435
438
  min-width: 0;
436
439
  max-width: 100%;
437
440
  }
@@ -464,10 +467,9 @@ font-family: inherit;
464
467
  font-size: var(--bgl-input-font-size);
465
468
  }
466
469
 
467
- /* width: 0 + flex-grow makes the label take only leftover space and ellipsize */
470
+ /* Grow into free space when the field is wide; shrink + ellipsize when constrained */
468
471
  .selectinput-btn__label {
469
- width: 0;
470
- flex: 1 1 0%;
472
+ flex: 1 1 auto;
471
473
  min-width: 0;
472
474
  margin: 0;
473
475
  white-space: nowrap;
@@ -480,7 +482,6 @@ text-align: start;
480
482
  display: inline-flex;
481
483
  align-items: center;
482
484
  flex-shrink: 0;
483
- margin-inline-start: auto;
484
485
  }
485
486
 
486
487
  .selectinput-btn__icon,
@@ -372,9 +372,10 @@
372
372
  .bgl-dark-mode .bagel-input.underlined textarea,
373
373
  .bgl-dark-mode .bagel-input.underlined select,
374
374
  .bgl-dark-mode .bagel-input.frame .selectinput-btn,
375
- /* CodeEditor: the inner textarea is transparent/overlaid — its frame must
376
- come only from .code-editor-grandpa, not from the generic input ring. */
377
- .bgl-dark-mode .bagel-input .code-input {
375
+ /* CodeEditor: legacy overlay textarea + new CodeMirror surface — frame/focus
376
+ come from .code-editor-grandpa / .structured-editor, not the generic input ring. */
377
+ .bgl-dark-mode .bagel-input .code-input,
378
+ .bgl-dark-mode .bagel-input .cm-editor {
378
379
  box-shadow: none;
379
380
  }
380
381
 
@@ -303,14 +303,23 @@ select {
303
303
 
304
304
  /* colorInputPickWrap variants handled in ColorInput.vue */
305
305
 
306
- .bagel-input.frame .code-editor-grandpa {
306
+ .bagel-input.frame .code-editor-grandpa,
307
+ .bagel-input.frame .structured-editor.toolbar-hover,
308
+ .bagel-input.frame .structured-editor.single-line,
309
+ .bagel-input.frame .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
307
310
  outline: 1.5px solid var(--bgl-border-color);
308
311
  outline-offset: -1px;
309
312
  border-radius: var(--bgl-input-border-radius);
313
+ transition: outline-color 0.2s ease, box-shadow 0.2s ease;
310
314
  }
311
315
 
312
- .bagel-input.frame:focus-within .code-editor-grandpa {
316
+ /* Legacy overlay textarea still uses :focus-within; CodeMirror uses .cm-focused so Copy/Format don't light the ring. */
317
+ .bagel-input.frame:focus-within .code-editor-grandpa,
318
+ .bagel-input.frame:has(.cm-focused) .structured-editor.toolbar-hover,
319
+ .bagel-input.frame:has(.cm-focused) .structured-editor.single-line,
320
+ .bagel-input.frame:has(.cm-focused) .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
313
321
  outline-color: var(--bgl-input-label-active-color, var(--bgl-primary));
322
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--bgl-input-label-active-color, var(--bgl-primary)) 12%, transparent);
314
323
  }
315
324
 
316
325
  .bagel-input.frame .rich-text-editor {