@nectary/components 2.0.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/action-menu/index.js +5 -1
- package/alert/index.js +2 -9
- package/alert/utils.d.ts +0 -3
- package/alert/utils.js +1 -6
- package/avatar/index.js +4 -20
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +0 -13
- package/badge/index.js +2 -8
- package/badge/utils.d.ts +0 -3
- package/badge/utils.js +1 -6
- package/button/index.js +25 -27
- package/button/utils.d.ts +0 -3
- package/button/utils.js +1 -9
- package/chat-bubble/index.d.ts +0 -1
- package/chat-bubble/index.js +1 -2
- package/checkbox/index.js +2 -4
- package/chip/index.js +22 -19
- package/chip/utils.d.ts +0 -1
- package/chip/utils.js +0 -5
- package/color-menu/index.js +6 -3
- package/color-swatch/index.js +1 -4
- package/color-swatch/utils.d.ts +0 -1
- package/color-swatch/utils.js +0 -5
- package/date-picker/index.js +1 -19
- package/date-picker/utils.d.ts +0 -8
- package/date-picker/utils.js +0 -20
- package/dialog/index.js +1 -2
- package/emoji-picker/index.js +7 -14
- package/file-status/index.js +2 -9
- package/file-status/utils.d.ts +0 -3
- package/file-status/utils.js +1 -6
- package/help-tooltip/index.d.ts +0 -1
- package/help-tooltip/index.js +1 -2
- 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 +2 -9
- package/inline-alert/utils.d.ts +0 -3
- package/inline-alert/utils.js +1 -6
- package/input/index.js +10 -12
- package/input/utils.d.ts +0 -3
- package/input/utils.js +1 -6
- package/package.json +2 -3
- package/pop/index.js +23 -25
- package/pop/utils.d.ts +0 -3
- package/pop/utils.js +0 -5
- package/popover/index.js +1 -4
- package/popover/utils.d.ts +0 -3
- package/popover/utils.js +0 -5
- package/rich-text/index.js +2 -9
- package/rich-text/utils.d.ts +0 -3
- package/rich-text/utils.js +1 -6
- package/segment/index.js +1 -4
- package/select-button/index.js +23 -20
- package/select-menu/index.js +6 -3
- package/spinner/index.js +2 -9
- package/tag/index.js +1 -4
- package/tag/utils.d.ts +0 -1
- package/tag/utils.js +0 -5
- package/text/index.js +2 -9
- package/text/utils.d.ts +0 -3
- package/text/utils.js +1 -6
- package/time-picker/index.js +0 -3
- package/time-picker/utils.d.ts +1 -1
- package/time-picker/utils.js +17 -5
- package/title/index.js +2 -12
- package/title/utils.d.ts +0 -7
- package/title/utils.js +1 -29
- package/toast/index.js +2 -9
- package/toast/utils.d.ts +0 -3
- package/toast/utils.js +1 -6
- package/tooltip/index.js +1 -7
- 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/title/utils.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
export const typeValues = ['xl', 'l', 'm', 's', 'xs'];
|
|
2
|
-
export const levelValues = ['1', '2', '3', '4', '5', '6'];
|
|
3
|
-
export const assertLevel = value => {
|
|
4
|
-
if (value === null || !levelValues.includes(value)) {
|
|
5
|
-
throw new Error(`sinch-title: invalid level attribute: ${value}`);
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
export const assertType = value => {
|
|
9
|
-
if (value === null || !typeValues.includes(value)) {
|
|
10
|
-
throw new Error(`sinch-title: invalid type attribute: ${value}`);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
2
|
export const getTitleLevelFromType = type => {
|
|
14
3
|
switch (type) {
|
|
15
4
|
case 'xl':
|
|
@@ -23,23 +12,6 @@ export const getTitleLevelFromType = type => {
|
|
|
23
12
|
case 'xs':
|
|
24
13
|
return '5';
|
|
25
14
|
default:
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export const getTitleTypeFromLevel = level => {
|
|
30
|
-
switch (level) {
|
|
31
|
-
case '1':
|
|
32
|
-
return 'xl';
|
|
33
|
-
case '2':
|
|
34
|
-
return 'l';
|
|
35
|
-
case '3':
|
|
36
|
-
return 'm';
|
|
37
|
-
case '4':
|
|
38
|
-
return 's';
|
|
39
|
-
case '5':
|
|
40
|
-
case '6':
|
|
41
|
-
return 'xs';
|
|
42
|
-
default:
|
|
43
|
-
throw new Error(`sinch-title: invalid level value: ${level}`);
|
|
15
|
+
return '';
|
|
44
16
|
}
|
|
45
17
|
};
|
package/toast/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import '../title';
|
|
|
3
3
|
import '../text';
|
|
4
4
|
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
|
|
5
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
|
-
import {
|
|
6
|
+
import { typeValues } from './utils';
|
|
7
7
|
const TIMEOUT = 5000;
|
|
8
8
|
const template = document.createElement('template');
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
@@ -29,20 +29,13 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
|
|
|
29
29
|
this.#clearTimeout();
|
|
30
30
|
}
|
|
31
31
|
static get observedAttributes() {
|
|
32
|
-
return ['text', '
|
|
32
|
+
return ['text', 'persistent'];
|
|
33
33
|
}
|
|
34
34
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
35
35
|
if (oldVal === newVal) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
switch (name) {
|
|
39
|
-
case 'type':
|
|
40
|
-
{
|
|
41
|
-
if ('production' !== 'production') {
|
|
42
|
-
assertType(newVal);
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
39
|
case 'text':
|
|
47
40
|
{
|
|
48
41
|
this.#$text.textContent = newVal;
|
package/toast/utils.d.ts
CHANGED
package/toast/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-toast: invalid type attribute: ${value}`);
|
|
5
|
-
}
|
|
6
|
-
};
|
|
1
|
+
export const typeValues = ['info', 'success', 'warn', 'error'];
|
package/tooltip/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import '../pop';
|
|
|
3
3
|
import { defineCustomElement, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, rectOverlap, getReactEventHandler, shouldReduceMotion } from '../utils';
|
|
4
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 {
|
|
6
|
+
import { getPopOrientation, orientationValues, typeValues } from './utils';
|
|
7
7
|
const TIP_SIZE = 8;
|
|
8
8
|
const SHOW_DELAY_SLOW = 1000;
|
|
9
9
|
const SHOW_DELAY_FAST = 250;
|
|
@@ -73,9 +73,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
73
73
|
}
|
|
74
74
|
case 'orientation':
|
|
75
75
|
{
|
|
76
|
-
if ('production' !== 'production') {
|
|
77
|
-
assertOrientation(newVal);
|
|
78
|
-
}
|
|
79
76
|
updateAttribute(this.#$pop, 'orientation', getPopOrientation(this.orientation));
|
|
80
77
|
if (this.#isOpen()) {
|
|
81
78
|
this.#resetTipOrientation();
|
|
@@ -85,9 +82,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
85
82
|
}
|
|
86
83
|
case 'type':
|
|
87
84
|
{
|
|
88
|
-
if ('production' !== 'production') {
|
|
89
|
-
assertType(newVal);
|
|
90
|
-
}
|
|
91
85
|
this.#tooltipState.updateOptions({
|
|
92
86
|
showDelay: newVal === 'fast' ? SHOW_DELAY_FAST : SHOW_DELAY_SLOW
|
|
93
87
|
});
|
package/tooltip/utils.d.ts
CHANGED
|
@@ -3,8 +3,3 @@ import type { TSinchPopOrientation } from '../pop/types';
|
|
|
3
3
|
export declare const typeValues: readonly TSinchTooltipType[];
|
|
4
4
|
export declare const orientationValues: readonly TSinchTooltipOrientation[];
|
|
5
5
|
export declare const getPopOrientation: (orientation: TSinchTooltipOrientation) => TSinchPopOrientation;
|
|
6
|
-
type TAssertOrientation = (value: string | null) => asserts value is TSinchTooltipOrientation;
|
|
7
|
-
export declare const assertOrientation: TAssertOrientation;
|
|
8
|
-
type TAssertType = (value: string | null) => asserts value is TSinchTooltipType;
|
|
9
|
-
export declare const assertType: TAssertType;
|
|
10
|
-
export {};
|
package/tooltip/utils.js
CHANGED
|
@@ -14,14 +14,4 @@ export const getPopOrientation = orientation => {
|
|
|
14
14
|
return 'center-right';
|
|
15
15
|
}
|
|
16
16
|
return orientation;
|
|
17
|
-
};
|
|
18
|
-
export const assertOrientation = value => {
|
|
19
|
-
if (value !== null && !orientationValues.includes(value)) {
|
|
20
|
-
throw new Error(`sinch-tooltip: invalid orientation attribute: ${value}`);
|
|
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
|
-
}
|
|
27
17
|
};
|
package/utils/dom.js
CHANGED
|
@@ -43,11 +43,6 @@ export function getLiteralAttribute($element, literals, attrName, defaultValue)
|
|
|
43
43
|
if (isLiteralValue(literals, attrValue)) {
|
|
44
44
|
return attrValue;
|
|
45
45
|
}
|
|
46
|
-
if (typeof defaultValue === 'undefined') {
|
|
47
|
-
if ('production' !== 'production') {
|
|
48
|
-
throw new Error(`Invalid attribute value: ${attrName} = ${attrValue}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
46
|
return defaultValue;
|
|
52
47
|
}
|
|
53
48
|
export const clampNumber = (value, min, max) => {
|
package/utils/element.js
CHANGED
|
@@ -25,8 +25,8 @@ export const setNectaryRegistry = registry => {
|
|
|
25
25
|
export class NectaryElement extends HTMLElement {
|
|
26
26
|
attachShadow(options) {
|
|
27
27
|
return super.attachShadow({
|
|
28
|
-
mode: '
|
|
29
|
-
delegatesFocus:
|
|
28
|
+
mode: 'open',
|
|
29
|
+
delegatesFocus: true,
|
|
30
30
|
customElements: nectaryRegistry,
|
|
31
31
|
...options
|
|
32
32
|
});
|
package/utils/size.d.ts
CHANGED
|
@@ -3,8 +3,3 @@ export type TSinchSizeEx = TSinchSize | 'xs';
|
|
|
3
3
|
export declare const DEFAULT_SIZE: TSinchSize;
|
|
4
4
|
export declare const sizeValues: readonly TSinchSize[];
|
|
5
5
|
export declare const sizeExValues: readonly TSinchSizeEx[];
|
|
6
|
-
type TAssertSize = (value: string | null, name: string) => asserts value is TSinchSize;
|
|
7
|
-
export declare const assertSize: TAssertSize;
|
|
8
|
-
type TAssertSizeEx = (value: string | null, name: string) => asserts value is TSinchSizeEx;
|
|
9
|
-
export declare const assertSizeEx: TAssertSizeEx;
|
|
10
|
-
export {};
|
package/utils/size.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_SIZE = 'm';
|
|
2
2
|
export const sizeValues = ['l', 'm', 's'];
|
|
3
|
-
export const sizeExValues = [...sizeValues, 'xs'];
|
|
4
|
-
export const assertSize = (value, name) => {
|
|
5
|
-
if (value === null || value.length === 0) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (!sizeValues.includes(value)) {
|
|
9
|
-
throw new Error(`Invalid size attribute for ${name}: ${value}`);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export const assertSizeEx = (value, name) => {
|
|
13
|
-
if (value === null || value.length === 0) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (!sizeExValues.includes(value)) {
|
|
17
|
-
throw new Error(`Invalid size attribute for ${name}: ${value}`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
3
|
+
export const sizeExValues = [...sizeValues, 'xs'];
|