base-ui-vue 0.3.0 → 0.5.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.
Files changed (218) hide show
  1. package/dist/arrow/TooltipArrow.cjs +609 -0
  2. package/dist/arrow/TooltipArrow.cjs.map +1 -0
  3. package/dist/arrow/TooltipArrow.js +478 -0
  4. package/dist/arrow/TooltipArrow.js.map +1 -0
  5. package/dist/button/Button.cjs +5 -317
  6. package/dist/button/Button.cjs.map +1 -1
  7. package/dist/button/Button.js +3 -249
  8. package/dist/button/Button.js.map +1 -1
  9. package/dist/button/ToolbarButton.cjs +19 -6
  10. package/dist/button/ToolbarButton.cjs.map +1 -1
  11. package/dist/button/ToolbarButton.js +3 -2
  12. package/dist/button/ToolbarButton.js.map +1 -1
  13. package/dist/checkbox/index.cjs +20 -9
  14. package/dist/checkbox/index.cjs.map +1 -1
  15. package/dist/checkbox/index.js +7 -2
  16. package/dist/checkbox/index.js.map +1 -1
  17. package/dist/checkbox-group/CheckboxGroup.cjs +14 -13
  18. package/dist/checkbox-group/CheckboxGroup.cjs.map +1 -1
  19. package/dist/checkbox-group/CheckboxGroup.js +2 -1
  20. package/dist/checkbox-group/CheckboxGroup.js.map +1 -1
  21. package/dist/components/FloatingPortal.cjs +66 -0
  22. package/dist/components/FloatingPortal.cjs.map +1 -0
  23. package/dist/components/FloatingPortal.js +55 -0
  24. package/dist/components/FloatingPortal.js.map +1 -0
  25. package/dist/components/FloatingRootStore.cjs +101 -0
  26. package/dist/components/FloatingRootStore.cjs.map +1 -0
  27. package/dist/components/FloatingRootStore.js +84 -0
  28. package/dist/components/FloatingRootStore.js.map +1 -0
  29. package/dist/components/FloatingTree.cjs +33 -0
  30. package/dist/components/FloatingTree.cjs.map +1 -0
  31. package/dist/components/FloatingTree.js +22 -0
  32. package/dist/components/FloatingTree.js.map +1 -0
  33. package/dist/composite/composite.cjs +6 -0
  34. package/dist/composite/composite.js +1 -1
  35. package/dist/content/ScrollAreaContent.cjs +3 -3
  36. package/dist/content/ScrollAreaContent.cjs.map +1 -1
  37. package/dist/content/ScrollAreaContent.js +1 -1
  38. package/dist/control/FieldControl.cjs +3 -3
  39. package/dist/control/FieldControl.cjs.map +1 -1
  40. package/dist/control/FieldControl.js +1 -1
  41. package/dist/control/SliderControl.cjs +3 -3
  42. package/dist/control/SliderControl.cjs.map +1 -1
  43. package/dist/control/SliderControl.js +3 -3
  44. package/dist/corner/ScrollAreaCorner.cjs +3 -3
  45. package/dist/corner/ScrollAreaCorner.cjs.map +1 -1
  46. package/dist/corner/ScrollAreaCorner.js +1 -1
  47. package/dist/decrement/NumberFieldDecrement.cjs +868 -0
  48. package/dist/decrement/NumberFieldDecrement.cjs.map +1 -0
  49. package/dist/decrement/NumberFieldDecrement.js +701 -0
  50. package/dist/decrement/NumberFieldDecrement.js.map +1 -0
  51. package/dist/description/FieldDescription.cjs +2 -2
  52. package/dist/description/FieldDescription.cjs.map +1 -1
  53. package/dist/description/FieldDescription.js +1 -1
  54. package/dist/error/FieldError.cjs +2 -2
  55. package/dist/error/FieldError.cjs.map +1 -1
  56. package/dist/error/FieldError.js +1 -1
  57. package/dist/fallback/AvatarFallback.cjs +4 -48
  58. package/dist/fallback/AvatarFallback.cjs.map +1 -1
  59. package/dist/fallback/AvatarFallback.js +4 -42
  60. package/dist/fallback/AvatarFallback.js.map +1 -1
  61. package/dist/floating-ui-vue/index.js +638 -0
  62. package/dist/floating-ui-vue/index.js.map +1 -0
  63. package/dist/form/Form.cjs +3 -3
  64. package/dist/form/Form.cjs.map +1 -1
  65. package/dist/form/Form.js +1 -1
  66. package/dist/group/NumberFieldGroup.cjs +72 -0
  67. package/dist/group/NumberFieldGroup.cjs.map +1 -0
  68. package/dist/group/NumberFieldGroup.js +67 -0
  69. package/dist/group/NumberFieldGroup.js.map +1 -0
  70. package/dist/group/ToolbarGroup.cjs +2 -2
  71. package/dist/group/ToolbarGroup.cjs.map +1 -1
  72. package/dist/group/ToolbarGroup.js +1 -1
  73. package/dist/header/AccordionHeader.cjs +2 -2
  74. package/dist/header/AccordionHeader.cjs.map +1 -1
  75. package/dist/header/AccordionHeader.js +1 -1
  76. package/dist/hooks/useDismiss.cjs +502 -0
  77. package/dist/hooks/useDismiss.cjs.map +1 -0
  78. package/dist/hooks/useHoverFloatingInteraction.cjs +233 -0
  79. package/dist/hooks/useHoverFloatingInteraction.cjs.map +1 -0
  80. package/dist/image/AvatarImage.cjs +4 -4
  81. package/dist/image/AvatarImage.cjs.map +1 -1
  82. package/dist/image/AvatarImage.js +1 -1
  83. package/dist/increment/NumberFieldIncrement.cjs +113 -0
  84. package/dist/increment/NumberFieldIncrement.cjs.map +1 -0
  85. package/dist/increment/NumberFieldIncrement.js +108 -0
  86. package/dist/increment/NumberFieldIncrement.js.map +1 -0
  87. package/dist/index.cjs +80 -8
  88. package/dist/index.d.cts +4328 -1600
  89. package/dist/index.d.cts.map +1 -1
  90. package/dist/index.d.ts +4328 -1600
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +8 -4
  93. package/dist/index2.cjs +9435 -3236
  94. package/dist/index2.cjs.map +1 -1
  95. package/dist/index2.js +8905 -3049
  96. package/dist/index2.js.map +1 -1
  97. package/dist/rolldown-runtime.js +36 -0
  98. package/package.json +1 -1
  99. package/src/floating-ui-vue/components/FloatingPortal.ts +171 -0
  100. package/src/floating-ui-vue/components/FloatingPortal.vue +259 -0
  101. package/src/floating-ui-vue/components/FloatingRootStore.ts +83 -0
  102. package/src/floating-ui-vue/components/FloatingTree.ts +64 -0
  103. package/src/floating-ui-vue/components/FloatingTreeStore.ts +21 -0
  104. package/src/floating-ui-vue/hooks/useDismiss.ts +689 -0
  105. package/src/floating-ui-vue/hooks/useHoverFloatingInteraction.ts +244 -0
  106. package/src/floating-ui-vue/hooks/useHoverInteractionSharedState.ts +125 -0
  107. package/src/floating-ui-vue/hooks/useHoverShared.ts +53 -0
  108. package/src/floating-ui-vue/index.ts +48 -0
  109. package/src/floating-ui-vue/middleware/arrow.ts +114 -0
  110. package/src/floating-ui-vue/types.ts +117 -0
  111. package/src/floating-ui-vue/utils/composite.ts +20 -0
  112. package/src/floating-ui-vue/utils/constants.ts +2 -0
  113. package/src/floating-ui-vue/utils/createAttribute.ts +3 -0
  114. package/src/floating-ui-vue/utils/createEventEmitter.ts +20 -0
  115. package/src/floating-ui-vue/utils/element.ts +59 -0
  116. package/src/floating-ui-vue/utils/event.ts +15 -0
  117. package/src/floating-ui-vue/utils/nodes.ts +14 -0
  118. package/src/floating-ui-vue/utils/tabbable.ts +309 -0
  119. package/src/index.ts +7 -1
  120. package/src/number-field/decrement/NumberFieldDecrement.vue +109 -0
  121. package/src/number-field/group/NumberFieldGroup.vue +47 -0
  122. package/src/number-field/increment/NumberFieldIncrement.vue +109 -0
  123. package/src/number-field/index.ts +42 -0
  124. package/src/number-field/input/NumberFieldInput.vue +455 -0
  125. package/src/number-field/root/NumberFieldRoot.vue +626 -0
  126. package/src/number-field/root/NumberFieldRootContext.ts +94 -0
  127. package/src/number-field/root/useNumberFieldButton.ts +171 -0
  128. package/src/number-field/scrub-area/NumberFieldScrubArea.vue +359 -0
  129. package/src/number-field/scrub-area/NumberFieldScrubAreaContext.ts +26 -0
  130. package/src/number-field/scrub-area-cursor/NumberFieldScrubAreaCursor.vue +75 -0
  131. package/src/number-field/utils/constants.ts +4 -0
  132. package/src/number-field/utils/getViewportRect.ts +34 -0
  133. package/src/number-field/utils/parse.ts +248 -0
  134. package/src/number-field/utils/stateAttributesMapping.ts +9 -0
  135. package/src/number-field/utils/subscribeToVisualViewportResize.ts +27 -0
  136. package/src/number-field/utils/types.ts +24 -0
  137. package/src/number-field/utils/validate.ts +120 -0
  138. package/src/otp-field/index.ts +22 -0
  139. package/src/otp-field/input/OtpFieldInput.vue +336 -0
  140. package/src/otp-field/root/OtpFieldRoot.vue +583 -0
  141. package/src/otp-field/root/OtpFieldRootContext.ts +81 -0
  142. package/src/otp-field/utils/otp.ts +135 -0
  143. package/src/otp-field/utils/stateAttributesMapping.ts +16 -0
  144. package/src/radio/index.ts +28 -0
  145. package/src/radio/indicator/RadioIndicator.vue +90 -0
  146. package/src/radio/indicator/RadioIndicatorDataAttributes.ts +54 -0
  147. package/src/radio/root/RadioRoot.vue +544 -0
  148. package/src/radio/root/RadioRootContext.ts +18 -0
  149. package/src/radio/root/RadioRootDataAttributes.ts +46 -0
  150. package/src/radio/utils/stateAttributesMapping.ts +29 -0
  151. package/src/radio-group/RadioGroup.vue +381 -0
  152. package/src/radio-group/RadioGroupContext.ts +42 -0
  153. package/src/radio-group/RadioGroupDataAttributes.ts +6 -0
  154. package/src/radio-group/index.ts +10 -0
  155. package/src/tabs/index.ts +38 -0
  156. package/src/tabs/indicator/TabsIndicator.vue +201 -0
  157. package/src/tabs/indicator/TabsIndicatorCssVars.ts +26 -0
  158. package/src/tabs/indicator/TabsIndicatorDataAttributes.ts +12 -0
  159. package/src/tabs/indicator/prehydrationScript.min.ts +5 -0
  160. package/src/tabs/indicator/prehydrationScript.template.js +87 -0
  161. package/src/tabs/list/TabsList.vue +201 -0
  162. package/src/tabs/list/TabsListContext.ts +29 -0
  163. package/src/tabs/list/TabsListDataAttributes.ts +12 -0
  164. package/src/tabs/panel/TabsPanel.vue +167 -0
  165. package/src/tabs/panel/TabsPanelDataAttributes.ts +28 -0
  166. package/src/tabs/root/TabsRoot.vue +468 -0
  167. package/src/tabs/root/TabsRootContext.ts +56 -0
  168. package/src/tabs/root/TabsRootDataAttributes.ts +12 -0
  169. package/src/tabs/root/stateAttributesMapping.ts +9 -0
  170. package/src/tabs/tab/TabsTab.vue +274 -0
  171. package/src/tabs/tab/TabsTabDataAttributes.ts +20 -0
  172. package/src/tabs/utils/areTabValuesEqual.ts +6 -0
  173. package/src/tooltip/arrow/TooltipArrow.vue +116 -0
  174. package/src/tooltip/arrow/TooltipArrowDataAttributes.ts +31 -0
  175. package/src/tooltip/index.ts +54 -0
  176. package/src/tooltip/popup/TooltipPopup.vue +142 -0
  177. package/src/tooltip/popup/TooltipPopupDataAttributes.ts +35 -0
  178. package/src/tooltip/portal/TooltipPortal.vue +83 -0
  179. package/src/tooltip/portal/TooltipPortalContext.ts +19 -0
  180. package/src/tooltip/positioner/TooltipPositioner.vue +221 -0
  181. package/src/tooltip/positioner/TooltipPositionerContext.ts +23 -0
  182. package/src/tooltip/positioner/TooltipPositionerCssVars.ts +27 -0
  183. package/src/tooltip/positioner/TooltipPositionerDataAttributes.ts +26 -0
  184. package/src/tooltip/provider/TooltipProvider.vue +78 -0
  185. package/src/tooltip/provider/TooltipProviderContext.ts +19 -0
  186. package/src/tooltip/root/TooltipRoot.vue +401 -0
  187. package/src/tooltip/root/TooltipRootContext.ts +71 -0
  188. package/src/tooltip/store/TooltipHandle.ts +215 -0
  189. package/src/tooltip/trigger/TooltipTrigger.vue +343 -0
  190. package/src/tooltip/trigger/TooltipTriggerDataAttributes.ts +12 -0
  191. package/src/tooltip/utils/constants.ts +2 -0
  192. package/src/tooltip/viewport/TooltipViewport.vue +149 -0
  193. package/src/tooltip/viewport/TooltipViewportCssVars.ts +14 -0
  194. package/src/tooltip/viewport/TooltipViewportDataAttributes.ts +26 -0
  195. package/src/utils/FloatingPortalLite.vue +66 -0
  196. package/src/utils/FocusGuard.vue +36 -0
  197. package/src/utils/adaptiveOriginMiddleware.ts +79 -0
  198. package/src/utils/addEventListener.ts +16 -0
  199. package/src/utils/constants.ts +11 -0
  200. package/src/utils/createBaseUIEventDetails.ts +2 -0
  201. package/src/utils/detectBrowser.ts +15 -0
  202. package/src/utils/formatNumber.ts +35 -2
  203. package/src/utils/getCssDimensions.ts +19 -0
  204. package/src/utils/getDisabledMountTransitionStyles.ts +9 -0
  205. package/src/utils/hideMiddleware.ts +19 -0
  206. package/src/utils/mergeCleanups.ts +7 -0
  207. package/src/utils/platform.ts +18 -0
  208. package/src/utils/popupStateMapping.ts +103 -0
  209. package/src/utils/reasons.ts +4 -0
  210. package/src/utils/serializeValue.ts +17 -0
  211. package/src/utils/useAnchorPositioning.ts +644 -0
  212. package/src/utils/useInterval.ts +45 -0
  213. package/src/utils/usePopupAutoResize.ts +254 -0
  214. package/src/utils/usePopupViewport.ts +398 -0
  215. package/src/utils/usePositioner.ts +61 -0
  216. package/src/utils/usePressAndHold.ts +260 -0
  217. package/src/utils/useRenderElement.ts +3 -0
  218. package/src/utils/useValueChanged.ts +21 -0
@@ -0,0 +1,336 @@
1
+ <script setup lang="ts">
2
+ import type { ComponentPublicInstance } from 'vue'
3
+ import type { BaseUIComponentProps } from '../../utils/types'
4
+ import type { OtpFieldRootState } from '../root/OtpFieldRoot.vue'
5
+ import { computed, ref, useAttrs } from 'vue'
6
+ import { IndexGuessBehavior, useCompositeListItem } from '../../composite/list/useCompositeListItem'
7
+ import { useDirection } from '../../direction-provider/DirectionContext'
8
+ import { stopEvent } from '../../floating-ui-vue/utils'
9
+ import { mergeProps } from '../../merge-props/mergeProps'
10
+ import { createChangeEventDetails, createGenericEventDetails } from '../../utils/createBaseUIEventDetails'
11
+ import { REASONS } from '../../utils/reasons'
12
+ import { useRenderElement } from '../../utils/useRenderElement'
13
+ import { getOtpFieldInputState, useOtpFieldRootContext } from '../root/OtpFieldRootContext'
14
+ import { getOTPCharacter, getOTPValueLength, normalizeOTPValueWithDetails, removeOTPCharacter, replaceOTPValue } from '../utils/otp'
15
+ import { inputStateAttributesMapping } from '../utils/stateAttributesMapping'
16
+
17
+ export interface OtpFieldInputState extends Omit<OtpFieldRootState, 'filled' | 'value'> {
18
+ /**
19
+ * Whether this input contains a character.
20
+ */
21
+ filled: boolean
22
+ /**
23
+ * The input index.
24
+ */
25
+ index: number
26
+ /**
27
+ * The character rendered in this slot.
28
+ */
29
+ value: string
30
+ }
31
+
32
+ export interface OtpFieldInputProps extends BaseUIComponentProps<OtpFieldInputState> {}
33
+
34
+ defineOptions({
35
+ name: 'OtpFieldInput',
36
+ inheritAttrs: false,
37
+ })
38
+
39
+ const props = defineProps<OtpFieldInputProps>()
40
+
41
+ const attrs = useAttrs()
42
+ const attrsObject = attrs as Record<string, any>
43
+
44
+ const {
45
+ activeIndex,
46
+ autoComplete,
47
+ disabled,
48
+ form,
49
+ focusInput,
50
+ queueFocusInput,
51
+ getInputId,
52
+ handleInputBlur,
53
+ handleInputFocus,
54
+ inputMode,
55
+ inputAriaLabelledBy,
56
+ invalid,
57
+ length,
58
+ mask,
59
+ pattern,
60
+ reportValueInvalid,
61
+ readOnly,
62
+ required,
63
+ normalizeValue,
64
+ setValue,
65
+ state,
66
+ validationType,
67
+ value,
68
+ } = useOtpFieldRootContext()
69
+
70
+ const { ref: listItemRef, index } = useCompositeListItem({
71
+ indexGuessBehavior: () => IndexGuessBehavior.GuessFromOrder,
72
+ })
73
+ const inputRef = ref<HTMLInputElement | null>(null)
74
+ const direction = useDirection()
75
+
76
+ const slotValue = computed(() => getOTPCharacter(value.value, index.value))
77
+ const inputState = computed(() => getOtpFieldInputState(state.value, slotValue.value, index.value))
78
+
79
+ const externalAriaLabel = computed(() => attrs['aria-label'] as string | undefined)
80
+ const externalAriaLabelledBy = computed(() => attrs['aria-labelledby'] as string | undefined)
81
+ const inheritedLabel = computed(() => externalAriaLabelledBy.value ?? inputAriaLabelledBy.value)
82
+ const ariaLabel = computed(() => (index.value === 0 ? undefined : externalAriaLabel.value))
83
+
84
+ function setInputRef(el: Element | ComponentPublicInstance | null) {
85
+ listItemRef(el as HTMLElement | null)
86
+ inputRef.value = el as HTMLInputElement | null
87
+ }
88
+
89
+ function onMousedown(event: MouseEvent) {
90
+ if (event.defaultPrevented || disabled.value) {
91
+ return
92
+ }
93
+
94
+ event.preventDefault()
95
+ focusInput(index.value)
96
+ }
97
+
98
+ function onFocus(event: FocusEvent) {
99
+ if (event.defaultPrevented || disabled.value) {
100
+ return
101
+ }
102
+
103
+ handleInputFocus(index.value, event)
104
+ }
105
+
106
+ function onBlur(event: FocusEvent) {
107
+ if (event.defaultPrevented) {
108
+ return
109
+ }
110
+
111
+ handleInputBlur(event)
112
+ }
113
+
114
+ function onInput(event: Event) {
115
+ const target = event.target as HTMLInputElement
116
+ if (event.defaultPrevented || disabled.value || readOnly.value) {
117
+ return
118
+ }
119
+
120
+ const rawValue = target.value
121
+ const [nextDigits, didRejectCharacters] = normalizeOTPValueWithDetails(
122
+ rawValue,
123
+ length.value,
124
+ validationType.value,
125
+ normalizeValue.value,
126
+ )
127
+
128
+ if (didRejectCharacters) {
129
+ reportValueInvalid(rawValue, createGenericEventDetails(REASONS.inputChange, event))
130
+ }
131
+
132
+ if (nextDigits === '') {
133
+ if (rawValue === '') {
134
+ setValue(
135
+ removeOTPCharacter(value.value, index.value),
136
+ createChangeEventDetails(REASONS.inputClear, event),
137
+ )
138
+ }
139
+ target.value = slotValue.value
140
+
141
+ if (slotValue.value !== '') {
142
+ target.select()
143
+ }
144
+ return
145
+ }
146
+
147
+ const nextValue = replaceOTPValue(
148
+ value.value,
149
+ index.value,
150
+ nextDigits,
151
+ length.value,
152
+ validationType.value,
153
+ normalizeValue.value,
154
+ )
155
+
156
+ const committedValue = setValue(nextValue, createChangeEventDetails(REASONS.inputChange, event))
157
+
158
+ if (committedValue != null) {
159
+ const nextInput = Math.min(index.value + getOTPValueLength(nextDigits), length.value - 1)
160
+ queueFocusInput(nextInput, committedValue)
161
+ }
162
+ }
163
+
164
+ function onKeydown(event: KeyboardEvent) {
165
+ if (event.defaultPrevented || disabled.value) {
166
+ return
167
+ }
168
+
169
+ const firstIndex = 0
170
+ const lastIndex = Math.max(length.value - 1, firstIndex)
171
+ const endTargetIndex = Math.min(getOTPValueLength(value.value), lastIndex)
172
+ const hasBoundaryModifier = (event.ctrlKey || event.metaKey) && !event.altKey
173
+ const isRtl = direction.value === 'rtl'
174
+ const previousKey = isRtl ? 'ArrowRight' : 'ArrowLeft'
175
+ const nextKey = isRtl ? 'ArrowLeft' : 'ArrowRight'
176
+
177
+ if (event.key === previousKey) {
178
+ stopEvent(event)
179
+ focusInput(hasBoundaryModifier ? firstIndex : Math.max(firstIndex, index.value - 1))
180
+ return
181
+ }
182
+
183
+ if (event.key === nextKey) {
184
+ stopEvent(event)
185
+ focusInput(hasBoundaryModifier ? endTargetIndex : Math.min(lastIndex, index.value + 1))
186
+ return
187
+ }
188
+
189
+ if (event.key === 'Home' || event.key === 'ArrowUp') {
190
+ stopEvent(event)
191
+ focusInput(firstIndex)
192
+ return
193
+ }
194
+
195
+ if (event.key === 'End' || event.key === 'ArrowDown') {
196
+ stopEvent(event)
197
+ focusInput(endTargetIndex)
198
+ return
199
+ }
200
+
201
+ if (readOnly.value) {
202
+ return
203
+ }
204
+
205
+ function setKeyboardValue(nextValue: string, targetIndex: number) {
206
+ const committedValue = setValue(nextValue, createChangeEventDetails(REASONS.keyboard, event))
207
+
208
+ if (committedValue != null) {
209
+ queueFocusInput(targetIndex, committedValue)
210
+ }
211
+ }
212
+
213
+ if (event.key === 'Backspace' && hasBoundaryModifier) {
214
+ stopEvent(event)
215
+ setKeyboardValue('', firstIndex)
216
+ return
217
+ }
218
+
219
+ if (event.key === 'Delete') {
220
+ stopEvent(event)
221
+ setKeyboardValue(removeOTPCharacter(value.value, index.value), index.value)
222
+ return
223
+ }
224
+
225
+ const target = event.currentTarget as HTMLInputElement
226
+ const inputValue = target.value
227
+ const fullSelection = target.selectionStart === 0 && target.selectionEnd === inputValue.length
228
+
229
+ if (getOTPValueLength(event.key) === 1 && fullSelection && slotValue.value === event.key) {
230
+ stopEvent(event)
231
+ if (index.value < length.value - 1) {
232
+ focusInput(index.value + 1)
233
+ }
234
+ return
235
+ }
236
+
237
+ if (event.key === 'Backspace') {
238
+ stopEvent(event)
239
+ const targetIndex = Math.max(firstIndex, index.value - 1)
240
+ const deleteIndex = slotValue.value === '' ? targetIndex : index.value
241
+ setKeyboardValue(removeOTPCharacter(value.value, deleteIndex), targetIndex)
242
+ }
243
+ }
244
+
245
+ function onPaste(event: ClipboardEvent) {
246
+ if (event.defaultPrevented || disabled.value || readOnly.value) {
247
+ return
248
+ }
249
+
250
+ let rawValue = ''
251
+
252
+ try {
253
+ rawValue = event.clipboardData?.getData('text/plain') ?? ''
254
+ }
255
+ catch {
256
+ return
257
+ }
258
+
259
+ event.preventDefault()
260
+
261
+ const [nextDigits, didRejectCharacters] = normalizeOTPValueWithDetails(
262
+ rawValue,
263
+ length.value,
264
+ validationType.value,
265
+ normalizeValue.value,
266
+ )
267
+
268
+ if (didRejectCharacters) {
269
+ reportValueInvalid(rawValue, createGenericEventDetails(REASONS.inputPaste, event))
270
+ }
271
+
272
+ if (nextDigits === '') {
273
+ return
274
+ }
275
+
276
+ const committedValue = setValue(
277
+ replaceOTPValue(value.value, index.value, nextDigits, length.value, validationType.value, normalizeValue.value),
278
+ createChangeEventDetails(REASONS.inputPaste, event),
279
+ )
280
+
281
+ if (committedValue != null) {
282
+ const nextInput = Math.min(index.value + getOTPValueLength(nextDigits), length.value - 1)
283
+ queueFocusInput(nextInput, committedValue)
284
+ }
285
+ }
286
+
287
+ const inputProps = computed(() => mergeProps(
288
+ attrsObject,
289
+ {
290
+ 'id': getInputId(index.value),
291
+ 'value': slotValue.value,
292
+ 'type': attrsObject.type ?? (mask.value ? 'password' : 'text'),
293
+ 'inputmode': inputMode.value,
294
+ 'autocomplete': index.value === 0 ? autoComplete.value : 'off',
295
+ 'autocorrect': 'off',
296
+ 'spellcheck': 'false',
297
+ 'enterkeyhint': index.value === length.value - 1 ? 'done' : 'next',
298
+ // Only the first slot has a max length to avoid password manager bubbles appearing after later inputs.
299
+ 'maxlength': index.value === 0 ? length.value : undefined,
300
+ 'tabindex': activeIndex.value === index.value ? 0 : -1,
301
+ 'disabled': disabled.value,
302
+ 'form': form.value,
303
+ 'pattern': pattern.value,
304
+ 'readonly': readOnly.value,
305
+ 'required': required.value,
306
+ 'aria-labelledby': ariaLabel.value == null ? inheritedLabel.value : undefined,
307
+ 'aria-invalid': !disabled.value && invalid.value ? true : undefined,
308
+ 'aria-label': ariaLabel.value,
309
+ 'onMousedown': onMousedown,
310
+ 'onFocus': onFocus,
311
+ 'onBlur': onBlur,
312
+ 'onInput': onInput,
313
+ 'onKeydown': onKeydown,
314
+ 'onPaste': onPaste,
315
+ },
316
+ ))
317
+
318
+ const {
319
+ tag,
320
+ mergedProps,
321
+ renderless,
322
+ ref: renderRef,
323
+ } = useRenderElement({
324
+ componentProps: props,
325
+ state: inputState,
326
+ props: inputProps,
327
+ stateAttributesMapping: inputStateAttributesMapping,
328
+ defaultTagName: 'input',
329
+ ref: setInputRef,
330
+ })
331
+ </script>
332
+
333
+ <template>
334
+ <slot v-if="renderless" :ref="renderRef" :props="mergedProps" :state="inputState" />
335
+ <component :is="tag" v-else :ref="renderRef" v-bind="mergedProps" />
336
+ </template>