diff --git a/package/component/src/component/popper/index.vue b/package/component/src/component/popper/index.vue index c94e08fe..c4fa522d 100644 --- a/package/component/src/component/popper/index.vue +++ b/package/component/src/component/popper/index.vue @@ -36,8 +36,14 @@ import { computed, toRef, StyleValue, + Ref, } from "vue"; -import { onClickOutside, useEventListener, useThrottleFn } from "@vueuse/core"; +import { + onClickOutside, + useEventListener, + useResizeObserver, + useThrottleFn, +} from "@vueuse/core"; export type PopperTrigger = "click" | "hover" | "focus" | "contextMenu"; @@ -209,18 +215,35 @@ onClickOutside( } ); +useResizeObserver(triggerRefEl, () => { + updatePosistion(); +}); + +let popperObserver: { stop: any; isSupported?: Ref } | undefined = + undefined; + +watch(innerVisible, (isShow) => { + updatePosistion(); + if (isShow) { + popperObserver = useResizeObserver(popperRefEl, () => { + updatePosistion(); + }); + } else { + popperObserver && popperObserver.stop(); + } +}); + watch( () => props.visible, (isShow) => (isShow ? doShow() : doHidden()) ); -watch(innerVisible, (val) => { - updatePosistion(); -}); - -watch([() => props.content, () => slots.content && slots?.content()], (val) => { - innerVisible.value && updatePosistion(); -}); +watch( + () => props.content, + () => { + updatePosistion(); + } +); const isScrollElement = function (element: HTMLElement) { return ( diff --git a/package/component/src/component/tagInput/Tag.vue b/package/component/src/component/tagInput/Tag.vue deleted file mode 100644 index 5ab4b9fc..00000000 --- a/package/component/src/component/tagInput/Tag.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - - - diff --git a/package/component/src/component/tagInput/index.less b/package/component/src/component/tagInput/index.less index d37fc198..cb5002dc 100644 --- a/package/component/src/component/tagInput/index.less +++ b/package/component/src/component/tagInput/index.less @@ -1,65 +1,138 @@ -.layui-input-tag { - position: relative; - display: block; +@import "../tag/index.less"; +@import "../popper/index.less"; +@import "../tooltip/index.less"; + +@tag-input-lg: 44px; +@tag-input-md: 38px; +@tag-input-sm: 32px; +@tag-input-xs: 26px; +@tag-input-boeder: 1px; +@tag-input-inner-padding-lg: 2px; +@tag-input-inner-padding-md: 2px; +@tag-input-inner-padding-sm: 1px; +@tag-input-inner-padding-xs: 1px; +@tag-margin-top-lg: 2px; +@tag-margin-top-md: 2px; +@tag-margin-top-sm: 1px; +@tag-margin-top-xs: 1px; +@tag-margin-bottom-lg: 2px; +@tag-margin-bottom-md: 2px; +@tag-margin-bottom-sm: 1px; +@tag-margin-bottom-xs: 1px; + +.layui-tag-input { + display: inline-flex; + box-sizing: border-box; + width: auto; + border-width: @tag-input-boeder; + border-style: solid; + border-color: var(--input-border-color); + border-radius: var(--input-border-radius); padding: 0 5px; - height: auto; - overflow: hidden; + cursor: text; - .layui-input-prefix { - display: inline; - text-align: left; - height: 100%; - flex: unset; - } - - .layui-input-suffix{ - position: absolute; - right: 3px; - bottom: 0; - height: 100%; - } - - .layui-input { - display: inline-block; - padding-left: 0; - width: auto; + &-inner { flex: 1; - max-width: 100%; - min-width: 12px; + overflow: hidden; + line-height: 0; + padding: @tag-input-inner-padding-md 0; } -} -.layui-input-tag-collapsed-panel, -.layui-input-tag { - .layui-badge { - margin-right: 5px; - height: 28px; - line-height: 28px; - user-select: none; - white-space: pre-wrap; + &-mirror { + position: absolute; + top: 0; + left: 0; + white-space: pre; + visibility: hidden; + pointer-events: none; + } - .layui-icon { - font-size: 12px; - padding-left: 3px; + &-clear { + display: none; + align-items: center; + cursor: pointer; + } - &:hover { - cursor: pointer; - color: #ff5722; - } + &-clear:hover { + opacity: 0.5; + } + + & &-inner-input { + box-sizing: border-box; + border: none; + } + + &-disabled { + cursor: not-allowed; + opacity: 0.4; + + .layui-tag-input-clear { + cursor: not-allowed; + opacity: 0.4; } } + + .layui-tag { + margin-right: 5px; + margin-top: 2px; + margin-bottom: 2px; + white-space: pre-wrap; + } + + &-collapsed-panel { + white-space: normal; + display: flex; + align-items: center; + flex-wrap: wrap; + width: fit-content; + max-width: 240px; + height: auto; + overflow: hidden; + + .layui-tag { + margin-right: 5px; + margin-bottom: 4px; + } + } + + + + .set-size(@size) { + @height: ~'tag-input-@{size}'; + @tag-margin-top: ~'tag-margin-top-@{size}'; + @tag-margin-bottom: ~'tag-margin-bottom-@{size}'; + @inner-padding: ~'tag-input-inner-padding-@{size}'; + + &.layui-tag-input-@{size} { + min-height: @@height; + + .layui-tag-input-inner-input { + height: @@height - (@@inner-padding + @tag-input-boeder)* 2; + vertical-align: middle; + } + + .layui-tag-input-inner { + padding: @@inner-padding 0; + } + + .layui-tag { + margin-top: @@tag-margin-top; + margin-bottom: @@tag-margin-bottom; + } + + } + } + + .set-size(lg); + .set-size(md); + .set-size(sm); + .set-size(xs); } -.layui-input-tag-collapsed-panel { - white-space: normal; - display: flex; - align-items: center; - flex-wrap: wrap; - width: fit-content; - max-width: 200px; - height: auto; - overflow: hidden; - .layui-badge{ - margin-bottom: 4px; +.layui-tag-input:hover, +.layui-tag-input:focus-within { + border-color: #d2d2d2 !important; + .layui-tag-input-clear{ + display: flex; } } \ No newline at end of file diff --git a/package/component/src/component/tagInput/index.vue b/package/component/src/component/tagInput/index.vue index 371faee4..2107d0d7 100644 --- a/package/component/src/component/tagInput/index.vue +++ b/package/component/src/component/tagInput/index.vue @@ -5,9 +5,18 @@ export default { diff --git a/package/component/src/component/tooltip/index.vue b/package/component/src/component/tooltip/index.vue index 1d4608cc..e60b996c 100644 --- a/package/component/src/component/tooltip/index.vue +++ b/package/component/src/component/tooltip/index.vue @@ -62,7 +62,7 @@ const props = defineProps({ type: [String, Array, Object], }, popperStyle: { - type: Object as PropType, + type: [String, Object] as PropType, }, }); const vm = getCurrentInstance()!;