2020-10-07 14:49:01 +00:00
|
|
|
import { cloneVNode, FunctionalComponent, PropType } from 'vue';
|
2020-10-01 09:20:10 +00:00
|
|
|
|
|
|
|
export interface ItemProps {
|
|
|
|
setRef: (element: HTMLElement) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Item: FunctionalComponent<ItemProps> = ({ setRef }, { slots }) => {
|
|
|
|
const children = slots.default?.();
|
|
|
|
|
|
|
|
return children && children.length
|
|
|
|
? cloneVNode(children[0], {
|
2020-10-17 04:14:13 +00:00
|
|
|
ref: setRef as any,
|
2020-10-01 09:20:10 +00:00
|
|
|
})
|
|
|
|
: children;
|
|
|
|
};
|
2020-10-07 14:49:01 +00:00
|
|
|
Item.props = {
|
|
|
|
setRef: {
|
|
|
|
type: Function as PropType<(element: HTMLElement) => void>,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
};
|
2020-10-17 04:14:13 +00:00
|
|
|
|
2020-10-01 09:20:10 +00:00
|
|
|
export default Item;
|