-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathindex.tsx
More file actions
32 lines (30 loc) · 1.19 KB
/
index.tsx
File metadata and controls
32 lines (30 loc) · 1.19 KB
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
import { defineComponent, toRefs, withModifiers } from 'vue';
import { flexibleOverlayProps, FlexibleOverlayProps } from './flexible-overlay-types';
import { useOverlay } from './use-flexible-overlay';
import { useNamespace } from '@devui/shared/utils';
import './flexible-overlay.scss';
export const FlexibleOverlay = defineComponent({
name: 'DFlexibleOverlay',
inheritAttrs: false,
props: flexibleOverlayProps,
emits: ['update:modelValue', 'positionChange'],
setup(props: FlexibleOverlayProps, { slots, attrs, emit, expose }) {
const ns = useNamespace('flexible-overlay');
const { clickEventBubble } = toRefs(props);
const { arrowRef, overlayRef, styles,showOverlay, updatePosition } = useOverlay(props, emit);
expose({ updatePosition });
return () =>
showOverlay.value && (
<div
ref={overlayRef}
class={ns.b()}
style={styles.value}
{...attrs}
onClick={withModifiers(() => ({}), [clickEventBubble.value ? '' : 'stop'])}
onPointerup={withModifiers(() => ({}), ['stop'])}>
{slots.default?.()}
{props.showArrow && <div ref={arrowRef} class={ns.e('arrow')}></div>}
</div>
);
},
});