chore(dynamic-tags, image): clean codes

This commit is contained in:
07akioni 2021-08-26 01:00:39 +08:00
parent 51633e5fe6
commit ede52ec472
6 changed files with 15 additions and 11 deletions

View File

@ -11,7 +11,9 @@ form
slot
```
## Props
## API
### DynamicTags Props
| Name | Type | Default | Description |
| --- | --- | --- | --- |
@ -28,7 +30,7 @@ slot
| value | `string[]` | `undefined` | Value in controlled mode. |
| on-update:value | `(value: boolean) => void` | `undefined` | Callback when the component's value changes. |
## Slots
### DynamicTags Slots
| Name | Parameters | Description |
| --- | --- | --- |

View File

@ -1,4 +1,4 @@
# Slot
# Customizing Input or Trigger Element
You can replace dynamic-tags's input or trigger element.

View File

@ -11,7 +11,9 @@ form
slot
```
## Props
## API
### DynamicTags Props
| 名称 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
@ -28,9 +30,9 @@ slot
| value | `string[]` | `undefined` | 受控模式下的值 |
| on-update:value | `(value: boolean) => void` | `undefined` | 组件值发生变化时的回调 |
## Slots
### DynamicTags Slots
| Name | Parameters | Description |
| 名称 | 参数 | 说明 |
| --- | --- | --- |
| input | `(info: { submit: (value: any) => void, })` | 自定义输入元素,由用户填充 |
| trigger | `(info: { activate: () => void, disabled: boolean })` | 触发输入标签的组件或元素 |

View File

@ -1,4 +1,4 @@
# 插槽
# 自定义输入或触发元素
你可以替换 `dynamic-tags` 的输入或触发元素。

View File

@ -8,6 +8,7 @@ import {
nextTick,
toRef
} from 'vue'
import { useMergedState } from 'vooks'
import commonProps from '../../tag/src/common-props'
import { AddIcon } from '../../_internal/icons'
import { NButton } from '../../button'
@ -22,9 +23,7 @@ import type { MaybeArray, ExtractPublicPropTypes } from '../../_utils'
import { dynamicTagsLight } from '../styles'
import type { DynamicTagsTheme } from '../styles'
import style from './styles/index.cssr'
import type { OnUpdateValue } from './interface'
import { useMergedState } from 'vooks'
const dynamicTagsProps = {
...(useTheme.props as ThemeProps<DynamicTagsTheme>),

View File

@ -61,15 +61,16 @@ export default defineComponent({
imageRef,
imgProps: imgPropsRef,
handleClick: () => {
const mergedPreviewSrc = props.previewSrc || props.src
if (imageGroupHandle) {
imageGroupHandle.setPreviewSrc(props.previewSrc || props.src)
imageGroupHandle.setPreviewSrc(mergedPreviewSrc)
imageGroupHandle.setThumbnailEl(imageRef.value)
imageGroupHandle.toggleShow()
return
}
const { value: previewInst } = previewInstRef
if (!previewInst) return
previewInst.setPreviewSrc(props.previewSrc || props.src)
previewInst.setPreviewSrc(mergedPreviewSrc)
previewInst.setThumbnailEl(imageRef.value)
previewInst.toggleShow()
}