@meistrari/tela-build 1.87.3 → 1.89.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,11 +2,30 @@
2
2
 
3
3
  Latest updates and announcements.
4
4
 
5
+ ## October 16, 2026
6
+
7
+ - [Input](/components/input) drops the `showDescription` prop and `description` slot. Put content on the right of the field with the `trailing` slot.
8
+ - [Input](/components/input) no longer has a clear button. The `showClearButton` and `clearLabel` props are removed.
9
+ - [Input](/components/input) no longer renders a label above the value. The `label`, `hideLabel`, and `labelClass` props and the `label-leading` slot are removed.
10
+ - [Input](/components/input#with-error) shows `error` as a warning icon on the right of the field, with the message in a tooltip that opens on hover and while the field has focus, instead of a line of text under the field. Screen readers announce the message through `aria-description`, and the input sets `aria-invalid`.
11
+ - [Video Player](/components/video-player#exposed-methods) exposes `seekTo(seconds)` and `play()` through a template ref, so outside controls like a chapter list can jump to a moment and start playback. It also emits `timeupdate` with the current time in seconds, so those controls can follow along as the video plays.
12
+ - [Video Player](/components/video-player) corners no longer show a dark fringe: the black backdrop only appears in fullscreen, and the border is a softer 0.5px `black/8` instead of `rgba(0, 0, 0, 0.65)`.
13
+ - [Video Player](/components/video-player) playback speed always shows a decimal: `1.0×` and `2.0×` instead of `1×` and `2×`, matching `1.25×` and `1.5×`.
14
+ - [Video Player](/components/video-player) without a `poster` shows a frame from the start of the video as its thumbnail instead of an empty surface. A `poster` still takes precedence.
15
+ - [Video Player](/components/video-player) opens on a centered play button and a duration badge instead of the full control bar; the controls take over once playback starts.
16
+ - [Video Player](/components/video-player) accepts a `preview` clip that loops muted as the cover until playback starts. It holds still when the user prefers reduced motion.
17
+
5
18
  ## October 15, 2026
6
19
 
7
20
  - [Preview](/components/preview) displays failed processed-file loads as errors and skips original file URL resolution and PDF loading when showing processed text.
8
21
  - [Preview](/patterns/preview) reserves space for the file selector and Original/Processed tabs so document content stays visible below them, including while scrolling.
22
+ - [Tooltip](/components/tooltip) with `open` set ignores hover and focus on its trigger. A forced-open tooltip no longer replays its fade-in when the pointer enters the trigger, which flipped it from `instant-open` to `delayed-open`.
9
23
  - [Preview](/components/preview) wraps preformatted text within the document width, keeping long indented email paragraphs readable while preserving indentation and line breaks.
24
+ - [Sidebar](/patterns/sidebar#telasidebaruser) `TelaSidebarUser` can be opened programmatically with `v-model:open`, and each action accepts an optional `tooltip` (`{ title, description, open }`) that pins a multiline tooltip to the right of that item, e.g. to point users at a menu entry after an action elsewhere.
25
+ - [Dropdown Menu](/components/dropdown-menu) item `tooltip` objects accept `open` to force the tooltip open or closed instead of showing it on hover.
26
+ - [Dropdown Menu](/components/dropdown-menu) items with a `tooltip` now span the full menu width and receive `@click`/`@select`; both were dropped before because the tooltip wrapped the item.
27
+ - [Video Player](/components/video-player) adapts its controls to its own width: below 400px the volume and picture-in-picture buttons hide and the bar uses the compact padding, so the time labels no longer overlap the playback speed in small players.
28
+ - [Video Player](/components/video-player) has a 0.5px `rgba(0, 0, 0, 0.65)` border, so its edge stays crisp against light pages and bright frames.
10
29
 
11
30
  ## October 14, 2026
12
31
 
@@ -5,6 +5,9 @@ import type { DropdownMenuItemProps } from 'radix-vue'
5
5
  import Tooltip from '../tooltip/tooltip.vue'
6
6
  import type { TooltipProps } from '../tooltip/tooltip.vue'
7
7
 
8
+ // The tooltip branch's root is the tooltip, so listeners must be forwarded to the item itself
9
+ defineOptions({ inheritAttrs: false })
10
+
8
11
  const props = defineProps<DropdownMenuItemProps & {
9
12
  class?: HTMLAttributes['class']
10
13
  labelClass?: HTMLAttributes['class']
@@ -57,6 +60,7 @@ const tooltipConfig = computed(() => {
57
60
  alignOffset: undefined,
58
61
  arrowOffset: undefined,
59
62
  delayDuration: undefined,
63
+ open: undefined,
60
64
  }
61
65
  }
62
66
  if (typeof props.tooltip === 'object' && props.tooltip) {
@@ -70,6 +74,7 @@ const tooltipConfig = computed(() => {
70
74
  alignOffset: props.tooltip.alignOffset,
71
75
  arrowOffset: props.tooltip.arrowOffset,
72
76
  delayDuration: props.tooltip.delayDuration,
77
+ open: props.tooltip.open,
73
78
  }
74
79
  }
75
80
  return null
@@ -96,9 +101,11 @@ const isIconImage = computed(() => {
96
101
  :title="tooltipConfig?.title"
97
102
  :description="tooltipConfig?.description"
98
103
  :delay-duration="tooltipConfig?.delayDuration ?? 100"
104
+ :open="tooltipConfig?.open"
105
+ trigger-class="w-full"
99
106
  >
100
107
  <DropdownMenuItem
101
- v-bind="props"
108
+ v-bind="{ ...props, ...$attrs }"
102
109
  :class="cn(
103
110
  'group outline-none',
104
111
  'relative flex gap-10px cursor-pointer select-none items-center rounded-xl px-3 py-1.5',
@@ -119,7 +126,7 @@ const isIconImage = computed(() => {
119
126
 
120
127
  <DropdownMenuItem
121
128
  v-else
122
- v-bind="props"
129
+ v-bind="{ ...props, ...$attrs }"
123
130
  :class="cn(
124
131
  'group outline-none',
125
132
  'relative flex gap-10px cursor-pointer select-none items-center rounded-xl px-3 py-1.5',
@@ -239,6 +239,7 @@ type DropdownMenuItem = {
239
239
  align?: 'start' | 'center' | 'end'
240
240
  alignOffset?: number
241
241
  arrowOffset?: number
242
+ open?: boolean // Forces the tooltip open or closed instead of showing it on hover
242
243
  }
243
244
  }
244
245
 
@@ -5,12 +5,13 @@ import * as InputStories from './input.stories.ts';
5
5
 
6
6
  # TelaInput
7
7
 
8
- A flexible input component that supports both text input and textarea modes. Includes features like labels, error states, icons, clear buttons, and validation feedback. Supports v-model binding for two-way data binding.
8
+ A flexible input component that supports both text input and textarea modes. Includes features like error states, icons, and validation feedback. Supports v-model binding for two-way data binding.
9
9
 
10
10
  ## Rules
11
11
 
12
12
  - **Always** use `size="md"` (default). When a `TelaInput` sits next to a `TelaButton` in the same row, both must be `md` — never mix sizes, it creates misaligned rows.
13
13
  - Inside a `TelaModal`, the input must be `w-full`.
14
+ - **Always** pass a validation error through the `error` prop whenever the field has one. Never render your own error text or icon next to the input; `error` shows the warning icon and tooltip, turns the field red, and links the message to the input for screen readers.
14
15
 
15
16
  ### Search
16
17
 
@@ -18,19 +19,15 @@ Search fields **never** have a submit button. Use an inline `TelaInput` that fil
18
19
 
19
20
  ```vue
20
21
  <!-- Correct -->
21
- <TelaInput v-model="query" placeholder="Search..." hide-label />
22
+ <TelaInput v-model="query" placeholder="Search..." />
22
23
 
23
24
  <!-- Wrong — no submit button next to a search input -->
24
- <TelaInput v-model="query" placeholder="Search..." hide-label />
25
+ <TelaInput v-model="query" placeholder="Search..." />
25
26
  <TelaButton>Search</TelaButton>
26
27
  ```
27
28
 
28
29
  ## Examples
29
30
 
30
- ### With Clear Button
31
-
32
- <Canvas of={InputStories.ClearButton} />
33
-
34
31
  ### With Icon
35
32
 
36
33
  <Canvas of={InputStories.WithIcon} />
@@ -64,23 +61,11 @@ const value = ref('')
64
61
  </template>
65
62
  ```
66
63
 
67
- ### With Clear Button Code
68
-
69
- ```vue
70
- <TelaInput
71
- v-model="value"
72
- placeholder="you@example.com"
73
- show-clear-button
74
- clear-label="Clear"
75
- />
76
- ```
77
-
78
64
  ### With Icon Code
79
65
 
80
66
  ```vue
81
67
  <TelaInput
82
68
  v-model="searchQuery"
83
- label="Search"
84
69
  icon="i-ph-magnifying-glass"
85
70
  placeholder="Search..."
86
71
  />
@@ -88,9 +73,11 @@ const value = ref('')
88
73
 
89
74
  ### With Error Code
90
75
 
76
+ `error` turns the field red and puts a warning icon on the right. The message shows in a tooltip when you hover the icon or focus the field, and screen readers announce it with the input.
77
+
91
78
  ```vue
92
79
  <TelaInput
93
- v-model="email"
80
+ model-value="gustavo@"
94
81
  placeholder="you@example.com"
95
82
  error="Please enter a valid email address"
96
83
  />
@@ -119,7 +106,6 @@ const value = ref('')
119
106
  ```vue
120
107
  <TelaInput
121
108
  v-model="value"
122
- label-class="text-blue-600 font-bold"
123
109
  input-class="border-blue-400"
124
110
  />
125
111
  ```
@@ -142,22 +128,16 @@ const value = ref('')
142
128
  type InputProps = {
143
129
  id?: string
144
130
  modelValue?: string | number
145
- label?: string
146
131
  placeholder?: string
147
- hideLabel?: boolean
148
132
  disabled?: boolean
149
133
  error?: string | false
150
- showClearButton?: boolean
151
- clearLabel?: string // overrides the shared useTelaLabels().clear label (English fallback: 'Clear')
152
134
  tabindex?: number
153
135
  autofocus?: boolean
154
136
  autocomplete?: 'on' | 'off'
155
137
  type?: string
156
- labelClass?: string
157
138
  inputFontClass?: string
158
139
  inputClass?: string
159
140
  icon?: string
160
- showDescription?: boolean
161
141
  maxlength?: number
162
142
  }
163
143
  ```
@@ -165,21 +145,17 @@ type InputProps = {
165
145
  ## Features
166
146
 
167
147
  - **Flexible Input Types**: Supports text, email, password, number, textarea, and more
168
- - **Label Support**: Built-in label with hide option for accessibility
169
- - **Error Handling**: Display validation errors with styling
148
+ - **Error Handling**: Validation errors as a warning icon with the message in a tooltip
170
149
  - **Icon Integration**: Add icons inside the input field
171
- - **Clear Button**: Quick clear functionality with a host-provided accessible tooltip label
172
150
  - **Auto-focus**: Automatically focus on mount
173
151
  - **Disabled State**: Proper disabled styling and behavior
174
152
  - **Character Limit**: Maxlength support with counter
175
- - **Custom Classes**: Granular control over label, input, and font styling
153
+ - **Custom Classes**: Granular control over input and font styling
176
154
  - **Two-way Binding**: Full v-model support
177
155
  - **Textarea Mode**: Multi-line input support
178
156
 
179
157
  ## Accessibility
180
158
 
181
- - Proper label-input association with `for` and `id` attributes
182
- - Hidden label option maintains accessibility
183
159
  - Error messages properly associated with input
184
160
  - Keyboard navigation support
185
161
  - Focus visible states
@@ -0,0 +1,56 @@
1
+ // @vitest-environment happy-dom
2
+ import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'
3
+ import { mount } from '@vue/test-utils'
4
+ import { describe, expect, it, vi } from 'vitest'
5
+ import Input from './input.vue'
6
+
7
+ vi.stubGlobal('computed', computed)
8
+ vi.stubGlobal('ref', ref)
9
+ vi.stubGlobal('watch', watch)
10
+ vi.stubGlobal('nextTick', nextTick)
11
+ vi.stubGlobal('onMounted', onMounted)
12
+ vi.stubGlobal('onBeforeUnmount', onBeforeUnmount)
13
+ vi.stubGlobal('useTemplateRef', useTemplateRef)
14
+ vi.stubGlobal('useTextareaAutosize', () => ({ textarea: ref(), input: ref('') }))
15
+ vi.stubGlobal('useElementBounding', () => ({ width: ref(0) }))
16
+ vi.stubGlobal('useResizeObserver', () => {})
17
+
18
+ const stubs = {
19
+ TelaIcon: true,
20
+ TelaTooltip: { template: '<div><slot /></div>' },
21
+ }
22
+
23
+ describe('telaInput error', () => {
24
+ it('shows a warning icon with the message in a tooltip', () => {
25
+ const wrapper = mount(Input, { props: { modelValue: 'luiz@', error: 'Enter a valid email' }, global: { stubs: { ...stubs, TelaTooltip: { props: ['content'], template: '<div data-tooltip :data-content="content"><slot /></div>' } } } })
26
+
27
+ expect(wrapper.get('[data-tooltip]').attributes('data-content')).toBe('Enter a valid email')
28
+ })
29
+
30
+ it('marks the input invalid and describes it with the message', () => {
31
+ const wrapper = mount(Input, { props: { modelValue: 'luiz@', error: 'Enter a valid email' }, global: { stubs } })
32
+
33
+ const input = wrapper.get('input')
34
+ expect(input.attributes('aria-invalid')).toBe('true')
35
+ expect(input.attributes('aria-description')).toBe('Enter a valid email')
36
+ })
37
+
38
+ it('opens the error tooltip while the input has focus', async () => {
39
+ const wrapper = mount(Input, { props: { modelValue: 'luiz@', error: 'Enter a valid email' }, global: { stubs: { ...stubs, TelaTooltip: { props: ['open'], template: '<div data-tooltip :data-open="String(open)"><slot /></div>' } } } })
40
+
41
+ const tooltip = () => wrapper.get('[data-tooltip]').attributes('data-open')
42
+ expect(tooltip()).toBe('undefined')
43
+ await wrapper.get('input').trigger('focus')
44
+ expect(tooltip()).toBe('true')
45
+ await wrapper.get('input').trigger('blur')
46
+ expect(tooltip()).toBe('undefined')
47
+ })
48
+
49
+ it('adds no aria wiring without an error', () => {
50
+ const wrapper = mount(Input, { props: { modelValue: '' }, global: { stubs } })
51
+
52
+ const input = wrapper.get('input')
53
+ expect(input.attributes('aria-invalid')).toBeUndefined()
54
+ expect(input.attributes('aria-description')).toBeUndefined()
55
+ })
56
+ })
@@ -4,25 +4,18 @@ import type { InputTypeHTMLAttribute } from 'vue'
4
4
  const props = withDefaults(defineProps<{
5
5
  id?: string
6
6
  modelValue: string | number | undefined
7
- label?: string
8
7
  placeholder?: string
9
- hideLabel?: boolean
10
8
  disabled?: boolean
11
9
  error?: string | false
12
- showClearButton?: boolean
13
- clearLabel?: string
14
10
  tabindex?: number
15
11
  autofocus?: boolean
16
12
  autocomplete?: 'off' | 'on'
17
13
  type?: InputTypeHTMLAttribute | 'textarea'
18
14
  variant?: 'default' | 'ghost'
19
- labelClass?: string
20
15
  inputFontClass?: string
21
16
  inputClass?: string
22
17
  icon?: string
23
- showDescription?: boolean
24
18
  maxlength?: number
25
- /** @deprecated TelaInput has a single size — omit this prop. */
26
19
  size?: 'sm' | 'md'
27
20
  }>(), {
28
21
  variant: 'default',
@@ -34,9 +27,6 @@ const emit = defineEmits<{
34
27
  'blur': [string]
35
28
  }>()
36
29
 
37
- const labels = useTelaLabels()
38
- const resolvedClearLabel = computed(() => props.clearLabel ?? labels.value.clear)
39
-
40
30
  const isTextarea = computed(() => props.type === 'textarea')
41
31
  const attributes = computed(() => ({
42
32
  type: isTextarea.value ? undefined : props.type,
@@ -52,17 +42,22 @@ function handleInput(data: Event | string) {
52
42
  emit('update:modelValue', ((data as Event).target as HTMLInputElement).value)
53
43
  }
54
44
 
45
+ const isFocused = ref(false)
46
+
47
+ function handleFocus() {
48
+ isFocused.value = true
49
+ emit('focus')
50
+ }
51
+
55
52
  function handleBlur(data: Event | string) {
53
+ isFocused.value = false
54
+
56
55
  if (isTextarea.value)
57
56
  emit('blur', data as string)
58
57
  else
59
58
  emit('blur', ((data as Event).target as HTMLInputElement).value)
60
59
  }
61
60
 
62
- function clearContent() {
63
- emit('update:modelValue', '')
64
- }
65
-
66
61
  const container = ref<HTMLElement>()
67
62
  const { textarea: inputRef, input: textareaInput } = useTextareaAutosize({ styleProp: 'minHeight' })
68
63
 
@@ -96,33 +91,6 @@ onMounted(() => {
96
91
  const trailingContent = useTemplateRef('trailing-content')
97
92
  const { width: trailingWidth } = useElementBounding(trailingContent)
98
93
 
99
- const errorContainerRef = ref<HTMLElement>()
100
- const isErrorTruncated = ref(false)
101
-
102
- function checkTruncation() {
103
- if (!errorContainerRef.value)
104
- return
105
-
106
- const span = errorContainerRef.value.querySelector('span')
107
- if (span) {
108
- isErrorTruncated.value = span.scrollWidth > span.clientWidth
109
- }
110
- }
111
-
112
- watch(() => props.error, async () => {
113
- if (props.error) {
114
- await nextTick()
115
- checkTruncation()
116
- }
117
- else {
118
- isErrorTruncated.value = false
119
- }
120
- }, { immediate: true })
121
-
122
- useResizeObserver(errorContainerRef, () => {
123
- checkTruncation()
124
- })
125
-
126
94
  defineExpose({
127
95
  focusInput,
128
96
  })
@@ -138,9 +106,9 @@ defineExpose({
138
106
  px-10px py-4px
139
107
  rounded-10px bg-white
140
108
  :class="[
141
- props.variant === 'default' && 'border-0.5px border [box-shadow:0_1px_4px_0_rgba(103,127,148,0.03)] focus-within-border-strong focus-within-ring-2 focus-within-ring-gray-100',
142
- disabled && '!bg-gray-50 cursor-not-allowed color-gray-600',
143
- error && '!border-red-900 !text-red-900 !bg-[#FFDBDB66]',
109
+ props.variant === 'default' && 'border-0.5px border [box-shadow:0_1px_4px_0_rgba(103,127,148,0.03)] focus-within-border-strong focus-within-ring-1.5 focus-within-ring-border-subtle',
110
+ disabled && '!bg-subtle cursor-not-allowed text-secondary',
111
+ error && '!border-red-800 !text-red-900 !bg-red-100 focus-within-ring-red-200',
144
112
  props.inputClass,
145
113
  $attrs.class,
146
114
  ]"
@@ -156,15 +124,6 @@ defineExpose({
156
124
  marginRight: `${trailingWidth - 0}px`,
157
125
  }"
158
126
  >
159
- <label
160
- v-if="label"
161
- :for="id"
162
- body-12-semibold text-tertiary flex align-center
163
- :class="[disabled && 'cursor-not-allowed', props.labelClass]"
164
- >
165
- <slot name="label-leading" />
166
- {{ label }}
167
- </label>
168
127
  <component
169
128
  :is="isTextarea ? 'textarea' : 'input'"
170
129
  :id="id"
@@ -182,10 +141,12 @@ defineExpose({
182
141
  z-0
183
142
  h-full
184
143
  body-14-regular
185
- class="placeholder-text-tertiary focus-visible:outline-none!"
144
+ class="placeholder-text-tertiary caret-icon-tertiary aria-[invalid=true]:placeholder:text-red-900/60 aria-[invalid=true]:caret-red-800 focus-visible:outline-none!"
186
145
  resize-none
187
146
  :disabled="disabled"
188
147
  :tabindex="tabindex"
148
+ :aria-description="error || undefined"
149
+ :aria-invalid="error ? true : undefined"
189
150
  :class="[
190
151
  disabled && 'cursor-not-allowed',
191
152
  props.inputFontClass ? props.inputFontClass : 'text-14px',
@@ -194,55 +155,30 @@ defineExpose({
194
155
  @input="handleInput"
195
156
  @update:model-value="handleInput"
196
157
  @blur="handleBlur"
197
- @focus="emit('focus')"
158
+ @focus="handleFocus"
198
159
  />
199
160
  </div>
200
161
 
201
- <div v-if="!showClearButton" ref="trailing-content" absolute top-0 right-0 :bg="error ? '' : 'bg-inherit'" h-full flex="~ col" px-8px>
202
- <div flex-auto />
203
- <slot name="trailing" />
162
+ <div v-if="$slots.trailing || error" ref="trailing-content" absolute top-0 right-0 :class="!error && 'bg-inherit'" h-full flex="~ col" px-8px>
204
163
  <div flex-auto />
205
- </div>
206
-
207
- <div v-if="showDescription" class="body-12-regular text-gray-500">
208
- <slot name="description" />
209
- </div>
210
164
 
211
- <div v-if="showClearButton && modelValue" class="top-60% -translate-y-60%" right-1 absolute>
212
- <TelaTooltip
213
- :content="resolvedClearLabel"
214
- >
215
- <button
216
- hover:bg="#EBEFF199"
217
- transition
218
- p-4px rounded-full
219
- class="group"
220
- tabindex="-1"
221
- type="button"
222
- :aria-label="resolvedClearLabel"
223
- @click="clearContent"
165
+ <div class="flex items-center gap-6px">
166
+ <div class="flex flex-col">
167
+ <slot name="trailing" />
168
+ </div>
169
+ <TelaTooltip
170
+ v-if="error"
171
+ :content="error"
172
+ :open="isFocused || undefined"
173
+ trigger-class="cursor-help"
174
+ content-class="max-w-300px break-words z-999"
224
175
  >
225
- <TelaIcon name="i-ph-x-circle-light" text="#031E22" op-40 group-hover:op-100 transition />
226
- </button>
227
- </TelaTooltip>
176
+ <TelaIcon name="i-ph-warning-bold" size="16px" color="red-900" />
177
+ </TelaTooltip>
178
+ </div>
179
+
180
+ <div flex-auto />
228
181
  </div>
229
182
  </div>
230
- <TelaTooltip
231
- v-if="error"
232
- :content="error"
233
- :disabled="!isErrorTruncated"
234
- content-class="max-w-300px break-words z-[12000]"
235
- >
236
- <div
237
- ref="errorContainerRef"
238
- absolute bottom--14px left-0 right-0
239
- body-10-medium text-red-900 flex items-center gap-3px
240
- overflow-hidden text-ellipsis whitespace-nowrap
241
- pr-2
242
- >
243
- <TelaIcon name="i-ph-warning-bold" size="sm" text="red-900" text-16px flex-shrink-0 />
244
- <span class="overflow-hidden text-ellipsis">{{ error }}</span>
245
- </div>
246
- </TelaTooltip>
247
183
  </div>
248
184
  </template>
@@ -7,15 +7,22 @@ defineProps<{
7
7
  label: string
8
8
  icon: string
9
9
  color?: 'caution' | 'negative'
10
+ tooltip?: {
11
+ title: string
12
+ description: string
13
+ open: boolean
14
+ }
10
15
  onClick: () => void
11
16
  }[]
12
17
  }>()
13
18
 
19
+ const open = defineModel<boolean>('open', { default: false })
20
+
14
21
  const labels = useTelaLabels()
15
22
  </script>
16
23
 
17
24
  <template>
18
- <TelaDropdownMenuRoot>
25
+ <TelaDropdownMenuRoot v-model:open="open">
19
26
  <TelaDropdownMenuTrigger as-child>
20
27
  <button
21
28
  :aria-label="labels.userMenu"
@@ -41,6 +48,7 @@ const labels = useTelaLabels()
41
48
  :key="action.label"
42
49
  :icon="action.icon"
43
50
  :color="action.color"
51
+ :tooltip="action.tooltip && { variant: 'multiline', side: 'right', align: 'start', ...action.tooltip }"
44
52
  @click="action.onClick"
45
53
  >
46
54
  {{ action.label }}
@@ -189,15 +189,39 @@ interface TelaSidebarUserProps {
189
189
  image?: string // Optional — falls back to a placeholder if not provided
190
190
  name: string
191
191
  email: string
192
+ open?: boolean // Bind with v-model:open to open the menu programmatically
192
193
  actions: {
193
194
  label: string
194
195
  icon: string
195
196
  color?: 'caution' | 'negative' // Omit for the default style
197
+ tooltip?: { // Multiline tooltip pinned to the right of the item while `open` is true
198
+ title: string
199
+ description: string
200
+ open: boolean
201
+ }
196
202
  onClick: () => void
197
203
  }[]
198
204
  }
199
205
  ```
200
206
 
207
+ To point users at an action, open the menu with `v-model:open` and set that action's `tooltip.open`:
208
+
209
+ ```vue
210
+ <TelaSidebarUser
211
+ v-model:open="isMenuOpen"
212
+ name="Jane Doe"
213
+ email="jane@example.com"
214
+ :actions="[
215
+ {
216
+ label: 'Onboarding',
217
+ icon: 'i-ph-hand-waving-bold',
218
+ tooltip: { title: 'If you change your mind', description: 'Click here to view the onboarding again', open: isMenuOpen },
219
+ onClick: openOnboarding,
220
+ },
221
+ ]"
222
+ />
223
+ ```
224
+
201
225
  Example:
202
226
 
203
227
  ```vue
@@ -24,11 +24,13 @@ defineEmits<{
24
24
 
25
25
  // `open` forces the state when set; otherwise hover/focus drive it. The root is
26
26
  // always controlled so an `open` that arrives after mount is still forwarded.
27
+ // While forced, hover is switched off too: it can't change what's shown, but its
28
+ // delayed open would flip `instant-open` to `delayed-open` and replay the fade-in.
27
29
  const interactionOpen = ref(false)
28
30
  </script>
29
31
 
30
32
  <template>
31
- <TelaTooltipProvider :disabled="disabled" :delay-duration="delayDuration">
33
+ <TelaTooltipProvider :disabled="disabled || open !== undefined" :delay-duration="delayDuration">
32
34
  <TelaTooltipRoot :open="open ?? interactionOpen" @update:open="interactionOpen = $event">
33
35
  <TelaTooltipTrigger :class="triggerClass" :as-child="asChild" :reference="reference" :tabindex="asChild ? undefined : -1">
34
36
  <slot />
@@ -6,7 +6,7 @@ import { Meta, ArgTypes } from '@storybook/blocks';
6
6
 
7
7
  A video player with custom controls: play/pause, a hover volume slider, a scrubbable progress bar with buffered range and hover time, playback speed, captions, picture-in-picture and fullscreen. Controls fade out after a short idle while playing and come back on pointer movement or focus.
8
8
 
9
- The player is a 16:9 black surface in both themes, so its controls are always white.
9
+ The player is a 16:9 surface with always-white controls; it turns black only in fullscreen, to letterbox the video. Without a `poster`, the player shows a frame from the start of the video as its thumbnail. A `preview` clip (short, muted) loops as the cover instead until playback starts, and holds still for users who prefer reduced motion. Until playback starts, the player shows a centered play button and the video duration instead of the full controls.
10
10
 
11
11
  ## Props
12
12
 
@@ -14,6 +14,7 @@ The player is a 16:9 black surface in both themes, so its controls are always wh
14
14
  type VideoPlayerProps = {
15
15
  src: string
16
16
  poster?: string
17
+ preview?: string
17
18
  tracks?: VideoPlayerTrack[]
18
19
  crossorigin?: 'anonymous' | 'use-credentials'
19
20
  labels?: Partial<VideoPlayerLabels>
@@ -34,6 +35,28 @@ type VideoPlayerTrack = {
34
35
  - `play` — playback started
35
36
  - `pause` — playback paused
36
37
  - `ended` — playback reached the end
38
+ - `timeupdate` — the playback position changed, with the current time in seconds
39
+
40
+ ## Exposed Methods
41
+
42
+ - `seekTo(seconds)` — jump to a time; clamped to the duration once it's known
43
+ - `play()` — start playback
44
+
45
+ ```vue
46
+ <script setup lang="ts">
47
+ const player = useTemplateRef('player')
48
+
49
+ function playFrom(seconds: number) {
50
+ player.value?.seekTo(seconds)
51
+ player.value?.play()
52
+ }
53
+ </script>
54
+
55
+ <template>
56
+ <TelaVideoPlayer ref="player" src="https://tela.com/videos/hero-showcase.mp4" />
57
+ <button @click="playFrom(26)">Canvas</button>
58
+ </template>
59
+ ```
37
60
 
38
61
  ## Examples
39
62
 
@@ -84,6 +107,7 @@ const labels = { play: t('video.play'), pause: t('video.pause') }
84
107
  - The speed button cycles `1×`, `1.25×`, `1.5×`, `2×`.
85
108
  - Fullscreen uses the container, so the custom controls stay visible. iPhone Safari has no element fullscreen and falls back to the native video fullscreen.
86
109
  - Below the `sm` breakpoint the speed and picture-in-picture buttons are hidden.
110
+ - When the player itself is narrower than 400px, the volume and picture-in-picture buttons are hidden so the time labels keep their room.
87
111
 
88
112
  ## Keyboard
89
113
 
@@ -28,6 +28,8 @@ export type VideoPlayerLabels = {
28
28
  const props = withDefaults(defineProps<{
29
29
  src: string
30
30
  poster?: string
31
+ /** A short muted clip that loops as the cover until playback starts */
32
+ preview?: string
31
33
  tracks?: VideoPlayerTrack[]
32
34
  crossorigin?: 'anonymous' | 'use-credentials'
33
35
  labels?: Partial<VideoPlayerLabels>
@@ -41,6 +43,7 @@ const emit = defineEmits<{
41
43
  play: []
42
44
  pause: []
43
45
  ended: []
46
+ timeupdate: [seconds: number]
44
47
  }>()
45
48
 
46
49
  const DEFAULT_LABELS: VideoPlayerLabels = {
@@ -66,6 +69,10 @@ const video = ref<HTMLVideoElement>()
66
69
 
67
70
  const isMounted = useMounted()
68
71
 
72
+ const POSTER_FRAME_TIME = 0.1
73
+
74
+ const source = computed(() => (props.poster || props.preview || props.src.includes('#') ? props.src : `${props.src}#t=${POSTER_FRAME_TIME}`))
75
+
69
76
  const {
70
77
  playing,
71
78
  currentTime,
@@ -80,10 +87,12 @@ const {
80
87
  supportsPictureInPicture,
81
88
  togglePictureInPicture,
82
89
  } = useMediaControls(video, {
83
- src: toRef(props, 'src'),
90
+ src: source,
84
91
  tracks: toRef(props, 'tracks'),
85
92
  })
86
93
 
94
+ watch(currentTime, time => emit('timeupdate', time))
95
+
87
96
  const {
88
97
  isFullscreen,
89
98
  isSupported: isFullscreenSupported,
@@ -94,7 +103,13 @@ function togglePlay() {
94
103
  playing.value = !playing.value
95
104
  }
96
105
 
97
- /* The play toggle waits out the double-click window so a double click only toggles fullscreen. */
106
+ function playFromCover(event: MouseEvent) {
107
+ if (event.currentTarget === document.activeElement)
108
+ container.value?.focus({ preventScroll: true })
109
+
110
+ togglePlay()
111
+ }
112
+
98
113
  const DOUBLE_CLICK_DELAY = 250
99
114
 
100
115
  let surfaceClickTimer: ReturnType<typeof setTimeout> | undefined
@@ -229,7 +244,12 @@ function onBarPointerLeave() {
229
244
  }
230
245
 
231
246
  function seekTo(time: number) {
232
- currentTime.value = Math.min(Math.max(time, 0), duration.value)
247
+ /* Before metadata loads the duration is 0, so only clamp once it's known */
248
+ currentTime.value = Math.max(duration.value ? Math.min(time, duration.value) : time, 0)
249
+ }
250
+
251
+ function play() {
252
+ playing.value = true
233
253
  }
234
254
 
235
255
  function seekBy(delta: number) {
@@ -263,7 +283,7 @@ function onBarKeydown(event: KeyboardEvent) {
263
283
 
264
284
  const RATES = [1, 1.25, 1.5, 2]
265
285
 
266
- const rateLabel = computed(() => `${rate.value}×`)
286
+ const rateLabel = computed(() => `${Number.isInteger(rate.value) ? rate.value.toFixed(1) : rate.value}x`)
267
287
 
268
288
  function cycleRate() {
269
289
  const index = RATES.indexOf(rate.value)
@@ -385,6 +405,20 @@ const volumeIcon = computed(() => {
385
405
  return volume.value < 0.5 ? 'i-ph-speaker-low' : 'i-ph-speaker-high'
386
406
  })
387
407
 
408
+ const { width: playerWidth } = useElementSize(container)
409
+ const isNarrow = computed(() => playerWidth.value > 0 && playerWidth.value < 400)
410
+
411
+ const hasStarted = ref(false)
412
+
413
+ watch(playing, (isPlaying) => {
414
+ if (isPlaying)
415
+ hasStarted.value = true
416
+ })
417
+
418
+ const reducedMotion = usePreferredReducedMotion()
419
+
420
+ const isCoverVisible = computed(() => !hasStarted.value)
421
+
388
422
  const buttonClass = 'flex items-center justify-center shrink-0 size-28px rounded-8px text-white/90 transition-[color,background-color,transform] duration-150 ease-out hover:text-white hover:bg-white/15 active:scale-95 outline-none focus-visible:ring-1 focus-visible:ring-white/60'
389
423
 
390
424
  const timeClass = 'shrink-0 body-12-medium tabular-nums text-white'
@@ -400,17 +434,23 @@ const iconTransition = {
400
434
  duration: 0.3,
401
435
  bounce: 0,
402
436
  } as const
437
+
438
+ defineExpose({
439
+ seekTo,
440
+ play,
441
+ })
403
442
  </script>
404
443
 
405
444
  <template>
406
445
  <div
407
446
  ref="container"
408
- tabindex="0"
447
+ :tabindex="isCoverVisible ? -1 : 0"
409
448
  role="region"
410
449
  :aria-label="text.region"
411
450
  :class="cn(
412
- 'group/player relative w-full aspect-video bg-black rounded-16px overflow-hidden outline-none select-none focus-visible:ring-2 focus-visible:ring-white/60',
413
- isFullscreen && 'rounded-none',
451
+ 'group/player relative isolate w-full aspect-video rounded-16px overflow-hidden outline-none select-none focus-visible:ring-2 focus-visible:ring-white/60',
452
+ 'after:content-empty after:absolute after:inset-0 after:rounded-[inherit] after:border-[0.5px] after:border-black/12 after:pointer-events-none',
453
+ isFullscreen && 'rounded-none bg-black',
414
454
  !areControlsVisible && 'cursor-none',
415
455
  props.class,
416
456
  )"
@@ -428,7 +468,7 @@ const iconTransition = {
428
468
  preload="metadata"
429
469
  playsinline
430
470
  :class="cn(
431
- 'absolute inset-0 size-full object-contain [&::cue]:bg-black/65 [&::cue]:text-white [&::cue]:text-16px',
471
+ 'absolute inset-0 size-full rounded-[inherit] object-contain [&::cue]:bg-black/65 [&::cue]:text-white [&::cue]:text-16px',
432
472
  areControlsVisible ? 'cursor-pointer' : 'cursor-none',
433
473
  )"
434
474
  @click="onSurfaceClick"
@@ -438,18 +478,61 @@ const iconTransition = {
438
478
  @ended="emit('ended')"
439
479
  />
440
480
 
481
+ <video
482
+ v-if="preview && !hasStarted"
483
+ :src="preview"
484
+ :autoplay="reducedMotion !== 'reduce'"
485
+ aria-hidden="true"
486
+ muted
487
+ loop
488
+ playsinline
489
+ preload="auto"
490
+ class="pointer-events-none absolute inset-0 size-full rounded-[inherit] object-cover"
491
+ />
492
+
493
+ <Transition
494
+ enter-active-class="transition-opacity duration-200 ease-out"
495
+ leave-active-class="transition-opacity duration-200 ease-out"
496
+ enter-from-class="opacity-0"
497
+ leave-to-class="opacity-0"
498
+ >
499
+ <button
500
+ v-if="isCoverVisible"
501
+ type="button"
502
+ :aria-label="text.play"
503
+ class="group/cover absolute inset-0 rounded-[inherit] cursor-pointer outline-none"
504
+ @click="playFromCover"
505
+ >
506
+ <span
507
+ aria-hidden="true"
508
+ class="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center size-36px rounded-10px bg-black/40 backdrop-blur-sm text-white transition-colors duration-100 ease-out group-hover/player:bg-black/50 group-focus-visible/cover:bg-black/60 group-focus-visible/cover:ring-1 group-focus-visible/cover:ring-cyan-600"
509
+ >
510
+ <TelaIcon name="i-ph-play-fill" size="18px" class="ml--1px" />
511
+ </span>
512
+
513
+ <span
514
+ v-if="duration"
515
+ class="absolute bottom-10px right-10px px-8px py-3px rounded-6px text-white/90 bg-black/40 backdrop-blur-sm body-12-semibold tabular-nums"
516
+ >
517
+ {{ durationLabel }}
518
+ </span>
519
+ </button>
520
+ </Transition>
521
+
441
522
  <div
442
523
  aria-hidden="true"
443
524
  :class="cn(
444
525
  'pointer-events-none absolute inset-x-0 bottom-0 h-120px bg-gradient-to-t from-black/60 to-transparent transition-opacity duration-300 ease-out',
445
- areControlsVisible ? 'opacity-100' : 'opacity-0',
526
+ areControlsVisible && !isCoverVisible ? 'opacity-100' : 'opacity-0',
446
527
  )"
447
528
  />
448
529
 
449
530
  <div
450
531
  :class="cn(
451
- 'absolute inset-x-0 bottom-0 flex items-center gap-12px px-24px pb-20px pt-32px text-white transition-opacity duration-300 ease-out max-sm:px-16px max-sm:pb-14px',
452
- areControlsVisible ? 'opacity-100' : 'opacity-0 pointer-events-none',
532
+ 'absolute inset-x-0 bottom-0 flex items-center max-w-1012px mx-auto gap-12px px-24px pb-20px pt-32px text-white transition-opacity duration-300 ease-out max-sm:px-16px max-sm:pb-14px',
533
+ isNarrow && 'px-16px pb-14px',
534
+ isCoverVisible && 'invisible',
535
+ areControlsVisible && !isCoverVisible ? 'opacity-100' : 'opacity-0 pointer-events-none',
453
536
  )"
454
537
  >
455
538
  <div class="flex items-center gap-8px">
@@ -476,7 +559,7 @@ const iconTransition = {
476
559
  </AnimatePresence>
477
560
  </button>
478
561
 
479
- <div class="group/volume relative flex items-center">
562
+ <div v-if="!isNarrow" class="group/volume relative flex items-center">
480
563
  <button
481
564
  type="button"
482
565
  :aria-label="muted ? text.unmute : text.mute"
@@ -562,7 +645,7 @@ const iconTransition = {
562
645
  <button
563
646
  type="button"
564
647
  :aria-label="text.playbackSpeed"
565
- :class="cn(buttonClass, 'min-w-52px body-12-medium tabular-nums max-sm:hidden')"
648
+ :class="cn(buttonClass, 'min-w-48px body-12-medium tabular-nums max-sm:hidden')"
566
649
  @click="cycleRate"
567
650
  >
568
651
  {{ rateLabel }}
@@ -580,7 +663,7 @@ const iconTransition = {
580
663
  </button>
581
664
 
582
665
  <button
583
- v-if="isMounted && supportsPictureInPicture"
666
+ v-if="isMounted && supportsPictureInPicture && !isNarrow"
584
667
  type="button"
585
668
  :aria-label="text.pictureInPicture"
586
669
  :class="cn(buttonClass, 'max-sm:hidden')"
@@ -200,16 +200,26 @@ const EditorComponent = defineComponent({
200
200
  </div>
201
201
 
202
202
  <div v-if="data" class="space-y-3">
203
- <TelaInput
204
- v-model="editName"
205
- label="Name"
206
- :placeholder="data.name"
207
- />
208
- <TelaInput
209
- v-model="editEmail"
210
- label="Email"
211
- :placeholder="data.email"
212
- />
203
+ <div class="flex flex-col gap-8px">
204
+ <TelaLabel for="demo-edit-name">
205
+ Name
206
+ </TelaLabel>
207
+ <TelaInput
208
+ id="demo-edit-name"
209
+ v-model="editName"
210
+ :placeholder="data.name"
211
+ />
212
+ </div>
213
+ <div class="flex flex-col gap-8px">
214
+ <TelaLabel for="demo-edit-email">
215
+ Email
216
+ </TelaLabel>
217
+ <TelaInput
218
+ id="demo-edit-email"
219
+ v-model="editEmail"
220
+ :placeholder="data.email"
221
+ />
222
+ </div>
213
223
  <TelaButton
214
224
  variant="primary"
215
225
  size="sm"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-build",
3
- "version": "1.87.3",
3
+ "version": "1.89.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "app.config.ts",