🐛 修复 icon-picker 选择图标自动隐藏内容

This commit is contained in:
就眠儀式 2021-12-17 00:07:15 +08:00
parent 43e4ab7ade
commit 7873134d81
3 changed files with 60 additions and 49 deletions

View File

@ -22,6 +22,7 @@
<li>[新增] layer 组件 resize 属性, 开启弹层尺寸拉伸, 常用于 页面层 与 Iframe 层。</li>
<li>[加强] layer 组件 area 属性, 支持 字符串 与 数组 类型, 默认 auto 宽高根据内容自适应。</li>
<li>[修复] layer 组件 body 禁用拖动, 仅支持标题拖动窗体。</li>
<li>[修复] dropdown 组件触发方式为 hover 时,移动不到菜单子项的问题</li>
<li>[集成] utteranc.es 插件, 基于 issues 提供为文档提供留言能力。</li>
<li>[升级] layer-vue 1.2.0, 更稳定的 layer 版本。</li>
<li>[升级] vue 3.2.26 版本。</li>

View File

@ -1,3 +1,49 @@
<script lang="ts">
export default {
name: "LayDropdown"
}
</script>
<script setup lang="ts">
import { defineProps, provide, ref, watch } from 'vue'
import { useClickOutside } from '@layui/hooks-vue'
const dropdownRef = ref<null | HTMLElement>(null)
const isClickOutside = useClickOutside(dropdownRef)
export interface LayDropdownProps {
trigger?: string
}
const props = withDefaults(defineProps<LayDropdownProps>(),{
trigger: 'click',
})
const openState = ref(false)
const open = function () {
openState.value = true
}
const hide = function () {
openState.value = false
}
const toggle = function () {
openState.value = !openState.value
}
watch(isClickOutside, () => {
if (isClickOutside.value) {
openState.value = false
}
})
provide('openState', openState)
defineExpose({ open, hide, toggle });
</script>
<template>
<div
v-if="trigger === 'click'"
@ -30,43 +76,4 @@
</ul>
</dl>
</div>
</template>
<script setup name="LaySelect" lang="ts">
import { defineProps, provide, ref, watch } from 'vue'
import { useClickOutside } from '@layui/hooks-vue'
const dropdownRef = ref<null | HTMLElement>(null)
const isClickOutside = useClickOutside(dropdownRef)
const props = withDefaults(
defineProps<{
trigger?: string
}>(),
{
trigger: 'click',
}
)
const openState = ref(false)
const open = function () {
openState.value = true
}
const hide = function () {
openState.value = false
}
const toggle = function () {
openState.value = !openState.value
}
watch(isClickOutside, () => {
if (isClickOutside.value) {
openState.value = false
}
})
provide('openState', openState)
</script>
</template>

View File

@ -1,5 +1,5 @@
<template>
<lay-dropdown>
<lay-dropdown ref="dropdownRef">
<div
class="
layui-inline layui-border-box layui-iconpicker layui-iconpicker-split
@ -85,17 +85,18 @@
import { defineProps, Ref, ref } from 'vue'
import { LayIconList as icons } from "@layui/icons-vue"
const props = withDefaults(
defineProps<{
modelValue?: string
page?: boolean
export interface LayIconPickerProps {
page?: boolean,
modelValue?: string,
showSearch?: boolean
}>(),
{
}
const props = withDefaults(defineProps<LayIconPickerProps>(),{
modelValue: 'layui-icon-face-smile',
page: false,
}
)
})
const dropdownRef = ref<null | HTMLElement>(null);
const emit = defineEmits(['update:modelValue'])
@ -104,6 +105,8 @@ const selectedIcon: Ref<string> = ref(props.modelValue as string)
const selectIcon = function (icon: string) {
emit('update:modelValue', icon)
selectedIcon.value = icon
// @ts-ignore
dropdownRef.value.hide()
}
const icones: Ref = ref([])