@nectary/components 0.8.1 → 0.10.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 +5 -1
- package/accordion-item/index.js +7 -7
- package/alert/index.js +2 -2
- package/alert-button/index.js +1 -1
- package/alert-close/index.js +2 -2
- package/button/index.d.ts +2 -1
- package/button/index.js +7 -3
- package/checkbox/index.d.ts +3 -0
- package/checkbox/index.js +27 -18
- package/dropdown/index.d.ts +34 -0
- package/dropdown/index.js +451 -0
- package/dropdown-option/index.d.ts +44 -0
- package/dropdown-option/index.js +116 -0
- package/help-tooltip/index.js +5 -1
- package/icon/arrow-back-ios/index.d.ts +11 -0
- package/icon/arrow-back-ios/index.js +4 -0
- package/icon/arrow-forward-ios/index.d.ts +11 -0
- package/icon/arrow-forward-ios/index.js +4 -0
- package/icon/cancel/index.js +1 -1
- package/icon/chevron-left/index.d.ts +11 -0
- package/icon/chevron-left/index.js +4 -0
- package/icon/chevron-right/index.d.ts +11 -0
- package/icon/chevron-right/index.js +4 -0
- package/icon/close/index.js +1 -1
- package/icon/create-icon-class.js +1 -1
- package/icon/east/index.js +1 -1
- package/icon/expand-less/index.d.ts +11 -0
- package/icon/expand-less/index.js +4 -0
- package/icon/expand-more/index.d.ts +11 -0
- package/icon/expand-more/index.js +4 -0
- package/icon/help-outline/index.js +1 -1
- package/icon/keyboard-arrow-down/index.d.ts +11 -0
- package/icon/keyboard-arrow-down/index.js +4 -0
- package/icon/keyboard-arrow-left/index.d.ts +11 -0
- package/icon/keyboard-arrow-left/index.js +4 -0
- package/icon/keyboard-arrow-right/index.d.ts +11 -0
- package/icon/keyboard-arrow-right/index.js +4 -0
- package/icon/keyboard-arrow-up/index.d.ts +11 -0
- package/icon/keyboard-arrow-up/index.js +4 -0
- package/icon/more-horiz/index.js +1 -1
- package/icon/more-vert/index.js +1 -1
- package/icon/north/index.js +1 -1
- package/icon/north-east/index.js +1 -1
- package/icon/north-west/index.js +1 -1
- package/icon/open-in-new/index.js +1 -1
- package/icon/south/index.js +1 -1
- package/icon/south-east/index.js +1 -1
- package/icon/south-west/index.js +1 -1
- package/icon/west/index.js +1 -1
- package/icon-branded/barchart-down/index.js +1 -1
- package/icon-branded/barchart-up/index.js +1 -1
- package/icon-branded/campaigns/index.js +1 -1
- package/icon-branded/chatbot/index.js +1 -1
- package/icon-branded/contact/index.js +1 -1
- package/icon-branded/create-icon-class.js +1 -1
- package/icon-branded/home/index.js +1 -1
- package/icon-branded/multiple-channels/index.js +1 -1
- package/icon-branded/rocket/index.js +1 -1
- package/icon-branded/settings/index.js +1 -1
- package/icon-branded/user/index.js +1 -1
- package/icon-branded/users/index.js +1 -1
- package/index.d.ts +13 -0
- package/index.js +13 -0
- package/input/index.d.ts +3 -1
- package/input/index.js +59 -11
- package/link/index.js +2 -2
- package/logo/create-logo-class.js +1 -1
- package/logo/sinch-icon/index.js +1 -1
- package/logo/sinch-icon-wordmark/index.js +1 -1
- package/package.json +1 -1
- package/pagination/index.d.ts +27 -0
- package/pagination/index.js +219 -0
- package/radio/index.d.ts +1 -0
- package/radio/index.js +97 -71
- package/radio-option/index.d.ts +1 -0
- package/radio-option/index.js +4 -1
- package/select/index.d.ts +4 -1
- package/select/index.js +72 -265
- package/select-option/index.d.ts +3 -17
- package/select-option/index.js +4 -103
- 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/index.js +1 -1
- package/table-head-cell/index.js +3 -2
- package/table-head-sort/index.d.ts +1 -0
- package/table-head-sort/index.js +3 -1
- package/table-row/index.js +1 -1
- package/tabs/index.d.ts +1 -0
- package/tabs/index.js +96 -66
- package/tabs-option/index.d.ts +1 -0
- package/tabs-option/index.js +4 -2
- package/tag/index.js +1 -1
- package/tag-close/index.js +2 -2
- package/textarea/index.d.ts +3 -1
- package/textarea/index.js +58 -11
- package/theme.css +3 -0
- package/toggle/index.d.ts +1 -0
- package/toggle/index.js +4 -5
- package/tooltip/index.d.ts +2 -1
- package/tooltip/index.js +7 -3
- package/types.d.ts +7 -0
- package/utils.d.ts +3 -0
- package/utils.js +17 -0
package/tooltip/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0%;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:100%}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:2px;top:-8px;left:50%;transform:translateX(-50%) translateY(-100%)}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
|
|
1
|
+
import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, getRect } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0%;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:100%}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:2px;top:-8px;left:50%;transform:translateX(-50%) translateY(-100%)}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4" aria-hidden="true"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
|
|
3
3
|
const orientationValues = ['top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right'];
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
@@ -7,7 +7,7 @@ defineCustomElement('sinch-tooltip', class extends HTMLElement {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
9
|
const shadowRoot = this.attachShadow({
|
|
10
|
-
mode: '
|
|
10
|
+
mode: 'closed'
|
|
11
11
|
});
|
|
12
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
13
|
this.$tooltipText = shadowRoot.querySelector('#text');
|
|
@@ -49,6 +49,10 @@ defineCustomElement('sinch-tooltip', class extends HTMLElement {
|
|
|
49
49
|
updateLiteralAttribute(this, orientationValues, 'orientation', value);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
get tooltipRect() {
|
|
53
|
+
return getRect(this.$tooltipText);
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
attributeChangedCallback(name, _, newVal) {
|
|
53
57
|
switch (name) {
|
|
54
58
|
case 'text':
|
package/types.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { ClassAttributes, HTMLAttributes } from 'react'
|
|
2
2
|
|
|
3
3
|
export type TSinchElementReact<TElementProperties> = Pick<HTMLAttributes<HTMLElement>, 'id' | 'className' | 'style' | 'slot' | 'children'> & ClassAttributes<TElementProperties> & { class?: string }
|
|
4
|
+
|
|
5
|
+
export type TRect = {
|
|
6
|
+
x: number,
|
|
7
|
+
y: number,
|
|
8
|
+
width: number,
|
|
9
|
+
height: number,
|
|
10
|
+
}
|
package/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TRect } from './types';
|
|
1
2
|
export declare const defineCustomElement: (name: string, constructor: CustomElementConstructor) => void;
|
|
2
3
|
export declare const defineNectaryElements: (registry: CustomElementRegistry) => void;
|
|
3
4
|
export declare type TEventHandler = (arg?: any) => void;
|
|
@@ -28,4 +29,6 @@ export declare function getIntegerAttribute($element: Element, attrName: string,
|
|
|
28
29
|
export declare const updateCSV: (acc: string, value: string, setActive: boolean) => string;
|
|
29
30
|
export declare const getCSVSet: (acc: string) => Set<string>;
|
|
30
31
|
export declare const getFirstCSValue: (acc: string) => string;
|
|
32
|
+
export declare const getRect: (el: Element) => TRect;
|
|
33
|
+
export declare const setClass: (elem: Element, name: string, isSet: boolean) => void;
|
|
31
34
|
export {};
|
package/utils.js
CHANGED
|
@@ -143,4 +143,21 @@ export const getCSVSet = acc => {
|
|
|
143
143
|
};
|
|
144
144
|
export const getFirstCSValue = acc => {
|
|
145
145
|
return acc.split(',')[0];
|
|
146
|
+
};
|
|
147
|
+
export const getRect = el => {
|
|
148
|
+
const {
|
|
149
|
+
x,
|
|
150
|
+
y,
|
|
151
|
+
width,
|
|
152
|
+
height
|
|
153
|
+
} = el.getBoundingClientRect();
|
|
154
|
+
return {
|
|
155
|
+
x,
|
|
156
|
+
y,
|
|
157
|
+
width,
|
|
158
|
+
height
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export const setClass = (elem, name, isSet) => {
|
|
162
|
+
isSet ? elem.classList.add(name) : elem.classList.remove(name);
|
|
146
163
|
};
|