@nectary/components 1.4.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.
Files changed (209) hide show
  1. package/accordion/index.js +0 -3
  2. package/accordion/types.d.ts +0 -3
  3. package/accordion-item/index.d.ts +2 -0
  4. package/accordion-item/index.js +33 -34
  5. package/action-menu/index.js +5 -1
  6. package/action-menu-option/index.js +2 -2
  7. package/alert/index.js +4 -21
  8. package/alert/utils.d.ts +0 -3
  9. package/alert/utils.js +1 -6
  10. package/avatar/index.js +5 -21
  11. package/avatar/utils.d.ts +0 -4
  12. package/avatar/utils.js +2 -15
  13. package/badge/index.js +36 -68
  14. package/badge/types.d.ts +0 -4
  15. package/badge/utils.d.ts +0 -6
  16. package/badge/utils.js +1 -17
  17. package/button/index.js +25 -27
  18. package/button/types.d.ts +2 -2
  19. package/button/utils.d.ts +0 -3
  20. package/button/utils.js +1 -9
  21. package/card/index.js +5 -16
  22. package/card/types.d.ts +0 -6
  23. package/card-container/index.js +1 -1
  24. package/chat-block/index.js +1 -1
  25. package/chat-bubble/index.d.ts +0 -1
  26. package/chat-bubble/index.js +3 -25
  27. package/checkbox/index.js +32 -33
  28. package/checkbox/types.d.ts +0 -3
  29. package/chip/index.js +54 -44
  30. package/chip/utils.d.ts +0 -1
  31. package/chip/utils.js +2 -7
  32. package/code-tag/index.js +1 -1
  33. package/color-menu/index.d.ts +0 -3
  34. package/color-menu/index.js +55 -101
  35. package/color-menu/types.d.ts +0 -4
  36. package/color-menu-option/index.d.ts +14 -0
  37. package/color-menu-option/index.js +52 -0
  38. package/color-menu-option/types.d.ts +9 -0
  39. package/color-menu-option/utils.d.ts +1 -0
  40. package/color-menu-option/utils.js +11 -0
  41. package/color-swatch/index.js +2 -5
  42. package/color-swatch/utils.d.ts +0 -1
  43. package/color-swatch/utils.js +2 -7
  44. package/date-picker/index.js +3 -40
  45. package/date-picker/types.d.ts +0 -3
  46. package/date-picker/utils.d.ts +0 -8
  47. package/date-picker/utils.js +0 -20
  48. package/dialog/index.js +2 -6
  49. package/dialog/types.d.ts +0 -2
  50. package/emoji/index.js +1 -1
  51. package/emoji-picker/index.d.ts +1 -0
  52. package/emoji-picker/index.js +36 -34
  53. package/field/index.js +39 -32
  54. package/file-drop/index.js +1 -1
  55. package/file-status/index.js +4 -25
  56. package/file-status/utils.d.ts +0 -3
  57. package/file-status/utils.js +1 -6
  58. package/flag/index.js +1 -1
  59. package/grid/index.js +1 -1
  60. package/help-tooltip/index.d.ts +0 -1
  61. package/help-tooltip/index.js +3 -13
  62. package/horizontal-stepper/index.js +1 -1
  63. package/horizontal-stepper-item/index.d.ts +2 -0
  64. package/horizontal-stepper-item/index.js +8 -12
  65. package/icon/index.js +1 -1
  66. package/icon-button/index.js +23 -27
  67. package/icon-button/utils.d.ts +0 -3
  68. package/icon-button/utils.js +1 -9
  69. package/inline-alert/index.js +20 -37
  70. package/inline-alert/utils.d.ts +0 -3
  71. package/inline-alert/utils.js +1 -6
  72. package/input/index.d.ts +0 -3
  73. package/input/index.js +22 -58
  74. package/input/types.d.ts +1 -5
  75. package/input/utils.d.ts +0 -3
  76. package/input/utils.js +1 -6
  77. package/link/index.js +35 -37
  78. package/list-item/index.js +1 -1
  79. package/package.json +11 -11
  80. package/pagination/index.js +8 -21
  81. package/pagination/types.d.ts +0 -3
  82. package/pop/index.js +39 -38
  83. package/pop/utils.d.ts +0 -3
  84. package/pop/utils.js +0 -5
  85. package/popover/index.js +42 -51
  86. package/popover/utils.d.ts +0 -3
  87. package/popover/utils.js +0 -5
  88. package/progress/index.js +20 -15
  89. package/radio/index.js +19 -6
  90. package/radio/types.d.ts +3 -3
  91. package/radio-option/index.js +35 -27
  92. package/rich-text/index.js +3 -10
  93. package/rich-text/utils.d.ts +0 -3
  94. package/rich-text/utils.js +1 -6
  95. package/segment/index.js +3 -7
  96. package/segment-collapse/index.js +2 -11
  97. package/segment-collapse/types.d.ts +0 -3
  98. package/segmented-control/index.js +0 -3
  99. package/segmented-control/types.d.ts +0 -3
  100. package/segmented-control-option/index.js +20 -19
  101. package/segmented-icon-control/index.js +1 -4
  102. package/segmented-icon-control/types.d.ts +0 -3
  103. package/segmented-icon-control-option/index.js +18 -14
  104. package/select-button/index.js +29 -31
  105. package/select-menu/index.js +18 -8
  106. package/select-menu-option/index.js +2 -5
  107. package/skeleton/index.js +1 -1
  108. package/skeleton-item/index.js +1 -1
  109. package/spinner/index.js +3 -10
  110. package/table/index.js +1 -1
  111. package/table-body/index.js +1 -1
  112. package/table-cell/index.js +1 -1
  113. package/table-head-cell/index.d.ts +1 -0
  114. package/table-head-cell/index.js +12 -3
  115. package/table-row/index.js +18 -2
  116. package/tabs/index.js +1 -4
  117. package/tabs/types.d.ts +0 -3
  118. package/tabs-icon-option/index.js +4 -2
  119. package/tabs-option/index.js +25 -20
  120. package/tag/index.js +17 -12
  121. package/tag/utils.d.ts +0 -1
  122. package/tag/utils.js +2 -7
  123. package/text/index.js +24 -21
  124. package/text/utils.d.ts +0 -3
  125. package/text/utils.js +1 -6
  126. package/textarea/index.js +10 -6
  127. package/textarea/types.d.ts +0 -3
  128. package/tile-control/index.js +23 -25
  129. package/tile-control/types.d.ts +0 -3
  130. package/tile-control-option/index.js +1 -1
  131. package/time-picker/index.js +2 -11
  132. package/time-picker/types.d.ts +0 -3
  133. package/time-picker/utils.d.ts +1 -1
  134. package/time-picker/utils.js +17 -5
  135. package/title/index.js +28 -30
  136. package/title/utils.d.ts +0 -7
  137. package/title/utils.js +1 -29
  138. package/toast/index.js +22 -39
  139. package/toast/utils.d.ts +0 -3
  140. package/toast/utils.js +1 -6
  141. package/toggle/index.js +33 -30
  142. package/toggle/types.d.ts +0 -3
  143. package/tooltip/index.js +3 -15
  144. package/tooltip/types.d.ts +0 -12
  145. package/tooltip/utils.d.ts +0 -5
  146. package/tooltip/utils.js +0 -10
  147. package/utils/dom.js +0 -5
  148. package/utils/element.js +2 -2
  149. package/utils/size.d.ts +0 -5
  150. package/utils/size.js +1 -17
  151. package/vertical-stepper/index.js +1 -1
  152. package/vertical-stepper-item/index.d.ts +2 -0
  153. package/vertical-stepper-item/index.js +8 -12
  154. package/logo/create-logo-class.d.ts +0 -1
  155. package/logo/create-logo-class.js +0 -52
  156. package/logo/engage-icon/index.d.ts +0 -11
  157. package/logo/engage-icon/index.js +0 -4
  158. package/logo/engage-icon-wordmark/index.d.ts +0 -11
  159. package/logo/engage-icon-wordmark/index.js +0 -4
  160. package/logo/sinch-icon/index.d.ts +0 -11
  161. package/logo/sinch-icon/index.js +0 -4
  162. package/logo/sinch-icon-wordmark/index.d.ts +0 -11
  163. package/logo/sinch-icon-wordmark/index.js +0 -4
  164. package/logo/types.d.ts +0 -11
  165. package/theme/accordion-item.css +0 -4
  166. package/theme/alert.css +0 -6
  167. package/theme/avatar.css +0 -25
  168. package/theme/badge.css +0 -15
  169. package/theme/button.css +0 -146
  170. package/theme/chat.css +0 -9
  171. package/theme/chip.css +0 -68
  172. package/theme/color-menu.css +0 -4
  173. package/theme/color-swatch.css +0 -71
  174. package/theme/colors.d.ts +0 -4
  175. package/theme/colors.js +0 -4
  176. package/theme/contextual.css +0 -40
  177. package/theme/date-picker.css +0 -7
  178. package/theme/dialog.css +0 -4
  179. package/theme/elevation.css +0 -7
  180. package/theme/emoji-picker.css +0 -13
  181. package/theme/emoji.css +0 -5
  182. package/theme/file-status.css +0 -7
  183. package/theme/flag.css +0 -4
  184. package/theme/fonts.css +0 -86
  185. package/theme/fonts.json +0 -89
  186. package/theme/help-tooltip.css +0 -5
  187. package/theme/horizontal-stepper.css +0 -5
  188. package/theme/icon-button.css +0 -68
  189. package/theme/icon.css +0 -7
  190. package/theme/index.css +0 -4
  191. package/theme/index.d.ts +0 -39
  192. package/theme/index.js +0 -39
  193. package/theme/inline-alert.css +0 -7
  194. package/theme/input.css +0 -10
  195. package/theme/link.css +0 -5
  196. package/theme/pagination.css +0 -5
  197. package/theme/palette.css +0 -90
  198. package/theme/segment.css +0 -4
  199. package/theme/select-button.css +0 -10
  200. package/theme/select-menu.css +0 -6
  201. package/theme/shapes.css +0 -8
  202. package/theme/size.css +0 -9
  203. package/theme/spinner.css +0 -7
  204. package/theme/tag.css +0 -67
  205. package/theme/time-picker.css +0 -4
  206. package/theme/toast.css +0 -7
  207. package/theme/typography.css +0 -16
  208. package/theme/vertical-stepper.css +0 -5
  209. /package/{logo → color-menu-option}/types.js +0 -0
@@ -24,9 +24,6 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
24
24
  this.#$slot.removeEventListener('option-change', this.#onOptionChange);
25
25
  this.removeEventListener('-change', this.#onChangeReactHandler);
26
26
  }
27
- get nodeName() {
28
- return 'select';
29
- }
30
27
  set value(value) {
31
28
  updateAttribute(this, 'value', value);
32
29
  }
@@ -1,5 +1,4 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export type TSinchAccordionElement = HTMLElement & {
4
3
  /** Value */
5
4
  value: string;
@@ -17,8 +16,6 @@ export type TSinchAccordionReact = TSinchElementReact<TSinchAccordionElement> &
17
16
  value: string;
18
17
  multiple?: boolean;
19
18
  /** Allows to expand multiple items simultanously */
20
- /** @deprecated */
21
- onChange?: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
22
19
  /** Change value handler */
23
20
  'on-change'?: (e: CustomEvent<string>) => void;
24
21
  };
@@ -1,4 +1,6 @@
1
1
  import '../icon';
2
+ import '../title';
3
+ import '../text';
2
4
  import type { TSinchAccordionItemElement, TSinchAccordionItemReact } from './types';
3
5
  declare global {
4
6
  namespace JSX {
@@ -1,26 +1,25 @@
1
1
  import '../icon';
2
- import { defineCustomElement, getAttribute, getBooleanAttribute, getCssVar, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
3
- const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-color-feedback-success-icon)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-feedback-warning-icon)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-feedback-invalid-icon)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-feedback-info-icon)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-text-m);color:var(--sinch-color-text-default)}#dropdown-icon{--sinch-size-icon:24px}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{font:var(--sinch-font-text-s);color:var(--sinch-color-stormy-300)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span><span id="optional"></span><sinch-icon id="dropdown-icon"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
2
+ import '../title';
3
+ import '../text';
4
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
5
+ const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-comp-accordion-color-default-border-initial)}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;--sinch-global-color-icon:var(--sinch-comp-accordion-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-accordion-size-icon)}#button>*{pointer-events:none}#button:disabled{cursor:initial;--sinch-global-color-icon:var(--sinch-comp-accordion-color-disabled-icon-initial)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-success)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-warning)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-error)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-info)}#title{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-accordion-font-title);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-title-initial)}#button:disabled>#title{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-title-initial)}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px}#dropdown-icon{transform:rotate(0)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{--sinch-comp-text-font:var(--sinch-comp-accordion-font-optional-text);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-optional-text-initial)}#button:disabled>#optional{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-optional-text-initial)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><sinch-title id="title" level="3" type="m" ellipsis></sinch-title><sinch-text id="optional" type="m"></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
4
6
  import { statusValues } from './utils';
5
7
  const template = document.createElement('template');
6
8
  template.innerHTML = templateHTML;
7
9
  defineCustomElement('sinch-accordion-item', class extends NectaryElement {
8
10
  #$button;
9
- #$icon;
10
- #$buttonContent;
11
+ #$title;
11
12
  #$optionalText;
12
13
  constructor() {
13
14
  super();
14
15
  const shadowRoot = this.attachShadow();
15
16
  shadowRoot.appendChild(template.content.cloneNode(true));
16
17
  this.#$button = shadowRoot.querySelector('#button');
17
- this.#$icon = shadowRoot.querySelector('#dropdown-icon');
18
- this.#$buttonContent = shadowRoot.querySelector('#title');
18
+ this.#$title = shadowRoot.querySelector('#title');
19
19
  this.#$optionalText = shadowRoot.querySelector('#optional');
20
20
  }
21
21
  connectedCallback() {
22
22
  this.#$button.addEventListener('click', this.#onButtonClick);
23
- updateAttribute(this.#$icon, 'name', getCssVar(this, '--sinch-accordion-item-icon-dropdown'));
24
23
  }
25
24
  disconnectedCallback() {
26
25
  this.#$button.removeEventListener('click', this.#onButtonClick);
@@ -28,6 +27,33 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
28
27
  static get observedAttributes() {
29
28
  return ['label', 'disabled', 'data-checked', 'optionaltext'];
30
29
  }
30
+ attributeChangedCallback(name, oldVal, newVal) {
31
+ if (oldVal === newVal) {
32
+ return;
33
+ }
34
+ switch (name) {
35
+ case 'label':
36
+ {
37
+ updateAttribute(this.#$title, 'text', newVal);
38
+ break;
39
+ }
40
+ case 'disabled':
41
+ {
42
+ this.#$button.disabled = isAttrTrue(newVal);
43
+ break;
44
+ }
45
+ case 'data-checked':
46
+ {
47
+ updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
48
+ break;
49
+ }
50
+ case 'optionaltext':
51
+ {
52
+ this.#$optionalText.textContent = newVal;
53
+ break;
54
+ }
55
+ }
56
+ }
31
57
  set value(value) {
32
58
  updateAttribute(this, 'value', value);
33
59
  }
@@ -58,33 +84,6 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
58
84
  get optionalText() {
59
85
  return getAttribute(this, 'optionaltext');
60
86
  }
61
- attributeChangedCallback(name, oldVal, newVal) {
62
- if (oldVal === newVal) {
63
- return;
64
- }
65
- switch (name) {
66
- case 'label':
67
- {
68
- this.#$buttonContent.textContent = newVal;
69
- break;
70
- }
71
- case 'disabled':
72
- {
73
- this.#$button.disabled = isAttrTrue(newVal);
74
- break;
75
- }
76
- case 'data-checked':
77
- {
78
- updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
79
- break;
80
- }
81
- case 'optionaltext':
82
- {
83
- this.#$optionalText.textContent = newVal;
84
- break;
85
- }
86
- }
87
- }
88
87
  #onButtonClick = e => {
89
88
  e.stopPropagation();
90
89
  this.dispatchEvent(new CustomEvent('option-change', {
@@ -10,7 +10,9 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
10
10
  #controller = null;
11
11
  constructor() {
12
12
  super();
13
- const shadowRoot = this.attachShadow();
13
+ const shadowRoot = this.attachShadow({
14
+ delegatesFocus: false
15
+ });
14
16
  shadowRoot.appendChild(template.content.cloneNode(true));
15
17
  this.#$optionSlot = shadowRoot.querySelector('slot');
16
18
  this.#$listbox = shadowRoot.querySelector('#listbox');
@@ -65,6 +67,7 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
65
67
  this.#selectOption(null);
66
68
  };
67
69
  #onListboxClick = e => {
70
+ this.focus();
68
71
  if (isSinchActionMenuOption(e.target)) {
69
72
  this.#selectOption(e.target);
70
73
  }
@@ -87,6 +90,7 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
87
90
  #handleKeydown(e) {
88
91
  switch (e.code) {
89
92
  case 'Enter':
93
+ case 'Space':
90
94
  {
91
95
  const $opt = this.#findSelectedOption();
92
96
  if ($opt !== null) {
@@ -1,6 +1,6 @@
1
1
  import '../text';
2
2
  import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
3
- const templateHTML = '<style>:host{display:block}#wrapper{all:initial;display:flex;position:relative;box-sizing:border-box;height:40px;width:100%;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([disabled])>#wrapper{cursor:initial;pointer-events:none;color:var(--sinch-color-text-disabled);--sinch-color-icon:var(--sinch-color-stormy-100)}:host(:hover:not([disabled]))>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-400)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text></div>';
3
+ const templateHTML = '<style>:host{display:block}#wrapper{all:initial;display:flex;position:relative;box-sizing:border-box;height:40px;width:100%;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;background-color:var(--sinch-comp-action-menu-color-default-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-action-menu-size-icon)}:host([data-selected])>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-selected)}:host(:hover)>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-hover)}:host([disabled])>#wrapper{cursor:initial;pointer-events:none;background-color:var(--sinch-comp-action-menu-color-disabled-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-disabled-icon-initial)}#content{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-action-menu-font-option)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text></div>';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
6
6
  defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends NectaryElement {
@@ -45,7 +45,7 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
45
45
  }
46
46
  case 'disabled':
47
47
  {
48
- updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
48
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
49
49
  break;
50
50
  }
51
51
  case 'data-selected':
package/alert/index.js CHANGED
@@ -1,25 +1,22 @@
1
1
  import '../icon';
2
2
  import '../rich-text';
3
3
  import '../text';
4
- import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getCssVar } from '../utils';
5
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}#text{display:flex;flex-direction:column;gap:8px;color:var(--sinch-color-stormy-500);flex:1;min-width:0}:host([type=warn]) #wrapper{background-color:var(--sinch-color-feedback-warning-bg)}:host([type=error]) #wrapper{background-color:var(--sinch-color-feedback-invalid-bg)}:host([type=info]) #wrapper{background-color:var(--sinch-color-feedback-info-bg)}:host([type=warn]) #icon{--sinch-color-icon:var(--sinch-color-feedback-warning-icon)}:host([type=error]) #icon{--sinch-color-icon:var(--sinch-color-feedback-invalid-icon)}:host([type=info]) #icon{--sinch-color-icon:var(--sinch-color-feedback-info-icon)}</style><div id="wrapper"><sinch-icon id="icon"></sinch-icon><sinch-rich-text id="text"></sinch-rich-text><slot name="action"></slot><slot name="close"></slot></div>';
6
- import { assertType, typeValues } from './utils';
4
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
5
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-alert-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-alert-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-alert-color-info-default-background)}#icon-error,#icon-info,#icon-warn{display:none}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-alert-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-alert-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-alert-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=warn]) #icon-warn{display:block}#text{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;--sinch-comp-rich-text-font:var(--sinch-comp-alert-font-body)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-info-default-text)}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><sinch-rich-text id="text"></sinch-rich-text><slot name="action"></slot><slot name="close"></slot></div>';
6
+ import { typeValues } from './utils';
7
7
  const template = document.createElement('template');
8
8
  template.innerHTML = templateHTML;
9
9
  defineCustomElement('sinch-alert', class extends NectaryElement {
10
10
  #$text;
11
- #$icon;
12
11
  constructor() {
13
12
  super();
14
13
  const shadowRoot = this.attachShadow();
15
14
  shadowRoot.appendChild(template.content.cloneNode(true));
16
15
  this.#$text = shadowRoot.querySelector('#text');
17
- this.#$icon = shadowRoot.querySelector('#icon');
18
16
  }
19
17
  connectedCallback() {
20
18
  super.connectedCallback();
21
19
  this.setAttribute('role', 'alert');
22
- this.#updateIcon();
23
20
  }
24
21
  disconnectedCallback() {
25
22
  super.disconnectedCallback();
@@ -37,18 +34,10 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
37
34
  updateAttribute(this, 'text', value);
38
35
  }
39
36
  static get observedAttributes() {
40
- return ['text', 'type'];
37
+ return ['text'];
41
38
  }
42
39
  attributeChangedCallback(name, _, newVal) {
43
40
  switch (name) {
44
- case 'type':
45
- {
46
- if ('production' !== 'production') {
47
- assertType(newVal);
48
- }
49
- this.#updateIcon();
50
- break;
51
- }
52
41
  case 'text':
53
42
  {
54
43
  updateAttribute(this.#$text, 'text', newVal);
@@ -56,10 +45,4 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
56
45
  }
57
46
  }
58
47
  }
59
- #updateIcon() {
60
- if (!this.isConnected) {
61
- return;
62
- }
63
- updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-alert-icon-${this.type}`));
64
- }
65
48
  });
package/alert/utils.d.ts CHANGED
@@ -1,5 +1,2 @@
1
1
  import type { TSinchAlertType } from './types';
2
2
  export declare const typeValues: readonly TSinchAlertType[];
3
- type TAssertType = (value: string | null) => asserts value is TSinchAlertType;
4
- export declare const assertType: TAssertType;
5
- export {};
package/alert/utils.js CHANGED
@@ -1,6 +1 @@
1
- export const typeValues = ['info', 'warn', 'error'];
2
- export const assertType = value => {
3
- if (value === null || !typeValues.includes(value)) {
4
- throw new Error(`sinch-alert: invalid type attribute: ${value}`);
5
- }
6
- };
1
+ export const typeValues = ['info', 'warn', 'error'];
package/avatar/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
2
- import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
3
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:40px;height:40px;background-color:var(--sinch-color-snow-100);border-radius:50%}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-avatar-color-default-bg);color:var(--sinch-avatar-color-default-fg)}#text{display:block;width:100%;height:100%;font:var(--sinch-font-title-s);line-height:38px;text-transform:uppercase;text-align:center}:host([size="l"]) #wrapper{width:56px;height:56px}:host([size="l"]) #text{font:var(--sinch-font-title-m);line-height:54px}:host([size="s"]) #wrapper{width:24px;height:24px}:host([size="s"]) #text{font:var(--sinch-font-text-xs);line-height:22px}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#status-wrapper{position:absolute;left:calc(85% - 5px);top:calc(85% - 5px);width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-color-snow-100);display:none;pointer-events:none}#status{width:8px;height:8px;border-radius:50%}:host([status=away]) #status-wrapper,:host([status=busy]) #status-wrapper,:host([status=offline]) #status-wrapper,:host([status=online]) #status-wrapper{display:block}:host([status=online]) #status{background-color:var(--sinch-avatar-status-color-online)}:host([status=away]) #status{background-color:var(--sinch-avatar-status-color-away)}:host([status=busy]) #status{background-color:var(--sinch-avatar-status-color-busy)}:host([status=offline]) #status{background-color:var(--sinch-avatar-status-color-offline)}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/></div><div id="status-wrapper"><div id="status"></div></div></div>';
4
- import { assertAvatarColor, assertStatus, getAvatarColorBg, getAvatarColorFg, statusValues } from './utils';
2
+ import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);background-color:var(--sinch-comp-avatar-border-color-default-initial);border-radius:var(--sinch-comp-avatar-shape-radius);--sinch-local-size:var(--sinch-comp-avatar-size-m)}:host([size="l"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-l)}:host([size="s"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-s)}#text{display:block;width:100%;height:100%;font:var(--sinch-comp-avatar-container-font-size-m-text);line-height:calc(var(--sinch-local-size) - 2px);text-transform:uppercase;text-align:center}:host([size="l"]) #text{font:var(--sinch-comp-avatar-container-font-size-l-text);line-height:calc(var(--sinch-local-size) - 2px)}:host([size="s"]) #text{font:var(--sinch-comp-avatar-container-font-size-s-text);line-height:calc(var(--sinch-local-size) - 2px)}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-comp-avatar-container-color-default-background);color:var(--sinch-comp-avatar-container-color-default-foreground)}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#status-wrapper{position:absolute;left:calc(85% - 5px);top:calc(85% - 5px);width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-comp-avatar-border-color-default-initial);display:none;pointer-events:none}#status{width:8px;height:8px;border-radius:50%}:host([status=away]) #status-wrapper,:host([status=busy]) #status-wrapper,:host([status=offline]) #status-wrapper,:host([status=online]) #status-wrapper{display:block}:host([status=online]) #status{background-color:var(--sinch-comp-avatar-status-color-online-default-background)}:host([status=away]) #status{background-color:var(--sinch-comp-avatar-status-color-away-default-background)}:host([status=busy]) #status{background-color:var(--sinch-comp-avatar-status-color-busy-default-background)}:host([status=offline]) #status{background-color:var(--sinch-comp-avatar-status-color-offline-default-background)}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/></div><div id="status-wrapper"><div id="status"></div></div></div>';
4
+ import { getAvatarColorBg, getAvatarColorFg, statusValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  defineCustomElement('sinch-avatar', class extends NectaryElement {
@@ -51,7 +51,7 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
51
51
  updateLiteralAttribute(this, statusValues, 'status', value);
52
52
  }
53
53
  static get observedAttributes() {
54
- return ['alt', 'src', 'status', 'size', 'color'];
54
+ return ['alt', 'src', 'color'];
55
55
  }
56
56
  attributeChangedCallback(name, _, newVal) {
57
57
  switch (name) {
@@ -66,23 +66,10 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
66
66
  this.#$image.src = newVal ?? '';
67
67
  break;
68
68
  }
69
- case 'size':
70
- {
71
- if ('production' !== 'production') {
72
- assertSize(newVal, 'sinch-avatar');
73
- }
74
- break;
75
- }
76
- case 'status':
77
- {
78
- if ('production' !== 'production') {
79
- assertStatus(newVal);
80
- }
81
- break;
82
- }
83
69
  case 'color':
84
70
  {
85
71
  this.#updateColor();
72
+ break;
86
73
  }
87
74
  }
88
75
  }
@@ -92,9 +79,6 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
92
79
  }
93
80
  const colorName = this.color;
94
81
  if (colorName !== null && colorName.length > 0) {
95
- if ('production' !== 'production') {
96
- assertAvatarColor(this, colorName);
97
- }
98
82
  const bg = getAvatarColorBg(colorName);
99
83
  const fg = getAvatarColorFg(colorName);
100
84
  this.#$circle.style.setProperty('background-color', bg);
package/avatar/utils.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import type { TSinchAvatarStatus } from './types';
2
2
  export declare const statusValues: readonly TSinchAvatarStatus[];
3
- type TAssertStatus = (value: string | null) => asserts value is TSinchAvatarStatus;
4
- export declare const assertStatus: TAssertStatus;
5
3
  export declare const getAvatarColorBg: (id: string) => string;
6
4
  export declare const getAvatarColorFg: (id: string) => string;
7
- export declare const assertAvatarColor: (root: Element, id: string | null) => void;
8
- export {};
package/avatar/utils.js CHANGED
@@ -1,20 +1,7 @@
1
1
  export const statusValues = ['online', 'busy', 'away', 'offline'];
2
- export const assertStatus = value => {
3
- if (value === null || value.length === 0) {
4
- return;
5
- }
6
- if (!statusValues.includes(value)) {
7
- throw new Error(`sinch-avatar: invalid status attribute: ${value}`);
8
- }
9
- };
10
2
  export const getAvatarColorBg = id => {
11
- return `var(--sinch-avatar-color-${id}-bg)`;
3
+ return `var(--sinch-comp-avatar-container-color-${id}-background)`;
12
4
  };
13
5
  export const getAvatarColorFg = id => {
14
- return `var(--sinch-avatar-color-${id}-fg)`;
15
- };
16
- export const assertAvatarColor = (root, id) => {
17
- if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-avatar-color-${id}-bg`).length === 0) {
18
- throw new Error(`Invalid sinch-avatar color name: ${id}`);
19
- }
6
+ return `var(--sinch-comp-avatar-container-color-${id}-foreground)`;
20
7
  };
package/badge/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
2
- import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
3
- const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:11px;padding:1px;pointer-events:none;background-color:var(--sinch-color-snow-100)}#badge{box-sizing:border-box;color:var(--sinch-badge-color-default-fg);background-color:var(--sinch-badge-color-default-bg);width:20px;height:20px;border-radius:10px}#badge.long{width:fit-content;padding:0 5px}#text{display:block;width:100%;height:100%;text-align:center;font-family:var(--sinch-font-mono-family);font-weight:400;font-size:14px;line-height:20px;text-rendering:optimizelegibility}:host([size="m"]) #badge-wrapper{left:calc(100% - 8px);top:-8px}:host([size="m"]) #badge{width:14px;height:14px}:host([size="m"]) #badge.long{width:fit-content;padding:0 3px}:host([size="m"]) #text{font-size:12px;line-height:14px}:host([size="s"]) #badge{width:8px;height:8px;padding:0}:host([size="s"]) #text{display:none}:host([hidden]:not([hidden=false])) #badge-wrapper{display:none}</style><slot id="slot"></slot><div id="badge-wrapper"><div id="badge"><span id="text"></span></div></div>';
4
- import { assertBadgeColor, assertMode, getBadgeColorBg, getBadgeColorFg, modeValues } from './utils';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
2
+ import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
+ const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:var(--sinch-comp-badge-shape-radius);padding:1px;pointer-events:none;background-color:var(--sinch-comp-badge-color-border)}#badge{box-sizing:border-box;color:var(--sinch-comp-badge-color-text);background-color:var(--sinch-comp-badge-color-background);width:20px;height:20px;border-radius:var(--sinch-comp-badge-shape-radius)}#badge.long{width:fit-content;padding:0 5px}#text{display:block;width:100%;height:100%;text-align:center;font:var(--sinch-comp-badge-font-size-l);line-height:20px;text-rendering:optimizelegibility}:host([size="m"]) #badge-wrapper{left:calc(100% - 8px);top:-8px}:host([size="m"]) #badge{width:14px;height:14px}:host([size="m"]) #badge.long{width:fit-content;padding:0 3px}:host([size="m"]) #text{font:var(--sinch-comp-badge-font-size-m);line-height:14px}:host([size="s"]) #badge{width:8px;height:8px;padding:0}:host([size="s"]) #text{display:none}:host([hidden]) #badge-wrapper{display:none}</style><slot id="slot"></slot><div id="badge-wrapper"><div id="badge"><span id="text"></span></div></div>';
4
+ import { modeValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  defineCustomElement('sinch-badge', class extends NectaryElement {
@@ -20,13 +20,44 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
20
20
  }
21
21
  connectedCallback() {
22
22
  super.connectedCallback();
23
- this.#updateColor();
24
23
  this.#observer.observe(this);
25
24
  }
26
25
  disconnectedCallback() {
27
26
  super.disconnectedCallback();
28
27
  this.#observer.unobserve(this);
29
28
  }
29
+ static get observedAttributes() {
30
+ return ['text', 'size', 'mode', 'hidden'];
31
+ }
32
+ attributeChangedCallback(name, oldVal, newVal) {
33
+ if (oldVal === newVal) {
34
+ return;
35
+ }
36
+ switch (name) {
37
+ case 'text':
38
+ {
39
+ this.#$text.textContent = newVal;
40
+ setClass(this.#$badge, 'long', newVal !== null && newVal.length > 1);
41
+ break;
42
+ }
43
+ case 'size':
44
+ {
45
+ this.#updatePosition();
46
+ break;
47
+ }
48
+ case 'mode':
49
+ {
50
+ this.#updatePosition();
51
+ break;
52
+ }
53
+ case 'hidden':
54
+ {
55
+ this.#updatePosition();
56
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
57
+ break;
58
+ }
59
+ }
60
+ }
30
61
  get text() {
31
62
  return getAttribute(this, 'text', '');
32
63
  }
@@ -45,12 +76,6 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
45
76
  set mode(value) {
46
77
  updateLiteralAttribute(this, modeValues, 'mode', value);
47
78
  }
48
- get color() {
49
- return getAttribute(this, 'color');
50
- }
51
- set color(value) {
52
- updateAttribute(this, 'color', value);
53
- }
54
79
  get hidden() {
55
80
  return getBooleanAttribute(this, 'hidden');
56
81
  }
@@ -69,63 +94,6 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
69
94
  }
70
95
  return getRect(this.#$badgeWrapper);
71
96
  }
72
- static get observedAttributes() {
73
- return ['text', 'size', 'mode', 'color', 'hidden'];
74
- }
75
- attributeChangedCallback(name, _, newVal) {
76
- switch (name) {
77
- case 'text':
78
- {
79
- this.#$text.textContent = newVal;
80
- setClass(this.#$badge, 'long', newVal !== null && newVal.length > 1);
81
- break;
82
- }
83
- case 'size':
84
- {
85
- if ('production' !== 'production') {
86
- assertSize(newVal, 'sinch-badge');
87
- }
88
- this.#updatePosition();
89
- break;
90
- }
91
- case 'mode':
92
- {
93
- if ('production' !== 'production') {
94
- assertMode(newVal);
95
- }
96
- this.#updatePosition();
97
- break;
98
- }
99
- case 'color':
100
- {
101
- this.#updateColor();
102
- break;
103
- }
104
- case 'hidden':
105
- {
106
- this.#updatePosition();
107
- break;
108
- }
109
- }
110
- }
111
- #updateColor() {
112
- if (!this.isConnected) {
113
- return;
114
- }
115
- const colorName = this.color;
116
- if (colorName !== null && colorName.length > 0) {
117
- if ('production' !== 'production') {
118
- assertBadgeColor(this, colorName);
119
- }
120
- const bg = getBadgeColorBg(colorName);
121
- const fg = getBadgeColorFg(colorName);
122
- this.#$badge.style.setProperty('background-color', bg);
123
- this.#$badge.style.setProperty('color', fg);
124
- } else {
125
- this.#$badge.style.removeProperty('background-color');
126
- this.#$badge.style.removeProperty('color');
127
- }
128
- }
129
97
  #updatePosition() {
130
98
  if (this.hidden) {
131
99
  return;
package/badge/types.d.ts CHANGED
@@ -8,8 +8,6 @@ export type TSinchBadgeElement = HTMLElement & {
8
8
  size: TSinchSize;
9
9
  /** Mode, `square` by default */
10
10
  mode: TSinchBadgeMode;
11
- /** Color */
12
- color: string | null;
13
11
  /** Hidden */
14
12
  hidden: boolean;
15
13
  readonly badgeRect: TRect;
@@ -31,8 +29,6 @@ export type TSinchBadgeReact = TSinchElementReact<TSinchBadgeElement> & {
31
29
  size?: TSinchSize;
32
30
  /** Mode, `square` by default */
33
31
  mode?: TSinchBadgeMode;
34
- /** Color */
35
- color?: string;
36
32
  /** Hidden */
37
33
  hidden?: boolean;
38
34
  };
package/badge/utils.d.ts CHANGED
@@ -1,8 +1,2 @@
1
1
  import type { TSinchBadgeMode } from './types';
2
2
  export declare const modeValues: readonly TSinchBadgeMode[];
3
- type TAssertMode = (value: string | null) => asserts value is TSinchBadgeMode;
4
- export declare const assertMode: TAssertMode;
5
- export declare const getBadgeColorBg: (id: string) => string;
6
- export declare const getBadgeColorFg: (id: string) => string;
7
- export declare const assertBadgeColor: (root: Element, id: string | null) => void;
8
- export {};
package/badge/utils.js CHANGED
@@ -1,17 +1 @@
1
- export const modeValues = ['square', 'circle'];
2
- export const assertMode = value => {
3
- if (value === null || !modeValues.includes(value)) {
4
- throw new Error(`sinch-badge: invalid mode attribute: ${value}`);
5
- }
6
- };
7
- export const getBadgeColorBg = id => {
8
- return `var(--sinch-badge-color-${id}-bg)`;
9
- };
10
- export const getBadgeColorFg = id => {
11
- return `var(--sinch-badge-color-${id}-fg)`;
12
- };
13
- export const assertBadgeColor = (root, id) => {
14
- if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-badge-color-${id}-bg`).length === 0) {
15
- throw new Error(`Invalid sinch-badge color name: ${id}`);
16
- }
17
- };
1
+ export const modeValues = ['square', 'circle'];