@nectary/components 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +0 -3
- package/accordion/types.d.ts +0 -3
- package/accordion-item/index.d.ts +2 -0
- package/accordion-item/index.js +33 -34
- package/action-menu-option/index.js +2 -2
- package/alert/index.js +2 -12
- package/avatar/index.js +1 -1
- package/avatar/utils.js +3 -3
- package/badge/index.js +41 -67
- package/badge/types.d.ts +0 -4
- package/badge/utils.d.ts +0 -3
- package/badge/utils.js +0 -11
- package/button/index.js +1 -1
- package/button/types.d.ts +2 -2
- package/card/index.js +5 -16
- package/card/types.d.ts +0 -6
- package/card-container/index.js +1 -1
- package/chat-block/index.js +1 -1
- package/chat-bubble/index.js +3 -24
- package/checkbox/index.js +31 -30
- package/checkbox/types.d.ts +0 -3
- package/chip/index.js +34 -27
- package/chip/utils.js +3 -3
- package/code-tag/index.js +1 -1
- package/color-menu/index.d.ts +0 -3
- package/color-menu/index.js +50 -99
- package/color-menu/types.d.ts +0 -4
- package/color-menu-option/index.d.ts +14 -0
- package/color-menu-option/index.js +52 -0
- package/color-menu-option/types.d.ts +9 -0
- package/color-menu-option/utils.d.ts +1 -0
- package/color-menu-option/utils.js +11 -0
- package/color-swatch/index.js +1 -1
- package/color-swatch/utils.js +3 -3
- package/date-picker/index.js +2 -21
- package/date-picker/types.d.ts +0 -3
- package/dialog/index.js +2 -5
- package/dialog/types.d.ts +0 -2
- package/emoji/index.js +1 -1
- package/emoji-picker/index.d.ts +1 -0
- package/emoji-picker/index.js +32 -23
- package/field/index.js +39 -32
- package/file-drop/index.js +1 -1
- package/file-status/index.js +2 -16
- package/flag/index.js +1 -1
- package/grid/index.js +1 -1
- package/help-tooltip/index.js +3 -12
- package/horizontal-stepper/index.js +1 -1
- package/horizontal-stepper-item/index.d.ts +2 -0
- package/horizontal-stepper-item/index.js +8 -12
- package/icon/index.js +1 -1
- package/icon-button/index.js +1 -1
- package/inline-alert/index.js +19 -29
- package/input/index.d.ts +0 -3
- package/input/index.js +12 -46
- package/input/types.d.ts +1 -5
- package/link/index.js +35 -37
- package/list-item/index.js +1 -1
- package/package.json +10 -9
- package/pagination/index.js +8 -21
- package/pagination/types.d.ts +0 -3
- package/pop/index.js +16 -13
- package/popover/index.js +44 -50
- package/progress/index.js +20 -15
- package/radio/index.js +19 -6
- package/radio/types.d.ts +3 -3
- package/radio-option/index.js +35 -27
- package/rich-text/index.js +1 -1
- package/segment/index.js +2 -3
- package/segment-collapse/index.js +2 -11
- package/segment-collapse/types.d.ts +0 -3
- package/segmented-control/index.js +0 -3
- package/segmented-control/types.d.ts +0 -3
- package/segmented-control-option/index.js +20 -19
- package/segmented-icon-control/index.js +1 -4
- package/segmented-icon-control/types.d.ts +0 -3
- package/segmented-icon-control-option/index.js +18 -14
- package/select-button/index.js +7 -12
- package/select-menu/index.js +12 -5
- package/select-menu-option/index.js +2 -5
- package/skeleton/index.js +1 -1
- package/skeleton-item/index.js +1 -1
- package/spinner/index.js +1 -1
- package/table/index.js +1 -1
- package/table-body/index.js +1 -1
- package/table-cell/index.js +1 -1
- package/table-head-cell/index.d.ts +1 -0
- package/table-head-cell/index.js +12 -3
- package/table-row/index.js +18 -2
- package/tabs/index.js +1 -4
- package/tabs/types.d.ts +0 -3
- package/tabs-icon-option/index.js +4 -2
- package/tabs-option/index.js +25 -20
- package/tag/index.js +16 -8
- package/tag/utils.js +3 -3
- package/text/index.js +30 -20
- package/textarea/index.js +10 -6
- package/textarea/types.d.ts +0 -3
- package/tile-control/index.js +23 -25
- package/tile-control/types.d.ts +0 -3
- package/tile-control-option/index.js +1 -1
- package/time-picker/index.js +2 -8
- package/time-picker/types.d.ts +0 -3
- package/title/index.js +30 -22
- package/toast/index.js +20 -30
- package/toggle/index.js +33 -30
- package/toggle/types.d.ts +0 -3
- package/tooltip/index.js +2 -8
- package/tooltip/types.d.ts +0 -12
- package/vertical-stepper/index.js +1 -1
- package/vertical-stepper-item/index.d.ts +2 -0
- package/vertical-stepper-item/index.js +8 -12
- package/logo/create-logo-class.d.ts +0 -1
- package/logo/create-logo-class.js +0 -52
- package/logo/engage-icon/index.d.ts +0 -11
- package/logo/engage-icon/index.js +0 -4
- package/logo/engage-icon-wordmark/index.d.ts +0 -11
- package/logo/engage-icon-wordmark/index.js +0 -4
- package/logo/sinch-icon/index.d.ts +0 -11
- package/logo/sinch-icon/index.js +0 -4
- package/logo/sinch-icon-wordmark/index.d.ts +0 -11
- package/logo/sinch-icon-wordmark/index.js +0 -4
- package/logo/types.d.ts +0 -11
- package/theme/accordion-item.css +0 -4
- package/theme/alert.css +0 -6
- package/theme/avatar.css +0 -25
- package/theme/badge.css +0 -15
- package/theme/button.css +0 -146
- package/theme/chat.css +0 -9
- package/theme/chip.css +0 -68
- package/theme/color-menu.css +0 -4
- package/theme/color-swatch.css +0 -71
- package/theme/colors.d.ts +0 -4
- package/theme/colors.js +0 -4
- package/theme/contextual.css +0 -40
- package/theme/date-picker.css +0 -7
- package/theme/dialog.css +0 -4
- package/theme/elevation.css +0 -7
- package/theme/emoji-picker.css +0 -13
- package/theme/emoji.css +0 -5
- package/theme/file-status.css +0 -7
- package/theme/flag.css +0 -4
- package/theme/fonts.css +0 -86
- package/theme/fonts.json +0 -89
- package/theme/help-tooltip.css +0 -5
- package/theme/horizontal-stepper.css +0 -5
- package/theme/icon-button.css +0 -68
- package/theme/icon.css +0 -7
- package/theme/index.css +0 -4
- package/theme/index.d.ts +0 -39
- package/theme/index.js +0 -39
- package/theme/inline-alert.css +0 -7
- package/theme/input.css +0 -10
- package/theme/link.css +0 -5
- package/theme/pagination.css +0 -5
- package/theme/palette.css +0 -90
- package/theme/segment.css +0 -4
- package/theme/select-button.css +0 -10
- package/theme/select-menu.css +0 -6
- package/theme/shapes.css +0 -8
- package/theme/size.css +0 -9
- package/theme/spinner.css +0 -7
- package/theme/tag.css +0 -67
- package/theme/time-picker.css +0 -4
- package/theme/toast.css +0 -7
- package/theme/typography.css +0 -16
- package/theme/vertical-stepper.css +0 -5
- /package/{logo → color-menu-option}/types.js +0 -0
package/radio-option/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;--sinch-local-size: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:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer}#input:disabled{cursor:initial}#input::before{content:"";position:absolute;top:0;left:0;width:var(--sinch-local-size);height:var(--sinch-local-size);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}#input:focus-visible::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}#input:enabled:hover::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}#input:enabled:active::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#input-wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);align-self:flex-start}#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}#input:checked+#knob{opacity:1}#input:enabled:hover+#knob{background-color:var(--sinch-local-color-knob-hover)}#input:enabled:active+#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}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="input-wrapper"><input id="input" type="radio"/><div id="knob"></div></div><label for="input" id="label"></label></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
@@ -20,33 +20,12 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
20
20
|
this.#$input.removeEventListener('input', this.#onInput);
|
|
21
21
|
}
|
|
22
22
|
static get observedAttributes() {
|
|
23
|
-
return ['checked', 'disabled', 'text', 'value'];
|
|
23
|
+
return ['checked', 'disabled', 'text', 'value', 'data-invalid'];
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return getBooleanAttribute(this, 'checked');
|
|
30
|
-
}
|
|
31
|
-
set value(value) {
|
|
32
|
-
updateAttribute(this, 'value', value);
|
|
33
|
-
}
|
|
34
|
-
get value() {
|
|
35
|
-
return getAttribute(this, 'value', '');
|
|
36
|
-
}
|
|
37
|
-
set disabled(isDisabled) {
|
|
38
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
39
|
-
}
|
|
40
|
-
get disabled() {
|
|
41
|
-
return getBooleanAttribute(this, 'disabled');
|
|
42
|
-
}
|
|
43
|
-
set text(value) {
|
|
44
|
-
updateAttribute(this, 'text', value);
|
|
45
|
-
}
|
|
46
|
-
get text() {
|
|
47
|
-
return getAttribute(this, 'text', '');
|
|
48
|
-
}
|
|
49
|
-
attributeChangedCallback(name, _, newVal) {
|
|
25
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
26
|
+
if (oldVal === newVal) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
50
29
|
switch (name) {
|
|
51
30
|
case 'text':
|
|
52
31
|
{
|
|
@@ -66,6 +45,11 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
66
45
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
67
46
|
break;
|
|
68
47
|
}
|
|
48
|
+
case 'data-invalid':
|
|
49
|
+
{
|
|
50
|
+
updateBooleanAttribute(this, 'data-invalid', isAttrTrue(newVal));
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
69
53
|
case 'value':
|
|
70
54
|
{
|
|
71
55
|
this.#$input.value = newVal ?? '';
|
|
@@ -73,6 +57,30 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
73
57
|
}
|
|
74
58
|
}
|
|
75
59
|
}
|
|
60
|
+
set checked(isChecked) {
|
|
61
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
62
|
+
}
|
|
63
|
+
get checked() {
|
|
64
|
+
return getBooleanAttribute(this, 'checked');
|
|
65
|
+
}
|
|
66
|
+
set value(value) {
|
|
67
|
+
updateAttribute(this, 'value', value);
|
|
68
|
+
}
|
|
69
|
+
get value() {
|
|
70
|
+
return getAttribute(this, 'value', '');
|
|
71
|
+
}
|
|
72
|
+
set disabled(isDisabled) {
|
|
73
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
74
|
+
}
|
|
75
|
+
get disabled() {
|
|
76
|
+
return getBooleanAttribute(this, 'disabled');
|
|
77
|
+
}
|
|
78
|
+
set text(value) {
|
|
79
|
+
updateAttribute(this, 'text', value);
|
|
80
|
+
}
|
|
81
|
+
get text() {
|
|
82
|
+
return getAttribute(this, 'text', '');
|
|
83
|
+
}
|
|
76
84
|
get focusable() {
|
|
77
85
|
return true;
|
|
78
86
|
}
|
package/rich-text/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, NectaryElement, getLiteralAttribute, updateLiteralAttribute, getAttribute, updateAttribute, parseMarkdown } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block
|
|
2
|
+
const templateHTML = '<style>:host{display:block;--sinch-comp-rich-text-font:var(--sinch-sys-font-body-m)}:host([size="s"]){--sinch-comp-rich-text-font:var(--sinch-sys-font-body-s)}:host([size=xs]){--sinch-comp-rich-text-font:var(--sinch-sys-font-body-xs)}:host([size=xxs]){--sinch-comp-rich-text-font:var(--sinch-sys-font-body-xxs)}#wrapper{font:var(--sinch-comp-rich-text-font);color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default))}.em1{font-style:italic}.em2{font-weight:var(--sinch-ref-typography-font-weight-700)}.em3{font-style:italic;font-weight:var(--sinch-ref-typography-font-weight-700)}.strikethrough{text-decoration:line-through}.link{font:var(--sinch-comp-link-default-font-initial);color:var(--sinch-comp-link-color-default-text-initial);text-decoration:underline}.link:hover{color:var(--sinch-comp-link-color-default-text-hover);text-decoration:none}.code{font:var(--sinch-comp-code-tag-font-text);line-height:inherit;font-size:inherit;border:1px solid var(--sinch-comp-code-tag-color-default-border-initial);background-color:var(--sinch-comp-code-tag-color-default-background-initial);padding:0 .25em;border-radius:var(--sinch-comp-code-tag-shape-radius)}.paragraph{margin:0}.paragraph+.paragraph{margin-top:12px}</style><div id="wrapper"></div>';
|
|
3
3
|
import { assertSize, sizeValues } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
package/segment/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import '../title';
|
|
|
2
2
|
import { getTitleLevelFromType } from '../title/utils';
|
|
3
3
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
4
4
|
import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:12px;width:100%;height:100%;border:1px solid var(--sinch-color-
|
|
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';
|
|
7
7
|
const template = document.createElement('template');
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
@@ -58,7 +58,7 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
58
58
|
}
|
|
59
59
|
case 'collapsed':
|
|
60
60
|
{
|
|
61
|
-
updateBooleanAttribute(this,
|
|
61
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
64
|
case 'size':
|
|
@@ -67,7 +67,6 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
67
67
|
assertSize(newVal, 'sinch-segment');
|
|
68
68
|
}
|
|
69
69
|
const titleType = getTitleTypeFromSize(this.size);
|
|
70
|
-
updateAttribute(this.#$caption, 'type', titleType);
|
|
71
70
|
updateAttribute(this.#$caption, 'level', getTitleLevelFromType(titleType));
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import '../icon';
|
|
2
2
|
import '../icon-button';
|
|
3
|
-
import { defineCustomElement, getBooleanAttribute,
|
|
4
|
-
const templateHTML = '<style>:host{display:block;--sinch-size-icon:32px}#icon-dropdown{display:block;will-change:transform;transform:rotate(180deg)}:host([value]:not([value=false])) #icon-dropdown{transform:rotate(0)}</style><sinch-icon-button id="button" size="s"><sinch-icon id="icon-dropdown" slot="icon"></sinch-icon></sinch-icon-button>';
|
|
3
|
+
import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
4
|
+
const templateHTML = '<style>:host{display:block;--sinch-global-size-icon:32px}#icon-dropdown{display:block;will-change:transform;transform:rotate(180deg)}:host([value]:not([value=false])) #icon-dropdown{transform:rotate(0)}</style><sinch-icon-button id="button" size="s"><sinch-icon id="icon-dropdown" slot="icon" name="keyboard_arrow_down"></sinch-icon></sinch-icon-button>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
8
8
|
#$button;
|
|
9
|
-
#$iconDropdown;
|
|
10
9
|
constructor() {
|
|
11
10
|
super();
|
|
12
11
|
const shadowRoot = this.attachShadow();
|
|
13
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
13
|
this.#$button = shadowRoot.querySelector('#button');
|
|
15
|
-
this.#$iconDropdown = shadowRoot.querySelector('#icon-dropdown');
|
|
16
14
|
}
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'checkbox');
|
|
19
17
|
this.#$button.addEventListener('click', this.#onClick);
|
|
20
18
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
21
|
-
updateAttribute(this.#$iconDropdown, 'name', getCssVar(this, '--sinch-segment-icon-dropdown'));
|
|
22
19
|
}
|
|
23
20
|
disconnectedCallback() {
|
|
24
21
|
this.#$button.removeEventListener('click', this.#onClick);
|
|
@@ -36,12 +33,6 @@ defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
get type() {
|
|
40
|
-
return 'text';
|
|
41
|
-
}
|
|
42
|
-
get nodeName() {
|
|
43
|
-
return 'input';
|
|
44
|
-
}
|
|
45
36
|
set value(isChecked) {
|
|
46
37
|
updateBooleanAttribute(this, 'value', isChecked);
|
|
47
38
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchSegmentExpandElement = HTMLElement & {
|
|
4
3
|
value: boolean;
|
|
5
4
|
addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
@@ -9,7 +8,5 @@ export type TSinchSegmentExpandElement = HTMLElement & {
|
|
|
9
8
|
export type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
|
|
10
9
|
value: boolean;
|
|
11
10
|
'aria-label': string;
|
|
12
|
-
/** @deprecated */
|
|
13
|
-
onChange?: (e: SyntheticEvent<TSinchSegmentExpandElement, CustomEvent<boolean>>) => void;
|
|
14
11
|
'on-change'?: (e: CustomEvent<boolean>) => void;
|
|
15
12
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchSegmentedControlElement = HTMLElement & {
|
|
4
3
|
value: string;
|
|
5
4
|
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
@@ -8,7 +7,5 @@ export type TSinchSegmentedControlElement = HTMLElement & {
|
|
|
8
7
|
export type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
|
|
9
8
|
value: string;
|
|
10
9
|
'aria-label': string;
|
|
11
|
-
/** @deprecated */
|
|
12
|
-
onChange?: (event: SyntheticEvent<TSinchSegmentedControlElement, CustomEvent<string>>) => void;
|
|
13
10
|
'on-change'?: (e: CustomEvent<string>) => void;
|
|
14
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{
|
|
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;
|
|
5
5
|
defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
|
|
@@ -30,24 +30,6 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
30
30
|
static get observedAttributes() {
|
|
31
31
|
return ['data-checked', 'disabled', 'text'];
|
|
32
32
|
}
|
|
33
|
-
set value(value) {
|
|
34
|
-
updateAttribute(this, 'value', value);
|
|
35
|
-
}
|
|
36
|
-
get value() {
|
|
37
|
-
return getAttribute(this, 'value', '');
|
|
38
|
-
}
|
|
39
|
-
set disabled(isDisabled) {
|
|
40
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
41
|
-
}
|
|
42
|
-
get disabled() {
|
|
43
|
-
return getBooleanAttribute(this, 'disabled');
|
|
44
|
-
}
|
|
45
|
-
set text(value) {
|
|
46
|
-
updateAttribute(this, 'text', value);
|
|
47
|
-
}
|
|
48
|
-
get text() {
|
|
49
|
-
return getAttribute(this, 'text', '');
|
|
50
|
-
}
|
|
51
33
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
52
34
|
if (oldVal === newVal) {
|
|
53
35
|
return;
|
|
@@ -66,10 +48,29 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
66
48
|
case 'disabled':
|
|
67
49
|
{
|
|
68
50
|
this.#$button.disabled = isAttrTrue(newVal);
|
|
51
|
+
updateBooleanAttribute(this, name, this.#$button.disabled);
|
|
69
52
|
break;
|
|
70
53
|
}
|
|
71
54
|
}
|
|
72
55
|
}
|
|
56
|
+
set value(value) {
|
|
57
|
+
updateAttribute(this, 'value', value);
|
|
58
|
+
}
|
|
59
|
+
get value() {
|
|
60
|
+
return getAttribute(this, 'value', '');
|
|
61
|
+
}
|
|
62
|
+
set disabled(isDisabled) {
|
|
63
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
64
|
+
}
|
|
65
|
+
get disabled() {
|
|
66
|
+
return getBooleanAttribute(this, 'disabled');
|
|
67
|
+
}
|
|
68
|
+
set text(value) {
|
|
69
|
+
updateAttribute(this, 'text', value);
|
|
70
|
+
}
|
|
71
|
+
get text() {
|
|
72
|
+
return getAttribute(this, 'text', '');
|
|
73
|
+
}
|
|
73
74
|
get focusable() {
|
|
74
75
|
return true;
|
|
75
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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}</style><div id="wrapper"><slot></slot></div>';
|
|
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>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement {
|
|
@@ -24,9 +24,6 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
24
24
|
static get observedAttributes() {
|
|
25
25
|
return ['value'];
|
|
26
26
|
}
|
|
27
|
-
get nodeName() {
|
|
28
|
-
return 'select';
|
|
29
|
-
}
|
|
30
27
|
set value(value) {
|
|
31
28
|
updateAttribute(this, 'value', value);
|
|
32
29
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchSegmentedIconControlElement = HTMLElement & {
|
|
4
3
|
value: string;
|
|
5
4
|
multiple: boolean;
|
|
@@ -11,7 +10,5 @@ export type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmented
|
|
|
11
10
|
value: string;
|
|
12
11
|
multiple?: boolean;
|
|
13
12
|
'aria-label': string;
|
|
14
|
-
/** @deprecated */
|
|
15
|
-
onChange?: (event: SyntheticEvent<TSinchSegmentedIconControlElement, CustomEvent<string>>) => void;
|
|
16
13
|
'on-change'?: (e: CustomEvent<string>) => void;
|
|
17
14
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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;
|
|
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;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control-option', class extends NectaryElement {
|
|
@@ -28,19 +28,10 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
28
28
|
static get observedAttributes() {
|
|
29
29
|
return ['data-checked', 'disabled'];
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return getAttribute(this, 'value', '');
|
|
36
|
-
}
|
|
37
|
-
set disabled(isDisabled) {
|
|
38
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
39
|
-
}
|
|
40
|
-
get disabled() {
|
|
41
|
-
return getBooleanAttribute(this, 'disabled');
|
|
42
|
-
}
|
|
43
|
-
attributeChangedCallback(name, _, newVal) {
|
|
31
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
32
|
+
if (oldVal === newVal) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
44
35
|
switch (name) {
|
|
45
36
|
case 'data-checked':
|
|
46
37
|
{
|
|
@@ -50,10 +41,23 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
50
41
|
case 'disabled':
|
|
51
42
|
{
|
|
52
43
|
this.#$button.disabled = isAttrTrue(newVal);
|
|
44
|
+
updateBooleanAttribute(this, name, this.#$button.disabled);
|
|
53
45
|
break;
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
48
|
}
|
|
49
|
+
set value(value) {
|
|
50
|
+
updateAttribute(this, 'value', value);
|
|
51
|
+
}
|
|
52
|
+
get value() {
|
|
53
|
+
return getAttribute(this, 'value', '');
|
|
54
|
+
}
|
|
55
|
+
set disabled(isDisabled) {
|
|
56
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
57
|
+
}
|
|
58
|
+
get disabled() {
|
|
59
|
+
return getBooleanAttribute(this, 'disabled');
|
|
60
|
+
}
|
|
57
61
|
get focusable() {
|
|
58
62
|
return true;
|
|
59
63
|
}
|
package/select-button/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import '../text';
|
|
2
2
|
import '../icon';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context } from '../utils';
|
|
4
4
|
import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-
|
|
5
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#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}#button{all:initial;cursor:pointer;position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}#button:disabled{cursor:initial}#button:disabled+#border{border-color:var(--sinch-comp-select-button-color-disabled-border-initial)}#button:disabled~#text{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-text-initial)}#button:disabled~#placeholder{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-placeholder-initial)}:host([invalid]) #button:enabled+#border{border-color:var(--sinch-comp-select-button-color-invalid-border-initial)}#wrapper>#button:focus-visible+#border{border-color:var(--sinch-comp-select-button-color-default-border-focus);border-width:2px}#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"><button id="button"></button><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');
|
|
7
7
|
template.innerHTML = templateHTML;
|
|
8
8
|
defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
9
9
|
#$button;
|
|
10
|
-
#$icon;
|
|
11
10
|
#$text;
|
|
11
|
+
#$placeholder;
|
|
12
12
|
#$leftSlot;
|
|
13
13
|
#$leftWrapper;
|
|
14
14
|
#$wrapper;
|
|
@@ -21,8 +21,8 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
21
21
|
});
|
|
22
22
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
23
23
|
this.#$button = shadowRoot.querySelector('#button');
|
|
24
|
-
this.#$icon = shadowRoot.querySelector('#dropdown-icon');
|
|
25
24
|
this.#$text = shadowRoot.querySelector('#text');
|
|
25
|
+
this.#$placeholder = shadowRoot.querySelector('#placeholder');
|
|
26
26
|
this.#$leftSlot = shadowRoot.querySelector('slot[name="left"]');
|
|
27
27
|
this.#$leftWrapper = shadowRoot.querySelector('#left');
|
|
28
28
|
this.#$wrapper = shadowRoot.querySelector('#wrapper');
|
|
@@ -56,7 +56,6 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
56
56
|
this.#$leftSlot.addEventListener('slotchange', this.#onLeftSlotChange, {
|
|
57
57
|
signal
|
|
58
58
|
});
|
|
59
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, '--sinch-select-button-icon-dropdown'));
|
|
60
59
|
this.#sizeContext.listen(this.#controller.signal);
|
|
61
60
|
subscribeContext(this, 'size', this.#onContextSize, signal);
|
|
62
61
|
this.#onLeftSlotChange();
|
|
@@ -76,23 +75,19 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
76
75
|
switch (name) {
|
|
77
76
|
case 'text':
|
|
78
77
|
{
|
|
79
|
-
|
|
80
|
-
this.#$text.textContent = value.length > 0 ? value : this.placeholder;
|
|
78
|
+
this.#$text.textContent = newVal;
|
|
81
79
|
break;
|
|
82
80
|
}
|
|
83
81
|
case 'placeholder':
|
|
84
82
|
{
|
|
85
|
-
|
|
86
|
-
if (value.length === 0) {
|
|
87
|
-
this.#$text.textContent = newVal ?? '';
|
|
88
|
-
}
|
|
83
|
+
this.#$placeholder.textContent = newVal;
|
|
89
84
|
break;
|
|
90
85
|
}
|
|
91
86
|
case 'invalid':
|
|
92
87
|
{
|
|
93
88
|
const isInvalid = isAttrTrue(newVal);
|
|
94
|
-
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
95
89
|
updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
|
|
90
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
96
91
|
break;
|
|
97
92
|
}
|
|
98
93
|
case 'disabled':
|
package/select-menu/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import '../input';
|
|
|
2
2
|
import '../icon-button';
|
|
3
3
|
import '../icon';
|
|
4
4
|
import '../text';
|
|
5
|
-
import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute, debounceTimeout, setClass, subscribeContext,
|
|
6
|
-
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}#search{display:none;margin:10px}#search.active{display:block}#not-found{display:
|
|
5
|
+
import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute, debounceTimeout, setClass, subscribeContext, hasClass } from '../utils';
|
|
6
|
+
const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}#search{display:none;margin:10px}#search.active{display:block}#search-clear:not(.active){display:none}#not-found{display:flex;align-items:center;justify-content:center;width:100%;height:30px;margin-bottom:10px;pointer-events:none;user-select:none;--sinch-comp-text-font:var(--sinch-comp-select-menu-font-not-found-text);--sinch-global-color-text:var(--sinch-comp-select-menu-color-default-not-found-text-initial)}#not-found:not(.active){display:none}::slotted(.hidden){display:none}</style><sinch-input id="search" size="s" placeholder="Search"><sinch-icon id="icon-search" slot="icon" name="search"></sinch-icon><sinch-icon-button id="search-clear" slot="right"><sinch-icon slot="icon" name="close"></sinch-icon></sinch-icon-button></sinch-input><div id="not-found"><sinch-text type="m">No results</sinch-text></div><div id="listbox" role="presentation"><slot></slot></div>';
|
|
7
7
|
const ITEM_HEIGHT = 40;
|
|
8
8
|
const NUM_ITEMS_SEARCH = 7;
|
|
9
9
|
const template = document.createElement('template');
|
|
@@ -12,7 +12,7 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
12
12
|
#$optionSlot;
|
|
13
13
|
#$listbox;
|
|
14
14
|
#$search;
|
|
15
|
-
#$
|
|
15
|
+
#$searchClear;
|
|
16
16
|
#$notFound;
|
|
17
17
|
#controller = null;
|
|
18
18
|
#searchDebounce;
|
|
@@ -23,7 +23,7 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
23
23
|
this.#$optionSlot = shadowRoot.querySelector('slot');
|
|
24
24
|
this.#$listbox = shadowRoot.querySelector('#listbox');
|
|
25
25
|
this.#$search = shadowRoot.querySelector('#search');
|
|
26
|
-
this.#$
|
|
26
|
+
this.#$searchClear = shadowRoot.querySelector('#search-clear');
|
|
27
27
|
this.#$notFound = shadowRoot.querySelector('#not-found');
|
|
28
28
|
this.#searchDebounce = debounceTimeout(200)(this.#updateSearch);
|
|
29
29
|
}
|
|
@@ -40,11 +40,11 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
40
40
|
this.#$listbox.addEventListener('mousedown', this.#onListboxMousedown, options);
|
|
41
41
|
this.#$listbox.addEventListener('click', this.#onListboxClick, options);
|
|
42
42
|
this.#$search.addEventListener('-change', this.#onSearchChange, options);
|
|
43
|
+
this.#$searchClear.addEventListener('-click', this.#onSearchClearClick, options);
|
|
43
44
|
this.#$optionSlot.addEventListener('slotchange', this.#onOptionSlotChange, options);
|
|
44
45
|
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
45
46
|
subscribeContext(this, 'keydown', this.#onContextKeyDown, this.#controller.signal);
|
|
46
47
|
subscribeContext(this, 'visibility', this.#onContextVisibility, this.#controller.signal);
|
|
47
|
-
updateAttribute(this.#$iconSearch, 'name', getCssVar(this, '--sinch-select-menu-icon-search'));
|
|
48
48
|
this.#onOptionSlotChange();
|
|
49
49
|
}
|
|
50
50
|
disconnectedCallback() {
|
|
@@ -125,6 +125,13 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
125
125
|
#onSearchChange = e => {
|
|
126
126
|
this.#$search.value = e.detail;
|
|
127
127
|
this.#searchDebounce.fn();
|
|
128
|
+
setClass(this.#$searchClear, 'active', e.detail.length > 0);
|
|
129
|
+
};
|
|
130
|
+
#onSearchClearClick = () => {
|
|
131
|
+
this.#$search.value = '';
|
|
132
|
+
this.#$search.focus();
|
|
133
|
+
this.#searchDebounce.fn();
|
|
134
|
+
setClass(this.#$searchClear, 'active', false);
|
|
128
135
|
};
|
|
129
136
|
#updateSearch = () => {
|
|
130
137
|
const searchValue = this.#$search.value.toLowerCase();
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import '../icon';
|
|
2
2
|
import '../text';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute,
|
|
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;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
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;
|
|
7
7
|
export class SelectMenuOption extends NectaryElement {
|
|
8
|
-
#$iconCheck;
|
|
9
8
|
#$content;
|
|
10
9
|
constructor() {
|
|
11
10
|
super();
|
|
12
11
|
const shadowRoot = this.attachShadow();
|
|
13
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
13
|
this.#$content = shadowRoot.querySelector('#content');
|
|
15
|
-
this.#$iconCheck = shadowRoot.querySelector('#icon-check');
|
|
16
14
|
}
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'option');
|
|
19
|
-
updateAttribute(this.#$iconCheck, 'name', getCssVar(this, '--sinch-select-menu-icon-check'));
|
|
20
17
|
}
|
|
21
18
|
static get observedAttributes() {
|
|
22
19
|
return ['text', 'data-checked', 'disabled'];
|
package/skeleton/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getUid, isAttrTrue, NectaryElement, shouldReduceMotion } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;height:100%;box-sizing:border-box;overflow:hidden}:host([card]:not([card=false]))>#wrapper{padding:16px;background-color:var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;height:100%;box-sizing:border-box;overflow:hidden}:host([card]:not([card=false]))>#wrapper{padding:16px;background-color:var(--sinch-sys-color-container-main-default);border-radius:var(--sinch-sys-shape-radius-l);border:1px solid var(--sinch-sys-color-border-light)}#shimmer{position:absolute;inset:0;background-image:linear-gradient(90deg,transparent 0,var(--sinch-sys-color-container-contrast-primary-default) 100px,transparent 200px);clip-path:url("#clip")}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"></div></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
const ANIMATION_DURATION = 2000;
|
package/skeleton-item/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getCssVar, NectaryElement, attrValueToInteger, shouldReduceMotion } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;height:var(--sinch-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([size=xs]){height:var(--sinch-size-xs);--sinch-shape-radius:var(--sinch-shape-radius-xs)}:host([size="s"]){height:var(--sinch-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s)}:host([size="m"]){height:var(--sinch-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([size="l"]){height:var(--sinch-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l)}#content{height:100%;background-color:var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:block;height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size=xs]){height:var(--sinch-sys-size-xs);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs)}:host([size="s"]){height:var(--sinch-sys-size-s);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s)}:host([size="m"]){height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size="l"]){height:var(--sinch-sys-size-l);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l)}#content{height:100%;background-color:var(--sinch-sys-color-border-light);border-radius:var(--sinch-local-shape-radius)}</style><div id="content"></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-skeleton-item', class extends NectaryElement {
|