mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(react,vue): backdrop for inline modal/popover overlay (#24453)
Resolves #24449
This commit is contained in:
@ -46,7 +46,9 @@ function generateOverlays() {
|
||||
const docsBlock = getDocsBlock(component.tag);
|
||||
const props = getPropsFromDocsBlock(docsBlock);
|
||||
|
||||
componentImports.push(`import { ${component.name} as ${component.name}Cmp } from '@ionic/core/components/${component.tag}.js'`);
|
||||
const defineCustomElementFn = `define${component.name}CustomElement`;
|
||||
|
||||
componentImports.push(`import { defineCustomElement as ${defineCustomElementFn} } from '@ionic/core/components/${component.tag}.js'`);
|
||||
|
||||
if (component.controller) {
|
||||
controllerImports.push(component.controller);
|
||||
@ -55,7 +57,7 @@ function generateOverlays() {
|
||||
const controllerParam = (component.controller) ? `, ${component.controller}` : '';
|
||||
|
||||
componentDefinitions.push(`
|
||||
export const ${component.name} = /*@__PURE__*/ defineOverlayContainer<JSX.${component.name}>('${component.tag}', ${component.name}Cmp, [${props.join(', ')}]${controllerParam});
|
||||
export const ${component.name} = /*@__PURE__*/ defineOverlayContainer<JSX.${component.name}>('${component.tag}', ${defineCustomElementFn}, [${props.join(', ')}]${controllerParam});
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -9,27 +9,27 @@ import {
|
||||
toastController,
|
||||
} from '@ionic/core/components';
|
||||
|
||||
import { IonActionSheet as IonActionSheetCmp } from '@ionic/core/components/ion-action-sheet.js'
|
||||
import { IonAlert as IonAlertCmp } from '@ionic/core/components/ion-alert.js'
|
||||
import { IonLoading as IonLoadingCmp } from '@ionic/core/components/ion-loading.js'
|
||||
import { IonPicker as IonPickerCmp } from '@ionic/core/components/ion-picker.js'
|
||||
import { IonToast as IonToastCmp } from '@ionic/core/components/ion-toast.js'
|
||||
import { IonModal as IonModalCmp } from '@ionic/core/components/ion-modal.js'
|
||||
import { IonPopover as IonPopoverCmp } from '@ionic/core/components/ion-popover.js'
|
||||
import { defineCustomElement as defineIonActionSheetCustomElement } from '@ionic/core/components/ion-action-sheet.js'
|
||||
import { defineCustomElement as defineIonAlertCustomElement } from '@ionic/core/components/ion-alert.js'
|
||||
import { defineCustomElement as defineIonLoadingCustomElement } from '@ionic/core/components/ion-loading.js'
|
||||
import { defineCustomElement as defineIonPickerCustomElement } from '@ionic/core/components/ion-picker.js'
|
||||
import { defineCustomElement as defineIonToastCustomElement } from '@ionic/core/components/ion-toast.js'
|
||||
import { defineCustomElement as defineIonModalCustomElement } from '@ionic/core/components/ion-modal.js'
|
||||
import { defineCustomElement as defineIonPopoverCustomElement } from '@ionic/core/components/ion-popover.js'
|
||||
|
||||
import { defineOverlayContainer } from '../vue-component-lib/overlays';
|
||||
|
||||
export const IonActionSheet = /*@__PURE__*/ defineOverlayContainer<JSX.IonActionSheet>('ion-action-sheet', IonActionSheetCmp, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'mode', 'subHeader', 'translucent'], actionSheetController);
|
||||
export const IonActionSheet = /*@__PURE__*/ defineOverlayContainer<JSX.IonActionSheet>('ion-action-sheet', defineIonActionSheetCustomElement, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'mode', 'subHeader', 'translucent'], actionSheetController);
|
||||
|
||||
export const IonAlert = /*@__PURE__*/ defineOverlayContainer<JSX.IonAlert>('ion-alert', IonAlertCmp, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'inputs', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'subHeader', 'translucent'], alertController);
|
||||
export const IonAlert = /*@__PURE__*/ defineOverlayContainer<JSX.IonAlert>('ion-alert', defineIonAlertCustomElement, ['animated', 'backdropDismiss', 'buttons', 'cssClass', 'enterAnimation', 'header', 'htmlAttributes', 'inputs', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'subHeader', 'translucent'], alertController);
|
||||
|
||||
export const IonLoading = /*@__PURE__*/ defineOverlayContainer<JSX.IonLoading>('ion-loading', IonLoadingCmp, ['animated', 'backdropDismiss', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'showBackdrop', 'spinner', 'translucent'], loadingController);
|
||||
export const IonLoading = /*@__PURE__*/ defineOverlayContainer<JSX.IonLoading>('ion-loading', defineIonLoadingCustomElement, ['animated', 'backdropDismiss', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'showBackdrop', 'spinner', 'translucent'], loadingController);
|
||||
|
||||
export const IonPicker = /*@__PURE__*/ defineOverlayContainer<JSX.IonPicker>('ion-picker', IonPickerCmp, ['animated', 'backdropDismiss', 'buttons', 'columns', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'mode', 'showBackdrop'], pickerController);
|
||||
export const IonPicker = /*@__PURE__*/ defineOverlayContainer<JSX.IonPicker>('ion-picker', defineIonPickerCustomElement, ['animated', 'backdropDismiss', 'buttons', 'columns', 'cssClass', 'duration', 'enterAnimation', 'htmlAttributes', 'keyboardClose', 'leaveAnimation', 'mode', 'showBackdrop'], pickerController);
|
||||
|
||||
export const IonToast = /*@__PURE__*/ defineOverlayContainer<JSX.IonToast>('ion-toast', IonToastCmp, ['animated', 'buttons', 'color', 'cssClass', 'duration', 'enterAnimation', 'header', 'htmlAttributes', 'icon', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'position', 'translucent'], toastController);
|
||||
export const IonToast = /*@__PURE__*/ defineOverlayContainer<JSX.IonToast>('ion-toast', defineIonToastCustomElement, ['animated', 'buttons', 'color', 'cssClass', 'duration', 'enterAnimation', 'header', 'htmlAttributes', 'icon', 'keyboardClose', 'leaveAnimation', 'message', 'mode', 'position', 'translucent'], toastController);
|
||||
|
||||
export const IonModal = /*@__PURE__*/ defineOverlayContainer<JSX.IonModal>('ion-modal', IonModalCmp, ['animated', 'backdropBreakpoint', 'backdropDismiss', 'breakpoints', 'enterAnimation', 'handle', 'htmlAttributes', 'initialBreakpoint', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'presentingElement', 'showBackdrop', 'swipeToClose', 'trigger']);
|
||||
export const IonModal = /*@__PURE__*/ defineOverlayContainer<JSX.IonModal>('ion-modal', defineIonModalCustomElement, ['animated', 'backdropBreakpoint', 'backdropDismiss', 'breakpoints', 'enterAnimation', 'handle', 'htmlAttributes', 'initialBreakpoint', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'presentingElement', 'showBackdrop', 'swipeToClose', 'trigger']);
|
||||
|
||||
export const IonPopover = /*@__PURE__*/ defineOverlayContainer<JSX.IonPopover>('ion-popover', IonPopoverCmp, ['alignment', 'animated', 'arrow', 'backdropDismiss', 'component', 'componentProps', 'dismissOnSelect', 'enterAnimation', 'event', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'reference', 'showBackdrop', 'side', 'size', 'translucent', 'trigger', 'triggerAction']);
|
||||
export const IonPopover = /*@__PURE__*/ defineOverlayContainer<JSX.IonPopover>('ion-popover', defineIonPopoverCustomElement, ['alignment', 'animated', 'arrow', 'backdropDismiss', 'component', 'componentProps', 'dismissOnSelect', 'enterAnimation', 'event', 'htmlAttributes', 'isOpen', 'keyboardClose', 'leaveAnimation', 'mode', 'reference', 'showBackdrop', 'side', 'size', 'translucent', 'trigger', 'triggerAction']);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { defineComponent, h, ref, VNode, onMounted } from 'vue';
|
||||
import { defineCustomElement } from '../utils';
|
||||
|
||||
export interface OverlayProps {
|
||||
isOpen?: boolean;
|
||||
@ -8,7 +7,7 @@ export interface OverlayProps {
|
||||
const EMPTY_PROP = Symbol();
|
||||
const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
|
||||
|
||||
export const defineOverlayContainer = <Props extends object>(name: string, customElement: any, componentProps: string[] = [], controller?: any) => {
|
||||
export const defineOverlayContainer = <Props extends object>(name: string, defineCustomElement: () => void, componentProps: string[] = [], controller?: any) => {
|
||||
|
||||
const createControllerComponent = () => {
|
||||
return defineComponent<Props & OverlayProps>((props, { slots, emit }) => {
|
||||
@ -19,7 +18,9 @@ export const defineOverlayContainer = <Props extends object>(name: string, custo
|
||||
{ componentEv: `${name}-did-dismiss`, frameworkEv: 'didDismiss' },
|
||||
];
|
||||
|
||||
defineCustomElement(name, customElement);
|
||||
if (defineCustomElement !== undefined) {
|
||||
defineCustomElement();
|
||||
}
|
||||
|
||||
const overlay = ref();
|
||||
const onVnodeMounted = async () => {
|
||||
@ -131,7 +132,9 @@ export const defineOverlayContainer = <Props extends object>(name: string, custo
|
||||
};
|
||||
const createInlineComponent = () => {
|
||||
return defineComponent((props, { slots }) => {
|
||||
defineCustomElement(name, customElement);
|
||||
if (defineCustomElement !== undefined) {
|
||||
defineCustomElement();
|
||||
}
|
||||
const isOpen = ref(false);
|
||||
const elementRef = ref();
|
||||
|
||||
|
Reference in New Issue
Block a user