@nectary/components 0.18.0 → 0.19.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.
@@ -0,0 +1,13 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchChatElement = HTMLElement & {};
3
+ export declare type TSinchChatReact = TSinchElementReact<TSinchChatElement> & {};
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-chat': TSinchChatReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-chat': TSinchChatElement;
12
+ }
13
+ }
package/chat/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import { defineCustomElement } from '../utils';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;gap:32px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
3
+ const template = document.createElement('template');
4
+ template.innerHTML = templateHTML;
5
+ defineCustomElement('sinch-chat', class extends HTMLElement {
6
+ constructor() {
7
+ super();
8
+ const shadowRoot = this.attachShadow({
9
+ mode: 'closed',
10
+ delegatesFocus: true
11
+ });
12
+ shadowRoot.appendChild(template.content.cloneNode(true));
13
+ }
14
+
15
+ });
@@ -0,0 +1,21 @@
1
+ import '../avatar';
2
+ import type { TSinchAvatarElement, TSinchAvatarReact } from '../avatar';
3
+ import type { TSinchElementReact } from '../types';
4
+ export declare type TSinchChatAvatarElement = HTMLElement & {
5
+ alt: TSinchAvatarElement['alt'];
6
+ src: TSinchAvatarElement['src'];
7
+ };
8
+ export declare type TSinchChatAvatarReact = TSinchElementReact<TSinchChatAvatarElement> & {
9
+ alt: TSinchAvatarReact['alt'];
10
+ src?: TSinchAvatarReact['src'];
11
+ };
12
+ declare global {
13
+ namespace JSX {
14
+ interface IntrinsicElements {
15
+ 'sinch-chat-avatar': TSinchChatAvatarReact;
16
+ }
17
+ }
18
+ interface HTMLElementTagNameMap {
19
+ 'sinch-chat-avatar': TSinchChatAvatarElement;
20
+ }
21
+ }
@@ -0,0 +1,69 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$avatar;
5
+
6
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
+
8
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
+
10
+ import '../avatar';
11
+ import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
12
+ const templateHTML = '<style>:host{display:contents}</style><sinch-avatar background="blue" size="l"></sinch-avatar>';
13
+ const template = document.createElement('template');
14
+ template.innerHTML = templateHTML;
15
+ defineCustomElement('sinch-chat-avatar', (_$avatar = new WeakMap(), class extends HTMLElement {
16
+ constructor() {
17
+ super();
18
+
19
+ _classPrivateFieldInitSpec(this, _$avatar, {
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+
24
+ const shadowRoot = this.attachShadow({
25
+ mode: 'closed',
26
+ delegatesFocus: true
27
+ });
28
+ shadowRoot.appendChild(template.content.cloneNode(true));
29
+
30
+ _classPrivateFieldSet(this, _$avatar, shadowRoot.querySelector('sinch-avatar'));
31
+ }
32
+
33
+ static get observedAttributes() {
34
+ return ['src', 'alt'];
35
+ }
36
+
37
+ attributeChangedCallback(name, _, newVal) {
38
+ switch (name) {
39
+ case 'src':
40
+ {
41
+ updateAttribute(_classPrivateFieldGet(this, _$avatar), 'src', newVal);
42
+ break;
43
+ }
44
+
45
+ case 'alt':
46
+ {
47
+ updateAttribute(_classPrivateFieldGet(this, _$avatar), 'alt', newVal);
48
+ break;
49
+ }
50
+ }
51
+ }
52
+
53
+ get src() {
54
+ return getAttribute(this, 'src', null);
55
+ }
56
+
57
+ set src(value) {
58
+ updateAttribute(this, 'src', value);
59
+ }
60
+
61
+ get alt() {
62
+ return getAttribute(this, 'alt', '');
63
+ }
64
+
65
+ set alt(value) {
66
+ updateAttribute(this, 'alt', value);
67
+ }
68
+
69
+ }));
@@ -0,0 +1,24 @@
1
+ import type { TSinchChatBubbleType } from '../chat-bubble';
2
+ import type { TSinchElementReact } from '../types';
3
+ export declare type TSinchChatBlockElement = HTMLElement & {
4
+ type: TSinchChatBubbleType | null;
5
+ firstName: string | null;
6
+ lastName: string | null;
7
+ timestamp: string | null;
8
+ };
9
+ export declare type TSinchChatBlockReact = TSinchElementReact<TSinchChatBlockElement> & {
10
+ type: TSinchChatBubbleType;
11
+ firstName?: string;
12
+ lastName?: string;
13
+ timestamp?: string;
14
+ };
15
+ declare global {
16
+ namespace JSX {
17
+ interface IntrinsicElements {
18
+ 'sinch-chat-block': TSinchChatBlockReact;
19
+ }
20
+ }
21
+ interface HTMLElementTagNameMap {
22
+ 'sinch-chat-block': TSinchChatBlockElement;
23
+ }
24
+ }
@@ -0,0 +1,148 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$firstName, _$lastName, _$timeStamp, _$bubbleSlot, _onBubbleSlotChange, _updateBubbleTypes;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
+
8
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
+
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import { typeValues } from '../chat-bubble';
15
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
16
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:56px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-stormy-400)}#avatar{display:none;position:absolute;left:0;top:24px}:host([type=customer])>#wrapper{align-items:flex-start}:host([type=customer]) #avatar{display:block}</style><div id="wrapper"><div id="avatar"><slot name="avatar"></slot></div><p id="stamp"><span id="firstname"></span><span id="lastname"></span>&bull;<span id="time"></span></p><slot name="bubble"></slot></div>';
17
+ const template = document.createElement('template');
18
+ template.innerHTML = templateHTML;
19
+ defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName = new WeakMap(), _$timeStamp = new WeakMap(), _$bubbleSlot = new WeakMap(), _onBubbleSlotChange = new WeakMap(), _updateBubbleTypes = new WeakSet(), class extends HTMLElement {
20
+ constructor() {
21
+ super();
22
+
23
+ _classPrivateMethodInitSpec(this, _updateBubbleTypes);
24
+
25
+ _classPrivateFieldInitSpec(this, _$firstName, {
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+
30
+ _classPrivateFieldInitSpec(this, _$lastName, {
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+
35
+ _classPrivateFieldInitSpec(this, _$timeStamp, {
36
+ writable: true,
37
+ value: void 0
38
+ });
39
+
40
+ _classPrivateFieldInitSpec(this, _$bubbleSlot, {
41
+ writable: true,
42
+ value: void 0
43
+ });
44
+
45
+ _classPrivateFieldInitSpec(this, _onBubbleSlotChange, {
46
+ writable: true,
47
+ value: () => {
48
+ _classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
49
+ }
50
+ });
51
+
52
+ const shadowRoot = this.attachShadow({
53
+ mode: 'closed',
54
+ delegatesFocus: true
55
+ });
56
+ shadowRoot.appendChild(template.content.cloneNode(true));
57
+
58
+ _classPrivateFieldSet(this, _$firstName, shadowRoot.querySelector('#firstname'));
59
+
60
+ _classPrivateFieldSet(this, _$lastName, shadowRoot.querySelector('#lastname'));
61
+
62
+ _classPrivateFieldSet(this, _$timeStamp, shadowRoot.querySelector('#time'));
63
+
64
+ _classPrivateFieldSet(this, _$bubbleSlot, shadowRoot.querySelector('slot[name="bubble"]'));
65
+ }
66
+
67
+ connectedCallback() {
68
+ _classPrivateFieldGet(this, _$bubbleSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
69
+ }
70
+
71
+ disconnectedCallback() {
72
+ _classPrivateFieldGet(this, _$bubbleSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
73
+ }
74
+
75
+ static get observedAttributes() {
76
+ return ['firstname', 'lastname', 'timestamp', 'type'];
77
+ }
78
+
79
+ attributeChangedCallback(name, _, newVal) {
80
+ switch (name) {
81
+ case 'firstname':
82
+ {
83
+ _classPrivateFieldGet(this, _$firstName).textContent = newVal;
84
+ break;
85
+ }
86
+
87
+ case 'lastname':
88
+ {
89
+ _classPrivateFieldGet(this, _$lastName).textContent = newVal;
90
+ break;
91
+ }
92
+
93
+ case 'timestamp':
94
+ {
95
+ _classPrivateFieldGet(this, _$timeStamp).textContent = newVal;
96
+ break;
97
+ }
98
+
99
+ case 'type':
100
+ {
101
+ _classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
102
+
103
+ break;
104
+ }
105
+ }
106
+ }
107
+
108
+ set type(value) {
109
+ updateLiteralAttribute(this, typeValues, 'type', value);
110
+ }
111
+
112
+ get type() {
113
+ return getLiteralAttribute(this, typeValues, 'type', null);
114
+ }
115
+
116
+ set firstName(value) {
117
+ updateAttribute(this, 'firstname', value);
118
+ }
119
+
120
+ get firstName() {
121
+ return getAttribute(this, 'firstname', null);
122
+ }
123
+
124
+ set lastName(value) {
125
+ updateAttribute(this, 'lastname', value);
126
+ }
127
+
128
+ get lastName() {
129
+ return getAttribute(this, 'lastname', null);
130
+ }
131
+
132
+ set timestamp(value) {
133
+ updateAttribute(this, 'timestamp', value);
134
+ }
135
+
136
+ get timestamp() {
137
+ return getAttribute(this, 'timestamp', null);
138
+ }
139
+
140
+ }));
141
+
142
+ function _updateBubbleTypes2() {
143
+ const typeValue = getAttribute(this, 'type');
144
+
145
+ _classPrivateFieldGet(this, _$bubbleSlot).assignedElements().forEach(el => {
146
+ updateAttribute(el, 'data-type', typeValue);
147
+ });
148
+ }
@@ -0,0 +1,20 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare const typeValues: readonly ["customer", "agent", "agent-prev"];
3
+ export declare type TSinchChatBubbleType = typeof typeValues[number];
4
+ export declare type TSinchChatBubbleElement = HTMLElement & {
5
+ readonly type: TSinchChatBubbleType | null;
6
+ text: string;
7
+ };
8
+ export declare type TSinchChatBubbleReact = TSinchElementReact<TSinchChatBubbleElement> & {
9
+ text: string;
10
+ };
11
+ declare global {
12
+ namespace JSX {
13
+ interface IntrinsicElements {
14
+ 'sinch-chat-bubble': TSinchChatBubbleReact;
15
+ }
16
+ }
17
+ interface HTMLElementTagNameMap {
18
+ 'sinch-chat-bubble': TSinchChatBubbleElement;
19
+ }
20
+ }
@@ -0,0 +1,59 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$text;
5
+
6
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
+
8
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
+
10
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute } from '../utils';
11
+ const templateHTML = '<style>:host{display:block;outline:0}#text{padding:12px 16px;border-radius:16px;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500);margin:0;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#text{background-color:var(--sinch-color-snow-500);border-top-left-radius:0}:host([data-type=agent-prev])>#text{background-color:var(--sinch-color-snow-700);border-top-right-radius:0}:host([data-type=agent])>#text{background-color:var(--sinch-color-honey-200);border-top-right-radius:0}</style><p id="text"></p>';
12
+ export const typeValues = ['customer', 'agent', 'agent-prev'];
13
+ const template = document.createElement('template');
14
+ template.innerHTML = templateHTML;
15
+ defineCustomElement('sinch-chat-bubble', (_$text = new WeakMap(), class extends HTMLElement {
16
+ constructor() {
17
+ super();
18
+
19
+ _classPrivateFieldInitSpec(this, _$text, {
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+
24
+ const shadowRoot = this.attachShadow({
25
+ mode: 'closed',
26
+ delegatesFocus: true
27
+ });
28
+ shadowRoot.appendChild(template.content.cloneNode(true));
29
+
30
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
31
+ }
32
+
33
+ static get observedAttributes() {
34
+ return ['text'];
35
+ }
36
+
37
+ attributeChangedCallback(name, _, newVal) {
38
+ switch (name) {
39
+ case 'text':
40
+ {
41
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
42
+ break;
43
+ }
44
+ }
45
+ }
46
+
47
+ set text(value) {
48
+ updateAttribute(this, 'text', value);
49
+ }
50
+
51
+ get text() {
52
+ return getAttribute(this, 'text', '');
53
+ }
54
+
55
+ get type() {
56
+ return getLiteralAttribute(this, typeValues, 'data-type', null);
57
+ }
58
+
59
+ }));
package/dialog/index.js CHANGED
@@ -78,7 +78,6 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
78
78
  _classPrivateFieldInitSpec(this, _onBackdropClick, {
79
79
  writable: true,
80
80
  value: e => {
81
- e.stopPropagation();
82
81
  const rect = this.dialogRect;
83
82
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
84
83
 
@@ -187,7 +186,9 @@ function _dispatchCloseEvent2() {
187
186
 
188
187
  function _setOpen2(isOpen) {
189
188
  if (isOpen) {
190
- _classPrivateFieldGet(this, _$dialog).showModal();
189
+ if (!getBooleanAttribute(_classPrivateFieldGet(this, _$dialog), 'open')) {
190
+ _classPrivateFieldGet(this, _$dialog).showModal();
191
+ }
191
192
  } else {
192
193
  _classPrivateFieldGet(this, _$dialog).close();
193
194
  }
package/dropdown/index.js CHANGED
@@ -285,7 +285,9 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
285
285
 
286
286
  function _setOpen2(isOpen) {
287
287
  if (isOpen) {
288
- _classPrivateFieldGet(this, _$listbox).showModal();
288
+ if (!getBooleanAttribute(_classPrivateFieldGet(this, _$listbox), 'open')) {
289
+ _classPrivateFieldGet(this, _$listbox).showModal();
290
+ }
289
291
  } else {
290
292
  _classPrivateFieldGet(this, _$listbox).close();
291
293
  }
package/index.d.ts CHANGED
@@ -139,3 +139,7 @@ import './search-option';
139
139
  import './segment';
140
140
  import './segment-collapse';
141
141
  import './avatar';
142
+ import './chat-avatar';
143
+ import './chat-bubble';
144
+ import './chat-block';
145
+ import './chat';
package/index.js CHANGED
@@ -138,4 +138,8 @@ import './search';
138
138
  import './search-option';
139
139
  import './segment';
140
140
  import './segment-collapse';
141
- import './avatar';
141
+ import './avatar';
142
+ import './chat-avatar';
143
+ import './chat-bubble';
144
+ import './chat-block';
145
+ import './chat';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",