@nectary/components 2.2.0 → 2.2.2
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 +0 -3
- package/segmented-control-option/index.js +5 -4
- package/segmented-icon-control/index.js +0 -3
- package/segmented-icon-control-option/index.js +5 -4
- 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/countries.json +3 -3
- 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
package/progress/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../text';
|
|
2
|
-
import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger, isAttrTrue } from '../utils';
|
|
2
|
+
import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger, isAttrTrue, isAttrEqual } from '../utils';
|
|
3
3
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;align-items:center;height:24px}#bar,#progress{height:8px;border-radius:4px}#progress{background-color:var(--sinch-comp-progress-color-default-background-initial);flex:1;min-width:0}#bar{background-color:var(--sinch-comp-progress-color-default-bar-initial);width:0}#text{display:none;width:46px;--sinch-global-color-text:var(--sinch-comp-progress-color-default-text-initial)}:host([detailed]) #text{display:block}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><div id="progress"><div id="bar"></div></div></div>';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
@@ -20,9 +20,6 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
|
|
|
20
20
|
return ['value', 'detailed'];
|
|
21
21
|
}
|
|
22
22
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
23
|
-
if (oldVal === newVal) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
23
|
switch (name) {
|
|
27
24
|
case 'value':
|
|
28
25
|
{
|
|
@@ -38,6 +35,9 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
|
|
|
38
35
|
}
|
|
39
36
|
case 'detailed':
|
|
40
37
|
{
|
|
38
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
41
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
@@ -40,10 +40,7 @@ defineCustomElement('sinch-progress-stepper', class extends NectaryElement {
|
|
|
40
40
|
static get observedAttributes() {
|
|
41
41
|
return ['value', 'progressvalue'];
|
|
42
42
|
}
|
|
43
|
-
attributeChangedCallback(name,
|
|
44
|
-
if (oldVal === newVal) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
43
|
+
attributeChangedCallback(name, _, newVal) {
|
|
47
44
|
switch (name) {
|
|
48
45
|
case 'value':
|
|
49
46
|
{
|
|
@@ -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;outline:0}#button{position:relative;display:flex;flex-direction:column;gap:4px;width:100%;height:100%;padding:8px 4px 4px;box-sizing:border-box;cursor:pointer;border-radius:var(--sinch-comp-progress-stepper-step-shape-radius)}:host([data-status=inactive])>#button{cursor:not-allowed}:host([data-status=incomplete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-background-hover)}:host([data-status=complete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-complete-background-hover)}:host([data-status=invalid]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-background-hover)}#outline{position:absolute;inset:-2px;border:2px solid var(--sinch-comp-progress-stepper-step-color-outline-focus);border-radius:calc(var(--sinch-comp-progress-stepper-step-shape-radius) + 2px);pointer-events:none;opacity:0}:host(:focus-visible) #outline{opacity:1}#text{flex-shrink:1;flex-basis:auto;min-width:0;transform:translate(0,0);will-change:transform;transition:transform .25s ease-out;padding-right:24px}:host([data-status=incomplete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-label)}:host([data-status=complete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-label)}:host([data-status=inactive]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-inactive-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-inactive-label)}:host([invalid]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-label);transform:translate(24px,0)}:host([data-status=incomplete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-current-label)}:host([data-status=complete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-current-label)}:host([invalid][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-current-label)}#icon-error{position:absolute;left:0;top:4px;pointer-events:none;opacity:0;transition:opacity .25s ease-in-out;--sinch-global-color-icon:var(--sinch-comp-progress-stepper-step-color-invalid-icon-default);--sinch-global-size-icon:16px}:host([invalid]) #icon-error{opacity:1}#progress{height:8px;border-radius:4px;transition:background-color .25s ease-in-out}:host([data-status=incomplete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-background)}:host([data-status=complete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-background)}:host([data-status=inactive]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-inactive-progress-background)}:host([invalid]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-progress-background)}#bar{width:8px;height:8px;border-radius:4px;opacity:0;transition:width .25s ease-in-out,opacity .25s ease-in-out}:host([data-status=incomplete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-bar)}:host([data-status=complete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-bar);width:100%}:host([data-status=complete]:not([invalid])) #bar,:host([data-status=incomplete]:not([invalid])) #bar{opacity:1}#label-bar{position:relative}</style><div id="button"><div id="progress"><div id="bar"></div></div><div id="label-bar"><sinch-icon id="icon-error" name="report_problem" aria-hidden="true"></sinch-icon><sinch-text id="text" type="m"></sinch-text></div><div id="outline"></div></div>';
|
|
4
4
|
import { ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_STATUS, isProgressStepperItemActive, isProgressStepperItemActiveDescendant } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
@@ -22,9 +22,6 @@ defineCustomElement('sinch-progress-stepper-item', class extends NectaryElement
|
|
|
22
22
|
return ['text', 'invalid', ATTR_PROGRESS_STEPPER_ITEM_STATUS, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT];
|
|
23
23
|
}
|
|
24
24
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
25
|
-
if (oldVal === newVal) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
25
|
switch (name) {
|
|
29
26
|
case 'text':
|
|
30
27
|
{
|
|
@@ -48,9 +45,12 @@ defineCustomElement('sinch-progress-stepper-item', class extends NectaryElement
|
|
|
48
45
|
}
|
|
49
46
|
case 'invalid':
|
|
50
47
|
{
|
|
48
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
51
|
const isInvalid = isAttrTrue(newVal);
|
|
52
|
-
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
53
52
|
updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
|
|
53
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
54
54
|
break;
|
|
55
55
|
}
|
|
56
56
|
}
|
package/radio/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getTargetByAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
6
6
|
#$slot;
|
|
7
|
+
#controller = null;
|
|
7
8
|
constructor() {
|
|
8
9
|
super();
|
|
9
10
|
const shadowRoot = this.attachShadow();
|
|
@@ -11,17 +12,22 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
11
12
|
this.#$slot = shadowRoot.querySelector('slot');
|
|
12
13
|
}
|
|
13
14
|
connectedCallback() {
|
|
14
|
-
this
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
this.#controller = new AbortController();
|
|
16
|
+
const {
|
|
17
|
+
signal
|
|
18
|
+
} = this.#controller;
|
|
19
|
+
const options = {
|
|
20
|
+
signal
|
|
21
|
+
};
|
|
22
|
+
this.role = 'radiogroup';
|
|
23
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
|
|
24
|
+
this.#$slot.addEventListener('keydown', this.#onOptionKeyDown, options);
|
|
25
|
+
this.#$slot.addEventListener('click', this.#onOptionClick, options);
|
|
26
|
+
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
19
27
|
}
|
|
20
28
|
disconnectedCallback() {
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
24
|
-
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
29
|
+
this.#controller.abort();
|
|
30
|
+
this.#controller = null;
|
|
25
31
|
}
|
|
26
32
|
static get observedAttributes() {
|
|
27
33
|
return ['value', 'invalid'];
|
|
@@ -39,9 +45,6 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
39
45
|
return getBooleanAttribute(this, 'invalid');
|
|
40
46
|
}
|
|
41
47
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
42
|
-
if (oldVal === newVal) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
48
|
switch (name) {
|
|
46
49
|
case 'value':
|
|
47
50
|
{
|
|
@@ -64,7 +67,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
64
67
|
const $option = this.#getPrevOption();
|
|
65
68
|
if ($option !== null) {
|
|
66
69
|
$option.focus();
|
|
67
|
-
|
|
70
|
+
$option.click();
|
|
68
71
|
}
|
|
69
72
|
break;
|
|
70
73
|
}
|
|
@@ -75,7 +78,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
75
78
|
const $option = this.#getNextOption();
|
|
76
79
|
if ($option !== null) {
|
|
77
80
|
$option.focus();
|
|
78
|
-
|
|
81
|
+
$option.click();
|
|
79
82
|
}
|
|
80
83
|
break;
|
|
81
84
|
}
|
|
@@ -84,9 +87,15 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
84
87
|
#onSlotChange = () => {
|
|
85
88
|
this.#onValueChange(this.value);
|
|
86
89
|
};
|
|
87
|
-
#
|
|
88
|
-
e
|
|
89
|
-
|
|
90
|
+
#onOptionClick = e => {
|
|
91
|
+
const target = getTargetByAttribute(e, 'value');
|
|
92
|
+
if (target === null || target.hasAttribute('disabled')) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const value = getAttribute(target, 'value');
|
|
96
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
97
|
+
detail: value
|
|
98
|
+
}));
|
|
90
99
|
};
|
|
91
100
|
#onValueChange(value) {
|
|
92
101
|
for (const $option of this.#$slot.assignedElements()) {
|
|
@@ -94,11 +103,6 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
94
103
|
updateBooleanAttribute($option, 'checked', isChecked);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
|
-
#dispatchChangeEvent(value) {
|
|
98
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
99
|
-
detail: value
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
106
|
#getFirstOption() {
|
|
103
107
|
for (const $option of this.#$slot.assignedElements()) {
|
|
104
108
|
if ($option.disabled !== true) {
|
|
@@ -134,7 +138,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
134
138
|
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
135
139
|
}
|
|
136
140
|
#getEnabledRadioElements() {
|
|
137
|
-
return this.#$slot.assignedElements().filter(el => el.disabled
|
|
141
|
+
return this.#$slot.assignedElements().filter(el => !el.hasAttribute('disabled'));
|
|
138
142
|
}
|
|
139
143
|
#findSelectedOption(elements) {
|
|
140
144
|
return elements.find(el => el.checked) ?? null;
|
package/radio-option/index.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;min-height:24px;--sinch-local-color-background:var(--sinch-comp-radio-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-radio-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-radio-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-radio-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-default-border-active);--sinch-local-color-knob:var(--sinch-comp-radio-color-checked-knob-initial);--sinch-local-color-knob-hover:var(--sinch-comp-radio-color-checked-knob-hover);--sinch-local-color-knob-active:var(--sinch-comp-radio-color-checked-knob-active);--sinch-local-color-text:var(--sinch-comp-radio-color-default-label-initial)}:host([data-invalid])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-radio-color-invalid-label-initial)}:host([checked])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-radio-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-radio-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-radio-color-disabled-label-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-checked-disabled-border-initial);--sinch-local-color-knob:var(--sinch-comp-radio-color-checked-disabled-knob-initial);--sinch-local-color-text:var(--sinch-comp-radio-color-checked-disabled-label-initial)}#input{all:initial;display:block;width:18px;height:18px;cursor:pointer}:host([disabled]) #input{cursor:initial}#input-wrapper{position:relative;width:18px;height:18px;align-self:flex-start;margin-top:3px}#input::before{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-comp-radio-color-default-outline-focus);border-radius:50%;transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}:host(:focus-visible) #input::before{opacity:1}#input::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:50%;box-sizing:border-box;pointer-events:none}:host(:hover:not([disabled])) #input::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}:host(:active:not([disabled])) #input::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#knob{position:absolute;width:10px;height:10px;inset:0;margin:auto;border-radius:50%;transition:opacity .1s linear;opacity:0;background-color:var(--sinch-local-color-knob);pointer-events:none}:host([checked]) #knob{opacity:1}:host(:hover:not([disabled])) #knob{background-color:var(--sinch-local-color-knob-hover)}:host(:active:not([disabled])) #knob{background-color:var(--sinch-local-color-knob-active)}@media (prefers-reduced-motion){#input::after,#input::before,#knob{transition:none}}#label{flex:1;align-self:center;padding-left:8px;font:var(--sinch-comp-radio-font-label);color:var(--sinch-local-color-text);cursor:pointer}#label:empty{display:none}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="input-wrapper"><div id="input"></div><div id="knob"></div></div><span id="label"></span></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
6
|
-
#$input;
|
|
7
6
|
#$label;
|
|
8
7
|
constructor() {
|
|
9
8
|
super();
|
|
10
9
|
const shadowRoot = this.attachShadow();
|
|
11
10
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$
|
|
13
|
-
this.#$label = shadowRoot.querySelector('label');
|
|
11
|
+
this.#$label = shadowRoot.querySelector('#label');
|
|
14
12
|
}
|
|
15
13
|
connectedCallback() {
|
|
16
|
-
this.
|
|
17
|
-
this
|
|
18
|
-
}
|
|
19
|
-
disconnectedCallback() {
|
|
20
|
-
this.#$input.removeEventListener('input', this.#onInput);
|
|
14
|
+
this.role = 'radio';
|
|
15
|
+
this.tabIndex = 0;
|
|
21
16
|
}
|
|
17
|
+
disconnectedCallback() {}
|
|
22
18
|
static get observedAttributes() {
|
|
23
|
-
return ['checked', 'disabled', 'text', '
|
|
19
|
+
return ['checked', 'disabled', 'text', 'data-invalid'];
|
|
24
20
|
}
|
|
25
21
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
26
|
-
if (oldVal
|
|
22
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
27
23
|
return;
|
|
28
24
|
}
|
|
29
25
|
switch (name) {
|
|
@@ -34,14 +30,15 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
34
30
|
}
|
|
35
31
|
case 'checked':
|
|
36
32
|
{
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const isChecked = isAttrTrue(newVal);
|
|
34
|
+
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
35
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
39
36
|
break;
|
|
40
37
|
}
|
|
41
38
|
case 'disabled':
|
|
42
39
|
{
|
|
43
40
|
const isDisabled = isAttrTrue(newVal);
|
|
44
|
-
this
|
|
41
|
+
updateExplicitBooleanAttribute(this, 'aria-disabled', isDisabled);
|
|
45
42
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
46
43
|
break;
|
|
47
44
|
}
|
|
@@ -50,11 +47,6 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
50
47
|
updateBooleanAttribute(this, 'data-invalid', isAttrTrue(newVal));
|
|
51
48
|
break;
|
|
52
49
|
}
|
|
53
|
-
case 'value':
|
|
54
|
-
{
|
|
55
|
-
this.#$input.value = newVal ?? '';
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
set checked(isChecked) {
|
|
@@ -84,18 +76,4 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
84
76
|
get focusable() {
|
|
85
77
|
return true;
|
|
86
78
|
}
|
|
87
|
-
focus() {
|
|
88
|
-
this.#$input.focus();
|
|
89
|
-
}
|
|
90
|
-
blur() {
|
|
91
|
-
this.#$input.blur();
|
|
92
|
-
}
|
|
93
|
-
#onInput = e => {
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
this.#$input.checked = false;
|
|
96
|
-
this.dispatchEvent(new CustomEvent('option-change', {
|
|
97
|
-
bubbles: true,
|
|
98
|
-
detail: this.value
|
|
99
|
-
}));
|
|
100
|
-
};
|
|
101
79
|
});
|
package/rich-text/index.js
CHANGED
|
@@ -14,18 +14,6 @@ defineCustomElement('sinch-rich-text', class extends NectaryElement {
|
|
|
14
14
|
connectedCallback() {
|
|
15
15
|
this.setAttribute('role', 'paragraph');
|
|
16
16
|
}
|
|
17
|
-
get size() {
|
|
18
|
-
return getLiteralAttribute(this, sizeValues, 'size', 'm');
|
|
19
|
-
}
|
|
20
|
-
set size(value) {
|
|
21
|
-
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
22
|
-
}
|
|
23
|
-
get text() {
|
|
24
|
-
return getAttribute(this, 'text', '');
|
|
25
|
-
}
|
|
26
|
-
set text(value) {
|
|
27
|
-
updateAttribute(this, 'text', value);
|
|
28
|
-
}
|
|
29
17
|
static get observedAttributes() {
|
|
30
18
|
return ['text'];
|
|
31
19
|
}
|
|
@@ -38,6 +26,18 @@ defineCustomElement('sinch-rich-text', class extends NectaryElement {
|
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
28
|
}
|
|
29
|
+
get size() {
|
|
30
|
+
return getLiteralAttribute(this, sizeValues, 'size', 'm');
|
|
31
|
+
}
|
|
32
|
+
set size(value) {
|
|
33
|
+
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
34
|
+
}
|
|
35
|
+
get text() {
|
|
36
|
+
return getAttribute(this, 'text', '');
|
|
37
|
+
}
|
|
38
|
+
set text(value) {
|
|
39
|
+
updateAttribute(this, 'text', value);
|
|
40
|
+
}
|
|
41
41
|
#updateText(text) {
|
|
42
42
|
if (text === null) {
|
|
43
43
|
this.#wrapper.innerHTML = '';
|
package/segment/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../title';
|
|
2
2
|
import { getTitleLevelFromType } from '../title/utils';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
4
4
|
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
5
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:12px;width:100%;height:100%;border:1px solid var(--sinch-comp-segment-color-default-border-initial);border-radius:var(--sinch-comp-segment-shape-radius);box-sizing:border-box;background-color:var(--sinch-comp-segment-color-default-background-initial);padding:8px 0 16px}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;padding:0 24px}#icon{--sinch-global-size-icon:32px}#caption{min-width:1em;--sinch-comp-title-font:var(--sinch-comp-segment-font-size-m-title)}:host([size="l"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-l-title)}:host([size="s"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-s-title)}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:0 24px}#action.empty{display:none}:host([collapsed]) :is(#content-wrapper,#action){display:none}:host([collapsed]) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" level="3" type="m" ellipsis></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
6
6
|
import { getTitleTypeFromSize } from './utils';
|
|
@@ -49,7 +49,7 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
49
49
|
static get observedAttributes() {
|
|
50
50
|
return ['caption', 'collapsed', 'size'];
|
|
51
51
|
}
|
|
52
|
-
attributeChangedCallback(name,
|
|
52
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
53
53
|
switch (name) {
|
|
54
54
|
case 'caption':
|
|
55
55
|
{
|
|
@@ -58,6 +58,9 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
58
58
|
}
|
|
59
59
|
case 'collapsed':
|
|
60
60
|
{
|
|
61
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
61
64
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
62
65
|
break;
|
|
63
66
|
}
|
|
@@ -31,9 +31,6 @@ defineCustomElement('sinch-segmented-control', class extends NectaryElement {
|
|
|
31
31
|
return getAttribute(this, 'value', '');
|
|
32
32
|
}
|
|
33
33
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
-
if (oldVal === newVal) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
34
|
switch (name) {
|
|
38
35
|
case 'value':
|
|
39
36
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
2
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px;box-sizing:border-box;color:var(--sinch-local-color-text);background-color:var(--sinch-local-color-background);--sinch-local-color-text:var(--sinch-comp-segmented-control-color-default-text-initial);--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);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon)}#wrapper: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-local-color-text:var(--sinch-comp-segmented-control-color-checked-text-initial);--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)}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);border-right-width:0;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-right-width:1px;border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{left:-1px}:host(:not(:last-child)) #border{right:-1px}:host([data-checked]) #border{border-width:2px;z-index:1}#button{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus-visible::before{content:"";position:absolute;inset:-4px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus)}:host(:first-child) #button:focus-visible::before{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) #button:focus-visible::before{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host([disabled]) #wrapper{--sinch-local-color-text:var(--sinch-comp-segmented-control-color-disabled-text-initial);--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)}#content{font:var(--sinch-comp-segmented-control-font-label);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label><div id="border"></div><button id="button"></button></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -31,7 +31,7 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
31
31
|
return ['data-checked', 'disabled', 'text'];
|
|
32
32
|
}
|
|
33
33
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
|
-
if (oldVal
|
|
34
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
switch (name) {
|
|
@@ -47,8 +47,9 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
47
47
|
}
|
|
48
48
|
case 'disabled':
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const isDisabled = isAttrTrue(newVal);
|
|
51
|
+
this.#$button.disabled = isDisabled;
|
|
52
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
52
53
|
break;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -37,9 +37,6 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
37
37
|
return getBooleanAttribute(this, 'multiple');
|
|
38
38
|
}
|
|
39
39
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
40
|
-
if (oldVal === newVal) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
40
|
switch (name) {
|
|
44
41
|
case 'value':
|
|
45
42
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
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)}#wrapper: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)}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);border-right-width:0;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-right-width:1px;border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{left:-1px}:host(:not(:last-child)) #border{right:-1px}:host([data-checked]) #border{border-width:2px;z-index:1}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus-visible::before{content:"";position:absolute;inset:-4px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus)}:host(:first-child) #button:focus-visible::before{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) #button:focus-visible::before{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}: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)}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><div id="border"></div><button id="button"></button></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
@@ -29,7 +29,7 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
29
29
|
return ['data-checked', 'disabled'];
|
|
30
30
|
}
|
|
31
31
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
32
|
-
if (oldVal
|
|
32
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
switch (name) {
|
|
@@ -40,8 +40,9 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
40
40
|
}
|
|
41
41
|
case 'disabled':
|
|
42
42
|
{
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const isDisabled = isAttrTrue(newVal);
|
|
44
|
+
this.#$button.disabled = isDisabled;
|
|
45
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
45
46
|
break;
|
|
46
47
|
}
|
|
47
48
|
}
|
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) {
|