|
@@ -1,7 +1,7 @@
|
|
|
<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)">
|
|
|
+ <component :is="InputComponents[type].component" v-bind="$attrs" :modelValue="props.modelValue" @update:model-value="handleUpdate">
|
|
|
<template v-for="(slot, name) in $slots" #[name]="raw">
|
|
|
<slot :name="name" v-bind="raw"></slot>
|
|
|
</template>
|
|
@@ -14,32 +14,35 @@
|
|
|
</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 emit = defineEmits(['update:modelValue'])
|
|
|
+const handleUpdate = (newValue: string) => {
|
|
|
+ emit('update:modelValue', newValue)
|
|
|
+}
|
|
|
// 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 childProps = computed(() => {
|
|
|
+// if (props.type) {
|
|
|
+// const retain = InputComponents[props.type].props
|
|
|
+// console.log('retain', retain)
|
|
|
+// const cProps = {}
|
|
|
+// if (retain) {
|
|
|
+// for (let key in props) {
|
|
|
+// console.log('key', key)
|
|
|
+// if (Object.keys(retain).includes(key)) {
|
|
|
+// cProps[key] = props[key]
|
|
|
+// }
|
|
|
+// }
|
|
|
+// console.log('cProps', cProps)
|
|
|
+// }
|
|
|
|
|
|
+// return childProps
|
|
|
+// }
|
|
|
+// return false
|
|
|
+// })
|
|
|
+
|
|
|
+// console.log('childProps', childProps)
|
|
|
// const style = computed(() => {
|
|
|
// const style = {}
|
|
|
// const keys = Object.keys(childProps.value)
|