@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.
Files changed (63) hide show
  1. package/color-select/index.d.ts +3 -6
  2. package/color-select/types.d.ts +6 -0
  3. package/color-select/types.js +1 -0
  4. package/index.d.ts +1 -0
  5. package/index.js +1 -0
  6. package/package.json +2 -2
  7. package/phone-preview/index.d.ts +3 -6
  8. package/phone-preview/index.js +20 -3
  9. package/phone-preview/template.html +48 -30
  10. package/phone-preview/types.d.ts +6 -0
  11. package/phone-preview/types.js +1 -0
  12. package/phone-preview-rcs-channel/index.d.ts +4 -12
  13. package/phone-preview-rcs-channel/index.js +7 -18
  14. package/phone-preview-rcs-channel/types.d.ts +16 -0
  15. package/phone-preview-rcs-channel/types.js +1 -0
  16. package/phone-preview-rcs-channel-actions/index.d.ts +3 -8
  17. package/phone-preview-rcs-channel-actions/types.d.ts +10 -0
  18. package/phone-preview-rcs-channel-actions/types.js +1 -0
  19. package/phone-preview-rcs-channel-info/index.d.ts +3 -3
  20. package/phone-preview-rcs-channel-info/types.d.ts +1 -0
  21. package/phone-preview-rcs-channel-info/types.js +1 -0
  22. package/phone-preview-rcs-channel-info-option/index.d.ts +3 -8
  23. package/phone-preview-rcs-channel-info-option/types.d.ts +10 -0
  24. package/phone-preview-rcs-channel-info-option/types.js +1 -0
  25. package/phone-preview-rcs-channel-options/index.d.ts +3 -3
  26. package/phone-preview-rcs-channel-options/types.d.ts +1 -0
  27. package/phone-preview-rcs-channel-options/types.js +1 -0
  28. package/phone-preview-rcs-channel-tabs/index.d.ts +3 -6
  29. package/phone-preview-rcs-channel-tabs/index.js +2 -6
  30. package/phone-preview-rcs-channel-tabs/template.html +1 -1
  31. package/phone-preview-rcs-channel-tabs/types.d.ts +6 -0
  32. package/phone-preview-rcs-channel-tabs/types.js +1 -0
  33. package/phone-preview-rcs-chat/index.d.ts +3 -7
  34. package/phone-preview-rcs-chat/types.d.ts +8 -0
  35. package/phone-preview-rcs-chat/types.js +1 -0
  36. package/phone-preview-rcs-chat-message/index.d.ts +3 -6
  37. package/phone-preview-rcs-chat-message/types.d.ts +6 -0
  38. package/phone-preview-rcs-chat-message/types.js +1 -0
  39. package/phone-preview-whatsapp-channel/index.d.ts +47 -0
  40. package/phone-preview-whatsapp-channel/index.js +134 -0
  41. package/phone-preview-whatsapp-channel/template.html +181 -0
  42. package/phone-preview-whatsapp-channel/types.d.ts +18 -0
  43. package/phone-preview-whatsapp-channel/types.js +1 -0
  44. package/phone-preview-whatsapp-channel-account/index.d.ts +31 -0
  45. package/phone-preview-whatsapp-channel-account/index.js +60 -0
  46. package/phone-preview-whatsapp-channel-account/template.html +58 -0
  47. package/phone-preview-whatsapp-channel-account/types.d.ts +6 -0
  48. package/phone-preview-whatsapp-channel-account/types.js +1 -0
  49. package/phone-preview-whatsapp-channel-actions/index.d.ts +31 -0
  50. package/phone-preview-whatsapp-channel-actions/index.js +52 -0
  51. package/phone-preview-whatsapp-channel-actions/template.html +47 -0
  52. package/phone-preview-whatsapp-channel-actions/types.d.ts +6 -0
  53. package/phone-preview-whatsapp-channel-actions/types.js +1 -0
  54. package/phone-preview-whatsapp-channel-info/index.d.ts +22 -0
  55. package/phone-preview-whatsapp-channel-info/index.js +15 -0
  56. package/phone-preview-whatsapp-channel-info/template.html +25 -0
  57. package/phone-preview-whatsapp-channel-info/types.d.ts +1 -0
  58. package/phone-preview-whatsapp-channel-info/types.js +1 -0
  59. package/phone-preview-whatsapp-channel-info-option/index.d.ts +32 -0
  60. package/phone-preview-whatsapp-channel-info-option/index.js +60 -0
  61. package/phone-preview-whatsapp-channel-info-option/template.html +34 -0
  62. package/phone-preview-whatsapp-channel-info-option/types.d.ts +9 -0
  63. package/phone-preview-whatsapp-channel-info-option/types.js +1 -0
@@ -4,7 +4,9 @@ import '@nectary/components/color-swatch';
4
4
  import '@nectary/components/popover';
5
5
  import '@nectary/components/select-button';
6
6
  import { NectaryElement } from '../utils';
7
+ import type { ColorSelectProps } from './types';
7
8
  import type React from 'react';
9
+ export * from './types';
8
10
  export declare class ColorSelect extends NectaryElement {
9
11
  #private;
10
12
  constructor();
@@ -17,12 +19,8 @@ export declare class ColorSelect extends NectaryElement {
17
19
  get value(): string;
18
20
  set value(newValue: string);
19
21
  }
20
- type Props = {
21
- open?: boolean;
22
- value?: string;
23
- };
24
22
  type ElementProps = Partial<{
25
- [K in keyof Props]: Props[K] | string;
23
+ [K in keyof ColorSelectProps]: ColorSelectProps[K] | string;
26
24
  }>;
27
25
  declare global {
28
26
  interface HTMLElementTagNameMap {
@@ -36,4 +34,3 @@ declare module 'react' {
36
34
  }
37
35
  }
38
36
  }
39
- export {};
@@ -0,0 +1,6 @@
1
+ export type ColorSelectProps = {
2
+ /** Controls whether the color menu is open. */
3
+ open?: boolean;
4
+ /** Selected color value. */
5
+ value?: string;
6
+ };
@@ -0,0 +1 @@
1
+
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './phone-preview-rcs-channel';
2
2
  import './phone-preview-rcs-chat-message';
3
+ import './phone-preview-whatsapp-channel';
3
4
  declare const _default: {};
4
5
  export default _default;
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import "./phone-preview-rcs-channel/index.js";
2
2
  import "./phone-preview-rcs-chat-message/index.js";
3
+ import "./phone-preview-whatsapp-channel/index.js";
3
4
  const index = {};
4
5
  export {
5
6
  index as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/labs",
3
- "version": "2.13.4",
3
+ "version": "2.14.0",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -19,7 +19,7 @@
19
19
  "dev": "vite build --watch"
20
20
  },
21
21
  "dependencies": {
22
- "@nectary/components": "5.50.0"
22
+ "@nectary/components": "5.50.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "22.12.0",
@@ -1,5 +1,7 @@
1
1
  import { NectaryElement } from '../utils';
2
+ import type { PhonePreviewProps } from './types';
2
3
  import type React from 'react';
4
+ export * from './types';
3
5
  /**
4
6
  * Container for channel previews in a styled phone container.
5
7
  * This container uses a custom scaling where the internal elements are scaled to fit the container from a fixed size.
@@ -21,12 +23,8 @@ export declare class PhonePreview extends NectaryElement {
21
23
  get clockOptions(): Intl.DateTimeFormatOptions;
22
24
  set clockOptions(value: Intl.DateTimeFormatOptions);
23
25
  }
24
- type Props = {
25
- locale?: string;
26
- clock?: Intl.DateTimeFormatOptions | string;
27
- };
28
26
  type ElementProps = Partial<{
29
- [K in keyof Props]: Props[K] | string;
27
+ [K in keyof PhonePreviewProps]: PhonePreviewProps[K] | string;
30
28
  }>;
31
29
  declare global {
32
30
  interface HTMLElementTagNameMap {
@@ -40,4 +38,3 @@ declare module 'react' {
40
38
  }
41
39
  }
42
40
  }
43
- export {};
@@ -1,9 +1,13 @@
1
1
  import { defineCustomElement, NectaryElement } from "../utils/element.js";
2
- 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 --base-size: 288px; /* 18rem */\n --aspect-ratio: 1 / 2.1;\n --scale: 1;\n\n inline-size: min(100%, var(--base-size));\n aspect-ratio: var(--aspect-ratio);\n overflow: hidden;\n display: block;\n}\n\nsection {\n position: relative;\n inline-size: var(--base-size);\n aspect-ratio: var(--aspect-ratio);\n scale: var(--scale);\n transform-origin: top left;\n overflow: hidden;\n display: flex;\n flex-flow: column;\n padding: 12px;\n border: 1px solid var(--sinch-sys-color-border-strong);\n border-radius: 32px;\n background: var(--sinch-sys-color-surface-primary-default);\n}\n\nsection > header {\n position: sticky;\n inset-block-start: 0;\n display: flex;\n justify-content: space-between;\n padding: 16px;\n background: var(--sinch-sys-color-surface-primary-default);\n font: var(--sinch-sys-font-body-xxs);\n}\n\nsection > header > svg {\n inline-size: 48px;\n}\n\nsection > div {\n flex: 1;\n overflow-y: auto;\n scrollbar-width: none;\n border-end-start-radius: 16px;\n border-end-end-radius: 16px;\n}\n</style>\n<section>\n <header>\n <span id="clock"></span>\n <svg viewBox="0 0 50 12">\n <path\n d="M13.2 2.4h-.7c-.4 0-.7.3-.7.7v6.2c0 .4.3.8.7.8h.7c.4 0 .7-.4.7-.8V3.1c0-.4-.3-.7-.7-.7ZM9.4 4.2h.6c.4 0 .7.3.7.7v4.5c0 .3-.3.7-.7.7h-.6c-.4 0-.7-.4-.7-.7V4.9c0-.4.3-.7.7-.7ZM6.9 6h-.7c-.4 0-.7.3-.7.7v2.7c0 .4.3.7.7.7h.7c.4 0 .7-.3.7-.7V6.7c0-.4-.3-.7-.7-.7ZM3.7 7.3H3c-.3 0-.6.4-.6.7v1.4c0 .4.3.7.6.7h.7c.4 0 .7-.3.7-.7V8c0-.3-.3-.7-.7-.7Zm19.4-3.7c1.7 0 3.3.7 4.5 1.8h.3l.8-.9.1-.1-.1-.2a8 8 0 0 0-11.1 0l-.1.2.1.1.8.9h.3a6.7 6.7 0 0 1 4.4-1.8Zm0 2.8a4 4 0 0 1 2.5 1h.3l.9-.9v-.3a5.4 5.4 0 0 0-7.3 0v.3l.9.9h.3c.7-.6 1.5-1 2.4-1Zm1.8 1.9-.1.2-1.5 1.5-.2.1-.1-.1-1.5-1.5-.1-.2.1-.1c1-.8 2.3-.8 3.3 0l.1.1Z"\n />\n <rect width="12.6" height="5.4" x="33.3" y="3.5" rx=".9" />\n <path fill="#999" d="M48 4.9v2.7c.5-.3.9-.8.9-1.4 0-.6-.4-1.1-.9-1.3Z" />\n <path\n fill="none"\n stroke="#999"\n stroke-width=".7"\n d="M32.3 4.4a2 2 0 0 1 1.9-1.9H45c1.1 0 2 .9 2 1.9V8c0 1.1-.9 1.9-2 1.9H34.2c-1 0-1.9-.8-1.9-1.9V4.4Z"\n />\n </svg>\n </header>\n <div>\n <slot></slot>\n </div>\n</section>\n';
2
+ 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 --base-size: 288px; /* 18rem */\n --aspect-ratio: 1 / 2.1;\n --scale: 1;\n --phone-preview-border-radius: 32px;\n --phone-preview-padding: 12px;\n --phone-preview-content-radius:\n calc(var(--phone-preview-border-radius) - var(--phone-preview-padding));\n\n inline-size: min(100%, var(--base-size));\n aspect-ratio: var(--aspect-ratio);\n overflow: hidden;\n display: block;\n}\n\n.phone {\n position: relative;\n inline-size: var(--base-size);\n aspect-ratio: var(--aspect-ratio);\n scale: var(--scale);\n transform-origin: top left;\n overflow: hidden;\n display: flex;\n flex-flow: column;\n padding: var(--phone-preview-padding);\n border: 1px solid var(--sinch-sys-color-border-strong);\n border-radius: var(--phone-preview-border-radius);\n background: var(--sinch-sys-color-surface-primary-default);\n}\n\n.surface {\n min-block-size: 0;\n display: flex;\n flex: 1;\n flex-flow: column;\n overflow: hidden;\n border-radius: var(--phone-preview-content-radius);\n background:\n var(\n --phone-preview-background,\n var(--sinch-sys-color-surface-primary-default)\n );\n}\n\n.surface > header {\n position: sticky;\n inset-block-start: 0;\n display: flex;\n justify-content: space-between;\n padding: 8px 16px;\n font: var(--sinch-sys-font-body-xxs);\n}\n\n.surface > header > svg {\n inline-size: 48px;\n}\n\n.content {\n min-block-size: 0;\n flex: 1;\n overflow-y: auto;\n scrollbar-width: none;\n}\n</style>\n<div class="phone" id="phone">\n <div class="surface">\n <header>\n <span id="clock"></span>\n <svg aria-hidden="true" viewBox="0 0 50 12">\n <path\n d="M13.2 2.4h-.7c-.4 0-.7.3-.7.7v6.2c0 .4.3.8.7.8h.7c.4 0 .7-.4.7-.8V3.1c0-.4-.3-.7-.7-.7ZM9.4 4.2h.6c.4 0 .7.3.7.7v4.5c0 .3-.3.7-.7.7h-.6c-.4 0-.7-.4-.7-.7V4.9c0-.4.3-.7.7-.7ZM6.9 6h-.7c-.4 0-.7.3-.7.7v2.7c0 .4.3.7.7.7h.7c.4 0 .7-.3.7-.7V6.7c0-.4-.3-.7-.7-.7ZM3.7 7.3H3c-.3 0-.6.4-.6.7v1.4c0 .4.3.7.6.7h.7c.4 0 .7-.3.7-.7V8c0-.3-.3-.7-.7-.7Zm19.4-3.7c1.7 0 3.3.7 4.5 1.8h.3l.8-.9.1-.1-.1-.2a8 8 0 0 0-11.1 0l-.1.2.1.1.8.9h.3a6.7 6.7 0 0 1 4.4-1.8Zm0 2.8a4 4 0 0 1 2.5 1h.3l.9-.9v-.3a5.4 5.4 0 0 0-7.3 0v.3l.9.9h.3c.7-.6 1.5-1 2.4-1Zm1.8 1.9-.1.2-1.5 1.5-.2.1-.1-.1-1.5-1.5-.1-.2.1-.1c1-.8 2.3-.8 3.3 0l.1.1Z"\n />\n <rect width="12.6" height="5.4" x="33.3" y="3.5" rx=".9" />\n <path fill="#999" d="M48 4.9v2.7c.5-.3.9-.8.9-1.4 0-.6-.4-1.1-.9-1.3Z" />\n <path\n fill="none"\n stroke="#999"\n stroke-width=".7"\n d="M32.3 4.4a2 2 0 0 1 1.9-1.9H45c1.1 0 2 .9 2 1.9V8c0 1.1-.9 1.9-2 1.9H34.2c-1 0-1.9-.8-1.9-1.9V4.4Z"\n />\n </svg>\n </header>\n <div class="content">\n <slot></slot>\n </div>\n </div>\n</div>\n';
3
3
  const template = document.createElement("template");
4
4
  template.innerHTML = templateHTML;
5
+ const BACKGROUND_PROPERTY = "--phone-preview-background";
6
+ const CHANNEL_BACKGROUND_PROPERTY = "--phone-preview-channel-background";
5
7
  class PhonePreview extends NectaryElement {
8
+ #phoneElement;
6
9
  #clockElement;
10
+ #contentSlot;
7
11
  #resizeObserver;
8
12
  #clockInterval = null;
9
13
  #formatter;
@@ -11,7 +15,9 @@ class PhonePreview extends NectaryElement {
11
15
  super();
12
16
  const shadowRoot = this.attachShadow();
13
17
  shadowRoot.appendChild(template.content.cloneNode(true));
18
+ this.#phoneElement = shadowRoot.querySelector("#phone");
14
19
  this.#clockElement = shadowRoot.querySelector("#clock");
20
+ this.#contentSlot = shadowRoot.querySelector("slot");
15
21
  this.#resizeObserver = new ResizeObserver(() => {
16
22
  this.#updateScale();
17
23
  });
@@ -19,15 +25,17 @@ class PhonePreview extends NectaryElement {
19
25
  }
20
26
  connectedCallback() {
21
27
  super.connectedCallback();
22
- const section = this.shadowRoot.querySelector("section");
23
28
  this.#resizeObserver.observe(this);
24
- this.#resizeObserver.observe(section);
29
+ this.#resizeObserver.observe(this.#phoneElement);
30
+ this.#contentSlot.addEventListener("slotchange", this.#syncBackground);
25
31
  this.#startClock();
26
32
  this.#updateClock();
33
+ this.#syncBackground();
27
34
  }
28
35
  disconnectedCallback() {
29
36
  super.disconnectedCallback();
30
37
  this.#resizeObserver.disconnect();
38
+ this.#contentSlot.removeEventListener("slotchange", this.#syncBackground);
31
39
  this.#stopClock();
32
40
  }
33
41
  static get observedAttributes() {
@@ -79,6 +87,15 @@ class PhonePreview extends NectaryElement {
79
87
  this.#clockElement.textContent = this.#formatter.format(/* @__PURE__ */ new Date());
80
88
  }
81
89
  }
90
+ #syncBackground = () => {
91
+ const [contentElement] = this.#contentSlot.assignedElements({ flatten: true });
92
+ const background = contentElement === void 0 ? "" : getComputedStyle(contentElement).getPropertyValue(CHANNEL_BACKGROUND_PROPERTY).trim();
93
+ if (background !== "") {
94
+ this.style.setProperty(BACKGROUND_PROPERTY, background);
95
+ } else {
96
+ this.style.removeProperty(BACKGROUND_PROPERTY);
97
+ }
98
+ };
82
99
  }
83
100
  defineCustomElement("sinch-labs-phone-preview", PhonePreview);
84
101
  export {
@@ -11,6 +11,10 @@
11
11
  --base-size: 288px; /* 18rem */
12
12
  --aspect-ratio: 1 / 2.1;
13
13
  --scale: 1;
14
+ --phone-preview-border-radius: 32px;
15
+ --phone-preview-padding: 12px;
16
+ --phone-preview-content-radius:
17
+ calc(var(--phone-preview-border-radius) - var(--phone-preview-padding));
14
18
 
15
19
  inline-size: min(100%, var(--base-size));
16
20
  aspect-ratio: var(--aspect-ratio);
@@ -18,7 +22,7 @@
18
22
  display: block;
19
23
  }
20
24
 
21
- section {
25
+ .phone {
22
26
  position: relative;
23
27
  inline-size: var(--base-size);
24
28
  aspect-ratio: var(--aspect-ratio);
@@ -27,52 +31,66 @@ section {
27
31
  overflow: hidden;
28
32
  display: flex;
29
33
  flex-flow: column;
30
- padding: 12px;
34
+ padding: var(--phone-preview-padding);
31
35
  border: 1px solid var(--sinch-sys-color-border-strong);
32
- border-radius: 32px;
36
+ border-radius: var(--phone-preview-border-radius);
33
37
  background: var(--sinch-sys-color-surface-primary-default);
34
38
  }
35
39
 
36
- section > header {
40
+ .surface {
41
+ min-block-size: 0;
42
+ display: flex;
43
+ flex: 1;
44
+ flex-flow: column;
45
+ overflow: hidden;
46
+ border-radius: var(--phone-preview-content-radius);
47
+ background:
48
+ var(
49
+ --phone-preview-background,
50
+ var(--sinch-sys-color-surface-primary-default)
51
+ );
52
+ }
53
+
54
+ .surface > header {
37
55
  position: sticky;
38
56
  inset-block-start: 0;
39
57
  display: flex;
40
58
  justify-content: space-between;
41
- padding: 16px;
42
- background: var(--sinch-sys-color-surface-primary-default);
59
+ padding: 8px 16px;
43
60
  font: var(--sinch-sys-font-body-xxs);
44
61
  }
45
62
 
46
- section > header > svg {
63
+ .surface > header > svg {
47
64
  inline-size: 48px;
48
65
  }
49
66
 
50
- section > div {
67
+ .content {
68
+ min-block-size: 0;
51
69
  flex: 1;
52
70
  overflow-y: auto;
53
71
  scrollbar-width: none;
54
- border-end-start-radius: 16px;
55
- border-end-end-radius: 16px;
56
72
  }
57
73
  </style>
58
- <section>
59
- <header>
60
- <span id="clock"></span>
61
- <svg viewBox="0 0 50 12">
62
- <path
63
- d="M13.2 2.4h-.7c-.4 0-.7.3-.7.7v6.2c0 .4.3.8.7.8h.7c.4 0 .7-.4.7-.8V3.1c0-.4-.3-.7-.7-.7ZM9.4 4.2h.6c.4 0 .7.3.7.7v4.5c0 .3-.3.7-.7.7h-.6c-.4 0-.7-.4-.7-.7V4.9c0-.4.3-.7.7-.7ZM6.9 6h-.7c-.4 0-.7.3-.7.7v2.7c0 .4.3.7.7.7h.7c.4 0 .7-.3.7-.7V6.7c0-.4-.3-.7-.7-.7ZM3.7 7.3H3c-.3 0-.6.4-.6.7v1.4c0 .4.3.7.6.7h.7c.4 0 .7-.3.7-.7V8c0-.3-.3-.7-.7-.7Zm19.4-3.7c1.7 0 3.3.7 4.5 1.8h.3l.8-.9.1-.1-.1-.2a8 8 0 0 0-11.1 0l-.1.2.1.1.8.9h.3a6.7 6.7 0 0 1 4.4-1.8Zm0 2.8a4 4 0 0 1 2.5 1h.3l.9-.9v-.3a5.4 5.4 0 0 0-7.3 0v.3l.9.9h.3c.7-.6 1.5-1 2.4-1Zm1.8 1.9-.1.2-1.5 1.5-.2.1-.1-.1-1.5-1.5-.1-.2.1-.1c1-.8 2.3-.8 3.3 0l.1.1Z"
64
- />
65
- <rect width="12.6" height="5.4" x="33.3" y="3.5" rx=".9" />
66
- <path fill="#999" d="M48 4.9v2.7c.5-.3.9-.8.9-1.4 0-.6-.4-1.1-.9-1.3Z" />
67
- <path
68
- fill="none"
69
- stroke="#999"
70
- stroke-width=".7"
71
- d="M32.3 4.4a2 2 0 0 1 1.9-1.9H45c1.1 0 2 .9 2 1.9V8c0 1.1-.9 1.9-2 1.9H34.2c-1 0-1.9-.8-1.9-1.9V4.4Z"
72
- />
73
- </svg>
74
- </header>
75
- <div>
76
- <slot></slot>
74
+ <div class="phone" id="phone">
75
+ <div class="surface">
76
+ <header>
77
+ <span id="clock"></span>
78
+ <svg aria-hidden="true" viewBox="0 0 50 12">
79
+ <path
80
+ d="M13.2 2.4h-.7c-.4 0-.7.3-.7.7v6.2c0 .4.3.8.7.8h.7c.4 0 .7-.4.7-.8V3.1c0-.4-.3-.7-.7-.7ZM9.4 4.2h.6c.4 0 .7.3.7.7v4.5c0 .3-.3.7-.7.7h-.6c-.4 0-.7-.4-.7-.7V4.9c0-.4.3-.7.7-.7ZM6.9 6h-.7c-.4 0-.7.3-.7.7v2.7c0 .4.3.7.7.7h.7c.4 0 .7-.3.7-.7V6.7c0-.4-.3-.7-.7-.7ZM3.7 7.3H3c-.3 0-.6.4-.6.7v1.4c0 .4.3.7.6.7h.7c.4 0 .7-.3.7-.7V8c0-.3-.3-.7-.7-.7Zm19.4-3.7c1.7 0 3.3.7 4.5 1.8h.3l.8-.9.1-.1-.1-.2a8 8 0 0 0-11.1 0l-.1.2.1.1.8.9h.3a6.7 6.7 0 0 1 4.4-1.8Zm0 2.8a4 4 0 0 1 2.5 1h.3l.9-.9v-.3a5.4 5.4 0 0 0-7.3 0v.3l.9.9h.3c.7-.6 1.5-1 2.4-1Zm1.8 1.9-.1.2-1.5 1.5-.2.1-.1-.1-1.5-1.5-.1-.2.1-.1c1-.8 2.3-.8 3.3 0l.1.1Z"
81
+ />
82
+ <rect width="12.6" height="5.4" x="33.3" y="3.5" rx=".9" />
83
+ <path fill="#999" d="M48 4.9v2.7c.5-.3.9-.8.9-1.4 0-.6-.4-1.1-.9-1.3Z" />
84
+ <path
85
+ fill="none"
86
+ stroke="#999"
87
+ stroke-width=".7"
88
+ d="M32.3 4.4a2 2 0 0 1 1.9-1.9H45c1.1 0 2 .9 2 1.9V8c0 1.1-.9 1.9-2 1.9H34.2c-1 0-1.9-.8-1.9-1.9V4.4Z"
89
+ />
90
+ </svg>
91
+ </header>
92
+ <div class="content">
93
+ <slot></slot>
94
+ </div>
77
95
  </div>
78
- </section>
96
+ </div>
@@ -0,0 +1,6 @@
1
+ export type PhonePreviewProps = {
2
+ /** Locale used to format the status-bar clock. */
3
+ locale?: string;
4
+ /** JSON-serialized or programmatic options used to format the status-bar clock. */
5
+ clock?: Intl.DateTimeFormatOptions | string;
6
+ };
@@ -0,0 +1 @@
1
+
@@ -5,14 +5,16 @@ import '../phone-preview-rcs-channel-info';
5
5
  import '../phone-preview-rcs-channel-info-option';
6
6
  import '../phone-preview-rcs-channel-options';
7
7
  import '../phone-preview-rcs-channel-tabs';
8
+ import type { PhonePreviewRcsChannelProps } from './types';
8
9
  import type React from 'react';
10
+ export * from './types';
9
11
  export declare class PhonePreviewRcsChannel extends NectaryElement {
10
12
  #private;
11
13
  constructor();
12
14
  connectedCallback(): void;
13
15
  disconnectedCallback(): void;
14
16
  static get observedAttributes(): string[];
15
- attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
17
+ attributeChangedCallback(_name: string, oldVal: string | null, newVal: string | null): void;
16
18
  get name(): string;
17
19
  set name(value: string);
18
20
  get description(): string;
@@ -28,17 +30,8 @@ export declare class PhonePreviewRcsChannel extends NectaryElement {
28
30
  get actionsDisabled(): boolean;
29
31
  set actionsDisabled(value: boolean);
30
32
  }
31
- type RcsChannelProps = {
32
- name?: string;
33
- description?: string;
34
- color?: string;
35
- banner?: string;
36
- bannerColor?: string;
37
- logo?: string;
38
- actionsDisabled?: boolean;
39
- };
40
33
  type RcsChannelElementProps = Partial<{
41
- [K in keyof RcsChannelProps]: RcsChannelProps[K] | string;
34
+ [K in keyof PhonePreviewRcsChannelProps]: PhonePreviewRcsChannelProps[K] | string;
42
35
  }>;
43
36
  declare global {
44
37
  interface HTMLElementTagNameMap {
@@ -52,4 +45,3 @@ declare module 'react' {
52
45
  }
53
46
  }
54
47
  }
55
- export {};
@@ -8,6 +8,8 @@ import "../phone-preview-rcs-channel-tabs/index.js";
8
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 --banner-aspect-ratio: 1440 / 448;\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 {\n display: block;\n aspect-ratio: var(--banner-aspect-ratio);\n margin-block-end: -40px;\n background: var(--banner-color);\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n}\n\n#logo {\n block-size: 64px;\n inline-size: 64px;\n border-radius: 100%;\n background: var(--logo-color);\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\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<div id="banner"></div>\n<div id="logo"></div>\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
9
  const template = document.createElement("template");
10
10
  template.innerHTML = templateHTML;
11
+ const DEFAULT_NAME = "Brand name";
12
+ const DEFAULT_DESCRIPTION = "Brand description";
11
13
  class PhonePreviewRcsChannel extends NectaryElement {
12
14
  #banner;
13
15
  #logo;
@@ -46,7 +48,7 @@ class PhonePreviewRcsChannel extends NectaryElement {
46
48
  observer.disconnect();
47
49
  });
48
50
  this.#updateUI();
49
- this.#updateTabContent();
51
+ this.#updateTabVisibility();
50
52
  }
51
53
  disconnectedCallback() {
52
54
  super.disconnectedCallback();
@@ -56,21 +58,11 @@ class PhonePreviewRcsChannel extends NectaryElement {
56
58
  static get observedAttributes() {
57
59
  return ["name", "description", "color", "banner", "bannercolor", "logo", "actionsdisabled"];
58
60
  }
59
- attributeChangedCallback(name, oldVal, newVal) {
61
+ attributeChangedCallback(_name, oldVal, newVal) {
60
62
  if (oldVal === newVal) {
61
63
  return;
62
64
  }
63
- switch (name) {
64
- case "name":
65
- case "description":
66
- case "color":
67
- case "banner":
68
- case "bannercolor":
69
- case "logo":
70
- case "actionsdisabled":
71
- this.#updateUI();
72
- break;
73
- }
65
+ this.#updateUI();
74
66
  }
75
67
  get name() {
76
68
  return this.getAttribute("name") ?? "";
@@ -124,8 +116,8 @@ class PhonePreviewRcsChannel extends NectaryElement {
124
116
  }
125
117
  this.#banner.style.backgroundImage = this.banner !== "" ? `url(${JSON.stringify(this.banner)})` : "";
126
118
  this.#logo.style.backgroundImage = this.logo !== "" ? `url(${JSON.stringify(this.logo)})` : "";
127
- this.#brandName.textContent = this.name !== "" ? this.name : "Brand name";
128
- this.#brandDescription.textContent = this.description !== "" ? this.description : "Brand description";
119
+ this.#brandName.textContent = this.name !== "" ? this.name : DEFAULT_NAME;
120
+ this.#brandDescription.textContent = this.description !== "" ? this.description : DEFAULT_DESCRIPTION;
129
121
  const bannerColor = this.bannerColor !== "" ? this.bannerColor : this.color;
130
122
  if (bannerColor !== "") {
131
123
  this.style.setProperty("--banner-color", bannerColor);
@@ -156,9 +148,6 @@ class PhonePreviewRcsChannel extends NectaryElement {
156
148
  this.#actions.setAttribute("email", firstEmail);
157
149
  this.#actions.toggleAttribute("disabled", this.actionsDisabled);
158
150
  }
159
- #updateTabContent() {
160
- this.#updateTabVisibility();
161
- }
162
151
  #updateTabVisibility() {
163
152
  if (this.#currentTab === 0) {
164
153
  this.#infoContainer.style.display = "block";
@@ -0,0 +1,16 @@
1
+ export type PhonePreviewRcsChannelProps = {
2
+ /** Business or agent name. */
3
+ name?: string;
4
+ /** Short business or agent description. */
5
+ description?: string;
6
+ /** Accent color used by the RCS profile. */
7
+ color?: string;
8
+ /** URL of the profile banner image. */
9
+ banner?: string;
10
+ /** Background color shown when no banner image is provided. */
11
+ bannerColor?: string;
12
+ /** URL of the profile logo image. */
13
+ logo?: string;
14
+ /** Visually disables the profile action buttons. */
15
+ actionsDisabled?: boolean;
16
+ };
@@ -0,0 +1 @@
1
+
@@ -1,6 +1,8 @@
1
1
  import '@nectary/components/icon';
2
2
  import { NectaryElement } from '../utils';
3
+ import type { PhonePreviewRcsChannelActionsProps } from './types';
3
4
  import type React from 'react';
5
+ export * from './types';
4
6
  export declare class PhonePreviewRcsChannelActions extends NectaryElement {
5
7
  #private;
6
8
  constructor();
@@ -16,14 +18,8 @@ export declare class PhonePreviewRcsChannelActions extends NectaryElement {
16
18
  get disabled(): boolean;
17
19
  set disabled(value: boolean);
18
20
  }
19
- type Props = {
20
- phone?: string;
21
- website?: string;
22
- email?: string;
23
- disabled?: boolean;
24
- };
25
21
  type ElementProps = Partial<{
26
- [K in keyof Props]: Props[K] | string;
22
+ [K in keyof PhonePreviewRcsChannelActionsProps]: PhonePreviewRcsChannelActionsProps[K] | string;
27
23
  }>;
28
24
  declare global {
29
25
  interface HTMLElementTagNameMap {
@@ -37,4 +33,3 @@ declare module 'react' {
37
33
  }
38
34
  }
39
35
  }
40
- export {};
@@ -0,0 +1,10 @@
1
+ export type PhonePreviewRcsChannelActionsProps = {
2
+ /** Phone number used by the call action. */
3
+ phone?: string;
4
+ /** URL used by the website action. */
5
+ website?: string;
6
+ /** Email address used by the email action. */
7
+ email?: string;
8
+ /** Visually and functionally disables the actions. */
9
+ disabled?: boolean;
10
+ };
@@ -1,6 +1,8 @@
1
1
  import '@nectary/components/icon';
2
2
  import { NectaryElement } from '../utils';
3
+ import type { PhonePreviewRcsChannelInfoProps } from './types';
3
4
  import type React from 'react';
5
+ export * from './types';
4
6
  export declare class PhonePreviewRcsChannelInfo extends NectaryElement {
5
7
  constructor();
6
8
  connectedCallback(): void;
@@ -8,9 +10,8 @@ export declare class PhonePreviewRcsChannelInfo extends NectaryElement {
8
10
  static get observedAttributes(): never[];
9
11
  attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
10
12
  }
11
- type Props = {};
12
13
  type ElementProps = Partial<{
13
- [K in keyof Props]: Props[K] | string;
14
+ [K in keyof PhonePreviewRcsChannelInfoProps]: PhonePreviewRcsChannelInfoProps[K] | string;
14
15
  }>;
15
16
  declare global {
16
17
  interface HTMLElementTagNameMap {
@@ -24,4 +25,3 @@ declare module 'react' {
24
25
  }
25
26
  }
26
27
  }
27
- export {};
@@ -0,0 +1 @@
1
+ export type PhonePreviewRcsChannelInfoProps = Record<never, never>;
@@ -1,6 +1,8 @@
1
1
  import '@nectary/components/icon';
2
2
  import { NectaryElement } from '../utils';
3
+ import type { PhonePreviewRcsChannelInfoOptionProps } from './types';
3
4
  import type React from 'react';
5
+ export * from './types';
4
6
  export declare class PhonePreviewRcsChannelInfoOption extends NectaryElement {
5
7
  #private;
6
8
  constructor();
@@ -16,14 +18,8 @@ export declare class PhonePreviewRcsChannelInfoOption extends NectaryElement {
16
18
  get placeholder(): boolean;
17
19
  set placeholder(value: boolean);
18
20
  }
19
- type Props = {
20
- type?: 'phone' | 'website' | 'email';
21
- contact?: string;
22
- label?: string;
23
- placeholder?: boolean;
24
- };
25
21
  type ElementProps = Partial<{
26
- [K in keyof Props]: Props[K] | string;
22
+ [K in keyof PhonePreviewRcsChannelInfoOptionProps]: PhonePreviewRcsChannelInfoOptionProps[K] | string;
27
23
  }>;
28
24
  declare global {
29
25
  interface HTMLElementTagNameMap {
@@ -37,4 +33,3 @@ declare module 'react' {
37
33
  }
38
34
  }
39
35
  }
40
- export {};
@@ -0,0 +1,10 @@
1
+ export type PhonePreviewRcsChannelInfoOptionProps = {
2
+ /** Kind of contact information represented by the option. */
3
+ type?: 'phone' | 'website' | 'email';
4
+ /** Phone number, URL, or email address displayed by the option. */
5
+ contact?: string;
6
+ /** Human-readable label displayed with the contact information. */
7
+ label?: string;
8
+ /** Displays the option using placeholder styling. */
9
+ placeholder?: boolean;
10
+ };
@@ -1,5 +1,7 @@
1
1
  import { NectaryElement } from '../utils';
2
+ import type { PhonePreviewRcsChannelOptionsProps } from './types';
2
3
  import type React from 'react';
4
+ export * from './types';
3
5
  export declare class PhonePreviewRcsChannelOptions extends NectaryElement {
4
6
  #private;
5
7
  constructor();
@@ -8,9 +10,8 @@ export declare class PhonePreviewRcsChannelOptions extends NectaryElement {
8
10
  static get observedAttributes(): never[];
9
11
  attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
10
12
  }
11
- type Props = {};
12
13
  type ElementProps = Partial<{
13
- [K in keyof Props]: Props[K] | string;
14
+ [K in keyof PhonePreviewRcsChannelOptionsProps]: PhonePreviewRcsChannelOptionsProps[K] | string;
14
15
  }>;
15
16
  declare global {
16
17
  interface HTMLElementTagNameMap {
@@ -24,4 +25,3 @@ declare module 'react' {
24
25
  }
25
26
  }
26
27
  }
27
- export {};
@@ -0,0 +1 @@
1
+ export type PhonePreviewRcsChannelOptionsProps = Record<never, never>;
@@ -1,5 +1,7 @@
1
1
  import { NectaryElement } from '../utils';
2
+ import type { PhonePreviewRcsChannelTabsProps } from './types';
2
3
  import type React from 'react';
4
+ export * from './types';
3
5
  export declare class PhonePreviewRcsChannelTabs extends NectaryElement {
4
6
  #private;
5
7
  constructor();
@@ -12,12 +14,8 @@ export declare class PhonePreviewRcsChannelTabs extends NectaryElement {
12
14
  get activeTab(): number;
13
15
  set activeTab(value: number);
14
16
  }
15
- type Props = {
16
- color?: string;
17
- 'active-tab'?: number;
18
- };
19
17
  type ElementProps = Partial<{
20
- [K in keyof Props]: Props[K] | string;
18
+ [K in keyof PhonePreviewRcsChannelTabsProps]: PhonePreviewRcsChannelTabsProps[K] | string;
21
19
  }>;
22
20
  declare global {
23
21
  interface HTMLElementTagNameMap {
@@ -31,4 +29,3 @@ declare module 'react' {
31
29
  }
32
30
  }
33
31
  }
34
- export {};
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, NectaryElement } from "../utils/element.js";
2
- 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.tabs {\n --highlight-color: var(--sinch-sys-color-text-default);\n\n display: flex;\n}\n\n.tabs > button {\n flex: 1;\n padding-block-end: 10px;\n border-block-end: 2px solid transparent;\n outline: none;\n background: transparent;\n color: var(--sinch-sys-color-text-disabled);\n font: var(--sinch-sys-font-desktop-title-xs);\n}\n\n.tabs > button.active {\n color: var(--sinch-sys-color-primary-default);\n border-block-end: 2px solid var(--highlight-color);\n}\n</style>\n\n<section class="tabs" id="tabs-container">\n <button>Info</button>\n <button>Options</button>\n</section>\n';
2
+ 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.tabs {\n --highlight-color: var(--sinch-sys-color-text-default);\n\n display: flex;\n}\n\n.tabs > button {\n flex: 1;\n padding-block-end: 10px;\n border-block-end: 2px solid transparent;\n outline: none;\n background: transparent;\n color: var(--sinch-sys-color-text-disabled);\n font: var(--sinch-sys-font-desktop-title-xs);\n}\n\n.tabs > button.active {\n color: var(--highlight-color);\n border-block-end: 2px solid var(--highlight-color);\n}\n</style>\n\n<section class="tabs" id="tabs-container">\n <button>Info</button>\n <button>Options</button>\n</section>\n';
3
3
  const template = document.createElement("template");
4
4
  template.innerHTML = templateHTML;
5
5
  class PhonePreviewRcsChannelTabs extends NectaryElement {
@@ -52,11 +52,7 @@ class PhonePreviewRcsChannelTabs extends NectaryElement {
52
52
  this.#tabsContainer.style.setProperty("--highlight-color", this.color);
53
53
  const buttons = this.#tabsContainer.querySelectorAll("button");
54
54
  buttons.forEach((button, index) => {
55
- if (index === this.activeTab) {
56
- button.classList.add("active");
57
- } else {
58
- button.classList.remove("active");
59
- }
55
+ button.classList.toggle("active", index === this.activeTab);
60
56
  });
61
57
  }
62
58
  #onTabClick = (event) => {
@@ -24,7 +24,7 @@
24
24
  }
25
25
 
26
26
  .tabs > button.active {
27
- color: var(--sinch-sys-color-primary-default);
27
+ color: var(--highlight-color);
28
28
  border-block-end: 2px solid var(--highlight-color);
29
29
  }
30
30
  </style>
@@ -0,0 +1,6 @@
1
+ export type PhonePreviewRcsChannelTabsProps = {
2
+ /** Accent color used by the active tab. */
3
+ color?: string;
4
+ /** Zero-based index of the active tab. */
5
+ 'active-tab'?: number;
6
+ };