@meistrari/tela-build 1.75.2 → 1.77.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Latest updates and announcements.
4
4
 
5
+ ## September 24, 2026
6
+
7
+ - [Floating chat](/templates/chat#floating): Escape now closes the topmost overlay before the chat. `TelaDialog`, `TelaModal`, `TelaSheet` and `TelaSideSheet` overlays carry `data-tela-escape-layer`, and [Dropdown Menu](/components/dropdown-menu) content has a new `escapeLayer` prop that adds the marker (`TelaDropdownMenu` sets it).
8
+ - [Floating chat](/templates/chat#floating) adds `keepMounted` (default `false`); set it to `true` to hide the window on close instead of unmounting it, so polling and other work inside it keep running.
9
+
5
10
  ## September 22, 2026
6
11
 
7
12
  - [Prompt Input](/templates/chat#prompt-input) adapts to its shell: inside `TelaChatFloatingWindow` and `TelaChatSidepanelWindow` it uses a 12px radius and 8px right padding, and the action menu trigger stays inline. On full-page chats it keeps the 16px radius and pulls the trigger flush with the editor.
@@ -147,6 +147,8 @@ A launcher pill fixed to the bottom-right corner opens the chat in an anchored p
147
147
 
148
148
  The window opens over its own launcher: the surface springs out of the launcher's box (and shrinks back into it on close) while the conversation is revealed in place, pinned to the shared bottom-right corner. The launcher fades out while the window is open and returns as the surface settles. The scroll lock is released only after the exit finishes, so the scrollbar coming back never shifts the window mid-animation.
149
149
 
150
+ By default, closing unmounts the content. Set `keepMounted` to hide it instead after the first open, so background work inside, like chat polling, keeps running and the conversation keeps its state. Nothing mounts until the first open.
151
+
150
152
  The widget header inside the window gets two extra actions automatically: **expand** grows the window until 8px from the top of the viewport (and back), and **minimize** closes it. See [Widget Header & History](#widget-header--history).
151
153
 
152
154
  ```vue
@@ -1511,6 +1513,7 @@ type FloatingWindowProps = {
1511
1513
  open: boolean
1512
1514
  contained?: boolean // anchor the launcher to the nearest positioned ancestor instead of the viewport
1513
1515
  triggerLabel?: string // label of the default trigger; ignored when #launcher is provided
1516
+ keepMounted?: boolean // defaults to false; keeps the content mounted (hidden) after the first open
1514
1517
  }
1515
1518
  // emits: update:open(value: boolean)
1516
1519
 
@@ -1637,9 +1640,11 @@ type TextShimmerProps = {
1637
1640
  - **Keep the primitives logic-free.** Fetch, stream, and persist in the host; pass results down as props and slots. No primitive owns message state.
1638
1641
  - **`contained` for user messages, `flat` for assistant messages.** Assistant output reads as page text; user input reads as a sent bubble.
1639
1642
  - **Never hand-roll the toolbar layout.** `TelaChatPromptInputTools` (attachment actions) on the left, `TelaChatPromptInputActions` with `TelaChatModelSelector` + `TelaChatPromptSubmitButton` on the right. Always the same order; never substitute a raw `<div class="flex items-center gap-4px">`.
1643
+ - **Floating chat dismissal.** Outside clicks close the chat by default; set `closeOnOutsideClick` to `false` to keep it open while using the host page. Focus changes keep it open. Close it using the launcher toggle or Escape. Components guaranteed to render above the shared widget layer (`z-599`) must mark their open overlay or content with `data-tela-escape-layer`; Escape then closes that layer before the chat. Never add the marker to a surface at or below the widget layer.
1640
1644
  - **`TelaChatAnswer` never talks to the server.** Parsing the model's questions, limits on how many questions or options to ask, saved answers, retries and what happens after the last question all live in the host (or its adapter). Every event is intent only; `dismiss` does not remove the card.
1641
1645
  - **Dock the active answer card above the prompt input.** Put both inside one `[data-chat-composer]` wrapper with a 12px gap so `TelaChatBody` pins and measures them together. Only one card should be interactive at a time, especially when sharing a `keyboardTarget`.
1642
1646
  - **One shell per page.** Never mount `TelaChatFloatingWindow` and `TelaChatSidepanelWindow` at the same time.
1647
+ - **Keep the floating shell on the shared widget layer.** The launcher and popover use `z-599`, above full-screen editor panes and below modal overlays (`z-600` and higher). Do not lower either half independently or the launcher can become visible but unclickable.
1643
1648
  - **Always wrap the conversation and prompt input in `TelaChatBody`.** It owns the spacing and pins the prompt input to the bottom, and messages scroll under it through a progressive blur. `variant="widget"` (default) inside the floating/sidepanel shells, `variant="page"` on full pages. Never re-add spacing or positioning classes to `TelaChatConversation` or `TelaChatPromptInput`.
1644
1649
  - **The `#launcher` slot is optional; when provided it must be exactly one element.** It is an anchor, not a container; omit it to get the default `TelaChatFloatingWindowTrigger`.
1645
1650
  - **`TelaChatSidepanelWindow` goes last in a flex row.** It is in-flow (`position: sticky`), so the row reserves its width; never absolutely position it over the page.
@@ -0,0 +1,182 @@
1
+ // @vitest-environment happy-dom
2
+ import { mount } from '@vue/test-utils'
3
+ import { PopoverRoot, PopoverTrigger } from 'reka-ui'
4
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, ref, watch } from 'vue'
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
6
+ import TelaPopoverContent from '../../popover/popover-content.vue'
7
+ import FloatingWindow from './floating-window.vue'
8
+
9
+ const cn = (...values: unknown[]) => values.filter(Boolean).join(' ')
10
+
11
+ vi.stubGlobal('cn', cn)
12
+ vi.stubGlobal('computed', computed)
13
+ vi.stubGlobal('nextTick', nextTick)
14
+ vi.stubGlobal('onBeforeUnmount', onBeforeUnmount)
15
+ vi.stubGlobal('onMounted', onMounted)
16
+ vi.stubGlobal('provide', provide)
17
+ vi.stubGlobal('ref', ref)
18
+ vi.stubGlobal('watch', watch)
19
+
20
+ const lifecycle = { mounted: 0, unmounted: 0 }
21
+ const mounted: Array<{ unmount: () => void }> = []
22
+
23
+ const ChatBody = defineComponent({
24
+ setup() {
25
+ onMounted(() => lifecycle.mounted++)
26
+ onUnmounted(() => lifecycle.unmounted++)
27
+
28
+ return () => h('div', { 'data-chat-prompt-input': '' }, [h('textarea', { 'data-testid': 'editor' })])
29
+ },
30
+ })
31
+
32
+ function mountWindow(props: { open: boolean, keepMounted?: boolean }) {
33
+ const wrapper = mount(FloatingWindow, {
34
+ props,
35
+ slots: { default: () => h(ChatBody) },
36
+ attachTo: document.body,
37
+ global: {
38
+ mocks: { cn },
39
+ components: {
40
+ TelaPopover: PopoverRoot,
41
+ TelaPopoverTrigger: PopoverTrigger,
42
+ TelaPopoverContent,
43
+ },
44
+ stubs: {
45
+ Motion: defineComponent({ setup: (_, { slots }) => () => h('div', slots.default?.()) }),
46
+ TelaChatFloatingWindowTrigger: defineComponent({ setup: () => () => h('button', { 'data-testid': 'launcher' }) }),
47
+ },
48
+ },
49
+ })
50
+
51
+ mounted.push(wrapper)
52
+
53
+ return wrapper
54
+ }
55
+
56
+ function content() {
57
+ return document.querySelector<HTMLElement>('.widget-popover')
58
+ }
59
+
60
+ describe('floating chat window', () => {
61
+ beforeEach(() => {
62
+ vi.useFakeTimers()
63
+ lifecycle.mounted = 0
64
+ lifecycle.unmounted = 0
65
+ })
66
+
67
+ afterEach(() => {
68
+ mounted.splice(0).forEach(wrapper => wrapper.unmount())
69
+ vi.useRealTimers()
70
+ document.body.innerHTML = ''
71
+ })
72
+
73
+ it('does not mount the content before the first open', () => {
74
+ // Arrange & Act
75
+ mountWindow({ open: false, keepMounted: true })
76
+
77
+ // Assert
78
+ expect(content()).toBeNull()
79
+ expect(lifecycle.mounted).toBe(0)
80
+ })
81
+
82
+ it('keeps the content mounted and hides it after the exit animation', async () => {
83
+ // Arrange
84
+ const wrapper = mountWindow({ open: true, keepMounted: true })
85
+ await nextTick()
86
+
87
+ // Act
88
+ await wrapper.setProps({ open: false })
89
+ const hiddenDuringExit = content()?.hasAttribute('data-content-hidden')
90
+ vi.advanceTimersByTime(380)
91
+ await nextTick()
92
+
93
+ // Assert
94
+ expect(hiddenDuringExit).toBe(false)
95
+ expect(content()?.dataset.state).toBe('closed')
96
+ expect(content()?.hasAttribute('data-content-hidden')).toBe(true)
97
+ expect(lifecycle).toEqual({ mounted: 1, unmounted: 0 })
98
+ })
99
+
100
+ it('reuses the same content instance when reopened', async () => {
101
+ // Arrange
102
+ const wrapper = mountWindow({ open: true, keepMounted: true })
103
+ await nextTick()
104
+ await wrapper.setProps({ open: false })
105
+ vi.advanceTimersByTime(380)
106
+ await nextTick()
107
+ await nextTick()
108
+
109
+ // Act
110
+ await wrapper.setProps({ open: true })
111
+ await nextTick()
112
+
113
+ // Assert
114
+ expect(content()?.dataset.state).toBe('open')
115
+ expect(content()?.hasAttribute('data-content-hidden')).toBe(false)
116
+ expect(lifecycle).toEqual({ mounted: 1, unmounted: 0 })
117
+ })
118
+
119
+ it('returns focus to the launcher when closing from inside', async () => {
120
+ // Arrange
121
+ const wrapper = mountWindow({ open: true, keepMounted: true })
122
+ await nextTick()
123
+ document.querySelector<HTMLElement>('[data-testid="editor"]')?.focus()
124
+
125
+ // Act
126
+ await wrapper.setProps({ open: false })
127
+
128
+ // Assert
129
+ expect(document.activeElement?.getAttribute('data-testid')).toBe('launcher')
130
+ })
131
+
132
+ it('focuses the editor when reopened', async () => {
133
+ // Arrange
134
+ const wrapper = mountWindow({ open: true, keepMounted: true })
135
+ await nextTick()
136
+ await wrapper.setProps({ open: false })
137
+ vi.advanceTimersByTime(380)
138
+ await nextTick()
139
+ const outside = document.body.appendChild(document.createElement('button'))
140
+ outside.focus()
141
+
142
+ // Act
143
+ await wrapper.setProps({ open: true })
144
+ await nextTick()
145
+
146
+ // Assert
147
+ expect(document.activeElement?.getAttribute('data-testid')).toBe('editor')
148
+ })
149
+
150
+ it('does not re-emit a close while already closed', async () => {
151
+ // Arrange
152
+ const wrapper = mountWindow({ open: true, keepMounted: true })
153
+ await nextTick()
154
+ await wrapper.setProps({ open: false })
155
+ vi.advanceTimersByTime(380)
156
+ await nextTick()
157
+ await nextTick()
158
+
159
+ // Act
160
+ document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
161
+ await nextTick()
162
+
163
+ // Assert
164
+ expect(wrapper.emitted('update:open')).toBeUndefined()
165
+ })
166
+
167
+ it('unmounts the content on close by default', async () => {
168
+ // Arrange
169
+ const wrapper = mountWindow({ open: true })
170
+ await nextTick()
171
+
172
+ // Act
173
+ await wrapper.setProps({ open: false })
174
+ // reka's Presence waits a tick before unmounting content with no exit animation
175
+ await nextTick()
176
+ await nextTick()
177
+
178
+ // Assert
179
+ expect(content()).toBeNull()
180
+ expect(lifecycle).toEqual({ mounted: 1, unmounted: 1 })
181
+ })
182
+ })
@@ -11,6 +11,8 @@ const props = withDefaults(defineProps<{
11
11
  contained?: boolean
12
12
  /** Label of the default trigger, ignored when the `launcher` slot is provided. */
13
13
  triggerLabel?: string
14
+ /** Keep the content mounted (hidden) after the first open, so background work inside it, like chat polling, survives closing the window. */
15
+ keepMounted?: boolean
14
16
  }>(), {
15
17
  closeOnOutsideClick: true,
16
18
  })
@@ -118,6 +120,11 @@ function handleEscapeKeyDown() {
118
120
  }
119
121
 
120
122
  function handleOpenUpdate(value: boolean) {
123
+ // A kept-mounted window stays a dismissable layer while closed, so Escape
124
+ // and outside interactions still reach it; there is nothing left to close.
125
+ if (!value && !props.open)
126
+ return
127
+
121
128
  if (!value && deferNextDismissal) {
122
129
  deferNextDismissal = false
123
130
  return
@@ -179,6 +186,7 @@ function unlockScroll() {
179
186
  const exitHoldMs = 380
180
187
 
181
188
  let unlockTimer: ReturnType<typeof setTimeout> | undefined
189
+ let hideTimer: ReturnType<typeof setTimeout> | undefined
182
190
 
183
191
  watch(() => props.open, (open) => {
184
192
  if (typeof document === 'undefined')
@@ -197,19 +205,58 @@ watch(() => props.open, (open) => {
197
205
 
198
206
  onBeforeUnmount(() => {
199
207
  clearTimeout(unlockTimer)
208
+ clearTimeout(hideTimer)
200
209
  unlockScroll()
201
210
  })
202
211
 
212
+ const hasOpened = ref(props.open)
213
+ const contentHidden = ref(false)
214
+ const forceMountContent = computed(() => props.keepMounted && hasOpened.value)
215
+
216
+ // Kept-mounted content never remounts, so reka's open/close auto-focus does not
217
+ // fire again: focus the editor on reopen and hand focus back to the launcher on close.
218
+ watch(() => props.open, (open) => {
219
+ clearTimeout(hideTimer)
220
+
221
+ if (open) {
222
+ const reopening = forceMountContent.value
223
+
224
+ hasOpened.value = true
225
+ contentHidden.value = false
226
+
227
+ if (reopening && shellEl.value)
228
+ focusEditorIn(shellEl.value)
229
+
230
+ return
231
+ }
232
+
233
+ if (!forceMountContent.value)
234
+ return
235
+
236
+ if (shellEl.value?.contains(document.activeElement))
237
+ launcher.value?.querySelector<HTMLElement>('[aria-haspopup]')?.focus()
238
+
239
+ hideTimer = setTimeout(() => {
240
+ contentHidden.value = true
241
+ }, exitHoldMs)
242
+ })
243
+
203
244
  function focusEditor(event: Event) {
204
245
  event.preventDefault()
205
246
 
247
+ const content = event.target instanceof HTMLElement
248
+ ? event.target
249
+ : document.querySelector<HTMLElement>('.widget-popover')
250
+
251
+ if (content)
252
+ focusEditorIn(content)
253
+ }
254
+
255
+ function focusEditorIn(content: HTMLElement) {
206
256
  nextTick(() => {
207
- const content = event.target instanceof HTMLElement
208
- ? event.target
209
- : document.querySelector('.widget-popover')
210
- const editor = Array.from(content?.querySelectorAll<HTMLElement>(
257
+ const editor = Array.from(content.querySelectorAll<HTMLElement>(
211
258
  '[data-prompt-editor] [contenteditable="true"], [data-chat-prompt-input] input:not(:disabled), [data-chat-prompt-input] textarea:not(:disabled), [data-chat-answer] input:not(:disabled), [data-chat-answer] textarea:not(:disabled)',
212
- ) ?? []).find(element => element.getClientRects().length > 0)
259
+ )).find(element => element.getClientRects().length > 0)
213
260
 
214
261
  if (!editor)
215
262
  return
@@ -250,6 +297,8 @@ function focusEditor(event: Event) {
250
297
  side="top"
251
298
  align="end"
252
299
  :side-offset="sideOffset"
300
+ :force-mount="forceMountContent"
301
+ :data-content-hidden="contentHidden || undefined"
253
302
  :class="cn(
254
303
  'widget-popover relative w-[min(480px,calc(100vw-32px))] p-0 z-599! transition-[height] duration-200 ease-out',
255
304
  expanded
@@ -292,6 +341,12 @@ function focusEditor(event: Event) {
292
341
  animation: widgetShellHoldOut 0.38s linear both;
293
342
  }
294
343
 
344
+ /* After the exit animation, kept-mounted content stops painting, taking focus and catching clicks. */
345
+ [data-reka-popper-content-wrapper]:has(> .widget-popover[data-content-hidden]) {
346
+ visibility: hidden;
347
+ pointer-events: none;
348
+ }
349
+
295
350
  @keyframes widgetShellHoldOut {
296
351
  from { opacity: 1; }
297
352
  to { opacity: 1; }
@@ -54,7 +54,7 @@ const modalMaxWidth = computed(() => {
54
54
  <template>
55
55
  <DialogRoot v-model:open="open">
56
56
  <DialogPortal>
57
- <DialogOverlay :class="`DialogOverlay ${overlayClass ?? ''}`" bg="bg-#020913/24" z-600 overflow-y-auto flex items-center justify-center :p-16px="!fullscreen">
57
+ <DialogOverlay data-tela-escape-layer :class="`DialogOverlay ${overlayClass ?? ''}`" bg="bg-#020913/24" z-600 overflow-y-auto flex items-center justify-center :p-16px="!fullscreen">
58
58
  <DialogContent
59
59
  :class="`DialogContent shadow-xl ${modalMaxWidth ?? ''}`"
60
60
  z-101
@@ -78,6 +78,7 @@ function onToggle(open: boolean) {
78
78
  </DropdownMenuTrigger>
79
79
 
80
80
  <DropdownMenuContent
81
+ escape-layer
81
82
  :align="align"
82
83
  :side-offset="sideOffset"
83
84
  :class="cn('min-w-128px! z-605!', contentClass)"
@@ -9,7 +9,7 @@ import { computed } from 'vue'
9
9
  import type { HTMLAttributes } from 'vue'
10
10
 
11
11
  const props = withDefaults(
12
- defineProps<DropdownMenuContentProps & { class?: HTMLAttributes['class'] }>(),
12
+ defineProps<DropdownMenuContentProps & { class?: HTMLAttributes['class'], escapeLayer?: boolean }>(),
13
13
  {
14
14
  sideOffset: 4,
15
15
  },
@@ -17,7 +17,7 @@ const props = withDefaults(
17
17
  const emits = defineEmits<DropdownMenuContentEmits>()
18
18
 
19
19
  const delegatedProps = computed(() => {
20
- const { class: _, ...delegated } = props
20
+ const { class: _, escapeLayer: _escapeLayer, ...delegated } = props
21
21
 
22
22
  return delegated
23
23
  })
@@ -28,6 +28,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
28
28
  <template>
29
29
  <DropdownMenuPortal>
30
30
  <DropdownMenuContent
31
+ :data-tela-escape-layer="escapeLayer ? '' : undefined"
31
32
  v-bind="forwarded"
32
33
  :class="cn('DropdownMenuContent popover-enter-exit z-50 min-w-60 overflow-hidden rounded-2xl border-[0.5px] border-gray-300 bg-white-1000 p-1 shadow-sm', props.class)"
33
34
  >
@@ -85,7 +85,7 @@ function handlePointerDownOutside(event: any) {
85
85
  <template>
86
86
  <DialogRoot v-model:open="open">
87
87
  <DialogPortal>
88
- <DialogOverlay :class="`DialogOverlay ${overlayClass ?? ''}`" bg="#000/35" z-600 overflow-y-auto flex items-center justify-center :p-16px="!fullscreen">
88
+ <DialogOverlay data-tela-escape-layer :class="`DialogOverlay ${overlayClass ?? ''}`" bg="#000/35" z-600 overflow-y-auto flex items-center justify-center :p-16px="!fullscreen">
89
89
  <DialogContent
90
90
  :data-animation="hideEnterAnimation"
91
91
  :class="cn('DialogContent shadow-xl', modalMaxWidth, dialogContentClass)"
@@ -39,6 +39,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
39
39
  <template>
40
40
  <DialogPortal>
41
41
  <DialogOverlay
42
+ data-tela-escape-layer
42
43
  class="fixed inset-0 z-999 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
43
44
  />
44
45
  <DialogContent
@@ -17,7 +17,7 @@ defineOptions({
17
17
  })
18
18
 
19
19
  const props = defineProps<{
20
- title?: string,
20
+ title?: string
21
21
  modalWidth?: 'md' | 'lg'
22
22
  compact?: boolean
23
23
  fullscreen?: boolean
@@ -66,7 +66,7 @@ function handlePointerDownOutside(event: any) {
66
66
  <template>
67
67
  <DialogRoot v-model:open="open">
68
68
  <DialogPortal>
69
- <DialogOverlay class="DialogOverlay" :class="overlayClass" bg="gray-700/70" z-600>
69
+ <DialogOverlay data-tela-escape-layer class="DialogOverlay" :class="overlayClass" bg="gray-700/70" z-600>
70
70
  <DialogContent
71
71
  z-101
72
72
  relative w-full flex="~ col"
@@ -31,7 +31,7 @@ watch(open, (value) => {
31
31
  <template>
32
32
  <DialogRoot v-model:open="open">
33
33
  <DialogPortal>
34
- <DialogOverlay class="DialogOverlay" :class="overlayClass" bg="gray-700/70" z-600>
34
+ <DialogOverlay data-tela-escape-layer class="DialogOverlay" :class="overlayClass" bg="gray-700/70" z-600>
35
35
  <DialogContent
36
36
  :class="`DialogContent ${$attrs?.class}`"
37
37
  z-101
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-build",
3
- "version": "1.75.2",
3
+ "version": "1.77.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "app.config.ts",