@shoper/phoenix_design_system 1.15.11-24 → 1.15.11-26
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/build/cjs/packages/phoenix/src/components/messages/base_message.js +24 -24
- package/build/cjs/packages/phoenix/src/components/messages/base_message_content.js +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +4 -2
- package/build/esm/packages/phoenix/src/components/messages/base_message.js +24 -24
- package/build/esm/packages/phoenix/src/components/messages/base_message_content.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
6
|
+
require('lit');
|
|
6
7
|
var decorators = require('lit/decorators');
|
|
7
8
|
var utilities = require('@dreamcommerce/utilities');
|
|
8
9
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
@@ -24,18 +25,22 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
24
25
|
if (!this._$baseMessageContent)
|
|
25
26
|
return;
|
|
26
27
|
[...this.children].forEach((child) => {
|
|
27
|
-
var _a;
|
|
28
28
|
if (base_message_constants.LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()))
|
|
29
29
|
return;
|
|
30
|
-
|
|
30
|
+
if (this._$baseMessageContent)
|
|
31
|
+
child.setAttribute('aria-describedby', this._$baseMessageContent.messageId);
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
34
|
this._setupEventListeners = () => {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
var _a, _b;
|
|
36
|
+
this.addEventListener('mouseenter', this.open);
|
|
37
|
+
this.addEventListener('mouseleave', this._closeFromEvent);
|
|
38
|
+
this.addEventListener('keydown', this._closeFromKeyboard);
|
|
39
|
+
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.open);
|
|
40
|
+
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this._closeFromEvent);
|
|
36
41
|
if (!this.mouseonly) {
|
|
37
42
|
this.addEventListener('focusin', this.open);
|
|
38
|
-
this.addEventListener('focusout', this.
|
|
43
|
+
this.addEventListener('focusout', this._closeFromEvent);
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
this._positionMessage = () => {
|
|
@@ -44,19 +49,6 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
44
49
|
(_a = this._$messageContent) === null || _a === void 0 ? void 0 : _a.setAttribute('direction', this._positionController.position(true));
|
|
45
50
|
});
|
|
46
51
|
};
|
|
47
|
-
this._toggleTooltipFromEvent = (ev) => {
|
|
48
|
-
var _a;
|
|
49
|
-
if (!ev.target)
|
|
50
|
-
return;
|
|
51
|
-
const $target = ev.target;
|
|
52
|
-
const isInsideMessageContent = $target.closest && $target.closest(`[id="${(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.id}"]`);
|
|
53
|
-
const isInsideMessageContainer = !!this.contains($target);
|
|
54
|
-
if (!isInsideMessageContent && !isInsideMessageContainer) {
|
|
55
|
-
this.close();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.open();
|
|
59
|
-
};
|
|
60
52
|
this.open = () => {
|
|
61
53
|
this._tooltipOpenTime = Date.now();
|
|
62
54
|
clearTimeout(this._closeTimeout);
|
|
@@ -67,13 +59,16 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
67
59
|
}, base_message_constants.MESSAGE_SHOW_DELAY_IN_MS);
|
|
68
60
|
};
|
|
69
61
|
this._closeFromKeyboard = (ev) => {
|
|
70
|
-
if (ev.key !== 'Escape')
|
|
62
|
+
if (ev.key !== 'Escape' || !this.opened)
|
|
71
63
|
return;
|
|
72
64
|
ev.preventDefault();
|
|
65
|
+
this.close(true);
|
|
66
|
+
};
|
|
67
|
+
this._closeFromEvent = () => {
|
|
73
68
|
this.close();
|
|
74
69
|
};
|
|
75
|
-
this.close = () => {
|
|
76
|
-
this._shouldDelayClosing = Date.now() - this._tooltipOpenTime > base_message_constants.MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
70
|
+
this.close = (shouldCloseImmediately = false) => {
|
|
71
|
+
this._shouldDelayClosing = !shouldCloseImmediately && Date.now() - this._tooltipOpenTime > base_message_constants.MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
77
72
|
clearTimeout(this._openTimeout);
|
|
78
73
|
if (!this.opened)
|
|
79
74
|
return;
|
|
@@ -94,7 +89,7 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
94
89
|
this._clickOutsideController = new click_outside_controller.ClickOutsideController({
|
|
95
90
|
host: this,
|
|
96
91
|
container: this,
|
|
97
|
-
action: this.
|
|
92
|
+
action: this._closeFromEvent
|
|
98
93
|
});
|
|
99
94
|
}
|
|
100
95
|
connectedCallback(messageComponentName = '') {
|
|
@@ -112,9 +107,12 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
112
107
|
offset: this.offset
|
|
113
108
|
});
|
|
114
109
|
this.setAttribute('tabindex', this.tabindex);
|
|
115
|
-
this._setupEventListeners();
|
|
116
110
|
if (!this._$baseMessageContent)
|
|
117
111
|
this._$baseMessageContent = [...this.children].find((child) => base_message_constants.LIST_OF_MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
|
|
112
|
+
this._setupEventListeners();
|
|
113
|
+
}
|
|
114
|
+
firstUpdated(props) {
|
|
115
|
+
super.firstUpdated(props);
|
|
118
116
|
this._handleChildrenAriaAttributes();
|
|
119
117
|
}
|
|
120
118
|
static _appendMessagePortal() {
|
|
@@ -126,8 +124,10 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
126
124
|
document.body.appendChild($portalTarget);
|
|
127
125
|
}
|
|
128
126
|
disconnectedCallback() {
|
|
127
|
+
var _a, _b;
|
|
129
128
|
super.disconnectedCallback();
|
|
130
|
-
|
|
129
|
+
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.open);
|
|
130
|
+
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this._closeFromEvent);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
tslib_es6.__decorate([
|
|
@@ -29,7 +29,7 @@ tslib_es6.__decorate([
|
|
|
29
29
|
tslib_es6.__metadata("design:type", Object)
|
|
30
30
|
], BaseMessageContent.prototype, "portalTarget", void 0);
|
|
31
31
|
tslib_es6.__decorate([
|
|
32
|
-
decorators.property({ type: String,
|
|
32
|
+
decorators.property({ type: String, attribute: 'message-id' }),
|
|
33
33
|
tslib_es6.__metadata("design:type", Object)
|
|
34
34
|
], BaseMessageContent.prototype, "messageId", void 0);
|
|
35
35
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IBaseMessage } from './base_message_types';
|
|
2
2
|
import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
|
|
3
3
|
import type { TDirection } from '@dreamcommerce/utilities';
|
|
4
|
+
import { PropertyValues } from 'lit';
|
|
4
5
|
export declare class BaseMessage extends PhoenixLightLitElement implements IBaseMessage {
|
|
5
6
|
opened: boolean;
|
|
6
7
|
portalTarget: string;
|
|
@@ -19,13 +20,14 @@ export declare class BaseMessage extends PhoenixLightLitElement implements IBase
|
|
|
19
20
|
private _$baseMessageContent?;
|
|
20
21
|
constructor();
|
|
21
22
|
connectedCallback(messageComponentName?: string): void;
|
|
23
|
+
firstUpdated(props: PropertyValues): void;
|
|
22
24
|
private _handleChildrenAriaAttributes;
|
|
23
25
|
private static _appendMessagePortal;
|
|
24
26
|
private _setupEventListeners;
|
|
25
27
|
protected _positionMessage: () => void;
|
|
26
|
-
private _toggleTooltipFromEvent;
|
|
27
28
|
open: () => void;
|
|
28
29
|
private _closeFromKeyboard;
|
|
29
|
-
|
|
30
|
+
private _closeFromEvent;
|
|
31
|
+
close: (shouldCloseImmediately?: boolean) => void;
|
|
30
32
|
disconnectedCallback(): void;
|
|
31
33
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import 'lit';
|
|
2
3
|
import { property } from 'lit/decorators';
|
|
3
4
|
import { DIRECTIONS } from '@dreamcommerce/utilities';
|
|
4
5
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
@@ -20,18 +21,22 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
20
21
|
if (!this._$baseMessageContent)
|
|
21
22
|
return;
|
|
22
23
|
[...this.children].forEach((child) => {
|
|
23
|
-
var _a;
|
|
24
24
|
if (LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()))
|
|
25
25
|
return;
|
|
26
|
-
|
|
26
|
+
if (this._$baseMessageContent)
|
|
27
|
+
child.setAttribute('aria-describedby', this._$baseMessageContent.messageId);
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
this._setupEventListeners = () => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var _a, _b;
|
|
32
|
+
this.addEventListener('mouseenter', this.open);
|
|
33
|
+
this.addEventListener('mouseleave', this._closeFromEvent);
|
|
34
|
+
this.addEventListener('keydown', this._closeFromKeyboard);
|
|
35
|
+
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.open);
|
|
36
|
+
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this._closeFromEvent);
|
|
32
37
|
if (!this.mouseonly) {
|
|
33
38
|
this.addEventListener('focusin', this.open);
|
|
34
|
-
this.addEventListener('focusout', this.
|
|
39
|
+
this.addEventListener('focusout', this._closeFromEvent);
|
|
35
40
|
}
|
|
36
41
|
};
|
|
37
42
|
this._positionMessage = () => {
|
|
@@ -40,19 +45,6 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
40
45
|
(_a = this._$messageContent) === null || _a === void 0 ? void 0 : _a.setAttribute('direction', this._positionController.position(true));
|
|
41
46
|
});
|
|
42
47
|
};
|
|
43
|
-
this._toggleTooltipFromEvent = (ev) => {
|
|
44
|
-
var _a;
|
|
45
|
-
if (!ev.target)
|
|
46
|
-
return;
|
|
47
|
-
const $target = ev.target;
|
|
48
|
-
const isInsideMessageContent = $target.closest && $target.closest(`[id="${(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.id}"]`);
|
|
49
|
-
const isInsideMessageContainer = !!this.contains($target);
|
|
50
|
-
if (!isInsideMessageContent && !isInsideMessageContainer) {
|
|
51
|
-
this.close();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.open();
|
|
55
|
-
};
|
|
56
48
|
this.open = () => {
|
|
57
49
|
this._tooltipOpenTime = Date.now();
|
|
58
50
|
clearTimeout(this._closeTimeout);
|
|
@@ -63,13 +55,16 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
63
55
|
}, MESSAGE_SHOW_DELAY_IN_MS);
|
|
64
56
|
};
|
|
65
57
|
this._closeFromKeyboard = (ev) => {
|
|
66
|
-
if (ev.key !== 'Escape')
|
|
58
|
+
if (ev.key !== 'Escape' || !this.opened)
|
|
67
59
|
return;
|
|
68
60
|
ev.preventDefault();
|
|
61
|
+
this.close(true);
|
|
62
|
+
};
|
|
63
|
+
this._closeFromEvent = () => {
|
|
69
64
|
this.close();
|
|
70
65
|
};
|
|
71
|
-
this.close = () => {
|
|
72
|
-
this._shouldDelayClosing = Date.now() - this._tooltipOpenTime > MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
66
|
+
this.close = (shouldCloseImmediately = false) => {
|
|
67
|
+
this._shouldDelayClosing = !shouldCloseImmediately && Date.now() - this._tooltipOpenTime > MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
73
68
|
clearTimeout(this._openTimeout);
|
|
74
69
|
if (!this.opened)
|
|
75
70
|
return;
|
|
@@ -90,7 +85,7 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
90
85
|
this._clickOutsideController = new ClickOutsideController({
|
|
91
86
|
host: this,
|
|
92
87
|
container: this,
|
|
93
|
-
action: this.
|
|
88
|
+
action: this._closeFromEvent
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
connectedCallback(messageComponentName = '') {
|
|
@@ -108,9 +103,12 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
108
103
|
offset: this.offset
|
|
109
104
|
});
|
|
110
105
|
this.setAttribute('tabindex', this.tabindex);
|
|
111
|
-
this._setupEventListeners();
|
|
112
106
|
if (!this._$baseMessageContent)
|
|
113
107
|
this._$baseMessageContent = [...this.children].find((child) => LIST_OF_MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
|
|
108
|
+
this._setupEventListeners();
|
|
109
|
+
}
|
|
110
|
+
firstUpdated(props) {
|
|
111
|
+
super.firstUpdated(props);
|
|
114
112
|
this._handleChildrenAriaAttributes();
|
|
115
113
|
}
|
|
116
114
|
static _appendMessagePortal() {
|
|
@@ -122,8 +120,10 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
122
120
|
document.body.appendChild($portalTarget);
|
|
123
121
|
}
|
|
124
122
|
disconnectedCallback() {
|
|
123
|
+
var _a, _b;
|
|
125
124
|
super.disconnectedCallback();
|
|
126
|
-
|
|
125
|
+
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.open);
|
|
126
|
+
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this._closeFromEvent);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
__decorate([
|
|
@@ -25,7 +25,7 @@ __decorate([
|
|
|
25
25
|
__metadata("design:type", Object)
|
|
26
26
|
], BaseMessageContent.prototype, "portalTarget", void 0);
|
|
27
27
|
__decorate([
|
|
28
|
-
property({ type: String,
|
|
28
|
+
property({ type: String, attribute: 'message-id' }),
|
|
29
29
|
__metadata("design:type", Object)
|
|
30
30
|
], BaseMessageContent.prototype, "messageId", void 0);
|
|
31
31
|
|
package/package.json
CHANGED