@umbraco-cms/backoffice 14.0.0--preview005-1ef9c3f3 → 14.0.0--preview005-a2cfdcbf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cms/packages/core/components/backoffice-modal-container/backoffice-modal-container.element.js +18 -5
- package/dist-cms/packages/core/modal/modal.element.d.ts +1 -1
- package/dist-cms/packages/core/modal/modal.element.js +9 -1
- package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -9,9 +9,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _UmbBackofficeModalContainerElement_instances, _UmbBackofficeModalContainerElement_createModalElements, _UmbBackofficeModalContainerElement_renderModal;
|
|
12
|
+
var _UmbBackofficeModalContainerElement_instances, _UmbBackofficeModalContainerElement_createModalElements, _UmbBackofficeModalContainerElement_onCloseEnd, _UmbBackofficeModalContainerElement_renderModal;
|
|
13
13
|
import { UmbTextStyles } from '../../../../shared/style/index.js';
|
|
14
|
-
import { css, html, repeat, customElement, state } from '../../../../external/lit/index.js';
|
|
14
|
+
import { css, html, repeat, customElement, state, nothing } from '../../../../external/lit/index.js';
|
|
15
15
|
import { UMB_MODAL_MANAGER_CONTEXT, UmbModalElement } from '../../modal/index.js';
|
|
16
16
|
import { UmbLitElement } from '../../../../shared/lit-element/index.js';
|
|
17
17
|
let UmbBackofficeModalContainerElement = class UmbBackofficeModalContainerElement extends UmbLitElement {
|
|
@@ -21,6 +21,7 @@ let UmbBackofficeModalContainerElement = class UmbBackofficeModalContainerElemen
|
|
|
21
21
|
this._modalElementMap = new Map();
|
|
22
22
|
this._modals = [];
|
|
23
23
|
this.consumeContext(UMB_MODAL_MANAGER_CONTEXT, (instance) => {
|
|
24
|
+
//TODO: This is being called way to many times if first page load includes an open modal.
|
|
24
25
|
this._modalManager = instance;
|
|
25
26
|
this._observeModals();
|
|
26
27
|
});
|
|
@@ -28,7 +29,9 @@ let UmbBackofficeModalContainerElement = class UmbBackofficeModalContainerElemen
|
|
|
28
29
|
_observeModals() {
|
|
29
30
|
if (!this._modalManager)
|
|
30
31
|
return;
|
|
31
|
-
this.observe(this._modalManager.modals, (modals) =>
|
|
32
|
+
this.observe(this._modalManager.modals, (modals) => {
|
|
33
|
+
__classPrivateFieldGet(this, _UmbBackofficeModalContainerElement_instances, "m", _UmbBackofficeModalContainerElement_createModalElements).call(this, modals);
|
|
34
|
+
});
|
|
32
35
|
}
|
|
33
36
|
render() {
|
|
34
37
|
return html `
|
|
@@ -42,7 +45,13 @@ let UmbBackofficeModalContainerElement = class UmbBackofficeModalContainerElemen
|
|
|
42
45
|
};
|
|
43
46
|
_UmbBackofficeModalContainerElement_instances = new WeakSet();
|
|
44
47
|
_UmbBackofficeModalContainerElement_createModalElements = function _UmbBackofficeModalContainerElement_createModalElements(modals) {
|
|
48
|
+
const oldValue = this._modals;
|
|
45
49
|
this._modals = modals;
|
|
50
|
+
const oldModals = oldValue.filter((oldModal) => !modals.some((modal) => modal.key === oldModal.key));
|
|
51
|
+
oldModals.forEach((modal) => {
|
|
52
|
+
this._modalElementMap.get(modal.key)?.removeEventListener('close-end', __classPrivateFieldGet(this, _UmbBackofficeModalContainerElement_instances, "m", _UmbBackofficeModalContainerElement_onCloseEnd).bind(this, modal.key));
|
|
53
|
+
this._modalElementMap.delete(modal.key);
|
|
54
|
+
});
|
|
46
55
|
if (this._modals.length === 0) {
|
|
47
56
|
this._modalElementMap.clear();
|
|
48
57
|
return;
|
|
@@ -52,14 +61,18 @@ _UmbBackofficeModalContainerElement_createModalElements = function _UmbBackoffic
|
|
|
52
61
|
return;
|
|
53
62
|
const modalElement = new UmbModalElement();
|
|
54
63
|
modalElement.modalContext = modal;
|
|
55
|
-
modalElement.element?.addEventListener('close-end', (
|
|
64
|
+
modalElement.element?.addEventListener('close-end', __classPrivateFieldGet(this, _UmbBackofficeModalContainerElement_instances, "m", _UmbBackofficeModalContainerElement_onCloseEnd).bind(this, modal.key));
|
|
56
65
|
this._modalElementMap.set(modal.key, modalElement);
|
|
66
|
+
this.requestUpdate();
|
|
57
67
|
});
|
|
58
68
|
};
|
|
69
|
+
_UmbBackofficeModalContainerElement_onCloseEnd = function _UmbBackofficeModalContainerElement_onCloseEnd(key) {
|
|
70
|
+
this._modalManager?.remove(key);
|
|
71
|
+
};
|
|
59
72
|
_UmbBackofficeModalContainerElement_renderModal = function _UmbBackofficeModalContainerElement_renderModal(key) {
|
|
60
73
|
const modalElement = this._modalElementMap.get(key);
|
|
61
74
|
if (!modalElement)
|
|
62
|
-
return;
|
|
75
|
+
return nothing;
|
|
63
76
|
return modalElement.render();
|
|
64
77
|
};
|
|
65
78
|
UmbBackofficeModalContainerElement.styles = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UmbModalContext } from './modal.context.js';
|
|
2
2
|
import type { CSSResultGroup } from '../../../external/lit/index.js';
|
|
3
3
|
import { UmbLitElement } from '../../../shared/lit-element/index.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type UUIModalDialogElement, type UUIModalSidebarElement } from '../../../external/uui/index.js';
|
|
5
5
|
export declare class UmbModalElement extends UmbLitElement {
|
|
6
6
|
#private;
|
|
7
7
|
get modalContext(): UmbModalContext | undefined;
|
|
@@ -15,13 +15,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
15
15
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
16
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
17
|
};
|
|
18
|
-
var _UmbModalElement_instances, _UmbModalElement_modalContext, _UmbModalElement_innerElement, _UmbModalElement_modalExtensionObserver, _UmbModalElement_modalRouterElement, _UmbModalElement_createModalElement, _UmbModalElement_createContainerElement, _UmbModalElement_createSidebarElement, _UmbModalElement_createDialogElement, _UmbModalElement_observeModal, _UmbModalElement_createInnerElement, _UmbModalElement_appendInnerElement, _UmbModalElement_removeInnerElement, _UmbModalElement_destroy;
|
|
18
|
+
var _UmbModalElement_instances, _UmbModalElement_modalContext, _UmbModalElement_innerElement, _UmbModalElement_modalExtensionObserver, _UmbModalElement_modalRouterElement, _UmbModalElement_onClose, _UmbModalElement_createModalElement, _UmbModalElement_createContainerElement, _UmbModalElement_createSidebarElement, _UmbModalElement_createDialogElement, _UmbModalElement_observeModal, _UmbModalElement_createInnerElement, _UmbModalElement_appendInnerElement, _UmbModalElement_removeInnerElement, _UmbModalElement_destroy;
|
|
19
19
|
import { UMB_MODAL_CONTEXT } from './modal.context.js';
|
|
20
20
|
import { umbExtensionsRegistry } from '../extension-registry/index.js';
|
|
21
21
|
import { UmbTextStyles } from '../../../shared/style/index.js';
|
|
22
22
|
import { html, customElement } from '../../../external/lit/index.js';
|
|
23
23
|
import { UmbLitElement } from '../../../shared/lit-element/index.js';
|
|
24
24
|
import { BehaviorSubject } from '../../../external/rxjs/index.js';
|
|
25
|
+
import { UUIModalCloseEvent, } from '../../../external/uui/index.js';
|
|
25
26
|
import { createExtensionElement } from '../../../libs/extension-api/index.js';
|
|
26
27
|
import { UMB_CONTENT_REQUEST_EVENT_TYPE, UmbContextProvider } from '../../../libs/context-api/index.js';
|
|
27
28
|
let UmbModalElement = class UmbModalElement extends UmbLitElement {
|
|
@@ -32,6 +33,10 @@ let UmbModalElement = class UmbModalElement extends UmbLitElement {
|
|
|
32
33
|
_UmbModalElement_innerElement.set(this, new BehaviorSubject(undefined));
|
|
33
34
|
_UmbModalElement_modalExtensionObserver.set(this, void 0);
|
|
34
35
|
_UmbModalElement_modalRouterElement.set(this, document.createElement('umb-router-slot'));
|
|
36
|
+
_UmbModalElement_onClose.set(this, () => {
|
|
37
|
+
this.element?.removeEventListener(UUIModalCloseEvent, __classPrivateFieldGet(this, _UmbModalElement_onClose, "f"));
|
|
38
|
+
__classPrivateFieldGet(this, _UmbModalElement_modalContext, "f")?.reject({ type: 'close' });
|
|
39
|
+
});
|
|
35
40
|
}
|
|
36
41
|
get modalContext() {
|
|
37
42
|
return __classPrivateFieldGet(this, _UmbModalElement_modalContext, "f");
|
|
@@ -56,11 +61,14 @@ _UmbModalElement_modalContext = new WeakMap();
|
|
|
56
61
|
_UmbModalElement_innerElement = new WeakMap();
|
|
57
62
|
_UmbModalElement_modalExtensionObserver = new WeakMap();
|
|
58
63
|
_UmbModalElement_modalRouterElement = new WeakMap();
|
|
64
|
+
_UmbModalElement_onClose = new WeakMap();
|
|
59
65
|
_UmbModalElement_instances = new WeakSet();
|
|
60
66
|
_UmbModalElement_createModalElement = function _UmbModalElement_createModalElement() {
|
|
61
67
|
if (!__classPrivateFieldGet(this, _UmbModalElement_modalContext, "f"))
|
|
62
68
|
return;
|
|
63
69
|
this.element = __classPrivateFieldGet(this, _UmbModalElement_instances, "m", _UmbModalElement_createContainerElement).call(this);
|
|
70
|
+
// Makes sure that the modal triggers the reject of the context promise when it is closed by pressing escape.
|
|
71
|
+
this.element.addEventListener(UUIModalCloseEvent, __classPrivateFieldGet(this, _UmbModalElement_onClose, "f"));
|
|
64
72
|
if (__classPrivateFieldGet(this, _UmbModalElement_modalContext, "f").originTarget) {
|
|
65
73
|
// The following code is the context api proxy.
|
|
66
74
|
// It re-dispatches the context api request event to the origin target of this modal, in other words the element that initiated the modal.
|