UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

1 lines 29.5 kB
{"version":3,"file":"BFormOtp-DYjsPhQN.mjs","names":[],"sources":["../../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/shared/useArrowNavigation.js","../../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/PinInput/PinInputRoot.js","../../../node_modules/.pnpm/reka-ui@2.9.2_vue@3.5.31_typescript@5.9.3_/node_modules/reka-ui/dist/PinInput/PinInputInput.js","../src/components/BFormOtp/BFormOtp.vue","../src/components/BFormOtp/BFormOtp.vue"],"sourcesContent":["//#region src/shared/useArrowNavigation.ts\nconst ignoredElement = [\"INPUT\", \"TEXTAREA\"];\n/**\n* Allow arrow navigation for every html element with data-reka-collection-item tag\n*\n* @param e Keyboard event\n* @param currentElement Event initiator element or any element that wants to handle the navigation\n* @param parentElement Parent element where contains all the collection items, this will collect every item to be used when nav\n* @param options further options\n* @returns the navigated html element or null if none\n*/\nfunction useArrowNavigation(e, currentElement, parentElement, options = {}) {\n\tif (!currentElement || options.enableIgnoredElement && ignoredElement.includes(currentElement.nodeName)) return null;\n\tconst { arrowKeyOptions = \"both\", attributeName = \"[data-reka-collection-item]\", itemsArray = [], loop = true, dir = \"ltr\", preventScroll = true, focus = false } = options;\n\tconst [right, left, up, down, home, end] = [\n\t\te.key === \"ArrowRight\",\n\t\te.key === \"ArrowLeft\",\n\t\te.key === \"ArrowUp\",\n\t\te.key === \"ArrowDown\",\n\t\te.key === \"Home\",\n\t\te.key === \"End\"\n\t];\n\tconst goingVertical = up || down;\n\tconst goingHorizontal = right || left;\n\tif (!home && !end && (!goingVertical && !goingHorizontal || arrowKeyOptions === \"vertical\" && goingHorizontal || arrowKeyOptions === \"horizontal\" && goingVertical)) return null;\n\tconst allCollectionItems = parentElement ? Array.from(parentElement.querySelectorAll(attributeName)) : itemsArray;\n\tif (!allCollectionItems.length) return null;\n\tif (preventScroll) e.preventDefault();\n\tlet item = null;\n\tif (goingHorizontal || goingVertical) {\n\t\tconst goForward = goingVertical ? down : dir === \"ltr\" ? right : left;\n\t\titem = findNextFocusableElement(allCollectionItems, currentElement, {\n\t\t\tgoForward,\n\t\t\tloop\n\t\t});\n\t} else if (home) item = allCollectionItems.at(0) || null;\n\telse if (end) item = allCollectionItems.at(-1) || null;\n\tif (focus) item?.focus();\n\treturn item;\n}\n/**\n* Recursive function to find the next focusable element to avoid disabled elements\n*\n* @param elements Elements to navigate\n* @param currentElement Current active element\n* @param options\n* @returns next focusable element\n*/\nfunction findNextFocusableElement(elements, currentElement, options, iterations = !elements.includes(currentElement) ? elements.length + 1 : elements.length) {\n\tif (--iterations === 0) return null;\n\tconst index = elements.indexOf(currentElement);\n\tlet newIndex;\n\tif (index === -1) newIndex = options.goForward ? 0 : elements.length - 1;\n\telse newIndex = options.goForward ? index + 1 : index - 1;\n\tif (!options.loop && (newIndex < 0 || newIndex >= elements.length)) return null;\n\tconst adjustedNewIndex = (newIndex + elements.length) % elements.length;\n\tconst candidate = elements[adjustedNewIndex];\n\tif (!candidate) return null;\n\tconst isDisabled = candidate.hasAttribute(\"disabled\") && candidate.getAttribute(\"disabled\") !== \"false\";\n\tif (isDisabled) return findNextFocusableElement(elements, candidate, options, iterations);\n\treturn candidate;\n}\n\n//#endregion\nexport { useArrowNavigation };\n//# sourceMappingURL=useArrowNavigation.js.map","import { createContext } from \"../shared/createContext.js\";\nimport { useDirection } from \"../shared/useDirection.js\";\nimport { useForwardExpose } from \"../shared/useForwardExpose.js\";\nimport { Primitive } from \"../Primitive/Primitive.js\";\nimport { VisuallyHiddenInput_default } from \"../VisuallyHidden/VisuallyHiddenInput.js\";\nimport { computed, createBlock, createVNode, defineComponent, mergeProps, openBlock, ref, renderSlot, toRefs, unref, watch, withCtx } from \"vue\";\nimport { useVModel } from \"@vueuse/core\";\n\n//#region src/PinInput/PinInputRoot.vue?vue&type=script&setup=true&lang.ts\nconst [injectPinInputRootContext, providePinInputRootContext] = createContext(\"PinInputRoot\");\nvar PinInputRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({\n\tinheritAttrs: false,\n\t__name: \"PinInputRoot\",\n\tprops: {\n\t\tmodelValue: {\n\t\t\ttype: null,\n\t\t\trequired: false\n\t\t},\n\t\tdefaultValue: {\n\t\t\ttype: null,\n\t\t\trequired: false\n\t\t},\n\t\tplaceholder: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t\tdefault: \"\"\n\t\t},\n\t\tmask: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\totp: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\ttype: {\n\t\t\ttype: null,\n\t\t\trequired: false,\n\t\t\tdefault: \"text\"\n\t\t},\n\t\tdir: {\n\t\t\ttype: String,\n\t\t\trequired: false\n\t\t},\n\t\tdisabled: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\tid: {\n\t\t\ttype: String,\n\t\t\trequired: false\n\t\t},\n\t\tasChild: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\tas: {\n\t\t\ttype: null,\n\t\t\trequired: false\n\t\t},\n\t\tname: {\n\t\t\ttype: String,\n\t\t\trequired: false\n\t\t},\n\t\trequired: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t}\n\t},\n\temits: [\"update:modelValue\", \"complete\"],\n\tsetup(__props, { emit: __emit }) {\n\t\tconst props = __props;\n\t\tconst emits = __emit;\n\t\tconst { mask, otp, placeholder, type, disabled, dir: propDir } = toRefs(props);\n\t\tconst { forwardRef } = useForwardExpose();\n\t\tconst dir = useDirection(propDir);\n\t\tconst modelValue = useVModel(props, \"modelValue\", emits, {\n\t\t\tdefaultValue: props.defaultValue ?? [],\n\t\t\tpassive: true,\n\t\t\tdeep: true\n\t\t});\n\t\tconst currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...modelValue.value] : []);\n\t\tconst inputElements = ref(/* @__PURE__ */ new Set());\n\t\tfunction onInputElementChange(el) {\n\t\t\tinputElements.value.add(el);\n\t\t}\n\t\tconst isNumericMode = computed(() => props.type === \"number\");\n\t\tconst isCompleted = computed(() => {\n\t\t\tconst modelValues = currentModelValue.value.filter((i) => !!i || isNumericMode.value && i === 0);\n\t\t\treturn modelValues.length === inputElements.value.size;\n\t\t});\n\t\twatch(modelValue, () => {\n\t\t\tif (isCompleted.value) emits(\"complete\", modelValue.value);\n\t\t}, { deep: true });\n\t\tprovidePinInputRootContext({\n\t\t\tmodelValue,\n\t\t\tcurrentModelValue,\n\t\t\tmask,\n\t\t\totp,\n\t\t\tplaceholder,\n\t\t\ttype,\n\t\t\tdir,\n\t\t\tdisabled,\n\t\t\tisCompleted,\n\t\t\tinputElements,\n\t\t\tonInputElementChange,\n\t\t\tisNumericMode\n\t\t});\n\t\treturn (_ctx, _cache) => {\n\t\t\treturn openBlock(), createBlock(unref(Primitive), mergeProps(_ctx.$attrs, {\n\t\t\t\tref: unref(forwardRef),\n\t\t\t\tdir: unref(dir),\n\t\t\t\t\"data-complete\": isCompleted.value ? \"\" : void 0,\n\t\t\t\t\"data-disabled\": unref(disabled) ? \"\" : void 0\n\t\t\t}), {\n\t\t\t\tdefault: withCtx(() => [renderSlot(_ctx.$slots, \"default\", { modelValue: unref(modelValue) }), createVNode(VisuallyHiddenInput_default, {\n\t\t\t\t\tid: _ctx.id,\n\t\t\t\t\tas: \"input\",\n\t\t\t\t\tfeature: \"focusable\",\n\t\t\t\t\ttabindex: \"-1\",\n\t\t\t\t\tvalue: currentModelValue.value.join(\"\"),\n\t\t\t\t\tname: _ctx.name ?? \"\",\n\t\t\t\t\tdisabled: unref(disabled),\n\t\t\t\t\trequired: _ctx.required,\n\t\t\t\t\tonFocus: _cache[0] || (_cache[0] = ($event) => Array.from(inputElements.value)?.[0]?.focus())\n\t\t\t\t}, null, 8, [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"value\",\n\t\t\t\t\t\"name\",\n\t\t\t\t\t\"disabled\",\n\t\t\t\t\t\"required\"\n\t\t\t\t])]),\n\t\t\t\t_: 3\n\t\t\t}, 16, [\n\t\t\t\t\"dir\",\n\t\t\t\t\"data-complete\",\n\t\t\t\t\"data-disabled\"\n\t\t\t]);\n\t\t};\n\t}\n});\n\n//#endregion\n//#region src/PinInput/PinInputRoot.vue\nvar PinInputRoot_default = PinInputRoot_vue_vue_type_script_setup_true_lang_default;\n\n//#endregion\nexport { PinInputRoot_default, injectPinInputRootContext };\n//# sourceMappingURL=PinInputRoot.js.map","import { getActiveElement } from \"../shared/getActiveElement.js\";\nimport { useArrowNavigation } from \"../shared/useArrowNavigation.js\";\nimport { Primitive } from \"../Primitive/Primitive.js\";\nimport { usePrimitiveElement } from \"../Primitive/usePrimitiveElement.js\";\nimport { injectPinInputRootContext } from \"./PinInputRoot.js\";\nimport { computed, createBlock, defineComponent, nextTick, onMounted, onUnmounted, openBlock, renderSlot, unref, watch, withCtx, withKeys } from \"vue\";\n\n//#region src/PinInput/PinInputInput.vue?vue&type=script&setup=true&lang.ts\nvar PinInputInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({\n\t__name: \"PinInputInput\",\n\tprops: {\n\t\tindex: {\n\t\t\ttype: Number,\n\t\t\trequired: true\n\t\t},\n\t\tdisabled: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\tasChild: {\n\t\t\ttype: Boolean,\n\t\t\trequired: false\n\t\t},\n\t\tas: {\n\t\t\ttype: null,\n\t\t\trequired: false,\n\t\t\tdefault: \"input\"\n\t\t}\n\t},\n\tsetup(__props) {\n\t\tconst props = __props;\n\t\tconst context = injectPinInputRootContext();\n\t\tconst inputElements = computed(() => Array.from(context.inputElements.value));\n\t\tconst currentValue = computed(() => context.currentModelValue.value[props.index]);\n\t\tconst disabled = computed(() => props.disabled || context.disabled.value);\n\t\tconst isOtpMode = computed(() => context.otp.value);\n\t\tconst isPasswordMode = computed(() => context.mask.value);\n\t\tconst { primitiveElement, currentElement } = usePrimitiveElement();\n\t\tfunction handleInput(event) {\n\t\t\tconst target = event.target;\n\t\t\tif ((event.data?.length ?? 0) > 1) {\n\t\t\t\thandleMultipleCharacter(target.value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (context.isNumericMode.value && !/^\\d*$/.test(target.value)) {\n\t\t\t\ttarget.value = target.value.replace(/\\D/g, \"\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttarget.value = event.data || target.value.slice(-1);\n\t\t\tupdateModelValueAt(props.index, target.value);\n\t\t\tconst nextEl = inputElements.value[props.index + 1];\n\t\t\tif (nextEl) nextEl.focus();\n\t\t}\n\t\tfunction updatePlaceholder() {\n\t\t\tnextTick(() => {\n\t\t\t\tconst target = currentElement.value;\n\t\t\t\tif (!target) return;\n\t\t\t\tif (!target.value && target === getActiveElement()) target.placeholder = \"\";\n\t\t\t\telse target.placeholder = context.placeholder.value;\n\t\t\t});\n\t\t}\n\t\tfunction handleKeydown(event) {\n\t\t\tuseArrowNavigation(event, getActiveElement(), void 0, {\n\t\t\t\titemsArray: inputElements.value,\n\t\t\t\tfocus: true,\n\t\t\t\tloop: false,\n\t\t\t\tarrowKeyOptions: \"horizontal\",\n\t\t\t\tdir: context.dir.value\n\t\t\t});\n\t\t}\n\t\tfunction handleBackspace(event) {\n\t\t\tevent.preventDefault();\n\t\t\tconst target = event.target;\n\t\t\tconst value = target.value;\n\t\t\tif (value) updateModelValueAt(props.index, \"\");\n\t\t\telse {\n\t\t\t\tconst prevEl = inputElements.value[props.index - 1];\n\t\t\t\tif (prevEl) {\n\t\t\t\t\tprevEl.focus();\n\t\t\t\t\tupdateModelValueAt(props.index - 1, \"\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfunction handleDelete(event) {\n\t\t\tif (event.key === \"Delete\") {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tupdateModelValueAt(props.index, \"\");\n\t\t\t}\n\t\t}\n\t\tfunction handleFocus(event) {\n\t\t\tif (context.otp.value) {\n\t\t\t\tconst firstEmptyInputIdx = inputElements.value.findIndex((_, idx) => context.currentModelValue.value[idx] === \"\" || context.currentModelValue.value[idx] === void 0);\n\t\t\t\tif (firstEmptyInputIdx !== -1 && firstEmptyInputIdx < props.index) {\n\t\t\t\t\tinputElements.value[firstEmptyInputIdx].focus();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst target = event.target;\n\t\t\ttarget.setSelectionRange(1, 1);\n\t\t\tupdatePlaceholder();\n\t\t}\n\t\tfunction handleBlur(event) {\n\t\t\tupdatePlaceholder();\n\t\t}\n\t\tfunction handlePaste(event) {\n\t\t\tevent.preventDefault();\n\t\t\tconst clipboardData = event.clipboardData;\n\t\t\tif (!clipboardData) return;\n\t\t\tconst values = clipboardData.getData(\"text\");\n\t\t\thandleMultipleCharacter(values);\n\t\t}\n\t\tfunction handleMultipleCharacter(values) {\n\t\t\tconst tempModelValue = [...context.currentModelValue.value];\n\t\t\tconst initialIndex = values.length >= inputElements.value.length ? 0 : props.index;\n\t\t\tconst lastIndex = Math.min(initialIndex + values.length, inputElements.value.length);\n\t\t\tfor (let i = initialIndex; i < lastIndex; i++) {\n\t\t\t\tconst input = inputElements.value[i];\n\t\t\t\tconst value = values[i - initialIndex];\n\t\t\t\tif (context.isNumericMode.value && !/^\\d*$/.test(value)) continue;\n\t\t\t\ttempModelValue[i] = value;\n\t\t\t\tinput.focus();\n\t\t\t}\n\t\t\tcontext.modelValue.value = tempModelValue;\n\t\t\tinputElements.value[lastIndex]?.focus();\n\t\t}\n\t\tfunction removeTrailingEmptyStrings(input) {\n\t\t\tlet i = input.length - 1;\n\t\t\twhile (i >= 0 && input[i] === \"\") {\n\t\t\t\tinput.pop();\n\t\t\t\ti--;\n\t\t\t}\n\t\t\treturn input;\n\t\t}\n\t\tfunction updateModelValueAt(index, value) {\n\t\t\tconst tempModelValue = [...context.currentModelValue.value];\n\t\t\tif (context.isNumericMode.value) {\n\t\t\t\tconst num = +value;\n\t\t\t\tif (value === \"\" || isNaN(num)) delete tempModelValue[index];\n\t\t\t\telse tempModelValue[index] = num;\n\t\t\t} else tempModelValue[index] = value;\n\t\t\tcontext.modelValue.value = removeTrailingEmptyStrings(tempModelValue);\n\t\t}\n\t\twatch(currentValue, updatePlaceholder);\n\t\tonMounted(() => {\n\t\t\tcontext.onInputElementChange(currentElement.value);\n\t\t});\n\t\tonUnmounted(() => {\n\t\t\tcontext.inputElements?.value.delete(currentElement.value);\n\t\t});\n\t\treturn (_ctx, _cache) => {\n\t\t\treturn openBlock(), createBlock(unref(Primitive), {\n\t\t\t\tref_key: \"primitiveElement\",\n\t\t\t\tref: primitiveElement,\n\t\t\t\tautocapitalize: \"none\",\n\t\t\t\tas: _ctx.as,\n\t\t\t\t\"as-child\": _ctx.asChild,\n\t\t\t\tautocomplete: isOtpMode.value ? \"one-time-code\" : \"false\",\n\t\t\t\ttype: isPasswordMode.value ? \"password\" : \"text\",\n\t\t\t\tinputmode: unref(context).isNumericMode.value ? \"numeric\" : \"text\",\n\t\t\t\tpattern: unref(context).isNumericMode.value ? \"[0-9]*\" : void 0,\n\t\t\t\tplaceholder: unref(context).placeholder.value,\n\t\t\t\tvalue: currentValue.value,\n\t\t\t\tdisabled: disabled.value,\n\t\t\t\t\"data-disabled\": disabled.value ? \"\" : void 0,\n\t\t\t\t\"data-complete\": unref(context).isCompleted.value ? \"\" : void 0,\n\t\t\t\t\"aria-label\": `pin input ${_ctx.index + 1} of ${inputElements.value.length}`,\n\t\t\t\tonInput: _cache[0] || (_cache[0] = ($event) => handleInput($event)),\n\t\t\t\tonKeydown: [\n\t\t\t\t\twithKeys(handleKeydown, [\n\t\t\t\t\t\t\"left\",\n\t\t\t\t\t\t\"right\",\n\t\t\t\t\t\t\"up\",\n\t\t\t\t\t\t\"down\",\n\t\t\t\t\t\t\"home\",\n\t\t\t\t\t\t\"end\"\n\t\t\t\t\t]),\n\t\t\t\t\twithKeys(handleBackspace, [\"backspace\"]),\n\t\t\t\t\twithKeys(handleDelete, [\"delete\"])\n\t\t\t\t],\n\t\t\t\tonFocus: handleFocus,\n\t\t\t\tonBlur: handleBlur,\n\t\t\t\tonPaste: handlePaste\n\t\t\t}, {\n\t\t\t\tdefault: withCtx(() => [renderSlot(_ctx.$slots, \"default\")]),\n\t\t\t\t_: 3\n\t\t\t}, 8, [\n\t\t\t\t\"as\",\n\t\t\t\t\"as-child\",\n\t\t\t\t\"autocomplete\",\n\t\t\t\t\"type\",\n\t\t\t\t\"inputmode\",\n\t\t\t\t\"pattern\",\n\t\t\t\t\"placeholder\",\n\t\t\t\t\"value\",\n\t\t\t\t\"disabled\",\n\t\t\t\t\"data-disabled\",\n\t\t\t\t\"data-complete\",\n\t\t\t\t\"aria-label\"\n\t\t\t]);\n\t\t};\n\t}\n});\n\n//#endregion\n//#region src/PinInput/PinInputInput.vue\nvar PinInputInput_default = PinInputInput_vue_vue_type_script_setup_true_lang_default;\n\n//#endregion\nexport { PinInputInput_default };\n//# sourceMappingURL=PinInputInput.js.map","<template>\n <PinInputRoot\n :id=\"computedId\"\n v-model=\"modelValue\"\n :class=\"rootClasses\"\n :disabled=\"props.disabled\"\n :dir=\"props.dir\"\n :mask=\"props.mask\"\n :name=\"props.name\"\n :otp=\"props.otp\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required\"\n :type=\"props.type\"\n @complete=\"emit('complete', $event)\"\n >\n <PinInputInput\n v-for=\"(_, i) in computedLength\"\n :key=\"i\"\n :index=\"i\"\n :disabled=\"props.disabled\"\n as-child\n >\n <BFormInput\n class=\"b-form-otp-field\"\n :aria-label=\"`${props.ariaLabel || 'Pin'} ${i + 1} of ${computedLength}`\"\n :aria-invalid=\"props.ariaInvalid\"\n :autofocus=\"props.autofocus && i === 0\"\n :disabled=\"props.disabled\"\n :form=\"props.form\"\n :plaintext=\"props.plaintext\"\n :readonly=\"props.readonly\"\n :size=\"props.size\"\n :state=\"props.state\"\n />\n </PinInputInput>\n </PinInputRoot>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {PinInputInput, PinInputRoot} from 'reka-ui'\nimport type {BFormOtpProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport BFormInput from '../BFormInput/BFormInput.vue'\n\nconst lengthDefault = 6\nconst _props = withDefaults(defineProps<Omit<BFormOtpProps, 'modelValue'>>(), {\n ariaInvalid: undefined,\n ariaLabel: undefined,\n autofocus: false,\n dir: undefined,\n disabled: false,\n form: undefined,\n id: undefined,\n length: lengthDefault,\n mask: false,\n name: undefined,\n otp: false,\n placeholder: '',\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: null,\n type: 'text',\n})\nconst props = useDefaults(_props, 'BFormOtp')\nconst emit = defineEmits<{\n complete: [value: string[]]\n}>()\n\nconst modelValue = defineModel<BFormOtpProps['modelValue']>({default: () => []})\n\nconst computedId = useId(() => props.id)\nconst lengthNumber = useToNumber(() => props.length, {nanToZero: true, method: 'parseInt'})\nconst computedLength = computed(() => (lengthNumber.value > 0 ? lengthNumber.value : lengthDefault))\n\nconst rootClasses = computed(() => [\n 'b-form-otp',\n 'd-flex',\n 'gap-2',\n 'align-items-center',\n {\n [`b-form-otp-${props.size}`]: !!props.size,\n },\n])\n</script>\n","<template>\n <PinInputRoot\n :id=\"computedId\"\n v-model=\"modelValue\"\n :class=\"rootClasses\"\n :disabled=\"props.disabled\"\n :dir=\"props.dir\"\n :mask=\"props.mask\"\n :name=\"props.name\"\n :otp=\"props.otp\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required\"\n :type=\"props.type\"\n @complete=\"emit('complete', $event)\"\n >\n <PinInputInput\n v-for=\"(_, i) in computedLength\"\n :key=\"i\"\n :index=\"i\"\n :disabled=\"props.disabled\"\n as-child\n >\n <BFormInput\n class=\"b-form-otp-field\"\n :aria-label=\"`${props.ariaLabel || 'Pin'} ${i + 1} of ${computedLength}`\"\n :aria-invalid=\"props.ariaInvalid\"\n :autofocus=\"props.autofocus && i === 0\"\n :disabled=\"props.disabled\"\n :form=\"props.form\"\n :plaintext=\"props.plaintext\"\n :readonly=\"props.readonly\"\n :size=\"props.size\"\n :state=\"props.state\"\n />\n </PinInputInput>\n </PinInputRoot>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {PinInputInput, PinInputRoot} from 'reka-ui'\nimport type {BFormOtpProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport BFormInput from '../BFormInput/BFormInput.vue'\n\nconst lengthDefault = 6\nconst _props = withDefaults(defineProps<Omit<BFormOtpProps, 'modelValue'>>(), {\n ariaInvalid: undefined,\n ariaLabel: undefined,\n autofocus: false,\n dir: undefined,\n disabled: false,\n form: undefined,\n id: undefined,\n length: lengthDefault,\n mask: false,\n name: undefined,\n otp: false,\n placeholder: '',\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: null,\n type: 'text',\n})\nconst props = useDefaults(_props, 'BFormOtp')\nconst emit = defineEmits<{\n complete: [value: string[]]\n}>()\n\nconst modelValue = defineModel<BFormOtpProps['modelValue']>({default: () => []})\n\nconst computedId = useId(() => props.id)\nconst lengthNumber = useToNumber(() => props.length, {nanToZero: true, method: 'parseInt'})\nconst computedLength = computed(() => (lengthNumber.value > 0 ? lengthNumber.value : lengthDefault))\n\nconst rootClasses = computed(() => [\n 'b-form-otp',\n 'd-flex',\n 'gap-2',\n 'align-items-center',\n {\n [`b-form-otp-${props.size}`]: !!props.size,\n },\n])\n</script>\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;;AACA,IAAM,iBAAiB,CAAC,SAAS,WAAW;;;;;;;;;;AAU5C,SAAS,mBAAmB,GAAG,gBAAgB,eAAe,UAA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