@nectary/components 3.2.0 → 3.3.1
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/lib/cjs/dialog/index.js +1 -2
- package/lib/cjs/persistent-overlay/index.d.ts +15 -0
- package/lib/cjs/persistent-overlay/index.js +106 -0
- package/lib/cjs/persistent-overlay/types.d.ts +22 -0
- package/lib/cjs/persistent-overlay/types.js +1 -0
- package/lib/esm/dialog/index.js +1 -2
- package/lib/esm/persistent-overlay/index.d.ts +15 -0
- package/lib/esm/persistent-overlay/index.js +104 -0
- package/lib/esm/persistent-overlay/types.d.ts +22 -0
- package/lib/esm/persistent-overlay/types.js +1 -0
- package/package.json +1 -1
package/lib/cjs/dialog/index.js
CHANGED
|
@@ -5,7 +5,7 @@ require('../stop-events');
|
|
|
5
5
|
require('../title');
|
|
6
6
|
var _utils = require('../utils');
|
|
7
7
|
var _utils2 = require('./utils');
|
|
8
|
-
const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:90vh;--sinch-comp-dialog-width:fit-content}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;width:var(--sinch-comp-dialog-width);max-width:var(--sinch-comp-dialog-max-width);max-height:var(--sinch-comp-dialog-max-height);border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
|
|
8
|
+
const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:90vh;--sinch-comp-dialog-width:fit-content;--sinch-dialog-close-button-display:unset}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;width:var(--sinch-comp-dialog-width);max-width:var(--sinch-comp-dialog-max-width);max-height:var(--sinch-comp-dialog-max-height);border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{display:var(--sinch-dialog-close-button-display,initial);position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
|
|
9
9
|
const template = document.createElement('template');
|
|
10
10
|
template.innerHTML = templateHTML;
|
|
11
11
|
(0, _utils.defineCustomElement)('sinch-dialog', class extends _utils.NectaryElement {
|
|
@@ -143,7 +143,6 @@ template.innerHTML = templateHTML;
|
|
|
143
143
|
if (!this.#$dialog.open) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
this.#$dialogContent.scrollTo(0, 0);
|
|
147
146
|
this.#$dialog.close?.();
|
|
148
147
|
(0, _utils2.enableScroll)();
|
|
149
148
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../icon';
|
|
2
|
+
import '../stop-events';
|
|
3
|
+
import '../title';
|
|
4
|
+
import type { TSinchPersistentOverlayElement, TSinchPersistentOverlayReact } from './types';
|
|
5
|
+
import '@nectary/components/dialog';
|
|
6
|
+
declare global {
|
|
7
|
+
namespace JSX {
|
|
8
|
+
interface IntrinsicElements {
|
|
9
|
+
'sinch-persistent-overlay': TSinchPersistentOverlayReact;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'sinch-persistent-overlay': TSinchPersistentOverlayElement;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require('../icon');
|
|
4
|
+
require('../stop-events');
|
|
5
|
+
require('../title');
|
|
6
|
+
var _utils = require('../utils');
|
|
7
|
+
require('@nectary/components/dialog');
|
|
8
|
+
const templateHTML = '<style>#persisted-dialog{--sinch-dialog-close-button-display:none}::slotted(*){display:block}</style><sinch-dialog id="persisted-dialog"><div slot="icon"><slot id="icon" name="icon"></slot></div><div slot="content"><slot name="content"></slot></div><div slot="buttons"><slot name="buttons"></slot></div></sinch-dialog>';
|
|
9
|
+
const template = document.createElement('template');
|
|
10
|
+
template.innerHTML = templateHTML;
|
|
11
|
+
function isVisible(elementStyle) {
|
|
12
|
+
return elementStyle.visibility === 'visible' && elementStyle.display !== 'none';
|
|
13
|
+
}
|
|
14
|
+
const observeDialogVisibilityManipulation = function (sinchDialogElement, cb) {
|
|
15
|
+
let intervalLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
16
|
+
const checkInterval = setInterval(() => {
|
|
17
|
+
const dialogElement = sinchDialogElement.shadowRoot?.querySelector('dialog');
|
|
18
|
+
if (!isVisible(getComputedStyle(sinchDialogElement)) || sinchDialogElement.open !== true || dialogElement === null || dialogElement === undefined || !isVisible(getComputedStyle(dialogElement)) || dialogElement.open !== true) {
|
|
19
|
+
cb();
|
|
20
|
+
}
|
|
21
|
+
}, intervalLength);
|
|
22
|
+
return checkInterval;
|
|
23
|
+
};
|
|
24
|
+
(0, _utils.defineCustomElement)('sinch-persistent-overlay', class extends _utils.NectaryElement {
|
|
25
|
+
#$sinchDialog;
|
|
26
|
+
#visibilityObserverInterval;
|
|
27
|
+
#controller = null;
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
const shadowRoot = this.attachShadow();
|
|
31
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
32
|
+
this.#$sinchDialog = shadowRoot.querySelector('#persisted-dialog');
|
|
33
|
+
}
|
|
34
|
+
static get observedAttributes() {
|
|
35
|
+
return ['caption', 'open'];
|
|
36
|
+
}
|
|
37
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
38
|
+
switch (name) {
|
|
39
|
+
case 'caption':
|
|
40
|
+
{
|
|
41
|
+
(0, _utils.updateAttribute)(this.#$sinchDialog, 'caption', newVal);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case 'open':
|
|
45
|
+
{
|
|
46
|
+
(0, _utils.updateAttribute)(this.#$sinchDialog, 'open', newVal);
|
|
47
|
+
const shouldOpen = (0, _utils.isAttrTrue)(newVal);
|
|
48
|
+
if (shouldOpen) {
|
|
49
|
+
requestAnimationFrame(() => {
|
|
50
|
+
this.#startObservingAlteration();
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
this.#stopObservingAlteration();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
connectedCallback() {
|
|
59
|
+
super.connectedCallback();
|
|
60
|
+
this.role = 'dialog';
|
|
61
|
+
this.#controller = new AbortController();
|
|
62
|
+
const {
|
|
63
|
+
signal
|
|
64
|
+
} = this.#controller;
|
|
65
|
+
this.addEventListener('-visibility-altered', this.#onVisibilityAlteredReactHandler, {
|
|
66
|
+
signal
|
|
67
|
+
});
|
|
68
|
+
if (this.open) {
|
|
69
|
+
this.#startObservingAlteration();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
super.disconnectedCallback();
|
|
74
|
+
this.#controller.abort();
|
|
75
|
+
this.#controller = null;
|
|
76
|
+
if (this.open || this.#visibilityObserverInterval !== undefined) {
|
|
77
|
+
this.#onVisibilityAltered();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
set caption(caption) {
|
|
81
|
+
(0, _utils.updateAttribute)(this, 'caption', caption);
|
|
82
|
+
}
|
|
83
|
+
get caption() {
|
|
84
|
+
return (0, _utils.getAttribute)(this, 'caption', '');
|
|
85
|
+
}
|
|
86
|
+
set open(isOpen) {
|
|
87
|
+
(0, _utils.updateBooleanAttribute)(this, 'open', isOpen);
|
|
88
|
+
}
|
|
89
|
+
get open() {
|
|
90
|
+
return (0, _utils.getBooleanAttribute)(this, 'open');
|
|
91
|
+
}
|
|
92
|
+
#startObservingAlteration() {
|
|
93
|
+
this.#visibilityObserverInterval = observeDialogVisibilityManipulation(this.#$sinchDialog, () => {
|
|
94
|
+
this.#onVisibilityAltered();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
#stopObservingAlteration() {
|
|
98
|
+
clearInterval(this.#visibilityObserverInterval);
|
|
99
|
+
}
|
|
100
|
+
#onVisibilityAltered() {
|
|
101
|
+
this.dispatchEvent(new CustomEvent('-visibility-altered'));
|
|
102
|
+
}
|
|
103
|
+
#onVisibilityAlteredReactHandler = e => {
|
|
104
|
+
(0, _utils.getReactEventHandler)(this, 'on-visibility-altered')?.(e);
|
|
105
|
+
};
|
|
106
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TSinchDialogElement, TSinchDialogReact } from '../dialog/types';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
export type TSinchPersistentOverlayElement = HTMLElement & {
|
|
4
|
+
/** Open/close state */
|
|
5
|
+
open: TSinchDialogElement['open'];
|
|
6
|
+
/** Dialog caption */
|
|
7
|
+
caption: TSinchDialogElement['caption'];
|
|
8
|
+
/** Dialog caption */
|
|
9
|
+
setAttribute(name: 'caption', value: TSinchDialogElement['caption']): void;
|
|
10
|
+
/** visibility altered event handler */
|
|
11
|
+
addEventListener(type: '-visibility-altered', listener: (e: CustomEvent) => void): void;
|
|
12
|
+
};
|
|
13
|
+
export type TSinchPersistentOverlayReact = TSinchElementReact<TSinchPersistentOverlayElement> & {
|
|
14
|
+
/** Controls whether the dialog should be open */
|
|
15
|
+
open: TSinchDialogReact['open'];
|
|
16
|
+
/** Dialog caption */
|
|
17
|
+
caption: TSinchDialogReact['caption'];
|
|
18
|
+
/** Label that is used for a11y */
|
|
19
|
+
'aria-label': TSinchDialogReact['aria-label'];
|
|
20
|
+
/** visibility altered event handler */
|
|
21
|
+
'on-visibility-altered': (e: CustomEvent) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/esm/dialog/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import '../icon';
|
|
|
2
2
|
import '../stop-events';
|
|
3
3
|
import '../title';
|
|
4
4
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute, getReactEventHandler, NectaryElement, updateBooleanAttribute, setClass, isTargetEqual, isAttrEqual } from '../utils';
|
|
5
|
-
const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:90vh;--sinch-comp-dialog-width:fit-content}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;width:var(--sinch-comp-dialog-width);max-width:var(--sinch-comp-dialog-max-width);max-height:var(--sinch-comp-dialog-max-height);border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
|
|
5
|
+
const templateHTML = '<style>:host{display:contents;--sinch-comp-dialog-max-width:512px;--sinch-comp-dialog-max-height:90vh;--sinch-comp-dialog-width:fit-content;--sinch-dialog-close-button-display:unset}#dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px 0;width:var(--sinch-comp-dialog-width);max-width:var(--sinch-comp-dialog-max-width);max-height:var(--sinch-comp-dialog-max-height);border-radius:var(--sinch-comp-dialog-shape-radius);box-sizing:border-box;contain:content;background-color:var(--sinch-comp-dialog-color-default-background-initial);border:none;box-shadow:var(--sinch-comp-dialog-shadow);outline:0}#dialog:not([open]){display:none}dialog::backdrop{background-color:#000;opacity:.55}#header{display:flex;flex-direction:row;align-items:flex-start;margin-bottom:12px;padding:0 24px;gap:8px;--sinch-global-size-icon:24px;--sinch-global-color-icon:var(--sinch-comp-dialog-color-default-icon-initial)}#caption{--sinch-global-color-text:var(--sinch-comp-dialog-color-default-title-initial);--sinch-comp-title-font:var(--sinch-comp-dialog-font-title)}#content{min-height:0;overflow:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:20px;padding:0 24px}#action.empty{display:none}#close{display:var(--sinch-dialog-close-button-display,initial);position:relative;left:4px;top:-4px;margin-left:auto}</style><dialog id="dialog"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" type="m" level="3"></sinch-title><sinch-button id="close" size="s"><sinch-icon id="icon-close" slot="icon" name="close"></sinch-icon></sinch-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="action"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
|
|
6
6
|
import { disableScroll, enableScroll } from './utils';
|
|
7
7
|
const template = document.createElement('template');
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
@@ -141,7 +141,6 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
141
141
|
if (!this.#$dialog.open) {
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
this.#$dialogContent.scrollTo(0, 0);
|
|
145
144
|
this.#$dialog.close?.();
|
|
146
145
|
enableScroll();
|
|
147
146
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../icon';
|
|
2
|
+
import '../stop-events';
|
|
3
|
+
import '../title';
|
|
4
|
+
import type { TSinchPersistentOverlayElement, TSinchPersistentOverlayReact } from './types';
|
|
5
|
+
import '@nectary/components/dialog';
|
|
6
|
+
declare global {
|
|
7
|
+
namespace JSX {
|
|
8
|
+
interface IntrinsicElements {
|
|
9
|
+
'sinch-persistent-overlay': TSinchPersistentOverlayReact;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'sinch-persistent-overlay': TSinchPersistentOverlayElement;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import '../icon';
|
|
2
|
+
import '../stop-events';
|
|
3
|
+
import '../title';
|
|
4
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, updateAttribute, NectaryElement, updateBooleanAttribute, isAttrTrue, getReactEventHandler } from '../utils';
|
|
5
|
+
const templateHTML = '<style>#persisted-dialog{--sinch-dialog-close-button-display:none}::slotted(*){display:block}</style><sinch-dialog id="persisted-dialog"><div slot="icon"><slot id="icon" name="icon"></slot></div><div slot="content"><slot name="content"></slot></div><div slot="buttons"><slot name="buttons"></slot></div></sinch-dialog>';
|
|
6
|
+
import '@nectary/components/dialog';
|
|
7
|
+
const template = document.createElement('template');
|
|
8
|
+
template.innerHTML = templateHTML;
|
|
9
|
+
function isVisible(elementStyle) {
|
|
10
|
+
return elementStyle.visibility === 'visible' && elementStyle.display !== 'none';
|
|
11
|
+
}
|
|
12
|
+
const observeDialogVisibilityManipulation = function (sinchDialogElement, cb) {
|
|
13
|
+
let intervalLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
14
|
+
const checkInterval = setInterval(() => {
|
|
15
|
+
const dialogElement = sinchDialogElement.shadowRoot?.querySelector('dialog');
|
|
16
|
+
if (!isVisible(getComputedStyle(sinchDialogElement)) || sinchDialogElement.open !== true || dialogElement === null || dialogElement === undefined || !isVisible(getComputedStyle(dialogElement)) || dialogElement.open !== true) {
|
|
17
|
+
cb();
|
|
18
|
+
}
|
|
19
|
+
}, intervalLength);
|
|
20
|
+
return checkInterval;
|
|
21
|
+
};
|
|
22
|
+
defineCustomElement('sinch-persistent-overlay', class extends NectaryElement {
|
|
23
|
+
#$sinchDialog;
|
|
24
|
+
#visibilityObserverInterval;
|
|
25
|
+
#controller = null;
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
const shadowRoot = this.attachShadow();
|
|
29
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
30
|
+
this.#$sinchDialog = shadowRoot.querySelector('#persisted-dialog');
|
|
31
|
+
}
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return ['caption', 'open'];
|
|
34
|
+
}
|
|
35
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
36
|
+
switch (name) {
|
|
37
|
+
case 'caption':
|
|
38
|
+
{
|
|
39
|
+
updateAttribute(this.#$sinchDialog, 'caption', newVal);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'open':
|
|
43
|
+
{
|
|
44
|
+
updateAttribute(this.#$sinchDialog, 'open', newVal);
|
|
45
|
+
const shouldOpen = isAttrTrue(newVal);
|
|
46
|
+
if (shouldOpen) {
|
|
47
|
+
requestAnimationFrame(() => {
|
|
48
|
+
this.#startObservingAlteration();
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
this.#stopObservingAlteration();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
connectedCallback() {
|
|
57
|
+
super.connectedCallback();
|
|
58
|
+
this.role = 'dialog';
|
|
59
|
+
this.#controller = new AbortController();
|
|
60
|
+
const {
|
|
61
|
+
signal
|
|
62
|
+
} = this.#controller;
|
|
63
|
+
this.addEventListener('-visibility-altered', this.#onVisibilityAlteredReactHandler, {
|
|
64
|
+
signal
|
|
65
|
+
});
|
|
66
|
+
if (this.open) {
|
|
67
|
+
this.#startObservingAlteration();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
super.disconnectedCallback();
|
|
72
|
+
this.#controller.abort();
|
|
73
|
+
this.#controller = null;
|
|
74
|
+
if (this.open || this.#visibilityObserverInterval !== undefined) {
|
|
75
|
+
this.#onVisibilityAltered();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
set caption(caption) {
|
|
79
|
+
updateAttribute(this, 'caption', caption);
|
|
80
|
+
}
|
|
81
|
+
get caption() {
|
|
82
|
+
return getAttribute(this, 'caption', '');
|
|
83
|
+
}
|
|
84
|
+
set open(isOpen) {
|
|
85
|
+
updateBooleanAttribute(this, 'open', isOpen);
|
|
86
|
+
}
|
|
87
|
+
get open() {
|
|
88
|
+
return getBooleanAttribute(this, 'open');
|
|
89
|
+
}
|
|
90
|
+
#startObservingAlteration() {
|
|
91
|
+
this.#visibilityObserverInterval = observeDialogVisibilityManipulation(this.#$sinchDialog, () => {
|
|
92
|
+
this.#onVisibilityAltered();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
#stopObservingAlteration() {
|
|
96
|
+
clearInterval(this.#visibilityObserverInterval);
|
|
97
|
+
}
|
|
98
|
+
#onVisibilityAltered() {
|
|
99
|
+
this.dispatchEvent(new CustomEvent('-visibility-altered'));
|
|
100
|
+
}
|
|
101
|
+
#onVisibilityAlteredReactHandler = e => {
|
|
102
|
+
getReactEventHandler(this, 'on-visibility-altered')?.(e);
|
|
103
|
+
};
|
|
104
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TSinchDialogElement, TSinchDialogReact } from '../dialog/types';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
export type TSinchPersistentOverlayElement = HTMLElement & {
|
|
4
|
+
/** Open/close state */
|
|
5
|
+
open: TSinchDialogElement['open'];
|
|
6
|
+
/** Dialog caption */
|
|
7
|
+
caption: TSinchDialogElement['caption'];
|
|
8
|
+
/** Dialog caption */
|
|
9
|
+
setAttribute(name: 'caption', value: TSinchDialogElement['caption']): void;
|
|
10
|
+
/** visibility altered event handler */
|
|
11
|
+
addEventListener(type: '-visibility-altered', listener: (e: CustomEvent) => void): void;
|
|
12
|
+
};
|
|
13
|
+
export type TSinchPersistentOverlayReact = TSinchElementReact<TSinchPersistentOverlayElement> & {
|
|
14
|
+
/** Controls whether the dialog should be open */
|
|
15
|
+
open: TSinchDialogReact['open'];
|
|
16
|
+
/** Dialog caption */
|
|
17
|
+
caption: TSinchDialogReact['caption'];
|
|
18
|
+
/** Label that is used for a11y */
|
|
19
|
+
'aria-label': TSinchDialogReact['aria-label'];
|
|
20
|
+
/** visibility altered event handler */
|
|
21
|
+
'on-visibility-altered': (e: CustomEvent) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|