@nectary/labs 2.13.4 → 2.14.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/color-select/index.d.ts +3 -6
- package/color-select/types.d.ts +6 -0
- package/color-select/types.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -2
- package/phone-preview/index.d.ts +3 -6
- package/phone-preview/index.js +20 -3
- package/phone-preview/template.html +48 -30
- package/phone-preview/types.d.ts +6 -0
- package/phone-preview/types.js +1 -0
- package/phone-preview-rcs-channel/index.d.ts +4 -12
- package/phone-preview-rcs-channel/index.js +7 -18
- package/phone-preview-rcs-channel/types.d.ts +16 -0
- package/phone-preview-rcs-channel/types.js +1 -0
- package/phone-preview-rcs-channel-actions/index.d.ts +3 -8
- package/phone-preview-rcs-channel-actions/types.d.ts +10 -0
- package/phone-preview-rcs-channel-actions/types.js +1 -0
- package/phone-preview-rcs-channel-info/index.d.ts +3 -3
- package/phone-preview-rcs-channel-info/types.d.ts +1 -0
- package/phone-preview-rcs-channel-info/types.js +1 -0
- package/phone-preview-rcs-channel-info-option/index.d.ts +3 -8
- package/phone-preview-rcs-channel-info-option/types.d.ts +10 -0
- package/phone-preview-rcs-channel-info-option/types.js +1 -0
- package/phone-preview-rcs-channel-options/index.d.ts +3 -3
- package/phone-preview-rcs-channel-options/types.d.ts +1 -0
- package/phone-preview-rcs-channel-options/types.js +1 -0
- package/phone-preview-rcs-channel-tabs/index.d.ts +3 -6
- package/phone-preview-rcs-channel-tabs/index.js +2 -6
- package/phone-preview-rcs-channel-tabs/template.html +1 -1
- package/phone-preview-rcs-channel-tabs/types.d.ts +6 -0
- package/phone-preview-rcs-channel-tabs/types.js +1 -0
- package/phone-preview-rcs-chat/index.d.ts +3 -7
- package/phone-preview-rcs-chat/types.d.ts +8 -0
- package/phone-preview-rcs-chat/types.js +1 -0
- package/phone-preview-rcs-chat-message/index.d.ts +3 -6
- package/phone-preview-rcs-chat-message/types.d.ts +6 -0
- package/phone-preview-rcs-chat-message/types.js +1 -0
- package/phone-preview-whatsapp-channel/index.d.ts +47 -0
- package/phone-preview-whatsapp-channel/index.js +134 -0
- package/phone-preview-whatsapp-channel/template.html +181 -0
- package/phone-preview-whatsapp-channel/types.d.ts +18 -0
- package/phone-preview-whatsapp-channel/types.js +1 -0
- package/phone-preview-whatsapp-channel-account/index.d.ts +31 -0
- package/phone-preview-whatsapp-channel-account/index.js +60 -0
- package/phone-preview-whatsapp-channel-account/template.html +58 -0
- package/phone-preview-whatsapp-channel-account/types.d.ts +6 -0
- package/phone-preview-whatsapp-channel-account/types.js +1 -0
- package/phone-preview-whatsapp-channel-actions/index.d.ts +31 -0
- package/phone-preview-whatsapp-channel-actions/index.js +52 -0
- package/phone-preview-whatsapp-channel-actions/template.html +47 -0
- package/phone-preview-whatsapp-channel-actions/types.d.ts +6 -0
- package/phone-preview-whatsapp-channel-actions/types.js +1 -0
- package/phone-preview-whatsapp-channel-info/index.d.ts +22 -0
- package/phone-preview-whatsapp-channel-info/index.js +15 -0
- package/phone-preview-whatsapp-channel-info/template.html +25 -0
- package/phone-preview-whatsapp-channel-info/types.d.ts +1 -0
- package/phone-preview-whatsapp-channel-info/types.js +1 -0
- package/phone-preview-whatsapp-channel-info-option/index.d.ts +32 -0
- package/phone-preview-whatsapp-channel-info-option/index.js +60 -0
- package/phone-preview-whatsapp-channel-info-option/template.html +34 -0
- package/phone-preview-whatsapp-channel-info-option/types.d.ts +9 -0
- package/phone-preview-whatsapp-channel-info-option/types.js +1 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import '@nectary/components/icon';
|
|
2
2
|
import { NectaryElement } from '../utils';
|
|
3
3
|
import '../phone-preview-rcs-chat-message';
|
|
4
|
+
import type { PhonePreviewRcsChatProps } from './types';
|
|
4
5
|
import type React from 'react';
|
|
6
|
+
export * from './types';
|
|
5
7
|
/**
|
|
6
8
|
* RCS chat preview component.
|
|
7
9
|
*
|
|
@@ -22,13 +24,8 @@ export declare class RcsChatPreview extends NectaryElement {
|
|
|
22
24
|
get logo(): string;
|
|
23
25
|
set logo(value: string);
|
|
24
26
|
}
|
|
25
|
-
type Props = {
|
|
26
|
-
name?: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
logo?: string;
|
|
29
|
-
};
|
|
30
27
|
type ElementProps = Partial<{
|
|
31
|
-
[K in keyof
|
|
28
|
+
[K in keyof PhonePreviewRcsChatProps]: PhonePreviewRcsChatProps[K] | string;
|
|
32
29
|
}>;
|
|
33
30
|
declare global {
|
|
34
31
|
interface HTMLElementTagNameMap {
|
|
@@ -42,4 +39,3 @@ declare module 'react' {
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NectaryElement } from '../utils';
|
|
2
|
+
import type { PhonePreviewRcsChatMessageProps } from './types';
|
|
2
3
|
import type React from 'react';
|
|
4
|
+
export * from './types';
|
|
3
5
|
/**
|
|
4
6
|
* Individual RCS chat message component.
|
|
5
7
|
*
|
|
@@ -16,12 +18,8 @@ export declare class RcsChatMessage extends NectaryElement {
|
|
|
16
18
|
get direction(): 'in' | 'out';
|
|
17
19
|
set direction(value: 'in' | 'out');
|
|
18
20
|
}
|
|
19
|
-
type Props = {
|
|
20
|
-
direction?: 'in' | 'out';
|
|
21
|
-
text?: string;
|
|
22
|
-
};
|
|
23
21
|
type ElementProps = Partial<{
|
|
24
|
-
[K in keyof
|
|
22
|
+
[K in keyof PhonePreviewRcsChatMessageProps]: PhonePreviewRcsChatMessageProps[K] | string;
|
|
25
23
|
}>;
|
|
26
24
|
declare global {
|
|
27
25
|
interface HTMLElementTagNameMap {
|
|
@@ -35,4 +33,3 @@ declare module 'react' {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import '@nectary/components/icon';
|
|
2
|
+
import { NectaryElement } from '../utils';
|
|
3
|
+
import '../phone-preview-whatsapp-channel-account';
|
|
4
|
+
import '../phone-preview-whatsapp-channel-actions';
|
|
5
|
+
import '../phone-preview-whatsapp-channel-info';
|
|
6
|
+
import '../phone-preview-whatsapp-channel-info-option';
|
|
7
|
+
import type { PhonePreviewWhatsAppChannelProps } from './types';
|
|
8
|
+
import type React from 'react';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export declare class PhonePreviewWhatsAppChannel extends NectaryElement {
|
|
11
|
+
#private;
|
|
12
|
+
constructor();
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
static get observedAttributes(): string[];
|
|
15
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
16
|
+
get name(): string;
|
|
17
|
+
set name(value: string);
|
|
18
|
+
get phone(): string;
|
|
19
|
+
set phone(value: string);
|
|
20
|
+
get username(): string;
|
|
21
|
+
set username(value: string);
|
|
22
|
+
get logo(): string;
|
|
23
|
+
set logo(value: string);
|
|
24
|
+
get verified(): boolean;
|
|
25
|
+
set verified(value: boolean);
|
|
26
|
+
get heading(): string;
|
|
27
|
+
set heading(value: string);
|
|
28
|
+
get shareLabel(): string;
|
|
29
|
+
set shareLabel(value: string);
|
|
30
|
+
get searchLabel(): string;
|
|
31
|
+
set searchLabel(value: string);
|
|
32
|
+
}
|
|
33
|
+
type WhatsAppChannelElementProps = Partial<{
|
|
34
|
+
[K in keyof PhonePreviewWhatsAppChannelProps]: PhonePreviewWhatsAppChannelProps[K] | string;
|
|
35
|
+
}>;
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'sinch-labs-phone-preview-whatsapp-channel': WhatsAppChannelElementProps & HTMLElement;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
declare module 'react' {
|
|
42
|
+
namespace JSX {
|
|
43
|
+
interface IntrinsicElements {
|
|
44
|
+
'sinch-labs-phone-preview-whatsapp-channel': WhatsAppChannelElementProps & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import "@nectary/components/icon";
|
|
2
|
+
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
3
|
+
import "../phone-preview-whatsapp-channel-account/index.js";
|
|
4
|
+
import "../phone-preview-whatsapp-channel-actions/index.js";
|
|
5
|
+
import "../phone-preview-whatsapp-channel-info/index.js";
|
|
6
|
+
import "../phone-preview-whatsapp-channel-info-option/index.js";
|
|
7
|
+
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 --whatsapp-color: #008069;\n --phone-preview-channel-background: #F4F4F4;\n\n min-block-size: 100%;\n display: block;\n color: var(--sinch-sys-color-text-default);\n}\n\n.channel {\n display: flex;\n flex-flow: column;\n gap: 8px;\n padding: 0 4px 12px;\n}\n\n.top-bar {\n min-block-size: 32px;\n display: grid;\n grid-template-columns: 32px 1fr 32px;\n align-items: center;\n}\n\n.top-bar #back {\n --sinch-global-size-icon: 16px;\n\n inline-size: 32px;\n block-size: 32px;\n display: grid;\n place-items: center;\n}\n\n.top-bar h1 {\n grid-column: 2;\n font: var(--sinch-sys-font-body-emphasize-xs);\n text-align: center;\n}\n\n.identity {\n display: flex;\n flex-flow: column;\n align-items: center;\n padding: 10px 10px 2px;\n text-align: center;\n}\n\n#logo {\n --sinch-global-color-icon: var(--sinch-sys-color-surface-primary-default);\n --sinch-global-size-icon: 28px;\n\n inline-size: 80px;\n block-size: 80px;\n display: grid;\n place-items: center;\n margin-block-end: 6px;\n border-radius: 100%;\n background-color: var(--sinch-sys-color-surface-tertiary-active);\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n}\n\n.name-row {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n}\n\n#name {\n max-inline-size: 210px;\n overflow-wrap: anywhere;\n font: var(--sinch-sys-font-body-emphasize);\n}\n\n#verified {\n --sinch-global-color-icon: white;\n --sinch-global-size-icon: 12px;\n\n inline-size: 16px;\n block-size: 16px;\n display: grid;\n flex: none;\n place-items: center;\n background: #1d9bf0;\n clip-path:\n polygon(\n 50% 0%,\n 61% 8%,\n 72% 4%,\n 78% 16%,\n 91% 17%,\n 91% 31%,\n 100% 40%,\n 94% 50%,\n 100% 60%,\n 91% 69%,\n 91% 83%,\n 78% 84%,\n 72% 96%,\n 61% 92%,\n 50% 100%,\n 39% 92%,\n 28% 96%,\n 22% 84%,\n 9% 83%,\n 9% 69%,\n 0% 60%,\n 6% 50%,\n 0% 40%,\n 9% 31%,\n 9% 17%,\n 22% 16%,\n 28% 4%,\n 39% 8%\n );\n}\n\n#phone,\n#username {\n max-inline-size: 220px;\n color: var(--sinch-sys-color-text-muted);\n overflow-wrap: anywhere;\n font: var(--sinch-sys-font-body-xs);\n}\n\n#username {\n margin-block-start: -2px;\n}\n\n#actions,\n#info {\n inline-size: 100%;\n}\n\n[hidden] {\n display: none !important;\n}\n</style>\n\n<section class="channel">\n <header class="top-bar">\n <span id="back" aria-hidden="true">\n <sinch-icon icons-version="2" name="chevron-left"></sinch-icon>\n </span>\n <h1 id="heading">Business info</h1>\n </header>\n\n <section class="identity">\n <div id="logo">\n <sinch-icon aria-hidden="true" id="logo-placeholder" icons-version="2" name="image"></sinch-icon>\n </div>\n <div class="name-row">\n <h2 id="name">Display name</h2>\n <span id="verified" role="img" aria-label="Verified" hidden>\n <sinch-icon icons-version="2" name="check"></sinch-icon>\n </span>\n </div>\n <p id="phone">Phone number</p>\n <p id="username" hidden></p>\n </section>\n\n <sinch-labs-phone-preview-whatsapp-channel-actions\n id="actions"\n ></sinch-labs-phone-preview-whatsapp-channel-actions>\n\n <sinch-labs-phone-preview-whatsapp-channel-info id="info">\n <slot name="information"></slot>\n </sinch-labs-phone-preview-whatsapp-channel-info>\n\n <slot name="account"></slot>\n</section>\n';
|
|
8
|
+
const template = document.createElement("template");
|
|
9
|
+
template.innerHTML = templateHTML;
|
|
10
|
+
const DEFAULT_NAME = "Display name";
|
|
11
|
+
const DEFAULT_PHONE = "Phone number";
|
|
12
|
+
const DEFAULT_HEADING = "Business info";
|
|
13
|
+
const DEFAULT_SHARE_LABEL = "Share";
|
|
14
|
+
const DEFAULT_SEARCH_LABEL = "Search";
|
|
15
|
+
class PhonePreviewWhatsAppChannel extends NectaryElement {
|
|
16
|
+
#heading;
|
|
17
|
+
#logo;
|
|
18
|
+
#logoPlaceholder;
|
|
19
|
+
#name;
|
|
20
|
+
#verified;
|
|
21
|
+
#phone;
|
|
22
|
+
#username;
|
|
23
|
+
#actions;
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
const shadowRoot = this.attachShadow();
|
|
27
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
28
|
+
this.#heading = shadowRoot.querySelector("#heading");
|
|
29
|
+
this.#logo = shadowRoot.querySelector("#logo");
|
|
30
|
+
this.#logoPlaceholder = shadowRoot.querySelector("#logo-placeholder");
|
|
31
|
+
this.#name = shadowRoot.querySelector("#name");
|
|
32
|
+
this.#verified = shadowRoot.querySelector("#verified");
|
|
33
|
+
this.#phone = shadowRoot.querySelector("#phone");
|
|
34
|
+
this.#username = shadowRoot.querySelector("#username");
|
|
35
|
+
this.#actions = shadowRoot.querySelector("#actions");
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
this.#updateUI();
|
|
40
|
+
}
|
|
41
|
+
static get observedAttributes() {
|
|
42
|
+
return [
|
|
43
|
+
"name",
|
|
44
|
+
"phone",
|
|
45
|
+
"username",
|
|
46
|
+
"logo",
|
|
47
|
+
"verified",
|
|
48
|
+
"heading",
|
|
49
|
+
"share-label",
|
|
50
|
+
"search-label",
|
|
51
|
+
// React versions that serialize unknown camelCase props use these names.
|
|
52
|
+
"sharelabel",
|
|
53
|
+
"searchlabel"
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
57
|
+
if (oldVal === newVal) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.#updateUI();
|
|
61
|
+
}
|
|
62
|
+
get name() {
|
|
63
|
+
return this.getAttribute("name") ?? DEFAULT_NAME;
|
|
64
|
+
}
|
|
65
|
+
set name(value) {
|
|
66
|
+
this.setAttribute("name", value);
|
|
67
|
+
}
|
|
68
|
+
get phone() {
|
|
69
|
+
return this.getAttribute("phone") ?? DEFAULT_PHONE;
|
|
70
|
+
}
|
|
71
|
+
set phone(value) {
|
|
72
|
+
this.setAttribute("phone", value);
|
|
73
|
+
}
|
|
74
|
+
get username() {
|
|
75
|
+
return this.getAttribute("username") ?? "";
|
|
76
|
+
}
|
|
77
|
+
set username(value) {
|
|
78
|
+
this.setAttribute("username", value);
|
|
79
|
+
}
|
|
80
|
+
get logo() {
|
|
81
|
+
return this.getAttribute("logo") ?? "";
|
|
82
|
+
}
|
|
83
|
+
set logo(value) {
|
|
84
|
+
this.setAttribute("logo", value);
|
|
85
|
+
}
|
|
86
|
+
get verified() {
|
|
87
|
+
return this.hasAttribute("verified");
|
|
88
|
+
}
|
|
89
|
+
set verified(value) {
|
|
90
|
+
if (value) {
|
|
91
|
+
this.setAttribute("verified", "");
|
|
92
|
+
} else {
|
|
93
|
+
this.removeAttribute("verified");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
get heading() {
|
|
97
|
+
return this.getAttribute("heading") ?? DEFAULT_HEADING;
|
|
98
|
+
}
|
|
99
|
+
set heading(value) {
|
|
100
|
+
this.setAttribute("heading", value);
|
|
101
|
+
}
|
|
102
|
+
get shareLabel() {
|
|
103
|
+
return this.getAttribute("share-label") ?? this.getAttribute("sharelabel") ?? DEFAULT_SHARE_LABEL;
|
|
104
|
+
}
|
|
105
|
+
set shareLabel(value) {
|
|
106
|
+
this.setAttribute("share-label", value);
|
|
107
|
+
}
|
|
108
|
+
get searchLabel() {
|
|
109
|
+
return this.getAttribute("search-label") ?? this.getAttribute("searchlabel") ?? DEFAULT_SEARCH_LABEL;
|
|
110
|
+
}
|
|
111
|
+
set searchLabel(value) {
|
|
112
|
+
this.setAttribute("search-label", value);
|
|
113
|
+
}
|
|
114
|
+
#updateUI() {
|
|
115
|
+
if (!this.isDomConnected) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const hasLogo = this.logo !== "";
|
|
119
|
+
this.#heading.textContent = this.heading;
|
|
120
|
+
this.#logo.style.backgroundImage = hasLogo ? `url(${JSON.stringify(this.logo)})` : "";
|
|
121
|
+
this.#logoPlaceholder.hidden = hasLogo;
|
|
122
|
+
this.#name.textContent = this.name;
|
|
123
|
+
this.#verified.hidden = !this.verified;
|
|
124
|
+
this.#phone.textContent = this.phone;
|
|
125
|
+
this.#username.textContent = this.username;
|
|
126
|
+
this.#username.hidden = this.username === "";
|
|
127
|
+
this.#actions.setAttribute("share-label", this.shareLabel);
|
|
128
|
+
this.#actions.setAttribute("search-label", this.searchLabel);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
defineCustomElement("sinch-labs-phone-preview-whatsapp-channel", PhonePreviewWhatsAppChannel);
|
|
132
|
+
export {
|
|
133
|
+
PhonePreviewWhatsAppChannel
|
|
134
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
:where(*, *::before, *::after) {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
padding: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
margin: 0;
|
|
7
|
+
font: inherit;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host {
|
|
11
|
+
--whatsapp-color: #008069;
|
|
12
|
+
--phone-preview-channel-background: #F4F4F4;
|
|
13
|
+
|
|
14
|
+
min-block-size: 100%;
|
|
15
|
+
display: block;
|
|
16
|
+
color: var(--sinch-sys-color-text-default);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.channel {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-flow: column;
|
|
22
|
+
gap: 8px;
|
|
23
|
+
padding: 0 4px 12px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.top-bar {
|
|
27
|
+
min-block-size: 32px;
|
|
28
|
+
display: grid;
|
|
29
|
+
grid-template-columns: 32px 1fr 32px;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.top-bar #back {
|
|
34
|
+
--sinch-global-size-icon: 16px;
|
|
35
|
+
|
|
36
|
+
inline-size: 32px;
|
|
37
|
+
block-size: 32px;
|
|
38
|
+
display: grid;
|
|
39
|
+
place-items: center;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.top-bar h1 {
|
|
43
|
+
grid-column: 2;
|
|
44
|
+
font: var(--sinch-sys-font-body-emphasize-xs);
|
|
45
|
+
text-align: center;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.identity {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-flow: column;
|
|
51
|
+
align-items: center;
|
|
52
|
+
padding: 10px 10px 2px;
|
|
53
|
+
text-align: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#logo {
|
|
57
|
+
--sinch-global-color-icon: var(--sinch-sys-color-surface-primary-default);
|
|
58
|
+
--sinch-global-size-icon: 28px;
|
|
59
|
+
|
|
60
|
+
inline-size: 80px;
|
|
61
|
+
block-size: 80px;
|
|
62
|
+
display: grid;
|
|
63
|
+
place-items: center;
|
|
64
|
+
margin-block-end: 6px;
|
|
65
|
+
border-radius: 100%;
|
|
66
|
+
background-color: var(--sinch-sys-color-surface-tertiary-active);
|
|
67
|
+
background-position: center;
|
|
68
|
+
background-repeat: no-repeat;
|
|
69
|
+
background-size: cover;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.name-row {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
gap: 4px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#name {
|
|
80
|
+
max-inline-size: 210px;
|
|
81
|
+
overflow-wrap: anywhere;
|
|
82
|
+
font: var(--sinch-sys-font-body-emphasize);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#verified {
|
|
86
|
+
--sinch-global-color-icon: white;
|
|
87
|
+
--sinch-global-size-icon: 12px;
|
|
88
|
+
|
|
89
|
+
inline-size: 16px;
|
|
90
|
+
block-size: 16px;
|
|
91
|
+
display: grid;
|
|
92
|
+
flex: none;
|
|
93
|
+
place-items: center;
|
|
94
|
+
background: #1d9bf0;
|
|
95
|
+
clip-path:
|
|
96
|
+
polygon(
|
|
97
|
+
50% 0%,
|
|
98
|
+
61% 8%,
|
|
99
|
+
72% 4%,
|
|
100
|
+
78% 16%,
|
|
101
|
+
91% 17%,
|
|
102
|
+
91% 31%,
|
|
103
|
+
100% 40%,
|
|
104
|
+
94% 50%,
|
|
105
|
+
100% 60%,
|
|
106
|
+
91% 69%,
|
|
107
|
+
91% 83%,
|
|
108
|
+
78% 84%,
|
|
109
|
+
72% 96%,
|
|
110
|
+
61% 92%,
|
|
111
|
+
50% 100%,
|
|
112
|
+
39% 92%,
|
|
113
|
+
28% 96%,
|
|
114
|
+
22% 84%,
|
|
115
|
+
9% 83%,
|
|
116
|
+
9% 69%,
|
|
117
|
+
0% 60%,
|
|
118
|
+
6% 50%,
|
|
119
|
+
0% 40%,
|
|
120
|
+
9% 31%,
|
|
121
|
+
9% 17%,
|
|
122
|
+
22% 16%,
|
|
123
|
+
28% 4%,
|
|
124
|
+
39% 8%
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
#phone,
|
|
129
|
+
#username {
|
|
130
|
+
max-inline-size: 220px;
|
|
131
|
+
color: var(--sinch-sys-color-text-muted);
|
|
132
|
+
overflow-wrap: anywhere;
|
|
133
|
+
font: var(--sinch-sys-font-body-xs);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#username {
|
|
137
|
+
margin-block-start: -2px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#actions,
|
|
141
|
+
#info {
|
|
142
|
+
inline-size: 100%;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
[hidden] {
|
|
146
|
+
display: none !important;
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
149
|
+
|
|
150
|
+
<section class="channel">
|
|
151
|
+
<header class="top-bar">
|
|
152
|
+
<span id="back" aria-hidden="true">
|
|
153
|
+
<sinch-icon icons-version="2" name="chevron-left"></sinch-icon>
|
|
154
|
+
</span>
|
|
155
|
+
<h1 id="heading">Business info</h1>
|
|
156
|
+
</header>
|
|
157
|
+
|
|
158
|
+
<section class="identity">
|
|
159
|
+
<div id="logo">
|
|
160
|
+
<sinch-icon aria-hidden="true" id="logo-placeholder" icons-version="2" name="image"></sinch-icon>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="name-row">
|
|
163
|
+
<h2 id="name">Display name</h2>
|
|
164
|
+
<span id="verified" role="img" aria-label="Verified" hidden>
|
|
165
|
+
<sinch-icon icons-version="2" name="check"></sinch-icon>
|
|
166
|
+
</span>
|
|
167
|
+
</div>
|
|
168
|
+
<p id="phone">Phone number</p>
|
|
169
|
+
<p id="username" hidden></p>
|
|
170
|
+
</section>
|
|
171
|
+
|
|
172
|
+
<sinch-labs-phone-preview-whatsapp-channel-actions
|
|
173
|
+
id="actions"
|
|
174
|
+
></sinch-labs-phone-preview-whatsapp-channel-actions>
|
|
175
|
+
|
|
176
|
+
<sinch-labs-phone-preview-whatsapp-channel-info id="info">
|
|
177
|
+
<slot name="information"></slot>
|
|
178
|
+
</sinch-labs-phone-preview-whatsapp-channel-info>
|
|
179
|
+
|
|
180
|
+
<slot name="account"></slot>
|
|
181
|
+
</section>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PhonePreviewWhatsAppChannelProps = {
|
|
2
|
+
/** Business display name. */
|
|
3
|
+
name?: string;
|
|
4
|
+
/** Business phone number. */
|
|
5
|
+
phone?: string;
|
|
6
|
+
/** Optional WhatsApp username. */
|
|
7
|
+
username?: string;
|
|
8
|
+
/** URL of the business logo. */
|
|
9
|
+
logo?: string;
|
|
10
|
+
/** Displays the verified business badge. */
|
|
11
|
+
verified?: boolean;
|
|
12
|
+
/** Heading shown in the profile header. */
|
|
13
|
+
heading?: string;
|
|
14
|
+
/** Label shown below the share action. */
|
|
15
|
+
shareLabel?: string;
|
|
16
|
+
/** Label shown below the search action. */
|
|
17
|
+
searchLabel?: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import '@nectary/components/icon';
|
|
2
|
+
import { NectaryElement } from '../utils';
|
|
3
|
+
import type { PhonePreviewWhatsAppChannelAccountProps } from './types';
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export declare class PhonePreviewWhatsAppChannelAccount extends NectaryElement {
|
|
7
|
+
#private;
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
12
|
+
get heading(): string;
|
|
13
|
+
set heading(value: string);
|
|
14
|
+
get description(): string;
|
|
15
|
+
set description(value: string);
|
|
16
|
+
}
|
|
17
|
+
type ElementProps = Partial<{
|
|
18
|
+
[K in keyof PhonePreviewWhatsAppChannelAccountProps]: PhonePreviewWhatsAppChannelAccountProps[K] | string;
|
|
19
|
+
}>;
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sinch-labs-phone-preview-whatsapp-channel-account': ElementProps & HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module 'react' {
|
|
26
|
+
namespace JSX {
|
|
27
|
+
interface IntrinsicElements {
|
|
28
|
+
'sinch-labs-phone-preview-whatsapp-channel-account': ElementProps & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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:host {\n display: block;\n overflow: hidden;\n border-radius: 6px;\n background: var(--sinch-sys-color-surface-primary-default);\n color: var(--sinch-sys-color-text-default);\n}\n\n.account {\n min-block-size: 64px;\n display: grid;\n grid-template-columns: 20px minmax(0, 1fr) 16px;\n align-items: center;\n gap: 8px;\n padding: 8px 12px;\n}\n\n.info-icon {\n --sinch-global-size-icon: 18px;\n}\n\n.content {\n min-inline-size: 0;\n}\n\n#heading {\n font: var(--sinch-sys-font-body-xs);\n}\n\n#description {\n color: var(--sinch-sys-color-text-muted);\n overflow-wrap: anywhere;\n font: var(--sinch-sys-font-body-xxs);\n}\n\n.chevron {\n --sinch-global-color-icon: var(--sinch-sys-color-text-disabled);\n --sinch-global-size-icon: 16px;\n}\n</style>\n\n<section class="account">\n <sinch-icon aria-hidden="true" class="info-icon" icons-version="2" name="fa-circle-info"></sinch-icon>\n <div class="content">\n <h2 id="heading">Business Account</h2>\n <p id="description">This account uses WhatsApp Business</p>\n </div>\n <sinch-icon aria-hidden="true" class="chevron" icons-version="2" name="chevron-right"></sinch-icon>\n</section>\n';
|
|
4
|
+
const template = document.createElement("template");
|
|
5
|
+
template.innerHTML = templateHTML;
|
|
6
|
+
const monthYearFormatter = new Intl.DateTimeFormat("en-US", {
|
|
7
|
+
month: "long",
|
|
8
|
+
year: "numeric"
|
|
9
|
+
});
|
|
10
|
+
const getDefaultDescription = () => {
|
|
11
|
+
const currentMonth = monthYearFormatter.format(/* @__PURE__ */ new Date());
|
|
12
|
+
return `This account uses WhatsApp Business – Joined in ${currentMonth}`;
|
|
13
|
+
};
|
|
14
|
+
class PhonePreviewWhatsAppChannelAccount extends NectaryElement {
|
|
15
|
+
#heading;
|
|
16
|
+
#description;
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
const shadowRoot = this.attachShadow();
|
|
20
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
21
|
+
this.#heading = shadowRoot.querySelector("#heading");
|
|
22
|
+
this.#description = shadowRoot.querySelector("#description");
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
this.#updateUI();
|
|
27
|
+
}
|
|
28
|
+
static get observedAttributes() {
|
|
29
|
+
return ["heading", "description"];
|
|
30
|
+
}
|
|
31
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
32
|
+
if (oldVal === newVal) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.#updateUI();
|
|
36
|
+
}
|
|
37
|
+
get heading() {
|
|
38
|
+
return this.getAttribute("heading") ?? "Business Account";
|
|
39
|
+
}
|
|
40
|
+
set heading(value) {
|
|
41
|
+
this.setAttribute("heading", value);
|
|
42
|
+
}
|
|
43
|
+
get description() {
|
|
44
|
+
return this.getAttribute("description") ?? getDefaultDescription();
|
|
45
|
+
}
|
|
46
|
+
set description(value) {
|
|
47
|
+
this.setAttribute("description", value);
|
|
48
|
+
}
|
|
49
|
+
#updateUI() {
|
|
50
|
+
if (!this.isDomConnected) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.#heading.textContent = this.heading;
|
|
54
|
+
this.#description.textContent = this.description;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
defineCustomElement("sinch-labs-phone-preview-whatsapp-channel-account", PhonePreviewWhatsAppChannelAccount);
|
|
58
|
+
export {
|
|
59
|
+
PhonePreviewWhatsAppChannelAccount
|
|
60
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
:where(*, *::before, *::after) {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
padding: 0;
|
|
5
|
+
border: 0;
|
|
6
|
+
margin: 0;
|
|
7
|
+
font: inherit;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
border-radius: 6px;
|
|
14
|
+
background: var(--sinch-sys-color-surface-primary-default);
|
|
15
|
+
color: var(--sinch-sys-color-text-default);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.account {
|
|
19
|
+
min-block-size: 64px;
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: 20px minmax(0, 1fr) 16px;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 8px;
|
|
24
|
+
padding: 8px 12px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.info-icon {
|
|
28
|
+
--sinch-global-size-icon: 18px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.content {
|
|
32
|
+
min-inline-size: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#heading {
|
|
36
|
+
font: var(--sinch-sys-font-body-xs);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#description {
|
|
40
|
+
color: var(--sinch-sys-color-text-muted);
|
|
41
|
+
overflow-wrap: anywhere;
|
|
42
|
+
font: var(--sinch-sys-font-body-xxs);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.chevron {
|
|
46
|
+
--sinch-global-color-icon: var(--sinch-sys-color-text-disabled);
|
|
47
|
+
--sinch-global-size-icon: 16px;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
50
|
+
|
|
51
|
+
<section class="account">
|
|
52
|
+
<sinch-icon aria-hidden="true" class="info-icon" icons-version="2" name="fa-circle-info"></sinch-icon>
|
|
53
|
+
<div class="content">
|
|
54
|
+
<h2 id="heading">Business Account</h2>
|
|
55
|
+
<p id="description">This account uses WhatsApp Business</p>
|
|
56
|
+
</div>
|
|
57
|
+
<sinch-icon aria-hidden="true" class="chevron" icons-version="2" name="chevron-right"></sinch-icon>
|
|
58
|
+
</section>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import '@nectary/components/icon';
|
|
2
|
+
import { NectaryElement } from '../utils';
|
|
3
|
+
import type { PhonePreviewWhatsAppChannelActionsProps } from './types';
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export declare class PhonePreviewWhatsAppChannelActions extends NectaryElement {
|
|
7
|
+
#private;
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
12
|
+
get shareLabel(): string;
|
|
13
|
+
set shareLabel(value: string);
|
|
14
|
+
get searchLabel(): string;
|
|
15
|
+
set searchLabel(value: string);
|
|
16
|
+
}
|
|
17
|
+
type ElementProps = Partial<{
|
|
18
|
+
[K in keyof PhonePreviewWhatsAppChannelActionsProps]: PhonePreviewWhatsAppChannelActionsProps[K] | string;
|
|
19
|
+
}>;
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sinch-labs-phone-preview-whatsapp-channel-actions': ElementProps & HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module 'react' {
|
|
26
|
+
namespace JSX {
|
|
27
|
+
interface IntrinsicElements {
|
|
28
|
+
'sinch-labs-phone-preview-whatsapp-channel-actions': ElementProps & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|