@nectary/labs 2.9.2 → 2.10.0
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/package.json
CHANGED
|
@@ -3,27 +3,19 @@ import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
|
3
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
4
|
const template = document.createElement("template");
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
6
|
-
console.log(template);
|
|
7
6
|
class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
8
7
|
#callAction;
|
|
9
8
|
#websiteAction;
|
|
10
9
|
#emailAction;
|
|
11
10
|
constructor() {
|
|
12
11
|
super();
|
|
13
|
-
console.log("[PhonePreviewRcsChannelActions] Constructor called");
|
|
14
12
|
const shadowRoot = this.attachShadow();
|
|
15
13
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
16
14
|
this.#callAction = shadowRoot.querySelector("#call-action");
|
|
17
15
|
this.#websiteAction = shadowRoot.querySelector("#website-action");
|
|
18
16
|
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
17
|
}
|
|
25
18
|
connectedCallback() {
|
|
26
|
-
console.log("[PhonePreviewRcsChannelActions] Connected to DOM");
|
|
27
19
|
super.connectedCallback();
|
|
28
20
|
this.#updateUI();
|
|
29
21
|
}
|
|
@@ -31,7 +23,6 @@ class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
|
31
23
|
return ["phone", "website", "email"];
|
|
32
24
|
}
|
|
33
25
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
-
console.log(`[PhonePreviewRcsChannelActions] Attribute "${name}" changed from "${oldVal}" to "${newVal}"`);
|
|
35
26
|
if (oldVal === newVal) {
|
|
36
27
|
return;
|
|
37
28
|
}
|
|
@@ -41,7 +32,6 @@ class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
|
41
32
|
return this.getAttribute("phone") ?? "";
|
|
42
33
|
}
|
|
43
34
|
set phone(value) {
|
|
44
|
-
console.log(`[PhonePreviewRcsChannelActions] Setting phone to "${value}"`);
|
|
45
35
|
if (value !== "") {
|
|
46
36
|
this.setAttribute("phone", value);
|
|
47
37
|
} else {
|
|
@@ -52,7 +42,6 @@ class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
|
52
42
|
return this.getAttribute("website") ?? "";
|
|
53
43
|
}
|
|
54
44
|
set website(value) {
|
|
55
|
-
console.log(`[PhonePreviewRcsChannelActions] Setting website to "${value}"`);
|
|
56
45
|
if (value !== "") {
|
|
57
46
|
this.setAttribute("website", value);
|
|
58
47
|
} else {
|
|
@@ -63,7 +52,6 @@ class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
|
63
52
|
return this.getAttribute("email") ?? "";
|
|
64
53
|
}
|
|
65
54
|
set email(value) {
|
|
66
|
-
console.log(`[PhonePreviewRcsChannelActions] Setting email to "${value}"`);
|
|
67
55
|
if (value !== "") {
|
|
68
56
|
this.setAttribute("email", value);
|
|
69
57
|
} else {
|
|
@@ -71,45 +59,32 @@ class PhonePreviewRcsChannelActions extends NectaryElement {
|
|
|
71
59
|
}
|
|
72
60
|
}
|
|
73
61
|
#updateUI() {
|
|
74
|
-
console.log("[PhonePreviewRcsChannelActions] Updating UI");
|
|
75
62
|
if (!this.isDomConnected) {
|
|
76
|
-
console.log("[PhonePreviewRcsChannelActions] DOM not connected, skipping UI update");
|
|
77
63
|
return;
|
|
78
64
|
}
|
|
79
65
|
const phoneNumber = this.phone;
|
|
80
66
|
const websiteUrl = this.website;
|
|
81
67
|
const emailAddress = this.email;
|
|
82
|
-
console.log("[PhonePreviewRcsChannelActions] Current values:", {
|
|
83
|
-
phone: phoneNumber,
|
|
84
|
-
website: websiteUrl,
|
|
85
|
-
email: emailAddress
|
|
86
|
-
});
|
|
87
68
|
if (phoneNumber !== "") {
|
|
88
69
|
this.#callAction.href = `tel:${phoneNumber}`;
|
|
89
70
|
this.#callAction.removeAttribute("inert");
|
|
90
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling call action with href: ${this.#callAction.href}`);
|
|
91
71
|
} else {
|
|
92
72
|
this.#callAction.href = "#";
|
|
93
73
|
this.#callAction.setAttribute("inert", "");
|
|
94
|
-
console.log("[PhonePreviewRcsChannelActions] Disabling call action");
|
|
95
74
|
}
|
|
96
75
|
if (websiteUrl !== "") {
|
|
97
76
|
this.#websiteAction.href = websiteUrl;
|
|
98
77
|
this.#websiteAction.removeAttribute("inert");
|
|
99
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling website action with href: ${this.#websiteAction.href}`);
|
|
100
78
|
} else {
|
|
101
79
|
this.#websiteAction.href = "#";
|
|
102
80
|
this.#websiteAction.setAttribute("inert", "");
|
|
103
|
-
console.log("[PhonePreviewRcsChannelActions] Disabling website action");
|
|
104
81
|
}
|
|
105
82
|
if (emailAddress !== "") {
|
|
106
83
|
this.#emailAction.href = `mailto:${emailAddress}`;
|
|
107
84
|
this.#emailAction.removeAttribute("inert");
|
|
108
|
-
console.log(`[PhonePreviewRcsChannelActions] Enabling email action with href: ${this.#emailAction.href}`);
|
|
109
85
|
} else {
|
|
110
86
|
this.#emailAction.href = "#";
|
|
111
87
|
this.#emailAction.setAttribute("inert", "");
|
|
112
|
-
console.log("[PhonePreviewRcsChannelActions] Disabling email action");
|
|
113
88
|
}
|
|
114
89
|
}
|
|
115
90
|
}
|
package/utils/element.js
CHANGED
|
@@ -5,18 +5,13 @@ const pkg = {
|
|
|
5
5
|
const nectaryDefinitions = /* @__PURE__ */ new Map();
|
|
6
6
|
let nectaryRegistry = null;
|
|
7
7
|
const defineCustomElement = (name, constructor) => {
|
|
8
|
-
console.log(`Defining custom element: ${name} nectaryRegistry`, nectaryRegistry);
|
|
9
8
|
if (nectaryRegistry !== null) {
|
|
10
9
|
if (nectaryRegistry.get(name) == null) {
|
|
11
10
|
nectaryRegistry.define(name, constructor);
|
|
12
|
-
console.log(`Custom element ${name} defined immediately`);
|
|
13
11
|
}
|
|
14
|
-
console.log(`Custom element ${name} already defined in registry`);
|
|
15
12
|
return;
|
|
16
13
|
}
|
|
17
14
|
nectaryDefinitions.set(name, constructor);
|
|
18
|
-
console.log(`Custom element ${name} queued for definition`);
|
|
19
|
-
console.log(`Current definitions queue: ${Array.from(nectaryDefinitions.keys()).join(", ")}`);
|
|
20
15
|
};
|
|
21
16
|
const setLabRegistry = (registry) => {
|
|
22
17
|
if (nectaryRegistry !== null) {
|
|
@@ -26,7 +21,6 @@ const setLabRegistry = (registry) => {
|
|
|
26
21
|
for (const [name, ctor] of nectaryDefinitions.entries()) {
|
|
27
22
|
if (nectaryRegistry.get(name) == null) {
|
|
28
23
|
nectaryRegistry.define(name, ctor);
|
|
29
|
-
console.log(`Custom element ${name} defined in registry`);
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
26
|
nectaryDefinitions.clear();
|