-
Notifications
You must be signed in to change notification settings - Fork 138
/
Item.tsx
34 lines (29 loc) 路 995 Bytes
/
Item.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/
import { defineComponent, onUnmounted, ref } from 'vue'
import { useResizeObserver } from '@idux/cdk/resize'
import { callEmit } from '@idux/cdk/utils'
import { overflowItemProps } from './types'
export default defineComponent({
name: 'IxOverflowItem',
props: overflowItemProps,
setup(props, { slots }) {
const itemElRef = ref<HTMLElement | undefined>()
const handleResize = (entry: ResizeObserverEntry) => callEmit(props.onSizeChange, entry, props.itemKey ?? '')
useResizeObserver(itemElRef, handleResize)
onUnmounted(() => {
callEmit(props.onSizeChange, undefined, props.itemKey ?? '')
})
return () => {
return (
<div v-show={props.display} class={`${props.prefixCls}-item`} ref={itemElRef}>
{slots.default?.()}
</div>
)
}
},
})