@nectary/components 0.9.0 → 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.
Files changed (84) hide show
  1. package/accordion/index.js +5 -1
  2. package/accordion-item/index.js +7 -7
  3. package/alert/index.js +2 -2
  4. package/alert-button/index.js +1 -1
  5. package/alert-close/index.js +2 -2
  6. package/button/index.d.ts +2 -1
  7. package/button/index.js +7 -3
  8. package/checkbox/index.d.ts +3 -0
  9. package/checkbox/index.js +27 -18
  10. package/dropdown/index.d.ts +34 -0
  11. package/dropdown/index.js +451 -0
  12. package/dropdown-option/index.d.ts +44 -0
  13. package/dropdown-option/index.js +116 -0
  14. package/help-tooltip/index.js +5 -1
  15. package/icon/cancel/index.js +1 -1
  16. package/icon/close/index.js +1 -1
  17. package/icon/create-icon-class.js +1 -1
  18. package/icon/east/index.js +1 -1
  19. package/icon/help-outline/index.js +1 -1
  20. package/icon/more-horiz/index.js +1 -1
  21. package/icon/more-vert/index.js +1 -1
  22. package/icon/north/index.js +1 -1
  23. package/icon/north-east/index.js +1 -1
  24. package/icon/north-west/index.js +1 -1
  25. package/icon/open-in-new/index.js +1 -1
  26. package/icon/south/index.js +1 -1
  27. package/icon/south-east/index.js +1 -1
  28. package/icon/south-west/index.js +1 -1
  29. package/icon/west/index.js +1 -1
  30. package/icon-branded/barchart-down/index.js +1 -1
  31. package/icon-branded/barchart-up/index.js +1 -1
  32. package/icon-branded/campaigns/index.js +1 -1
  33. package/icon-branded/chatbot/index.js +1 -1
  34. package/icon-branded/contact/index.js +1 -1
  35. package/icon-branded/create-icon-class.js +1 -1
  36. package/icon-branded/home/index.js +1 -1
  37. package/icon-branded/multiple-channels/index.js +1 -1
  38. package/icon-branded/rocket/index.js +1 -1
  39. package/icon-branded/settings/index.js +1 -1
  40. package/icon-branded/user/index.js +1 -1
  41. package/icon-branded/users/index.js +1 -1
  42. package/index.d.ts +2 -0
  43. package/index.js +2 -0
  44. package/input/index.d.ts +3 -1
  45. package/input/index.js +59 -11
  46. package/link/index.js +2 -2
  47. package/logo/create-logo-class.js +1 -1
  48. package/logo/sinch-icon/index.js +1 -1
  49. package/logo/sinch-icon-wordmark/index.js +1 -1
  50. package/package.json +1 -1
  51. package/pagination/index.js +1 -6
  52. package/radio/index.d.ts +1 -0
  53. package/radio/index.js +97 -71
  54. package/radio-option/index.d.ts +1 -0
  55. package/radio-option/index.js +4 -1
  56. package/select/index.d.ts +4 -1
  57. package/select/index.js +72 -265
  58. package/select-option/index.d.ts +3 -17
  59. package/select-option/index.js +4 -103
  60. package/spinner/index.js +1 -1
  61. package/table/index.js +1 -1
  62. package/table-body/index.js +1 -1
  63. package/table-cell/index.js +1 -1
  64. package/table-head/index.js +1 -1
  65. package/table-head-cell/index.js +3 -2
  66. package/table-head-sort/index.d.ts +1 -0
  67. package/table-head-sort/index.js +3 -1
  68. package/table-row/index.js +1 -1
  69. package/tabs/index.d.ts +1 -0
  70. package/tabs/index.js +96 -66
  71. package/tabs-option/index.d.ts +1 -0
  72. package/tabs-option/index.js +4 -2
  73. package/tag/index.js +1 -1
  74. package/tag-close/index.js +2 -2
  75. package/textarea/index.d.ts +3 -1
  76. package/textarea/index.js +58 -11
  77. package/theme.css +3 -0
  78. package/toggle/index.d.ts +1 -0
  79. package/toggle/index.js +4 -5
  80. package/tooltip/index.d.ts +2 -1
  81. package/tooltip/index.js +7 -3
  82. package/types.d.ts +7 -0
  83. package/utils.d.ts +3 -0
  84. 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: 'production' === 'development' ? 'open' : 'closed'
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
  };