@nectary/components 1.3.3 → 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 -24
- 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 -10
- 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 +41 -30
- package/tooltip/tooltip-state.d.ts +1 -0
- package/tooltip/tooltip-state.js +6 -0
- package/tooltip/types.d.ts +7 -12
- package/tooltip/utils.d.ts +4 -1
- package/tooltip/utils.js +7 -1
- 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/time-picker/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import '../icon-button';
|
|
|
2
2
|
import '../icon';
|
|
3
3
|
import '../segmented-control';
|
|
4
4
|
import '../segmented-control-option';
|
|
5
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute,
|
|
6
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-
|
|
5
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
6
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-comp-time-picker-header-font);line-height:48px;user-select:none;color:var(--sinch-comp-time-picker-header-color-default-text-initial)}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-comp-time-picker-watch-face-color-default-border-initial);background-color:var(--sinch-comp-time-picker-watch-face-color-default-background-initial)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;text-align:center;top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-12{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h12-initial)}.digit-hour-12.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h12);color:var(--sinch-comp-time-picker-digit-color-checked-h12-default)}.digit-hour-24{font:var(--sinch-comp-time-picker-digit-font-default-h24);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h24-initial)}.digit-hour-24.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h24);color:var(--sinch-comp-time-picker-digit-color-checked-h24-initial)}.digit-minute{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-minute-initial)}.digit-minute.selected{color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-comp-time-picker-needle-color-default-background-initial)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-comp-time-picker-needle-color-default-background-focus)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}#submit-icon{--sinch-global-color-icon:var(--sinch-comp-time-picker-header-color-default-icon-initial)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">:</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon" name="done"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
|
|
7
7
|
import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
|
|
8
8
|
const template = document.createElement('template');
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
@@ -29,7 +29,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
29
29
|
#$headerMinutesText;
|
|
30
30
|
#$ampm;
|
|
31
31
|
#$submitButton;
|
|
32
|
-
#$iconSubmit;
|
|
33
32
|
#hour = 0;
|
|
34
33
|
#minute = 0;
|
|
35
34
|
#controller = null;
|
|
@@ -48,7 +47,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
48
47
|
this.#$headerMinutesText = shadowRoot.querySelector('#header-minutes > span');
|
|
49
48
|
this.#$ampm = shadowRoot.querySelector('#ampm');
|
|
50
49
|
this.#$submitButton = shadowRoot.querySelector('#submit');
|
|
51
|
-
this.#$iconSubmit = shadowRoot.querySelector('#icon-submit');
|
|
52
50
|
this.#$needleMinute.style.height = `${NEEDLE_MINUTE_LENGTH}px`;
|
|
53
51
|
this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
|
|
54
52
|
const MINUTE_DIGIT_RADIUS = MINUTE_RADIUS + MINUTE_DIGIT_SIZE / 2;
|
|
@@ -104,7 +102,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
104
102
|
this.#$needleHour.addEventListener('keydown', this.#onHoursKeydown, options);
|
|
105
103
|
this.#$needleMinute.addEventListener('keydown', this.#onMinutesKeydown, options);
|
|
106
104
|
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
107
|
-
updateAttribute(this.#$iconSubmit, 'name', getCssVar(this, '--sinch-time-picker-icon-submit'));
|
|
108
105
|
}
|
|
109
106
|
disconnectedCallback() {
|
|
110
107
|
this.#controller.abort();
|
|
@@ -145,9 +142,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
|
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
|
-
get nodeName() {
|
|
149
|
-
return 'select';
|
|
150
|
-
}
|
|
151
145
|
set value(value) {
|
|
152
146
|
updateAttribute(this, 'value', value);
|
|
153
147
|
}
|
package/time-picker/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchTimePickerElement = HTMLElement & {
|
|
4
3
|
/** Time value in ISO 8601 format */
|
|
5
4
|
value: string;
|
|
@@ -30,8 +29,6 @@ export type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerElement>
|
|
|
30
29
|
'aria-label': string;
|
|
31
30
|
/** Submit button label that is used for a11y */
|
|
32
31
|
'submit-aria-label': string;
|
|
33
|
-
/** @deprecated Change value handler, return time in ISO 8601 format */
|
|
34
|
-
onChange?: (e: SyntheticEvent<TSinchTimePickerElement, CustomEvent<string>>) => void;
|
|
35
32
|
/** Change value handler, return time in ISO 8601 format */
|
|
36
33
|
'on-change'?: (e: CustomEvent<string>) => void;
|
|
37
34
|
};
|
package/title/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block
|
|
1
|
+
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type=xl]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xl)}:host([type="l"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-l)}:host([type="m"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type="s"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-s)}:host([type=xs]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xs)}#text{letter-spacing:-2%;color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));font:var(--sinch-comp-title-font)}:host([ellipsis]) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
|
|
3
3
|
import { assertLevel, assertType, typeValues } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
@@ -14,28 +14,13 @@ defineCustomElement('sinch-title', class extends NectaryElement {
|
|
|
14
14
|
connectedCallback() {
|
|
15
15
|
this.setAttribute('role', 'heading');
|
|
16
16
|
}
|
|
17
|
-
get text() {
|
|
18
|
-
return getAttribute(this, 'text', '');
|
|
19
|
-
}
|
|
20
|
-
set text(value) {
|
|
21
|
-
updateAttribute(this, 'text', value);
|
|
22
|
-
}
|
|
23
|
-
set type(value) {
|
|
24
|
-
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
25
|
-
}
|
|
26
|
-
get type() {
|
|
27
|
-
return getLiteralAttribute(this, typeValues, 'type');
|
|
28
|
-
}
|
|
29
|
-
set ellipsis(isEllipsis) {
|
|
30
|
-
updateBooleanAttribute(this, 'ellipsis', isEllipsis);
|
|
31
|
-
}
|
|
32
|
-
get ellipsis() {
|
|
33
|
-
return getBooleanAttribute(this, 'ellipsis');
|
|
34
|
-
}
|
|
35
17
|
static get observedAttributes() {
|
|
36
|
-
return ['text', 'type', 'level'];
|
|
18
|
+
return ['text', 'type', 'level', 'ellipsis'];
|
|
37
19
|
}
|
|
38
|
-
attributeChangedCallback(name,
|
|
20
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
21
|
+
if (oldVal === newVal) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
39
24
|
switch (name) {
|
|
40
25
|
case 'text':
|
|
41
26
|
{
|
|
@@ -57,6 +42,29 @@ defineCustomElement('sinch-title', class extends NectaryElement {
|
|
|
57
42
|
}
|
|
58
43
|
break;
|
|
59
44
|
}
|
|
45
|
+
case 'ellipsis':
|
|
46
|
+
{
|
|
47
|
+
updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
60
50
|
}
|
|
61
51
|
}
|
|
52
|
+
get text() {
|
|
53
|
+
return getAttribute(this, 'text', '');
|
|
54
|
+
}
|
|
55
|
+
set text(value) {
|
|
56
|
+
updateAttribute(this, 'text', value);
|
|
57
|
+
}
|
|
58
|
+
set type(value) {
|
|
59
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
60
|
+
}
|
|
61
|
+
get type() {
|
|
62
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
63
|
+
}
|
|
64
|
+
set ellipsis(isEllipsis) {
|
|
65
|
+
updateBooleanAttribute(this, 'ellipsis', isEllipsis);
|
|
66
|
+
}
|
|
67
|
+
get ellipsis() {
|
|
68
|
+
return getBooleanAttribute(this, 'ellipsis');
|
|
69
|
+
}
|
|
62
70
|
});
|
package/toast/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import '../icon';
|
|
2
2
|
import '../title';
|
|
3
3
|
import '../text';
|
|
4
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:center;gap:8px;width:328px;padding:8px 16px;box-sizing:border-box;border-radius:var(--sinch-shape-radius
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:center;gap:8px;width:328px;padding:8px 16px;box-sizing:border-box;border-radius:var(--sinch-comp-toast-shape-radius);box-shadow:var(--sinch-comp-toast-shadow)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-toast-color-success-default-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-toast-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-toast-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-toast-color-info-default-background)}#text{padding:4px 0 4px 4px;flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-toast-font-body)}:host([type=success]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-success-default-text)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-info-default-text)}#icon{align-self:flex-start;margin:4px 0}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}#icon-success{--sinch-global-color-icon:var(--sinch-comp-toast-color-success-default-icon)}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-toast-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-toast-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-toast-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}</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><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
|
|
6
6
|
import { assertType, typeValues } from './utils';
|
|
7
7
|
const TIMEOUT = 5000;
|
|
8
8
|
const template = document.createElement('template');
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
10
10
|
defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
11
|
-
#$icon;
|
|
12
11
|
#$text;
|
|
13
12
|
#tid = null;
|
|
14
13
|
constructor() {
|
|
@@ -16,7 +15,6 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
16
15
|
const shadowRoot = this.attachShadow();
|
|
17
16
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
18
17
|
this.#$text = shadowRoot.querySelector('#text');
|
|
19
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
20
18
|
}
|
|
21
19
|
connectedCallback() {
|
|
22
20
|
super.connectedCallback();
|
|
@@ -24,31 +22,12 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
24
22
|
this.setAttribute('aria-live', 'polite');
|
|
25
23
|
this.addEventListener('-timeout', this.#onTimeoutReactHandler);
|
|
26
24
|
this.#updateTimeout();
|
|
27
|
-
this.#updateIcon();
|
|
28
25
|
}
|
|
29
26
|
disconnectedCallback() {
|
|
30
27
|
super.disconnectedCallback();
|
|
31
28
|
this.removeEventListener('-timeout', this.#onTimeoutReactHandler);
|
|
32
29
|
this.#clearTimeout();
|
|
33
30
|
}
|
|
34
|
-
get type() {
|
|
35
|
-
return getLiteralAttribute(this, typeValues, 'type');
|
|
36
|
-
}
|
|
37
|
-
set type(value) {
|
|
38
|
-
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
39
|
-
}
|
|
40
|
-
get text() {
|
|
41
|
-
return getAttribute(this, 'text', '');
|
|
42
|
-
}
|
|
43
|
-
set text(value) {
|
|
44
|
-
updateAttribute(this, 'text', value);
|
|
45
|
-
}
|
|
46
|
-
get persistent() {
|
|
47
|
-
return getBooleanAttribute(this, 'persistent');
|
|
48
|
-
}
|
|
49
|
-
set persistent(isPersistent) {
|
|
50
|
-
updateBooleanAttribute(this, 'persistent', isPersistent);
|
|
51
|
-
}
|
|
52
31
|
static get observedAttributes() {
|
|
53
32
|
return ['text', 'type', 'persistent'];
|
|
54
33
|
}
|
|
@@ -62,7 +41,6 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
62
41
|
if ('production' !== 'production') {
|
|
63
42
|
assertType(newVal);
|
|
64
43
|
}
|
|
65
|
-
this.#updateIcon();
|
|
66
44
|
break;
|
|
67
45
|
}
|
|
68
46
|
case 'text':
|
|
@@ -77,6 +55,24 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
77
55
|
}
|
|
78
56
|
}
|
|
79
57
|
}
|
|
58
|
+
get type() {
|
|
59
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
60
|
+
}
|
|
61
|
+
set type(value) {
|
|
62
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
63
|
+
}
|
|
64
|
+
get text() {
|
|
65
|
+
return getAttribute(this, 'text', '');
|
|
66
|
+
}
|
|
67
|
+
set text(value) {
|
|
68
|
+
updateAttribute(this, 'text', value);
|
|
69
|
+
}
|
|
70
|
+
get persistent() {
|
|
71
|
+
return getBooleanAttribute(this, 'persistent');
|
|
72
|
+
}
|
|
73
|
+
set persistent(isPersistent) {
|
|
74
|
+
updateBooleanAttribute(this, 'persistent', isPersistent);
|
|
75
|
+
}
|
|
80
76
|
#updateTimeout() {
|
|
81
77
|
if (this.persistent) {
|
|
82
78
|
this.#clearTimeout();
|
|
@@ -86,12 +82,6 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
86
82
|
this.#tid = window.setTimeout(this.#onTimeout, TIMEOUT);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
|
-
#updateIcon() {
|
|
90
|
-
if (!this.isConnected) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-toast-icon-${this.type}`));
|
|
94
|
-
}
|
|
95
85
|
#onTimeout = () => {
|
|
96
86
|
this.dispatchEvent(new CustomEvent('-timeout'));
|
|
97
87
|
};
|
package/toggle/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:var(--sinch-local-size);--sinch-local-size:24px}:host([small]) #wrapper{--sinch-local-size:22px}#input{all:initial;display:block;position:absolute;left:0;top:2px;width:40px;height:20px;cursor:pointer;pointer-events:initial}#input:disabled{cursor:initial}#input:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-comp-toggle-color-default-outline-focus);border-radius:18px;pointer-events:none}:host([small]) #input{width:32px;height:16px;top:3px}#knob-container{position:relative;box-sizing:border-box;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-comp-toggle-color-default-background-initial);overflow:hidden}:host([small]) #knob-container{width:32px;height:16px;border-radius:8px}#input:checked~#knob-container{background-color:var(--sinch-comp-toggle-color-checked-background-initial)}#input:disabled~#knob-container{background-color:var(--sinch-comp-toggle-color-disabled-background-initial)}#input:checked:disabled~#knob-container{background-color:var(--sinch-comp-toggle-color-checked-disabled-background-initial)}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-comp-toggle-color-default-knob-background-initial);box-shadow:var(--sinch-comp-toggle-shadow-knob-default);transform:translateX(0);transition:transform .1s ease-in-out;will-change:transform}:host([small]) #knob{width:12px;height:12px}#input:disabled+#knob-container>#knob{box-shadow:var(--sinch-comp-toggle-shadow-knob-disabled)}#input:checked+#knob-container>#knob{transform:translateX(20px)}:host([small]) #input:checked+#knob-container>#knob{transform:translateX(16px)}#knob::after,#knob::before{font:var(--sinch-comp-toggle-font-size-m-inside-text);color:var(--sinch-comp-toggle-color-default-text-inside-initial);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([small])) #knob::after,:host([labeled]:not([small])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-comp-toggle-font-size-m-label);color:var(--sinch-comp-toggle-color-default-label-initial)}#label:empty{display:none}:host([small]) #label{font:var(--sinch-comp-toggle-font-size-s-label)}#input:disabled~#label{color:var(--sinch-comp-toggle-color-disabled-label-initial)}</style><div id="wrapper"><input id="input" type="checkbox"><div id="knob-container"><div id="knob"></div></div><label id="label" for="input"></label></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
@@ -30,13 +30,39 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
30
30
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
31
31
|
}
|
|
32
32
|
static get observedAttributes() {
|
|
33
|
-
return ['checked', 'disabled', 'text'];
|
|
33
|
+
return ['checked', 'disabled', 'text', 'labeled', 'small'];
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
36
|
+
if (oldVal === newVal) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
switch (name) {
|
|
40
|
+
case 'text':
|
|
41
|
+
{
|
|
42
|
+
this.#$label.textContent = newVal;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'checked':
|
|
46
|
+
{
|
|
47
|
+
const isChecked = isAttrTrue(newVal);
|
|
48
|
+
this.#$input.checked = isChecked;
|
|
49
|
+
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'disabled':
|
|
53
|
+
{
|
|
54
|
+
const isDisabled = isAttrTrue(newVal);
|
|
55
|
+
this.#$input.disabled = isDisabled;
|
|
56
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'small':
|
|
60
|
+
case 'labeled':
|
|
61
|
+
{
|
|
62
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
40
66
|
}
|
|
41
67
|
set checked(isChecked) {
|
|
42
68
|
updateBooleanAttribute(this, 'checked', isChecked);
|
|
@@ -68,29 +94,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
68
94
|
get text() {
|
|
69
95
|
return getAttribute(this, 'text');
|
|
70
96
|
}
|
|
71
|
-
attributeChangedCallback(name, _, newVal) {
|
|
72
|
-
switch (name) {
|
|
73
|
-
case 'text':
|
|
74
|
-
{
|
|
75
|
-
this.#$label.textContent = newVal;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case 'checked':
|
|
79
|
-
{
|
|
80
|
-
const isChecked = isAttrTrue(newVal);
|
|
81
|
-
this.#$input.checked = isChecked;
|
|
82
|
-
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case 'disabled':
|
|
86
|
-
{
|
|
87
|
-
const isDisabled = isAttrTrue(newVal);
|
|
88
|
-
this.#$input.disabled = isDisabled;
|
|
89
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
97
|
get focusable() {
|
|
95
98
|
return true;
|
|
96
99
|
}
|
package/toggle/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchToggleElement = HTMLElement & {
|
|
4
3
|
checked: boolean;
|
|
5
4
|
small: boolean;
|
|
@@ -21,7 +20,5 @@ export type TSinchToggleReact = TSinchElementReact<TSinchToggleElement> & {
|
|
|
21
20
|
disabled?: boolean;
|
|
22
21
|
text?: string;
|
|
23
22
|
'aria-label': string;
|
|
24
|
-
/** @deprecated */
|
|
25
|
-
onChange?: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
|
|
26
23
|
'on-change'?: (e: CustomEvent<boolean>) => void;
|
|
27
24
|
};
|
package/tooltip/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import '../text';
|
|
2
2
|
import '../pop';
|
|
3
|
-
import { defineCustomElement,
|
|
4
|
-
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px
|
|
3
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, rectOverlap, getReactEventHandler, shouldReduceMotion } from '../utils';
|
|
4
|
+
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
5
5
|
import { TooltipState } from './tooltip-state';
|
|
6
|
-
import { assertOrientation, getPopOrientation, orientationValues } from './utils';
|
|
6
|
+
import { assertOrientation, assertType, getPopOrientation, orientationValues, typeValues } from './utils';
|
|
7
7
|
const TIP_SIZE = 8;
|
|
8
|
-
const
|
|
8
|
+
const SHOW_DELAY_SLOW = 1000;
|
|
9
|
+
const SHOW_DELAY_FAST = 250;
|
|
9
10
|
const HIDE_DELAY = 0;
|
|
10
11
|
const ANIMATION_DURATION = 100;
|
|
11
12
|
const template = document.createElement('template');
|
|
@@ -34,7 +35,7 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
34
35
|
this.#$target = shadowRoot.querySelector('#target');
|
|
35
36
|
this.#shouldReduceMotion = shouldReduceMotion();
|
|
36
37
|
this.#tooltipState = new TooltipState({
|
|
37
|
-
showDelay:
|
|
38
|
+
showDelay: SHOW_DELAY_SLOW,
|
|
38
39
|
hideDelay: this.#shouldReduceMotion ? HIDE_DELAY + ANIMATION_DURATION : HIDE_DELAY,
|
|
39
40
|
hideAnimationDuration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION,
|
|
40
41
|
onShowStart: this.#onStateShowStart,
|
|
@@ -61,31 +62,7 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
61
62
|
this.#tooltipState.destroy();
|
|
62
63
|
}
|
|
63
64
|
static get observedAttributes() {
|
|
64
|
-
return ['text', 'orientation'];
|
|
65
|
-
}
|
|
66
|
-
get text() {
|
|
67
|
-
return getAttribute(this, 'text', '');
|
|
68
|
-
}
|
|
69
|
-
set text(value) {
|
|
70
|
-
updateAttribute(this, 'text', value);
|
|
71
|
-
}
|
|
72
|
-
get inverted() {
|
|
73
|
-
return getBooleanAttribute(this, 'inverted');
|
|
74
|
-
}
|
|
75
|
-
set inverted(isInverted) {
|
|
76
|
-
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
77
|
-
}
|
|
78
|
-
get orientation() {
|
|
79
|
-
return getLiteralAttribute(this, orientationValues, 'orientation', 'top');
|
|
80
|
-
}
|
|
81
|
-
set orientation(value) {
|
|
82
|
-
updateLiteralAttribute(this, orientationValues, 'orientation', value);
|
|
83
|
-
}
|
|
84
|
-
get footprintRect() {
|
|
85
|
-
return this.#$pop.footprintRect;
|
|
86
|
-
}
|
|
87
|
-
get tooltipRect() {
|
|
88
|
-
return this.#$pop.popoverRect;
|
|
65
|
+
return ['text', 'orientation', 'type'];
|
|
89
66
|
}
|
|
90
67
|
attributeChangedCallback(name, _, newVal) {
|
|
91
68
|
switch (name) {
|
|
@@ -106,8 +83,42 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
106
83
|
}
|
|
107
84
|
break;
|
|
108
85
|
}
|
|
86
|
+
case 'type':
|
|
87
|
+
{
|
|
88
|
+
if ('production' !== 'production') {
|
|
89
|
+
assertType(newVal);
|
|
90
|
+
}
|
|
91
|
+
this.#tooltipState.updateOptions({
|
|
92
|
+
showDelay: newVal === 'fast' ? SHOW_DELAY_FAST : SHOW_DELAY_SLOW
|
|
93
|
+
});
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
109
96
|
}
|
|
110
97
|
}
|
|
98
|
+
get text() {
|
|
99
|
+
return getAttribute(this, 'text', '');
|
|
100
|
+
}
|
|
101
|
+
set text(value) {
|
|
102
|
+
updateAttribute(this, 'text', value);
|
|
103
|
+
}
|
|
104
|
+
get orientation() {
|
|
105
|
+
return getLiteralAttribute(this, orientationValues, 'orientation', 'top');
|
|
106
|
+
}
|
|
107
|
+
set orientation(value) {
|
|
108
|
+
updateLiteralAttribute(this, orientationValues, 'orientation', value);
|
|
109
|
+
}
|
|
110
|
+
get type() {
|
|
111
|
+
return getLiteralAttribute(this, typeValues, 'type', 'slow');
|
|
112
|
+
}
|
|
113
|
+
set type(value) {
|
|
114
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
115
|
+
}
|
|
116
|
+
get footprintRect() {
|
|
117
|
+
return this.#$pop.footprintRect;
|
|
118
|
+
}
|
|
119
|
+
get tooltipRect() {
|
|
120
|
+
return this.#$pop.popoverRect;
|
|
121
|
+
}
|
|
111
122
|
#onMouseDown = () => {
|
|
112
123
|
this.#tooltipState.destroy();
|
|
113
124
|
};
|
package/tooltip/tooltip-state.js
CHANGED
package/tooltip/types.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { TRect, TSinchElementReact } from '../types';
|
|
2
2
|
export type TSinchTooltipOrientation = 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
3
|
+
export type TSinchTooltipType = 'slow' | 'fast';
|
|
3
4
|
export type TSinchTooltipElement = HTMLElement & {
|
|
4
5
|
/** Text */
|
|
5
6
|
text: string;
|
|
6
|
-
/** @deprecated */
|
|
7
|
-
width: number | null;
|
|
8
|
-
/** Inverted */
|
|
9
|
-
inverted: boolean;
|
|
10
7
|
/** Orientation, where it *points to* from origin */
|
|
11
8
|
orientation: TSinchTooltipOrientation;
|
|
9
|
+
/** Type */
|
|
10
|
+
type: TSinchTooltipType;
|
|
12
11
|
readonly footprintRect: TRect;
|
|
13
12
|
readonly tooltipRect: TRect;
|
|
14
13
|
/** Show event */
|
|
@@ -17,22 +16,18 @@ export type TSinchTooltipElement = HTMLElement & {
|
|
|
17
16
|
addEventListener(type: '-hide', listener: (e: CustomEvent<void>) => void): void;
|
|
18
17
|
/** Text */
|
|
19
18
|
setAttribute(name: 'text', value: string): void;
|
|
20
|
-
/** @deprecated */
|
|
21
|
-
setAttribute(name: 'width', value: string): void;
|
|
22
|
-
/** Inverted */
|
|
23
|
-
setAttribute(name: 'inverted', value: ''): void;
|
|
24
19
|
/** Orientation, where it *points to* from origin */
|
|
25
20
|
setAttribute(name: 'orientation', value: TSinchTooltipOrientation): void;
|
|
21
|
+
/** Type */
|
|
22
|
+
setAttribute(name: 'type', value: TSinchTooltipType): void;
|
|
26
23
|
};
|
|
27
24
|
export type TSinchTooltipReact = TSinchElementReact<TSinchTooltipElement> & {
|
|
28
25
|
/** Text */
|
|
29
26
|
text: string;
|
|
30
|
-
/** @deprecated */
|
|
31
|
-
width?: number;
|
|
32
|
-
/** Inverted */
|
|
33
|
-
inverted?: boolean;
|
|
34
27
|
/** Orientation, where it *points to* from origin */
|
|
35
28
|
orientation?: TSinchTooltipOrientation;
|
|
29
|
+
/** Type */
|
|
30
|
+
type?: TSinchTooltipType;
|
|
36
31
|
/** Show event handler */
|
|
37
32
|
'on-show'?: (e: CustomEvent<void>) => void;
|
|
38
33
|
/** Hide event handler */
|
package/tooltip/utils.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { TSinchTooltipOrientation } from './types';
|
|
1
|
+
import type { TSinchTooltipOrientation, TSinchTooltipType } from './types';
|
|
2
2
|
import type { TSinchPopOrientation } from '../pop/types';
|
|
3
|
+
export declare const typeValues: readonly TSinchTooltipType[];
|
|
3
4
|
export declare const orientationValues: readonly TSinchTooltipOrientation[];
|
|
4
5
|
export declare const getPopOrientation: (orientation: TSinchTooltipOrientation) => TSinchPopOrientation;
|
|
5
6
|
type TAssertOrientation = (value: string | null) => asserts value is TSinchTooltipOrientation;
|
|
6
7
|
export declare const assertOrientation: TAssertOrientation;
|
|
8
|
+
type TAssertType = (value: string | null) => asserts value is TSinchTooltipType;
|
|
9
|
+
export declare const assertType: TAssertType;
|
|
7
10
|
export {};
|
package/tooltip/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const typeValues = ['fast', 'slow'];
|
|
1
2
|
export const orientationValues = ['top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right'];
|
|
2
3
|
export const getPopOrientation = orientation => {
|
|
3
4
|
if (orientation === 'top') {
|
|
@@ -15,7 +16,12 @@ export const getPopOrientation = orientation => {
|
|
|
15
16
|
return orientation;
|
|
16
17
|
};
|
|
17
18
|
export const assertOrientation = value => {
|
|
18
|
-
if (value
|
|
19
|
+
if (value !== null && !orientationValues.includes(value)) {
|
|
19
20
|
throw new Error(`sinch-tooltip: invalid orientation attribute: ${value}`);
|
|
20
21
|
}
|
|
22
|
+
};
|
|
23
|
+
export const assertType = value => {
|
|
24
|
+
if (value !== null && !typeValues.includes(value)) {
|
|
25
|
+
throw new Error(`sinch-tooltip: invalid type attribute: ${value}`);
|
|
26
|
+
}
|
|
21
27
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-comp-vertical-stepper-color-background-default:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-vertical-stepper-color-background-visited-skip:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-vertical-stepper-color-background-active:var(--sinch-ref-color-main-stormy-400);--sinch-comp-vertical-stepper-color-background-visited:var(--sinch-ref-color-main-snow-700);--sinch-comp-vertical-stepper-color-background-visited-error:var(--sinch-sys-color-feedback-invalid-background);--sinch-comp-vertical-stepper-color-border-default:transparent;--sinch-comp-vertical-stepper-color-border-visited-skip:var(--sinch-ref-color-main-stormy-400);--sinch-comp-vertical-stepper-color-border-active:transparent;--sinch-comp-vertical-stepper-color-border-visited:var(--sinch-ref-color-main-stormy-400);--sinch-comp-vertical-stepper-color-border-visited-error:var(--sinch-ref-color-main-stormy-400);--sinch-comp-vertical-stepper-color-icon-default:var(--sinch-ref-color-main-stormy-700);--sinch-comp-vertical-stepper-color-icon-visited-skip:var(--sinch-ref-color-main-stormy-700);--sinch-comp-vertical-stepper-color-icon-active:var(--sinch-ref-color-main-snow-100);--sinch-comp-vertical-stepper-color-icon-visited:var(--sinch-ref-color-main-stormy-700);--sinch-comp-vertical-stepper-color-icon-visited-error:var(--sinch-ref-color-main-stormy-700);--sinch-comp-vertical-stepper-color-label:var(--sinch-sys-color-text-default);--sinch-comp-vertical-stepper-color-description:var(--sinch-sys-color-text-muted);--sinch-comp-vertical-stepper-color-progress:var(--sinch-ref-color-main-snow-700);--sinch-comp-vertical-stepper-color-progress-visited:var(--sinch-ref-color-main-stormy-400)}#wrapper{position:relative;display:flex;flex-direction:column;width:100%}</style><div id="wrapper"><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|