VInput.mjs.map 10 KB

1
  1. {"version":3,"file":"VInput.mjs","names":["useInputIcon","VMessages","makeComponentProps","makeDensityProps","useDensity","IconValue","useRtl","makeValidationProps","useValidation","computed","EventProp","genericComponent","getUid","propsFactory","useRender","makeVInputProps","id","String","appendIcon","centerAffix","type","Boolean","default","prependIcon","hideDetails","hint","persistentHint","messages","Array","direction","validator","v","includes","VInput","name","props","emits","val","setup","_ref","attrs","slots","emit","densityClasses","rtlClasses","InputIcon","uid","messagesId","value","errorMessages","isDirty","isDisabled","isReadonly","isPristine","isValid","isValidating","reset","resetValidation","validate","validationClasses","slotProps","length","focused","hasPrepend","prepend","hasAppend","append","hasMessages","hasDetails","details","_createVNode","class","style","message"],"sources":["../../../src/components/VInput/VInput.tsx"],"sourcesContent":["// Styles\nimport './VInput.sass'\n\n// Components\nimport { useInputIcon } from '@/components/VInput/InputIcon'\nimport { VMessages } from '@/components/VMessages/VMessages'\n\n// Composables\nimport { makeComponentProps } from '@/composables/component'\nimport { makeDensityProps, useDensity } from '@/composables/density'\nimport { IconValue } from '@/composables/icons'\nimport { useRtl } from '@/composables/locale'\nimport { makeValidationProps, useValidation } from '@/composables/validation'\n\n// Utilities\nimport { computed } from 'vue'\nimport { EventProp, genericComponent, getUid, propsFactory, useRender } from '@/util'\n\n// Types\nimport type { ComputedRef, PropType, Ref } from 'vue'\nimport type { VMessageSlot } from '@/components/VMessages/VMessages'\n\nexport interface VInputSlot {\n id: ComputedRef<string>\n messagesId: ComputedRef<string>\n isDirty: ComputedRef<boolean>\n isDisabled: ComputedRef<boolean>\n isReadonly: ComputedRef<boolean>\n isPristine: Ref<boolean>\n isValid: ComputedRef<boolean | null>\n isValidating: Ref<boolean>\n reset: () => void\n resetValidation: () => void\n validate: () => void\n}\n\nexport const makeVInputProps = propsFactory({\n id: String,\n appendIcon: IconValue,\n centerAffix: {\n type: Boolean,\n default: true,\n },\n prependIcon: IconValue,\n hideDetails: [Boolean, String] as PropType<boolean | 'auto'>,\n hint: String,\n persistentHint: Boolean,\n messages: {\n type: [Array, String] as PropType<string | readonly string[]>,\n default: () => ([]),\n },\n direction: {\n type: String as PropType<'horizontal' | 'vertical'>,\n default: 'horizontal',\n validator: (v: any) => ['horizontal', 'vertical'].includes(v),\n },\n\n 'onClick:prepend': EventProp<[MouseEvent]>(),\n 'onClick:append': EventProp<[MouseEvent]>(),\n\n ...makeComponentProps(),\n ...makeDensityProps(),\n ...makeValidationProps(),\n}, 'VInput')\n\nexport type VInputSlots = {\n default: VInputSlot\n prepend: VInputSlot\n append: VInputSlot\n details: VInputSlot\n message: VMessageSlot\n}\n\nexport const VInput = genericComponent<VInputSlots>()({\n name: 'VInput',\n\n props: {\n ...makeVInputProps(),\n },\n\n emits: {\n 'update:modelValue': (val: any) => true,\n },\n\n setup (props, { attrs, slots, emit }) {\n const { densityClasses } = useDensity(props)\n const { rtlClasses } = useRtl()\n const { InputIcon } = useInputIcon(props)\n\n const uid = getUid()\n const id = computed(() => props.id || `input-${uid}`)\n const messagesId = computed(() => `${id.value}-messages`)\n\n const {\n errorMessages,\n isDirty,\n isDisabled,\n isReadonly,\n isPristine,\n isValid,\n isValidating,\n reset,\n resetValidation,\n validate,\n validationClasses,\n } = useValidation(props, 'v-input', id)\n\n const slotProps = computed<VInputSlot>(() => ({\n id,\n messagesId,\n isDirty,\n isDisabled,\n isReadonly,\n isPristine,\n isValid,\n isValidating,\n reset,\n resetValidation,\n validate,\n }))\n\n const messages = computed(() => {\n if (props.errorMessages?.length || (!isPristine.value && errorMessages.value.length)) {\n return errorMessages.value\n } else if (props.hint && (props.persistentHint || props.focused)) {\n return props.hint\n } else {\n return props.messages\n }\n })\n\n useRender(() => {\n const hasPrepend = !!(slots.prepend || props.prependIcon)\n const hasAppend = !!(slots.append || props.appendIcon)\n const hasMessages = messages.value.length > 0\n const hasDetails = !props.hideDetails || (\n props.hideDetails === 'auto' &&\n (hasMessages || !!slots.details)\n )\n\n return (\n <div\n class={[\n 'v-input',\n `v-input--${props.direction}`,\n {\n 'v-input--center-affix': props.centerAffix,\n },\n densityClasses.value,\n rtlClasses.value,\n validationClasses.value,\n props.class,\n ]}\n style={ props.style }\n >\n { hasPrepend && (\n <div key=\"prepend\" class=\"v-input__prepend\">\n { slots.prepend?.(slotProps.value) }\n\n { props.prependIcon && (\n <InputIcon\n key=\"prepend-icon\"\n name=\"prepend\"\n />\n )}\n </div>\n )}\n\n { slots.default && (\n <div class=\"v-input__control\">\n { slots.default?.(slotProps.value) }\n </div>\n )}\n\n { hasAppend && (\n <div key=\"append\" class=\"v-input__append\">\n { props.appendIcon && (\n <InputIcon\n key=\"append-icon\"\n name=\"append\"\n />\n )}\n\n { slots.append?.(slotProps.value) }\n </div>\n )}\n\n { hasDetails && (\n <div class=\"v-input__details\">\n <VMessages\n id={ messagesId.value }\n active={ hasMessages }\n messages={ messages.value }\n v-slots={{ message: slots.message }}\n />\n\n { slots.details?.(slotProps.value) }\n </div>\n )}\n </div>\n )\n })\n\n return {\n reset,\n resetValidation,\n validate,\n }\n },\n})\n\nexport type VInput = InstanceType<typeof VInput>\n"],"mappings":";AAAA;AACA;;AAEA;AAAA,SACSA,YAAY;AAAA,SACZC,SAAS,sCAElB;AAAA,SACSC,kBAAkB;AAAA,SAClBC,gBAAgB,EAAEC,UAAU;AAAA,SAC5BC,SAAS;AAAA,SACTC,MAAM;AAAA,SACNC,mBAAmB,EAAEC,aAAa,4CAE3C;AACA,SAASC,QAAQ,QAAQ,KAAK;AAAA,SACrBC,SAAS,EAAEC,gBAAgB,EAAEC,MAAM,EAAEC,YAAY,EAAEC,SAAS,gCAErE;AAkBA,OAAO,MAAMC,eAAe,GAAGF,YAAY,CAAC;EAC1CG,EAAE,EAAEC,MAAM;EACVC,UAAU,EAAEb,SAAS;EACrBc,WAAW,EAAE;IACXC,IAAI,EAAEC,OAAO;IACbC,OAAO,EAAE;EACX,CAAC;EACDC,WAAW,EAAElB,SAAS;EACtBmB,WAAW,EAAE,CAACH,OAAO,EAAEJ,MAAM,CAA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