@nectary/components 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +35 -10
- package/accordion/types.d.ts +3 -2
- package/accordion-item/index.js +8 -4
- package/action-menu/index.js +7 -8
- package/action-menu/types.d.ts +3 -3
- package/action-menu-option/index.js +23 -3
- package/action-menu-option/types.d.ts +2 -0
- package/alert/index.js +1 -1
- package/avatar/index.js +1 -1
- package/button/index.js +68 -4
- package/button/types.d.ts +6 -0
- package/checkbox/index.js +64 -6
- package/checkbox/types.d.ts +8 -2
- package/date-picker/index.js +37 -12
- package/date-picker/types.d.ts +4 -2
- package/dialog/index.js +5 -6
- package/dialog/types.d.ts +3 -3
- package/dropdown/index.js +44 -28
- package/dropdown/types.d.ts +6 -4
- package/dropdown-checkbox-option/index.js +1 -1
- package/dropdown-checkbox-option/types.d.ts +0 -2
- package/dropdown-radio-option/index.js +1 -1
- package/dropdown-radio-option/types.d.ts +0 -2
- package/dropdown-text-option/index.js +1 -1
- package/dropdown-text-option/types.d.ts +0 -2
- package/horizontal-stepper-item/index.js +1 -1
- package/icon-button/index.js +67 -3
- package/icon-button/types.d.ts +6 -0
- package/icons/create-icon-class.js +1 -1
- package/icons-branded/create-icon-class.js +3 -7
- package/icons-branded/types.d.ts +3 -0
- package/icons-channel/create-icon-class.js +3 -7
- package/icons-channel/types.d.ts +3 -0
- package/input/index.d.ts +0 -1
- package/input/index.js +58 -5
- package/input/types.d.ts +8 -2
- package/link/index.js +81 -3
- package/link/types.d.ts +9 -0
- package/package.json +1 -1
- package/pagination/index.js +24 -8
- package/pagination/types.d.ts +3 -1
- package/popover/index.js +5 -6
- package/popover/types.d.ts +4 -3
- package/radio/index.js +36 -8
- package/radio/types.d.ts +3 -1
- package/radio-option/index.js +1 -1
- package/search/types.d.ts +0 -1
- package/segment-collapse/index.js +28 -12
- package/segment-collapse/types.d.ts +3 -1
- package/segmented-control/index.js +28 -23
- package/segmented-control/types.d.ts +3 -2
- package/segmented-control-option/index.js +59 -13
- package/segmented-control-option/types.d.ts +4 -0
- package/segmented-icon-control/index.js +27 -16
- package/segmented-icon-control/types.d.ts +5 -2
- package/segmented-icon-control-option/index.js +54 -12
- package/segmented-icon-control-option/types.d.ts +4 -0
- package/select/index.js +68 -9
- package/select/types.d.ts +8 -2
- package/tabs/index.js +32 -8
- package/tabs/types.d.ts +3 -2
- package/tabs-option/index.js +2 -2
- package/textarea/index.js +58 -4
- package/textarea/types.d.ts +7 -2
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +181 -0
- package/tile-control/types.d.ts +38 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +161 -0
- package/tile-control-option/types.d.ts +37 -0
- package/tile-control-option/types.js +1 -0
- package/time-picker/index.js +17 -3
- package/time-picker/types.d.ts +4 -2
- package/toggle/index.js +63 -5
- package/toggle/types.d.ts +3 -1
|
@@ -2,11 +2,9 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchDropdownRadioOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
text: string;
|
|
5
|
-
checked: boolean;
|
|
6
5
|
disabled: boolean;
|
|
7
6
|
setAttribute(name: 'value', value: string): void;
|
|
8
7
|
setAttribute(name: 'text', value: string): void;
|
|
9
|
-
setAttribute(name: 'checked', value: ''): void;
|
|
10
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
11
9
|
};
|
|
12
10
|
export declare type TSinchDropdownRadioOptionReact = TSinchElementReact<TSinchDropdownRadioOptionElement> & {
|
|
@@ -7,7 +7,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
7
7
|
|
|
8
8
|
import '../icons/check';
|
|
9
9
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
10
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;--sinch-size-icon:24px}#content{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}#check{display:none;margin-right:-6px}:host([checked]
|
|
10
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;--sinch-size-icon:24px}#content{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial;--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span><sinch-icon-check id="check"></sinch-icon-check></div>';
|
|
11
11
|
const template = document.createElement('template');
|
|
12
12
|
template.innerHTML = templateHTML;
|
|
13
13
|
|
|
@@ -2,12 +2,10 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchDropdownTextOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
text: string;
|
|
5
|
-
checked: boolean;
|
|
6
5
|
disabled: boolean;
|
|
7
6
|
readonly icon: Element | null;
|
|
8
7
|
setAttribute(name: 'value', value: string): void;
|
|
9
8
|
setAttribute(name: 'text', value: string): void;
|
|
10
|
-
setAttribute(name: 'checked', value: ''): void;
|
|
11
9
|
setAttribute(name: 'disabled', value: ''): void;
|
|
12
10
|
};
|
|
13
11
|
export declare type TSinchDropdownTextOptionReact = TSinchElementReact<TSinchDropdownTextOptionElement> & {
|
|
@@ -10,7 +10,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
10
10
|
import '../icons/check';
|
|
11
11
|
import '../icons/exclamation';
|
|
12
12
|
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
13
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon-size:20px}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:8px}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><span id="label"></span
|
|
13
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon-size:20px}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:8px}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><span id="label"></span><span id="description"></span></div>';
|
|
14
14
|
import { statusValues } from './utils';
|
|
15
15
|
const template = document.createElement('template');
|
|
16
16
|
template.innerHTML = templateHTML;
|
package/icon-button/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button;
|
|
4
|
+
var _$button, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
|
-
import { defineCustomElement, getBooleanAttribute, isAttrTrue, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
10
|
+
import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
11
11
|
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:48px;height:48px;border-radius:var(--sinch-shape-radius-s);border:1px solid transparent;background-color:transparent;cursor:pointer;--sinch-size-icon:24px;--sinch-color-icon:var(--sinch-icon-button-color, var(--sinch-color-stormy-500))}button:focus-visible::before{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:1px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-s) + 2px)}@supports not selector(:focus-visible){button:focus::before{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:1px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-s) + 2px)}}button:hover{background-color:var(--sinch-color-snow-500)}button:active{background-color:var(--sinch-color-snow-600)}button:disabled{background-color:transparent;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-200);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-100)}:host([small]:not([small=false]))>button{width:32px;height:32px}button>*{pointer-events:none}</style><button><slot name="icon"></slot></button>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extends NectaryElement {
|
|
14
|
+
defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), _onClickReactHandler = new WeakMap(), class extends NectaryElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -20,6 +20,48 @@ defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extend
|
|
|
20
20
|
value: void 0
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
24
|
+
writable: true,
|
|
25
|
+
value: () => {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: () => {
|
|
33
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
38
|
+
writable: true,
|
|
39
|
+
value: () => {
|
|
40
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
45
|
+
writable: true,
|
|
46
|
+
value: () => {
|
|
47
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
52
|
+
writable: true,
|
|
53
|
+
value: () => {
|
|
54
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
_classPrivateFieldInitSpec(this, _onClickReactHandler, {
|
|
59
|
+
writable: true,
|
|
60
|
+
value: e => {
|
|
61
|
+
getReactEventHandler(this, 'on-click')?.(e);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
23
65
|
const shadowRoot = this.attachShadow();
|
|
24
66
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
25
67
|
|
|
@@ -28,6 +70,28 @@ defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extend
|
|
|
28
70
|
|
|
29
71
|
connectedCallback() {
|
|
30
72
|
this.setAttribute('role', 'button');
|
|
73
|
+
|
|
74
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
75
|
+
|
|
76
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
77
|
+
|
|
78
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
79
|
+
|
|
80
|
+
this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
81
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
82
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
disconnectedCallback() {
|
|
86
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
87
|
+
|
|
88
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
89
|
+
|
|
90
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
91
|
+
|
|
92
|
+
this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
93
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
94
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
31
95
|
}
|
|
32
96
|
|
|
33
97
|
static get observedAttributes() {
|
package/icon-button/types.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchIconButtonElement = HTMLElement & {
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
small: boolean;
|
|
5
|
+
addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
|
|
6
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
7
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
5
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
6
9
|
setAttribute(name: 'small', value: ''): void;
|
|
7
10
|
};
|
|
@@ -9,4 +12,7 @@ export declare type TSinchIconButtonReact = TSinchElementReact<TSinchIconButtonE
|
|
|
9
12
|
'aria-label': string;
|
|
10
13
|
disabled?: boolean;
|
|
11
14
|
small?: boolean;
|
|
15
|
+
'on-click'?: (e: CustomEvent<void>) => void;
|
|
16
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
17
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
12
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;fill:var(--sinch-color-icon,--sinch-color-text-default);height:var(--sinch-size-icon,24px)}</style>';
|
|
2
|
+
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;pointer-events:none;fill:var(--sinch-color-icon,--sinch-color-text-default);height:var(--sinch-size-icon,24px)}</style>';
|
|
3
3
|
export const createIconClass = templateHTML => {
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = iconStylesHtml + templateHTML;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBooleanAttribute, getIntegerAttribute, NectaryElement, updateAttribute, updateBooleanAttribute
|
|
2
|
-
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;fill:var(--sinch-color-stormy-500)}.accent{fill:var(--sinch-color-text-link)}:host([inverted]:not([inverted=false])) svg{fill:var(--sinch-color-snow-100)}:host([inverted]:not([inverted=false])) .accent{fill:var(--sinch-color-honey-500)}</style>';
|
|
1
|
+
import { attrValueToPixels, getBooleanAttribute, getIntegerAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
2
|
+
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;pointer-events:none;fill:var(--sinch-color-stormy-500);height:var(--sinch-size-icon,48px)}.accent{fill:var(--sinch-color-text-link)}:host([inverted]:not([inverted=false])) svg{fill:var(--sinch-color-snow-100)}:host([inverted]:not([inverted=false])) .accent{fill:var(--sinch-color-honey-500)}</style>';
|
|
3
3
|
const DEFAULT_SIZE = 48;
|
|
4
4
|
const MIN_SIZE = 4;
|
|
5
5
|
const MAX_SIZE = 256;
|
|
@@ -36,17 +36,13 @@ export const createIconClass = templateHTML => {
|
|
|
36
36
|
|
|
37
37
|
connectedCallback() {
|
|
38
38
|
updateAttribute(this.$svg, 'preserveAspectRatio', 'xMinYMin meet');
|
|
39
|
-
|
|
40
|
-
if (!this.hasAttribute('size')) {
|
|
41
|
-
updateAttribute(this, 'size', DEFAULT_SIZE);
|
|
42
|
-
}
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
attributeChangedCallback(name, _, newVal) {
|
|
46
42
|
switch (name) {
|
|
47
43
|
case 'size':
|
|
48
44
|
{
|
|
49
|
-
|
|
45
|
+
this.$svg.style.height = attrValueToPixels(newVal, {
|
|
50
46
|
min: MIN_SIZE,
|
|
51
47
|
max: MAX_SIZE
|
|
52
48
|
});
|
package/icons-branded/types.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
export declare type TSinchIconBrandedElement = HTMLElement & {
|
|
3
|
+
/** @deprecated */
|
|
3
4
|
size: number;
|
|
4
5
|
inverted: boolean;
|
|
6
|
+
/** @deprecated */
|
|
5
7
|
setAttribute(name: 'size', value: string): void;
|
|
6
8
|
setAttribute(name: 'inverted', value: ''): void;
|
|
7
9
|
};
|
|
8
10
|
export declare type TSinchIconBrandedReact = TSinchElementReact<TSinchIconBrandedElement> & {
|
|
11
|
+
/** @deprecated */
|
|
9
12
|
size?: number;
|
|
10
13
|
inverted?: boolean;
|
|
11
14
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getIntegerAttribute, NectaryElement, updateAttribute
|
|
2
|
-
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;pointer-events:none}</style>';
|
|
1
|
+
import { attrValueToPixels, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
+
const iconStylesHtml = '<style>:host{display:inline-block;vertical-align:middle}svg{display:block;pointer-events:none;height:var(--sinch-size-icon,48px)}</style>';
|
|
3
3
|
const DEFAULT_SIZE = 48;
|
|
4
4
|
const MIN_SIZE = 4;
|
|
5
5
|
const MAX_SIZE = 256;
|
|
@@ -28,17 +28,13 @@ export const createIconClass = templateHTML => {
|
|
|
28
28
|
|
|
29
29
|
connectedCallback() {
|
|
30
30
|
updateAttribute(this.$svg, 'preserveAspectRatio', 'xMinYMin meet');
|
|
31
|
-
|
|
32
|
-
if (!this.hasAttribute('size')) {
|
|
33
|
-
updateAttribute(this, 'size', DEFAULT_SIZE);
|
|
34
|
-
}
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
attributeChangedCallback(name, _, newVal) {
|
|
38
34
|
switch (name) {
|
|
39
35
|
case 'size':
|
|
40
36
|
{
|
|
41
|
-
|
|
37
|
+
this.$svg.style.height = attrValueToPixels(newVal, {
|
|
42
38
|
min: MIN_SIZE,
|
|
43
39
|
max: MAX_SIZE
|
|
44
40
|
});
|
package/icons-channel/types.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
export declare type TSinchIconChannelElement = HTMLElement & {
|
|
3
|
+
/** @deprecated */
|
|
3
4
|
size: number;
|
|
5
|
+
/** @deprecated */
|
|
4
6
|
setAttribute(name: 'size', value: string): void;
|
|
5
7
|
};
|
|
6
8
|
export declare type TSinchIconChannelReact = TSinchElementReact<TSinchIconChannelElement> & {
|
|
9
|
+
/** @deprecated */
|
|
7
10
|
size?: number;
|
|
8
11
|
};
|
package/input/index.d.ts
CHANGED
package/input/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange;
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
|
-
import '../
|
|
11
|
-
|
|
12
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><sinch-stop-events events="input,change,focusin,focusout"><slot name="right"></slot></sinch-stop-events></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><slot name="right"></slot></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
13
12
|
import { inputTypes } from './utils';
|
|
14
13
|
const template = document.createElement('template');
|
|
15
14
|
template.innerHTML = templateHTML;
|
|
16
|
-
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), class extends NectaryElement {
|
|
15
|
+
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
17
16
|
constructor() {
|
|
18
17
|
super();
|
|
19
18
|
|
|
@@ -118,6 +117,9 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
118
117
|
detail: nextValue,
|
|
119
118
|
bubbles: true
|
|
120
119
|
}));
|
|
120
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
121
|
+
detail: nextValue
|
|
122
|
+
}));
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
});
|
|
@@ -136,6 +138,41 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
136
138
|
}
|
|
137
139
|
});
|
|
138
140
|
|
|
141
|
+
_classPrivateFieldInitSpec(this, _onInputFocus, {
|
|
142
|
+
writable: true,
|
|
143
|
+
value: () => {
|
|
144
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
_classPrivateFieldInitSpec(this, _onInputBlur, {
|
|
149
|
+
writable: true,
|
|
150
|
+
value: () => {
|
|
151
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
156
|
+
writable: true,
|
|
157
|
+
value: e => {
|
|
158
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
163
|
+
writable: true,
|
|
164
|
+
value: () => {
|
|
165
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
170
|
+
writable: true,
|
|
171
|
+
value: () => {
|
|
172
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
139
176
|
const shadowRoot = this.attachShadow();
|
|
140
177
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
141
178
|
|
|
@@ -169,10 +206,18 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
169
206
|
|
|
170
207
|
_classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
171
208
|
|
|
209
|
+
_classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
210
|
+
|
|
211
|
+
_classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
212
|
+
|
|
172
213
|
_classPrivateFieldGet(this, _$iconSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
|
|
173
214
|
|
|
174
215
|
_classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
|
|
175
216
|
|
|
217
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
218
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
219
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
220
|
+
|
|
176
221
|
_classPrivateFieldGet(this, _onIconSlotChange).call(this);
|
|
177
222
|
|
|
178
223
|
_classPrivateFieldGet(this, _onRightSlotChange).call(this);
|
|
@@ -187,9 +232,17 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
187
232
|
|
|
188
233
|
_classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
189
234
|
|
|
235
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
236
|
+
|
|
237
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
238
|
+
|
|
190
239
|
_classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
|
|
191
240
|
|
|
192
241
|
_classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
|
|
242
|
+
|
|
243
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
244
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
245
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
193
246
|
}
|
|
194
247
|
|
|
195
248
|
static get observedAttributes() {
|
package/input/types.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export declare type TSinchInputElement = HTMLElement & {
|
|
|
22
22
|
selectionEnd: number | null;
|
|
23
23
|
selectionDirection: 'forward' | 'backward' | 'none' | null;
|
|
24
24
|
/** Change value event */
|
|
25
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
25
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
26
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
27
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
26
28
|
/** Text field type, `text` by default */
|
|
27
29
|
setAttribute(name: 'type', value: TSinchInputType): void;
|
|
28
30
|
/** Value */
|
|
@@ -59,6 +61,10 @@ export declare type TSinchInputReact = TSinchElementReact<TSinchInputElement> &
|
|
|
59
61
|
invalidText?: string;
|
|
60
62
|
/** Disabled */
|
|
61
63
|
disabled?: boolean;
|
|
64
|
+
/** @deprecated Change value handler */
|
|
65
|
+
onChange?: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
|
|
62
66
|
/** Change value handler */
|
|
63
|
-
|
|
67
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
68
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
69
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
64
70
|
};
|
package/link/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$anchor, _$text;
|
|
4
|
+
var _$anchor, _$text, _onAnchorClick, _onAnchorFocus, _onAnchorBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
10
|
import '../icons/open-in-new';
|
|
11
|
-
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue } from '../utils';
|
|
11
|
+
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, getReactEventHandler } from '../utils';
|
|
12
12
|
const templateHTML = '<style>:host{display:inline;outline:0}a{font:var(--sinch-font-body);font-size:inherit;line-height:inherit;color:var(--sinch-color-text-link);fill:var(--sinch-color-text-link);--sinch-size-icon:1em}#icon{display:none;margin-left:.2em;vertical-align:-.25em}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-200);pointer-events:none;cursor:initial;fill:var(--sinch-color-tropical-200)}:host([external]:not([external=false])) #icon{display:inline-block}</style><a><span id="content"></span><sinch-icon-open-in-new id="icon"></sinch-icon-open-in-new></a>';
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = templateHTML;
|
|
15
|
-
defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), class extends NectaryElement {
|
|
15
|
+
defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onAnchorClick = new WeakMap(), _onAnchorFocus = new WeakMap(), _onAnchorBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), _onClickReactHandler = new WeakMap(), class extends NectaryElement {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
18
|
|
|
@@ -26,6 +26,52 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
|
|
|
26
26
|
value: void 0
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
_classPrivateFieldInitSpec(this, _onAnchorClick, {
|
|
30
|
+
writable: true,
|
|
31
|
+
value: e => {
|
|
32
|
+
if (this.preventDefault) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldInitSpec(this, _onAnchorFocus, {
|
|
41
|
+
writable: true,
|
|
42
|
+
value: () => {
|
|
43
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
_classPrivateFieldInitSpec(this, _onAnchorBlur, {
|
|
48
|
+
writable: true,
|
|
49
|
+
value: () => {
|
|
50
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
55
|
+
writable: true,
|
|
56
|
+
value: () => {
|
|
57
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
62
|
+
writable: true,
|
|
63
|
+
value: () => {
|
|
64
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
_classPrivateFieldInitSpec(this, _onClickReactHandler, {
|
|
69
|
+
writable: true,
|
|
70
|
+
value: e => {
|
|
71
|
+
getReactEventHandler(this, 'on-click')?.(e);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
29
75
|
const shadowRoot = this.attachShadow();
|
|
30
76
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
31
77
|
|
|
@@ -34,6 +80,30 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
|
|
|
34
80
|
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#content'));
|
|
35
81
|
}
|
|
36
82
|
|
|
83
|
+
connectedCallback() {
|
|
84
|
+
_classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
|
|
85
|
+
|
|
86
|
+
_classPrivateFieldGet(this, _$anchor).addEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
|
|
87
|
+
|
|
88
|
+
_classPrivateFieldGet(this, _$anchor).addEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
|
|
89
|
+
|
|
90
|
+
this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
91
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
92
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
disconnectedCallback() {
|
|
96
|
+
_classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
|
|
97
|
+
|
|
98
|
+
_classPrivateFieldGet(this, _$anchor).removeEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
|
|
99
|
+
|
|
100
|
+
_classPrivateFieldGet(this, _$anchor).removeEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
|
|
101
|
+
|
|
102
|
+
this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
|
|
103
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
104
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
105
|
+
}
|
|
106
|
+
|
|
37
107
|
get text() {
|
|
38
108
|
return getAttribute(this, 'text', '');
|
|
39
109
|
}
|
|
@@ -66,6 +136,14 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
|
|
|
66
136
|
return getBooleanAttribute(this, 'external');
|
|
67
137
|
}
|
|
68
138
|
|
|
139
|
+
set preventDefault(isPrevented) {
|
|
140
|
+
updateBooleanAttribute(this, 'preventdefault', isPrevented);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get preventDefault() {
|
|
144
|
+
return getBooleanAttribute(this, 'preventdefault');
|
|
145
|
+
}
|
|
146
|
+
|
|
69
147
|
static get observedAttributes() {
|
|
70
148
|
return ['text', 'href', 'external', 'disabled'];
|
|
71
149
|
}
|
package/link/types.d.ts
CHANGED
|
@@ -4,14 +4,23 @@ export declare type TSinchLinkElement = HTMLElement & {
|
|
|
4
4
|
href: string;
|
|
5
5
|
disabled: boolean;
|
|
6
6
|
external: boolean;
|
|
7
|
+
preventDefault: boolean;
|
|
8
|
+
addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
|
|
9
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
10
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
7
11
|
setAttribute(name: 'text', value: string): void;
|
|
8
12
|
setAttribute(name: 'href', value: string): void;
|
|
9
13
|
setAttribute(name: 'disabled', value: ''): void;
|
|
10
14
|
setAttribute(name: 'external', value: ''): void;
|
|
15
|
+
setAttribute(name: 'preventdefault', value: ''): void;
|
|
11
16
|
};
|
|
12
17
|
export declare type TSinchLinkReact = TSinchElementReact<TSinchLinkElement> & {
|
|
13
18
|
text: string;
|
|
14
19
|
href: string;
|
|
15
20
|
disabled?: boolean;
|
|
16
21
|
external?: boolean;
|
|
22
|
+
preventDefault?: boolean;
|
|
23
|
+
'on-click'?: (e: CustomEvent<void>) => void;
|
|
24
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
25
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
17
26
|
};
|