40 lines
3.3 KiB
JavaScript
40 lines
3.3 KiB
JavaScript
|
import { DefaultNoComponentGlobalConfig, TOAST_CONFIG } from './toastr-config';
|
||
|
import { makeEnvironmentProviders } from '@angular/core';
|
||
|
import { Toast } from './toast.component';
|
||
|
export const DefaultGlobalConfig = {
|
||
|
...DefaultNoComponentGlobalConfig,
|
||
|
toastComponent: Toast,
|
||
|
};
|
||
|
/**
|
||
|
* @description
|
||
|
* Provides the `TOAST_CONFIG` token with the given config.
|
||
|
*
|
||
|
* @param config The config to configure toastr.
|
||
|
* @returns The environment providers.
|
||
|
*
|
||
|
* @example
|
||
|
* ```ts
|
||
|
* import { provideToastr } from 'ngx-toastr';
|
||
|
*
|
||
|
* bootstrap(AppComponent, {
|
||
|
* providers: [
|
||
|
* provideToastr({
|
||
|
* timeOut: 2000,
|
||
|
* positionClass: 'toast-top-right',
|
||
|
* }),
|
||
|
* ],
|
||
|
* })
|
||
|
*/
|
||
|
export const provideToastr = (config = {}) => {
|
||
|
const providers = [
|
||
|
{
|
||
|
provide: TOAST_CONFIG,
|
||
|
useValue: {
|
||
|
default: DefaultGlobalConfig,
|
||
|
config,
|
||
|
}
|
||
|
}
|
||
|
];
|
||
|
return makeEnvironmentProviders(providers);
|
||
|
};
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3QucHJvdmlkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGliL3RvYXN0ci90b2FzdC5wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsOEJBQThCLEVBQWdCLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQzdGLE9BQU8sRUFBd0Isd0JBQXdCLEVBQVksTUFBTSxlQUFlLENBQUM7QUFDekYsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRTF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