@nectary/components 2.12.4 → 3.0.1
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/lib/cjs/card/index.js +1 -1
- package/lib/cjs/card-container/index.js +1 -1
- package/lib/cjs/checkbox/index.js +1 -1
- package/lib/cjs/color-swatch/index.js +1 -1
- package/lib/cjs/date-picker/index.d.ts +0 -1
- package/lib/cjs/date-picker/index.js +1 -2
- package/lib/cjs/dialog/index.d.ts +0 -1
- package/lib/cjs/dialog/index.js +12 -8
- package/lib/cjs/emoji-picker/index.d.ts +0 -1
- package/lib/cjs/emoji-picker/index.js +2 -3
- package/lib/cjs/horizontal-stepper/index.js +1 -1
- package/lib/cjs/segment-collapse/index.d.ts +0 -1
- package/lib/cjs/segment-collapse/index.js +1 -2
- package/lib/cjs/select-menu/index.d.ts +0 -1
- package/lib/cjs/select-menu/index.js +1 -2
- package/lib/cjs/skeleton/index.js +1 -1
- package/lib/cjs/skeleton-item/index.js +1 -1
- package/lib/cjs/standalone.d.ts +0 -4
- package/lib/cjs/standalone.js +0 -4
- package/lib/cjs/time-picker/index.d.ts +0 -1
- package/lib/cjs/time-picker/index.js +1 -2
- package/lib/cjs/vertical-stepper/index.js +1 -1
- package/lib/esm/card/index.js +1 -1
- package/lib/esm/card-container/index.js +1 -1
- package/lib/esm/checkbox/index.js +1 -1
- package/lib/esm/color-swatch/index.js +1 -1
- package/lib/esm/date-picker/index.d.ts +0 -1
- package/lib/esm/date-picker/index.js +1 -2
- package/lib/esm/dialog/index.d.ts +0 -1
- package/lib/esm/dialog/index.js +12 -8
- package/lib/esm/emoji-picker/index.d.ts +0 -1
- package/lib/esm/emoji-picker/index.js +2 -3
- package/lib/esm/horizontal-stepper/index.js +1 -1
- package/lib/esm/segment-collapse/index.d.ts +0 -1
- package/lib/esm/segment-collapse/index.js +1 -2
- package/lib/esm/select-menu/index.d.ts +0 -1
- package/lib/esm/select-menu/index.js +1 -2
- package/lib/esm/skeleton/index.js +1 -1
- package/lib/esm/skeleton-item/index.js +1 -1
- package/lib/esm/standalone.d.ts +0 -4
- package/lib/esm/standalone.js +0 -4
- package/lib/esm/time-picker/index.d.ts +0 -1
- package/lib/esm/time-picker/index.js +1 -2
- package/lib/esm/vertical-stepper/index.js +1 -1
- package/package.json +1 -1
- package/lib/cjs/chat/index.d.ts +0 -11
- package/lib/cjs/chat/index.js +0 -13
- package/lib/cjs/chat/types.d.ts +0 -3
- package/lib/cjs/chat/types.js +0 -1
- package/lib/cjs/chat-block/index.d.ts +0 -11
- package/lib/cjs/chat-block/index.js +0 -88
- package/lib/cjs/chat-block/types.d.ts +0 -30
- package/lib/cjs/chat-block/types.js +0 -1
- package/lib/cjs/chat-bubble/index.d.ts +0 -11
- package/lib/cjs/chat-bubble/index.js +0 -43
- package/lib/cjs/chat-bubble/types.d.ts +0 -20
- package/lib/cjs/chat-bubble/types.js +0 -1
- package/lib/cjs/chat-bubble/utils.d.ts +0 -3
- package/lib/cjs/chat-bubble/utils.js +0 -8
- package/lib/cjs/icon-button/index.d.ts +0 -12
- package/lib/cjs/icon-button/index.js +0 -177
- package/lib/cjs/icon-button/types.d.ts +0 -44
- package/lib/cjs/icon-button/types.js +0 -1
- package/lib/cjs/icon-button/utils.d.ts +0 -2
- package/lib/cjs/icon-button/utils.js +0 -7
- package/lib/esm/chat/index.d.ts +0 -11
- package/lib/esm/chat/index.js +0 -11
- package/lib/esm/chat/types.d.ts +0 -3
- package/lib/esm/chat/types.js +0 -1
- package/lib/esm/chat-block/index.d.ts +0 -11
- package/lib/esm/chat-block/index.js +0 -86
- package/lib/esm/chat-block/types.d.ts +0 -30
- package/lib/esm/chat-block/types.js +0 -1
- package/lib/esm/chat-bubble/index.d.ts +0 -11
- package/lib/esm/chat-bubble/index.js +0 -41
- package/lib/esm/chat-bubble/types.d.ts +0 -20
- package/lib/esm/chat-bubble/types.js +0 -1
- package/lib/esm/chat-bubble/utils.d.ts +0 -3
- package/lib/esm/chat-bubble/utils.js +0 -2
- package/lib/esm/icon-button/index.d.ts +0 -12
- package/lib/esm/icon-button/index.js +0 -175
- package/lib/esm/icon-button/types.d.ts +0 -44
- package/lib/esm/icon-button/types.js +0 -1
- package/lib/esm/icon-button/utils.d.ts +0 -2
- package/lib/esm/icon-button/utils.js +0 -1
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require('../tooltip');
|
|
4
|
-
var _utils = require('../utils');
|
|
5
|
-
var _size = require('../utils/size');
|
|
6
|
-
var _utils2 = require('./utils');
|
|
7
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{display:block;position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer;user-select:none;contain:size;--sinch-global-color-icon:var(--sinch-local-color-icon)}:host([disabled]) #button{cursor:initial}:host([data-size="l"]) #button{--sinch-local-size:var(--sinch-comp-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-l)}#button,:host([data-size="m"]) #button{--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m)}:host([data-size="s"]) #button{--sinch-local-size:var(--sinch-comp-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-s)}:host([data-size=xs]) #button{--sinch-local-size:var(--sinch-comp-button-size-container-xs);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-xs);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-xs)}:host([type=primary]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-initial);--sinch-local-color-outline:var(--sinch-comp-button-color-primary-default-outline-focus)}:host([type=secondary]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-initial);--sinch-local-color-outline:var(--sinch-comp-button-color-secondary-default-outline-focus)}#button,:host([type=tertiary]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-secondary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-subtle-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-initial);--sinch-local-color-outline:var(--sinch-comp-button-color-subtle-secondary-default-outline-focus)}:host([type=primary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-disabled)}:host([type=secondary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-disabled)}:host([disabled]) #button,:host([type=tertiary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-secondary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-subtle-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-disabled)}:host([type=primary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-focus)}:host([type=secondary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-focus)}:host(:focus),:host([type=tertiary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-focus)}:host([type=primary]:not([disabled]):hover) #button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-hover)}:host([type=secondary]:not([disabled]):hover) #button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-hover)}:host(:not([disabled]):hover) #button,:host([type=tertiary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-hover)}:host([type=primary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-active)}:host([type=secondary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-active)}:host(:not([disabled]):active) #button,:host([type=tertiary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-active)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}:host(:focus-visible) #button::after{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-local-color-outline);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:100%}</style><sinch-tooltip id="tooltip"><div id="button"><div id="content" inert><slot name="icon"></slot></div></div></sinch-tooltip>';
|
|
8
|
-
const template = document.createElement('template');
|
|
9
|
-
template.innerHTML = templateHTML;
|
|
10
|
-
(0, _utils.defineCustomElement)('sinch-icon-button', class extends _utils.NectaryElement {
|
|
11
|
-
#$button;
|
|
12
|
-
#$tooltip;
|
|
13
|
-
#controller = null;
|
|
14
|
-
#sizeContext;
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
const shadowRoot = this.attachShadow();
|
|
18
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
19
|
-
this.#$button = shadowRoot.querySelector('#button');
|
|
20
|
-
this.#$tooltip = shadowRoot.querySelector('#tooltip');
|
|
21
|
-
this.#sizeContext = new _utils.Context(this.#$button, 'size');
|
|
22
|
-
}
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
super.connectedCallback();
|
|
25
|
-
this.#controller = new AbortController();
|
|
26
|
-
const options = {
|
|
27
|
-
signal: this.#controller.signal
|
|
28
|
-
};
|
|
29
|
-
this.role = 'button';
|
|
30
|
-
this.tabIndex = 0;
|
|
31
|
-
this.addEventListener('click', this.#onButtonClick, options);
|
|
32
|
-
this.addEventListener('focus', this.#onButtonFocus, options);
|
|
33
|
-
this.addEventListener('blur', this.#onButtonBlur, options);
|
|
34
|
-
this.addEventListener('keydown', this.#onButtonKeydown, options);
|
|
35
|
-
this.addEventListener('-click', this.#onClickReactHandler, options);
|
|
36
|
-
this.addEventListener('-focus', this.#onFocusReactHandler, options);
|
|
37
|
-
this.addEventListener('-blur', this.#onBlurReactHandler, options);
|
|
38
|
-
this.#$tooltip.addEventListener('-show', this.#onTooltipShow, options);
|
|
39
|
-
this.#$tooltip.addEventListener('-hide', this.#onTooltipHide, options);
|
|
40
|
-
this.addEventListener('-tooltip-show', this.#onTooltipShowReactHandler, options);
|
|
41
|
-
this.addEventListener('-tooltip-hide', this.#onTooltipHideReactHandler, options);
|
|
42
|
-
(0, _utils.subscribeContext)(this, 'size', this.#onContextSize, this.#controller.signal);
|
|
43
|
-
this.#sizeContext.listen(this.#controller.signal);
|
|
44
|
-
this.#onSizeUpdate();
|
|
45
|
-
}
|
|
46
|
-
disconnectedCallback() {
|
|
47
|
-
super.disconnectedCallback();
|
|
48
|
-
this.#controller.abort();
|
|
49
|
-
this.#controller = null;
|
|
50
|
-
}
|
|
51
|
-
static get observedAttributes() {
|
|
52
|
-
return ['size', 'disabled', 'aria-label', 'data-size'];
|
|
53
|
-
}
|
|
54
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
55
|
-
switch (name) {
|
|
56
|
-
case 'disabled':
|
|
57
|
-
{
|
|
58
|
-
if ((0, _utils.isAttrEqual)(oldVal, newVal)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const isDisabled = (0, _utils.isAttrTrue)(newVal);
|
|
62
|
-
this.ariaDisabled = isDisabled.toString();
|
|
63
|
-
(0, _utils.updateBooleanAttribute)(this, 'disabled', isDisabled);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case 'aria-label':
|
|
67
|
-
{
|
|
68
|
-
(0, _utils.updateAttribute)(this.#$tooltip, 'text', newVal);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case 'size':
|
|
72
|
-
{
|
|
73
|
-
(0, _utils.updateAttribute)(this, 'data-size', newVal);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'data-size':
|
|
77
|
-
{
|
|
78
|
-
this.#onSizeUpdate();
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
set type(value) {
|
|
84
|
-
(0, _utils.updateLiteralAttribute)(this, _utils2.typeValues, 'type', value);
|
|
85
|
-
}
|
|
86
|
-
get type() {
|
|
87
|
-
return (0, _utils.getLiteralAttribute)(this, _utils2.typeValues, 'type', 'tertiary');
|
|
88
|
-
}
|
|
89
|
-
set disabled(isDisabled) {
|
|
90
|
-
(0, _utils.updateBooleanAttribute)(this, 'disabled', isDisabled);
|
|
91
|
-
}
|
|
92
|
-
get disabled() {
|
|
93
|
-
return (0, _utils.getBooleanAttribute)(this, 'disabled');
|
|
94
|
-
}
|
|
95
|
-
set size(size) {
|
|
96
|
-
(0, _utils.updateLiteralAttribute)(this, _size.sizeExValues, 'size', size);
|
|
97
|
-
}
|
|
98
|
-
get size() {
|
|
99
|
-
return (0, _utils.getLiteralAttribute)(this, _size.sizeExValues, 'size', _size.DEFAULT_SIZE);
|
|
100
|
-
}
|
|
101
|
-
get tooltipRect() {
|
|
102
|
-
return this.#$tooltip.tooltipRect;
|
|
103
|
-
}
|
|
104
|
-
get focusable() {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
#onSizeUpdate() {
|
|
108
|
-
if (!this.isDomConnected) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const size = (0, _utils.getAttribute)(this, 'data-size', _size.DEFAULT_SIZE);
|
|
112
|
-
this.#sizeContext.dispatch(size);
|
|
113
|
-
}
|
|
114
|
-
#onContextSize = e => {
|
|
115
|
-
if (this.hasAttribute('size')) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
switch (e.detail) {
|
|
119
|
-
case 'l':
|
|
120
|
-
{
|
|
121
|
-
this.setAttribute('data-size', 'm');
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case 'm':
|
|
125
|
-
{
|
|
126
|
-
this.setAttribute('data-size', 's');
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
default:
|
|
130
|
-
{
|
|
131
|
-
this.setAttribute('data-size', 'xs');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
#onButtonClick = () => {
|
|
136
|
-
if (!this.disabled) {
|
|
137
|
-
this.dispatchEvent(new CustomEvent('-click'));
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
#onButtonFocus = () => {
|
|
141
|
-
this.dispatchEvent(new CustomEvent('-focus'));
|
|
142
|
-
};
|
|
143
|
-
#onButtonBlur = () => {
|
|
144
|
-
this.dispatchEvent(new CustomEvent('-blur'));
|
|
145
|
-
};
|
|
146
|
-
#onButtonKeydown = e => {
|
|
147
|
-
switch (e.code) {
|
|
148
|
-
case 'Space':
|
|
149
|
-
case 'Enter':
|
|
150
|
-
{
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
this.click();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
#onTooltipShow = () => {
|
|
157
|
-
this.dispatchEvent(new CustomEvent('-tooltip-show'));
|
|
158
|
-
};
|
|
159
|
-
#onTooltipHide = () => {
|
|
160
|
-
this.dispatchEvent(new CustomEvent('-tooltip-hide'));
|
|
161
|
-
};
|
|
162
|
-
#onFocusReactHandler = () => {
|
|
163
|
-
(0, _utils.getReactEventHandler)(this, 'on-focus')?.();
|
|
164
|
-
};
|
|
165
|
-
#onBlurReactHandler = () => {
|
|
166
|
-
(0, _utils.getReactEventHandler)(this, 'on-blur')?.();
|
|
167
|
-
};
|
|
168
|
-
#onClickReactHandler = e => {
|
|
169
|
-
(0, _utils.getReactEventHandler)(this, 'on-click')?.(e);
|
|
170
|
-
};
|
|
171
|
-
#onTooltipShowReactHandler = () => {
|
|
172
|
-
(0, _utils.getReactEventHandler)(this, 'on-tooltip-show')?.();
|
|
173
|
-
};
|
|
174
|
-
#onTooltipHideReactHandler = () => {
|
|
175
|
-
(0, _utils.getReactEventHandler)(this, 'on-tooltip-hide')?.();
|
|
176
|
-
};
|
|
177
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
import type { TSinchSizeEx } from '../utils/size';
|
|
3
|
-
export type TSinchIconButtonType = 'primary' | 'secondary' | 'tertiary';
|
|
4
|
-
export type TSinchIconButtonElement = HTMLElement & {
|
|
5
|
-
/** Type, `tertiary` by default */
|
|
6
|
-
type: TSinchIconButtonType;
|
|
7
|
-
/** Size, `m` by default */
|
|
8
|
-
size: TSinchSizeEx;
|
|
9
|
-
/** Disabled */
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
readonly tooltipRect: TRect;
|
|
12
|
-
/** Click event */
|
|
13
|
-
addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
|
|
14
|
-
/** Focus event */
|
|
15
|
-
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
16
|
-
/** Blur event */
|
|
17
|
-
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
18
|
-
/** Type, `tertiary` by default */
|
|
19
|
-
setAttribute(name: 'type', value: string): void;
|
|
20
|
-
/** Size, `m` by default */
|
|
21
|
-
setAttribute(name: 'size', value: string): void;
|
|
22
|
-
/** Disabled */
|
|
23
|
-
setAttribute(name: 'disabled', value: ''): void;
|
|
24
|
-
};
|
|
25
|
-
export type TSinchIconButtonReact = TSinchElementReact<TSinchIconButtonElement> & {
|
|
26
|
-
/** Type, `tertiary` by default */
|
|
27
|
-
type?: TSinchIconButtonType;
|
|
28
|
-
/** Size, `m` by default */
|
|
29
|
-
size?: TSinchSizeEx;
|
|
30
|
-
/** Disabled */
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
/** Label that is used for a11y */
|
|
33
|
-
'aria-label': string;
|
|
34
|
-
/** Click event handler */
|
|
35
|
-
'on-click'?: (e: CustomEvent<void>) => void;
|
|
36
|
-
/** Focus event handler */
|
|
37
|
-
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
38
|
-
/** Blur event handler */
|
|
39
|
-
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
40
|
-
/** Tooltip Show Event */
|
|
41
|
-
'on-tooltip-show'?: (e: CustomEvent<void>) => void;
|
|
42
|
-
/** Tooltip Hide Event */
|
|
43
|
-
'on-tooltip-hide'?: (e: CustomEvent<void>) => void;
|
|
44
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/lib/esm/chat/index.d.ts
DELETED
package/lib/esm/chat/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, NectaryElement } 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 NectaryElement {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
const shadowRoot = this.attachShadow();
|
|
9
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
10
|
-
}
|
|
11
|
-
});
|
package/lib/esm/chat/types.d.ts
DELETED
package/lib/esm/chat/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchChatBlockElement, TSinchChatBlockReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-chat-block': TSinchChatBlockReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-chat-block': TSinchChatBlockElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { typeValues } from '../chat-bubble/utils';
|
|
2
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:72px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-sys-font-body-xs);color:var(--sinch-sys-color-text-default)}#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>•<span id="time"></span></p><slot name="bubble"></slot></div>';
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = templateHTML;
|
|
6
|
-
defineCustomElement('sinch-chat-block', class extends NectaryElement {
|
|
7
|
-
#$firstName;
|
|
8
|
-
#$lastName;
|
|
9
|
-
#$timeStamp;
|
|
10
|
-
#$bubbleSlot;
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
const shadowRoot = this.attachShadow();
|
|
14
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
15
|
-
this.#$firstName = shadowRoot.querySelector('#firstname');
|
|
16
|
-
this.#$lastName = shadowRoot.querySelector('#lastname');
|
|
17
|
-
this.#$timeStamp = shadowRoot.querySelector('#time');
|
|
18
|
-
this.#$bubbleSlot = shadowRoot.querySelector('slot[name="bubble"]');
|
|
19
|
-
}
|
|
20
|
-
connectedCallback() {
|
|
21
|
-
this.#$bubbleSlot.addEventListener('slotchange', this.#onBubbleSlotChange);
|
|
22
|
-
}
|
|
23
|
-
disconnectedCallback() {
|
|
24
|
-
this.#$bubbleSlot.removeEventListener('slotchange', this.#onBubbleSlotChange);
|
|
25
|
-
}
|
|
26
|
-
static get observedAttributes() {
|
|
27
|
-
return ['firstname', 'lastname', 'timestamp', 'type'];
|
|
28
|
-
}
|
|
29
|
-
attributeChangedCallback(name, _, newVal) {
|
|
30
|
-
switch (name) {
|
|
31
|
-
case 'firstname':
|
|
32
|
-
{
|
|
33
|
-
this.#$firstName.textContent = newVal;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case 'lastname':
|
|
37
|
-
{
|
|
38
|
-
this.#$lastName.textContent = newVal;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case 'timestamp':
|
|
42
|
-
{
|
|
43
|
-
this.#$timeStamp.textContent = newVal;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'type':
|
|
47
|
-
{
|
|
48
|
-
this.#updateBubbleTypes();
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
set type(value) {
|
|
54
|
-
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
55
|
-
}
|
|
56
|
-
get type() {
|
|
57
|
-
return getLiteralAttribute(this, typeValues, 'type', null);
|
|
58
|
-
}
|
|
59
|
-
set firstName(value) {
|
|
60
|
-
updateAttribute(this, 'firstname', value);
|
|
61
|
-
}
|
|
62
|
-
get firstName() {
|
|
63
|
-
return getAttribute(this, 'firstname');
|
|
64
|
-
}
|
|
65
|
-
set lastName(value) {
|
|
66
|
-
updateAttribute(this, 'lastname', value);
|
|
67
|
-
}
|
|
68
|
-
get lastName() {
|
|
69
|
-
return getAttribute(this, 'lastname');
|
|
70
|
-
}
|
|
71
|
-
set timestamp(value) {
|
|
72
|
-
updateAttribute(this, 'timestamp', value);
|
|
73
|
-
}
|
|
74
|
-
get timestamp() {
|
|
75
|
-
return getAttribute(this, 'timestamp');
|
|
76
|
-
}
|
|
77
|
-
#onBubbleSlotChange = () => {
|
|
78
|
-
this.#updateBubbleTypes();
|
|
79
|
-
};
|
|
80
|
-
#updateBubbleTypes() {
|
|
81
|
-
const typeValue = getAttribute(this, 'type');
|
|
82
|
-
this.#$bubbleSlot.assignedElements().forEach(el => {
|
|
83
|
-
updateAttribute(el, 'data-type', typeValue);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchChatBlockType = 'customer' | 'agent' | 'agent-prev';
|
|
3
|
-
export type TSinchChatBlockElement = HTMLElement & {
|
|
4
|
-
/** Type */
|
|
5
|
-
type: TSinchChatBlockType | null;
|
|
6
|
-
/** First name */
|
|
7
|
-
firstName: string | null;
|
|
8
|
-
/** Last name */
|
|
9
|
-
lastName: string | null;
|
|
10
|
-
/** Timestamp */
|
|
11
|
-
timestamp: string | null;
|
|
12
|
-
/** Type */
|
|
13
|
-
setAttribute(name: 'type', value: TSinchChatBlockType): void;
|
|
14
|
-
/** First name */
|
|
15
|
-
setAttribute(name: 'firstName', value: string): void;
|
|
16
|
-
/** Last name */
|
|
17
|
-
setAttribute(name: 'lastName', value: string): void;
|
|
18
|
-
/** Timestamp */
|
|
19
|
-
setAttribute(name: 'timestamp', value: string): void;
|
|
20
|
-
};
|
|
21
|
-
export type TSinchChatBlockReact = TSinchElementReact<TSinchChatBlockElement> & {
|
|
22
|
-
/** Type */
|
|
23
|
-
type: TSinchChatBlockType;
|
|
24
|
-
/** First name */
|
|
25
|
-
firstName?: string;
|
|
26
|
-
/** Last name */
|
|
27
|
-
lastName?: string;
|
|
28
|
-
/** Timestamp */
|
|
29
|
-
timestamp?: string;
|
|
30
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchChatBubbleElement, TSinchChatBubbleReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-chat-bubble': TSinchChatBubbleReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-chat-bubble': TSinchChatBubbleElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;padding:12px 16px;border-radius:16px;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-default);border-top-left-radius:0}:host([data-type=agent-prev])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-active);border-top-right-radius:0}:host([data-type=agent])>#wrapper{background-color:var(--sinch-sys-color-container-complement-primary-hover);border-top-right-radius:0}#text{--sinch-global-color-text:var(--sinch-sys-color-text-default)}#icon-error,#icon-received,#icon-seen,#icon-sending,#icon-sent{display:none;position:absolute;right:16px;bottom:12px;height:16px}#icon-sending{fill:var(--sinch-sys-color-text-default)}#icon-sent{fill:var(--sinch-sys-color-text-default)}#icon-received{fill:var(--sinch-sys-color-text-default)}#icon-seen{fill:var(--sinch-sys-color-feedback-success-contrast)}#icon-error{fill:var(--sinch-sys-color-feedback-invalid-contrast)}:host([status=error]) #icon-error,:host([status=received]) #icon-received,:host([status=seen]) #icon-seen,:host([status=sending]) #icon-sending,:host([status=sent]) #icon-sent{display:block}:host([status]:not([status=""])) #wrapper{padding-right:42px}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><svg id="icon-sending" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2ZM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8Zm-.22-13h-.06c-.4 0-.72.32-.72.72v4.72c0 .35.18.68.49.86l4.15 2.49c.34.2.78.1.98-.24a.71.71 0 0 0-.25-.99l-3.87-2.3V7.72c0-.4-.32-.72-.72-.72Z"/></svg><svg id="icon-sent" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-received" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M17.3 6.3a.996.996 0 0 0-1.41 0l-5.64 5.64 1.41 1.41L17.3 7.7c.38-.38.38-1.02 0-1.4Zm4.24-.01-9.88 9.88-3.48-3.47a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L22.95 7.71a.996.996 0 0 0 0-1.41h-.01a.975.975 0 0 0-1.4-.01ZM1.12 14.12 5.3 18.3c.39.39 1.02.39 1.41 0l.7-.7-4.88-4.9a.996.996 0 0 0-1.41 0c-.39.39-.39 1.03 0 1.42Z"/></svg><svg id="icon-seen" id="icon-received" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M17.3 6.3a.996.996 0 0 0-1.41 0l-5.64 5.64 1.41 1.41L17.3 7.7c.38-.38.38-1.02 0-1.4Zm4.24-.01-9.88 9.88-3.48-3.47a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L22.95 7.71a.996.996 0 0 0 0-1.41h-.01a.975.975 0 0 0-1.4-.01ZM1.12 14.12 5.3 18.3c.39.39 1.02.39 1.41 0l.7-.7-4.88-4.9a.996.996 0 0 0-1.41 0c-.39.39-.39 1.03 0 1.42Z"/></svg><svg id="icon-error" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1Zm-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2ZM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8Zm1-3h-2v-2h2v2Z"/></svg></div>';
|
|
3
|
-
import { statusValues, typeValues } from './utils';
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = templateHTML;
|
|
6
|
-
defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
|
|
7
|
-
#$text;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$text = shadowRoot.querySelector('#text');
|
|
13
|
-
}
|
|
14
|
-
static get observedAttributes() {
|
|
15
|
-
return ['text'];
|
|
16
|
-
}
|
|
17
|
-
attributeChangedCallback(name, _, newVal) {
|
|
18
|
-
switch (name) {
|
|
19
|
-
case 'text':
|
|
20
|
-
{
|
|
21
|
-
this.#$text.textContent = newVal;
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
set text(value) {
|
|
27
|
-
updateAttribute(this, 'text', value);
|
|
28
|
-
}
|
|
29
|
-
get text() {
|
|
30
|
-
return getAttribute(this, 'text', '');
|
|
31
|
-
}
|
|
32
|
-
get type() {
|
|
33
|
-
return getLiteralAttribute(this, typeValues, 'data-type', null);
|
|
34
|
-
}
|
|
35
|
-
set status(value) {
|
|
36
|
-
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
37
|
-
}
|
|
38
|
-
get status() {
|
|
39
|
-
return getLiteralAttribute(this, statusValues, 'status', null);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchChatBubbleType = 'customer' | 'agent' | 'agent-prev';
|
|
3
|
-
export type TSinchChatBubbleStatus = 'sending' | 'sent' | 'received' | 'seen' | 'error';
|
|
4
|
-
export type TSinchChatBubbleElement = HTMLElement & {
|
|
5
|
-
readonly type: TSinchChatBubbleType | null;
|
|
6
|
-
/** Text */
|
|
7
|
-
text: string;
|
|
8
|
-
/** Status */
|
|
9
|
-
status: TSinchChatBubbleStatus | null;
|
|
10
|
-
/** Text */
|
|
11
|
-
setAttribute(name: 'text', value: string): void;
|
|
12
|
-
/** Status */
|
|
13
|
-
setAttribute(name: 'status', value: TSinchChatBubbleStatus): void;
|
|
14
|
-
};
|
|
15
|
-
export type TSinchChatBubbleReact = TSinchElementReact<TSinchChatBubbleElement> & {
|
|
16
|
-
/** Text */
|
|
17
|
-
text: string;
|
|
18
|
-
/** Status */
|
|
19
|
-
status?: TSinchChatBubbleStatus;
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '../tooltip';
|
|
2
|
-
import type { TSinchIconButtonElement, TSinchIconButtonReact } from './types';
|
|
3
|
-
declare global {
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface IntrinsicElements {
|
|
6
|
-
'sinch-icon-button': TSinchIconButtonReact;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
interface HTMLElementTagNameMap {
|
|
10
|
-
'sinch-icon-button': TSinchIconButtonElement;
|
|
11
|
-
}
|
|
12
|
-
}
|