@nectary/components 0.9.0 → 0.11.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 (106) 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/card/index.d.ts +23 -0
  9. package/card/index.js +164 -0
  10. package/card-button/index.d.ts +27 -0
  11. package/card-button/index.js +83 -0
  12. package/card-link/index.d.ts +29 -0
  13. package/card-link/index.js +121 -0
  14. package/checkbox/index.d.ts +3 -0
  15. package/checkbox/index.js +27 -18
  16. package/dialog/index.d.ts +23 -0
  17. package/dialog/index.js +181 -0
  18. package/dropdown/index.d.ts +34 -0
  19. package/dropdown/index.js +451 -0
  20. package/dropdown-option/index.d.ts +44 -0
  21. package/dropdown-option/index.js +116 -0
  22. package/help-tooltip/index.js +5 -1
  23. package/icon/arrow-back/index.d.ts +11 -0
  24. package/icon/arrow-back/index.js +4 -0
  25. package/icon/arrow-downward/index.d.ts +11 -0
  26. package/icon/arrow-downward/index.js +4 -0
  27. package/icon/arrow-forward/index.d.ts +11 -0
  28. package/icon/arrow-forward/index.js +4 -0
  29. package/icon/arrow-upward/index.d.ts +11 -0
  30. package/icon/arrow-upward/index.js +4 -0
  31. package/icon/cancel/index.js +1 -1
  32. package/icon/close/index.js +1 -1
  33. package/icon/create-icon-class.js +1 -1
  34. package/icon/east/index.js +1 -1
  35. package/icon/help-outline/index.js +1 -1
  36. package/icon/more-horiz/index.js +1 -1
  37. package/icon/more-vert/index.js +1 -1
  38. package/icon/north/index.js +1 -1
  39. package/icon/north-east/index.js +1 -1
  40. package/icon/north-west/index.js +1 -1
  41. package/icon/open-in-new/index.js +1 -1
  42. package/icon/south/index.js +1 -1
  43. package/icon/south-east/index.js +1 -1
  44. package/icon/south-west/index.js +1 -1
  45. package/icon/west/index.js +1 -1
  46. package/icon-branded/barchart-down/index.js +1 -1
  47. package/icon-branded/barchart-up/index.js +1 -1
  48. package/icon-branded/campaigns/index.js +1 -1
  49. package/icon-branded/chatbot/index.js +1 -1
  50. package/icon-branded/contact/index.js +1 -1
  51. package/icon-branded/create-icon-class.js +1 -1
  52. package/icon-branded/home/index.js +1 -1
  53. package/icon-branded/multiple-channels/index.js +1 -1
  54. package/icon-branded/rocket/index.js +1 -1
  55. package/icon-branded/settings/index.js +1 -1
  56. package/icon-branded/user/index.js +1 -1
  57. package/icon-branded/users/index.js +1 -1
  58. package/illustration/create-illustration-class.d.ts +308 -0
  59. package/illustration/create-illustration-class.js +53 -0
  60. package/illustration/phone-and-cat/index.d.ts +11 -0
  61. package/illustration/phone-and-cat/index.js +4 -0
  62. package/illustration/types.d.ts +7 -0
  63. package/illustration/types.js +1 -0
  64. package/index.d.ts +11 -0
  65. package/index.js +12 -1
  66. package/input/index.d.ts +3 -1
  67. package/input/index.js +59 -11
  68. package/link/index.js +2 -2
  69. package/logo/create-logo-class.js +1 -1
  70. package/logo/sinch-icon/index.js +1 -1
  71. package/logo/sinch-icon-wordmark/index.js +1 -1
  72. package/package.json +1 -1
  73. package/pagination/index.js +1 -6
  74. package/radio/index.d.ts +1 -0
  75. package/radio/index.js +97 -71
  76. package/radio-option/index.d.ts +1 -0
  77. package/radio-option/index.js +4 -1
  78. package/select/index.d.ts +4 -1
  79. package/select/index.js +72 -265
  80. package/select-option/index.d.ts +3 -17
  81. package/select-option/index.js +4 -103
  82. package/spinner/index.js +1 -1
  83. package/table/index.js +1 -1
  84. package/table-body/index.js +1 -1
  85. package/table-cell/index.js +1 -1
  86. package/table-head/index.js +1 -1
  87. package/table-head-cell/index.js +3 -2
  88. package/table-head-sort/index.d.ts +1 -0
  89. package/table-head-sort/index.js +3 -1
  90. package/table-row/index.js +1 -1
  91. package/tabs/index.d.ts +1 -0
  92. package/tabs/index.js +96 -66
  93. package/tabs-option/index.d.ts +1 -0
  94. package/tabs-option/index.js +4 -2
  95. package/tag/index.js +1 -1
  96. package/tag-close/index.js +2 -2
  97. package/textarea/index.d.ts +3 -1
  98. package/textarea/index.js +58 -11
  99. package/theme.css +6 -2
  100. package/toggle/index.d.ts +1 -0
  101. package/toggle/index.js +4 -5
  102. package/tooltip/index.d.ts +2 -1
  103. package/tooltip/index.js +7 -3
  104. package/types.d.ts +7 -0
  105. package/utils.d.ts +3 -0
  106. 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
  };