@nectary/labs 2.5.39 → 2.5.40

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.
@@ -1,96 +1,97 @@
1
- import '@nectary/components/color-menu';
2
- import '@nectary/components/color-menu-option';
3
- import '@nectary/components/color-swatch';
4
- import '@nectary/components/popover';
5
- import '@nectary/components/select-button';
6
- import { defineCustomElement, NectaryElement } from '../utils';
7
- import templateHTML from './template.html';
8
- const template = document.createElement('template');
1
+ import "@nectary/components/color-menu";
2
+ import "@nectary/components/color-menu-option";
3
+ import "@nectary/components/color-swatch";
4
+ import "@nectary/components/popover";
5
+ import "@nectary/components/select-button";
6
+ import { defineCustomElement, NectaryElement } from "../utils/element.js";
7
+ const templateHTML = '<sinch-popover\n aria-label="Select color"\n orientation="bottom-right"\n modal\n>\n <sinch-select-button\n slot="target"\n placeholder="Select color"\n aria-label="Open color select"\n >\n <sinch-color-swatch slot="icon"></sinch-color-swatch>\n </sinch-select-button>\n <sinch-color-menu\n slot="content"\n aria-label="Color menu"\n >\n <sinch-color-menu-option value="violet"></sinch-color-menu-option>\n </sinch-color-menu>\n</sinch-popover>\n';
8
+ const template = document.createElement("template");
9
9
  template.innerHTML = templateHTML;
10
- export class ColorSelect extends NectaryElement {
11
- #popover;
12
- #selectButton;
13
- #colorSwatch;
14
- #colorMenu;
15
- #controller = null;
16
- constructor() {
17
- super();
18
- const shadowRoot = this.attachShadow();
19
- shadowRoot.appendChild(template.content.cloneNode(true));
20
- this.#popover = shadowRoot.querySelector('sinch-popover');
21
- this.#selectButton = shadowRoot.querySelector('sinch-select-button');
22
- this.#colorSwatch = shadowRoot.querySelector('sinch-color-swatch');
23
- this.#colorMenu = shadowRoot.querySelector('sinch-color-menu');
10
+ class ColorSelect extends NectaryElement {
11
+ #popover;
12
+ #selectButton;
13
+ #colorSwatch;
14
+ #colorMenu;
15
+ #controller = null;
16
+ constructor() {
17
+ super();
18
+ const shadowRoot = this.attachShadow();
19
+ shadowRoot.appendChild(template.content.cloneNode(true));
20
+ this.#popover = shadowRoot.querySelector("sinch-popover");
21
+ this.#selectButton = shadowRoot.querySelector("sinch-select-button");
22
+ this.#colorSwatch = shadowRoot.querySelector("sinch-color-swatch");
23
+ this.#colorMenu = shadowRoot.querySelector("sinch-color-menu");
24
+ }
25
+ connectedCallback() {
26
+ super.connectedCallback();
27
+ this.#controller = new AbortController();
28
+ const { signal } = this.#controller;
29
+ this.#selectButton.addEventListener("-click", this.#onOpen, { signal });
30
+ this.#popover.addEventListener("-close", this.#onClose, { signal });
31
+ this.#colorMenu.addEventListener("-change", this.#onChange, { signal });
32
+ this.#updateUI();
33
+ }
34
+ disconnectedCallback() {
35
+ super.disconnectedCallback();
36
+ this.#controller?.abort();
37
+ this.#controller = null;
38
+ }
39
+ static get observedAttributes() {
40
+ return ["open", "value"];
41
+ }
42
+ attributeChangedCallback(name, oldVal, newVal) {
43
+ if (oldVal === newVal) {
44
+ return;
24
45
  }
25
- connectedCallback() {
26
- super.connectedCallback();
27
- this.#controller = new AbortController();
28
- const { signal } = this.#controller;
29
- this.#selectButton.addEventListener('-click', this.#onOpen, { signal });
30
- this.#popover.addEventListener('-close', this.#onClose, { signal });
31
- this.#colorMenu.addEventListener('-change', this.#onChange, { signal });
46
+ switch (name) {
47
+ case "open":
48
+ case "value": {
32
49
  this.#updateUI();
50
+ break;
51
+ }
33
52
  }
34
- disconnectedCallback() {
35
- super.disconnectedCallback();
36
- this.#controller?.abort();
37
- this.#controller = null;
53
+ }
54
+ get open() {
55
+ return this.hasAttribute("open");
56
+ }
57
+ set open(value) {
58
+ if (value) {
59
+ this.setAttribute("open", "");
60
+ } else {
61
+ this.removeAttribute("open");
38
62
  }
39
- static get observedAttributes() {
40
- return ['open', 'value'];
63
+ }
64
+ get value() {
65
+ return this.getAttribute("value") ?? "";
66
+ }
67
+ set value(newValue) {
68
+ if (newValue !== "") {
69
+ this.setAttribute("value", newValue);
70
+ } else {
71
+ this.removeAttribute("value");
41
72
  }
42
- attributeChangedCallback(name, oldVal, newVal) {
43
- if (oldVal === newVal) {
44
- return;
45
- }
46
- switch (name) {
47
- case 'open':
48
- case 'value': {
49
- this.#updateUI();
50
- break;
51
- }
52
- }
73
+ }
74
+ #updateUI() {
75
+ if (!this.isDomConnected) {
76
+ return;
53
77
  }
54
- get open() {
55
- return this.hasAttribute('open');
56
- }
57
- set open(value) {
58
- if (value) {
59
- this.setAttribute('open', '');
60
- }
61
- else {
62
- this.removeAttribute('open');
63
- }
64
- }
65
- get value() {
66
- return this.getAttribute('value') ?? '';
67
- }
68
- set value(newValue) {
69
- if (newValue !== '') {
70
- this.setAttribute('value', newValue);
71
- }
72
- else {
73
- this.removeAttribute('value');
74
- }
75
- }
76
- #updateUI() {
77
- if (!this.isDomConnected) {
78
- return;
79
- }
80
- this.#popover.toggleAttribute('open', this.open);
81
- this.#selectButton.setAttribute('text', this.value);
82
- this.#colorSwatch.setAttribute('name', this.value);
83
- this.#colorMenu.setAttribute('value', this.value);
84
- }
85
- #onClose = () => {
86
- this.open = false;
87
- };
88
- #onOpen = () => {
89
- this.open = true;
90
- };
91
- #onChange = (e) => {
92
- this.value = e.detail;
93
- this.dispatchEvent(new CustomEvent('-change', { detail: e.detail }));
94
- };
78
+ this.#popover.toggleAttribute("open", this.open);
79
+ this.#selectButton.setAttribute("text", this.value);
80
+ this.#colorSwatch.setAttribute("name", this.value);
81
+ this.#colorMenu.setAttribute("value", this.value);
82
+ }
83
+ #onClose = () => {
84
+ this.open = false;
85
+ };
86
+ #onOpen = () => {
87
+ this.open = true;
88
+ };
89
+ #onChange = (e) => {
90
+ this.value = e.detail;
91
+ this.dispatchEvent(new CustomEvent("-change", { detail: e.detail }));
92
+ };
95
93
  }
96
- defineCustomElement('sinch-labs-color-select', ColorSelect);
94
+ defineCustomElement("sinch-labs-color-select", ColorSelect);
95
+ export {
96
+ ColorSelect
97
+ };
package/imports.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /// <reference types="vite/client" />
2
+
1
3
  declare module '*.html' {
2
4
  const value: string
3
5
  export default value
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
- /// Nectary Labs
2
- // Import to register the phone preview RCS channel web component
3
- import './phone-preview-rcs-channel';
4
- import './phone-preview-rcs-chat-message';
5
- export default {};
1
+ import "./phone-preview-rcs-channel/index.js";
2
+ import "./phone-preview-rcs-chat-message/index.js";
3
+ const index = {};
4
+ export {
5
+ index as default
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/labs",
3
- "version": "2.5.39",
3
+ "version": "2.5.40",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -15,16 +15,17 @@
15
15
  "access": "public"
16
16
  },
17
17
  "scripts": {
18
- "build": "NODE_ENV=production && rimraf lib/ && tsc"
18
+ "build": "vite build && npx tsc --declaration --emitDeclarationOnly",
19
+ "dev": "vite build --watch"
19
20
  },
20
21
  "dependencies": {
21
22
  "@nectary/components": "5.15.4"
22
23
  },
23
24
  "devDependencies": {
24
- "@types/node": "^18.17.17",
25
+ "@types/node": "22.12.0",
25
26
  "@types/react": "^18.2.21",
26
- "rimraf": "^3.0.2",
27
- "ts-node": "^10.9.1",
28
- "typescript": "^5.2.2"
27
+ "glob": "^11.0.1",
28
+ "typescript": "^5.2.2",
29
+ "vite": "^7.0.6"
29
30
  }
30
31
  }
@@ -1,94 +1,86 @@
1
- import { defineCustomElement, NectaryElement } from '../utils';
2
- import templateHTML from './template.html';
3
- const template = document.createElement('template');
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';
3
+ const template = document.createElement("template");
4
4
  template.innerHTML = templateHTML;
5
- /**
6
- * Container for channel previews in a styled phone container.
7
- * This container uses a custom scaling where the internal elements are scaled to fit the container from a fixed size.
8
- * Because of the fixed size, absolute units (px) are preferred over relative units (rem, em) for the internal elements.
9
- *
10
- * @param props.locale Clock locale.
11
- * @param props.clock Clock `Intl.DateTimeFormat` options.
12
- * @param props.children Content to display in the phone container.
13
- */
14
- export class PhonePreview extends NectaryElement {
15
- #clockElement;
16
- #resizeObserver;
17
- #clockInterval = null;
18
- #formatter;
19
- constructor() {
20
- super();
21
- const shadowRoot = this.attachShadow();
22
- shadowRoot.appendChild(template.content.cloneNode(true));
23
- this.#clockElement = shadowRoot.querySelector('#clock');
24
- this.#resizeObserver = new ResizeObserver(() => {
25
- this.#updateScale();
26
- });
27
- this.#formatter = new Intl.DateTimeFormat(this.locale, this.clockOptions);
5
+ class PhonePreview extends NectaryElement {
6
+ #clockElement;
7
+ #resizeObserver;
8
+ #clockInterval = null;
9
+ #formatter;
10
+ constructor() {
11
+ super();
12
+ const shadowRoot = this.attachShadow();
13
+ shadowRoot.appendChild(template.content.cloneNode(true));
14
+ this.#clockElement = shadowRoot.querySelector("#clock");
15
+ this.#resizeObserver = new ResizeObserver(() => {
16
+ this.#updateScale();
17
+ });
18
+ this.#formatter = new Intl.DateTimeFormat(this.locale, this.clockOptions);
19
+ }
20
+ connectedCallback() {
21
+ super.connectedCallback();
22
+ const section = this.shadowRoot.querySelector("section");
23
+ this.#resizeObserver.observe(this);
24
+ this.#resizeObserver.observe(section);
25
+ this.#startClock();
26
+ this.#updateClock();
27
+ }
28
+ disconnectedCallback() {
29
+ super.disconnectedCallback();
30
+ this.#resizeObserver.disconnect();
31
+ this.#stopClock();
32
+ }
33
+ static get observedAttributes() {
34
+ return ["locale", "clock"];
35
+ }
36
+ attributeChangedCallback() {
37
+ this.#formatter = new Intl.DateTimeFormat(this.locale, this.clockOptions);
38
+ this.#updateClock();
39
+ }
40
+ get locale() {
41
+ return this.getAttribute("locale") ?? "en-US";
42
+ }
43
+ set locale(value) {
44
+ this.setAttribute("locale", value);
45
+ }
46
+ get clockOptions() {
47
+ const clockAttr = this.getAttribute("clock");
48
+ if (clockAttr !== null && clockAttr !== "") {
49
+ try {
50
+ return JSON.parse(clockAttr);
51
+ } catch {
52
+ }
28
53
  }
29
- connectedCallback() {
30
- super.connectedCallback();
31
- const section = this.shadowRoot.querySelector('section');
32
- this.#resizeObserver.observe(this);
33
- this.#resizeObserver.observe(section);
34
- this.#startClock();
35
- this.#updateClock();
54
+ return { hour: "2-digit", minute: "2-digit" };
55
+ }
56
+ set clockOptions(value) {
57
+ this.setAttribute("clock", JSON.stringify(value));
58
+ }
59
+ #updateScale() {
60
+ const style = getComputedStyle(this);
61
+ const baseSize = parseFloat(style.getPropertyValue("--base-size"));
62
+ const currentSize = this.getBoundingClientRect().width;
63
+ this.style.setProperty("--scale", `${currentSize / baseSize}`);
64
+ }
65
+ #startClock() {
66
+ this.#stopClock();
67
+ this.#clockInterval = window.setInterval(() => {
68
+ this.#updateClock();
69
+ }, 6e4);
70
+ }
71
+ #stopClock() {
72
+ if (this.#clockInterval !== null) {
73
+ clearInterval(this.#clockInterval);
74
+ this.#clockInterval = null;
36
75
  }
37
- disconnectedCallback() {
38
- super.disconnectedCallback();
39
- this.#resizeObserver.disconnect();
40
- this.#stopClock();
41
- }
42
- static get observedAttributes() {
43
- return ['locale', 'clock'];
44
- }
45
- attributeChangedCallback() {
46
- this.#formatter = new Intl.DateTimeFormat(this.locale, this.clockOptions);
47
- this.#updateClock();
48
- }
49
- get locale() {
50
- return this.getAttribute('locale') ?? 'en-US';
51
- }
52
- set locale(value) {
53
- this.setAttribute('locale', value);
54
- }
55
- get clockOptions() {
56
- const clockAttr = this.getAttribute('clock');
57
- if (clockAttr !== null && clockAttr !== '') {
58
- try {
59
- return JSON.parse(clockAttr);
60
- }
61
- catch {
62
- // Fallback to default if JSON parsing fails
63
- }
64
- }
65
- return { hour: '2-digit', minute: '2-digit' };
66
- }
67
- set clockOptions(value) {
68
- this.setAttribute('clock', JSON.stringify(value));
69
- }
70
- #updateScale() {
71
- const style = getComputedStyle(this);
72
- const baseSize = parseFloat(style.getPropertyValue('--base-size'));
73
- const currentSize = this.getBoundingClientRect().width;
74
- this.style.setProperty('--scale', `${currentSize / baseSize}`);
75
- }
76
- #startClock() {
77
- this.#stopClock();
78
- this.#clockInterval = window.setInterval(() => {
79
- this.#updateClock();
80
- }, 60000);
81
- }
82
- #stopClock() {
83
- if (this.#clockInterval !== null) {
84
- clearInterval(this.#clockInterval);
85
- this.#clockInterval = null;
86
- }
87
- }
88
- #updateClock() {
89
- if (this.isDomConnected) {
90
- this.#clockElement.textContent = this.#formatter.format(new Date());
91
- }
76
+ }
77
+ #updateClock() {
78
+ if (this.isDomConnected) {
79
+ this.#clockElement.textContent = this.#formatter.format(/* @__PURE__ */ new Date());
92
80
  }
81
+ }
93
82
  }
94
- defineCustomElement('sinch-labs-phone-preview', PhonePreview);
83
+ defineCustomElement("sinch-labs-phone-preview", PhonePreview);
84
+ export {
85
+ PhonePreview
86
+ };