bootstrap-vue-next 1.2.3 → 1.2.5
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/dist/{BAccordion-nQptHiXD.js → BAccordion-BfaVicrj.js} +2 -2
- package/dist/{BAccordion-nQptHiXD.js.map → BAccordion-BfaVicrj.js.map} +1 -1
- package/dist/{BAlert-Bl3TOay3.js → BAlert-Czy83dU3.js} +5 -5
- package/dist/{BAlert-Bl3TOay3.js.map → BAlert-Czy83dU3.js.map} +1 -1
- package/dist/{BApp-Bg5xEz8H.js → BApp-DZ9AITOm.js} +22 -3
- package/dist/BApp-DZ9AITOm.js.map +1 -0
- package/dist/BAutocomplete-Bh4Bp5AI.js +437 -0
- package/dist/BAutocomplete-Bh4Bp5AI.js.map +1 -0
- package/dist/{BAvatar-BsStQrBF.js → BAvatar-BJNeQ1fe.js} +2 -2
- package/dist/{BAvatar-BsStQrBF.js.map → BAvatar-BJNeQ1fe.js.map} +1 -1
- package/dist/{BButton-KZu5jczf.js → BButton-DlOQ5sem.js} +2 -2
- package/dist/{BButton-KZu5jczf.js.map → BButton-DlOQ5sem.js.map} +1 -1
- package/dist/{BCard-DELccMG-.js → BCard-Bc1wed-3.js} +2 -2
- package/dist/{BCard-DELccMG-.js.map → BCard-Bc1wed-3.js.map} +1 -1
- package/dist/{BCarousel-BV2EiQRM.js → BCarousel-B-WZR469.js} +4 -5
- package/dist/{BCarousel-BV2EiQRM.js.map → BCarousel-B-WZR469.js.map} +1 -1
- package/dist/{BCollapse-B2q9Ya2S.js → BCollapse-DCjKiTxo.js} +2 -2
- package/dist/{BCollapse-B2q9Ya2S.js.map → BCollapse-DCjKiTxo.js.map} +1 -1
- package/dist/BDateField-Oh-cU-4i.js +456 -0
- package/dist/BDateField-Oh-cU-4i.js.map +1 -0
- package/dist/BDatePicker-HNI11eCe.js +632 -0
- package/dist/BDatePicker-HNI11eCe.js.map +1 -0
- package/dist/{BDropdown-D4gLdtmX.js → BDropdown-04nGcMhm.js} +6 -7
- package/dist/{BDropdown-D4gLdtmX.js.map → BDropdown-04nGcMhm.js.map} +1 -1
- package/dist/{BFormCheckbox-BYNGQgr2.js → BFormCheckbox-zjr8OsNd.js} +2 -2
- package/dist/{BFormCheckbox-BYNGQgr2.js.map → BFormCheckbox-zjr8OsNd.js.map} +1 -1
- package/dist/{BFormFile-C2DnrbK7.js → BFormFile-D_s8tf1m.js} +2 -2
- package/dist/{BFormFile-C2DnrbK7.js.map → BFormFile-D_s8tf1m.js.map} +1 -1
- package/dist/{BFormInput-_AkAy6Wk.js → BFormInput-DnIBPLCx.js} +2 -2
- package/dist/{BFormInput-_AkAy6Wk.js.map → BFormInput-DnIBPLCx.js.map} +1 -1
- package/dist/BFormOtp-Dx2RxPAW.js +150 -0
- package/dist/BFormOtp-Dx2RxPAW.js.map +1 -0
- package/dist/{BFormRadio-DAddcnfE.js → BFormRadio-DUz60sBI.js} +2 -2
- package/dist/{BFormRadio-DAddcnfE.js.map → BFormRadio-DUz60sBI.js.map} +1 -1
- package/dist/{BFormRating-iKFgSFet.js → BFormRating-CtMmDgrF.js} +2 -2
- package/dist/{BFormRating-iKFgSFet.js.map → BFormRating-CtMmDgrF.js.map} +1 -1
- package/dist/{BFormSelect-CSS-_kul.js → BFormSelect-CeslPN3i.js} +2 -3
- package/dist/{BFormSelect-CSS-_kul.js.map → BFormSelect-CeslPN3i.js.map} +1 -1
- package/dist/{BFormSpinbutton-fkVMbQC3.js → BFormSpinbutton-BR9YTfYy.js} +2 -3
- package/dist/{BFormSpinbutton-fkVMbQC3.js.map → BFormSpinbutton-BR9YTfYy.js.map} +1 -1
- package/dist/{BFormTags-CUcyRTCK.js → BFormTags-6qQn0Vlv.js} +2 -3
- package/dist/{BFormTags-CUcyRTCK.js.map → BFormTags-6qQn0Vlv.js.map} +1 -1
- package/dist/{BFormTextarea-CBBlEcrV.js → BFormTextarea-DvLrtG08.js} +3 -3
- package/dist/{BFormTextarea-CBBlEcrV.js.map → BFormTextarea-DvLrtG08.js.map} +1 -1
- package/dist/{BImg-knz2UZQE.js → BImg-Dd8Pc1Ln.js} +2 -2
- package/dist/{BImg-knz2UZQE.js.map → BImg-Dd8Pc1Ln.js.map} +1 -1
- package/dist/{BModal-BjmeVZen.js → BModal-DOmTYI6F.js} +5 -6
- package/dist/{BModal-BjmeVZen.js.map → BModal-DOmTYI6F.js.map} +1 -1
- package/dist/{BNav-B2PlMEMD.js → BNav-D3XbyI1R.js} +2 -2
- package/dist/{BNav-B2PlMEMD.js.map → BNav-D3XbyI1R.js.map} +1 -1
- package/dist/{BOffcanvas-DfR32-ZP.js → BOffcanvas-DyPG7s8I.js} +5 -5
- package/dist/{BOffcanvas-DfR32-ZP.js.map → BOffcanvas-DyPG7s8I.js.map} +1 -1
- package/dist/{BPagination-CfrsVgDp.js → BPagination-DGvgWeYG.js} +3 -3
- package/dist/{BPagination-CfrsVgDp.js.map → BPagination-DGvgWeYG.js.map} +1 -1
- package/dist/{BPlaceholder-DI12zz0a.js → BPlaceholder-BrBmbfIg.js} +3 -3
- package/dist/{BPlaceholder-DI12zz0a.js.map → BPlaceholder-BrBmbfIg.js.map} +1 -1
- package/dist/{BProgress-BNxYppi-.js → BProgress-CXhe6hsN.js} +2 -2
- package/dist/{BProgress-BNxYppi-.js.map → BProgress-CXhe6hsN.js.map} +1 -1
- package/dist/{BTable-BZxX17YU.js → BTable-8jp3wPAI.js} +2 -2
- package/dist/{BTable-BZxX17YU.js.map → BTable-8jp3wPAI.js.map} +1 -1
- package/dist/{BTabs-Zp8CvCL_.js → BTabs-Cfe8HOGE.js} +2 -2
- package/dist/{BTabs-Zp8CvCL_.js.map → BTabs-Cfe8HOGE.js.map} +1 -1
- package/dist/BTimeField-vdultTwg.js +138 -0
- package/dist/BTimeField-vdultTwg.js.map +1 -0
- package/dist/{BToast-CqE2VMW2.js → BToast-vxfpFGe3.js} +5 -5
- package/dist/{BToast-CqE2VMW2.js.map → BToast-vxfpFGe3.js.map} +1 -1
- package/dist/{BTooltip-BHFBLXnr.js → BTooltip-CV5Ogidy.js} +5 -11
- package/dist/BTooltip-CV5Ogidy.js.map +1 -0
- package/dist/bootstrap-vue-next.mjs +36 -36
- package/dist/{classes-BEWWGbj5.js → classes-DCjKFM2E.js} +12 -2
- package/dist/classes-DCjKFM2E.js.map +1 -0
- package/dist/components/BTooltip/BTooltip.vue.d.mts +3 -3
- package/dist/components/BTooltip/BTooltip.vue.d.ts +3 -3
- package/dist/composables/usePopover/index.d.mts +9 -9
- package/dist/composables/usePopover/index.d.ts +9 -9
- package/dist/{floatingUi-Stb1SUvw.js → floatingUi-BhgR4GBJ.js} +10 -168
- package/dist/floatingUi-BhgR4GBJ.js.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/src/components/BAccordion/index.mjs +1 -1
- package/dist/src/components/BAlert/index.mjs +1 -1
- package/dist/src/components/BApp/index.mjs +1 -1
- package/dist/src/components/BAutocomplete/index.mjs +1 -1
- package/dist/src/components/BAvatar/index.mjs +1 -1
- package/dist/src/components/BButton/index.mjs +1 -1
- package/dist/src/components/BCard/index.mjs +1 -1
- package/dist/src/components/BCarousel/index.mjs +1 -1
- package/dist/src/components/BCollapse/index.mjs +1 -1
- package/dist/src/components/BDateField/index.mjs +1 -1
- package/dist/src/components/BDatePicker/index.mjs +1 -1
- package/dist/src/components/BDropdown/index.mjs +1 -1
- package/dist/src/components/BFormCheckbox/index.mjs +1 -1
- package/dist/src/components/BFormFile/index.mjs +1 -1
- package/dist/src/components/BFormInput/index.mjs +1 -1
- package/dist/src/components/BFormOtp/index.mjs +1 -1
- package/dist/src/components/BFormRadio/index.mjs +1 -1
- package/dist/src/components/BFormRating/index.mjs +1 -1
- package/dist/src/components/BFormSelect/index.mjs +1 -1
- package/dist/src/components/BFormSpinbutton/index.mjs +1 -1
- package/dist/src/components/BFormTags/index.mjs +1 -1
- package/dist/src/components/BFormTextarea/index.mjs +1 -1
- package/dist/src/components/BImg/index.mjs +1 -1
- package/dist/src/components/BModal/index.mjs +1 -1
- package/dist/src/components/BNav/index.mjs +1 -1
- package/dist/src/components/BOffcanvas/index.mjs +1 -1
- package/dist/src/components/BPagination/index.mjs +1 -1
- package/dist/src/components/BPlaceholder/index.mjs +1 -1
- package/dist/src/components/BPopover/index.mjs +1 -1
- package/dist/src/components/BProgress/index.mjs +1 -1
- package/dist/src/components/BTable/index.mjs +1 -1
- package/dist/src/components/BTabs/index.mjs +1 -1
- package/dist/src/components/BTimeField/index.mjs +1 -1
- package/dist/src/components/BToast/index.mjs +1 -1
- package/dist/src/components/BTooltip/index.mjs +1 -1
- package/dist/src/components/index.mjs +36 -36
- package/dist/src/composables/index.mjs +1 -1
- package/dist/src/composables/orchestratorShared/index.mjs +145 -27
- package/dist/src/composables/orchestratorShared/index.mjs.map +1 -1
- package/dist/src/composables/useColorMode/index.mjs +1 -1
- package/dist/src/composables/useModal/index.mjs +1 -1
- package/dist/src/composables/usePopover/index.mjs +2 -2
- package/dist/src/composables/useScrollLock/index.mjs +1 -2
- package/dist/src/composables/useScrollLock/index.mjs.map +1 -1
- package/dist/src/composables/useScrollspy/index.mjs +1 -2
- package/dist/src/composables/useScrollspy/index.mjs.map +1 -1
- package/dist/src/composables/useToast/index.mjs +1 -1
- package/dist/src/directives/BPopover/index.mjs +2 -2
- package/dist/src/directives/BScrollspy/index.mjs +1 -1
- package/dist/src/directives/BToggle/index.mjs +1 -1
- package/dist/src/directives/BTooltip/index.mjs +2 -2
- package/dist/src/directives/index.mjs +1 -1
- package/dist/src/plugins/index.mjs +1 -1
- package/dist/src/resolvers/index.mjs +1 -1
- package/dist/src/types/index.mjs +1 -1
- package/dist/src/utils/index.mjs +2 -2
- package/dist/types/ComponentOrchestratorTypes.d.mts +8 -1
- package/dist/types/ComponentOrchestratorTypes.d.ts +8 -1
- package/dist/{useCountdownHover-BN8vJIQW.js → useCountdownHover-HZSJZkHq.js} +2 -2
- package/dist/{useCountdownHover-BN8vJIQW.js.map → useCountdownHover-HZSJZkHq.js.map} +1 -1
- package/dist/{useFormInput-C-iXRxog.js → useFormInput-CMtXFoM2.js} +2 -3
- package/dist/{useFormInput-C-iXRxog.js.map → useFormInput-CMtXFoM2.js.map} +1 -1
- package/dist/useSafeScrollLock-BT4KKhxB.js +89 -0
- package/dist/useSafeScrollLock-BT4KKhxB.js.map +1 -0
- package/dist/{useShowHide-B6RQbFDt.js → useShowHide-BLIZLD9E.js} +125 -56
- package/dist/useShowHide-BLIZLD9E.js.map +1 -0
- package/dist/utils/classes.d.mts +10 -0
- package/dist/utils/classes.d.ts +10 -0
- package/dist/{utils-CK56zzsO.js → utils-CvjliJBf.js} +2 -2
- package/dist/{utils-CK56zzsO.js.map → utils-CvjliJBf.js.map} +1 -1
- package/package.json +3 -23
- package/dist/BApp-Bg5xEz8H.js.map +0 -1
- package/dist/BAutocomplete-BFbbKtpz.js +0 -2490
- package/dist/BAutocomplete-BFbbKtpz.js.map +0 -1
- package/dist/BDateField-Bj-Jz7u4.js +0 -906
- package/dist/BDateField-Bj-Jz7u4.js.map +0 -1
- package/dist/BDatePicker-AVTYcVLy.js +0 -5210
- package/dist/BDatePicker-AVTYcVLy.js.map +0 -1
- package/dist/BFormOtp-ClDACqXM.js +0 -577
- package/dist/BFormOtp-ClDACqXM.js.map +0 -1
- package/dist/BTimeField-CbRGjaI6.js +0 -516
- package/dist/BTimeField-CbRGjaI6.js.map +0 -1
- package/dist/BTooltip-BHFBLXnr.js.map +0 -1
- package/dist/DateRangeFieldInput-Cbzjg8iF.js +0 -761
- package/dist/DateRangeFieldInput-Cbzjg8iF.js.map +0 -1
- package/dist/PopperContent-C9eeL6LH.js +0 -1726
- package/dist/PopperContent-C9eeL6LH.js.map +0 -1
- package/dist/VisuallyHidden-BYzyjJiY.js +0 -182
- package/dist/VisuallyHidden-BYzyjJiY.js.map +0 -1
- package/dist/VisuallyHiddenInput-CUrc8XXa.js +0 -180
- package/dist/VisuallyHiddenInput-CUrc8XXa.js.map +0 -1
- package/dist/classes-BEWWGbj5.js.map +0 -1
- package/dist/dist-9-XTMhb-.js +0 -1302
- package/dist/dist-9-XTMhb-.js.map +0 -1
- package/dist/dist-B-regXAP.js +0 -123
- package/dist/dist-B-regXAP.js.map +0 -1
- package/dist/dist-DKc2ivHS.js +0 -411
- package/dist/dist-DKc2ivHS.js.map +0 -1
- package/dist/floating-ui.dom-C7UZexJK.js +0 -1484
- package/dist/floating-ui.dom-C7UZexJK.js.map +0 -1
- package/dist/floatingUi-Stb1SUvw.js.map +0 -1
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
- package/dist/useDateField-CQZb799C.js +0 -3679
- package/dist/useDateField-CQZb799C.js.map +0 -1
- package/dist/useForwardExpose-DDvk7mir.js +0 -60
- package/dist/useForwardExpose-DDvk7mir.js.map +0 -1
- package/dist/useKbd-DRsaFU_f.js +0 -76
- package/dist/useKbd-DRsaFU_f.js.map +0 -1
- package/dist/useSafeScrollLock-PVgSASYu.js +0 -1326
- package/dist/useSafeScrollLock-PVgSASYu.js.map +0 -1
- package/dist/useShowHide-B6RQbFDt.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BFormSpinbutton-fkVMbQC3.js","names":[],"sources":["../src/components/BFormSpinbutton/BFormSpinbutton.vue","../src/components/BFormSpinbutton/BFormSpinbutton.vue"],"sourcesContent":["<template>\n <div\n ref=\"_element\"\n class=\"b-form-spinbutton form-control\"\n :class=\"computedClasses\"\n role=\"group\"\n :lang=\"computedLocale\"\n :tabindex=\"props.disabled ? undefined : '-1'\"\n :title=\"props.ariaLabel\"\n @click=\"focused = true\"\n >\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.top.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.top.button\"\n @mousedown=\"buttons.top.handler\"\n @touchstart=\"buttons.top.handler\"\n >\n <svg v-bind=\"buttons.top.svg\">\n <path v-bind=\"buttons.top.path\" />\n </svg>\n </button>\n </slot>\n <input\n v-if=\"props.name && !props.disabled\"\n key=\"hidden\"\n type=\"hidden\"\n :name=\"props.name\"\n :form=\"props.form\"\n :value=\"valueAsFixed\"\n />\n <output\n :id=\"computedId\"\n key=\"output\"\n class=\"flex-grow-1\"\n :class=\"computedSpinClasses\"\n :dir=\"(isRtl ?? false) ? 'rtl' : 'ltr'\"\n :tabindex=\"props.disabled ? undefined : '0'\"\n role=\"spinbutton\"\n aria-live=\"off\"\n :aria-label=\"props.ariaLabel || undefined\"\n :aria-controls=\"props.ariaControls || undefined\"\n :aria-invalid=\"\n props.state === false || (modelValue === null && props.required) ? true : undefined\n \"\n :aria-required=\"props.required ? true : undefined\"\n :aria-valuemin=\"computedMin\"\n :aria-valuemax=\"computedMax\"\n :aria-valuenow=\"modelValue !== null ? modelValue : undefined\"\n :aria-valuetext=\"modelValue !== null ? computedFormatter(modelValue) : undefined\"\n >\n <bdi>\n {{ (modelValue !== null ? computedFormatter(modelValue) : props.placeholder) || '' }}\n </bdi>\n </output>\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.bottom.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.bottom.button\"\n @mousedown=\"buttons.bottom.handler\"\n @touchstart=\"buttons.bottom.handler\"\n >\n <svg v-bind=\"buttons.bottom.svg\">\n <path v-bind=\"buttons.bottom.path\" />\n </svg>\n </button>\n </slot>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed, onUnmounted, useTemplateRef} from 'vue'\nimport {\n CODE_DOWN,\n CODE_END,\n CODE_HOME,\n CODE_PAGEDOWN,\n CODE_PAGEUP,\n CODE_UP,\n} from '../../utils/constants'\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useRtl} from '../../composables/useRtl'\nimport type {\n BFormSpinbuttonEmits,\n BFormSpinbuttonProps,\n BFormSpinbuttonSlots,\n ButtonType,\n} from '../../types'\nimport {getSafeDocument} from '../../utils/dom'\n\nconst KEY_CODES = [CODE_UP, CODE_DOWN, CODE_HOME, CODE_END, CODE_PAGEUP, CODE_PAGEDOWN]\n\nconst _props = withDefaults(defineProps<Omit<BFormSpinbuttonProps, 'modelValue'>>(), {\n ariaControls: undefined,\n ariaLabel: undefined,\n disabled: false,\n form: undefined,\n formatterFn: undefined,\n id: undefined,\n inline: false,\n labelDecrement: 'Decrement',\n labelIncrement: 'Increment',\n locale: undefined,\n max: defaultValues.max,\n min: defaultValues.min,\n name: undefined,\n placeholder: undefined,\n readonly: false,\n repeatDelay: defaultValues.repeatDelay,\n repeatInterval: defaultValues.repeatInterval,\n repeatStepMultiplier: defaultValues.repeatMultiplier,\n repeatThreshold: defaultValues.repeatThreshold,\n required: false,\n size: undefined,\n state: null,\n step: defaultValues.step,\n vertical: false,\n wrap: false,\n})\nconst props = useDefaults(_props, 'BFormSpinbutton')\nconst emit = defineEmits<BFormSpinbuttonEmits>()\ndefineSlots<BFormSpinbuttonSlots>()\n\nconst modelValue = defineModel<Exclude<BFormSpinbuttonProps['modelValue'], undefined>>({\n default: null,\n})\n\nconst element = useTemplateRef('_element')\n\nconst {focused} = useFocus(element)\n\nconst computedId = useId(() => props.id, 'spinbutton')\n\nconst computedClasses = computed(() => ({\n 'disabled': props.disabled,\n 'readonly': props.readonly,\n 'focus': focused.value,\n 'd-inline-flex': props.inline || props.vertical,\n 'd-flex': !props.inline && !props.vertical,\n 'align-items-stretch': !props.vertical,\n 'flex-column': props.vertical,\n [`form-control-${props.size}`]: props.size !== undefined,\n}))\n\nconst computedSpinClasses = computed(() => ({\n 'd-flex': props.vertical,\n 'align-self-center': !props.vertical,\n 'align-items-center': props.vertical,\n 'border-top': props.vertical,\n 'border-bottom': props.vertical,\n 'border-start': !props.vertical,\n 'border-end': !props.vertical,\n}))\n\n//non-reactive properties\nlet $_autoDelayTimer: ReturnType<typeof setTimeout> | undefined\nlet $_autoRepeatTimer: ReturnType<typeof setTimeout> | undefined\nlet $_keyIsDown = false\n\n// const computedInline = computed(() => props.inline && !props.vertical)\n\n// const computedReadonly = computed(() => props.readonly && !props.disabled)\n\nconst stepNumber = useToNumber(() => props.step)\nconst computedStep = computed(() =>\n Number.isNaN(stepNumber.value) ? defaultValues.step : stepNumber.value\n)\n\nconst minNumber = useToNumber(() => props.min)\nconst computedMin = computed(() =>\n Number.isNaN(minNumber.value) ? defaultValues.min : minNumber.value\n)\n\nconst maxNumber = useToNumber(() => props.max)\nconst computedMax = computed(() => {\n const step = computedStep.value\n const min = computedMin.value\n return Math.floor((maxNumber.value - min) / step) * step + min\n})\n\nconst repeatDelayNumber = useToNumber(() => props.repeatDelay, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedDelay = computed(() =>\n repeatDelayNumber.value > 0 ? repeatDelayNumber.value : defaultValues.repeatDelay\n)\n\nconst repeatIntervalNumber = useToNumber(() => props.repeatInterval, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedInterval = computed(() =>\n repeatIntervalNumber.value > 0 ? repeatIntervalNumber.value : defaultValues.repeatInterval\n)\n\nconst repeatThresholdNumber = useToNumber(() => props.repeatThreshold, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedThreshold = computed(() =>\n Math.max(\n Number.isNaN(repeatThresholdNumber.value)\n ? defaultValues.repeatThreshold\n : repeatThresholdNumber.value,\n 1\n )\n)\n\nconst repeatStepMultiplierNumber = useToNumber(() => props.repeatStepMultiplier, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedStepMultiplier = computed(() =>\n Math.max(\n Number.isNaN(repeatStepMultiplierNumber.value)\n ? defaultValues.repeatMultiplier\n : repeatStepMultiplierNumber.value,\n 1\n )\n)\n\nconst computedPrecision = computed(() => {\n const step = computedStep.value\n return Math.floor(step) === step ? 0 : (step.toString().split('.')[1] || '').length\n})\n\nconst computedMultiplier = computed(() => Math.pow(10, computedPrecision.value || 0))\n\nconst valueAsFixed = computed(() =>\n modelValue.value === null ? '' : modelValue.value.toFixed(computedPrecision.value)\n)\n\nconst {isRtl, locale: globalLocale} = useRtl()\n\nconst computedLocale = computed(() => {\n const loc = (props.locale ?? globalLocale?.value) || 'locale'\n const locales = [loc]\n const nf = new Intl.NumberFormat(locales)\n return nf.resolvedOptions().locale\n})\n\nconst defaultFormatter = () =>\n new Intl.NumberFormat(computedLocale.value, {\n style: 'decimal',\n useGrouping: false,\n minimumIntegerDigits: 1,\n minimumFractionDigits: computedPrecision.value,\n maximumFractionDigits: computedPrecision.value,\n notation: 'standard',\n }).format\n\nconst computedFormatter = computed(() => props.formatterFn ?? defaultFormatter())\n\nconst stepValue = (direction: number) => {\n // Sets a new incremented or decremented value, supporting optional wrapping\n // Direction is either +1 or -1 (or a multiple thereof)\n let {value} = modelValue\n if (!props.disabled && value !== null) {\n const step = computedStep.value * direction\n const min = computedMin.value\n const max = computedMax.value\n const multiplier = computedMultiplier.value\n const {wrap} = props\n // We ensure that the value steps like a native input\n value = Math.round((value - min) / step) * step + min + step\n // We ensure that precision is maintained (decimals)\n value = Math.round(value * multiplier) / multiplier\n // Handle if wrapping is enabled\n modelValue.value = value > max ? (wrap ? min : max) : value < min ? (wrap ? max : min) : value\n }\n}\n\nconst stepUp = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = computedMin.value\n return\n }\n stepValue(+1 * multiplier)\n}\n\nconst stepDown = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = props.wrap ? computedMax.value : computedMin.value\n return\n }\n stepValue(-1 * multiplier)\n}\n\nconst stopEvent = (event: Readonly<Event>) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n}\n\nonKeyStroke(\n KEY_CODES,\n (event) => {\n const {code, altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n // https://w3c.github.io/aria-practices/#spinbutton\n stopEvent(event)\n if ($_keyIsDown) {\n // Keypress is already in progress\n return\n }\n\n resetTimers()\n if ([CODE_UP, CODE_DOWN].includes(code)) {\n // The following use the custom auto-repeat handling\n\n $_keyIsDown = true\n if (code === CODE_UP) {\n handleStepRepeat(event, stepUp)\n return\n }\n if (code === CODE_DOWN) {\n handleStepRepeat(event, stepDown)\n }\n return\n }\n // These use native OS key repeating\n if (code === CODE_PAGEUP) {\n stepUp(computedStepMultiplier.value)\n return\n }\n if (code === CODE_PAGEDOWN) {\n stepDown(computedStepMultiplier.value)\n return\n }\n if (code === CODE_HOME) {\n modelValue.value = computedMin.value\n return\n }\n if (code === CODE_END) {\n modelValue.value = computedMax.value\n }\n },\n {target: element, eventName: 'keydown'}\n)\n\nonKeyStroke(\n KEY_CODES,\n (event: Readonly<KeyboardEvent>) => {\n // Emit a change event when the keyup happens\n\n const {altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n stopEvent(event)\n resetTimers()\n $_keyIsDown = false\n emit('change', modelValue.value)\n },\n {target: element, eventName: 'keyup'}\n)\n\n// takes in a mount or Keyboard Event\nconst handleStepRepeat = (event: Readonly<Event>, stepper: (step: number) => void) => {\n const {type} = event || {}\n\n if (!props.disabled && !props.readonly) {\n if (isMouseEvent(event)) {\n // We only respond to left (main === 0) button clicks\n if (type === 'mousedown' && event.button) return\n }\n resetTimers()\n // Step the counter initially\n stepper(1)\n const threshold = computedThreshold.value\n const multiplier = computedStepMultiplier.value\n const delay = computedDelay.value\n const interval = computedInterval.value\n\n // Initiate the delay/repeat interval\n $_autoDelayTimer = setTimeout(() => {\n let count = 0\n $_autoRepeatTimer = setInterval(() => {\n // After N initial repeats, we increase the incrementing step amount\n // We do this to minimize screen reader announcements of the value\n // (values are announced every change, which can be chatty for SR users)\n // And to make it easer to select a value when the range is large\n stepper(count < threshold ? 1 : multiplier)\n count++\n }, interval)\n }, delay)\n }\n}\n\nconst isMouseEvent = (evt: Readonly<Event>): evt is MouseEvent =>\n evt.type === 'mouseup' || evt.type === 'mousedown'\n\nconst onMouseup: EventListener = (event: Readonly<Event>) => {\n // `<body>` listener, only enabled when mousedown starts\n\n if (isMouseEvent(event)) {\n if (event.type === 'mouseup' && event.button) {\n // Ignore non left button (main === 0) mouse button click\n return\n }\n }\n\n stopEvent(event)\n resetTimers()\n setMouseup('removeEventListener')\n // Trigger the change event\n emit('change', modelValue.value)\n}\n\nconst setMouseup = (operation: 'addEventListener' | 'removeEventListener') => {\n const doc = getSafeDocument()\n if (doc === null) return\n\n if (operation === 'addEventListener') {\n doc.body.addEventListener('mouseup', onMouseup)\n doc.body.addEventListener('touchend', onMouseup, {passive: false})\n } else {\n doc.body.removeEventListener('mouseup', onMouseup)\n doc.body.removeEventListener('touchend', onMouseup)\n }\n}\nconst resetTimers = () => {\n clearTimeout($_autoDelayTimer)\n clearInterval($_autoRepeatTimer)\n $_autoDelayTimer = undefined\n $_autoRepeatTimer = undefined\n}\n\nconst buttons = computed(() => {\n const incrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-plus',\n viewBox: '0 0 16 16',\n },\n path: {\n d: 'M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z',\n },\n } as const\n\n const decrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-dash',\n viewBox: '0 0 16 16',\n },\n path: {d: 'M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z'},\n } as const\n\n const sharedButtonAttrs = {\n 'class': [{'py-0': !props.vertical}, 'btn', 'btn-sm', 'border-0', 'rounded-0'],\n 'tabindex': '-1',\n 'type': 'button' as ButtonType,\n 'disabled': props.disabled || props.readonly,\n 'aria-disabled': props.disabled || props.readonly ? true : undefined,\n 'aria-controls': computedId.value,\n }\n\n const sharedSvgAttrs = {\n 'aria-hidden': true,\n 'scale': focused.value ? 1.5 : 1.25,\n }\n\n const handler = (event: Readonly<Event>, stepper: (multiplier?: number) => void) => {\n if (!props.disabled && !props.readonly) {\n stopEvent(event)\n setMouseup('addEventListener')\n // Since we `preventDefault()`, we must manually focus the button\n // Though it's likely captured from the element click focus\n focused.value = true\n handleStepRepeat(event, stepper)\n }\n }\n\n const incrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelIncrement || undefined,\n 'aria-keyshortcuts': 'ArrowUp',\n },\n svg: {\n ...sharedSvgAttrs,\n ...incrementSvgAttrs.svg,\n },\n path: {\n ...incrementSvgAttrs.path,\n },\n slot: {\n name: 'increment',\n },\n handler: (e: Event) => handler(e, stepUp),\n }\n\n const decrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelDecrement || undefined,\n 'aria-keyshortcuts': 'ArrowDown',\n },\n svg: {\n ...sharedSvgAttrs,\n ...decrementSvgAttrs.svg,\n },\n path: {\n ...decrementSvgAttrs.path,\n },\n slot: {\n name: 'decrement',\n },\n handler: (e: Readonly<Event>) => handler(e, stepDown),\n }\n\n return {\n top: {\n ...(props.vertical ? incrementAttrs : decrementAttrs),\n },\n bottom: {\n ...(!props.vertical ? incrementAttrs : decrementAttrs),\n },\n }\n})\n\nonUnmounted(() => {\n // Cleanup event listeners\n setMouseup('removeEventListener')\n})\n</script>\n\n<script lang=\"ts\">\nconst defaultValues = {\n min: 1,\n max: 100,\n step: 1,\n repeatDelay: 500,\n repeatInterval: 100,\n repeatThreshold: 10,\n repeatMultiplier: 4,\n} as const\n</script>\n","<template>\n <div\n ref=\"_element\"\n class=\"b-form-spinbutton form-control\"\n :class=\"computedClasses\"\n role=\"group\"\n :lang=\"computedLocale\"\n :tabindex=\"props.disabled ? undefined : '-1'\"\n :title=\"props.ariaLabel\"\n @click=\"focused = true\"\n >\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.top.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.top.button\"\n @mousedown=\"buttons.top.handler\"\n @touchstart=\"buttons.top.handler\"\n >\n <svg v-bind=\"buttons.top.svg\">\n <path v-bind=\"buttons.top.path\" />\n </svg>\n </button>\n </slot>\n <input\n v-if=\"props.name && !props.disabled\"\n key=\"hidden\"\n type=\"hidden\"\n :name=\"props.name\"\n :form=\"props.form\"\n :value=\"valueAsFixed\"\n />\n <output\n :id=\"computedId\"\n key=\"output\"\n class=\"flex-grow-1\"\n :class=\"computedSpinClasses\"\n :dir=\"(isRtl ?? false) ? 'rtl' : 'ltr'\"\n :tabindex=\"props.disabled ? undefined : '0'\"\n role=\"spinbutton\"\n aria-live=\"off\"\n :aria-label=\"props.ariaLabel || undefined\"\n :aria-controls=\"props.ariaControls || undefined\"\n :aria-invalid=\"\n props.state === false || (modelValue === null && props.required) ? true : undefined\n \"\n :aria-required=\"props.required ? true : undefined\"\n :aria-valuemin=\"computedMin\"\n :aria-valuemax=\"computedMax\"\n :aria-valuenow=\"modelValue !== null ? modelValue : undefined\"\n :aria-valuetext=\"modelValue !== null ? computedFormatter(modelValue) : undefined\"\n >\n <bdi>\n {{ (modelValue !== null ? computedFormatter(modelValue) : props.placeholder) || '' }}\n </bdi>\n </output>\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.bottom.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.bottom.button\"\n @mousedown=\"buttons.bottom.handler\"\n @touchstart=\"buttons.bottom.handler\"\n >\n <svg v-bind=\"buttons.bottom.svg\">\n <path v-bind=\"buttons.bottom.path\" />\n </svg>\n </button>\n </slot>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed, onUnmounted, useTemplateRef} from 'vue'\nimport {\n CODE_DOWN,\n CODE_END,\n CODE_HOME,\n CODE_PAGEDOWN,\n CODE_PAGEUP,\n CODE_UP,\n} from '../../utils/constants'\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useRtl} from '../../composables/useRtl'\nimport type {\n BFormSpinbuttonEmits,\n BFormSpinbuttonProps,\n BFormSpinbuttonSlots,\n ButtonType,\n} from '../../types'\nimport {getSafeDocument} from '../../utils/dom'\n\nconst KEY_CODES = [CODE_UP, CODE_DOWN, CODE_HOME, CODE_END, CODE_PAGEUP, CODE_PAGEDOWN]\n\nconst _props = withDefaults(defineProps<Omit<BFormSpinbuttonProps, 'modelValue'>>(), {\n ariaControls: undefined,\n ariaLabel: undefined,\n disabled: false,\n form: undefined,\n formatterFn: undefined,\n id: undefined,\n inline: false,\n labelDecrement: 'Decrement',\n labelIncrement: 'Increment',\n locale: undefined,\n max: defaultValues.max,\n min: defaultValues.min,\n name: undefined,\n placeholder: undefined,\n readonly: false,\n repeatDelay: defaultValues.repeatDelay,\n repeatInterval: defaultValues.repeatInterval,\n repeatStepMultiplier: defaultValues.repeatMultiplier,\n repeatThreshold: defaultValues.repeatThreshold,\n required: false,\n size: undefined,\n state: null,\n step: defaultValues.step,\n vertical: false,\n wrap: false,\n})\nconst props = useDefaults(_props, 'BFormSpinbutton')\nconst emit = defineEmits<BFormSpinbuttonEmits>()\ndefineSlots<BFormSpinbuttonSlots>()\n\nconst modelValue = defineModel<Exclude<BFormSpinbuttonProps['modelValue'], undefined>>({\n default: null,\n})\n\nconst element = useTemplateRef('_element')\n\nconst {focused} = useFocus(element)\n\nconst computedId = useId(() => props.id, 'spinbutton')\n\nconst computedClasses = computed(() => ({\n 'disabled': props.disabled,\n 'readonly': props.readonly,\n 'focus': focused.value,\n 'd-inline-flex': props.inline || props.vertical,\n 'd-flex': !props.inline && !props.vertical,\n 'align-items-stretch': !props.vertical,\n 'flex-column': props.vertical,\n [`form-control-${props.size}`]: props.size !== undefined,\n}))\n\nconst computedSpinClasses = computed(() => ({\n 'd-flex': props.vertical,\n 'align-self-center': !props.vertical,\n 'align-items-center': props.vertical,\n 'border-top': props.vertical,\n 'border-bottom': props.vertical,\n 'border-start': !props.vertical,\n 'border-end': !props.vertical,\n}))\n\n//non-reactive properties\nlet $_autoDelayTimer: ReturnType<typeof setTimeout> | undefined\nlet $_autoRepeatTimer: ReturnType<typeof setTimeout> | undefined\nlet $_keyIsDown = false\n\n// const computedInline = computed(() => props.inline && !props.vertical)\n\n// const computedReadonly = computed(() => props.readonly && !props.disabled)\n\nconst stepNumber = useToNumber(() => props.step)\nconst computedStep = computed(() =>\n Number.isNaN(stepNumber.value) ? defaultValues.step : stepNumber.value\n)\n\nconst minNumber = useToNumber(() => props.min)\nconst computedMin = computed(() =>\n Number.isNaN(minNumber.value) ? defaultValues.min : minNumber.value\n)\n\nconst maxNumber = useToNumber(() => props.max)\nconst computedMax = computed(() => {\n const step = computedStep.value\n const min = computedMin.value\n return Math.floor((maxNumber.value - min) / step) * step + min\n})\n\nconst repeatDelayNumber = useToNumber(() => props.repeatDelay, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedDelay = computed(() =>\n repeatDelayNumber.value > 0 ? repeatDelayNumber.value : defaultValues.repeatDelay\n)\n\nconst repeatIntervalNumber = useToNumber(() => props.repeatInterval, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedInterval = computed(() =>\n repeatIntervalNumber.value > 0 ? repeatIntervalNumber.value : defaultValues.repeatInterval\n)\n\nconst repeatThresholdNumber = useToNumber(() => props.repeatThreshold, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedThreshold = computed(() =>\n Math.max(\n Number.isNaN(repeatThresholdNumber.value)\n ? defaultValues.repeatThreshold\n : repeatThresholdNumber.value,\n 1\n )\n)\n\nconst repeatStepMultiplierNumber = useToNumber(() => props.repeatStepMultiplier, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedStepMultiplier = computed(() =>\n Math.max(\n Number.isNaN(repeatStepMultiplierNumber.value)\n ? defaultValues.repeatMultiplier\n : repeatStepMultiplierNumber.value,\n 1\n )\n)\n\nconst computedPrecision = computed(() => {\n const step = computedStep.value\n return Math.floor(step) === step ? 0 : (step.toString().split('.')[1] || '').length\n})\n\nconst computedMultiplier = computed(() => Math.pow(10, computedPrecision.value || 0))\n\nconst valueAsFixed = computed(() =>\n modelValue.value === null ? '' : modelValue.value.toFixed(computedPrecision.value)\n)\n\nconst {isRtl, locale: globalLocale} = useRtl()\n\nconst computedLocale = computed(() => {\n const loc = (props.locale ?? globalLocale?.value) || 'locale'\n const locales = [loc]\n const nf = new Intl.NumberFormat(locales)\n return nf.resolvedOptions().locale\n})\n\nconst defaultFormatter = () =>\n new Intl.NumberFormat(computedLocale.value, {\n style: 'decimal',\n useGrouping: false,\n minimumIntegerDigits: 1,\n minimumFractionDigits: computedPrecision.value,\n maximumFractionDigits: computedPrecision.value,\n notation: 'standard',\n }).format\n\nconst computedFormatter = computed(() => props.formatterFn ?? defaultFormatter())\n\nconst stepValue = (direction: number) => {\n // Sets a new incremented or decremented value, supporting optional wrapping\n // Direction is either +1 or -1 (or a multiple thereof)\n let {value} = modelValue\n if (!props.disabled && value !== null) {\n const step = computedStep.value * direction\n const min = computedMin.value\n const max = computedMax.value\n const multiplier = computedMultiplier.value\n const {wrap} = props\n // We ensure that the value steps like a native input\n value = Math.round((value - min) / step) * step + min + step\n // We ensure that precision is maintained (decimals)\n value = Math.round(value * multiplier) / multiplier\n // Handle if wrapping is enabled\n modelValue.value = value > max ? (wrap ? min : max) : value < min ? (wrap ? max : min) : value\n }\n}\n\nconst stepUp = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = computedMin.value\n return\n }\n stepValue(+1 * multiplier)\n}\n\nconst stepDown = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = props.wrap ? computedMax.value : computedMin.value\n return\n }\n stepValue(-1 * multiplier)\n}\n\nconst stopEvent = (event: Readonly<Event>) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n}\n\nonKeyStroke(\n KEY_CODES,\n (event) => {\n const {code, altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n // https://w3c.github.io/aria-practices/#spinbutton\n stopEvent(event)\n if ($_keyIsDown) {\n // Keypress is already in progress\n return\n }\n\n resetTimers()\n if ([CODE_UP, CODE_DOWN].includes(code)) {\n // The following use the custom auto-repeat handling\n\n $_keyIsDown = true\n if (code === CODE_UP) {\n handleStepRepeat(event, stepUp)\n return\n }\n if (code === CODE_DOWN) {\n handleStepRepeat(event, stepDown)\n }\n return\n }\n // These use native OS key repeating\n if (code === CODE_PAGEUP) {\n stepUp(computedStepMultiplier.value)\n return\n }\n if (code === CODE_PAGEDOWN) {\n stepDown(computedStepMultiplier.value)\n return\n }\n if (code === CODE_HOME) {\n modelValue.value = computedMin.value\n return\n }\n if (code === CODE_END) {\n modelValue.value = computedMax.value\n }\n },\n {target: element, eventName: 'keydown'}\n)\n\nonKeyStroke(\n KEY_CODES,\n (event: Readonly<KeyboardEvent>) => {\n // Emit a change event when the keyup happens\n\n const {altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n stopEvent(event)\n resetTimers()\n $_keyIsDown = false\n emit('change', modelValue.value)\n },\n {target: element, eventName: 'keyup'}\n)\n\n// takes in a mount or Keyboard Event\nconst handleStepRepeat = (event: Readonly<Event>, stepper: (step: number) => void) => {\n const {type} = event || {}\n\n if (!props.disabled && !props.readonly) {\n if (isMouseEvent(event)) {\n // We only respond to left (main === 0) button clicks\n if (type === 'mousedown' && event.button) return\n }\n resetTimers()\n // Step the counter initially\n stepper(1)\n const threshold = computedThreshold.value\n const multiplier = computedStepMultiplier.value\n const delay = computedDelay.value\n const interval = computedInterval.value\n\n // Initiate the delay/repeat interval\n $_autoDelayTimer = setTimeout(() => {\n let count = 0\n $_autoRepeatTimer = setInterval(() => {\n // After N initial repeats, we increase the incrementing step amount\n // We do this to minimize screen reader announcements of the value\n // (values are announced every change, which can be chatty for SR users)\n // And to make it easer to select a value when the range is large\n stepper(count < threshold ? 1 : multiplier)\n count++\n }, interval)\n }, delay)\n }\n}\n\nconst isMouseEvent = (evt: Readonly<Event>): evt is MouseEvent =>\n evt.type === 'mouseup' || evt.type === 'mousedown'\n\nconst onMouseup: EventListener = (event: Readonly<Event>) => {\n // `<body>` listener, only enabled when mousedown starts\n\n if (isMouseEvent(event)) {\n if (event.type === 'mouseup' && event.button) {\n // Ignore non left button (main === 0) mouse button click\n return\n }\n }\n\n stopEvent(event)\n resetTimers()\n setMouseup('removeEventListener')\n // Trigger the change event\n emit('change', modelValue.value)\n}\n\nconst setMouseup = (operation: 'addEventListener' | 'removeEventListener') => {\n const doc = getSafeDocument()\n if (doc === null) return\n\n if (operation === 'addEventListener') {\n doc.body.addEventListener('mouseup', onMouseup)\n doc.body.addEventListener('touchend', onMouseup, {passive: false})\n } else {\n doc.body.removeEventListener('mouseup', onMouseup)\n doc.body.removeEventListener('touchend', onMouseup)\n }\n}\nconst resetTimers = () => {\n clearTimeout($_autoDelayTimer)\n clearInterval($_autoRepeatTimer)\n $_autoDelayTimer = undefined\n $_autoRepeatTimer = undefined\n}\n\nconst buttons = computed(() => {\n const incrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-plus',\n viewBox: '0 0 16 16',\n },\n path: {\n d: 'M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z',\n },\n } as const\n\n const decrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-dash',\n viewBox: '0 0 16 16',\n },\n path: {d: 'M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z'},\n } as const\n\n const sharedButtonAttrs = {\n 'class': [{'py-0': !props.vertical}, 'btn', 'btn-sm', 'border-0', 'rounded-0'],\n 'tabindex': '-1',\n 'type': 'button' as ButtonType,\n 'disabled': props.disabled || props.readonly,\n 'aria-disabled': props.disabled || props.readonly ? true : undefined,\n 'aria-controls': computedId.value,\n }\n\n const sharedSvgAttrs = {\n 'aria-hidden': true,\n 'scale': focused.value ? 1.5 : 1.25,\n }\n\n const handler = (event: Readonly<Event>, stepper: (multiplier?: number) => void) => {\n if (!props.disabled && !props.readonly) {\n stopEvent(event)\n setMouseup('addEventListener')\n // Since we `preventDefault()`, we must manually focus the button\n // Though it's likely captured from the element click focus\n focused.value = true\n handleStepRepeat(event, stepper)\n }\n }\n\n const incrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelIncrement || undefined,\n 'aria-keyshortcuts': 'ArrowUp',\n },\n svg: {\n ...sharedSvgAttrs,\n ...incrementSvgAttrs.svg,\n },\n path: {\n ...incrementSvgAttrs.path,\n },\n slot: {\n name: 'increment',\n },\n handler: (e: Event) => handler(e, stepUp),\n }\n\n const decrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelDecrement || undefined,\n 'aria-keyshortcuts': 'ArrowDown',\n },\n svg: {\n ...sharedSvgAttrs,\n ...decrementSvgAttrs.svg,\n },\n path: {\n ...decrementSvgAttrs.path,\n },\n slot: {\n name: 'decrement',\n },\n handler: (e: Readonly<Event>) => handler(e, stepDown),\n }\n\n return {\n top: {\n ...(props.vertical ? incrementAttrs : decrementAttrs),\n },\n bottom: {\n ...(!props.vertical ? incrementAttrs : decrementAttrs),\n },\n }\n})\n\nonUnmounted(() => {\n // Cleanup event listeners\n setMouseup('removeEventListener')\n})\n</script>\n\n<script lang=\"ts\">\nconst defaultValues = {\n min: 1,\n max: 100,\n step: 1,\n repeatDelay: 500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AAuB,MAAA,KAAA,CAAK,CAAC,UAAK,SAAe,WAAA,UAAU,QAAa,MAAA,KAAA,CAAK,CAAC,WAAQ,OAAW,KAAA;KAGjG,iBAAe,MAAA,KAAA,CAAK,CAAC,WAAQ,OAAU,KAAA;KACvC,iBAAe,YAAA;KACf,iBAAe,YAAA;KACf,iBAAe,WAAA,UAAU,OAAY,WAAA,QAAa,KAAA;KAClD,kBAAgB,WAAA,UAAU,OAAY,kBAAA,MAAkB,WAAA,KAAU,IAAI,KAAA;IAEvE,GAAA,CAAA,mBAEM,OAAA,MAAA,iBADA,WAAA,UAAU,OAAY,kBAAA,MAAkB,WAAA,KAAU,IAAI,MAAA,KAAA,CAAK,CAAC,gBAAW,EAAA,GAAA,CAAA,CAAA,GAAA,IAAA,UAAA;IAK/E,WAUO,KAAA,QAVO,QAAA,MAAQ,OAAO,KAAK,MAAI,EAAiC,UAAW,MAAA,OAAA,EAAO,SAUlF,CATL,mBAQS,UART,WACU,QAOD,MAPS,OAAO,QAAM;KAC5B,aAAS,OAAA,OAAA,OAAA,MAAE,GAAA,SAAA,QAAA,MAAQ,OAAO,WAAf,QAAA,MAAQ,OAAO,QAAO,GAAA,IAAA;KACjC,cAAU,OAAA,OAAA,OAAA,MAAE,GAAA,SAAA,QAAA,MAAQ,OAAO,WAAf,QAAA,MAAQ,OAAO,QAAO,GAAA,IAAA;IAEnC,CAAA,GAAA,EAAA,UAAA,GAAA,mBAEM,OAAA,eAAA,mBAFO,QAAA,MAAQ,OAAO,GAAG,CAAA,GAAA,CAC7B,mBAAqC,QAAA,eAAA,mBAAvB,QAAA,MAAQ,OAAO,IAAI,CAAA,GAAA,MAAA,EAAA,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"BFormSpinbutton-BR9YTfYy.js","names":[],"sources":["../src/components/BFormSpinbutton/BFormSpinbutton.vue","../src/components/BFormSpinbutton/BFormSpinbutton.vue"],"sourcesContent":["<template>\n <div\n ref=\"_element\"\n class=\"b-form-spinbutton form-control\"\n :class=\"computedClasses\"\n role=\"group\"\n :lang=\"computedLocale\"\n :tabindex=\"props.disabled ? undefined : '-1'\"\n :title=\"props.ariaLabel\"\n @click=\"focused = true\"\n >\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.top.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.top.button\"\n @mousedown=\"buttons.top.handler\"\n @touchstart=\"buttons.top.handler\"\n >\n <svg v-bind=\"buttons.top.svg\">\n <path v-bind=\"buttons.top.path\" />\n </svg>\n </button>\n </slot>\n <input\n v-if=\"props.name && !props.disabled\"\n key=\"hidden\"\n type=\"hidden\"\n :name=\"props.name\"\n :form=\"props.form\"\n :value=\"valueAsFixed\"\n />\n <output\n :id=\"computedId\"\n key=\"output\"\n class=\"flex-grow-1\"\n :class=\"computedSpinClasses\"\n :dir=\"(isRtl ?? false) ? 'rtl' : 'ltr'\"\n :tabindex=\"props.disabled ? undefined : '0'\"\n role=\"spinbutton\"\n aria-live=\"off\"\n :aria-label=\"props.ariaLabel || undefined\"\n :aria-controls=\"props.ariaControls || undefined\"\n :aria-invalid=\"\n props.state === false || (modelValue === null && props.required) ? true : undefined\n \"\n :aria-required=\"props.required ? true : undefined\"\n :aria-valuemin=\"computedMin\"\n :aria-valuemax=\"computedMax\"\n :aria-valuenow=\"modelValue !== null ? modelValue : undefined\"\n :aria-valuetext=\"modelValue !== null ? computedFormatter(modelValue) : undefined\"\n >\n <bdi>\n {{ (modelValue !== null ? computedFormatter(modelValue) : props.placeholder) || '' }}\n </bdi>\n </output>\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.bottom.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.bottom.button\"\n @mousedown=\"buttons.bottom.handler\"\n @touchstart=\"buttons.bottom.handler\"\n >\n <svg v-bind=\"buttons.bottom.svg\">\n <path v-bind=\"buttons.bottom.path\" />\n </svg>\n </button>\n </slot>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed, onUnmounted, useTemplateRef} from 'vue'\nimport {\n CODE_DOWN,\n CODE_END,\n CODE_HOME,\n CODE_PAGEDOWN,\n CODE_PAGEUP,\n CODE_UP,\n} from '../../utils/constants'\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useRtl} from '../../composables/useRtl'\nimport type {\n BFormSpinbuttonEmits,\n BFormSpinbuttonProps,\n BFormSpinbuttonSlots,\n ButtonType,\n} from '../../types'\nimport {getSafeDocument} from '../../utils/dom'\n\nconst KEY_CODES = [CODE_UP, CODE_DOWN, CODE_HOME, CODE_END, CODE_PAGEUP, CODE_PAGEDOWN]\n\nconst _props = withDefaults(defineProps<Omit<BFormSpinbuttonProps, 'modelValue'>>(), {\n ariaControls: undefined,\n ariaLabel: undefined,\n disabled: false,\n form: undefined,\n formatterFn: undefined,\n id: undefined,\n inline: false,\n labelDecrement: 'Decrement',\n labelIncrement: 'Increment',\n locale: undefined,\n max: defaultValues.max,\n min: defaultValues.min,\n name: undefined,\n placeholder: undefined,\n readonly: false,\n repeatDelay: defaultValues.repeatDelay,\n repeatInterval: defaultValues.repeatInterval,\n repeatStepMultiplier: defaultValues.repeatMultiplier,\n repeatThreshold: defaultValues.repeatThreshold,\n required: false,\n size: undefined,\n state: null,\n step: defaultValues.step,\n vertical: false,\n wrap: false,\n})\nconst props = useDefaults(_props, 'BFormSpinbutton')\nconst emit = defineEmits<BFormSpinbuttonEmits>()\ndefineSlots<BFormSpinbuttonSlots>()\n\nconst modelValue = defineModel<Exclude<BFormSpinbuttonProps['modelValue'], undefined>>({\n default: null,\n})\n\nconst element = useTemplateRef('_element')\n\nconst {focused} = useFocus(element)\n\nconst computedId = useId(() => props.id, 'spinbutton')\n\nconst computedClasses = computed(() => ({\n 'disabled': props.disabled,\n 'readonly': props.readonly,\n 'focus': focused.value,\n 'd-inline-flex': props.inline || props.vertical,\n 'd-flex': !props.inline && !props.vertical,\n 'align-items-stretch': !props.vertical,\n 'flex-column': props.vertical,\n [`form-control-${props.size}`]: props.size !== undefined,\n}))\n\nconst computedSpinClasses = computed(() => ({\n 'd-flex': props.vertical,\n 'align-self-center': !props.vertical,\n 'align-items-center': props.vertical,\n 'border-top': props.vertical,\n 'border-bottom': props.vertical,\n 'border-start': !props.vertical,\n 'border-end': !props.vertical,\n}))\n\n//non-reactive properties\nlet $_autoDelayTimer: ReturnType<typeof setTimeout> | undefined\nlet $_autoRepeatTimer: ReturnType<typeof setTimeout> | undefined\nlet $_keyIsDown = false\n\n// const computedInline = computed(() => props.inline && !props.vertical)\n\n// const computedReadonly = computed(() => props.readonly && !props.disabled)\n\nconst stepNumber = useToNumber(() => props.step)\nconst computedStep = computed(() =>\n Number.isNaN(stepNumber.value) ? defaultValues.step : stepNumber.value\n)\n\nconst minNumber = useToNumber(() => props.min)\nconst computedMin = computed(() =>\n Number.isNaN(minNumber.value) ? defaultValues.min : minNumber.value\n)\n\nconst maxNumber = useToNumber(() => props.max)\nconst computedMax = computed(() => {\n const step = computedStep.value\n const min = computedMin.value\n return Math.floor((maxNumber.value - min) / step) * step + min\n})\n\nconst repeatDelayNumber = useToNumber(() => props.repeatDelay, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedDelay = computed(() =>\n repeatDelayNumber.value > 0 ? repeatDelayNumber.value : defaultValues.repeatDelay\n)\n\nconst repeatIntervalNumber = useToNumber(() => props.repeatInterval, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedInterval = computed(() =>\n repeatIntervalNumber.value > 0 ? repeatIntervalNumber.value : defaultValues.repeatInterval\n)\n\nconst repeatThresholdNumber = useToNumber(() => props.repeatThreshold, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedThreshold = computed(() =>\n Math.max(\n Number.isNaN(repeatThresholdNumber.value)\n ? defaultValues.repeatThreshold\n : repeatThresholdNumber.value,\n 1\n )\n)\n\nconst repeatStepMultiplierNumber = useToNumber(() => props.repeatStepMultiplier, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedStepMultiplier = computed(() =>\n Math.max(\n Number.isNaN(repeatStepMultiplierNumber.value)\n ? defaultValues.repeatMultiplier\n : repeatStepMultiplierNumber.value,\n 1\n )\n)\n\nconst computedPrecision = computed(() => {\n const step = computedStep.value\n return Math.floor(step) === step ? 0 : (step.toString().split('.')[1] || '').length\n})\n\nconst computedMultiplier = computed(() => Math.pow(10, computedPrecision.value || 0))\n\nconst valueAsFixed = computed(() =>\n modelValue.value === null ? '' : modelValue.value.toFixed(computedPrecision.value)\n)\n\nconst {isRtl, locale: globalLocale} = useRtl()\n\nconst computedLocale = computed(() => {\n const loc = (props.locale ?? globalLocale?.value) || 'locale'\n const locales = [loc]\n const nf = new Intl.NumberFormat(locales)\n return nf.resolvedOptions().locale\n})\n\nconst defaultFormatter = () =>\n new Intl.NumberFormat(computedLocale.value, {\n style: 'decimal',\n useGrouping: false,\n minimumIntegerDigits: 1,\n minimumFractionDigits: computedPrecision.value,\n maximumFractionDigits: computedPrecision.value,\n notation: 'standard',\n }).format\n\nconst computedFormatter = computed(() => props.formatterFn ?? defaultFormatter())\n\nconst stepValue = (direction: number) => {\n // Sets a new incremented or decremented value, supporting optional wrapping\n // Direction is either +1 or -1 (or a multiple thereof)\n let {value} = modelValue\n if (!props.disabled && value !== null) {\n const step = computedStep.value * direction\n const min = computedMin.value\n const max = computedMax.value\n const multiplier = computedMultiplier.value\n const {wrap} = props\n // We ensure that the value steps like a native input\n value = Math.round((value - min) / step) * step + min + step\n // We ensure that precision is maintained (decimals)\n value = Math.round(value * multiplier) / multiplier\n // Handle if wrapping is enabled\n modelValue.value = value > max ? (wrap ? min : max) : value < min ? (wrap ? max : min) : value\n }\n}\n\nconst stepUp = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = computedMin.value\n return\n }\n stepValue(+1 * multiplier)\n}\n\nconst stepDown = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = props.wrap ? computedMax.value : computedMin.value\n return\n }\n stepValue(-1 * multiplier)\n}\n\nconst stopEvent = (event: Readonly<Event>) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n}\n\nonKeyStroke(\n KEY_CODES,\n (event) => {\n const {code, altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n // https://w3c.github.io/aria-practices/#spinbutton\n stopEvent(event)\n if ($_keyIsDown) {\n // Keypress is already in progress\n return\n }\n\n resetTimers()\n if ([CODE_UP, CODE_DOWN].includes(code)) {\n // The following use the custom auto-repeat handling\n\n $_keyIsDown = true\n if (code === CODE_UP) {\n handleStepRepeat(event, stepUp)\n return\n }\n if (code === CODE_DOWN) {\n handleStepRepeat(event, stepDown)\n }\n return\n }\n // These use native OS key repeating\n if (code === CODE_PAGEUP) {\n stepUp(computedStepMultiplier.value)\n return\n }\n if (code === CODE_PAGEDOWN) {\n stepDown(computedStepMultiplier.value)\n return\n }\n if (code === CODE_HOME) {\n modelValue.value = computedMin.value\n return\n }\n if (code === CODE_END) {\n modelValue.value = computedMax.value\n }\n },\n {target: element, eventName: 'keydown'}\n)\n\nonKeyStroke(\n KEY_CODES,\n (event: Readonly<KeyboardEvent>) => {\n // Emit a change event when the keyup happens\n\n const {altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n stopEvent(event)\n resetTimers()\n $_keyIsDown = false\n emit('change', modelValue.value)\n },\n {target: element, eventName: 'keyup'}\n)\n\n// takes in a mount or Keyboard Event\nconst handleStepRepeat = (event: Readonly<Event>, stepper: (step: number) => void) => {\n const {type} = event || {}\n\n if (!props.disabled && !props.readonly) {\n if (isMouseEvent(event)) {\n // We only respond to left (main === 0) button clicks\n if (type === 'mousedown' && event.button) return\n }\n resetTimers()\n // Step the counter initially\n stepper(1)\n const threshold = computedThreshold.value\n const multiplier = computedStepMultiplier.value\n const delay = computedDelay.value\n const interval = computedInterval.value\n\n // Initiate the delay/repeat interval\n $_autoDelayTimer = setTimeout(() => {\n let count = 0\n $_autoRepeatTimer = setInterval(() => {\n // After N initial repeats, we increase the incrementing step amount\n // We do this to minimize screen reader announcements of the value\n // (values are announced every change, which can be chatty for SR users)\n // And to make it easer to select a value when the range is large\n stepper(count < threshold ? 1 : multiplier)\n count++\n }, interval)\n }, delay)\n }\n}\n\nconst isMouseEvent = (evt: Readonly<Event>): evt is MouseEvent =>\n evt.type === 'mouseup' || evt.type === 'mousedown'\n\nconst onMouseup: EventListener = (event: Readonly<Event>) => {\n // `<body>` listener, only enabled when mousedown starts\n\n if (isMouseEvent(event)) {\n if (event.type === 'mouseup' && event.button) {\n // Ignore non left button (main === 0) mouse button click\n return\n }\n }\n\n stopEvent(event)\n resetTimers()\n setMouseup('removeEventListener')\n // Trigger the change event\n emit('change', modelValue.value)\n}\n\nconst setMouseup = (operation: 'addEventListener' | 'removeEventListener') => {\n const doc = getSafeDocument()\n if (doc === null) return\n\n if (operation === 'addEventListener') {\n doc.body.addEventListener('mouseup', onMouseup)\n doc.body.addEventListener('touchend', onMouseup, {passive: false})\n } else {\n doc.body.removeEventListener('mouseup', onMouseup)\n doc.body.removeEventListener('touchend', onMouseup)\n }\n}\nconst resetTimers = () => {\n clearTimeout($_autoDelayTimer)\n clearInterval($_autoRepeatTimer)\n $_autoDelayTimer = undefined\n $_autoRepeatTimer = undefined\n}\n\nconst buttons = computed(() => {\n const incrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-plus',\n viewBox: '0 0 16 16',\n },\n path: {\n d: 'M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z',\n },\n } as const\n\n const decrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-dash',\n viewBox: '0 0 16 16',\n },\n path: {d: 'M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z'},\n } as const\n\n const sharedButtonAttrs = {\n 'class': [{'py-0': !props.vertical}, 'btn', 'btn-sm', 'border-0', 'rounded-0'],\n 'tabindex': '-1',\n 'type': 'button' as ButtonType,\n 'disabled': props.disabled || props.readonly,\n 'aria-disabled': props.disabled || props.readonly ? true : undefined,\n 'aria-controls': computedId.value,\n }\n\n const sharedSvgAttrs = {\n 'aria-hidden': true,\n 'scale': focused.value ? 1.5 : 1.25,\n }\n\n const handler = (event: Readonly<Event>, stepper: (multiplier?: number) => void) => {\n if (!props.disabled && !props.readonly) {\n stopEvent(event)\n setMouseup('addEventListener')\n // Since we `preventDefault()`, we must manually focus the button\n // Though it's likely captured from the element click focus\n focused.value = true\n handleStepRepeat(event, stepper)\n }\n }\n\n const incrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelIncrement || undefined,\n 'aria-keyshortcuts': 'ArrowUp',\n },\n svg: {\n ...sharedSvgAttrs,\n ...incrementSvgAttrs.svg,\n },\n path: {\n ...incrementSvgAttrs.path,\n },\n slot: {\n name: 'increment',\n },\n handler: (e: Event) => handler(e, stepUp),\n }\n\n const decrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelDecrement || undefined,\n 'aria-keyshortcuts': 'ArrowDown',\n },\n svg: {\n ...sharedSvgAttrs,\n ...decrementSvgAttrs.svg,\n },\n path: {\n ...decrementSvgAttrs.path,\n },\n slot: {\n name: 'decrement',\n },\n handler: (e: Readonly<Event>) => handler(e, stepDown),\n }\n\n return {\n top: {\n ...(props.vertical ? incrementAttrs : decrementAttrs),\n },\n bottom: {\n ...(!props.vertical ? incrementAttrs : decrementAttrs),\n },\n }\n})\n\nonUnmounted(() => {\n // Cleanup event listeners\n setMouseup('removeEventListener')\n})\n</script>\n\n<script lang=\"ts\">\nconst defaultValues = {\n min: 1,\n max: 100,\n step: 1,\n repeatDelay: 500,\n repeatInterval: 100,\n repeatThreshold: 10,\n repeatMultiplier: 4,\n} as const\n</script>\n","<template>\n <div\n ref=\"_element\"\n class=\"b-form-spinbutton form-control\"\n :class=\"computedClasses\"\n role=\"group\"\n :lang=\"computedLocale\"\n :tabindex=\"props.disabled ? undefined : '-1'\"\n :title=\"props.ariaLabel\"\n @click=\"focused = true\"\n >\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.top.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.top.button\"\n @mousedown=\"buttons.top.handler\"\n @touchstart=\"buttons.top.handler\"\n >\n <svg v-bind=\"buttons.top.svg\">\n <path v-bind=\"buttons.top.path\" />\n </svg>\n </button>\n </slot>\n <input\n v-if=\"props.name && !props.disabled\"\n key=\"hidden\"\n type=\"hidden\"\n :name=\"props.name\"\n :form=\"props.form\"\n :value=\"valueAsFixed\"\n />\n <output\n :id=\"computedId\"\n key=\"output\"\n class=\"flex-grow-1\"\n :class=\"computedSpinClasses\"\n :dir=\"(isRtl ?? false) ? 'rtl' : 'ltr'\"\n :tabindex=\"props.disabled ? undefined : '0'\"\n role=\"spinbutton\"\n aria-live=\"off\"\n :aria-label=\"props.ariaLabel || undefined\"\n :aria-controls=\"props.ariaControls || undefined\"\n :aria-invalid=\"\n props.state === false || (modelValue === null && props.required) ? true : undefined\n \"\n :aria-required=\"props.required ? true : undefined\"\n :aria-valuemin=\"computedMin\"\n :aria-valuemax=\"computedMax\"\n :aria-valuenow=\"modelValue !== null ? modelValue : undefined\"\n :aria-valuetext=\"modelValue !== null ? computedFormatter(modelValue) : undefined\"\n >\n <bdi>\n {{ (modelValue !== null ? computedFormatter(modelValue) : props.placeholder) || '' }}\n </bdi>\n </output>\n <!-- eslint-disable-next-line prettier/prettier -->\n <!-- prettier-ignore -->\n <slot :name=\"(buttons.bottom.slot.name as 'increment' | 'decrement')\" :has-focus=\"focused\">\n <button\n v-bind=\"buttons.bottom.button\"\n @mousedown=\"buttons.bottom.handler\"\n @touchstart=\"buttons.bottom.handler\"\n >\n <svg v-bind=\"buttons.bottom.svg\">\n <path v-bind=\"buttons.bottom.path\" />\n </svg>\n </button>\n </slot>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {computed, onUnmounted, useTemplateRef} from 'vue'\nimport {\n CODE_DOWN,\n CODE_END,\n CODE_HOME,\n CODE_PAGEDOWN,\n CODE_PAGEUP,\n CODE_UP,\n} from '../../utils/constants'\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {useId} from '../../composables/useId'\nimport {useRtl} from '../../composables/useRtl'\nimport type {\n BFormSpinbuttonEmits,\n BFormSpinbuttonProps,\n BFormSpinbuttonSlots,\n ButtonType,\n} from '../../types'\nimport {getSafeDocument} from '../../utils/dom'\n\nconst KEY_CODES = [CODE_UP, CODE_DOWN, CODE_HOME, CODE_END, CODE_PAGEUP, CODE_PAGEDOWN]\n\nconst _props = withDefaults(defineProps<Omit<BFormSpinbuttonProps, 'modelValue'>>(), {\n ariaControls: undefined,\n ariaLabel: undefined,\n disabled: false,\n form: undefined,\n formatterFn: undefined,\n id: undefined,\n inline: false,\n labelDecrement: 'Decrement',\n labelIncrement: 'Increment',\n locale: undefined,\n max: defaultValues.max,\n min: defaultValues.min,\n name: undefined,\n placeholder: undefined,\n readonly: false,\n repeatDelay: defaultValues.repeatDelay,\n repeatInterval: defaultValues.repeatInterval,\n repeatStepMultiplier: defaultValues.repeatMultiplier,\n repeatThreshold: defaultValues.repeatThreshold,\n required: false,\n size: undefined,\n state: null,\n step: defaultValues.step,\n vertical: false,\n wrap: false,\n})\nconst props = useDefaults(_props, 'BFormSpinbutton')\nconst emit = defineEmits<BFormSpinbuttonEmits>()\ndefineSlots<BFormSpinbuttonSlots>()\n\nconst modelValue = defineModel<Exclude<BFormSpinbuttonProps['modelValue'], undefined>>({\n default: null,\n})\n\nconst element = useTemplateRef('_element')\n\nconst {focused} = useFocus(element)\n\nconst computedId = useId(() => props.id, 'spinbutton')\n\nconst computedClasses = computed(() => ({\n 'disabled': props.disabled,\n 'readonly': props.readonly,\n 'focus': focused.value,\n 'd-inline-flex': props.inline || props.vertical,\n 'd-flex': !props.inline && !props.vertical,\n 'align-items-stretch': !props.vertical,\n 'flex-column': props.vertical,\n [`form-control-${props.size}`]: props.size !== undefined,\n}))\n\nconst computedSpinClasses = computed(() => ({\n 'd-flex': props.vertical,\n 'align-self-center': !props.vertical,\n 'align-items-center': props.vertical,\n 'border-top': props.vertical,\n 'border-bottom': props.vertical,\n 'border-start': !props.vertical,\n 'border-end': !props.vertical,\n}))\n\n//non-reactive properties\nlet $_autoDelayTimer: ReturnType<typeof setTimeout> | undefined\nlet $_autoRepeatTimer: ReturnType<typeof setTimeout> | undefined\nlet $_keyIsDown = false\n\n// const computedInline = computed(() => props.inline && !props.vertical)\n\n// const computedReadonly = computed(() => props.readonly && !props.disabled)\n\nconst stepNumber = useToNumber(() => props.step)\nconst computedStep = computed(() =>\n Number.isNaN(stepNumber.value) ? defaultValues.step : stepNumber.value\n)\n\nconst minNumber = useToNumber(() => props.min)\nconst computedMin = computed(() =>\n Number.isNaN(minNumber.value) ? defaultValues.min : minNumber.value\n)\n\nconst maxNumber = useToNumber(() => props.max)\nconst computedMax = computed(() => {\n const step = computedStep.value\n const min = computedMin.value\n return Math.floor((maxNumber.value - min) / step) * step + min\n})\n\nconst repeatDelayNumber = useToNumber(() => props.repeatDelay, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedDelay = computed(() =>\n repeatDelayNumber.value > 0 ? repeatDelayNumber.value : defaultValues.repeatDelay\n)\n\nconst repeatIntervalNumber = useToNumber(() => props.repeatInterval, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedInterval = computed(() =>\n repeatIntervalNumber.value > 0 ? repeatIntervalNumber.value : defaultValues.repeatInterval\n)\n\nconst repeatThresholdNumber = useToNumber(() => props.repeatThreshold, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedThreshold = computed(() =>\n Math.max(\n Number.isNaN(repeatThresholdNumber.value)\n ? defaultValues.repeatThreshold\n : repeatThresholdNumber.value,\n 1\n )\n)\n\nconst repeatStepMultiplierNumber = useToNumber(() => props.repeatStepMultiplier, {\n nanToZero: true,\n method: 'parseInt',\n})\nconst computedStepMultiplier = computed(() =>\n Math.max(\n Number.isNaN(repeatStepMultiplierNumber.value)\n ? defaultValues.repeatMultiplier\n : repeatStepMultiplierNumber.value,\n 1\n )\n)\n\nconst computedPrecision = computed(() => {\n const step = computedStep.value\n return Math.floor(step) === step ? 0 : (step.toString().split('.')[1] || '').length\n})\n\nconst computedMultiplier = computed(() => Math.pow(10, computedPrecision.value || 0))\n\nconst valueAsFixed = computed(() =>\n modelValue.value === null ? '' : modelValue.value.toFixed(computedPrecision.value)\n)\n\nconst {isRtl, locale: globalLocale} = useRtl()\n\nconst computedLocale = computed(() => {\n const loc = (props.locale ?? globalLocale?.value) || 'locale'\n const locales = [loc]\n const nf = new Intl.NumberFormat(locales)\n return nf.resolvedOptions().locale\n})\n\nconst defaultFormatter = () =>\n new Intl.NumberFormat(computedLocale.value, {\n style: 'decimal',\n useGrouping: false,\n minimumIntegerDigits: 1,\n minimumFractionDigits: computedPrecision.value,\n maximumFractionDigits: computedPrecision.value,\n notation: 'standard',\n }).format\n\nconst computedFormatter = computed(() => props.formatterFn ?? defaultFormatter())\n\nconst stepValue = (direction: number) => {\n // Sets a new incremented or decremented value, supporting optional wrapping\n // Direction is either +1 or -1 (or a multiple thereof)\n let {value} = modelValue\n if (!props.disabled && value !== null) {\n const step = computedStep.value * direction\n const min = computedMin.value\n const max = computedMax.value\n const multiplier = computedMultiplier.value\n const {wrap} = props\n // We ensure that the value steps like a native input\n value = Math.round((value - min) / step) * step + min + step\n // We ensure that precision is maintained (decimals)\n value = Math.round(value * multiplier) / multiplier\n // Handle if wrapping is enabled\n modelValue.value = value > max ? (wrap ? min : max) : value < min ? (wrap ? max : min) : value\n }\n}\n\nconst stepUp = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = computedMin.value\n return\n }\n stepValue(+1 * multiplier)\n}\n\nconst stepDown = (multiplier = 1) => {\n if (modelValue.value === null) {\n modelValue.value = props.wrap ? computedMax.value : computedMin.value\n return\n }\n stepValue(-1 * multiplier)\n}\n\nconst stopEvent = (event: Readonly<Event>) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n}\n\nonKeyStroke(\n KEY_CODES,\n (event) => {\n const {code, altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n // https://w3c.github.io/aria-practices/#spinbutton\n stopEvent(event)\n if ($_keyIsDown) {\n // Keypress is already in progress\n return\n }\n\n resetTimers()\n if ([CODE_UP, CODE_DOWN].includes(code)) {\n // The following use the custom auto-repeat handling\n\n $_keyIsDown = true\n if (code === CODE_UP) {\n handleStepRepeat(event, stepUp)\n return\n }\n if (code === CODE_DOWN) {\n handleStepRepeat(event, stepDown)\n }\n return\n }\n // These use native OS key repeating\n if (code === CODE_PAGEUP) {\n stepUp(computedStepMultiplier.value)\n return\n }\n if (code === CODE_PAGEDOWN) {\n stepDown(computedStepMultiplier.value)\n return\n }\n if (code === CODE_HOME) {\n modelValue.value = computedMin.value\n return\n }\n if (code === CODE_END) {\n modelValue.value = computedMax.value\n }\n },\n {target: element, eventName: 'keydown'}\n)\n\nonKeyStroke(\n KEY_CODES,\n (event: Readonly<KeyboardEvent>) => {\n // Emit a change event when the keyup happens\n\n const {altKey, ctrlKey, metaKey} = event\n\n if (props.disabled || props.readonly || altKey || ctrlKey || metaKey) return\n\n stopEvent(event)\n resetTimers()\n $_keyIsDown = false\n emit('change', modelValue.value)\n },\n {target: element, eventName: 'keyup'}\n)\n\n// takes in a mount or Keyboard Event\nconst handleStepRepeat = (event: Readonly<Event>, stepper: (step: number) => void) => {\n const {type} = event || {}\n\n if (!props.disabled && !props.readonly) {\n if (isMouseEvent(event)) {\n // We only respond to left (main === 0) button clicks\n if (type === 'mousedown' && event.button) return\n }\n resetTimers()\n // Step the counter initially\n stepper(1)\n const threshold = computedThreshold.value\n const multiplier = computedStepMultiplier.value\n const delay = computedDelay.value\n const interval = computedInterval.value\n\n // Initiate the delay/repeat interval\n $_autoDelayTimer = setTimeout(() => {\n let count = 0\n $_autoRepeatTimer = setInterval(() => {\n // After N initial repeats, we increase the incrementing step amount\n // We do this to minimize screen reader announcements of the value\n // (values are announced every change, which can be chatty for SR users)\n // And to make it easer to select a value when the range is large\n stepper(count < threshold ? 1 : multiplier)\n count++\n }, interval)\n }, delay)\n }\n}\n\nconst isMouseEvent = (evt: Readonly<Event>): evt is MouseEvent =>\n evt.type === 'mouseup' || evt.type === 'mousedown'\n\nconst onMouseup: EventListener = (event: Readonly<Event>) => {\n // `<body>` listener, only enabled when mousedown starts\n\n if (isMouseEvent(event)) {\n if (event.type === 'mouseup' && event.button) {\n // Ignore non left button (main === 0) mouse button click\n return\n }\n }\n\n stopEvent(event)\n resetTimers()\n setMouseup('removeEventListener')\n // Trigger the change event\n emit('change', modelValue.value)\n}\n\nconst setMouseup = (operation: 'addEventListener' | 'removeEventListener') => {\n const doc = getSafeDocument()\n if (doc === null) return\n\n if (operation === 'addEventListener') {\n doc.body.addEventListener('mouseup', onMouseup)\n doc.body.addEventListener('touchend', onMouseup, {passive: false})\n } else {\n doc.body.removeEventListener('mouseup', onMouseup)\n doc.body.removeEventListener('touchend', onMouseup)\n }\n}\nconst resetTimers = () => {\n clearTimeout($_autoDelayTimer)\n clearInterval($_autoRepeatTimer)\n $_autoDelayTimer = undefined\n $_autoRepeatTimer = undefined\n}\n\nconst buttons = computed(() => {\n const incrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-plus',\n viewBox: '0 0 16 16',\n },\n path: {\n d: 'M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z',\n },\n } as const\n\n const decrementSvgAttrs = {\n svg: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '16',\n height: '16',\n fill: 'currentColor',\n class: 'bi bi-dash',\n viewBox: '0 0 16 16',\n },\n path: {d: 'M4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8z'},\n } as const\n\n const sharedButtonAttrs = {\n 'class': [{'py-0': !props.vertical}, 'btn', 'btn-sm', 'border-0', 'rounded-0'],\n 'tabindex': '-1',\n 'type': 'button' as ButtonType,\n 'disabled': props.disabled || props.readonly,\n 'aria-disabled': props.disabled || props.readonly ? true : undefined,\n 'aria-controls': computedId.value,\n }\n\n const sharedSvgAttrs = {\n 'aria-hidden': true,\n 'scale': focused.value ? 1.5 : 1.25,\n }\n\n const handler = (event: Readonly<Event>, stepper: (multiplier?: number) => void) => {\n if (!props.disabled && !props.readonly) {\n stopEvent(event)\n setMouseup('addEventListener')\n // Since we `preventDefault()`, we must manually focus the button\n // Though it's likely captured from the element click focus\n focused.value = true\n handleStepRepeat(event, stepper)\n }\n }\n\n const incrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelIncrement || undefined,\n 'aria-keyshortcuts': 'ArrowUp',\n },\n svg: {\n ...sharedSvgAttrs,\n ...incrementSvgAttrs.svg,\n },\n path: {\n ...incrementSvgAttrs.path,\n },\n slot: {\n name: 'increment',\n },\n handler: (e: Event) => handler(e, stepUp),\n }\n\n const decrementAttrs = {\n button: {\n ...sharedButtonAttrs,\n 'aria-label': props.labelDecrement || undefined,\n 'aria-keyshortcuts': 'ArrowDown',\n },\n svg: {\n ...sharedSvgAttrs,\n ...decrementSvgAttrs.svg,\n },\n path: {\n ...decrementSvgAttrs.path,\n },\n slot: {\n name: 'decrement',\n },\n handler: (e: Readonly<Event>) => handler(e, stepDown),\n }\n\n return {\n top: {\n ...(props.vertical ? incrementAttrs : decrementAttrs),\n },\n bottom: {\n ...(!props.vertical ? incrementAttrs : decrementAttrs),\n },\n }\n})\n\nonUnmounted(() => {\n // Cleanup event listeners\n setMouseup('removeEventListener')\n})\n</script>\n\n<script lang=\"ts\">\nconst defaultValues = {\n min: 1,\n max: 100,\n step: 1,\n repeatDelay: 500,\n repeatInterval: 100,\n repeatThreshold: 10,\n repeatMultiplier: 4,\n} as const\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6hBA,IAAM,gBAAgB;CACpB,KAAK;CACL,KAAK;CACL,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,iBAAiB;CACjB,kBAAkB;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAvcA,MAAM,YAAY;GAAC;GAAS;GAAW;;GAAqB;GAAa;EAAa;EA6BtF,MAAM,QAAQ,YAAY,SAAQ,iBAAiB;EACnD,MAAM,OAAO;EAGb,MAAM,aAAa,SAAmE,SAAA,YAErF;EAED,MAAM,UAAU,eAAe,UAAU;EAEzC,MAAM,EAAC,YAAW,SAAS,OAAO;EAElC,MAAM,aAAa,cAAY,MAAM,IAAI,YAAY;EAErD,MAAM,kBAAkB,gBAAgB;GACtC,YAAY,MAAM;GAClB,YAAY,MAAM;GAClB,SAAS,QAAQ;GACjB,iBAAiB,MAAM,UAAU,MAAM;GACvC,UAAU,CAAC,MAAM,UAAU,CAAC,MAAM;GAClC,uBAAuB,CAAC,MAAM;GAC9B,eAAe,MAAM;IACpB,gBAAgB,MAAM,SAAS,MAAM,SAAS,KAAA;EACjD,EAAE;EAEF,MAAM,sBAAsB,g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AA;IAEnC,CAAA,GAAA,EAAA,UAAA,GAAA,mBAEM,OAAA,eAAA,mBAFO,QAAA,MAAQ,OAAO,GAAG,CAAA,GAAA,CAC7B,mBAAqC,QAAA,eAAA,mBAAvB,QAAA,MAAQ,OAAO,IAAI,CAAA,GAAA,MAAA,EAAA,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,CAAA,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { S as useToNumber } from "./dist-DKc2ivHS.js";
|
|
2
|
-
import { a as onKeyStroke, m as useFocus } from "./dist-9-XTMhb-.js";
|
|
3
1
|
import { t as useDefaults } from "./useDefaults-BzP4qZBu.js";
|
|
4
2
|
import { t as useId$1 } from "./useId-Fh-Arhb7.js";
|
|
5
3
|
import { t as escapeRegExpChars } from "./stringUtils-CVySsg3y.js";
|
|
6
4
|
import { t as useStateClass } from "./useStateClass-BF7kf2zK.js";
|
|
7
5
|
import { t as BFormTag_default } from "./BFormTag-DGSUfz7A.js";
|
|
8
6
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, mergeProps, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef, withCtx } from "vue";
|
|
7
|
+
import { onKeyStroke, useFocus, useToNumber } from "@vueuse/core";
|
|
9
8
|
//#region src/components/BFormTags/BFormTags.vue?vue&type=script&setup=true&lang.ts
|
|
10
9
|
var _hoisted_1 = ["id"];
|
|
11
10
|
var _hoisted_2 = [
|
|
@@ -414,4 +413,4 @@ var BFormTags_default = /* @__PURE__ */ defineComponent({
|
|
|
414
413
|
//#endregion
|
|
415
414
|
export { BFormTags_default as t };
|
|
416
415
|
|
|
417
|
-
//# sourceMappingURL=BFormTags-
|
|
416
|
+
//# sourceMappingURL=BFormTags-6qQn0Vlv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BFormTags-CUcyRTCK.js","names":[],"sources":["../src/components/BFormTags/BFormTags.vue","../src/components/BFormTags/BFormTags.vue"],"sourcesContent":["<template>\n <div\n :id=\"computedId\"\n class=\"b-form-tags form-control h-auto\"\n :class=\"computedClasses\"\n role=\"group\"\n tabindex=\"-1\"\n @click=\"onClick\"\n @focusin=\"onFocusin\"\n @focusout=\"emit('focusout', $event)\"\n >\n <output\n :id=\"`${computedId}selected_tags__`\"\n class=\"visually-hidden\"\n :for=\"_inputId\"\n :aria-live=\"focused ? 'polite' : 'off'\"\n aria-atomic=\"true\"\n aria-relevant=\"additions\"\n >{{ modelValue.join(', ') }}</output\n >\n <div\n :id=\"`${computedId}removed_tags__`\"\n role=\"status\"\n :aria-live=\"focused ? 'assertive' : 'off'\"\n aria-atomic=\"true\"\n class=\"visually-hidden\"\n >\n ({{ props.tagRemovedLabel }}) {{ lastRemovedTag }}\n </div>\n\n <slot\n :add-button-text=\"props.addButtonText\"\n :add-button-variant=\"props.addButtonVariant\"\n :add-tag\n :disable-add-button=\"disableAddButton\"\n :disabled=\"props.disabled\"\n :duplicate-tag-text=\"props.duplicateTagText\"\n :duplicate-tags=\"duplicateTags\"\n :form=\"props.form\"\n :input-attrs=\"{\n ...props.inputAttrs,\n disabled: props.disabled,\n form: props.form,\n id: _inputId,\n value: inputValue,\n }\"\n :input-class=\"props.inputClass\"\n :input-handlers=\"{\n input: onInput,\n keydown: onKeydown,\n change: onChange,\n }\"\n :input-id=\"_inputId\"\n :input-type=\"props.inputType\"\n :invalid-tag-text=\"props.invalidTagText\"\n :invalid-tags\n :is-duplicate\n :is-invalid\n :is-limit-reached=\"isLimitReached\"\n :limit-tags-text=\"props.limitTagsText\"\n :limit=\"limitNumber\"\n :no-tag-remove=\"props.noTagRemove\"\n :placeholder=\"props.placeholder\"\n :remove-tag\n :required=\"props.required\"\n :separator=\"props.separator\"\n :size=\"props.size\"\n :state=\"props.state\"\n :tag-class=\"props.tagClass\"\n :tag-pills=\"props.tagPills\"\n :tag-remove-label=\"props.tagRemoveLabel\"\n :tag-variant=\"props.tagVariant\"\n :tags=\"[...modelValue]\"\n >\n <ul\n :id=\"`${computedId}tag_list__`\"\n class=\"b-form-tags-list list-unstyled mb-0 d-flex flex-wrap align-items-center\"\n >\n <template v-for=\"(tag, index) in modelValue\" :key=\"index\">\n <slot\n name=\"tag\"\n :tag=\"tag\"\n :tag-class=\"props.tagClass\"\n :tag-variant=\"props.tagVariant\"\n :tag-pills=\"props.tagPills\"\n :remove-tag=\"removeTag\"\n >\n <BFormTag\n :key=\"tag\"\n :class=\"props.tagClass\"\n tag=\"li\"\n :variant=\"props.tagVariant\"\n :pill=\"props.tagPills\"\n :no-remove=\"props.noTagRemove\"\n :disabled=\"props.disabled\"\n @remove=\"removeTag\"\n >{{ tag }}</BFormTag\n >\n </slot>\n </template>\n <li\n role=\"none\"\n aria-live=\"off\"\n class=\"b-from-tags-field flex-grow-1\"\n :aria-controls=\"`${computedId}tag_list__`\"\n >\n <div role=\"group\" class=\"d-flex\">\n <input\n :id=\"_inputId\"\n ref=\"_input\"\n :disabled=\"props.disabled\"\n :value=\"inputValue\"\n :type=\"props.inputType\"\n :placeholder=\"props.placeholder\"\n class=\"b-form-tags-input w-100 flex-grow-1 p-0 m-0 bg-transparent border-0\"\n style=\"outline: currentcolor none 0; min-width: 5rem\"\n v-bind=\"props.inputAttrs\"\n :form=\"props.form\"\n :required=\"props.required || undefined\"\n :aria-required=\"props.required || undefined\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n />\n <button\n v-if=\"disableAddButton\"\n type=\"button\"\n class=\"btn b-form-tags-button py-0\"\n :class=\"[\n inputClass,\n {\n [`btn-${props.addButtonVariant}`]: props.addButtonVariant !== null,\n 'disabled invisible': inputValue.length === 0,\n },\n ]\"\n style=\"font-size: 90%\"\n :disabled=\"props.disabled || inputValue.length === 0 || isLimitReached\"\n @click=\"addTag(inputValue)\"\n >\n <slot name=\"add-button-text\">{{ props.addButtonText }}</slot>\n </button>\n </div>\n </li>\n </ul>\n <div :aria-live=\"props.feedbackAriaLive\" aria-atomic=\"true\">\n <div v-if=\"isInvalid\" class=\"d-block invalid-feedback\">\n {{ props.invalidTagText }}: {{ inputValue }}\n </div>\n <small v-if=\"isDuplicate\" class=\"form-text text-body-secondary\"\n >{{ props.duplicateTagText }}: {{ inputValue }}</small\n >\n <small v-if=\"isLimitReached\" class=\"form-text text-body-secondary\">\n {{ props.limitTagsText }}</small\n >\n </div>\n </slot>\n <template v-if=\"props.name\">\n <input\n v-for=\"(tag, index) in modelValue\"\n :key=\"index\"\n type=\"hidden\"\n :name=\"props.name\"\n :value=\"tag\"\n />\n </template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {computed, ref, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {escapeRegExpChars} from '../../utils/stringUtils'\nimport BFormTag from './BFormTag.vue'\nimport {useId} from '../../composables/useId'\nimport {useStateClass} from '../../composables/useStateClass'\nimport type {BFormTagsEmits, BFormTagsProps, BFormTagsSlots} from '../../types'\n\nconst _props = withDefaults(defineProps<Omit<BFormTagsProps, 'modelValue'>>(), {\n addButtonText: 'Add',\n addButtonVariant: 'outline-secondary',\n addOnChange: false,\n autofocus: false,\n disabled: false,\n duplicateTagText: 'Duplicate tag(s)',\n feedbackAriaLive: 'assertive',\n form: undefined,\n ignoreInputFocusSelector: () => ['.b-form-tag', 'button', 'input', 'select'],\n inputAttrs: undefined,\n inputClass: undefined,\n inputId: undefined,\n inputType: 'text',\n invalidTagText: 'Invalid tag(s)',\n limit: undefined,\n limitTagsText: 'Tag limit reached',\n name: undefined,\n noAddOnEnter: false,\n noOuterFocus: false,\n noTagRemove: false,\n placeholder: 'Add tag...',\n removeOnDelete: false,\n required: false,\n separator: undefined,\n size: undefined,\n state: null,\n tagClass: undefined,\n tagPills: false,\n tagRemoveLabel: undefined,\n tagRemovedLabel: 'Tag removed',\n tagValidator: () => true,\n tagVariant: 'secondary',\n})\nconst props = useDefaults(_props, 'BFormTags')\nconst emit = defineEmits<BFormTagsEmits>()\ndefineSlots<BFormTagsSlots>()\n\nconst modelValue = defineModel<Exclude<BFormTagsProps['modelValue'], undefined>>({\n default: () => [],\n})\n\nconst computedId = useId()\n\nconst limitNumber = useToNumber(() => props.limit ?? Number.NaN)\n\nconst stateClass = useStateClass(() => props.state)\n\nconst input = useTemplateRef('_input')\n\nconst {focused} = useFocus(input, {\n initialValue: props.autofocus,\n})\n\nconst _inputId = computed(() => props.inputId || `${computedId.value}input__`)\nconst inputValue = ref<string>('')\nconst shouldRemoveOnDelete = ref<boolean>(modelValue.value.length > 0)\nconst lastRemovedTag = ref<string>('')\nconst validTags = ref<string[]>([])\nconst invalidTags = ref<string[]>([])\nconst duplicateTags = ref<string[]>([])\n\nconst computedClasses = computed(() => [\n stateClass.value,\n {\n [`form-control-${props.size}`]: props.size !== undefined,\n disabled: props.disabled,\n focus: focused.value,\n },\n])\n\nconst isDuplicate = computed(() => modelValue.value.includes(inputValue.value))\nconst isInvalid = computed(() =>\n inputValue.value === '' ? false : !props.tagValidator(inputValue.value)\n)\nconst isLimitReached = computed(() => modelValue.value.length === limitNumber.value)\nconst disableAddButton = computed(() => !isInvalid.value && !isDuplicate.value)\n\nconst onFocusin = (e: Readonly<FocusEvent>): void => {\n if (props.disabled) {\n const target = e.target as HTMLDivElement\n target.blur()\n return\n }\n\n emit('focusin', e)\n}\n\nconst onClick = (e: Readonly<MouseEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n const {target} = e\n const ignoreSelectors = props.ignoreInputFocusSelector\n if (ignoreSelectors && target instanceof Element) {\n const selector =\n typeof ignoreSelectors === 'string' ? ignoreSelectors : ignoreSelectors.join(',')\n\n if (selector && target.closest(selector)) {\n return\n }\n }\n\n focused.value = true\n}\n\nconst onFocus = (e: Readonly<FocusEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n focused.value = true\n emit('focus', e)\n}\n\nconst onBlur = (e: Readonly<FocusEvent>): void => {\n focused.value = false\n emit('blur', e)\n}\n\nconst onInput = (e: Readonly<Event> | string): void => {\n const value = typeof e === 'string' ? e : (e.target as HTMLInputElement).value\n\n shouldRemoveOnDelete.value = false\n\n if (props.separator?.includes(value.charAt(0)) && value.length > 0) {\n if (input.value) {\n input.value.value = ''\n }\n return\n }\n\n inputValue.value = value\n\n if (props.separator?.includes(value.charAt(value.length - 1))) {\n addTag(value.slice(0, value.length - 1))\n return\n }\n\n validTags.value = props.tagValidator(value) && !isDuplicate.value ? [value] : []\n invalidTags.value = props.tagValidator(value) ? [] : [value]\n duplicateTags.value = isDuplicate.value ? [value] : []\n\n emit('tag-state', validTags.value, invalidTags.value, duplicateTags.value)\n}\n\nconst onChange = (e: Readonly<Event>): void => {\n if (props.addOnChange) {\n onInput(e)\n\n if (!isDuplicate.value) {\n addTag(inputValue.value)\n }\n }\n}\n\nconst onKeydown = (e: Readonly<KeyboardEvent>): void => {\n if ((e.key === 'Enter' || e.code === 'NumpadEnter') && !props.noAddOnEnter) {\n addTag(inputValue.value)\n return\n }\n\n if (\n (e.key === 'Backspace' || e.key === 'Delete') &&\n props.removeOnDelete &&\n inputValue.value === '' &&\n shouldRemoveOnDelete.value &&\n modelValue.value.length > 0\n ) {\n removeTag(modelValue.value[modelValue.value.length - 1])\n } else {\n shouldRemoveOnDelete.value = true\n }\n}\n\nonKeyStroke(onKeydown, {target: input, passive: true})\n\nconst separator = computed(() => {\n if (!props.separator) {\n return undefined\n }\n\n return typeof props.separator === 'string' ? props.separator : props.separator.join('')\n})\n\nconst separatorRegExp = computed(() => {\n if (!separator.value) {\n return undefined\n }\n\n return new RegExp(`[${escapeRegExpChars(separator.value)}]+`)\n})\n\nconst addTag = (tag?: string): void => {\n tag = (tag ?? inputValue.value).trim()\n\n const newTags = separatorRegExp.value\n ? tag.split(separatorRegExp.value).map((t) => t.trim())\n : [tag]\n const validTags: string[] = []\n\n for (const newTag of newTags) {\n if (newTag === '' || isDuplicate.value || !props.tagValidator(newTag)) {\n continue\n }\n\n if (limitNumber.value && isLimitReached.value) {\n break\n }\n\n validTags.push(newTag)\n }\n\n const newValue = [...modelValue.value, ...validTags]\n inputValue.value = ''\n shouldRemoveOnDelete.value = true\n modelValue.value = newValue\n if (validTags.length > 0) {\n emit('tag-added', validTags)\n }\n focused.value = true\n}\n\nconst removeTag = (tag?: string): void => {\n const tagStr = tag?.toString() ?? ''\n const tagIndex = modelValue.value.indexOf(tagStr)\n if (tagIndex === -1) return\n lastRemovedTag.value = tagStr\n modelValue.value = [\n ...modelValue.value.slice(0, tagIndex),\n ...modelValue.value.slice(tagIndex + 1),\n ]\n}\n\ndefineExpose({\n blur: () => {\n focused.value = false\n },\n element: input,\n focus: () => {\n focused.value = true\n },\n inputValue,\n})\n</script>\n","<template>\n <div\n :id=\"computedId\"\n class=\"b-form-tags form-control h-auto\"\n :class=\"computedClasses\"\n role=\"group\"\n tabindex=\"-1\"\n @click=\"onClick\"\n @focusin=\"onFocusin\"\n @focusout=\"emit('focusout', $event)\"\n >\n <output\n :id=\"`${computedId}selected_tags__`\"\n class=\"visually-hidden\"\n :for=\"_inputId\"\n :aria-live=\"focused ? 'polite' : 'off'\"\n aria-atomic=\"true\"\n aria-relevant=\"additions\"\n >{{ modelValue.join(', ') }}</output\n >\n <div\n :id=\"`${computedId}removed_tags__`\"\n role=\"status\"\n :aria-live=\"focused ? 'assertive' : 'off'\"\n aria-atomic=\"true\"\n class=\"visually-hidden\"\n >\n ({{ props.tagRemovedLabel }}) {{ lastRemovedTag }}\n </div>\n\n <slot\n :add-button-text=\"props.addButtonText\"\n :add-button-variant=\"props.addButtonVariant\"\n :add-tag\n :disable-add-button=\"disableAddButton\"\n :disabled=\"props.disabled\"\n :duplicate-tag-text=\"props.duplicateTagText\"\n :duplicate-tags=\"duplicateTags\"\n :form=\"props.form\"\n :input-attrs=\"{\n ...props.inputAttrs,\n disabled: props.disabled,\n form: props.form,\n id: _inputId,\n value: inputValue,\n }\"\n :input-class=\"props.inputClass\"\n :input-handlers=\"{\n input: onInput,\n keydown: onKeydown,\n change: onChange,\n }\"\n :input-id=\"_inputId\"\n :input-type=\"props.inputType\"\n :invalid-tag-text=\"props.invalidTagText\"\n :invalid-tags\n :is-duplicate\n :is-invalid\n :is-limit-reached=\"isLimitReached\"\n :limit-tags-text=\"props.limitTagsText\"\n :limit=\"limitNumber\"\n :no-tag-remove=\"props.noTagRemove\"\n :placeholder=\"props.placeholder\"\n :remove-tag\n :required=\"props.required\"\n :separator=\"props.separator\"\n :size=\"props.size\"\n :state=\"props.state\"\n :tag-class=\"props.tagClass\"\n :tag-pills=\"props.tagPills\"\n :tag-remove-label=\"props.tagRemoveLabel\"\n :tag-variant=\"props.tagVariant\"\n :tags=\"[...modelValue]\"\n >\n <ul\n :id=\"`${computedId}tag_list__`\"\n class=\"b-form-tags-list list-unstyled mb-0 d-flex flex-wrap align-items-center\"\n >\n <template v-for=\"(tag, index) in modelValue\" :key=\"index\">\n <slot\n name=\"tag\"\n :tag=\"tag\"\n :tag-class=\"props.tagClass\"\n :tag-variant=\"props.tagVariant\"\n :tag-pills=\"props.tagPills\"\n :remove-tag=\"removeTag\"\n >\n <BFormTag\n :key=\"tag\"\n :class=\"props.tagClass\"\n tag=\"li\"\n :variant=\"props.tagVariant\"\n :pill=\"props.tagPills\"\n :no-remove=\"props.noTagRemove\"\n :disabled=\"props.disabled\"\n @remove=\"removeTag\"\n >{{ tag }}</BFormTag\n >\n </slot>\n </template>\n <li\n role=\"none\"\n aria-live=\"off\"\n class=\"b-from-tags-field flex-grow-1\"\n :aria-controls=\"`${computedId}tag_list__`\"\n >\n <div role=\"group\" class=\"d-flex\">\n <input\n :id=\"_inputId\"\n ref=\"_input\"\n :disabled=\"props.disabled\"\n :value=\"inputValue\"\n :type=\"props.inputType\"\n :placeholder=\"props.placeholder\"\n class=\"b-form-tags-input w-100 flex-grow-1 p-0 m-0 bg-transparent border-0\"\n style=\"outline: currentcolor none 0; min-width: 5rem\"\n v-bind=\"props.inputAttrs\"\n :form=\"props.form\"\n :required=\"props.required || undefined\"\n :aria-required=\"props.required || undefined\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n />\n <button\n v-if=\"disableAddButton\"\n type=\"button\"\n class=\"btn b-form-tags-button py-0\"\n :class=\"[\n inputClass,\n {\n [`btn-${props.addButtonVariant}`]: props.addButtonVariant !== null,\n 'disabled invisible': inputValue.length === 0,\n },\n ]\"\n style=\"font-size: 90%\"\n :disabled=\"props.disabled || inputValue.length === 0 || isLimitReached\"\n @click=\"addTag(inputValue)\"\n >\n <slot name=\"add-button-text\">{{ props.addButtonText }}</slot>\n </button>\n </div>\n </li>\n </ul>\n <div :aria-live=\"props.feedbackAriaLive\" aria-atomic=\"true\">\n <div v-if=\"isInvalid\" class=\"d-block invalid-feedback\">\n {{ props.invalidTagText }}: {{ inputValue }}\n </div>\n <small v-if=\"isDuplicate\" class=\"form-text text-body-secondary\"\n >{{ props.duplicateTagText }}: {{ inputValue }}</small\n >\n <small v-if=\"isLimitReached\" class=\"form-text text-body-secondary\">\n {{ props.limitTagsText }}</small\n >\n </div>\n </slot>\n <template v-if=\"props.name\">\n <input\n v-for=\"(tag, index) in modelValue\"\n :key=\"index\"\n type=\"hidden\"\n :name=\"props.name\"\n :value=\"tag\"\n />\n </template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {computed, ref, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {escapeRegExpChars} from '../../utils/stringUtils'\nimport BFormTag from './BFormTag.vue'\nimport {useId} from '../../composables/useId'\nimport {useStateClass} from '../../composables/useStateClass'\nimport type {BFormTagsEmits, BFormTagsProps, BFormTagsSlots} from '../../types'\n\nconst _props = withDefaults(defineProps<Omit<BFormTagsProps, 'modelValue'>>(), {\n addButtonText: 'Add',\n addButtonVariant: 'outline-secondary',\n addOnChange: false,\n autofocus: false,\n disabled: false,\n duplicateTagText: 'Duplicate tag(s)',\n feedbackAriaLive: 'assertive',\n form: undefined,\n ignoreInputFocusSelector: () => ['.b-form-tag', 'button', 'input', 'select'],\n inputAttrs: undefined,\n inputClass: undefined,\n inputId: undefined,\n inputType: 'text',\n invalidTagText: 'Invalid tag(s)',\n limit: undefined,\n limitTagsText: 'Tag limit reached',\n name: undefined,\n noAddOnEnter: false,\n noOuterFocus: false,\n noTagRemove: false,\n placeholder: 'Add tag...',\n removeOnDelete: false,\n required: false,\n separator: undefined,\n size: undefined,\n state: null,\n tagClass: undefined,\n tagPills: false,\n tagRemoveLabel: undefined,\n tagRemovedLabel: 'Tag removed',\n tagValidator: () => true,\n tagVariant: 'secondary',\n})\nconst props = useDefaults(_props, 'BFormTags')\nconst emit = defineEmits<BFormTagsEmits>()\ndefineSlots<BFormTagsSlots>()\n\nconst modelValue = defineModel<Exclude<BFormTagsProps['modelValue'], undefined>>({\n default: () => [],\n})\n\nconst computedId = useId()\n\nconst limitNumber = useToNumber(() => props.limit ?? Number.NaN)\n\nconst stateClass = useStateClass(() => props.state)\n\nconst input = useTemplateRef('_input')\n\nconst {focused} = useFocus(input, {\n initialValue: props.autofocus,\n})\n\nconst _inputId = computed(() => props.inputId || `${computedId.value}input__`)\nconst inputValue = ref<string>('')\nconst shouldRemoveOnDelete = ref<boolean>(modelValue.value.length > 0)\nconst lastRemovedTag = ref<string>('')\nconst validTags = ref<string[]>([])\nconst invalidTags = ref<string[]>([])\nconst duplicateTags = ref<string[]>([])\n\nconst computedClasses = computed(() => [\n stateClass.value,\n {\n [`form-control-${props.size}`]: props.size !== undefined,\n disabled: props.disabled,\n focus: focused.value,\n },\n])\n\nconst isDuplicate = computed(() => modelValue.value.includes(inputValue.value))\nconst isInvalid = computed(() =>\n inputValue.value === '' ? false : !props.tagValidator(inputValue.value)\n)\nconst isLimitReached = computed(() => modelValue.value.length === limitNumber.value)\nconst disableAddButton = computed(() => !isInvalid.value && !isDuplicate.value)\n\nconst onFocusin = (e: Readonly<FocusEvent>): void => {\n if (props.disabled) {\n const target = e.target as HTMLDivElement\n target.blur()\n return\n }\n\n emit('focusin', e)\n}\n\nconst onClick = (e: Readonly<MouseEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n const {target} = e\n const ignoreSelectors = props.ignoreInputFocusSelector\n if (ignoreSelectors && target instanceof Element) {\n const selector =\n typeof ignoreSelectors === 'string' ? ignoreSelectors : ignoreSelectors.join(',')\n\n if (selector && target.closest(selector)) {\n return\n }\n }\n\n focused.value = true\n}\n\nconst onFocus = (e: Readonly<FocusEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n focused.value = true\n emit('focus', e)\n}\n\nconst onBlur = (e: Readonly<FocusEvent>): void => {\n focused.value = false\n emit('blur', e)\n}\n\nconst onInput = (e: Readonly<Event> | string): void => {\n const value = typeof e === 'string' ? e : (e.target as HTMLInputElement).value\n\n shouldRemoveOnDelete.value = false\n\n if (props.separator?.includes(value.charAt(0)) && value.length > 0) {\n if (input.value) {\n input.value.value = ''\n }\n return\n }\n\n inputValue.value = value\n\n if (props.separator?.includes(value.charAt(value.length - 1))) {\n addTag(value.slice(0, value.length - 1))\n return\n }\n\n validTags.value = props.tagValidator(value) && !isDuplicate.value ? [value] : []\n invalidTags.value = props.tagValidator(value) ? [] : [value]\n duplicateTags.value = isDuplicate.value ? [value] : []\n\n emit('tag-state', validTags.value, invalidTags.value, duplicateTags.value)\n}\n\nconst onChange = (e: Readonly<Event>): void => {\n if (props.addOnChange) {\n onInput(e)\n\n if (!isDuplicate.value) {\n addTag(inputValue.value)\n }\n }\n}\n\nconst onKeydown = (e: Readonly<KeyboardEvent>): void => {\n if ((e.key === 'Enter' || e.code === 'NumpadEnter') && !props.noAddOnEnter) {\n addTag(inputValue.value)\n return\n }\n\n if (\n (e.key === 'Backspace' || e.key === 'Delete') &&\n props.removeOnDelete &&\n inputValue.value === '' &&\n shouldRemoveOnDelete.value &&\n modelValue.value.length > 0\n ) {\n removeTag(modelValue.value[modelValue.value.length - 1])\n } else {\n shouldRemoveOnDelete.value = true\n }\n}\n\nonKeyStroke(onKeydown, {target: input, passive: true})\n\nconst separator = computed(() => {\n if (!props.separator) {\n return undefined\n }\n\n return typeof props.separator === 'string' ? props.separator : props.separator.join('')\n})\n\nconst separatorRegExp = computed(() => {\n if (!separator.value) {\n return undefined\n }\n\n return new RegExp(`[${escapeRegExpChars(separator.value)}]+`)\n})\n\nconst addTag = (tag?: string): void => {\n tag = (tag ?? inputValue.value).trim()\n\n const newTags = separatorRegExp.value\n ? tag.split(separatorRegExp.value).map((t) => t.trim())\n : [tag]\n const validTags: string[] = []\n\n for (const newTag of newTags) {\n if (newTag === '' || isDuplicate.value || !props.tagValidator(newTag)) {\n continue\n }\n\n if (limitNumber.value && isLimitReached.value) {\n break\n }\n\n validTags.push(newTag)\n }\n\n const newValue = [...modelValue.value, ...validTags]\n inputValue.value = ''\n shouldRemoveOnDelete.value = true\n modelValue.value = newValue\n if (validTags.length > 0) {\n emit('tag-added', validTags)\n }\n focused.value = true\n}\n\nconst removeTag = (tag?: string): void => {\n const tagStr = tag?.toString() ?? ''\n const tagIndex = modelValue.value.indexOf(tagStr)\n if (tagIndex === -1) return\n lastRemovedTag.value = tagStr\n modelValue.value = [\n ...modelValue.value.slice(0, tagIndex),\n ...modelValue.value.slice(tagIndex + 1),\n ]\n}\n\ndefineExpose({\n blur: () => {\n focused.value = false\n },\n element: input,\n focus: () => {\n focused.value = true\n },\n inputValue,\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqNA,MAAM,QAAQ,YAAY,SAAQ,WAAW;EAC7C,MAAM,OAAO;EAGb,MAAM,aAAa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,OAAA,OAAA,MAAA,WAAE,OAAO,WAAA,KAAU;IAEzB,GAAA,CAAA,WAA6D,KAAA,QAAA,mBAAA,CAAA,SAAA,CAA7B,gBAAA,gBAAA,MAAA,KAAA,CAAK,CAAC,aAAa,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,UAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,CAAA,GAAA,GAAA,UAAA,CAAA,GAAA,GAAA,UAAA,GAK3D,mBAUM,OAAA;KAVA,aAAW,MAAA,KAAA,CAAK,CAAC;KAAkB,eAAY;;KACxC,UAAA,SAAX,UAAA,GAAA,mBAEM,OAFN,aAEM,gBADD,MAAA,KAAA,CAAK,CAAC,cAAc,IAAG,OAAE,gBAAG,WAAA,KAAU,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;KAE9B,YAAA,SAAb,UAAA,GAAA,mBAEC,SAFD,aAEC,gBADK,MAAA,KAAA,CAAK,CAAC,gBAAgB,IAAG,OAAE,gBAAG,WAAA,KAAU,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;KAEjC,eAAA,SAAb,UAAA,GAAA,mBAEC,SAFD,aAEC,gBADI,MAAA,KAAA,CAAK,CAAC,aAAa,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;;IAIZ,MAAA,KAAA,CAAK,CAAC,QACpB,UAAA,IAAA,GAAA,mBAME,UAAA,EAAA,KAAA,EAAA,GAAA,WALuB,WAAA,QAAf,KAAK,UAAK;KADpB,OAAA,UAAA,GAAA,mBAME,SAAA;MAJC,KAAK;MACN,MAAK;MACJ,MAAM,MAAA,KAAA,CAAK,CAAC;MACZ,OAAO"}
|
|
1
|
+
{"version":3,"file":"BFormTags-6qQn0Vlv.js","names":[],"sources":["../src/components/BFormTags/BFormTags.vue","../src/components/BFormTags/BFormTags.vue"],"sourcesContent":["<template>\n <div\n :id=\"computedId\"\n class=\"b-form-tags form-control h-auto\"\n :class=\"computedClasses\"\n role=\"group\"\n tabindex=\"-1\"\n @click=\"onClick\"\n @focusin=\"onFocusin\"\n @focusout=\"emit('focusout', $event)\"\n >\n <output\n :id=\"`${computedId}selected_tags__`\"\n class=\"visually-hidden\"\n :for=\"_inputId\"\n :aria-live=\"focused ? 'polite' : 'off'\"\n aria-atomic=\"true\"\n aria-relevant=\"additions\"\n >{{ modelValue.join(', ') }}</output\n >\n <div\n :id=\"`${computedId}removed_tags__`\"\n role=\"status\"\n :aria-live=\"focused ? 'assertive' : 'off'\"\n aria-atomic=\"true\"\n class=\"visually-hidden\"\n >\n ({{ props.tagRemovedLabel }}) {{ lastRemovedTag }}\n </div>\n\n <slot\n :add-button-text=\"props.addButtonText\"\n :add-button-variant=\"props.addButtonVariant\"\n :add-tag\n :disable-add-button=\"disableAddButton\"\n :disabled=\"props.disabled\"\n :duplicate-tag-text=\"props.duplicateTagText\"\n :duplicate-tags=\"duplicateTags\"\n :form=\"props.form\"\n :input-attrs=\"{\n ...props.inputAttrs,\n disabled: props.disabled,\n form: props.form,\n id: _inputId,\n value: inputValue,\n }\"\n :input-class=\"props.inputClass\"\n :input-handlers=\"{\n input: onInput,\n keydown: onKeydown,\n change: onChange,\n }\"\n :input-id=\"_inputId\"\n :input-type=\"props.inputType\"\n :invalid-tag-text=\"props.invalidTagText\"\n :invalid-tags\n :is-duplicate\n :is-invalid\n :is-limit-reached=\"isLimitReached\"\n :limit-tags-text=\"props.limitTagsText\"\n :limit=\"limitNumber\"\n :no-tag-remove=\"props.noTagRemove\"\n :placeholder=\"props.placeholder\"\n :remove-tag\n :required=\"props.required\"\n :separator=\"props.separator\"\n :size=\"props.size\"\n :state=\"props.state\"\n :tag-class=\"props.tagClass\"\n :tag-pills=\"props.tagPills\"\n :tag-remove-label=\"props.tagRemoveLabel\"\n :tag-variant=\"props.tagVariant\"\n :tags=\"[...modelValue]\"\n >\n <ul\n :id=\"`${computedId}tag_list__`\"\n class=\"b-form-tags-list list-unstyled mb-0 d-flex flex-wrap align-items-center\"\n >\n <template v-for=\"(tag, index) in modelValue\" :key=\"index\">\n <slot\n name=\"tag\"\n :tag=\"tag\"\n :tag-class=\"props.tagClass\"\n :tag-variant=\"props.tagVariant\"\n :tag-pills=\"props.tagPills\"\n :remove-tag=\"removeTag\"\n >\n <BFormTag\n :key=\"tag\"\n :class=\"props.tagClass\"\n tag=\"li\"\n :variant=\"props.tagVariant\"\n :pill=\"props.tagPills\"\n :no-remove=\"props.noTagRemove\"\n :disabled=\"props.disabled\"\n @remove=\"removeTag\"\n >{{ tag }}</BFormTag\n >\n </slot>\n </template>\n <li\n role=\"none\"\n aria-live=\"off\"\n class=\"b-from-tags-field flex-grow-1\"\n :aria-controls=\"`${computedId}tag_list__`\"\n >\n <div role=\"group\" class=\"d-flex\">\n <input\n :id=\"_inputId\"\n ref=\"_input\"\n :disabled=\"props.disabled\"\n :value=\"inputValue\"\n :type=\"props.inputType\"\n :placeholder=\"props.placeholder\"\n class=\"b-form-tags-input w-100 flex-grow-1 p-0 m-0 bg-transparent border-0\"\n style=\"outline: currentcolor none 0; min-width: 5rem\"\n v-bind=\"props.inputAttrs\"\n :form=\"props.form\"\n :required=\"props.required || undefined\"\n :aria-required=\"props.required || undefined\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n />\n <button\n v-if=\"disableAddButton\"\n type=\"button\"\n class=\"btn b-form-tags-button py-0\"\n :class=\"[\n inputClass,\n {\n [`btn-${props.addButtonVariant}`]: props.addButtonVariant !== null,\n 'disabled invisible': inputValue.length === 0,\n },\n ]\"\n style=\"font-size: 90%\"\n :disabled=\"props.disabled || inputValue.length === 0 || isLimitReached\"\n @click=\"addTag(inputValue)\"\n >\n <slot name=\"add-button-text\">{{ props.addButtonText }}</slot>\n </button>\n </div>\n </li>\n </ul>\n <div :aria-live=\"props.feedbackAriaLive\" aria-atomic=\"true\">\n <div v-if=\"isInvalid\" class=\"d-block invalid-feedback\">\n {{ props.invalidTagText }}: {{ inputValue }}\n </div>\n <small v-if=\"isDuplicate\" class=\"form-text text-body-secondary\"\n >{{ props.duplicateTagText }}: {{ inputValue }}</small\n >\n <small v-if=\"isLimitReached\" class=\"form-text text-body-secondary\">\n {{ props.limitTagsText }}</small\n >\n </div>\n </slot>\n <template v-if=\"props.name\">\n <input\n v-for=\"(tag, index) in modelValue\"\n :key=\"index\"\n type=\"hidden\"\n :name=\"props.name\"\n :value=\"tag\"\n />\n </template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {computed, ref, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {escapeRegExpChars} from '../../utils/stringUtils'\nimport BFormTag from './BFormTag.vue'\nimport {useId} from '../../composables/useId'\nimport {useStateClass} from '../../composables/useStateClass'\nimport type {BFormTagsEmits, BFormTagsProps, BFormTagsSlots} from '../../types'\n\nconst _props = withDefaults(defineProps<Omit<BFormTagsProps, 'modelValue'>>(), {\n addButtonText: 'Add',\n addButtonVariant: 'outline-secondary',\n addOnChange: false,\n autofocus: false,\n disabled: false,\n duplicateTagText: 'Duplicate tag(s)',\n feedbackAriaLive: 'assertive',\n form: undefined,\n ignoreInputFocusSelector: () => ['.b-form-tag', 'button', 'input', 'select'],\n inputAttrs: undefined,\n inputClass: undefined,\n inputId: undefined,\n inputType: 'text',\n invalidTagText: 'Invalid tag(s)',\n limit: undefined,\n limitTagsText: 'Tag limit reached',\n name: undefined,\n noAddOnEnter: false,\n noOuterFocus: false,\n noTagRemove: false,\n placeholder: 'Add tag...',\n removeOnDelete: false,\n required: false,\n separator: undefined,\n size: undefined,\n state: null,\n tagClass: undefined,\n tagPills: false,\n tagRemoveLabel: undefined,\n tagRemovedLabel: 'Tag removed',\n tagValidator: () => true,\n tagVariant: 'secondary',\n})\nconst props = useDefaults(_props, 'BFormTags')\nconst emit = defineEmits<BFormTagsEmits>()\ndefineSlots<BFormTagsSlots>()\n\nconst modelValue = defineModel<Exclude<BFormTagsProps['modelValue'], undefined>>({\n default: () => [],\n})\n\nconst computedId = useId()\n\nconst limitNumber = useToNumber(() => props.limit ?? Number.NaN)\n\nconst stateClass = useStateClass(() => props.state)\n\nconst input = useTemplateRef('_input')\n\nconst {focused} = useFocus(input, {\n initialValue: props.autofocus,\n})\n\nconst _inputId = computed(() => props.inputId || `${computedId.value}input__`)\nconst inputValue = ref<string>('')\nconst shouldRemoveOnDelete = ref<boolean>(modelValue.value.length > 0)\nconst lastRemovedTag = ref<string>('')\nconst validTags = ref<string[]>([])\nconst invalidTags = ref<string[]>([])\nconst duplicateTags = ref<string[]>([])\n\nconst computedClasses = computed(() => [\n stateClass.value,\n {\n [`form-control-${props.size}`]: props.size !== undefined,\n disabled: props.disabled,\n focus: focused.value,\n },\n])\n\nconst isDuplicate = computed(() => modelValue.value.includes(inputValue.value))\nconst isInvalid = computed(() =>\n inputValue.value === '' ? false : !props.tagValidator(inputValue.value)\n)\nconst isLimitReached = computed(() => modelValue.value.length === limitNumber.value)\nconst disableAddButton = computed(() => !isInvalid.value && !isDuplicate.value)\n\nconst onFocusin = (e: Readonly<FocusEvent>): void => {\n if (props.disabled) {\n const target = e.target as HTMLDivElement\n target.blur()\n return\n }\n\n emit('focusin', e)\n}\n\nconst onClick = (e: Readonly<MouseEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n const {target} = e\n const ignoreSelectors = props.ignoreInputFocusSelector\n if (ignoreSelectors && target instanceof Element) {\n const selector =\n typeof ignoreSelectors === 'string' ? ignoreSelectors : ignoreSelectors.join(',')\n\n if (selector && target.closest(selector)) {\n return\n }\n }\n\n focused.value = true\n}\n\nconst onFocus = (e: Readonly<FocusEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n focused.value = true\n emit('focus', e)\n}\n\nconst onBlur = (e: Readonly<FocusEvent>): void => {\n focused.value = false\n emit('blur', e)\n}\n\nconst onInput = (e: Readonly<Event> | string): void => {\n const value = typeof e === 'string' ? e : (e.target as HTMLInputElement).value\n\n shouldRemoveOnDelete.value = false\n\n if (props.separator?.includes(value.charAt(0)) && value.length > 0) {\n if (input.value) {\n input.value.value = ''\n }\n return\n }\n\n inputValue.value = value\n\n if (props.separator?.includes(value.charAt(value.length - 1))) {\n addTag(value.slice(0, value.length - 1))\n return\n }\n\n validTags.value = props.tagValidator(value) && !isDuplicate.value ? [value] : []\n invalidTags.value = props.tagValidator(value) ? [] : [value]\n duplicateTags.value = isDuplicate.value ? [value] : []\n\n emit('tag-state', validTags.value, invalidTags.value, duplicateTags.value)\n}\n\nconst onChange = (e: Readonly<Event>): void => {\n if (props.addOnChange) {\n onInput(e)\n\n if (!isDuplicate.value) {\n addTag(inputValue.value)\n }\n }\n}\n\nconst onKeydown = (e: Readonly<KeyboardEvent>): void => {\n if ((e.key === 'Enter' || e.code === 'NumpadEnter') && !props.noAddOnEnter) {\n addTag(inputValue.value)\n return\n }\n\n if (\n (e.key === 'Backspace' || e.key === 'Delete') &&\n props.removeOnDelete &&\n inputValue.value === '' &&\n shouldRemoveOnDelete.value &&\n modelValue.value.length > 0\n ) {\n removeTag(modelValue.value[modelValue.value.length - 1])\n } else {\n shouldRemoveOnDelete.value = true\n }\n}\n\nonKeyStroke(onKeydown, {target: input, passive: true})\n\nconst separator = computed(() => {\n if (!props.separator) {\n return undefined\n }\n\n return typeof props.separator === 'string' ? props.separator : props.separator.join('')\n})\n\nconst separatorRegExp = computed(() => {\n if (!separator.value) {\n return undefined\n }\n\n return new RegExp(`[${escapeRegExpChars(separator.value)}]+`)\n})\n\nconst addTag = (tag?: string): void => {\n tag = (tag ?? inputValue.value).trim()\n\n const newTags = separatorRegExp.value\n ? tag.split(separatorRegExp.value).map((t) => t.trim())\n : [tag]\n const validTags: string[] = []\n\n for (const newTag of newTags) {\n if (newTag === '' || isDuplicate.value || !props.tagValidator(newTag)) {\n continue\n }\n\n if (limitNumber.value && isLimitReached.value) {\n break\n }\n\n validTags.push(newTag)\n }\n\n const newValue = [...modelValue.value, ...validTags]\n inputValue.value = ''\n shouldRemoveOnDelete.value = true\n modelValue.value = newValue\n if (validTags.length > 0) {\n emit('tag-added', validTags)\n }\n focused.value = true\n}\n\nconst removeTag = (tag?: string): void => {\n const tagStr = tag?.toString() ?? ''\n const tagIndex = modelValue.value.indexOf(tagStr)\n if (tagIndex === -1) return\n lastRemovedTag.value = tagStr\n modelValue.value = [\n ...modelValue.value.slice(0, tagIndex),\n ...modelValue.value.slice(tagIndex + 1),\n ]\n}\n\ndefineExpose({\n blur: () => {\n focused.value = false\n },\n element: input,\n focus: () => {\n focused.value = true\n },\n inputValue,\n})\n</script>\n","<template>\n <div\n :id=\"computedId\"\n class=\"b-form-tags form-control h-auto\"\n :class=\"computedClasses\"\n role=\"group\"\n tabindex=\"-1\"\n @click=\"onClick\"\n @focusin=\"onFocusin\"\n @focusout=\"emit('focusout', $event)\"\n >\n <output\n :id=\"`${computedId}selected_tags__`\"\n class=\"visually-hidden\"\n :for=\"_inputId\"\n :aria-live=\"focused ? 'polite' : 'off'\"\n aria-atomic=\"true\"\n aria-relevant=\"additions\"\n >{{ modelValue.join(', ') }}</output\n >\n <div\n :id=\"`${computedId}removed_tags__`\"\n role=\"status\"\n :aria-live=\"focused ? 'assertive' : 'off'\"\n aria-atomic=\"true\"\n class=\"visually-hidden\"\n >\n ({{ props.tagRemovedLabel }}) {{ lastRemovedTag }}\n </div>\n\n <slot\n :add-button-text=\"props.addButtonText\"\n :add-button-variant=\"props.addButtonVariant\"\n :add-tag\n :disable-add-button=\"disableAddButton\"\n :disabled=\"props.disabled\"\n :duplicate-tag-text=\"props.duplicateTagText\"\n :duplicate-tags=\"duplicateTags\"\n :form=\"props.form\"\n :input-attrs=\"{\n ...props.inputAttrs,\n disabled: props.disabled,\n form: props.form,\n id: _inputId,\n value: inputValue,\n }\"\n :input-class=\"props.inputClass\"\n :input-handlers=\"{\n input: onInput,\n keydown: onKeydown,\n change: onChange,\n }\"\n :input-id=\"_inputId\"\n :input-type=\"props.inputType\"\n :invalid-tag-text=\"props.invalidTagText\"\n :invalid-tags\n :is-duplicate\n :is-invalid\n :is-limit-reached=\"isLimitReached\"\n :limit-tags-text=\"props.limitTagsText\"\n :limit=\"limitNumber\"\n :no-tag-remove=\"props.noTagRemove\"\n :placeholder=\"props.placeholder\"\n :remove-tag\n :required=\"props.required\"\n :separator=\"props.separator\"\n :size=\"props.size\"\n :state=\"props.state\"\n :tag-class=\"props.tagClass\"\n :tag-pills=\"props.tagPills\"\n :tag-remove-label=\"props.tagRemoveLabel\"\n :tag-variant=\"props.tagVariant\"\n :tags=\"[...modelValue]\"\n >\n <ul\n :id=\"`${computedId}tag_list__`\"\n class=\"b-form-tags-list list-unstyled mb-0 d-flex flex-wrap align-items-center\"\n >\n <template v-for=\"(tag, index) in modelValue\" :key=\"index\">\n <slot\n name=\"tag\"\n :tag=\"tag\"\n :tag-class=\"props.tagClass\"\n :tag-variant=\"props.tagVariant\"\n :tag-pills=\"props.tagPills\"\n :remove-tag=\"removeTag\"\n >\n <BFormTag\n :key=\"tag\"\n :class=\"props.tagClass\"\n tag=\"li\"\n :variant=\"props.tagVariant\"\n :pill=\"props.tagPills\"\n :no-remove=\"props.noTagRemove\"\n :disabled=\"props.disabled\"\n @remove=\"removeTag\"\n >{{ tag }}</BFormTag\n >\n </slot>\n </template>\n <li\n role=\"none\"\n aria-live=\"off\"\n class=\"b-from-tags-field flex-grow-1\"\n :aria-controls=\"`${computedId}tag_list__`\"\n >\n <div role=\"group\" class=\"d-flex\">\n <input\n :id=\"_inputId\"\n ref=\"_input\"\n :disabled=\"props.disabled\"\n :value=\"inputValue\"\n :type=\"props.inputType\"\n :placeholder=\"props.placeholder\"\n class=\"b-form-tags-input w-100 flex-grow-1 p-0 m-0 bg-transparent border-0\"\n style=\"outline: currentcolor none 0; min-width: 5rem\"\n v-bind=\"props.inputAttrs\"\n :form=\"props.form\"\n :required=\"props.required || undefined\"\n :aria-required=\"props.required || undefined\"\n @input=\"onInput\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n />\n <button\n v-if=\"disableAddButton\"\n type=\"button\"\n class=\"btn b-form-tags-button py-0\"\n :class=\"[\n inputClass,\n {\n [`btn-${props.addButtonVariant}`]: props.addButtonVariant !== null,\n 'disabled invisible': inputValue.length === 0,\n },\n ]\"\n style=\"font-size: 90%\"\n :disabled=\"props.disabled || inputValue.length === 0 || isLimitReached\"\n @click=\"addTag(inputValue)\"\n >\n <slot name=\"add-button-text\">{{ props.addButtonText }}</slot>\n </button>\n </div>\n </li>\n </ul>\n <div :aria-live=\"props.feedbackAriaLive\" aria-atomic=\"true\">\n <div v-if=\"isInvalid\" class=\"d-block invalid-feedback\">\n {{ props.invalidTagText }}: {{ inputValue }}\n </div>\n <small v-if=\"isDuplicate\" class=\"form-text text-body-secondary\"\n >{{ props.duplicateTagText }}: {{ inputValue }}</small\n >\n <small v-if=\"isLimitReached\" class=\"form-text text-body-secondary\">\n {{ props.limitTagsText }}</small\n >\n </div>\n </slot>\n <template v-if=\"props.name\">\n <input\n v-for=\"(tag, index) in modelValue\"\n :key=\"index\"\n type=\"hidden\"\n :name=\"props.name\"\n :value=\"tag\"\n />\n </template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport {onKeyStroke, useFocus, useToNumber} from '@vueuse/core'\nimport {computed, ref, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {escapeRegExpChars} from '../../utils/stringUtils'\nimport BFormTag from './BFormTag.vue'\nimport {useId} from '../../composables/useId'\nimport {useStateClass} from '../../composables/useStateClass'\nimport type {BFormTagsEmits, BFormTagsProps, BFormTagsSlots} from '../../types'\n\nconst _props = withDefaults(defineProps<Omit<BFormTagsProps, 'modelValue'>>(), {\n addButtonText: 'Add',\n addButtonVariant: 'outline-secondary',\n addOnChange: false,\n autofocus: false,\n disabled: false,\n duplicateTagText: 'Duplicate tag(s)',\n feedbackAriaLive: 'assertive',\n form: undefined,\n ignoreInputFocusSelector: () => ['.b-form-tag', 'button', 'input', 'select'],\n inputAttrs: undefined,\n inputClass: undefined,\n inputId: undefined,\n inputType: 'text',\n invalidTagText: 'Invalid tag(s)',\n limit: undefined,\n limitTagsText: 'Tag limit reached',\n name: undefined,\n noAddOnEnter: false,\n noOuterFocus: false,\n noTagRemove: false,\n placeholder: 'Add tag...',\n removeOnDelete: false,\n required: false,\n separator: undefined,\n size: undefined,\n state: null,\n tagClass: undefined,\n tagPills: false,\n tagRemoveLabel: undefined,\n tagRemovedLabel: 'Tag removed',\n tagValidator: () => true,\n tagVariant: 'secondary',\n})\nconst props = useDefaults(_props, 'BFormTags')\nconst emit = defineEmits<BFormTagsEmits>()\ndefineSlots<BFormTagsSlots>()\n\nconst modelValue = defineModel<Exclude<BFormTagsProps['modelValue'], undefined>>({\n default: () => [],\n})\n\nconst computedId = useId()\n\nconst limitNumber = useToNumber(() => props.limit ?? Number.NaN)\n\nconst stateClass = useStateClass(() => props.state)\n\nconst input = useTemplateRef('_input')\n\nconst {focused} = useFocus(input, {\n initialValue: props.autofocus,\n})\n\nconst _inputId = computed(() => props.inputId || `${computedId.value}input__`)\nconst inputValue = ref<string>('')\nconst shouldRemoveOnDelete = ref<boolean>(modelValue.value.length > 0)\nconst lastRemovedTag = ref<string>('')\nconst validTags = ref<string[]>([])\nconst invalidTags = ref<string[]>([])\nconst duplicateTags = ref<string[]>([])\n\nconst computedClasses = computed(() => [\n stateClass.value,\n {\n [`form-control-${props.size}`]: props.size !== undefined,\n disabled: props.disabled,\n focus: focused.value,\n },\n])\n\nconst isDuplicate = computed(() => modelValue.value.includes(inputValue.value))\nconst isInvalid = computed(() =>\n inputValue.value === '' ? false : !props.tagValidator(inputValue.value)\n)\nconst isLimitReached = computed(() => modelValue.value.length === limitNumber.value)\nconst disableAddButton = computed(() => !isInvalid.value && !isDuplicate.value)\n\nconst onFocusin = (e: Readonly<FocusEvent>): void => {\n if (props.disabled) {\n const target = e.target as HTMLDivElement\n target.blur()\n return\n }\n\n emit('focusin', e)\n}\n\nconst onClick = (e: Readonly<MouseEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n const {target} = e\n const ignoreSelectors = props.ignoreInputFocusSelector\n if (ignoreSelectors && target instanceof Element) {\n const selector =\n typeof ignoreSelectors === 'string' ? ignoreSelectors : ignoreSelectors.join(',')\n\n if (selector && target.closest(selector)) {\n return\n }\n }\n\n focused.value = true\n}\n\nconst onFocus = (e: Readonly<FocusEvent>): void => {\n if (props.disabled || props.noOuterFocus) {\n return\n }\n\n focused.value = true\n emit('focus', e)\n}\n\nconst onBlur = (e: Readonly<FocusEvent>): void => {\n focused.value = false\n emit('blur', e)\n}\n\nconst onInput = (e: Readonly<Event> | string): void => {\n const value = typeof e === 'string' ? e : (e.target as HTMLInputElement).value\n\n shouldRemoveOnDelete.value = false\n\n if (props.separator?.includes(value.charAt(0)) && value.length > 0) {\n if (input.value) {\n input.value.value = ''\n }\n return\n }\n\n inputValue.value = value\n\n if (props.separator?.includes(value.charAt(value.length - 1))) {\n addTag(value.slice(0, value.length - 1))\n return\n }\n\n validTags.value = props.tagValidator(value) && !isDuplicate.value ? [value] : []\n invalidTags.value = props.tagValidator(value) ? [] : [value]\n duplicateTags.value = isDuplicate.value ? [value] : []\n\n emit('tag-state', validTags.value, invalidTags.value, duplicateTags.value)\n}\n\nconst onChange = (e: Readonly<Event>): void => {\n if (props.addOnChange) {\n onInput(e)\n\n if (!isDuplicate.value) {\n addTag(inputValue.value)\n }\n }\n}\n\nconst onKeydown = (e: Readonly<KeyboardEvent>): void => {\n if ((e.key === 'Enter' || e.code === 'NumpadEnter') && !props.noAddOnEnter) {\n addTag(inputValue.value)\n return\n }\n\n if (\n (e.key === 'Backspace' || e.key === 'Delete') &&\n props.removeOnDelete &&\n inputValue.value === '' &&\n shouldRemoveOnDelete.value &&\n modelValue.value.length > 0\n ) {\n removeTag(modelValue.value[modelValue.value.length - 1])\n } else {\n shouldRemoveOnDelete.value = true\n }\n}\n\nonKeyStroke(onKeydown, {target: input, passive: true})\n\nconst separator = computed(() => {\n if (!props.separator) {\n return undefined\n }\n\n return typeof props.separator === 'string' ? props.separator : props.separator.join('')\n})\n\nconst separatorRegExp = computed(() => {\n if (!separator.value) {\n return undefined\n }\n\n return new RegExp(`[${escapeRegExpChars(separator.value)}]+`)\n})\n\nconst addTag = (tag?: string): void => {\n tag = (tag ?? inputValue.value).trim()\n\n const newTags = separatorRegExp.value\n ? tag.split(separatorRegExp.value).map((t) => t.trim())\n : [tag]\n const validTags: string[] = []\n\n for (const newTag of newTags) {\n if (newTag === '' || isDuplicate.value || !props.tagValidator(newTag)) {\n continue\n }\n\n if (limitNumber.value && isLimitReached.value) {\n break\n }\n\n validTags.push(newTag)\n }\n\n const newValue = [...modelValue.value, ...validTags]\n inputValue.value = ''\n shouldRemoveOnDelete.value = true\n modelValue.value = newValue\n if (validTags.length > 0) {\n emit('tag-added', validTags)\n }\n focused.value = true\n}\n\nconst removeTag = (tag?: string): void => {\n const tagStr = tag?.toString() ?? ''\n const tagIndex = modelValue.value.indexOf(tagStr)\n if (tagIndex === -1) return\n lastRemovedTag.value = tagStr\n modelValue.value = [\n ...modelValue.value.slice(0, tagIndex),\n ...modelValue.value.slice(tagIndex + 1),\n ]\n}\n\ndefineExpose({\n blur: () => {\n focused.value = false\n },\n element: input,\n focus: () => {\n focused.value = true\n },\n inputValue,\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqNA,MAAM,QAAQ,YAAY,SAAQ,WAAW;EAC7C,MAAM,OAAO;EAGb,MAAM,aAAa,SAA6D,SAAA,YAE/E;EAED,MAAM,aAAa,QAAM;EAEzB,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAU;EAE/D,MAAM,aAAa,oBAAoB,MAAM,KAAK;EAElD,MAAM,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AAC,aAAa,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,UAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,CAAA,GAAA,GAAA,UAAA,CAAA,GAAA,GAAA,UAAA,GAK3D,mBAUM,OAAA;KAVA,aAAW,MAAA,KAAA,CAAK,CAAC;KAAkB,eAAY;;KACxC,UAAA,SAAX,UAAA,GAAA,mBAEM,OAFN,aAEM,gBADD,MAAA,KAAA,CAAK,CAAC,cAAc,IAAG,OAAE,gBAAG,WAAA,KAAU,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;KAE9B,YAAA,SAAb,UAAA,GAAA,mBAEC,SAFD,aAEC,gBADK,MAAA,KAAA,CAAK,CAAC,gBAAgB,IAAG,OAAE,gBAAG,WAAA,KAAU,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;KAEjC,eAAA,SAAb,UAAA,GAAA,mBAEC,SAFD,aAEC,gBADI,MAAA,KAAA,CAAK,CAAC,aAAa,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;;IAIZ,MAAA,KAAA,CAAK,CAAC,QACpB,UAAA,IAAA,GAAA,mBAME,UAAA,EAAA,KAAA,EAAA,GAAA,WALuB,WAAA,QAAf,KAAK,UAAK;KADpB,OAAA,UAAA,GAAA,mBAME,SAAA;MAJC,KAAK;MACN,MAAK;MACJ,MAAM,MAAA,KAAA,CAAK,CAAC;MACZ,OAAO"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as useToNumber } from "./dist-DKc2ivHS.js";
|
|
2
1
|
import { s as isVisible } from "./dom-BdUQrX99.js";
|
|
3
2
|
import { t as useDefaults } from "./useDefaults-BzP4qZBu.js";
|
|
4
|
-
import { n as normalizeInput, t as useFormInput } from "./useFormInput-
|
|
3
|
+
import { n as normalizeInput, t as useFormInput } from "./useFormInput-CMtXFoM2.js";
|
|
5
4
|
import { computed, createElementBlock, defineComponent, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, openBlock, ref, toValue, unref, useModel, useTemplateRef } from "vue";
|
|
5
|
+
import { useToNumber } from "@vueuse/core";
|
|
6
6
|
//#region src/composables/useTextareaResize.ts
|
|
7
7
|
var useTextareaResize = (input, { maxRows, noAutoShrink, rows }) => {
|
|
8
8
|
const height = ref(0);
|
|
@@ -194,4 +194,4 @@ var BFormTextarea_default = /* @__PURE__ */ defineComponent({
|
|
|
194
194
|
//#endregion
|
|
195
195
|
export { BFormTextarea_default as t };
|
|
196
196
|
|
|
197
|
-
//# sourceMappingURL=BFormTextarea-
|
|
197
|
+
//# sourceMappingURL=BFormTextarea-DvLrtG08.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BFormTextarea-CBBlEcrV.js","names":[],"sources":["../src/composables/useTextareaResize.ts","../src/components/BFormTextarea/BFormTextarea.vue","../src/components/BFormTextarea/BFormTextarea.vue"],"sourcesContent":["import {useToNumber} from '@vueuse/core'\nimport type {Numberish} from '../types/CommonTypes'\nimport {\n computed,\n type CSSProperties,\n type MaybeRefOrGetter,\n nextTick,\n onMounted,\n ref,\n type ShallowRef,\n toValue,\n} from 'vue'\nimport {isVisible} from '../utils/dom'\n\nexport const useTextareaResize = (\n input: Readonly<ShallowRef<HTMLTextAreaElement | null>>,\n {\n maxRows,\n noAutoShrink,\n rows,\n }: {\n rows: MaybeRefOrGetter<Numberish>\n maxRows: MaybeRefOrGetter<Numberish | undefined>\n noAutoShrink: MaybeRefOrGetter<boolean>\n }\n) => {\n const height = ref<number | null | string>(0)\n const maxRowsNumber = useToNumber(\n computed(() => toValue(maxRows) || Number.NaN),\n {\n method: 'parseInt',\n nanToZero: true,\n }\n )\n const rowsNumber = useToNumber(rows, {\n method: 'parseInt',\n nanToZero: true,\n })\n const computedMinRows = computed(() => Math.max(rowsNumber.value || 2, 2))\n const computedMaxRows = computed(() => Math.max(computedMinRows.value, maxRowsNumber.value || 0))\n const computedRows = computed(() =>\n computedMinRows.value === computedMaxRows.value ? computedMinRows.value : null\n )\n\n const handleHeightChange = async () => {\n // Element must be visible (not hidden) and in document\n // Must be checked after above checks\n if (!input.value || !isVisible(input.value)) {\n height.value = null\n return\n }\n\n // Get current computed styles\n const computedStyle = getComputedStyle(input.value)\n // Height of one line of text in px\n const lineHeight = Number.parseFloat(computedStyle.lineHeight) || 1\n // Calculate height of border and padding\n const border =\n (Number.parseFloat(computedStyle.borderTopWidth) || 0) +\n (Number.parseFloat(computedStyle.borderBottomWidth) || 0)\n const padding =\n (Number.parseFloat(computedStyle.paddingTop) || 0) +\n (Number.parseFloat(computedStyle.paddingBottom) || 0)\n // Calculate offset\n const offset = border + padding\n // Minimum height for min rows (which must be 2 rows or greater for cross-browser support)\n const minHeight = lineHeight * computedMinRows.value + offset\n\n // Get the current style height (with `px` units)\n const oldHeight = input.value.style.height || computedStyle.height\n // Probe scrollHeight by temporarily changing the height to `auto`\n height.value = 'auto'\n await nextTick() // We need to wait for the dom to update. These cannot be batched in the same tick\n // Re-check input.value after await since the element may have been unmounted\n // (e.g., during SSR hydration when BFormGroup re-renders its wrapper element)\n if (!input.value) return\n const {scrollHeight} = input.value\n // Place the original old height back on the element, just in case `computedProp`\n // returns the same value as before\n height.value = oldHeight\n await nextTick() // We need to wait for the dom to update. These cannot be batched in the same tick\n if (!input.value) return\n\n // Calculate content height in 'rows' (scrollHeight includes padding but not border)\n const contentRows = Math.max((scrollHeight - padding) / lineHeight, 2)\n // Calculate number of rows to display (limited within min/max rows)\n const rows = Math.min(Math.max(contentRows, computedMinRows.value), computedMaxRows.value)\n // Calculate the required height of the textarea including border and padding (in pixels)\n const newHeight = Math.max(Math.ceil(rows * lineHeight + offset), minHeight)\n\n // Computed height remains the larger of `oldHeight` and new `height`,\n // when height is in `sticky` mode (prop `no-auto-shrink` is true)\n if (toValue(noAutoShrink) && (Number.parseFloat(oldHeight.toString()) || 0) > newHeight) {\n height.value = oldHeight\n return\n }\n\n // Return the new computed CSS height in px units\n height.value = `${newHeight}px`\n }\n\n onMounted(handleHeightChange)\n\n const computedStyles = computed<CSSProperties>(() => ({\n resize: 'none',\n height:\n typeof height.value === 'string'\n ? height.value\n : height.value\n ? `${height.value}px`\n : undefined,\n }))\n\n return {\n onInput: handleHeightChange,\n computedStyles,\n computedRows,\n }\n}\n","<template>\n <textarea\n :id=\"computedId\"\n ref=\"_input\"\n :class=\"computedClasses\"\n :name=\"props.name || undefined\"\n :form=\"props.form || undefined\"\n :value=\"computedValue\"\n :disabled=\"isDisabled\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required || undefined\"\n :autocomplete=\"props.autocomplete || undefined\"\n :readonly=\"props.readonly || props.plaintext\"\n :aria-required=\"props.required || undefined\"\n :aria-invalid=\"computedAriaInvalid\"\n :rows=\"computedRows || 2\"\n :style=\"computedStyles\"\n :wrap=\"props.wrap || undefined\"\n @input=\"\n (e) => {\n onInput(e)\n handleHeightChange()\n }\n \"\n @change=\"onChange\"\n @blur=\"onBlur\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormTextareaProps} from '../../types'\nimport {computed, type CSSProperties, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {normalizeInput} from '../../utils/normalizeInput'\nimport {useFormInput} from '../../composables/useFormInput'\nimport {useTextareaResize} from '../../composables/useTextareaResize'\n\nconst _props = withDefaults(defineProps<Omit<BFormTextareaProps, 'modelValue'>>(), {\n // CommonInputProps\n ariaInvalid: undefined,\n autocomplete: undefined,\n autofocus: false,\n debounce: 0,\n debounceMaxWait: Number.NaN,\n disabled: false,\n form: undefined,\n formatter: undefined,\n id: undefined,\n lazyFormatter: false,\n list: undefined,\n modelValue: '',\n name: undefined,\n placeholder: undefined,\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: undefined,\n // End CommonInputProps\n noResize: false,\n noAutoShrink: false,\n maxRows: undefined,\n rows: 2,\n wrap: 'soft',\n})\nconst props = useDefaults(_props, 'BFormTextarea')\n\nconst [modelValue, modelModifiers] = defineModel<\n Exclude<BFormTextareaProps['modelValue'], undefined>,\n 'trim' | 'lazy' | 'number'\n>({\n default: '',\n set: (v) => normalizeInput(v, modelModifiers),\n})\n\nconst input = useTemplateRef('_input')\n\nconst {\n computedId,\n computedAriaInvalid,\n computedValue,\n onInput,\n stateClass,\n onChange,\n onBlur,\n focus,\n blur,\n isDisabled,\n} = useFormInput(props, input, modelValue, modelModifiers)\n\nconst computedClasses = computed(() => [\n stateClass.value,\n props.plaintext ? 'form-control-plaintext' : 'form-control',\n {\n [`form-control-${props.size}`]: !!props.size,\n },\n])\n\nconst {\n computedStyles: resizeStyles,\n onInput: handleHeightChange,\n computedRows,\n} = useTextareaResize(input, {\n maxRows: () => props.maxRows,\n rows: () => props.rows,\n noAutoShrink: () => props.noAutoShrink,\n})\n\nconst computedStyles = computed<CSSProperties>(() => ({\n resize: props.noResize ? 'none' : undefined,\n ...(props.maxRows || props.noAutoShrink ? resizeStyles.value : undefined),\n}))\n\ndefineExpose({\n blur,\n element: input,\n flushDebounce: onBlur,\n focus,\n})\n</script>\n","<template>\n <textarea\n :id=\"computedId\"\n ref=\"_input\"\n :class=\"computedClasses\"\n :name=\"props.name || undefined\"\n :form=\"props.form || undefined\"\n :value=\"computedValue\"\n :disabled=\"isDisabled\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required || undefined\"\n :autocomplete=\"props.autocomplete || undefined\"\n :readonly=\"props.readonly || props.plaintext\"\n :aria-required=\"props.required || undefined\"\n :aria-invalid=\"computedAriaInvalid\"\n :rows=\"computedRows || 2\"\n :style=\"computedStyles\"\n :wrap=\"props.wrap || undefined\"\n @input=\"\n (e) => {\n onInput(e)\n handleHeightChange()\n }\n \"\n @change=\"onChange\"\n @blur=\"onBlur\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormTextareaProps} from '../../types'\nimport {computed, type CSSProperties, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {normalizeInput} from '../../utils/normalizeInput'\nimport {useFormInput} from '../../composables/useFormInput'\nimport {useTextareaResize} from '../../composables/useTextareaResize'\n\nconst _props = withDefaults(defineProps<Omit<BFormTextareaProps, 'modelValue'>>(), {\n // CommonInputProps\n ariaInvalid: undefined,\n autocomplete: undefined,\n autofocus: false,\n debounce: 0,\n debounceMaxWait: Number.NaN,\n disabled: false,\n form: undefined,\n formatter: undefined,\n id: undefined,\n lazyFormatter: false,\n list: undefined,\n modelValue: '',\n name: undefined,\n placeholder: undefined,\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: undefined,\n // End CommonInputProps\n noResize: false,\n noAutoShrink: false,\n maxRows: undefined,\n rows: 2,\n wrap: 'soft',\n})\nconst props = useDefaults(_props, 'BFormTextarea')\n\nconst [modelValue, modelModifiers] = defineModel<\n Exclude<BFormTextareaProps['modelValue'], undefined>,\n 'trim' | 'lazy' | 'number'\n>({\n default: '',\n set: (v) => normalizeInput(v, modelModifiers),\n})\n\nconst input = useTemplateRef('_input')\n\nconst {\n computedId,\n computedAriaInvalid,\n computedValue,\n onInput,\n stateClass,\n onChange,\n onBlur,\n focus,\n blur,\n isDisabled,\n} = useFormInput(props, input, modelValue, modelModifiers)\n\nconst computedClasses = computed(() => [\n stateClass.value,\n props.plaintext ? 'form-control-plaintext' : 'form-control',\n {\n [`form-control-${props.size}`]: !!props.size,\n },\n])\n\nconst {\n computedStyles: resizeStyles,\n onInput: handleHeightChange,\n computedRows,\n} = useTextareaResize(input, {\n maxRows: () => props.maxRows,\n rows: () => props.rows,\n noAutoShrink: () => props.noAutoShrink,\n})\n\nconst computedStyles = computed<CSSProperties>(() => ({\n resize: props.noResize ? 'none' : undefined,\n ...(props.maxRows || props.noAutoShrink ? resizeStyles.value : undefined),\n}))\n\ndefineExpose({\n blur,\n element: input,\n flushDebounce: onBlur,\n focus,\n})\n</script>\n"],"mappings":";;;;;;AAcA,IAAa,qBACX,OACA,EACE,SACA,cACA,WAMC;CACH,MAAM,SAAS,IAA4B,CAAC;CAC5C,MAAM,gBAAgB,YACpB,eAA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,OAAK,eAAE,gBAAA,KAAe;IACtB,MAAM,MAAA,KAAA,CAAK,CAAC,QAAQ,KAAA;IACpB,MAAM,MAAA,KAAA,CAAK,CAAC,QAAQ,KAAA;IACpB,OAAO,MAAA,aAAA;IACP,UAAU,MAAA,UAAA;IACV,aAAa,MAAA,KAAA,CAAK,CAAC;IACnB,UAAU,MAAA,KAAA,CAAK,CAAC,YAAY,KAAA;IAC5B,cAAc,MAAA,KAAA,CAAK,CAAC,gBAAgB,KAAA;IACpC,UAAU,MAAA,KAAA,CAAK,CAAC,YAAY,MAAA,KAAA,CAAK,CAAC;IAClC,iBAAe,MAAA,KAAA,CAAK,CAAC,YAAY,KAAA;IACjC,gBAAc,MAAA,mBAAA;IACd,MAAM,MAAA,YAAA,KAAY;IAClB,OAAK,eAAE,eAAA,KAAc;IACrB,MAAM,MAAA,KAAA,CAAK,CAAC,QAAQ,KAAA;IACpB,SAAK,OAAA,OAAA,OAAA,MAAU,MAAC;KAAe,MAAA,OAAA,CAAO,CAAC,CAAC;KAAU,MAAA,kBAAA,CAAkB,CAAA;;IAMpE,UAAM,OAAA,OAAA,OAAA,MAAE,GAAA,SAAA,MAAA,QAAA,KAAA,MAAA,QAAA,CAAA,CAAA,GAAA,IAAA;IACR,QAAI,OAAA,OAAA,OAAA,MAAE,GAAA,SAAA,MAAA,MAAA,KAAA,MAAA,MAAA,CAAA,CAAA,GAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"BFormTextarea-DvLrtG08.js","names":[],"sources":["../src/composables/useTextareaResize.ts","../src/components/BFormTextarea/BFormTextarea.vue","../src/components/BFormTextarea/BFormTextarea.vue"],"sourcesContent":["import {useToNumber} from '@vueuse/core'\nimport type {Numberish} from '../types/CommonTypes'\nimport {\n computed,\n type CSSProperties,\n type MaybeRefOrGetter,\n nextTick,\n onMounted,\n ref,\n type ShallowRef,\n toValue,\n} from 'vue'\nimport {isVisible} from '../utils/dom'\n\nexport const useTextareaResize = (\n input: Readonly<ShallowRef<HTMLTextAreaElement | null>>,\n {\n maxRows,\n noAutoShrink,\n rows,\n }: {\n rows: MaybeRefOrGetter<Numberish>\n maxRows: MaybeRefOrGetter<Numberish | undefined>\n noAutoShrink: MaybeRefOrGetter<boolean>\n }\n) => {\n const height = ref<number | null | string>(0)\n const maxRowsNumber = useToNumber(\n computed(() => toValue(maxRows) || Number.NaN),\n {\n method: 'parseInt',\n nanToZero: true,\n }\n )\n const rowsNumber = useToNumber(rows, {\n method: 'parseInt',\n nanToZero: true,\n })\n const computedMinRows = computed(() => Math.max(rowsNumber.value || 2, 2))\n const computedMaxRows = computed(() => Math.max(computedMinRows.value, maxRowsNumber.value || 0))\n const computedRows = computed(() =>\n computedMinRows.value === computedMaxRows.value ? computedMinRows.value : null\n )\n\n const handleHeightChange = async () => {\n // Element must be visible (not hidden) and in document\n // Must be checked after above checks\n if (!input.value || !isVisible(input.value)) {\n height.value = null\n return\n }\n\n // Get current computed styles\n const computedStyle = getComputedStyle(input.value)\n // Height of one line of text in px\n const lineHeight = Number.parseFloat(computedStyle.lineHeight) || 1\n // Calculate height of border and padding\n const border =\n (Number.parseFloat(computedStyle.borderTopWidth) || 0) +\n (Number.parseFloat(computedStyle.borderBottomWidth) || 0)\n const padding =\n (Number.parseFloat(computedStyle.paddingTop) || 0) +\n (Number.parseFloat(computedStyle.paddingBottom) || 0)\n // Calculate offset\n const offset = border + padding\n // Minimum height for min rows (which must be 2 rows or greater for cross-browser support)\n const minHeight = lineHeight * computedMinRows.value + offset\n\n // Get the current style height (with `px` units)\n const oldHeight = input.value.style.height || computedStyle.height\n // Probe scrollHeight by temporarily changing the height to `auto`\n height.value = 'auto'\n await nextTick() // We need to wait for the dom to update. These cannot be batched in the same tick\n // Re-check input.value after await since the element may have been unmounted\n // (e.g., during SSR hydration when BFormGroup re-renders its wrapper element)\n if (!input.value) return\n const {scrollHeight} = input.value\n // Place the original old height back on the element, just in case `computedProp`\n // returns the same value as before\n height.value = oldHeight\n await nextTick() // We need to wait for the dom to update. These cannot be batched in the same tick\n if (!input.value) return\n\n // Calculate content height in 'rows' (scrollHeight includes padding but not border)\n const contentRows = Math.max((scrollHeight - padding) / lineHeight, 2)\n // Calculate number of rows to display (limited within min/max rows)\n const rows = Math.min(Math.max(contentRows, computedMinRows.value), computedMaxRows.value)\n // Calculate the required height of the textarea including border and padding (in pixels)\n const newHeight = Math.max(Math.ceil(rows * lineHeight + offset), minHeight)\n\n // Computed height remains the larger of `oldHeight` and new `height`,\n // when height is in `sticky` mode (prop `no-auto-shrink` is true)\n if (toValue(noAutoShrink) && (Number.parseFloat(oldHeight.toString()) || 0) > newHeight) {\n height.value = oldHeight\n return\n }\n\n // Return the new computed CSS height in px units\n height.value = `${newHeight}px`\n }\n\n onMounted(handleHeightChange)\n\n const computedStyles = computed<CSSProperties>(() => ({\n resize: 'none',\n height:\n typeof height.value === 'string'\n ? height.value\n : height.value\n ? `${height.value}px`\n : undefined,\n }))\n\n return {\n onInput: handleHeightChange,\n computedStyles,\n computedRows,\n }\n}\n","<template>\n <textarea\n :id=\"computedId\"\n ref=\"_input\"\n :class=\"computedClasses\"\n :name=\"props.name || undefined\"\n :form=\"props.form || undefined\"\n :value=\"computedValue\"\n :disabled=\"isDisabled\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required || undefined\"\n :autocomplete=\"props.autocomplete || undefined\"\n :readonly=\"props.readonly || props.plaintext\"\n :aria-required=\"props.required || undefined\"\n :aria-invalid=\"computedAriaInvalid\"\n :rows=\"computedRows || 2\"\n :style=\"computedStyles\"\n :wrap=\"props.wrap || undefined\"\n @input=\"\n (e) => {\n onInput(e)\n handleHeightChange()\n }\n \"\n @change=\"onChange\"\n @blur=\"onBlur\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormTextareaProps} from '../../types'\nimport {computed, type CSSProperties, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {normalizeInput} from '../../utils/normalizeInput'\nimport {useFormInput} from '../../composables/useFormInput'\nimport {useTextareaResize} from '../../composables/useTextareaResize'\n\nconst _props = withDefaults(defineProps<Omit<BFormTextareaProps, 'modelValue'>>(), {\n // CommonInputProps\n ariaInvalid: undefined,\n autocomplete: undefined,\n autofocus: false,\n debounce: 0,\n debounceMaxWait: Number.NaN,\n disabled: false,\n form: undefined,\n formatter: undefined,\n id: undefined,\n lazyFormatter: false,\n list: undefined,\n modelValue: '',\n name: undefined,\n placeholder: undefined,\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: undefined,\n // End CommonInputProps\n noResize: false,\n noAutoShrink: false,\n maxRows: undefined,\n rows: 2,\n wrap: 'soft',\n})\nconst props = useDefaults(_props, 'BFormTextarea')\n\nconst [modelValue, modelModifiers] = defineModel<\n Exclude<BFormTextareaProps['modelValue'], undefined>,\n 'trim' | 'lazy' | 'number'\n>({\n default: '',\n set: (v) => normalizeInput(v, modelModifiers),\n})\n\nconst input = useTemplateRef('_input')\n\nconst {\n computedId,\n computedAriaInvalid,\n computedValue,\n onInput,\n stateClass,\n onChange,\n onBlur,\n focus,\n blur,\n isDisabled,\n} = useFormInput(props, input, modelValue, modelModifiers)\n\nconst computedClasses = computed(() => [\n stateClass.value,\n props.plaintext ? 'form-control-plaintext' : 'form-control',\n {\n [`form-control-${props.size}`]: !!props.size,\n },\n])\n\nconst {\n computedStyles: resizeStyles,\n onInput: handleHeightChange,\n computedRows,\n} = useTextareaResize(input, {\n maxRows: () => props.maxRows,\n rows: () => props.rows,\n noAutoShrink: () => props.noAutoShrink,\n})\n\nconst computedStyles = computed<CSSProperties>(() => ({\n resize: props.noResize ? 'none' : undefined,\n ...(props.maxRows || props.noAutoShrink ? resizeStyles.value : undefined),\n}))\n\ndefineExpose({\n blur,\n element: input,\n flushDebounce: onBlur,\n focus,\n})\n</script>\n","<template>\n <textarea\n :id=\"computedId\"\n ref=\"_input\"\n :class=\"computedClasses\"\n :name=\"props.name || undefined\"\n :form=\"props.form || undefined\"\n :value=\"computedValue\"\n :disabled=\"isDisabled\"\n :placeholder=\"props.placeholder\"\n :required=\"props.required || undefined\"\n :autocomplete=\"props.autocomplete || undefined\"\n :readonly=\"props.readonly || props.plaintext\"\n :aria-required=\"props.required || undefined\"\n :aria-invalid=\"computedAriaInvalid\"\n :rows=\"computedRows || 2\"\n :style=\"computedStyles\"\n :wrap=\"props.wrap || undefined\"\n @input=\"\n (e) => {\n onInput(e)\n handleHeightChange()\n }\n \"\n @change=\"onChange\"\n @blur=\"onBlur\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BFormTextareaProps} from '../../types'\nimport {computed, type CSSProperties, useTemplateRef} from 'vue'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {normalizeInput} from '../../utils/normalizeInput'\nimport {useFormInput} from '../../composables/useFormInput'\nimport {useTextareaResize} from '../../composables/useTextareaResize'\n\nconst _props = withDefaults(defineProps<Omit<BFormTextareaProps, 'modelValue'>>(), {\n // CommonInputProps\n ariaInvalid: undefined,\n autocomplete: undefined,\n autofocus: false,\n debounce: 0,\n debounceMaxWait: Number.NaN,\n disabled: false,\n form: undefined,\n formatter: undefined,\n id: undefined,\n lazyFormatter: false,\n list: undefined,\n modelValue: '',\n name: undefined,\n placeholder: undefined,\n plaintext: false,\n readonly: false,\n required: false,\n size: undefined,\n state: undefined,\n // End CommonInputProps\n noResize: false,\n noAutoShrink: false,\n maxRows: undefined,\n rows: 2,\n wrap: 'soft',\n})\nconst props = useDefaults(_props, 'BFormTextarea')\n\nconst [modelValue, modelModifiers] = defineModel<\n Exclude<BFormTextareaProps['modelValue'], undefined>,\n 'trim' | 'lazy' | 'number'\n>({\n default: '',\n set: (v) => normalizeInput(v, modelModifiers),\n})\n\nconst input = useTemplateRef('_input')\n\nconst {\n computedId,\n computedAriaInvalid,\n computedValue,\n onInput,\n stateClass,\n onChange,\n onBlur,\n focus,\n blur,\n isDisabled,\n} = useFormInput(props, input, modelValue, modelModifiers)\n\nconst computedClasses = computed(() => [\n stateClass.value,\n props.plaintext ? 'form-control-plaintext' : 'form-control',\n {\n [`form-control-${props.size}`]: !!props.size,\n },\n])\n\nconst {\n computedStyles: resizeStyles,\n onInput: handleHeightChange,\n computedRows,\n} = useTextareaResize(input, {\n maxRows: () => props.maxRows,\n rows: () => props.rows,\n noAutoShrink: () => props.noAutoShrink,\n})\n\nconst computedStyles = computed<CSSProperties>(() => ({\n resize: props.noResize ? 'none' : undefined,\n ...(props.maxRows || props.noAutoShrink ? resizeStyles.value : undefined),\n}))\n\ndefineExpose({\n blur,\n element: input,\n flushDebounce: onBlur,\n focus,\n})\n</script>\n"],"mappings":";;;;;;AAcA,IAAa,qBACX,OACA,EACE,SACA,cACA,WAMC;CACH,MAAM,SAAS,IAA4B,CAAC;CAC5C,MAAM,gBAAgB,YACpB,eAAe,QAAQ,OAAO,KAAK,GAAU,GAC7C;EACE,QAAQ;EACR,WAAW;CACb,CACF;CACA,MAAM,aAAa,YAAY,MAAM;EACnC,QAAQ;EACR,WAAW;CACb,CAAC;CACD,MAAM,kBAAkB,eAAe,KAAK,IAAI,WAAW,SAAS,GAAG,CAAC,CAAC;CACzE,MAAM,kBAAkB,eAAe,KAAK,IAAI,gBAAgB,OAAO,cAAc,SAAS,CAAC,CAAC;CAChG,MAAM,eAAe,eACnB,gBAAgB,UAAU,gBAAgB,QAAQ,gBAAgB,QAAQ,IAC5E;CAEA,MAAM,qBAAqB,YAAY;EAGrC,IAAI,CAAC,MAAM,SAAS,CAAC,UAAU,MAAM,KAAK,GAAG;GAC3C,OAAO,QAAQ;GACf;EACF;EAGA,MAAM,gBAAgB,iBAAiB,MAAM,KAAK;EAElD,MAAM,aAAa,OAAO,WAAW,cAAc,UAAU,KAAK;EAElE,MAAM,UACH,OAAO,WAAW,cAAc,cAAc,KAAK,MACnD,OAAO,WAAW,cAAc,iBAAiB,KAAK;EACzD,MAAM,WACH,OAAO,WAAW,cAAc,UAAU,KAAK,MAC/C,OAAO,WAAW,cAAc,aAAa,KAAK;EAErD,MAAM,SAAS,SAAS;EAExB,MAAM,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,IAAA;IACR,QAAI,OAAA,OAAA,OAAA,MAAE,GAAA,SAAA,MAAA,MAAA,KAAA,MAAA,MAAA,CAAA,CAAA,GAAA,IAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as useToNumber } from "./dist-DKc2ivHS.js";
|
|
2
1
|
import { t as useDefaults } from "./useDefaults-BzP4qZBu.js";
|
|
3
2
|
import { r as isReadOnlyArray } from "./object-C7YmCGEm.js";
|
|
4
3
|
import { t as useRadiusElementClasses } from "./useRadiusElementClasses-CKCJjpkK.js";
|
|
5
4
|
import { computed, createBlock, defineComponent, normalizeClass, openBlock, resolveDynamicComponent, unref } from "vue";
|
|
5
|
+
import { useToNumber } from "@vueuse/core";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/components/BImg/BImg.vue
|
|
8
8
|
var BImg_default = /* @__PURE__ */ defineComponent({
|
|
@@ -159,4 +159,4 @@ var BImg_default = /* @__PURE__ */ defineComponent({
|
|
|
159
159
|
//#endregion
|
|
160
160
|
export { BImg_default as t };
|
|
161
161
|
|
|
162
|
-
//# sourceMappingURL=BImg-
|
|
162
|
+
//# sourceMappingURL=BImg-Dd8Pc1Ln.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BImg-knz2UZQE.js","names":[],"sources":["../src/components/BImg/BImg.vue","../src/components/BImg/BImg.vue"],"sourcesContent":["<template>\n <component\n :is=\"props.tag\"\n :class=\"computedClasses\"\n class=\"b-img\"\n :src=\"!props.blank ? props.src : computedBlankImgSrc\"\n :width=\"computedDimensions.width || undefined\"\n :height=\"computedDimensions.height || undefined\"\n :srcset=\"!props.blank ? computedSrcset : undefined\"\n :sizes=\"!props.blank ? computedSizes : undefined\"\n :loading=\"props.lazy ? 'lazy' : 'eager'\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BImgProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {useRadiusElementClasses} from '../../composables/useRadiusElementClasses'\nimport {isReadOnlyArray} from '../../utils/object'\n\nconst _props = withDefaults(defineProps<BImgProps>(), {\n blank: false,\n blankColor: 'transparent',\n block: false,\n fluid: false,\n fluidGrow: false,\n height: undefined,\n lazy: false,\n sizes: undefined,\n tag: 'img',\n src: undefined,\n srcset: undefined,\n placement: undefined,\n thumbnail: false,\n width: undefined,\n // RadiusElementExtendables props\n rounded: false,\n roundedBottom: undefined,\n roundedEnd: undefined,\n roundedStart: undefined,\n roundedTop: undefined,\n // End RadiusElementExtendables props\n})\nconst props = useDefaults(_props, 'BImg')\n\nconst heightNumber = useToNumber(() => props.height ?? Number.NaN)\nconst widthNumber = useToNumber(() => props.width ?? Number.NaN)\n\nconst radiusElementClasses = useRadiusElementClasses(() => ({\n rounded: props.rounded,\n roundedTop: props.roundedTop,\n roundedBottom: props.roundedBottom,\n roundedStart: props.roundedStart,\n roundedEnd: props.roundedEnd,\n}))\n\nconst computedSrcset = computed(() =>\n typeof props.srcset === 'string'\n ? props.srcset\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.srcset)\n ? props.srcset.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedSizes = computed(() =>\n typeof props.sizes === 'string'\n ? props.sizes\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.sizes)\n ? props.sizes.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedDimensions = computed<{height: number | undefined; width: number | undefined}>(() => {\n const width = Number.isNaN(widthNumber.value) ? undefined : widthNumber.value\n const height = Number.isNaN(heightNumber.value) ? undefined : heightNumber.value\n if (props.blank) {\n if (width !== undefined && height === undefined) return {height: width, width}\n if (width === undefined && height !== undefined) return {height, width: height}\n if (width === undefined && height === undefined) return {height: 1, width: 1}\n }\n return {\n width,\n height,\n }\n})\n\nconst computedBlankImgSrc = computed(() =>\n makeBlankImgSrc(computedDimensions.value.width, computedDimensions.value.height, props.blankColor)\n)\n\nconst computedAlignment = computed(() => ({\n 'float-start': props.placement === 'start',\n 'float-end': props.placement === 'end',\n 'mx-auto': props.placement === 'center',\n}))\n\nconst computedClasses = computed(() => [\n radiusElementClasses.value,\n computedAlignment.value,\n {\n 'img-thumbnail': props.thumbnail,\n 'img-fluid': props.fluid || props.fluidGrow,\n 'w-100': props.fluidGrow,\n 'd-block': props.block || props.placement === 'center',\n },\n])\n\nconst makeBlankImgSrc = (width: number | undefined, height: number | undefined, color: string) =>\n `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`<svg width=\"${width}\" height=\"${height}\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"none\">\n <rect width=\"100%\" height=\"100%\" style=\"fill:${color};\"></rect>\n </svg>`)}`\n</script>\n","<template>\n <component\n :is=\"props.tag\"\n :class=\"computedClasses\"\n class=\"b-img\"\n :src=\"!props.blank ? props.src : computedBlankImgSrc\"\n :width=\"computedDimensions.width || undefined\"\n :height=\"computedDimensions.height || undefined\"\n :srcset=\"!props.blank ? computedSrcset : undefined\"\n :sizes=\"!props.blank ? computedSizes : undefined\"\n :loading=\"props.lazy ? 'lazy' : 'eager'\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BImgProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {useRadiusElementClasses} from '../../composables/useRadiusElementClasses'\nimport {isReadOnlyArray} from '../../utils/object'\n\nconst _props = withDefaults(defineProps<BImgProps>(), {\n blank: false,\n blankColor: 'transparent',\n block: false,\n fluid: false,\n fluidGrow: false,\n height: undefined,\n lazy: false,\n sizes: undefined,\n tag: 'img',\n src: undefined,\n srcset: undefined,\n placement: undefined,\n thumbnail: false,\n width: undefined,\n // RadiusElementExtendables props\n rounded: false,\n roundedBottom: undefined,\n roundedEnd: undefined,\n roundedStart: undefined,\n roundedTop: undefined,\n // End RadiusElementExtendables props\n})\nconst props = useDefaults(_props, 'BImg')\n\nconst heightNumber = useToNumber(() => props.height ?? Number.NaN)\nconst widthNumber = useToNumber(() => props.width ?? Number.NaN)\n\nconst radiusElementClasses = useRadiusElementClasses(() => ({\n rounded: props.rounded,\n roundedTop: props.roundedTop,\n roundedBottom: props.roundedBottom,\n roundedStart: props.roundedStart,\n roundedEnd: props.roundedEnd,\n}))\n\nconst computedSrcset = computed(() =>\n typeof props.srcset === 'string'\n ? props.srcset\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.srcset)\n ? props.srcset.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedSizes = computed(() =>\n typeof props.sizes === 'string'\n ? props.sizes\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.sizes)\n ? props.sizes.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedDimensions = computed<{height: number | undefined; width: number | undefined}>(() => {\n const width = Number.isNaN(widthNumber.value) ? undefined : widthNumber.value\n const height = Number.isNaN(heightNumber.value) ? undefined : heightNumber.value\n if (props.blank) {\n if (width !== undefined && height === undefined) return {height: width, width}\n if (width === undefined && height !== undefined) return {height, width: height}\n if (width === undefined && height === undefined) return {height: 1, width: 1}\n }\n return {\n width,\n height,\n }\n})\n\nconst computedBlankImgSrc = computed(() =>\n makeBlankImgSrc(computedDimensions.value.width, computedDimensions.value.height, props.blankColor)\n)\n\nconst computedAlignment = computed(() => ({\n 'float-start': props.placement === 'start',\n 'float-end': props.placement === 'end',\n 'mx-auto': props.placement === 'center',\n}))\n\nconst computedClasses = computed(() => [\n radiusElementClasses.value,\n computedAlignment.value,\n {\n 'img-thumbnail': props.thumbnail,\n 'img-fluid': props.fluid || props.fluidGrow,\n 'w-100': props.fluidGrow,\n 'd-block': props.block || props.placement === 'center',\n },\n])\n\nconst makeBlankImgSrc = (width: number | undefined, height: number | undefined, color: string) =>\n `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`<svg width=\"${width}\" height=\"${height}\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"none\">\n <rect width=\"100%\" height=\"100%\" style=\"fill:${color};\"></rect>\n </svg>`)}`\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CA,MAAM,QAAQ,YAAY,SAAQ,MAAM;EAExC,MAAM,eAAe,kBAAkB,MAAM,UAAU,GAAU;EACjE,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAU;EAE/D,MAAM,uBAAuB,+BAA+B;GAC1D,SAAS,MAAM;GACf,YAAY,MAAM;GAClB,eAAe,MAAM;GACrB,cAAc,MAAM;GACpB,YAAY,MAAM;EACpB,EAAE;EAEF,MAAM,iBAAiB,eACrB,OAAO,MAAM,WAAW,WACpB,MAAM,OACH,MAAM,GAAG,CAAA,CACT,QAAQ,MAAM,CAAC,CAAA,CACf,KAAK,GAAG,IACX,gBAAgB,MAAM,MAAM,IAC1B,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IACtC,KAAA,CACR;EAEA,MAAM,gBAAgB,eACpB,OAAO,MAAM,UAAU,WACnB,MAAM,MACH,MAAM,GAAG,CAAA,CACT,QAAQ,MAAM,CAAC,CAAA,CACf,KAAK,GAAG,IACX,gBAAgB,MAAM,KAAK,IACzB,MAAM,MAAM,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IACrC,KAAA,CACR;EAEA,MAAM,qBAAqB,eAAwE;GACjG,MAAM,QAAQ,OAAO,MAAM,YAAY,KAAK,IAAI,KAAA,IAAY,YAAY;GACxE,MAAM,SAAS,OAAO,MAAM,aAAa,KAAK,IAAI,KAAA,IAAY,aAAa;GAC3E,IAAI,MAAM,OAAO;IACf,IAAI,UAAU,KAAA,KAAa,WAAW,KAAA,GAAW,OAAO;KAAC,QAAQ;KAAO;IAAK;IAC7E,IAAI,UA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":[],"sources":["../src/components/BImg/BImg.vue","../src/components/BImg/BImg.vue"],"sourcesContent":["<template>\n <component\n :is=\"props.tag\"\n :class=\"computedClasses\"\n class=\"b-img\"\n :src=\"!props.blank ? props.src : computedBlankImgSrc\"\n :width=\"computedDimensions.width || undefined\"\n :height=\"computedDimensions.height || undefined\"\n :srcset=\"!props.blank ? computedSrcset : undefined\"\n :sizes=\"!props.blank ? computedSizes : undefined\"\n :loading=\"props.lazy ? 'lazy' : 'eager'\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BImgProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {useRadiusElementClasses} from '../../composables/useRadiusElementClasses'\nimport {isReadOnlyArray} from '../../utils/object'\n\nconst _props = withDefaults(defineProps<BImgProps>(), {\n blank: false,\n blankColor: 'transparent',\n block: false,\n fluid: false,\n fluidGrow: false,\n height: undefined,\n lazy: false,\n sizes: undefined,\n tag: 'img',\n src: undefined,\n srcset: undefined,\n placement: undefined,\n thumbnail: false,\n width: undefined,\n // RadiusElementExtendables props\n rounded: false,\n roundedBottom: undefined,\n roundedEnd: undefined,\n roundedStart: undefined,\n roundedTop: undefined,\n // End RadiusElementExtendables props\n})\nconst props = useDefaults(_props, 'BImg')\n\nconst heightNumber = useToNumber(() => props.height ?? Number.NaN)\nconst widthNumber = useToNumber(() => props.width ?? Number.NaN)\n\nconst radiusElementClasses = useRadiusElementClasses(() => ({\n rounded: props.rounded,\n roundedTop: props.roundedTop,\n roundedBottom: props.roundedBottom,\n roundedStart: props.roundedStart,\n roundedEnd: props.roundedEnd,\n}))\n\nconst computedSrcset = computed(() =>\n typeof props.srcset === 'string'\n ? props.srcset\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.srcset)\n ? props.srcset.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedSizes = computed(() =>\n typeof props.sizes === 'string'\n ? props.sizes\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.sizes)\n ? props.sizes.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedDimensions = computed<{height: number | undefined; width: number | undefined}>(() => {\n const width = Number.isNaN(widthNumber.value) ? undefined : widthNumber.value\n const height = Number.isNaN(heightNumber.value) ? undefined : heightNumber.value\n if (props.blank) {\n if (width !== undefined && height === undefined) return {height: width, width}\n if (width === undefined && height !== undefined) return {height, width: height}\n if (width === undefined && height === undefined) return {height: 1, width: 1}\n }\n return {\n width,\n height,\n }\n})\n\nconst computedBlankImgSrc = computed(() =>\n makeBlankImgSrc(computedDimensions.value.width, computedDimensions.value.height, props.blankColor)\n)\n\nconst computedAlignment = computed(() => ({\n 'float-start': props.placement === 'start',\n 'float-end': props.placement === 'end',\n 'mx-auto': props.placement === 'center',\n}))\n\nconst computedClasses = computed(() => [\n radiusElementClasses.value,\n computedAlignment.value,\n {\n 'img-thumbnail': props.thumbnail,\n 'img-fluid': props.fluid || props.fluidGrow,\n 'w-100': props.fluidGrow,\n 'd-block': props.block || props.placement === 'center',\n },\n])\n\nconst makeBlankImgSrc = (width: number | undefined, height: number | undefined, color: string) =>\n `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`<svg width=\"${width}\" height=\"${height}\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"none\">\n <rect width=\"100%\" height=\"100%\" style=\"fill:${color};\"></rect>\n </svg>`)}`\n</script>\n","<template>\n <component\n :is=\"props.tag\"\n :class=\"computedClasses\"\n class=\"b-img\"\n :src=\"!props.blank ? props.src : computedBlankImgSrc\"\n :width=\"computedDimensions.width || undefined\"\n :height=\"computedDimensions.height || undefined\"\n :srcset=\"!props.blank ? computedSrcset : undefined\"\n :sizes=\"!props.blank ? computedSizes : undefined\"\n :loading=\"props.lazy ? 'lazy' : 'eager'\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport type {BImgProps} from '../../types'\nimport {useDefaults} from '../../composables/useDefaults'\nimport {computed} from 'vue'\nimport {useToNumber} from '@vueuse/core'\nimport {useRadiusElementClasses} from '../../composables/useRadiusElementClasses'\nimport {isReadOnlyArray} from '../../utils/object'\n\nconst _props = withDefaults(defineProps<BImgProps>(), {\n blank: false,\n blankColor: 'transparent',\n block: false,\n fluid: false,\n fluidGrow: false,\n height: undefined,\n lazy: false,\n sizes: undefined,\n tag: 'img',\n src: undefined,\n srcset: undefined,\n placement: undefined,\n thumbnail: false,\n width: undefined,\n // RadiusElementExtendables props\n rounded: false,\n roundedBottom: undefined,\n roundedEnd: undefined,\n roundedStart: undefined,\n roundedTop: undefined,\n // End RadiusElementExtendables props\n})\nconst props = useDefaults(_props, 'BImg')\n\nconst heightNumber = useToNumber(() => props.height ?? Number.NaN)\nconst widthNumber = useToNumber(() => props.width ?? Number.NaN)\n\nconst radiusElementClasses = useRadiusElementClasses(() => ({\n rounded: props.rounded,\n roundedTop: props.roundedTop,\n roundedBottom: props.roundedBottom,\n roundedStart: props.roundedStart,\n roundedEnd: props.roundedEnd,\n}))\n\nconst computedSrcset = computed(() =>\n typeof props.srcset === 'string'\n ? props.srcset\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.srcset)\n ? props.srcset.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedSizes = computed(() =>\n typeof props.sizes === 'string'\n ? props.sizes\n .split(',')\n .filter((x) => x)\n .join(',')\n : isReadOnlyArray(props.sizes)\n ? props.sizes.filter((x) => x).join(',')\n : undefined\n)\n\nconst computedDimensions = computed<{height: number | undefined; width: number | undefined}>(() => {\n const width = Number.isNaN(widthNumber.value) ? undefined : widthNumber.value\n const height = Number.isNaN(heightNumber.value) ? undefined : heightNumber.value\n if (props.blank) {\n if (width !== undefined && height === undefined) return {height: width, width}\n if (width === undefined && height !== undefined) return {height, width: height}\n if (width === undefined && height === undefined) return {height: 1, width: 1}\n }\n return {\n width,\n height,\n }\n})\n\nconst computedBlankImgSrc = computed(() =>\n makeBlankImgSrc(computedDimensions.value.width, computedDimensions.value.height, props.blankColor)\n)\n\nconst computedAlignment = computed(() => ({\n 'float-start': props.placement === 'start',\n 'float-end': props.placement === 'end',\n 'mx-auto': props.placement === 'center',\n}))\n\nconst computedClasses = computed(() => [\n radiusElementClasses.value,\n computedAlignment.value,\n {\n 'img-thumbnail': props.thumbnail,\n 'img-fluid': props.fluid || props.fluidGrow,\n 'w-100': props.fluidGrow,\n 'd-block': props.block || props.placement === 'center',\n },\n])\n\nconst makeBlankImgSrc = (width: number | undefined, height: number | undefined, color: string) =>\n `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`<svg width=\"${width}\" height=\"${height}\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"none\">\n <rect width=\"100%\" height=\"100%\" style=\"fill:${color};\"></rect>\n </svg>`)}`\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CA,MAAM,QAAQ,YAAY,SAAQ,MAAM;EAExC,MAAM,eAAe,kBAAkB,MAAM,UAAU,GAAU;EACjE,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAU;EAE/D,MAAM,uBAAuB,+BAA+B;GAC1D,SAAS,MAAM;GACf,YAAY,MAAM;GAClB,eAAe,MAAM;GACrB,cAAc,MAAM;GACpB,YAAY,MAAM;EACpB,EAAE;EAEF,MAAM,iBAAiB,eACrB,OAAO,MAAM,WAAW,WACpB,MAAM,OACH,MAAM,GAAG,CAAA,CACT,QAAQ,MAAM,CAAC,CAAA,CACf,KAAK,GAAG,IACX,gBAAgB,MAAM,MAAM,IAC1B,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IACtC,KAAA,CACR;EAEA,MAAM,gBAAgB,eACpB,OAAO,MAAM,UAAU,WACnB,MAAM,MACH,MAAM,GAAG,CAAA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