123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <template>
- <div class="ui-input">
- <template v-if="type">
- <component :is="InputComponents[type].component" v-bind="childProps" :modelValue="props.modelValue" @update:model-value="newValue => emit('update:modelValue', newValue)">
- <template v-for="(slot, name) in $slots" #[name]="raw">
- <slot :name="name" v-bind="raw"></slot>
- </template>
- </component>
- <slot></slot>
- <!-- <p class="error-msg" v-if="error">{{ error }}</p> -->
- </template>
- </div>
- </template>
- <script setup lang="ts">
- import { computed } from 'vue'
- import { inputProps, InputComponents } from './input'
- const props = defineProps(inputProps)
- console.log('props', props)
- // const emit = defineEmits(['update:modelValue'])
- // const type = computed(() => (types[props.type] ? props.type : 'text'))
- const childProps = computed(() => {
- if (props.type) {
- console.log('props--type', InputComponents[props.type])
- return InputComponents[props.type].props
- }
- // const retain = Object.keys(types[type.value].propsDesc)
- // const childProps = {}
- // for (let key in props) {
- // if (retain.includes(key)) {
- // childProps[key] = props[key]
- // }
- // }
- // if (!types[props.type]) {
- // childProps.type = props.type
- // }
- // return childProps
- return false
- })
- // const style = computed(() => {
- // const style = {}
- // const keys = Object.keys(childProps.value)
- // if (!keys.includes('width')) {
- // style.width = props.width
- // }
- // if (!keys.includes('height')) {
- // style.height = props.height
- // }
- // return style
- // })
- </script>
|