moved responsibility
This commit is contained in:
@@ -3,7 +3,7 @@ import { UmbModalHandler } from '..';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
|
||||
@customElement('umb-modal-element')
|
||||
export class UmbModalBaseElement<UmbModalData = void, UmbModalResult = void> extends UmbLitElement {
|
||||
export class UmbModalBaseElement<UmbModalData extends object = object, UmbModalResult = unknown> extends UmbLitElement {
|
||||
@property({ attribute: false })
|
||||
modalHandler?: UmbModalHandler<UmbModalData, UmbModalResult>;
|
||||
|
||||
@@ -13,6 +13,6 @@ export class UmbModalBaseElement<UmbModalData = void, UmbModalResult = void> ext
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-modal-element': UmbModalBaseElement<unknown>;
|
||||
'umb-modal-element': UmbModalBaseElement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ManifestModal } from '@umbraco-cms/extensions-registry';
|
||||
/**
|
||||
* Type which omits the real submit method, and replaces it with a submit method which accepts an optional argument depending on the generic type.
|
||||
*/
|
||||
export type UmbModalHandler<ModalData extends object = { [key: string]: unknown }, ModalResult = unknown> = Omit<
|
||||
export type UmbModalHandler<ModalData extends object = object, ModalResult = any> = Omit<
|
||||
UmbModalHandlerClass<ModalData, ModalResult>,
|
||||
'submit'
|
||||
> &
|
||||
@@ -35,7 +35,7 @@ type OptionalSubmitArgumentIfUndefined<T> = T extends undefined
|
||||
};
|
||||
|
||||
//TODO consider splitting this into two separate handlers
|
||||
export class UmbModalHandlerClass<ModalData extends object, ModalResult> {
|
||||
export class UmbModalHandlerClass<ModalData extends object = object, ModalResult = unknown> {
|
||||
private _submitPromise: Promise<ModalResult>;
|
||||
private _submitResolver?: (value: ModalResult) => void;
|
||||
private _submitRejecter?: () => void;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { UmbController, UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
|
||||
/*
|
||||
export class UmbModalRegistrationController<UmbModalToken, ModalData, ModalResult> extends UmbController {
|
||||
constructor(host: UmbControllerHostInterface, modalAlias: string | NewType<UmbModalToken, ModalData, ModalResult>) {
|
||||
super(host);
|
||||
this.key = config?.key || uuidv4();
|
||||
}
|
||||
|
||||
updateSetup() {}
|
||||
|
||||
hostConnected(): void {}
|
||||
hostDisconnected(): void {}
|
||||
}
|
||||
*/
|
||||
@@ -22,7 +22,7 @@ export interface UmbModalConfig {
|
||||
export class UmbModalContext {
|
||||
host: UmbControllerHostInterface;
|
||||
// TODO: Investigate if we can get rid of HTML elements in our store, so we can use one of our states.
|
||||
#modals = new BehaviorSubject(<Array<UmbModalHandler<any, any>>>[]);
|
||||
#modals = new BehaviorSubject(<Array<UmbModalHandler>>[]);
|
||||
public readonly modals = this.#modals.asObservable();
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
@@ -76,7 +76,7 @@ export class UmbModalContext {
|
||||
* @return {*} {UmbModalHandler}
|
||||
* @memberof UmbModalContext
|
||||
*/
|
||||
public open<ModalData extends object = { [key: string]: unknown }, ModalResult = unknown>(
|
||||
public open<ModalData extends object = object, ModalResult = unknown>(
|
||||
modalAlias: string | UmbModalToken<ModalData, ModalResult>,
|
||||
data?: ModalData,
|
||||
config?: UmbModalConfig
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UmbModalConfig } from '../modal.context';
|
||||
|
||||
export class UmbModalToken<Data extends object = { [key: string]: unknown }, Result = unknown> {
|
||||
export class UmbModalToken<Data extends object = object, Result = unknown> {
|
||||
/**
|
||||
* Get the data type of the token's data.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user