@nectary/labs 2.5.39 → 2.5.41
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/color-select/index.js +89 -88
- package/imports.d.ts +2 -0
- package/index.js +6 -5
- package/package.json +8 -7
- package/phone-preview/index.js +81 -89
- package/phone-preview-rcs-channel/index.js +158 -172
- package/phone-preview-rcs-channel-actions/index.js +108 -115
- package/phone-preview-rcs-channel-info/index.js +59 -61
- package/phone-preview-rcs-channel-info-option/index.js +94 -99
- package/phone-preview-rcs-channel-options/index.js +42 -42
- package/phone-preview-rcs-channel-tabs/index.js +74 -74
- package/phone-preview-rcs-chat/index.js +190 -73
- package/phone-preview-rcs-chat-message/index.js +40 -42
- package/utils/element.js +63 -54
- package/utils/index.js +7 -1
- package/vite.config.js +66 -0
|
@@ -1,175 +1,161 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { defineCustomElement, NectaryElement } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
const template = document.createElement(
|
|
1
|
+
import "@nectary/components/icon";
|
|
2
|
+
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
3
|
+
import "../phone-preview-rcs-channel-actions/index.js";
|
|
4
|
+
import "../phone-preview-rcs-channel-info/index.js";
|
|
5
|
+
import "../phone-preview-rcs-channel-info-option/index.js";
|
|
6
|
+
import "../phone-preview-rcs-channel-options/index.js";
|
|
7
|
+
import "../phone-preview-rcs-channel-tabs/index.js";
|
|
8
|
+
const templateHTML = '<style>\n:where(*, *::before, *::after) {\n box-sizing: border-box;\n padding: 0;\n border: 0;\n margin: 0;\n font: inherit;\n}\n\n:host {\n --banner-color: var(--sinch-sys-color-surface-tertiary-active);\n --logo-color: var(--sinch-sys-color-surface-secondary-default);\n\n display: flex;\n flex-flow: column;\n color: var(--sinch-sys-color-text-default);\n}\n\n#banner-img {\n block-size: 70px;\n margin-block-end: -40px;\n background: var(--banner-color);\n}\n\n#logo-img {\n block-size: 64px;\n inline-size: 64px;\n border-radius: 100%;\n background: var(--logo-color);\n align-self: center;\n}\n\n#brand-name {\n padding: 8px 24px;\n font: var(--sinch-sys-font-body-m);\n text-align: center;\n text-wrap: balance;\n word-wrap: break-word;\n}\n\n#brand-description {\n padding-inline: 24px;\n font: var(--sinch-sys-font-body-xs);\n text-align: center;\n text-wrap: balance;\n word-wrap: break-word;\n}\n\n#actions {\n align-self: center;\n padding-block: 32px 24px;\n}\n\n#tabs {\n padding-block-end: 8px;\n}\n\n#info-container {\n display: block;\n}\n\n#options-container {\n display: none;\n}\n</style>\n\n<img id="banner-img" alt="" />\n<img id="logo-img" alt="" />\n<h1 id="brand-name">Brand name</h1>\n<p id="brand-description">Brand description</p>\n<sinch-labs-phone-preview-rcs-channel-actions id="actions"></sinch-labs-phone-preview-rcs-channel-actions>\n<sinch-labs-phone-preview-rcs-channel-tabs id="tabs"></sinch-labs-phone-preview-rcs-channel-tabs>\n<sinch-labs-phone-preview-rcs-channel-info id="info-container">\n <slot name="contacts"></slot>\n</sinch-labs-phone-preview-rcs-channel-info>\n<sinch-labs-phone-preview-rcs-channel-options id="options-container"></sinch-labs-phone-preview-rcs-channel-options>\n';
|
|
9
|
+
const template = document.createElement("template");
|
|
10
10
|
template.innerHTML = templateHTML;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
11
|
+
class PhonePreviewRcsChannel extends NectaryElement {
|
|
12
|
+
#bannerImg;
|
|
13
|
+
#logoImg;
|
|
14
|
+
#brandName;
|
|
15
|
+
#brandDescription;
|
|
16
|
+
#actions;
|
|
17
|
+
#tabs;
|
|
18
|
+
#infoContainer;
|
|
19
|
+
#optionsContainer;
|
|
20
|
+
#controller = null;
|
|
21
|
+
#currentTab = 0;
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
const shadowRoot = this.attachShadow();
|
|
25
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
26
|
+
this.#bannerImg = shadowRoot.querySelector("#banner-img");
|
|
27
|
+
this.#logoImg = shadowRoot.querySelector("#logo-img");
|
|
28
|
+
this.#brandName = shadowRoot.querySelector("#brand-name");
|
|
29
|
+
this.#brandDescription = shadowRoot.querySelector("#brand-description");
|
|
30
|
+
this.#actions = shadowRoot.querySelector("#actions");
|
|
31
|
+
this.#tabs = shadowRoot.querySelector("#tabs");
|
|
32
|
+
this.#infoContainer = shadowRoot.querySelector("#info-container");
|
|
33
|
+
this.#optionsContainer = shadowRoot.querySelector("#options-container");
|
|
34
|
+
}
|
|
35
|
+
connectedCallback() {
|
|
36
|
+
super.connectedCallback();
|
|
37
|
+
this.#controller = new AbortController();
|
|
38
|
+
const { signal } = this.#controller;
|
|
39
|
+
this.#tabs.addEventListener("-tab-change", this.#onTabChange, { signal });
|
|
40
|
+
this.addEventListener("slotchange", this.#onSlotChange, { signal });
|
|
41
|
+
const observer = new MutationObserver(() => {
|
|
42
|
+
this.#updateActionsFromSlottedChildren();
|
|
43
|
+
});
|
|
44
|
+
observer.observe(this, { childList: true, subtree: true });
|
|
45
|
+
signal.addEventListener("abort", () => {
|
|
46
|
+
observer.disconnect();
|
|
47
|
+
});
|
|
48
|
+
this.#updateUI();
|
|
49
|
+
this.#updateTabContent();
|
|
50
|
+
}
|
|
51
|
+
disconnectedCallback() {
|
|
52
|
+
super.disconnectedCallback();
|
|
53
|
+
this.#controller?.abort();
|
|
54
|
+
this.#controller = null;
|
|
55
|
+
}
|
|
56
|
+
static get observedAttributes() {
|
|
57
|
+
return ["name", "description", "color", "banner", "logo"];
|
|
58
|
+
}
|
|
59
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
60
|
+
if (oldVal === newVal) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
switch (name) {
|
|
64
|
+
case "name":
|
|
65
|
+
case "description":
|
|
66
|
+
case "color":
|
|
67
|
+
case "banner":
|
|
68
|
+
case "logo":
|
|
51
69
|
this.#updateUI();
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (type === 'phone' && firstPhone === '') {
|
|
140
|
-
firstPhone = contact;
|
|
141
|
-
}
|
|
142
|
-
else if (type === 'website' && firstWebsite === '') {
|
|
143
|
-
firstWebsite = contact;
|
|
144
|
-
}
|
|
145
|
-
else if (type === 'email' && firstEmail === '') {
|
|
146
|
-
firstEmail = contact;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
this.#actions.setAttribute('phone', firstPhone);
|
|
150
|
-
this.#actions.setAttribute('website', firstWebsite);
|
|
151
|
-
this.#actions.setAttribute('email', firstEmail);
|
|
152
|
-
}
|
|
153
|
-
#updateTabContent() {
|
|
154
|
-
// No longer needed since we use slots
|
|
155
|
-
this.#updateTabVisibility();
|
|
156
|
-
}
|
|
157
|
-
#updateTabVisibility() {
|
|
158
|
-
if (this.#currentTab === 0) {
|
|
159
|
-
this.#infoContainer.style.display = 'block';
|
|
160
|
-
this.#optionsContainer.style.display = 'none';
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
this.#infoContainer.style.display = 'none';
|
|
164
|
-
this.#optionsContainer.style.display = 'block';
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
#onSlotChange = () => {
|
|
168
|
-
this.#updateActionsFromSlottedChildren();
|
|
169
|
-
};
|
|
170
|
-
#onTabChange = (event) => {
|
|
171
|
-
this.#currentTab = event.detail;
|
|
172
|
-
this.#updateTabVisibility();
|
|
173
|
-
};
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
get name() {
|
|
74
|
+
return this.getAttribute("name") ?? "";
|
|
75
|
+
}
|
|
76
|
+
set name(value) {
|
|
77
|
+
this.setAttribute("name", value);
|
|
78
|
+
}
|
|
79
|
+
get description() {
|
|
80
|
+
return this.getAttribute("description") ?? "";
|
|
81
|
+
}
|
|
82
|
+
set description(value) {
|
|
83
|
+
this.setAttribute("description", value);
|
|
84
|
+
}
|
|
85
|
+
get color() {
|
|
86
|
+
return this.getAttribute("color") ?? "";
|
|
87
|
+
}
|
|
88
|
+
set color(value) {
|
|
89
|
+
this.setAttribute("color", value);
|
|
90
|
+
}
|
|
91
|
+
get banner() {
|
|
92
|
+
return this.getAttribute("banner") ?? "";
|
|
93
|
+
}
|
|
94
|
+
set banner(value) {
|
|
95
|
+
this.setAttribute("banner", value);
|
|
96
|
+
}
|
|
97
|
+
get logo() {
|
|
98
|
+
return this.getAttribute("logo") ?? "";
|
|
99
|
+
}
|
|
100
|
+
set logo(value) {
|
|
101
|
+
this.setAttribute("logo", value);
|
|
102
|
+
}
|
|
103
|
+
#updateUI() {
|
|
104
|
+
if (!this.isDomConnected) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const transparentIcon = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
|
|
108
|
+
this.#bannerImg.src = this.banner !== "" ? this.banner : transparentIcon;
|
|
109
|
+
this.#logoImg.src = this.logo !== "" ? this.logo : transparentIcon;
|
|
110
|
+
this.#brandName.textContent = this.name !== "" ? this.name : "Brand name";
|
|
111
|
+
this.#brandDescription.textContent = this.description !== "" ? this.description : "Brand description";
|
|
112
|
+
if (this.color !== "") {
|
|
113
|
+
this.style.setProperty("--banner-color", this.color);
|
|
114
|
+
}
|
|
115
|
+
this.#updateActionsFromSlottedChildren();
|
|
116
|
+
this.#tabs.setAttribute("color", this.color);
|
|
117
|
+
}
|
|
118
|
+
#updateActionsFromSlottedChildren() {
|
|
119
|
+
const slottedElements = this.querySelectorAll("sinch-labs-phone-preview-rcs-channel-info-option");
|
|
120
|
+
let firstPhone = "";
|
|
121
|
+
let firstWebsite = "";
|
|
122
|
+
let firstEmail = "";
|
|
123
|
+
for (const element of slottedElements) {
|
|
124
|
+
const type = element.getAttribute("type");
|
|
125
|
+
const contact = element.getAttribute("contact") ?? "";
|
|
126
|
+
if (type === "phone" && firstPhone === "") {
|
|
127
|
+
firstPhone = contact;
|
|
128
|
+
} else if (type === "website" && firstWebsite === "") {
|
|
129
|
+
firstWebsite = contact;
|
|
130
|
+
} else if (type === "email" && firstEmail === "") {
|
|
131
|
+
firstEmail = contact;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
this.#actions.setAttribute("phone", firstPhone);
|
|
135
|
+
this.#actions.setAttribute("website", firstWebsite);
|
|
136
|
+
this.#actions.setAttribute("email", firstEmail);
|
|
137
|
+
}
|
|
138
|
+
#updateTabContent() {
|
|
139
|
+
this.#updateTabVisibility();
|
|
140
|
+
}
|
|
141
|
+
#updateTabVisibility() {
|
|
142
|
+
if (this.#currentTab === 0) {
|
|
143
|
+
this.#infoContainer.style.display = "block";
|
|
144
|
+
this.#optionsContainer.style.display = "none";
|
|
145
|
+
} else {
|
|
146
|
+
this.#infoContainer.style.display = "none";
|
|
147
|
+
this.#optionsContainer.style.display = "block";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
#onSlotChange = () => {
|
|
151
|
+
this.#updateActionsFromSlottedChildren();
|
|
152
|
+
};
|
|
153
|
+
#onTabChange = (event) => {
|
|
154
|
+
this.#currentTab = event.detail;
|
|
155
|
+
this.#updateTabVisibility();
|
|
156
|
+
};
|
|
174
157
|
}
|
|
175
|
-
defineCustomElement(
|
|
158
|
+
defineCustomElement("sinch-labs-phone-preview-rcs-channel", PhonePreviewRcsChannel);
|
|
159
|
+
export {
|
|
160
|
+
PhonePreviewRcsChannel
|
|
161
|
+
};
|
|
@@ -1,126 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { defineCustomElement, NectaryElement } from
|
|
3
|
-
|
|
4
|
-
const template = document.createElement(
|
|
1
|
+
import "@nectary/components/icon";
|
|
2
|
+
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
3
|
+
const templateHTML = '<style>\n:where(*, *::before, *::after) {\n box-sizing: border-box;\n padding: 0;\n border: 0;\n margin: 0;\n font: inherit;\n}\n\n.actions {\n display: grid;\n grid-auto-columns: 1fr;\n grid-auto-flow: column;\n gap: 24px;\n font: var(--sinch-sys-font-body-xs);\n}\n\n.actions > a {\n display: flex;\n flex-flow: column;\n align-items: center;\n gap: 2px;\n color: inherit;\n text-decoration: none;\n}\n\n.actions > a[inert] {\n --sinch-global-color-icon: currentcolor;\n\n color: var(--sinch-sys-color-text-muted);\n}\n</style>\n\n<section class="actions">\n <!-- Call button -->\n <a id="call-action" target="_blank">\n <sinch-icon icons-version="2" name="fa-phone" class="icon-link"></sinch-icon>\n Call\n </a>\n\n <!-- Website button -->\n <a id="website-action" target="_blank">\n <sinch-icon icons-version="2" name="fa-earth-americas" name="public" class="icon-link"></sinch-icon>\n Website\n </a>\n\n <!-- Email button -->\n <a id="email-action" target="_blank">\n <sinch-icon icons-version="2" name="envelope" name="mail" class="icon-link"></sinch-icon>\n Email\n </a>\n</section>\n';
|
|
4
|
+
const template = document.createElement("template");
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
6
6
|
console.log(template);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
8
|
+
#callAction;
|
|
9
|
+
#websiteAction;
|
|
10
|
+
#emailAction;
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
console.log("[PhonePreviewRcsChannelActions] Constructor called");
|
|
14
|
+
const shadowRoot = this.attachShadow();
|
|
15
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
16
|
+
this.#callAction = shadowRoot.querySelector("#call-action");
|
|
17
|
+
this.#websiteAction = shadowRoot.querySelector("#website-action");
|
|
18
|
+
this.#emailAction = shadowRoot.querySelector("#email-action");
|
|
19
|
+
console.log("[PhonePreviewRcsChannelActions] Elements queried:", {
|
|
20
|
+
callAction: this.#callAction,
|
|
21
|
+
websiteAction: this.#websiteAction,
|
|
22
|
+
emailAction: this.#emailAction
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
console.log("[PhonePreviewRcsChannelActions] Connected to DOM");
|
|
27
|
+
super.connectedCallback();
|
|
28
|
+
this.#updateUI();
|
|
29
|
+
}
|
|
30
|
+
static get observedAttributes() {
|
|
31
|
+
return ["phone", "website", "email"];
|
|
32
|
+
}
|
|
33
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
+
console.log(`[PhonePreviewRcsChannelActions] Attribute "${name}" changed from "${oldVal}" to "${newVal}"`);
|
|
35
|
+
if (oldVal === newVal) {
|
|
36
|
+
return;
|
|
24
37
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
this.#updateUI();
|
|
39
|
+
}
|
|
40
|
+
get phone() {
|
|
41
|
+
return this.getAttribute("phone") ?? "";
|
|
42
|
+
}
|
|
43
|
+
set phone(value) {
|
|
44
|
+
console.log(`[PhonePreviewRcsChannelActions] Setting phone to "${value}"`);
|
|
45
|
+
if (value !== "") {
|
|
46
|
+
this.setAttribute("phone", value);
|
|
47
|
+
} else {
|
|
48
|
+
this.removeAttribute("phone");
|
|
29
49
|
}
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
}
|
|
51
|
+
get website() {
|
|
52
|
+
return this.getAttribute("website") ?? "";
|
|
53
|
+
}
|
|
54
|
+
set website(value) {
|
|
55
|
+
console.log(`[PhonePreviewRcsChannelActions] Setting website to "${value}"`);
|
|
56
|
+
if (value !== "") {
|
|
57
|
+
this.setAttribute("website", value);
|
|
58
|
+
} else {
|
|
59
|
+
this.removeAttribute("website");
|
|
32
60
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
}
|
|
62
|
+
get email() {
|
|
63
|
+
return this.getAttribute("email") ?? "";
|
|
64
|
+
}
|
|
65
|
+
set email(value) {
|
|
66
|
+
console.log(`[PhonePreviewRcsChannelActions] Setting email to "${value}"`);
|
|
67
|
+
if (value !== "") {
|
|
68
|
+
this.setAttribute("email", value);
|
|
69
|
+
} else {
|
|
70
|
+
this.removeAttribute("email");
|
|
39
71
|
}
|
|
40
|
-
|
|
41
|
-
|
|
72
|
+
}
|
|
73
|
+
#updateUI() {
|
|
74
|
+
console.log("[PhonePreviewRcsChannelActions] Updating UI");
|
|
75
|
+
if (!this.isDomConnected) {
|
|
76
|
+
console.log("[PhonePreviewRcsChannelActions] DOM not connected, skipping UI update");
|
|
77
|
+
return;
|
|
42
78
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
79
|
+
const phoneNumber = this.phone;
|
|
80
|
+
const websiteUrl = this.website;
|
|
81
|
+
const emailAddress = this.email;
|
|
82
|
+
console.log("[PhonePreviewRcsChannelActions] Current values:", {
|
|
83
|
+
phone: phoneNumber,
|
|
84
|
+
website: websiteUrl,
|
|
85
|
+
email: emailAddress
|
|
86
|
+
});
|
|
87
|
+
if (phoneNumber !== "") {
|
|
88
|
+
this.#callAction.href = `tel:${phoneNumber}`;
|
|
89
|
+
this.#callAction.removeAttribute("inert");
|
|
90
|
+
console.log(`[PhonePreviewRcsChannelActions] Enabling call action with href: ${this.#callAction.href}`);
|
|
91
|
+
} else {
|
|
92
|
+
this.#callAction.href = "#";
|
|
93
|
+
this.#callAction.setAttribute("inert", "");
|
|
94
|
+
console.log("[PhonePreviewRcsChannelActions] Disabling call action");
|
|
51
95
|
}
|
|
52
|
-
|
|
53
|
-
|
|
96
|
+
if (websiteUrl !== "") {
|
|
97
|
+
this.#websiteAction.href = websiteUrl;
|
|
98
|
+
this.#websiteAction.removeAttribute("inert");
|
|
99
|
+
console.log(`[PhonePreviewRcsChannelActions] Enabling website action with href: ${this.#websiteAction.href}`);
|
|
100
|
+
} else {
|
|
101
|
+
this.#websiteAction.href = "#";
|
|
102
|
+
this.#websiteAction.setAttribute("inert", "");
|
|
103
|
+
console.log("[PhonePreviewRcsChannelActions] Disabling website action");
|
|
54
104
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
get email() {
|
|
65
|
-
return this.getAttribute('email') ?? '';
|
|
66
|
-
}
|
|
67
|
-
set email(value) {
|
|
68
|
-
console.log(`[PhonePreviewRcsChannelActions] Setting email to "${value}"`);
|
|
69
|
-
if (value !== '') {
|
|
70
|
-
this.setAttribute('email', value);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.removeAttribute('email');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
#updateUI() {
|
|
77
|
-
console.log('[PhonePreviewRcsChannelActions] Updating UI');
|
|
78
|
-
if (!this.isDomConnected) {
|
|
79
|
-
console.log('[PhonePreviewRcsChannelActions] DOM not connected, skipping UI update');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
// Get contact values directly as strings
|
|
83
|
-
const phoneNumber = this.phone;
|
|
84
|
-
const websiteUrl = this.website;
|
|
85
|
-
const emailAddress = this.email;
|
|
86
|
-
console.log('[PhonePreviewRcsChannelActions] Current values:', {
|
|
87
|
-
phone: phoneNumber,
|
|
88
|
-
website: websiteUrl,
|
|
89
|
-
email: emailAddress,
|
|
90
|
-
});
|
|
91
|
-
// Update call action
|
|
92
|
-
if (phoneNumber !== '') {
|
|
93
|
-
this.#callAction.href = `tel:${phoneNumber}`;
|
|
94
|
-
this.#callAction.removeAttribute('inert');
|
|
95
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling call action with href: ${this.#callAction.href}`);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.#callAction.href = '#';
|
|
99
|
-
this.#callAction.setAttribute('inert', '');
|
|
100
|
-
console.log('[PhonePreviewRcsChannelActions] Disabling call action');
|
|
101
|
-
}
|
|
102
|
-
// Update website action
|
|
103
|
-
if (websiteUrl !== '') {
|
|
104
|
-
this.#websiteAction.href = websiteUrl;
|
|
105
|
-
this.#websiteAction.removeAttribute('inert');
|
|
106
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling website action with href: ${this.#websiteAction.href}`);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
this.#websiteAction.href = '#';
|
|
110
|
-
this.#websiteAction.setAttribute('inert', '');
|
|
111
|
-
console.log('[PhonePreviewRcsChannelActions] Disabling website action');
|
|
112
|
-
}
|
|
113
|
-
// Update email action
|
|
114
|
-
if (emailAddress !== '') {
|
|
115
|
-
this.#emailAction.href = `mailto:${emailAddress}`;
|
|
116
|
-
this.#emailAction.removeAttribute('inert');
|
|
117
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling email action with href: ${this.#emailAction.href}`);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
this.#emailAction.href = '#';
|
|
121
|
-
this.#emailAction.setAttribute('inert', '');
|
|
122
|
-
console.log('[PhonePreviewRcsChannelActions] Disabling email action');
|
|
123
|
-
}
|
|
105
|
+
if (emailAddress !== "") {
|
|
106
|
+
this.#emailAction.href = `mailto:${emailAddress}`;
|
|
107
|
+
this.#emailAction.removeAttribute("inert");
|
|
108
|
+
console.log(`[PhonePreviewRcsChannelActions] Enabling email action with href: ${this.#emailAction.href}`);
|
|
109
|
+
} else {
|
|
110
|
+
this.#emailAction.href = "#";
|
|
111
|
+
this.#emailAction.setAttribute("inert", "");
|
|
112
|
+
console.log("[PhonePreviewRcsChannelActions] Disabling email action");
|
|
124
113
|
}
|
|
114
|
+
}
|
|
125
115
|
}
|
|
126
|
-
defineCustomElement(
|
|
116
|
+
defineCustomElement("sinch-labs-phone-preview-rcs-channel-actions", PhonePreviewRcsChannelActions);
|
|
117
|
+
export {
|
|
118
|
+
PhonePreviewRcsChannelActions
|
|
119
|
+
};
|