From 511b464a107fd67a572a40a40135855bbe60b9ea Mon Sep 17 00:00:00 2001 From: zcating Date: Mon, 29 Nov 2021 16:36:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(overlay):=20API=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=EF=BC=9A=20backdropClick=20=3D>=20onBackdropClick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/overlay/src/fixed-overlay.tsx | 5 +++-- .../devui-vue/devui/overlay/src/flexible-overlay.tsx | 4 ++-- packages/devui-vue/devui/overlay/src/overlay-types.ts | 9 ++++++--- packages/devui-vue/devui/overlay/src/utils.ts | 3 +-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/devui-vue/devui/overlay/src/fixed-overlay.tsx b/packages/devui-vue/devui/overlay/src/fixed-overlay.tsx index c4ccfa03..6d8f57c1 100644 --- a/packages/devui-vue/devui/overlay/src/fixed-overlay.tsx +++ b/packages/devui-vue/devui/overlay/src/fixed-overlay.tsx @@ -1,12 +1,13 @@ -import { defineComponent, ref, renderSlot, CSSProperties, PropType } from 'vue'; +import { defineComponent, renderSlot } from 'vue'; import { CommonOverlay } from './common-overlay'; -import { fixedOverlayProps, FixedOverlayProps } from './overlay-types'; +import { fixedOverlayProps, FixedOverlayProps, overlayEmits } from './overlay-types'; import { useOverlayLogic } from './utils'; import './overlay.scss'; export const FixedOverlay = defineComponent({ name: 'DFixedOverlay', props: fixedOverlayProps, + emits: overlayEmits, setup(props: FixedOverlayProps, ctx) { const { backgroundClass, diff --git a/packages/devui-vue/devui/overlay/src/flexible-overlay.tsx b/packages/devui-vue/devui/overlay/src/flexible-overlay.tsx index 42556b58..18320b2f 100644 --- a/packages/devui-vue/devui/overlay/src/flexible-overlay.tsx +++ b/packages/devui-vue/devui/overlay/src/flexible-overlay.tsx @@ -13,7 +13,7 @@ import { watch, } from 'vue'; import { CommonOverlay } from './common-overlay'; -import { OriginOrDomRef, flexibleOverlayProps, FlexibleOverlayProps, Point, Origin, ConnectionPosition } from './overlay-types'; +import { OriginOrDomRef, flexibleOverlayProps, FlexibleOverlayProps, Point, Origin, ConnectionPosition, overlayEmits } from './overlay-types'; import { useOverlayLogic } from './utils'; import { getElement, isComponent } from '../../shared/util/dom'; @@ -24,7 +24,7 @@ import { getElement, isComponent } from '../../shared/util/dom'; export const FlexibleOverlay = defineComponent({ name: 'DFlexibleOverlay', props: flexibleOverlayProps, - emits: ['onUpdate:visible'], + emits: overlayEmits, setup(props: FlexibleOverlayProps, ctx) { // lift cycle const overlayRef = ref(null); diff --git a/packages/devui-vue/devui/overlay/src/overlay-types.ts b/packages/devui-vue/devui/overlay/src/overlay-types.ts index f90ccfb7..23f933eb 100644 --- a/packages/devui-vue/devui/overlay/src/overlay-types.ts +++ b/packages/devui-vue/devui/overlay/src/overlay-types.ts @@ -18,7 +18,7 @@ export const overlayProps = { backgroundStyle: { type: [String, Object] as PropType }, - backdropClick: { + onBackdropClick: { type: Function, }, backdropClose: { @@ -31,6 +31,7 @@ export const overlayProps = { }, } as const; +export const overlayEmits = ['onUpdate:visible', 'backdropClick'] as ['onUpdate:visible', 'backdropClick']; export type OverlayProps = ExtractPropTypes; @@ -41,9 +42,9 @@ export const fixedOverlayProps = { default: undefined, }, }; - export type FixedOverlayProps = ExtractPropTypes; + export const flexibleOverlayProps = { origin: { type: Object as PropType, @@ -51,7 +52,7 @@ export const flexibleOverlayProps = { }, position: { type: Object as PropType, - default: () => ({ + default: (): ConnectionPosition => ({ originX: 'left', originY: 'top', overlayX: 'left', @@ -62,6 +63,8 @@ export const flexibleOverlayProps = { } + + export interface ClientRect { bottom: number readonly height: number diff --git a/packages/devui-vue/devui/overlay/src/utils.ts b/packages/devui-vue/devui/overlay/src/utils.ts index 4f115130..cd7f89c1 100644 --- a/packages/devui-vue/devui/overlay/src/utils.ts +++ b/packages/devui-vue/devui/overlay/src/utils.ts @@ -22,8 +22,7 @@ export function useOverlayLogic(props: OverlayProps): CommonInfo { const handleBackdropClick = (event: Event) => { event.preventDefault(); - - props.backdropClick?.(); + props.onBackdropClick?.(); if (props.backdropClose) { props['onUpdate:visible']?.(false); } -- Gitee From 5ab7fd90ae516eb178121770e072e3632daf4caa Mon Sep 17 00:00:00 2001 From: zcating Date: Mon, 29 Nov 2021 16:37:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(overlay-doc):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/components/overlay/index.md | 97 +++++++++++++------ 1 file changed, 67 insertions(+), 30 deletions(-) diff --git a/packages/devui-vue/docs/components/overlay/index.md b/packages/devui-vue/docs/components/overlay/index.md index 7d604b35..3b57bcc3 100644 --- a/packages/devui-vue/docs/components/overlay/index.md +++ b/packages/devui-vue/docs/components/overlay/index.md @@ -14,7 +14,12 @@ backgroundClass="justify-center items-center bg-gray-50" backgroundBlock > -
hello world
+
+ hello world +