accept default data in modal token

This commit is contained in:
Mads Rasmussen
2023-05-09 11:48:27 +02:00
parent a812b14668
commit 10328ee252

View File

@@ -1,36 +1,38 @@
import { UmbModalConfig } from '../modal.context'; import { UmbModalConfig } from '../modal.context';
export class UmbModalToken<Data extends object = object, Result = unknown> { export class UmbModalToken<ModalDataType extends object = object, ModalResultType = unknown> {
/** /**
* Get the data type of the token's data. * Get the data type of the token's data.
* *
* @public * @public
* @type {Data} * @type {ModalDataType}
* @memberOf UmbModalToken * @memberOf UmbModalToken
* @example `typeof MyModal.TYPE` * @example `typeof MyModal.TYPE`
* @returns undefined * @returns undefined
*/ */
readonly DATA: Data = undefined as never; readonly DATA: ModalDataType = undefined as never;
/** /**
* Get the result type of the token * Get the result type of the token
* *
* @public * @public
* @type {Result} * @type {ModalResultType}
* @memberOf UmbModalToken * @memberOf UmbModalToken
* @example `typeof MyModal.RESULT` * @example `typeof MyModal.RESULT`
* @returns undefined * @returns undefined
*/ */
readonly RESULT: Result = undefined as never; readonly RESULT: ModalResultType = undefined as never;
/** /**
* @param alias Unique identifier for the token, * @param alias Unique identifier for the token,
* @param defaultConfig Default configuration for the modal, * @param defaultConfig Default configuration for the modal,
* @param _desc Description for the token, * @param defaultData Default data for the modal,
* used only for debugging purposes,
* it should but does not need to be unique
*/ */
constructor(protected alias: string, protected defaultConfig?: UmbModalConfig, protected _desc?: string) {} constructor(
protected alias: string,
protected defaultConfig?: UmbModalConfig,
protected defaultData?: ModalDataType
) {}
/** /**
* This method must always return the unique alias of the token since that * This method must always return the unique alias of the token since that
@@ -45,4 +47,8 @@ export class UmbModalToken<Data extends object = object, Result = unknown> {
public getDefaultConfig(): UmbModalConfig | undefined { public getDefaultConfig(): UmbModalConfig | undefined {
return this.defaultConfig; return this.defaultConfig;
} }
public getDefaultData(): ModalDataType | undefined {
return this.defaultData;
}
} }