@nectary/components 2.2.1 → 2.2.3
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 +21 -16
- package/accordion-item/index.js +9 -17
- package/action-menu/index.js +6 -9
- package/action-menu-option/index.js +3 -7
- package/alert/index.js +12 -12
- package/avatar/index.js +26 -23
- package/badge/index.js +2 -2
- package/button/index.js +6 -4
- package/card/index.js +6 -6
- package/checkbox/index.js +3 -3
- package/chip/index.js +2 -2
- package/code-tag/index.js +6 -9
- package/color-menu/index.js +10 -17
- package/color-menu-option/index.d.ts +0 -1
- package/color-menu-option/index.js +2 -6
- package/color-swatch/index.js +9 -9
- package/date-picker/index.js +0 -3
- package/dialog/index.js +16 -10
- package/dialog/types.d.ts +2 -0
- package/emoji/index.js +3 -0
- package/field/index.js +4 -4
- package/file-drop/index.js +21 -19
- package/file-picker/index.js +18 -18
- package/file-status/index.js +8 -5
- package/flag/index.js +3 -0
- package/help-tooltip/index.d.ts +1 -0
- package/help-tooltip/index.js +2 -1
- package/horizontal-stepper/index.js +1 -4
- package/horizontal-stepper-item/index.js +0 -3
- package/icon-button/index.js +5 -6
- package/input/index.js +8 -5
- package/link/index.js +2 -2
- package/package.json +1 -1
- package/pagination/index.js +2 -6
- package/pop/index.js +5 -4
- package/popover/index.js +2 -2
- package/progress/index.js +4 -4
- package/progress-stepper/index.js +1 -4
- package/progress-stepper-item/index.js +5 -5
- package/radio/index.js +28 -24
- package/radio-option/index.js +12 -34
- package/rich-text/index.js +12 -12
- package/segment/index.js +5 -2
- package/segmented-control/index.js +42 -21
- package/segmented-control-option/index.js +23 -30
- package/segmented-icon-control/index.js +46 -26
- package/segmented-icon-control-option/index.js +25 -32
- package/select-button/index.js +3 -4
- package/select-menu/index.js +0 -3
- package/select-menu-option/index.js +2 -2
- package/skeleton/index.js +0 -3
- package/spinner/index.js +0 -3
- package/table-head-cell/index.js +2 -2
- package/table-row/index.js +2 -2
- package/tabs/index.js +7 -7
- package/tabs-icon-option/index.js +2 -2
- package/tabs-option/index.js +2 -2
- package/tag/index.js +5 -2
- package/text/index.js +5 -2
- package/textarea/index.js +12 -6
- package/tile-control/index.js +2 -2
- package/tile-control-option/index.js +0 -3
- package/time-picker/index.js +3 -4
- package/title/index.js +4 -4
- package/toast/index.js +0 -3
- package/toggle/index.js +2 -2
- package/tooltip/index.js +1 -1
- package/utils/dom.d.ts +1 -0
- package/utils/dom.js +5 -2
- package/vertical-stepper/index.js +1 -4
- package/vertical-stepper-item/index.js +0 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, getTargetByAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box;position:relative;z-index:0}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement {
|
|
6
6
|
#$slot;
|
|
7
|
+
#controller = null;
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
9
10
|
const shadowRoot = this.attachShadow();
|
|
@@ -11,19 +12,35 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
11
12
|
this.#$slot = shadowRoot.querySelector('slot');
|
|
12
13
|
}
|
|
13
14
|
connectedCallback() {
|
|
14
|
-
this
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
this.#controller = new AbortController();
|
|
16
|
+
const {
|
|
17
|
+
signal
|
|
18
|
+
} = this.#controller;
|
|
19
|
+
const options = {
|
|
20
|
+
signal
|
|
21
|
+
};
|
|
22
|
+
this.role = 'tablist';
|
|
23
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
|
|
24
|
+
this.#$slot.addEventListener('click', this.#onOptionClick, options);
|
|
25
|
+
this.#$slot.addEventListener('keydown', this.#onOptionKeydown, options);
|
|
26
|
+
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
18
27
|
}
|
|
19
28
|
disconnectedCallback() {
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
29
|
+
this.#controller.abort();
|
|
30
|
+
this.#controller = null;
|
|
23
31
|
}
|
|
24
32
|
static get observedAttributes() {
|
|
25
33
|
return ['value'];
|
|
26
34
|
}
|
|
35
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
36
|
+
switch (name) {
|
|
37
|
+
case 'value':
|
|
38
|
+
{
|
|
39
|
+
this.#onValueChange(newVal ?? '');
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
27
44
|
set value(value) {
|
|
28
45
|
updateAttribute(this, 'value', value);
|
|
29
46
|
}
|
|
@@ -36,30 +53,33 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
36
53
|
get multiple() {
|
|
37
54
|
return getBooleanAttribute(this, 'multiple');
|
|
38
55
|
}
|
|
39
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
40
|
-
if (oldVal === newVal) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
switch (name) {
|
|
44
|
-
case 'value':
|
|
45
|
-
{
|
|
46
|
-
this.#onValueChange(newVal ?? '');
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
56
|
#onSlotChange = () => {
|
|
52
57
|
this.#onValueChange(this.value);
|
|
53
58
|
};
|
|
54
|
-
#
|
|
55
|
-
e
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
#onOptionClick = e => {
|
|
60
|
+
const target = getTargetByAttribute(e, 'value');
|
|
61
|
+
if (target === null || getBooleanAttribute(target, 'disabled')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const value = getAttribute(target, 'value', '');
|
|
65
|
+
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute(target, 'data-checked')) : value;
|
|
59
66
|
this.dispatchEvent(new CustomEvent('-change', {
|
|
60
67
|
detail
|
|
61
68
|
}));
|
|
62
69
|
};
|
|
70
|
+
#onOptionKeydown = e => {
|
|
71
|
+
switch (e.code) {
|
|
72
|
+
case 'Space':
|
|
73
|
+
case 'Enter':
|
|
74
|
+
{
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const target = getTargetByAttribute(e, 'value');
|
|
77
|
+
if (target !== null) {
|
|
78
|
+
target.click();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
63
83
|
#onValueChange(csv) {
|
|
64
84
|
if (this.multiple) {
|
|
65
85
|
const values = unpackCsv(csv);
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;background-color:var(--sinch-local-color-background);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon);--sinch-local-shape-radius:var(--sinch-comp-segmented-control-shape-radius);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-default-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-initial)}
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;background-color:var(--sinch-local-color-background);cursor:pointer;--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon);--sinch-local-shape-radius:var(--sinch-comp-segmented-control-shape-radius);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-default-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-initial)}:host(:hover){--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-hover)}:host(:first-child) #wrapper{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #wrapper{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host([data-checked]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-checked-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-checked-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-checked-background-initial)}:host([disabled]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-disabled-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-disabled-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-disabled-background-initial);cursor:initial}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);pointer-events:none;box-sizing:border-box}:host(:first-child) #border{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #border{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{border-left-width:0}:host([data-checked]) #border{border-width:2px}:host([data-checked]:not(:first-child)) #border{left:-1px}#outline{display:none;position:absolute;inset:-3px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus);pointer-events:none;box-sizing:border-box;z-index:1}:host(:focus-visible) #outline{display:block}:host(:first-child) #outline{border-top-left-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-left-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:last-child) #outline{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:not(:first-child)) #outline{left:-4px}::slotted(*){display:block;pointer-events:none}</style><div id="wrapper"><slot name="icon"></slot><div id="border"></div><div id="outline"></div></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control-option', class extends NectaryElement {
|
|
6
|
-
|
|
6
|
+
#controller = null;
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
9
|
const shadowRoot = this.attachShadow();
|
|
10
10
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
11
|
-
this.#$button = shadowRoot.querySelector('#button');
|
|
12
11
|
}
|
|
13
12
|
connectedCallback() {
|
|
14
|
-
this
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
this.#controller = new AbortController();
|
|
14
|
+
const {
|
|
15
|
+
signal
|
|
16
|
+
} = this.#controller;
|
|
17
|
+
const options = {
|
|
18
|
+
signal
|
|
19
|
+
};
|
|
20
|
+
this.role = 'tab';
|
|
21
|
+
this.addEventListener('focus', this.#onButtonFocus, options);
|
|
22
|
+
this.addEventListener('blur', this.#onButtonBlur, options);
|
|
23
|
+
this.addEventListener('-focus', this.#onFocusReactHandler, options);
|
|
24
|
+
this.addEventListener('-blur', this.#onBlurReactHandler, options);
|
|
25
|
+
this.#updateTabIndex();
|
|
20
26
|
}
|
|
21
27
|
disconnectedCallback() {
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
this.#$button.removeEventListener('blur', this.#onButtonBlur);
|
|
25
|
-
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
26
|
-
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
28
|
+
this.#controller.abort();
|
|
29
|
+
this.#controller = null;
|
|
27
30
|
}
|
|
28
31
|
static get observedAttributes() {
|
|
29
32
|
return ['data-checked', 'disabled'];
|
|
30
33
|
}
|
|
31
34
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
32
|
-
if (oldVal === newVal) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
35
|
switch (name) {
|
|
36
36
|
case 'data-checked':
|
|
37
37
|
{
|
|
@@ -40,8 +40,11 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
40
40
|
}
|
|
41
41
|
case 'disabled':
|
|
42
42
|
{
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
this.#updateTabIndex();
|
|
47
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
45
48
|
break;
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -61,19 +64,9 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
61
64
|
get focusable() {
|
|
62
65
|
return true;
|
|
63
66
|
}
|
|
64
|
-
|
|
65
|
-
this
|
|
66
|
-
}
|
|
67
|
-
blur() {
|
|
68
|
-
this.#$button.blur();
|
|
67
|
+
#updateTabIndex() {
|
|
68
|
+
this.tabIndex = this.disabled ? -1 : 0;
|
|
69
69
|
}
|
|
70
|
-
#onButtonClick = e => {
|
|
71
|
-
e.stopPropagation();
|
|
72
|
-
this.dispatchEvent(new CustomEvent('option-change', {
|
|
73
|
-
detail: this.value,
|
|
74
|
-
bubbles: true
|
|
75
|
-
}));
|
|
76
|
-
};
|
|
77
70
|
#onButtonFocus = () => {
|
|
78
71
|
this.dispatchEvent(new CustomEvent('-focus'));
|
|
79
72
|
};
|
package/select-button/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../text';
|
|
2
2
|
import '../icon';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context } from '../utils';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context, isAttrEqual } from '../utils';
|
|
4
4
|
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
5
|
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;cursor:pointer}:host([disabled]){cursor:initial}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-local-size);padding:0 8px 0 12px;background-color:var(--sinch-comp-select-button-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);--sinch-local-size:var(--sinch-comp-select-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-m);--sinch-global-color-icon:var(--sinch-comp-select-button-color-default-icon-initial)}:host([data-size="l"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-l)}:host([data-size="m"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-m)}:host([data-size="s"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-s)}:host([data-size="l"]) #wrapper{padding:0 12px}:host([data-size="m"]) #wrapper{padding:0 8px 0 12px}:host([data-size="s"]) #wrapper{padding:0 4px 0 12px}:host([disabled]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-select-button-color-disabled-icon-initial)}#text{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-select-button-font-input);--sinch-global-color-text:var(--sinch-comp-select-button-color-default-text-initial)}#text:empty{display:none}#placeholder{display:none;flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-select-button-font-placeholder);--sinch-global-color-text:var(--sinch-comp-select-button-color-default-placeholder-initial)}#text:empty+#placeholder{display:block}#border{position:absolute;border:1px solid var(--sinch-comp-select-button-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host(:focus-visible) #border{border-color:var(--sinch-comp-select-button-color-default-border-focus);border-width:2px}:host([invalid]) #border{border-color:var(--sinch-comp-select-button-color-invalid-border-initial)}:host([disabled]) #border{border-color:var(--sinch-comp-select-button-color-disabled-border-initial)}:host([disabled]) #text{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-text-initial)}:host([disabled]) #placeholder{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-placeholder-initial)}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;margin-left:-4px}#left.empty{display:none}#dropdown-icon{margin-left:-4px}</style><div id="wrapper" inert><div id="border"></div><div id="left"><slot name="left"></slot></div><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-text id="placeholder" type="m" ellipsis></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></div>';
|
|
6
6
|
const template = document.createElement('template');
|
|
@@ -70,7 +70,7 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
70
70
|
return ['text', 'placeholder', 'invalid', 'disabled', 'size', 'data-size'];
|
|
71
71
|
}
|
|
72
72
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
73
|
-
if (oldVal
|
|
73
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
switch (name) {
|
|
@@ -93,8 +93,7 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
93
93
|
}
|
|
94
94
|
case 'disabled':
|
|
95
95
|
{
|
|
96
|
-
|
|
97
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
96
|
+
updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
|
|
98
97
|
break;
|
|
99
98
|
}
|
|
100
99
|
case 'size':
|
package/select-menu/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../icon';
|
|
2
2
|
import '../text';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
4
4
|
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;background-color:var(--sinch-comp-select-menu-color-default-background-initial);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-option-initial);--sinch-global-color-icon:var(--sinch-comp-select-menu-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-select-menu-size-icon)}#content{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-option)}#icon-check{display:none;margin-right:-6px}:host([data-checked]) #icon-check{display:block}:host([data-selected])>#wrapper{background-color:var(--sinch-comp-select-menu-color-default-background-selected)}:host(:hover)>#wrapper{background-color:var(--sinch-comp-select-menu-color-default-background-hover)}:host([disabled])>#wrapper{cursor:initial;pointer-events:none;background-color:var(--sinch-comp-select-menu-color-disabled-background-initial);--sinch-global-color-text:var(--sinch-comp-select-menu-color-disabled-option-initial);--sinch-global-color-icon:var(--sinch-comp-select-menu-color-disabled-icon-initial)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text><sinch-icon id="icon-check" name="check"></sinch-icon></div>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
@@ -19,7 +19,7 @@ export class SelectMenuOption extends NectaryElement {
|
|
|
19
19
|
return ['text', 'data-checked', 'disabled'];
|
|
20
20
|
}
|
|
21
21
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
22
|
-
if (oldVal
|
|
22
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
switch (name) {
|
package/skeleton/index.js
CHANGED
package/spinner/index.js
CHANGED
package/table-head-cell/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../text';
|
|
2
2
|
import { alignValues } from '../table-cell/utils';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
4
4
|
const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-comp-table-color-head-cell-default-border-initial);vertical-align:middle}#wrapper{position:relative;display:flex;align-items:center;gap:8px;width:100%;height:100%;padding:8px;box-sizing:border-box;--sinch-global-color-icon:var(--sinch-comp-table-color-head-cell-default-icon-initial)}#text{flex-shrink:1;min-width:0;--sinch-global-color-text:var(--sinch-comp-table-color-head-cell-default-text-initial)}#text:empty{display:none}:host([align=center])>#wrapper{justify-content:center}:host([align=end])>#wrapper{justify-content:flex-end}:host([fit]){width:1px}</style><div id="wrapper"><slot name="checkbox"></slot><slot name="left"></slot><sinch-text id="text" type="m"></sinch-text><slot name="tooltip"></slot><slot name="right"></slot></div>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
@@ -20,7 +20,7 @@ defineCustomElement('sinch-table-head-cell', class extends NectaryElement {
|
|
|
20
20
|
return ['text', 'fit'];
|
|
21
21
|
}
|
|
22
22
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
23
|
-
if (oldVal
|
|
23
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
switch (name) {
|
package/table-row/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getBooleanAttribute, isAttrTrue, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:table-row;background-color:var(--sinch-comp-table-color-row-default-background-initial)}:host([selected]){background-color:var(--sinch-comp-table-color-row-checked-background-initial)}:host(:hover){background-color:var(--sinch-comp-table-color-row-default-background-hover)}:host([sticky]) ::slotted(sinch-table-head-cell){position:sticky;top:0;z-index:1;background-color:var(--sinch-comp-table-color-row-default-background-sticky)}:host(:last-child) ::slotted(sinch-table-cell){border-bottom:none}</style><slot></slot>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -15,7 +15,7 @@ defineCustomElement('sinch-table-row', class extends NectaryElement {
|
|
|
15
15
|
return ['sticky', 'selected'];
|
|
16
16
|
}
|
|
17
17
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
18
|
-
if (oldVal
|
|
18
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
switch (name) {
|
package/tabs/index.js
CHANGED
|
@@ -34,13 +34,7 @@ defineCustomElement('sinch-tabs', class extends NectaryElement {
|
|
|
34
34
|
static get observedAttributes() {
|
|
35
35
|
return ['value'];
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
updateAttribute(this, 'value', value);
|
|
39
|
-
}
|
|
40
|
-
get value() {
|
|
41
|
-
return getAttribute(this, 'value', '');
|
|
42
|
-
}
|
|
43
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
37
|
+
attributeChangedCallback(name, _, newVal) {
|
|
44
38
|
switch (name) {
|
|
45
39
|
case 'value':
|
|
46
40
|
{
|
|
@@ -49,6 +43,12 @@ defineCustomElement('sinch-tabs', class extends NectaryElement {
|
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
}
|
|
46
|
+
set value(value) {
|
|
47
|
+
updateAttribute(this, 'value', value);
|
|
48
|
+
}
|
|
49
|
+
get value() {
|
|
50
|
+
return getAttribute(this, 'value', '');
|
|
51
|
+
}
|
|
52
52
|
nthOptionRect(index) {
|
|
53
53
|
const $el = this.#$slot.assignedElements()[index];
|
|
54
54
|
if ($el != null) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0}#button{all:initial;position:relative;display:flex;flex-direction:column;padding:12px 16px 0;box-sizing:border-box;cursor:pointer;background-color:var(--sinch-comp-tab-color-default-background-initial);border-top-left-radius:var(--sinch-comp-tab-shape-radius);border-top-right-radius:var(--sinch-comp-tab-shape-radius);height:39px;--sinch-global-color-icon:var(--sinch-comp-tab-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-tab-size-icon)}#button:hover{background-color:var(--sinch-comp-tab-color-default-background-hover)}#button:focus-visible::after{content:"";position:absolute;inset:0;bottom:-3px;border:2px solid var(--sinch-comp-tab-color-default-outline-focus);border-top-left-radius:var(--sinch-comp-tab-shape-radius);border-top-right-radius:var(--sinch-comp-tab-shape-radius);pointer-events:none}#button:disabled{cursor:unset;pointer-events:none;--sinch-global-color-icon:var(--sinch-comp-tab-color-disabled-icon-initial)}:host([data-checked]) #button{--sinch-global-color-icon:var(--sinch-comp-tab-color-checked-icon-initial)}:host([data-checked]) #button::before{content:"";position:absolute;left:0;right:0;bottom:-1px;pointer-events:none;border-top:2px solid var(--sinch-comp-tab-color-checked-border-initial)}::slotted(*){display:block}</style><sinch-tooltip id="tooltip"><button id="button" tabindex="0"><slot name="icon"></slot></button></sinch-tooltip>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -37,7 +37,7 @@ defineCustomElement('sinch-tabs-icon-option', class extends NectaryElement {
|
|
|
37
37
|
return getBooleanAttribute(this, 'disabled');
|
|
38
38
|
}
|
|
39
39
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
40
|
-
if (oldVal
|
|
40
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
switch (name) {
|
package/tabs-option/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../text';
|
|
2
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
3
3
|
const templateHTML = '<style>:host{display:block}#button{all:initial;position:relative;display:flex;align-items:center;justify-content:center;gap:8px;width:100%;padding:12px 16px;box-sizing:border-box;cursor:pointer;background-color:var(--sinch-comp-tab-color-default-background-initial);border-top-left-radius:var(--sinch-comp-tab-shape-radius);border-top-right-radius:var(--sinch-comp-tab-shape-radius);height:39px;--sinch-global-color-text:var(--sinch-comp-tab-color-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-tab-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-tab-size-icon)}#button:hover{background-color:var(--sinch-comp-tab-color-default-background-hover)}#button:focus-visible::after{content:"";position:absolute;inset:0;bottom:-3px;border:2px solid var(--sinch-comp-tab-color-default-outline-focus);border-top-left-radius:var(--sinch-comp-tab-shape-radius);border-top-right-radius:var(--sinch-comp-tab-shape-radius);pointer-events:none}#button:disabled{cursor:unset;pointer-events:none;--sinch-global-color-text:var(--sinch-comp-tab-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-tab-color-disabled-icon-initial)}:host([data-checked]) #button{--sinch-global-color-text:var(--sinch-comp-tab-color-checked-text-initial);--sinch-global-color-icon:var(--sinch-comp-tab-color-checked-icon-initial)}:host([data-checked]) #button::before{content:"";position:absolute;left:0;right:0;bottom:-1px;pointer-events:none;border-top:2px solid var(--sinch-comp-tab-color-checked-border-initial)}#text{flex-shrink:1;flex-basis:auto;min-width:0;--sinch-comp-text-font:var(--sinch-comp-tab-font-label)}::slotted(*){display:block}</style><button id="button" tabindex="0"><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text></button>';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
@@ -26,7 +26,7 @@ defineCustomElement('sinch-tabs-option', class extends NectaryElement {
|
|
|
26
26
|
return ['data-checked', 'disabled', 'text'];
|
|
27
27
|
}
|
|
28
28
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
29
|
-
if (oldVal
|
|
29
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
switch (name) {
|
package/tag/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../text';
|
|
2
|
-
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue } from '../utils';
|
|
2
|
+
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, isAttrEqual } from '../utils';
|
|
3
3
|
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:var(--sinch-comp-tag-size-container-m);padding:0 9px;border-radius:var(--sinch-comp-tag-shape-radius);background-color:var(--sinch-comp-tag-color-default-background);box-sizing:border-box;user-select:none;--sinch-global-color-text:var(--sinch-comp-tag-color-default-foreground);--sinch-global-color-icon:var(--sinch-comp-tag-color-default-foreground);--sinch-global-size-icon:var(--sinch-comp-tag-size-icon-m)}:host([small]) #wrapper{height:var(--sinch-comp-tag-size-container-s);padding:0 8px;--sinch-global-size-icon:var(--sinch-comp-tag-size-icon-s)}#text{flex:1;--sinch-comp-text-font:var(--sinch-comp-tag-font-size-m-label)}:host([small]) #text{--sinch-comp-text-font:var(--sinch-comp-tag-font-size-s-label)}::slotted(*){margin-left:-4px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="text" type="s" ellipsis></sinch-text></div>';
|
|
4
4
|
import { getTagColorBg, getTagColorFg } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
@@ -18,6 +18,9 @@ defineCustomElement('sinch-tag', class extends NectaryElement {
|
|
|
18
18
|
super.connectedCallback();
|
|
19
19
|
this.#updateColor();
|
|
20
20
|
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback();
|
|
23
|
+
}
|
|
21
24
|
get color() {
|
|
22
25
|
return getAttribute(this, 'color');
|
|
23
26
|
}
|
|
@@ -40,7 +43,7 @@ defineCustomElement('sinch-tag', class extends NectaryElement {
|
|
|
40
43
|
return ['text', 'color', 'small'];
|
|
41
44
|
}
|
|
42
45
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
43
|
-
if (oldVal
|
|
46
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
switch (name) {
|
package/text/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
|
|
1
|
+
import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;font:var(--sinch-comp-text-font);color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));--sinch-comp-text-font:var(--sinch-sys-font-body-m)}:host([inline]){display:inline}:host([type="s"]){--sinch-comp-text-font:var(--sinch-sys-font-body-s)}:host([type=xs]){--sinch-comp-text-font:var(--sinch-sys-font-body-xs)}:host([type=xxs]){--sinch-comp-text-font:var(--sinch-sys-font-body-xxs)}:host([type="m"][emphasized]){--sinch-comp-text-font:var(--sinch-sys-font-body-emphasize)}:host([type="s"][emphasized]){--sinch-comp-text-font:var(--sinch-sys-font-body-emphasize-s)}:host([ellipsis]){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;--sinch-global-text-white-space:nowrap}</style><slot></slot>';
|
|
3
3
|
import { typeValues } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
@@ -15,7 +15,10 @@ defineCustomElement('sinch-text', class extends NectaryElement {
|
|
|
15
15
|
static get observedAttributes() {
|
|
16
16
|
return ['inline', 'ellipsis', 'emphasized'];
|
|
17
17
|
}
|
|
18
|
-
attributeChangedCallback(name,
|
|
18
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
19
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
19
22
|
switch (name) {
|
|
20
23
|
case 'inline':
|
|
21
24
|
{
|
package/textarea/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
1
|
+
import { Context, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
2
|
import { DEFAULT_SIZE } from '../utils/size';
|
|
3
3
|
const templateHTML = '<style>:host{all:initial;display:inline-block;vertical-align:middle}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;box-sizing:border-box;background-color:var(--sinch-comp-textarea-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);padding-right:2px;padding-bottom:2px;overflow:hidden;--sinch-local-shape-radius:var(--sinch-comp-textarea-shape-radius)}#input{all:initial;display:block;font:var(--sinch-comp-textarea-font-input);color:var(--sinch-comp-textarea-color-default-text-initial);resize:none;white-space:pre-wrap;overflow-wrap:break-word;padding:8px 10px 8px 12px;border:none}#input::placeholder{color:var(--sinch-comp-textarea-color-default-text-placeholder);opacity:1}#input:disabled{color:var(--sinch-comp-textarea-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-textarea-color-disabled-text-initial)}:host([resizable]) #input{resize:vertical}#border{position:absolute;border:1px solid var(--sinch-comp-textarea-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host([invalid]) #border{border-color:var(--sinch-comp-textarea-color-invalid-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-textarea-color-default-border-focus);border-width:2px}#input:disabled+#border{border-color:var(--sinch-comp-textarea-color-disabled-border-initial)}#bottom{display:flex;flex-direction:row;align-items:center;gap:8px;padding:8px 10px 10px 12px}#bottom.empty{display:none}</style><div id="wrapper"><textarea id="input"></textarea><div id="border"></div><div id="bottom"><slot name="bottom"></slot></div></div>';
|
|
4
4
|
const template = document.createElement('template');
|
|
@@ -28,8 +28,8 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
|
|
|
28
28
|
const options = {
|
|
29
29
|
signal: this.#controller.signal
|
|
30
30
|
};
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
31
|
+
this.role = 'textbox';
|
|
32
|
+
this.ariaMultiLine = 'true';
|
|
33
33
|
this.#$input.addEventListener('input', this.#onInput, options);
|
|
34
34
|
this.#$input.addEventListener('compositionstart', this.#onCompositionStart, options);
|
|
35
35
|
this.#$input.addEventListener('mousedown', this.#onSelectionChange, options);
|
|
@@ -53,9 +53,6 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
|
|
|
53
53
|
return ['value', 'placeholder', 'invalid', 'disabled', 'rows', 'resizable'];
|
|
54
54
|
}
|
|
55
55
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
56
|
-
if (oldVal === newVal) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
56
|
switch (name) {
|
|
60
57
|
case 'value':
|
|
61
58
|
{
|
|
@@ -79,6 +76,9 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
|
|
|
79
76
|
}
|
|
80
77
|
case 'invalid':
|
|
81
78
|
{
|
|
79
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
82
|
const isInvalid = isAttrTrue(newVal);
|
|
83
83
|
updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
|
|
84
84
|
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
@@ -86,6 +86,9 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
|
|
|
86
86
|
}
|
|
87
87
|
case 'disabled':
|
|
88
88
|
{
|
|
89
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
89
92
|
const isDisabled = isAttrTrue(newVal);
|
|
90
93
|
this.#$input.disabled = isDisabled;
|
|
91
94
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
@@ -98,6 +101,9 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
|
|
|
98
101
|
}
|
|
99
102
|
case 'resizable':
|
|
100
103
|
{
|
|
104
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
101
107
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
102
108
|
break;
|
|
103
109
|
}
|
package/tile-control/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, isAttrTrue } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0;--sinch-grid-num-columns:1}#wrapper{display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),auto);gap:16px;width:fit-content}:host([small]) #wrapper{gap:8px}:host([cols="2"]){--sinch-grid-num-columns:2}:host([cols="3"]){--sinch-grid-num-columns:3}:host([cols="4"]){--sinch-grid-num-columns:4}:host([cols="5"]){--sinch-grid-num-columns:5}:host([cols="6"]){--sinch-grid-num-columns:6}:host([cols="7"]){--sinch-grid-num-columns:7}:host([cols="8"]){--sinch-grid-num-columns:8}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -25,7 +25,7 @@ defineCustomElement('sinch-tile-control', class extends NectaryElement {
|
|
|
25
25
|
return ['value', 'small', 'multiple'];
|
|
26
26
|
}
|
|
27
27
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
28
|
-
if (oldVal
|
|
28
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
switch (name) {
|
|
@@ -31,9 +31,6 @@ defineCustomElement('sinch-tile-control-option', class extends NectaryElement {
|
|
|
31
31
|
return ['data-checked', 'text', 'disabled'];
|
|
32
32
|
}
|
|
33
33
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
-
if (oldVal === newVal) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
34
|
switch (name) {
|
|
38
35
|
case 'text':
|
|
39
36
|
{
|
package/time-picker/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import '../icon-button';
|
|
|
2
2
|
import '../icon';
|
|
3
3
|
import '../segmented-control';
|
|
4
4
|
import '../segmented-control-option';
|
|
5
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
5
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
6
6
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-comp-time-picker-header-font);line-height:48px;user-select:none;color:var(--sinch-comp-time-picker-header-color-default-text-initial)}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-comp-time-picker-watch-face-color-default-border-initial);background-color:var(--sinch-comp-time-picker-watch-face-color-default-background-initial)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;text-align:center;top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-12{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h12-initial)}.digit-hour-12.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h12);color:var(--sinch-comp-time-picker-digit-color-checked-h12-default)}.digit-hour-24{font:var(--sinch-comp-time-picker-digit-font-default-h24);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h24-initial)}.digit-hour-24.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h24);color:var(--sinch-comp-time-picker-digit-color-checked-h24-initial)}.digit-minute{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-minute-initial)}.digit-minute.selected{color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-comp-time-picker-needle-color-default-background-initial)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-comp-time-picker-needle-color-default-background-focus)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}#submit-icon{--sinch-global-color-icon:var(--sinch-comp-time-picker-header-color-default-icon-initial)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">:</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon" name="done"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
|
|
7
7
|
import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
|
|
8
8
|
const template = document.createElement('template');
|
|
@@ -111,7 +111,7 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
111
111
|
return ['value', 'ampm', 'submit-aria-label'];
|
|
112
112
|
}
|
|
113
113
|
attributeChangedCallback(name, prevValue, newVal) {
|
|
114
|
-
if (newVal
|
|
114
|
+
if (isAttrEqual(prevValue, newVal)) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
switch (name) {
|
|
@@ -128,9 +128,8 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
128
128
|
}
|
|
129
129
|
case 'ampm':
|
|
130
130
|
{
|
|
131
|
-
const isAmpm = isAttrTrue(newVal);
|
|
132
|
-
updateBooleanAttribute(this, 'ampm', isAmpm);
|
|
133
131
|
this.#render();
|
|
132
|
+
updateBooleanAttribute(this, 'ampm', isAttrTrue(newVal));
|
|
134
133
|
break;
|
|
135
134
|
}
|
|
136
135
|
case 'submit-aria-label':
|
package/title/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue, isAttrEqual } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type=xl]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xl)}:host([type="l"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-l)}:host([type="m"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type="s"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-s)}:host([type=xs]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xs)}#text{letter-spacing:-2%;color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));font:var(--sinch-comp-title-font)}:host([ellipsis]) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
|
|
3
3
|
import { typeValues } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
@@ -18,9 +18,6 @@ defineCustomElement('sinch-title', class extends NectaryElement {
|
|
|
18
18
|
return ['text', 'level', 'ellipsis'];
|
|
19
19
|
}
|
|
20
20
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
21
|
-
if (oldVal === newVal) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
21
|
switch (name) {
|
|
25
22
|
case 'text':
|
|
26
23
|
{
|
|
@@ -34,6 +31,9 @@ defineCustomElement('sinch-title', class extends NectaryElement {
|
|
|
34
31
|
}
|
|
35
32
|
case 'ellipsis':
|
|
36
33
|
{
|
|
34
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
37
|
updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
|
|
38
38
|
break;
|
|
39
39
|
}
|
package/toast/index.js
CHANGED