@nectary/components 0.23.0 → 0.24.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 (67) hide show
  1. package/accordion/index.js +3 -6
  2. package/accordion-item/index.js +3 -6
  3. package/alert/index.js +3 -5
  4. package/alert-button/index.js +3 -6
  5. package/alert-close/index.js +3 -6
  6. package/avatar/index.js +3 -5
  7. package/avatar-badge/index.js +3 -5
  8. package/avatar-status/index.js +3 -5
  9. package/button/index.js +3 -6
  10. package/card/index.js +3 -6
  11. package/card-button/index.js +3 -6
  12. package/card-container/index.js +3 -6
  13. package/card-link/index.js +3 -6
  14. package/chat/index.js +3 -6
  15. package/chat-avatar/index.js +3 -6
  16. package/chat-block/index.js +3 -6
  17. package/chat-bubble/index.js +3 -6
  18. package/checkbox/index.js +3 -6
  19. package/dialog/index.d.ts +2 -3
  20. package/dialog/index.js +3 -6
  21. package/dropdown/index.js +4 -7
  22. package/dropdown-option/index.d.ts +2 -1
  23. package/dropdown-option/index.js +4 -6
  24. package/grid/index.js +3 -5
  25. package/grid-item/index.js +3 -5
  26. package/help-tooltip/index.js +3 -5
  27. package/icon-button/index.js +3 -6
  28. package/icons/create-icon-class.d.ts +1 -1
  29. package/icons/create-icon-class.js +3 -5
  30. package/icons-branded/create-icon-class.d.ts +1 -1
  31. package/icons-branded/create-icon-class.js +3 -5
  32. package/icons-channel/create-icon-class.d.ts +1 -1
  33. package/icons-channel/create-icon-class.js +3 -5
  34. package/illustration/create-illustration-class.d.ts +1 -1
  35. package/illustration/create-illustration-class.js +3 -5
  36. package/input/index.js +3 -6
  37. package/link/index.js +5 -26
  38. package/logo/create-logo-class.d.ts +1 -1
  39. package/logo/create-logo-class.js +3 -5
  40. package/package.json +1 -1
  41. package/pagination/index.d.ts +4 -1
  42. package/pagination/index.js +17 -6
  43. package/popover/index.js +3 -6
  44. package/radio/index.js +3 -6
  45. package/radio-option/index.js +3 -6
  46. package/search/index.js +4 -7
  47. package/search-option/index.js +3 -5
  48. package/segment/index.js +3 -6
  49. package/segment-collapse/index.js +3 -5
  50. package/select/index.js +22 -8
  51. package/spinner/index.js +3 -5
  52. package/table/index.js +3 -5
  53. package/table-body/index.js +3 -5
  54. package/table-cell/index.js +3 -5
  55. package/table-head/index.js +3 -5
  56. package/table-head-cell/index.js +3 -5
  57. package/table-row/index.js +3 -5
  58. package/tabs/index.js +3 -6
  59. package/tabs-option/index.js +4 -7
  60. package/tag/index.js +3 -5
  61. package/tag-close/index.js +3 -6
  62. package/textarea/index.js +3 -6
  63. package/title/index.js +3 -6
  64. package/toggle/index.js +3 -6
  65. package/tooltip/index.js +3 -5
  66. package/utils.d.ts +10 -3
  67. package/utils.js +22 -14
package/tooltip/index.js CHANGED
@@ -1,14 +1,12 @@
1
- import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, getRect } from '../utils';
1
+ import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, getRect, NectaryElement } from '../utils';
2
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:1}#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;
6
- defineCustomElement('sinch-tooltip', class extends HTMLElement {
6
+ defineCustomElement('sinch-tooltip', class extends NectaryElement {
7
7
  constructor() {
8
8
  super();
9
- const shadowRoot = this.attachShadow({
10
- mode: 'closed'
11
- });
9
+ const shadowRoot = this.attachShadow();
12
10
  shadowRoot.appendChild(template.content.cloneNode(true));
13
11
  this.$tooltipText = shadowRoot.querySelector('#text');
14
12
  }
package/utils.d.ts CHANGED
@@ -1,8 +1,15 @@
1
1
  import type { TRect } from './types';
2
- export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
3
2
  export declare const defineCustomElement: (name: string, constructor: CustomElementConstructor) => void;
4
- export declare const defineNectaryElements: (registry: CustomElementRegistry) => void;
5
- export declare type TEventHandler = (arg?: any) => void;
3
+ export declare const setNectaryRegistry: (registry: CustomElementRegistry) => void;
4
+ declare global {
5
+ interface ShadowRootInit {
6
+ customElements?: CustomElementRegistry;
7
+ }
8
+ }
9
+ export declare class NectaryElement extends HTMLElement {
10
+ attachShadow(): ShadowRoot;
11
+ }
12
+ export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
6
13
  export declare const updateBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
7
14
  export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
8
15
  export declare const isAttrTrue: (attrValue: string | null) => boolean;
package/utils.js CHANGED
@@ -1,14 +1,5 @@
1
1
  const nectaryDefinitions = new Map();
2
2
  let nectaryRegistry = null;
3
- export const getReactEventHandler = ($element, handlerName) => {
4
- for (const key in $element) {
5
- if (key.startsWith('__reactProps$')) {
6
- return $element[key][handlerName];
7
- }
8
- }
9
-
10
- return null;
11
- };
12
3
  export const defineCustomElement = (name, constructor) => {
13
4
  if (nectaryRegistry !== null) {
14
5
  if (nectaryRegistry.get(name) == null) {
@@ -19,12 +10,8 @@ export const defineCustomElement = (name, constructor) => {
19
10
  }
20
11
 
21
12
  nectaryDefinitions.set(name, constructor);
22
-
23
- if (customElements.get(name) == null) {
24
- customElements.define(name, constructor);
25
- }
26
13
  };
27
- export const defineNectaryElements = registry => {
14
+ export const setNectaryRegistry = registry => {
28
15
  if (nectaryRegistry !== null) {
29
16
  throw new Error('Nectary elements already registered');
30
17
  }
@@ -36,6 +23,27 @@ export const defineNectaryElements = registry => {
36
23
  nectaryRegistry.define(name, ctor);
37
24
  }
38
25
  }
26
+
27
+ nectaryDefinitions.clear();
28
+ };
29
+ export class NectaryElement extends HTMLElement {
30
+ attachShadow() {
31
+ return super.attachShadow({
32
+ mode: 'closed',
33
+ delegatesFocus: true,
34
+ customElements: nectaryRegistry
35
+ });
36
+ }
37
+
38
+ }
39
+ export const getReactEventHandler = ($element, handlerName) => {
40
+ for (const key in $element) {
41
+ if (key.startsWith('__reactProps$')) {
42
+ return $element[key][handlerName];
43
+ }
44
+ }
45
+
46
+ return null;
39
47
  };
40
48
  export const updateBooleanAttribute = ($element, attrName, attrValue) => {
41
49
  if (attrValue === true) {