UNPKG

@descope/sdk-mixins

Version:
51 lines (47 loc) 2.53 kB
'use strict'; var tslib = require('tslib'); var sdkHelpers = require('@descope/sdk-helpers'); var initLifecycleMixin = require('../initLifecycleMixin.js'); var initElementMixin = require('../initElementMixin.js'); var descopeUiMixin = require('../descopeUiMixin/descopeUiMixin.js'); var helpers = require('./helpers.js'); var constants = require('./constants.js'); var sdkComponentDrivers = require('@descope/sdk-component-drivers'); const notificationsMixin = sdkHelpers.createSingletonMixin((superclass) => { var _NotificationsMixinClass_NotificationDriverWrapper, _a; const BaseClass = sdkHelpers.compose(initLifecycleMixin.initLifecycleMixin, initElementMixin.initElementMixin, descopeUiMixin.descopeUiMixin)(superclass); return _a = class NotificationsMixinClass extends BaseClass { constructor() { super(...arguments); _NotificationsMixinClass_NotificationDriverWrapper.set(this, (() => { const loadDescopeUiComponents = this.loadDescopeUiComponents.bind(this); return class NotificationDriverWrapper extends sdkComponentDrivers.NotificationDriver { setContent(templateOrString) { const template = typeof templateOrString === 'string' ? sdkHelpers.createTemplate(templateOrString) : templateOrString; loadDescopeUiComponents(template); super.setContent(template); } }; })()); } createNotification(config) { const baseConfig = {}; const notification = helpers.createNotificationEle(Object.assign(Object.assign({}, baseConfig), config)); this.rootElement.append(notification); return new (tslib.__classPrivateFieldGet(this, _NotificationsMixinClass_NotificationDriverWrapper, "f"))(notification, { logger: this.logger, }); } async init() { var _b; await ((_b = super.init) === null || _b === void 0 ? void 0 : _b.call(this)); this.loadDescopeUiComponents([constants.NOTIFICATION_ELE_TAG]); } }, _NotificationsMixinClass_NotificationDriverWrapper = new WeakMap(), _a; }); exports.notificationsMixin = notificationsMixin; //# sourceMappingURL=notificationsMixin.js.map