@nectary/components 1.4.0 → 2.1.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/index.js +5 -1
- package/action-menu-option/index.js +2 -2
- package/alert/index.js +4 -21
- package/alert/utils.d.ts +0 -3
- package/alert/utils.js +1 -6
- package/avatar/index.js +5 -21
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +2 -15
- package/badge/index.js +36 -68
- package/badge/types.d.ts +0 -4
- package/badge/utils.d.ts +0 -6
- package/badge/utils.js +1 -17
- package/button/index.js +25 -27
- package/button/types.d.ts +2 -2
- package/button/utils.d.ts +0 -3
- package/button/utils.js +1 -9
- 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.d.ts +0 -1
- package/chat-bubble/index.js +3 -25
- package/checkbox/index.js +32 -33
- package/checkbox/types.d.ts +0 -3
- package/chip/index.js +54 -44
- package/chip/utils.d.ts +0 -1
- package/chip/utils.js +2 -7
- package/code-tag/index.js +1 -1
- package/color-menu/index.d.ts +0 -3
- package/color-menu/index.js +55 -101
- 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 +2 -5
- package/color-swatch/utils.d.ts +0 -1
- package/color-swatch/utils.js +2 -7
- package/date-picker/index.js +3 -40
- package/date-picker/types.d.ts +0 -3
- package/date-picker/utils.d.ts +0 -8
- package/date-picker/utils.js +0 -20
- package/dialog/index.js +2 -6
- 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 +36 -34
- package/field/index.js +39 -32
- package/file-drop/index.js +1 -1
- package/file-status/index.js +4 -25
- package/file-status/utils.d.ts +0 -3
- package/file-status/utils.js +1 -6
- package/flag/index.js +1 -1
- package/grid/index.js +1 -1
- package/help-tooltip/index.d.ts +0 -1
- package/help-tooltip/index.js +3 -13
- 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 +23 -27
- package/icon-button/utils.d.ts +0 -3
- package/icon-button/utils.js +1 -9
- package/inline-alert/index.js +20 -37
- package/inline-alert/utils.d.ts +0 -3
- package/inline-alert/utils.js +1 -6
- package/input/index.d.ts +0 -3
- package/input/index.js +22 -58
- package/input/types.d.ts +1 -5
- package/input/utils.d.ts +0 -3
- package/input/utils.js +1 -6
- package/link/index.js +35 -37
- package/list-item/index.js +1 -1
- package/package.json +11 -11
- package/pagination/index.js +8 -21
- package/pagination/types.d.ts +0 -3
- package/pop/index.js +39 -38
- package/pop/utils.d.ts +0 -3
- package/pop/utils.js +0 -5
- package/popover/index.js +42 -51
- package/popover/utils.d.ts +0 -3
- package/popover/utils.js +0 -5
- 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 +3 -10
- package/rich-text/utils.d.ts +0 -3
- package/rich-text/utils.js +1 -6
- package/segment/index.js +3 -7
- 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 +29 -31
- package/select-menu/index.js +18 -8
- 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 +3 -10
- 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 +17 -12
- package/tag/utils.d.ts +0 -1
- package/tag/utils.js +2 -7
- package/text/index.js +24 -21
- package/text/utils.d.ts +0 -3
- package/text/utils.js +1 -6
- 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 -11
- package/time-picker/types.d.ts +0 -3
- package/time-picker/utils.d.ts +1 -1
- package/time-picker/utils.js +17 -5
- package/title/index.js +28 -30
- package/title/utils.d.ts +0 -7
- package/title/utils.js +1 -29
- package/toast/index.js +22 -39
- package/toast/utils.d.ts +0 -3
- package/toast/utils.js +1 -6
- package/toggle/index.js +33 -30
- package/toggle/types.d.ts +0 -3
- package/tooltip/index.js +3 -15
- package/tooltip/types.d.ts +0 -12
- package/tooltip/utils.d.ts +0 -5
- package/tooltip/utils.js +0 -10
- package/utils/dom.js +0 -5
- package/utils/element.js +2 -2
- package/utils/size.d.ts +0 -5
- package/utils/size.js +1 -17
- 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/file-status/index.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import '../spinner';
|
|
2
2
|
import '../icon';
|
|
3
3
|
import '../text';
|
|
4
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, updateBooleanAttribute
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;background-color:var(--sinch-color-
|
|
6
|
-
import {
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;border-radius:var(--sinch-comp-file-status-shape-radius)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-file-status-color-error-background)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-file-status-color-success-background)}:host([type=pending]) #wrapper{background-color:var(--sinch-comp-file-status-color-pending-background)}:host([type=progress]) #wrapper{background-color:var(--sinch-comp-file-status-color-progress-background)}:host([type=loading]) #wrapper{background-color:var(--sinch-comp-file-status-color-loading-background)}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;min-height:24px;margin-left:16px}:host([type=error]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-error-text)}:host([type=success]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-success-text)}:host([type=pending]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-pending-text)}:host([type=progress]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-progress-text)}:host([type=loading]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-loading-text)}#action{display:flex;gap:4px;height:32px;margin-top:-4px;margin-bottom:-4px}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success{display:none}#icon-pending{--sinch-global-color-icon:var(--sinch-comp-file-status-color-pending-icon)}#icon-success{--sinch-global-color-icon:var(--sinch-comp-file-status-color-success-icon)}#icon-progress{--sinch-global-color-icon:var(--sinch-comp-file-status-color-progress-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-file-status-color-error-icon)}#icon-loading{--sinch-global-color-icon:var(--sinch-comp-file-status-color-loading-icon)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block}</style><div id="wrapper"><sinch-spinner id="icon-loading" size="m"></sinch-spinner><sinch-icon id="icon-pending" name="pending_actions"></sinch-icon><sinch-icon id="icon-success" name="check_circle"></sinch-icon><sinch-icon id="icon-progress" name="text_snippet"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><div id="content-wrapper"><sinch-text id="filename" type="m" ellipsis></sinch-text><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
6
|
+
import { typeValues } from './utils';
|
|
7
7
|
const template = document.createElement('template');
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
9
9
|
defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
10
10
|
#$filename;
|
|
11
11
|
#$contentSlot;
|
|
12
|
-
#$icon;
|
|
13
12
|
constructor() {
|
|
14
13
|
super();
|
|
15
14
|
const shadowRoot = this.attachShadow();
|
|
16
15
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
17
16
|
this.#$filename = shadowRoot.querySelector('#filename');
|
|
18
17
|
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
19
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
20
18
|
}
|
|
21
19
|
connectedCallback() {
|
|
22
20
|
super.connectedCallback();
|
|
23
21
|
this.#$contentSlot.addEventListener('slotchange', this.#onContentSlotChange);
|
|
24
22
|
this.#onContentSlotChange();
|
|
25
|
-
this.#updateIcon();
|
|
26
23
|
}
|
|
27
24
|
disconnectedCallback() {
|
|
28
25
|
super.disconnectedCallback();
|
|
@@ -41,21 +38,13 @@ defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
|
41
38
|
updateAttribute(this, 'filename', value);
|
|
42
39
|
}
|
|
43
40
|
static get observedAttributes() {
|
|
44
|
-
return ['filename'
|
|
41
|
+
return ['filename'];
|
|
45
42
|
}
|
|
46
43
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
47
44
|
if (oldVal === newVal) {
|
|
48
45
|
return;
|
|
49
46
|
}
|
|
50
47
|
switch (name) {
|
|
51
|
-
case 'type':
|
|
52
|
-
{
|
|
53
|
-
if ('production' !== 'production') {
|
|
54
|
-
assertType(newVal);
|
|
55
|
-
}
|
|
56
|
-
this.#updateIcon();
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
48
|
case 'filename':
|
|
60
49
|
{
|
|
61
50
|
this.#$filename.textContent = newVal;
|
|
@@ -63,16 +52,6 @@ defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
#updateIcon() {
|
|
67
|
-
if (!this.isConnected) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const type = this.type;
|
|
71
|
-
if (type === 'loading') {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-file-status-icon-${type}`));
|
|
75
|
-
}
|
|
76
55
|
#onContentSlotChange = () => {
|
|
77
56
|
updateBooleanAttribute(this.#$filename, 'emphasized', this.#$contentSlot.assignedElements().length > 0);
|
|
78
57
|
};
|
package/file-status/utils.d.ts
CHANGED
package/file-status/utils.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export const typeValues = ['pending', 'loading', 'progress', 'success', 'error'];
|
|
2
|
-
export const assertType = value => {
|
|
3
|
-
if (value === null || !typeValues.includes(value)) {
|
|
4
|
-
throw new Error(`sinch-file-status: invalid type attribute: ${value}`);
|
|
5
|
-
}
|
|
6
|
-
};
|
|
1
|
+
export const typeValues = ['pending', 'loading', 'progress', 'success', 'error'];
|
package/flag/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:contents}#image{pointer-events:none;width:var(--sinch-size-icon,48px);height:var(--sinch-size-icon,48px);object-fit:contain}</style><img id="image" src="" alt="" loading="lazy"/>';
|
|
2
|
+
const templateHTML = '<style>:host{display:contents}#image{pointer-events:none;width:var(--sinch-global-size-icon,48px);height:var(--sinch-global-size-icon,48px);object-fit:contain}</style><img id="image" src="" alt="" loading="lazy"/>';
|
|
3
3
|
import { getFlagUrl } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
package/grid/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, NectaryElement } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{--sinch-grid-gutter:24px;--sinch-grid-margin:32px;--sinch-grid-num-columns:12;display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),minmax(0,1fr));grid-column-gap:var(--sinch-grid-gutter);grid-row-gap:var(--sinch-grid-gutter);padding:var(--sinch-grid-margin)}@media only screen and (max-width:1439px){:host{--sinch-grid-gutter:24px;--sinch-grid-margin:24px;--sinch-grid-num-columns:12}}@media only screen and (max-width:1023px){:host{--sinch-grid-gutter:24px;--sinch-grid-margin:24px;--sinch-grid-num-columns:8}}@media only screen and (max-width:767px){:host{--sinch-grid-gutter:16px;--sinch-grid-margin:16px;--sinch-grid-num-columns:4}}</style><slot name="item"></slot>';
|
|
2
|
+
const templateHTML = '<style>:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:32px;--sinch-comp-grid-num-columns:12;display:grid;grid-template-columns:repeat(var(--sinch-comp-grid-num-columns),minmax(0,1fr));grid-column-gap:var(--sinch-comp-grid-gutter);grid-row-gap:var(--sinch-comp-grid-gutter);padding:var(--sinch-comp-grid-margin)}@media only screen and (max-width:1439px){:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:24px;--sinch-comp-grid-num-columns:12}}@media only screen and (max-width:1023px){:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:24px;--sinch-comp-grid-num-columns:8}}@media only screen and (max-width:767px){:host{--sinch-comp-grid-gutter:16px;--sinch-comp-grid-margin:16px;--sinch-comp-grid-num-columns:4}}</style><slot name="item"></slot>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-grid', class extends NectaryElement {
|
package/help-tooltip/index.d.ts
CHANGED
package/help-tooltip/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import '../tooltip';
|
|
2
|
-
import '../
|
|
3
|
-
|
|
4
|
-
const templateHTML = '<style>:host{display:contents}#icon{--sinch-size-icon:18px;--sinch-icon-font-variation-settings:var(--sinch-help-tooltip-icon-font-variation-settings)}</style><sinch-tooltip type="fast"><sinch-icon id="icon"></sinch-icon></sinch-tooltip>';
|
|
2
|
+
import { defineCustomElement, getAttribute, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateIntegerAttribute } from '../utils';
|
|
3
|
+
const templateHTML = '<style>:host{display:contents;--sinch-comp-help-tooltip-color-icon:var(--sinch-sys-color-text-default)}#icon{height:18px;fill:var(--sinch-comp-help-tooltip-color-icon)}</style><sinch-tooltip type="fast"><svg id="icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm-1-4h2v2h-2v-2Zm1.61-9.96c-2.06-.3-3.88.97-4.43 2.79-.18.58.26 1.17.87 1.17h.2c.41 0 .74-.29.88-.67.32-.89 1.27-1.5 2.3-1.28.95.2 1.65 1.13 1.57 2.1-.1 1.34-1.62 1.63-2.45 2.88 0 .01-.01.01-.01.02-.01.02-.02.03-.03.05-.09.15-.18.32-.25.5-.01.03-.03.05-.04.08-.01.02-.01.04-.02.07-.12.34-.2.75-.2 1.25h2c0-.42.11-.77.28-1.07.02-.03.03-.06.05-.09.08-.14.18-.27.28-.39.01-.01.02-.03.03-.04.1-.12.21-.23.33-.34.96-.91 2.26-1.65 1.99-3.56-.24-1.74-1.61-3.21-3.35-3.47Z"/></svg></sinch-tooltip>';
|
|
5
4
|
const template = document.createElement('template');
|
|
6
5
|
template.innerHTML = templateHTML;
|
|
7
6
|
defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
8
|
-
#$icon;
|
|
9
7
|
#$tooltip;
|
|
10
8
|
#controller = null;
|
|
11
9
|
constructor() {
|
|
@@ -13,7 +11,6 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
13
11
|
const shadowRoot = this.attachShadow();
|
|
14
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
15
13
|
this.#$tooltip = shadowRoot.querySelector('sinch-tooltip');
|
|
16
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
17
14
|
}
|
|
18
15
|
connectedCallback() {
|
|
19
16
|
super.connectedCallback();
|
|
@@ -25,14 +22,13 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
25
22
|
this.#$tooltip.addEventListener('-hide', this.#onTooltipHide, options);
|
|
26
23
|
this.addEventListener('-show', this.#onTooltipShowReactHandler, options);
|
|
27
24
|
this.addEventListener('-hide', this.#onTooltipHideReactHandler, options);
|
|
28
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, '--sinch-help-tooltip-icon-help'));
|
|
29
25
|
}
|
|
30
26
|
disconnectedCallback() {
|
|
31
27
|
super.disconnectedCallback();
|
|
32
28
|
this.#controller.abort();
|
|
33
29
|
}
|
|
34
30
|
static get observedAttributes() {
|
|
35
|
-
return ['text', 'width', 'orientation'
|
|
31
|
+
return ['text', 'width', 'orientation'];
|
|
36
32
|
}
|
|
37
33
|
attributeChangedCallback(name, _, newVal) {
|
|
38
34
|
updateAttribute(this.#$tooltip, name, newVal);
|
|
@@ -49,12 +45,6 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
49
45
|
set width(value) {
|
|
50
46
|
updateIntegerAttribute(this, 'width', value);
|
|
51
47
|
}
|
|
52
|
-
get inverted() {
|
|
53
|
-
return getBooleanAttribute(this, 'inverted');
|
|
54
|
-
}
|
|
55
|
-
set inverted(isInverted) {
|
|
56
|
-
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
57
|
-
}
|
|
58
48
|
get orientation() {
|
|
59
49
|
return getAttribute(this, 'orientation', 'top');
|
|
60
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;gap:28px;width:fit-content}#progress{position:absolute;height:1px;background-color:var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-comp-horizontal-stepper-color-background-default:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-horizontal-stepper-color-background-visited-skip:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-horizontal-stepper-color-background-active:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-background-visited:var(--sinch-ref-color-main-snow-700);--sinch-comp-horizontal-stepper-color-background-visited-error:var(--sinch-sys-color-feedback-invalid-background);--sinch-comp-horizontal-stepper-color-border-default:transparent;--sinch-comp-horizontal-stepper-color-border-visited-skip:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-border-active:transparent;--sinch-comp-horizontal-stepper-color-border-visited:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-border-visited-error:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-icon-default:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-visited-skip:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-active:var(--sinch-ref-color-main-snow-100);--sinch-comp-horizontal-stepper-color-icon-visited:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-visited-error:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-label:var(--sinch-sys-color-text-default);--sinch-comp-horizontal-stepper-color-description:var(--sinch-sys-color-text-muted);--sinch-comp-horizontal-stepper-color-progress:var(--sinch-ref-color-main-snow-700);--sinch-comp-horizontal-stepper-color-progress-visited:var(--sinch-ref-color-main-stormy-400)}#wrapper{position:relative;display:flex;flex-direction:row;gap:28px;width:fit-content}#progress{position:absolute;height:1px;background-color:var(--sinch-comp-horizontal-stepper-color-progress);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-comp-horizontal-stepper-color-progress-visited);left:0;top:0}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-horizontal-stepper', class extends NectaryElement {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import '../icon';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import '../title';
|
|
3
|
+
import '../text';
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-local-color-background);font:var(--sinch-sys-font-desktop-title-s);line-height:32px;text-align:center;color:var(--sinch-local-color-text);border:1px solid var(--sinch-local-color-border);border-radius:50%;box-sizing:border-box;--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-default);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-default);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-default);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-default);--sinch-global-size-icon:20px}:host([data-progress=active]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-active);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-active);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-active);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-active)}:host([data-progress=done]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited)}:host([data-progress=done][status=error]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited-error);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited-error);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited-error);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited-error)}:host([data-progress=done][status=skip]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited-skip);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited-skip);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited-skip);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited-skip)}#icon-error,#icon-success{display:none}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}#label{text-align:center;margin-top:8px;--sinch-global-color-text:var(--sinch-comp-horizontal-stepper-color-label)}#description{text-align:center;--sinch-global-color-text:var(--sinch-comp-horizontal-stepper-color-description)}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon id="icon-success" name="check"></sinch-icon><sinch-icon id="icon-error" name="exclamation"></sinch-icon><span id="circle-text"></span></div><sinch-title id="label" type="s" ellipsis></sinch-title><sinch-text id="description" type="xs" ellipsis></sinch-text></div>';
|
|
4
6
|
import { statusValues } from './utils';
|
|
5
7
|
const template = document.createElement('template');
|
|
6
8
|
template.innerHTML = templateHTML;
|
|
@@ -8,8 +10,6 @@ defineCustomElement('sinch-horizontal-stepper-item', class extends NectaryElemen
|
|
|
8
10
|
#$label;
|
|
9
11
|
#$description;
|
|
10
12
|
#$circleText;
|
|
11
|
-
#$iconSuccess;
|
|
12
|
-
#$iconError;
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
const shadowRoot = this.attachShadow();
|
|
@@ -17,22 +17,18 @@ defineCustomElement('sinch-horizontal-stepper-item', class extends NectaryElemen
|
|
|
17
17
|
this.#$label = shadowRoot.querySelector('#label');
|
|
18
18
|
this.#$description = shadowRoot.querySelector('#description');
|
|
19
19
|
this.#$circleText = shadowRoot.querySelector('#circle-text');
|
|
20
|
-
this.#$iconSuccess = shadowRoot.querySelector('#icon-success');
|
|
21
|
-
this.#$iconError = shadowRoot.querySelector('#icon-error');
|
|
22
|
-
}
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
const [successName, errorName] = getCssVars(this, ['--sinch-horizontal-stepper-icon-success', '--sinch-horizontal-stepper-icon-error']);
|
|
25
|
-
updateAttribute(this.#$iconSuccess, 'name', successName);
|
|
26
|
-
updateAttribute(this.#$iconError, 'name', errorName);
|
|
27
20
|
}
|
|
28
21
|
static get observedAttributes() {
|
|
29
22
|
return ['label', 'description', 'data-index'];
|
|
30
23
|
}
|
|
31
24
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
25
|
+
if (oldVal === newVal) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
32
28
|
switch (name) {
|
|
33
29
|
case 'label':
|
|
34
30
|
{
|
|
35
|
-
this.#$label
|
|
31
|
+
updateAttribute(this.#$label, 'text', newVal);
|
|
36
32
|
break;
|
|
37
33
|
}
|
|
38
34
|
case 'description':
|
package/icon/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block}#icon{display:block;font-family:var(--sinch-icon-font-family);font-weight:var(--sinch-icon-font-weight);font-size:var(--sinch-size-icon, 24px);font-feature-settings:var(--sinch-icon-font-feature-settings)
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block}#icon{display:block;font-family:var(--sinch-comp-icon-font-family);font-weight:var(--sinch-comp-icon-font-weight);font-size:var(--sinch-global-size-icon, 24px);font-feature-settings:var(--sinch-comp-icon-font-feature-settings);-webkit-font-smoothing:antialiased;line-height:1;white-space:nowrap;width:var(--sinch-global-size-icon,24px);height:var(--sinch-global-size-icon,24px);color:var(--sinch-global-color-icon,var(--sinch-sys-color-text-default));user-select:none}</style><span id="icon" role="img"></span>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-icon', class extends NectaryElement {
|
package/icon-button/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../tooltip';
|
|
2
2
|
import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, subscribeContext, updateAttribute, updateBooleanAttribute, updateLiteralAttribute, Context, getAttribute } from '../utils';
|
|
3
|
-
import {
|
|
4
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0
|
|
5
|
-
import {
|
|
3
|
+
import { DEFAULT_SIZE, sizeExValues } from '../utils/size';
|
|
4
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{display:block;position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer;contain:size;--sinch-global-color-icon:var(--sinch-local-color-icon)}:host([disabled]) #button{cursor:initial}:host([data-size="l"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-l)}#button,:host([data-size="m"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-m)}:host([data-size="s"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-s)}:host([data-size=xs]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-xs);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-xs);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-xs)}:host([type=primary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-primary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-primary-default-outline-focus)}:host([type=secondary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-secondary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-secondary-default-outline-focus)}#button,:host([type=tertiary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-tertiary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-tertiary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-tertiary-default-outline-focus)}:host([type=primary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-primary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-disabled)}:host([type=secondary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-secondary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-disabled)}:host([disabled]) #button,:host([type=tertiary][disabled]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-tertiary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-tertiary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-disabled)}:host([type=primary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-focus)}:host([type=secondary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-focus)}:host(:focus),:host([type=tertiary]:focus) #button{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-focus)}:host([type=primary]:not([disabled]):hover) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-hover)}:host([type=secondary]:not([disabled]):hover) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-hover)}:host(:not([disabled]):hover) #button,:host([type=tertiary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-hover)}:host([type=primary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-active)}:host([type=secondary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-active)}:host(:not([disabled]):active) #button,:host([type=tertiary]:not([disabled]):active) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-active)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}:host(:focus-visible) #button::after{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-local-color-outline);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:100%}</style><sinch-tooltip id="tooltip"><div id="button"><div id="content" inert><slot name="icon"></slot></div></div></sinch-tooltip>';
|
|
5
|
+
import { typeValues } from './utils';
|
|
6
6
|
const template = document.createElement('template');
|
|
7
7
|
template.innerHTML = templateHTML;
|
|
8
8
|
defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
@@ -13,7 +13,7 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
const shadowRoot = this.attachShadow({
|
|
16
|
-
delegatesFocus:
|
|
16
|
+
delegatesFocus: false
|
|
17
17
|
});
|
|
18
18
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
19
19
|
this.#$button = shadowRoot.querySelector('#button');
|
|
@@ -26,10 +26,12 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
26
26
|
const options = {
|
|
27
27
|
signal: this.#controller.signal
|
|
28
28
|
};
|
|
29
|
-
this.
|
|
30
|
-
this
|
|
31
|
-
this
|
|
32
|
-
this
|
|
29
|
+
this.role = 'button';
|
|
30
|
+
this.tabIndex = 0;
|
|
31
|
+
this.addEventListener('click', this.#onButtonClick, options);
|
|
32
|
+
this.addEventListener('focus', this.#onButtonFocus, options);
|
|
33
|
+
this.addEventListener('blur', this.#onButtonBlur, options);
|
|
34
|
+
this.addEventListener('keydown', this.#onButtonKeydown, options);
|
|
33
35
|
this.addEventListener('-click', this.#onClickReactHandler, options);
|
|
34
36
|
this.addEventListener('-focus', this.#onFocusReactHandler, options);
|
|
35
37
|
this.addEventListener('-blur', this.#onBlurReactHandler, options);
|
|
@@ -46,7 +48,7 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
46
48
|
this.#controller.abort();
|
|
47
49
|
}
|
|
48
50
|
static get observedAttributes() {
|
|
49
|
-
return ['
|
|
51
|
+
return ['size', 'disabled', 'aria-label', 'data-size'];
|
|
50
52
|
}
|
|
51
53
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
52
54
|
if (oldVal === newVal) {
|
|
@@ -56,7 +58,6 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
56
58
|
case 'disabled':
|
|
57
59
|
{
|
|
58
60
|
const isDisabled = isAttrTrue(newVal);
|
|
59
|
-
this.#$button.disabled = isDisabled;
|
|
60
61
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
61
62
|
break;
|
|
62
63
|
}
|
|
@@ -65,13 +66,6 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
65
66
|
updateAttribute(this.#$tooltip, 'text', newVal);
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
68
|
-
case 'type':
|
|
69
|
-
{
|
|
70
|
-
if ('production' !== 'production') {
|
|
71
|
-
assertType(newVal);
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
69
|
case 'size':
|
|
76
70
|
{
|
|
77
71
|
updateAttribute(this, 'data-size', newVal);
|
|
@@ -79,9 +73,6 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
79
73
|
}
|
|
80
74
|
case 'data-size':
|
|
81
75
|
{
|
|
82
|
-
if ('production' !== 'production') {
|
|
83
|
-
assertSizeEx(newVal, 'sinch-icon-button');
|
|
84
|
-
}
|
|
85
76
|
this.#onSizeUpdate();
|
|
86
77
|
break;
|
|
87
78
|
}
|
|
@@ -111,12 +102,6 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
111
102
|
get focusable() {
|
|
112
103
|
return true;
|
|
113
104
|
}
|
|
114
|
-
focus() {
|
|
115
|
-
this.#$button.focus();
|
|
116
|
-
}
|
|
117
|
-
blur() {
|
|
118
|
-
this.#$button.blur();
|
|
119
|
-
}
|
|
120
105
|
#onSizeUpdate() {
|
|
121
106
|
if (!this.isConnected) {
|
|
122
107
|
return;
|
|
@@ -146,7 +131,9 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
146
131
|
}
|
|
147
132
|
};
|
|
148
133
|
#onButtonClick = () => {
|
|
149
|
-
this.
|
|
134
|
+
if (!this.disabled) {
|
|
135
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
136
|
+
}
|
|
150
137
|
};
|
|
151
138
|
#onButtonFocus = () => {
|
|
152
139
|
this.dispatchEvent(new CustomEvent('-focus'));
|
|
@@ -154,6 +141,15 @@ defineCustomElement('sinch-icon-button', class extends NectaryElement {
|
|
|
154
141
|
#onButtonBlur = () => {
|
|
155
142
|
this.dispatchEvent(new CustomEvent('-blur'));
|
|
156
143
|
};
|
|
144
|
+
#onButtonKeydown = e => {
|
|
145
|
+
switch (e.code) {
|
|
146
|
+
case 'Space':
|
|
147
|
+
case 'Enter':
|
|
148
|
+
{
|
|
149
|
+
this.click();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
157
153
|
#onTooltipShow = () => {
|
|
158
154
|
this.dispatchEvent(new CustomEvent('-tooltip-show'));
|
|
159
155
|
};
|
package/icon-button/utils.d.ts
CHANGED
package/icon-button/utils.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export const typeValues = ['primary', 'secondary', 'tertiary'];
|
|
2
|
-
export const assertType = value => {
|
|
3
|
-
if (value === null || value.length === 0) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
if (!typeValues.includes(value)) {
|
|
7
|
-
throw new Error(`sinch-icon-button: invalid type attribute: ${value}`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
1
|
+
export const typeValues = ['primary', 'secondary', 'tertiary'];
|
package/inline-alert/index.js
CHANGED
|
@@ -2,13 +2,12 @@ import '../icon';
|
|
|
2
2
|
import '../rich-text';
|
|
3
3
|
import '../text';
|
|
4
4
|
import '../title';
|
|
5
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass
|
|
6
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-shape-radius
|
|
7
|
-
import {
|
|
5
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass } from '../utils';
|
|
6
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-comp-inline-alert-shape-radius);box-sizing:border-box;width:100%}:host([type=success]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-success-default-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-info-default-background)}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}#icon-success{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-success-default-icon)}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=success]) #icon-success,:host([type=warn]) #icon-warn{display:block}#body-wrapper{display:flex;flex-direction:column;align-items:flex-start;margin-left:8px;min-width:0;flex:1}#caption{align-self:stretch;--sinch-comp-title-font:var(--sinch-comp-inline-alert-font-title)}:host([type=success]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-success-default-text)}:host([type=warn]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-warning-default-text)}:host([type=error]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-error-default-text)}:host([type=info]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-info-default-text)}#text{display:flex;flex-direction:column;gap:8px;margin-top:4px;align-self:stretch;--sinch-comp-rich-text-font:var(--sinch-comp-inline-alert-font-body)}:host([type=success]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-success-default-text)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-info-default-text)}#action{display:flex;margin-top:16px;min-width:0}#action.empty{display:none}#close{margin-left:16px}#close.empty{display:none}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-success" name="check_circle"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><div id="body-wrapper"><sinch-title id="caption" level="3" type="s" ellipsis></sinch-title><sinch-rich-text id="text"></sinch-rich-text><div id="action"><slot name="action"></slot></div></div><div id="close"><slot name="close"></slot></div></div>';
|
|
7
|
+
import { typeValues } from './utils';
|
|
8
8
|
const template = document.createElement('template');
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
10
10
|
defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
11
|
-
#$icon;
|
|
12
11
|
#$text;
|
|
13
12
|
#$caption;
|
|
14
13
|
#$closeWrapper;
|
|
@@ -19,7 +18,6 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
19
18
|
super();
|
|
20
19
|
const shadowRoot = this.attachShadow();
|
|
21
20
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
22
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
23
21
|
this.#$text = shadowRoot.querySelector('#text');
|
|
24
22
|
this.#$caption = shadowRoot.querySelector('#caption');
|
|
25
23
|
this.#$closeWrapper = shadowRoot.querySelector('#close');
|
|
@@ -35,13 +33,29 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
35
33
|
this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
|
|
36
34
|
this.#onCloseSlotChange();
|
|
37
35
|
this.#onActionSlotChange();
|
|
38
|
-
this.#updateIcon();
|
|
39
36
|
}
|
|
40
37
|
disconnectedCallback() {
|
|
41
38
|
super.disconnectedCallback();
|
|
42
39
|
this.#$closeSlot.removeEventListener('slotchange', this.#onCloseSlotChange);
|
|
43
40
|
this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
|
|
44
41
|
}
|
|
42
|
+
static get observedAttributes() {
|
|
43
|
+
return ['text', 'caption'];
|
|
44
|
+
}
|
|
45
|
+
attributeChangedCallback(name, _, newVal) {
|
|
46
|
+
switch (name) {
|
|
47
|
+
case 'text':
|
|
48
|
+
{
|
|
49
|
+
updateAttribute(this.#$text, 'text', newVal);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'caption':
|
|
53
|
+
{
|
|
54
|
+
updateAttribute(this.#$caption, 'text', newVal);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
45
59
|
get type() {
|
|
46
60
|
return getLiteralAttribute(this, typeValues, 'type');
|
|
47
61
|
}
|
|
@@ -60,37 +74,6 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
60
74
|
set caption(value) {
|
|
61
75
|
updateAttribute(this, 'caption', value);
|
|
62
76
|
}
|
|
63
|
-
static get observedAttributes() {
|
|
64
|
-
return ['text', 'caption', 'type'];
|
|
65
|
-
}
|
|
66
|
-
attributeChangedCallback(name, _, newVal) {
|
|
67
|
-
switch (name) {
|
|
68
|
-
case 'type':
|
|
69
|
-
{
|
|
70
|
-
if ('production' !== 'production') {
|
|
71
|
-
assertType(newVal);
|
|
72
|
-
}
|
|
73
|
-
this.#updateIcon();
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'text':
|
|
77
|
-
{
|
|
78
|
-
updateAttribute(this.#$text, 'text', newVal);
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
case 'caption':
|
|
82
|
-
{
|
|
83
|
-
updateAttribute(this.#$caption, 'text', newVal);
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
#updateIcon() {
|
|
89
|
-
if (!this.isConnected) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-inline-alert-icon-${this.type}`));
|
|
93
|
-
}
|
|
94
77
|
#onCloseSlotChange = () => {
|
|
95
78
|
setClass(this.#$closeWrapper, 'empty', this.#$closeSlot.assignedElements().length === 0);
|
|
96
79
|
};
|
package/inline-alert/utils.d.ts
CHANGED
package/inline-alert/utils.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export const typeValues = ['info', 'success', 'warn', 'error'];
|
|
2
|
-
export const assertType = value => {
|
|
3
|
-
if (value === null || !typeValues.includes(value)) {
|
|
4
|
-
throw new Error(`sinch-inline-alert: invalid type attribute: ${value}`);
|
|
5
|
-
}
|
|
6
|
-
};
|
|
1
|
+
export const typeValues = ['info', 'success', 'warn', 'error'];
|