@nectary/components 0.48.1 → 0.49.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 (149) hide show
  1. package/accordion/types.d.ts +2 -2
  2. package/accordion-item/types.d.ts +3 -3
  3. package/action-menu/index.js +0 -1
  4. package/action-menu/types.d.ts +2 -2
  5. package/action-menu-option/index.js +1 -1
  6. package/action-menu-option/types.d.ts +2 -2
  7. package/alert/index.d.ts +2 -1
  8. package/alert/index.js +4 -3
  9. package/alert/types.d.ts +3 -3
  10. package/alert/utils.d.ts +1 -1
  11. package/avatar/types.d.ts +3 -3
  12. package/avatar/utils.d.ts +1 -1
  13. package/badge/types.d.ts +3 -3
  14. package/badge/utils.d.ts +1 -1
  15. package/button/types.d.ts +3 -3
  16. package/button/utils.d.ts +1 -1
  17. package/card/types.d.ts +2 -2
  18. package/card-container/types.d.ts +2 -2
  19. package/chat/types.d.ts +2 -2
  20. package/chat-block/types.d.ts +3 -3
  21. package/chat-bubble/types.d.ts +4 -4
  22. package/checkbox/types.d.ts +2 -2
  23. package/chip/types.d.ts +2 -2
  24. package/code-tag/index.d.ts +13 -0
  25. package/code-tag/index.js +36 -0
  26. package/code-tag/types.d.ts +11 -0
  27. package/code-tag/types.js +1 -0
  28. package/color-menu/index.js +0 -3
  29. package/color-menu/types.d.ts +2 -2
  30. package/color-swatch/types.d.ts +2 -2
  31. package/date-picker/index.js +0 -6
  32. package/date-picker/types.d.ts +2 -2
  33. package/date-picker/utils.d.ts +6 -6
  34. package/dialog/index.js +0 -1
  35. package/dialog/types.d.ts +2 -2
  36. package/emoji/types.d.ts +2 -2
  37. package/emoji/utils.js +0 -4
  38. package/emoji-picker/index.js +1 -3
  39. package/emoji-picker/types.d.ts +4 -4
  40. package/field/types.d.ts +2 -2
  41. package/file-drop/types.d.ts +3 -3
  42. package/file-picker/index.js +0 -1
  43. package/file-picker/types.d.ts +3 -3
  44. package/file-status/types.d.ts +3 -3
  45. package/file-status/utils.d.ts +1 -1
  46. package/flag/types.d.ts +2 -2
  47. package/flag/utils.js +0 -2
  48. package/grid/types.d.ts +2 -2
  49. package/grid-item/types.d.ts +2 -2
  50. package/help-tooltip/types.d.ts +2 -2
  51. package/horizontal-stepper/types.d.ts +2 -2
  52. package/horizontal-stepper-item/types.d.ts +3 -3
  53. package/icon/types.d.ts +2 -2
  54. package/icon-button/types.d.ts +3 -3
  55. package/icon-button/utils.d.ts +1 -1
  56. package/icons/types.d.ts +2 -2
  57. package/icons-branded/types.d.ts +2 -2
  58. package/icons-channel/types.d.ts +2 -2
  59. package/illustrations/types.d.ts +4 -4
  60. package/inline-alert/index.d.ts +4 -3
  61. package/inline-alert/index.js +6 -5
  62. package/inline-alert/types.d.ts +3 -3
  63. package/inline-alert/utils.d.ts +1 -1
  64. package/input/index.js +17 -3
  65. package/input/types.d.ts +9 -3
  66. package/input/utils.d.ts +3 -0
  67. package/input/utils.js +6 -1
  68. package/link/types.d.ts +2 -2
  69. package/list/types.d.ts +2 -2
  70. package/list-item/types.d.ts +2 -2
  71. package/logo/types.d.ts +2 -2
  72. package/package.json +10 -9
  73. package/pagination/index.js +0 -6
  74. package/pagination/types.d.ts +2 -2
  75. package/pop/index.js +0 -16
  76. package/pop/types.d.ts +3 -3
  77. package/pop/utils.d.ts +1 -1
  78. package/popover/types.d.ts +3 -3
  79. package/popover/utils.d.ts +2 -2
  80. package/progress/types.d.ts +2 -2
  81. package/radio/types.d.ts +2 -2
  82. package/radio-option/types.d.ts +2 -2
  83. package/rich-text/index.d.ts +12 -0
  84. package/rich-text/index.js +56 -0
  85. package/rich-text/types.d.ts +12 -0
  86. package/rich-text/types.js +1 -0
  87. package/rich-text/utils.d.ts +5 -0
  88. package/rich-text/utils.js +6 -0
  89. package/segment/types.d.ts +2 -2
  90. package/segment-collapse/types.d.ts +2 -2
  91. package/segmented-control/types.d.ts +2 -2
  92. package/segmented-control-option/types.d.ts +2 -2
  93. package/segmented-icon-control/types.d.ts +2 -2
  94. package/segmented-icon-control-option/types.d.ts +2 -2
  95. package/select-button/index.js +1 -1
  96. package/select-button/types.d.ts +2 -2
  97. package/select-menu/index.js +0 -1
  98. package/select-menu/types.d.ts +2 -2
  99. package/select-menu-option/index.js +1 -1
  100. package/select-menu-option/types.d.ts +2 -2
  101. package/spinner/types.d.ts +2 -2
  102. package/table/types.d.ts +2 -2
  103. package/table-body/types.d.ts +2 -2
  104. package/table-cell/types.d.ts +3 -3
  105. package/table-head/types.d.ts +2 -2
  106. package/table-head-cell/types.d.ts +2 -2
  107. package/table-row/types.d.ts +2 -2
  108. package/tabs/types.d.ts +2 -2
  109. package/tabs-icon-option/index.js +1 -1
  110. package/tabs-icon-option/types.d.ts +2 -2
  111. package/tabs-option/index.js +1 -1
  112. package/tabs-option/types.d.ts +2 -2
  113. package/tag/types.d.ts +2 -2
  114. package/text/index.js +1 -3
  115. package/text/types.d.ts +3 -3
  116. package/text/utils.d.ts +1 -1
  117. package/text/utils.js +1 -1
  118. package/textarea/index.js +1 -1
  119. package/textarea/types.d.ts +2 -2
  120. package/theme/fonts.css +33 -0
  121. package/theme/fonts.json +33 -0
  122. package/tile-control/types.d.ts +2 -2
  123. package/tile-control-option/types.d.ts +2 -2
  124. package/time-picker/index.js +0 -4
  125. package/time-picker/types.d.ts +2 -2
  126. package/title/index.js +0 -2
  127. package/title/types.d.ts +4 -4
  128. package/title/utils.d.ts +3 -2
  129. package/title/utils.js +17 -0
  130. package/toast/types.d.ts +3 -3
  131. package/toast/utils.d.ts +1 -1
  132. package/toast-manager/index.js +0 -1
  133. package/toast-manager/types.d.ts +2 -2
  134. package/toggle/types.d.ts +2 -2
  135. package/tooltip/tooltip-state.d.ts +1 -1
  136. package/tooltip/types.d.ts +3 -3
  137. package/tooltip/utils.d.ts +2 -2
  138. package/utils/context.d.ts +5 -5
  139. package/utils/context.js +0 -1
  140. package/utils/countries.d.ts +1 -1
  141. package/utils/dom.d.ts +1 -1
  142. package/utils/index.d.ts +1 -0
  143. package/utils/index.js +2 -1
  144. package/utils/markdown.d.ts +1 -0
  145. package/utils/markdown.js +128 -0
  146. package/utils/rect.js +0 -1
  147. package/utils/size.d.ts +4 -4
  148. package/vertical-stepper/types.d.ts +2 -2
  149. package/vertical-stepper-item/types.d.ts +3 -3
@@ -95,11 +95,9 @@ defineCustomElement('sinch-pagination', class extends NectaryElement {
95
95
  e.stopPropagation();
96
96
  const value = getIntegerAttribute(this, 'value', 0) - 1;
97
97
  const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
98
-
99
98
  if (e.target === this.#$left) {
100
99
  return this.#dispatchChangeEvent(value - 1);
101
100
  }
102
-
103
101
  if (e.target === this.#$right) {
104
102
  return this.#dispatchChangeEvent(value + 1);
105
103
  }
@@ -108,19 +106,15 @@ defineCustomElement('sinch-pagination', class extends NectaryElement {
108
106
  if (btnIndex === FIRST_BTN_INDEX) {
109
107
  return this.#dispatchChangeEvent(0);
110
108
  }
111
-
112
109
  if (btnIndex === this.#$buttons.length - 1) {
113
110
  return this.#dispatchChangeEvent(max - 1);
114
111
  }
115
-
116
112
  if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
117
113
  return this.#dispatchChangeEvent(Math.floor(value / 2));
118
114
  }
119
-
120
115
  if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
121
116
  return this.#dispatchChangeEvent(Math.floor((max - value) / 2 + value));
122
117
  }
123
-
124
118
  return this.#dispatchChangeEvent(btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
125
119
  }
126
120
  };
@@ -1,6 +1,6 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchPaginationElement = HTMLElement & {
3
+ export type TSinchPaginationElement = HTMLElement & {
4
4
  value: number;
5
5
  max: number;
6
6
  readonly prevButtonRect: TRect;
@@ -11,7 +11,7 @@ export declare type TSinchPaginationElement = HTMLElement & {
11
11
  setAttribute(name: 'value', value: string): void;
12
12
  setAttribute(name: 'max', value: string): void;
13
13
  };
14
- export declare type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
14
+ export type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
15
15
  value: number;
16
16
  max: number;
17
17
  /** @deprecated */
package/pop/index.js CHANGED
@@ -146,7 +146,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
146
146
  if (!this.isConnected || this.#isOpen()) {
147
147
  return;
148
148
  }
149
-
150
149
  this.#$targetSlot.addEventListener('blur', this.#stopEventPropagation, true);
151
150
  this.#$focus.style.setProperty('display', 'block');
152
151
  this.#$focus.addEventListener('focus', this.#captureRelatedActiveElement);
@@ -154,7 +153,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
154
153
  this.#$focus.removeEventListener('focus', this.#captureRelatedActiveElement);
155
154
  this.#$focus.style.removeProperty('display');
156
155
  this.#$targetSlot.removeEventListener('blur', this.#stopEventPropagation, true);
157
-
158
156
  this.#$dialog.showModal();
159
157
  this.#$target.setAttribute('aria-expanded', 'true');
160
158
  this.#updateOrientation();
@@ -180,15 +178,12 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
180
178
  const matrix = new DOMMatrixReadOnly(targetElComputedStyle.transform);
181
179
  $targetEl.style.setProperty('transform', matrix.translate(-matrix.e, -matrix.f).toString());
182
180
  }
183
-
184
181
  getFirstSlotElement(this.#$targetSlot)?.setAttribute('slot', 'target-open');
185
-
186
182
  this.#$targetOpenSlot.addEventListener('keydown', this.#onTargetKeydown);
187
183
  if (this.#targetActiveElement !== null) {
188
184
  this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
189
185
  this.#targetActiveElement.focus();
190
186
  this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
191
-
192
187
  if (!isElementFocused(this.#targetActiveElement)) {
193
188
  requestAnimationFrame(() => {
194
189
  this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
@@ -198,10 +193,8 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
198
193
  }
199
194
  }
200
195
  }
201
-
202
196
  disableScroll();
203
197
  window.addEventListener('resize', this.#onResize);
204
-
205
198
  this.#dispatchContentVisibility(true);
206
199
  }
207
200
  #onCollapse() {
@@ -209,23 +202,17 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
209
202
  return;
210
203
  }
211
204
  const isNonModal = !this.modal;
212
-
213
205
  this.#dispatchContentVisibility(false);
214
-
215
206
  this.#$targetOpenSlot.removeEventListener('keydown', this.#onTargetKeydown);
216
-
217
207
  if (isNonModal) {
218
208
  this.#targetActiveElement = null;
219
209
  this.#$targetOpenSlot.addEventListener('blur', this.#captureActiveElement, true);
220
210
  }
221
-
222
211
  this.#$dialog.close();
223
212
  this.#$target.setAttribute('aria-expanded', 'false');
224
-
225
213
  if (isNonModal) {
226
214
  this.#$targetOpenSlot.removeEventListener('blur', this.#captureActiveElement, true);
227
215
  }
228
-
229
216
  const targetEl = this.#getFirstTargetElement(this.#$targetOpenSlot);
230
217
  targetEl.style.removeProperty('margin');
231
218
  targetEl.style.removeProperty('position');
@@ -238,13 +225,11 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
238
225
  this.#$target.style.removeProperty('display');
239
226
  this.#$target.style.removeProperty('width');
240
227
  this.#$target.style.removeProperty('height');
241
-
242
228
  if (this.#targetActiveElement !== null) {
243
229
  if (!isElementFocused(this.#targetActiveElement)) {
244
230
  this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
245
231
  this.#targetActiveElement.focus();
246
232
  this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
247
-
248
233
  if (!isElementFocused(this.#targetActiveElement)) {
249
234
  const $targetEl = this.#targetActiveElement;
250
235
  requestAnimationFrame(() => {
@@ -256,7 +241,6 @@ defineCustomElement('sinch-pop', class extends NectaryElement {
256
241
  this.#targetActiveElement = null;
257
242
  }
258
243
  }
259
-
260
244
  enableScroll();
261
245
  this.#resizeThrottle.cancel();
262
246
  window.removeEventListener('resize', this.#onResize);
package/pop/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- export declare type TSinchPopOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'bottom-stretch' | 'top-center' | 'top-stretch' | 'center-right' | 'center-left';
3
- export declare type TSinchPopElement = HTMLElement & {
2
+ export type TSinchPopOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'bottom-stretch' | 'top-center' | 'top-stretch' | 'center-right' | 'center-left';
3
+ export type TSinchPopElement = HTMLElement & {
4
4
  /** Open/close state */
5
5
  open: boolean;
6
6
  /** Orientation, where it *points to* from origin */
@@ -20,7 +20,7 @@ export declare type TSinchPopElement = HTMLElement & {
20
20
  setAttribute(name: 'modal', value: boolean): void;
21
21
  setAttribute(name: 'inset', value: string): void;
22
22
  };
23
- export declare type TSinchPopReact = TSinchElementReact<TSinchPopElement> & {
23
+ export type TSinchPopReact = TSinchElementReact<TSinchPopElement> & {
24
24
  /** Open/close state */
25
25
  open: boolean;
26
26
  /** Orientation, where it *points to* from origin */
package/pop/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { TSinchPopOrientation } from './types';
2
2
  export declare const orientationValues: readonly TSinchPopOrientation[];
3
- declare type TAssertOrientation = (value: string | null) => asserts value is TSinchPopOrientation;
3
+ type TAssertOrientation = (value: string | null) => asserts value is TSinchPopOrientation;
4
4
  export declare const assertOrientation: TAssertOrientation;
5
5
  export declare const disableScroll: () => void;
6
6
  export declare const enableScroll: () => void;
@@ -1,6 +1,6 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- export declare type TSinchPopoverOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom' | 'top';
3
- export declare type TSinchPopoverElement = HTMLElement & {
2
+ export type TSinchPopoverOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom' | 'top';
3
+ export type TSinchPopoverElement = HTMLElement & {
4
4
  /** Open/close state */
5
5
  open: boolean;
6
6
  /** Orientation, where it *points to* from origin */
@@ -22,7 +22,7 @@ export declare type TSinchPopoverElement = HTMLElement & {
22
22
  /** Show tip */
23
23
  setAttribute(name: 'tip', value: ''): void;
24
24
  };
25
- export declare type TSinchPopoverReact = TSinchElementReact<TSinchPopoverElement> & {
25
+ export type TSinchPopoverReact = TSinchElementReact<TSinchPopoverElement> & {
26
26
  /** Open/close state */
27
27
  open: boolean;
28
28
  /** Orientation, where it *points to* from origin */
@@ -1,7 +1,7 @@
1
- import type { TSinchPopOrientation } from '../pop/types';
2
1
  import type { TSinchPopoverOrientation } from './types';
2
+ import type { TSinchPopOrientation } from '../pop/types';
3
3
  export declare const orientationValues: readonly TSinchPopoverOrientation[];
4
4
  export declare const getPopOrientation: (orientation: TSinchPopoverOrientation) => TSinchPopOrientation;
5
- declare type TAssertOrientation = (value: string | null) => asserts value is TSinchPopoverOrientation;
5
+ type TAssertOrientation = (value: string | null) => asserts value is TSinchPopoverOrientation;
6
6
  export declare const assertOrientation: TAssertOrientation;
7
7
  export {};
@@ -1,11 +1,11 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchProgressElement = HTMLElement & {
2
+ export type TSinchProgressElement = HTMLElement & {
3
3
  value: number;
4
4
  detailed: boolean;
5
5
  setAttribute(name: 'value', value: string): void;
6
6
  setAttribute(name: 'detailed', value: ''): void;
7
7
  };
8
- export declare type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
8
+ export type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
9
9
  value: number;
10
10
  detailed?: boolean;
11
11
  'aria-label': string;
package/radio/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchRadioElement = HTMLElement & {
3
+ export type TSinchRadioElement = HTMLElement & {
4
4
  value: string;
5
5
  addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
6
6
  addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
7
7
  setAttribute(name: 'value', value: string): void;
8
8
  };
9
- export declare type TSinchRadioReact = TSinchElementReact<TSinchRadioElement> & {
9
+ export type TSinchRadioReact = TSinchElementReact<TSinchRadioElement> & {
10
10
  value: string;
11
11
  'aria-label': string;
12
12
  /** @deprecated */
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchRadioOptionElement = HTMLElement & {
2
+ export type TSinchRadioOptionElement = HTMLElement & {
3
3
  value: string;
4
4
  checked: boolean;
5
5
  disabled: boolean;
@@ -9,7 +9,7 @@ export declare type TSinchRadioOptionElement = HTMLElement & {
9
9
  setAttribute(name: 'disabled', value: ''): void;
10
10
  setAttribute(name: 'text', value: string): void;
11
11
  };
12
- export declare type TSinchRadioOptionReact = TSinchElementReact<TSinchRadioOptionElement> & {
12
+ export type TSinchRadioOptionReact = TSinchElementReact<TSinchRadioOptionElement> & {
13
13
  value: string;
14
14
  disabled?: boolean;
15
15
  text: string;
@@ -0,0 +1,12 @@
1
+ import '../icons/cancel';
2
+ import type { TSinchRichTextElement, TSinchRichTextReact } from './types';
3
+ declare global {
4
+ namespace JSX {
5
+ interface IntrinsicElements {
6
+ 'sinch-rich-text': TSinchRichTextReact;
7
+ }
8
+ }
9
+ interface HTMLElementTagNameMap {
10
+ 'sinch-rich-text': TSinchRichTextElement;
11
+ }
12
+ }
@@ -0,0 +1,56 @@
1
+ import '../icons/cancel';
2
+ import { defineCustomElement, NectaryElement, getLiteralAttribute, updateLiteralAttribute, getAttribute, updateAttribute, parseMarkdown } from '../utils';
3
+ const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([size="s"]){font:var(--sinch-font-text-s)}:host([size=xs]){font:var(--sinch-font-text-xs)}:host([size=xxs]){font:var(--sinch-font-text-xxs)}.em1{font-style:italic}.em2{font-weight:700}.em3{font-style:italic;font-weight:700}.strikethrough{text-decoration:line-through}.link{color:var(--sinch-color-tropical-500)}.code{border:1px solid var(--sinch-color-border-light);background-color:var(--sinch-color-bg-primary-contrast);padding:0 .25em;border-radius:var(--sinch-shape-radius-xs)}.paragraph{margin:0}.paragraph+.paragraph{margin-top:12px}</style><div id="wrapper"></div>';
4
+ import { assertSize, sizeValues } from './utils';
5
+ const template = document.createElement('template');
6
+ template.innerHTML = templateHTML;
7
+ defineCustomElement('sinch-rich-text', class extends NectaryElement {
8
+ #wrapper;
9
+ constructor() {
10
+ super();
11
+ const shadowRoot = this.attachShadow();
12
+ shadowRoot.appendChild(template.content.cloneNode(true));
13
+ this.#wrapper = shadowRoot.querySelector('#wrapper');
14
+ }
15
+ connectedCallback() {
16
+ this.setAttribute('role', 'paragraph');
17
+ }
18
+ get size() {
19
+ return getLiteralAttribute(this, sizeValues, 'size', 'm');
20
+ }
21
+ set size(value) {
22
+ updateLiteralAttribute(this, sizeValues, 'size', value);
23
+ }
24
+ get text() {
25
+ return getAttribute(this, 'text', '');
26
+ }
27
+ set text(value) {
28
+ updateAttribute(this, 'text', value);
29
+ }
30
+ static get observedAttributes() {
31
+ return ['size', 'text'];
32
+ }
33
+ attributeChangedCallback(name, _, newVal) {
34
+ switch (name) {
35
+ case 'size':
36
+ {
37
+ if ('production' !== 'production') {
38
+ assertSize(newVal);
39
+ }
40
+ break;
41
+ }
42
+ case 'text':
43
+ {
44
+ this.#updateText(newVal);
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ #updateText(text) {
50
+ if (text === null) {
51
+ this.#wrapper.innerHTML = '';
52
+ return;
53
+ }
54
+ this.#wrapper.innerHTML = parseMarkdown(text);
55
+ }
56
+ });
@@ -0,0 +1,12 @@
1
+ import type { TSinchTextType } from '../text/types';
2
+ import type { TSinchElementReact } from '../types';
3
+ export type TSinchRichTextElement = HTMLElement & {
4
+ size: TSinchTextType;
5
+ text: string;
6
+ setAttribute(name: 'size', value: TSinchTextType): void;
7
+ setAttribute(name: 'text', value: string): void;
8
+ };
9
+ export type TSinchRichTextReact = TSinchElementReact<TSinchRichTextElement> & {
10
+ size?: TSinchTextType;
11
+ text: string;
12
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { TSinchTextType } from '../text/types';
2
+ export declare const sizeValues: readonly TSinchTextType[];
3
+ type TAssertSize = (value: string | null) => asserts value is TSinchTextType;
4
+ export declare const assertSize: TAssertSize;
5
+ export {};
@@ -0,0 +1,6 @@
1
+ export const sizeValues = ['m', 's', 'xs', 'xxs'];
2
+ export const assertSize = value => {
3
+ if (value === null || !sizeValues.includes(value)) {
4
+ throw new Error(`sinch-rich-text: invalid "size" attribute: "${value}"`);
5
+ }
6
+ };
@@ -1,6 +1,6 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
2
  import type { TSinchSize } from '../utils/size';
3
- export declare type TSinchSegmentElement = HTMLElement & {
3
+ export type TSinchSegmentElement = HTMLElement & {
4
4
  caption: string;
5
5
  collapsed: boolean;
6
6
  size: TSinchSize;
@@ -9,7 +9,7 @@ export declare type TSinchSegmentElement = HTMLElement & {
9
9
  setAttribute(name: 'collapsed', value: ''): void;
10
10
  setAttribute(name: 'size', value: TSinchSize): void;
11
11
  };
12
- export declare type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
12
+ export type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
13
13
  caption: string;
14
14
  collapsed?: boolean;
15
15
  size?: TSinchSize;
@@ -1,12 +1,12 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchSegmentExpandElement = HTMLElement & {
3
+ export type TSinchSegmentExpandElement = HTMLElement & {
4
4
  value: boolean;
5
5
  addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
6
6
  addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
7
7
  setAttribute(name: 'value', value: string): void;
8
8
  };
9
- export declare type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
9
+ export type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
10
10
  value: boolean;
11
11
  'aria-label': string;
12
12
  /** @deprecated */
@@ -1,11 +1,11 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchSegmentedControlElement = HTMLElement & {
3
+ export type TSinchSegmentedControlElement = HTMLElement & {
4
4
  value: string;
5
5
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
6
6
  setAttribute(name: 'value', value: string): void;
7
7
  };
8
- export declare type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
8
+ export type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
9
9
  value: string;
10
10
  'aria-label': string;
11
11
  /** @deprecated */
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
2
+ export type TSinchSegmentedControlOptionElement = HTMLElement & {
3
3
  value: string;
4
4
  disabled: boolean;
5
5
  text: string;
@@ -9,7 +9,7 @@ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
9
9
  setAttribute(name: 'text', value: string): void;
10
10
  setAttribute(name: 'disabled', value: ''): void;
11
11
  };
12
- export declare type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
12
+ export type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
13
13
  value: string;
14
14
  text: string;
15
15
  disabled?: boolean;
@@ -1,13 +1,13 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchSegmentedIconControlElement = HTMLElement & {
3
+ export type TSinchSegmentedIconControlElement = HTMLElement & {
4
4
  value: string;
5
5
  multiple: boolean;
6
6
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
7
7
  setAttribute(name: 'value', value: string): void;
8
8
  setAttribute(name: 'multiple', value: ''): void;
9
9
  };
10
- export declare type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
10
+ export type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
11
11
  value: string;
12
12
  multiple?: boolean;
13
13
  'aria-label': string;
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
2
+ export type TSinchSegmentedIconControlOptionElement = HTMLElement & {
3
3
  value: string;
4
4
  disabled: boolean;
5
5
  addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
@@ -7,7 +7,7 @@ export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
7
7
  setAttribute(name: 'value', value: string): void;
8
8
  setAttribute(name: 'disabled', value: ''): void;
9
9
  };
10
- export declare type TSinchSegmentedIconControlOptionReact = TSinchElementReact<TSinchSegmentedIconControlOptionElement> & {
10
+ export type TSinchSegmentedIconControlOptionReact = TSinchElementReact<TSinchSegmentedIconControlOptionElement> & {
11
11
  value: string;
12
12
  disabled?: boolean;
13
13
  'aria-label': string;
@@ -2,7 +2,7 @@ import '../text';
2
2
  import '../icons/keyboard-arrow-down';
3
3
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute, Context } from '../utils';
4
4
  import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
5
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="l"]){--sinch-size:var(--sinch-size-l);--sinch-size-icon:var(--sinch-select-button-icon-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l)}:host([data-size="m"]){--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="s"]){--sinch-size:var(--sinch-size-s);--sinch-size-icon:var(--sinch-select-button-icon-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s)}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-size);padding:0 8px 0 12px;background-color:var(--sinch-color-bg-primary-light);border-radius:var(--sinch-shape-radius);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([disabled]:not([disabled=false])) #wrapper{--sinch-color-icon:var(--sinch-color-text-disabled)}:host([data-size="l"]) #wrapper{padding:0 12px}:host([data-size="m"]) #wrapper{padding:0 8px 0 12px}:host([data-size="s"]) #wrapper{padding:0 4px 0 12px}#button{all:initial;cursor:pointer;position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}#border{position:absolute;border:1px solid var(--sinch-color-border-dark);border-radius:var(--sinch-shape-radius);inset:0;pointer-events:none}#text{flex:1;min-width:0;color:var(--sinch-color-text-muted)}:host([text]:not([text=""])) #text{color:var(--sinch-color-text-default)}#button:disabled{cursor:initial}#button:disabled+#border{border-color:var(--sinch-color-border-disabled)}#button:focus-visible+#border{border-color:var(--sinch-color-border-focus);border-width:2px}:host([invalid]) #button:enabled+#border{border-color:var(--sinch-color-text-invalid)}#button:disabled~#text{color:var(--sinch-color-text-disabled)}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;margin-left:-4px}#left.empty{display:none}#dropdown-icon{margin-left:-4px}</style><div id="wrapper"><button id="button"></button><div id="border"></div><div id="left"><slot name="left"></slot></div><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></div>';
5
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="l"]){--sinch-size:var(--sinch-size-l);--sinch-size-icon:var(--sinch-select-button-icon-size-l);--sinch-shape-radius:var(--sinch-shape-radius-l)}:host([data-size="m"]){--sinch-size:var(--sinch-size-m);--sinch-size-icon:var(--sinch-select-button-icon-size-m);--sinch-shape-radius:var(--sinch-shape-radius-m)}:host([data-size="s"]){--sinch-size:var(--sinch-size-s);--sinch-size-icon:var(--sinch-select-button-icon-size-s);--sinch-shape-radius:var(--sinch-shape-radius-s)}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-size);padding:0 8px 0 12px;background-color:var(--sinch-color-bg-primary-light);border-radius:var(--sinch-shape-radius);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([data-size="l"]) #wrapper{padding:0 12px}:host([data-size="m"]) #wrapper{padding:0 8px 0 12px}:host([data-size="s"]) #wrapper{padding:0 4px 0 12px}:host([disabled]:not([disabled=false])) #wrapper{--sinch-color-icon:var(--sinch-color-text-disabled)}#button{all:initial;cursor:pointer;position:absolute;left:0;top:0;width:100%;height:100%;z-index:1}#border{position:absolute;border:1px solid var(--sinch-color-border-dark);border-radius:var(--sinch-shape-radius);inset:0;pointer-events:none}#text{flex:1;min-width:0;color:var(--sinch-color-text-muted)}:host([text]:not([text=""])) #text{color:var(--sinch-color-text-default)}#button:disabled{cursor:initial}#button:disabled+#border{border-color:var(--sinch-color-border-disabled)}#button:focus-visible+#border{border-color:var(--sinch-color-border-focus);border-width:2px}:host([invalid]) #button:enabled+#border{border-color:var(--sinch-color-text-invalid)}#button:disabled~#text{color:var(--sinch-color-text-disabled)}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;margin-left:-4px}#left.empty{display:none}#dropdown-icon{margin-left:-4px}</style><div id="wrapper"><button id="button"></button><div id="border"></div><div id="left"><slot name="left"></slot></div><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></div>';
6
6
  const template = document.createElement('template');
7
7
  template.innerHTML = templateHTML;
8
8
  defineCustomElement('sinch-select-button', class extends NectaryElement {
@@ -1,6 +1,6 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { TSinchSize } from '../utils/size';
3
- export declare type TSinchSelectButtonElement = HTMLElement & {
3
+ export type TSinchSelectButtonElement = HTMLElement & {
4
4
  /** Text */
5
5
  text: string;
6
6
  /** Text that appears in the text field when it has no text set */
@@ -28,7 +28,7 @@ export declare type TSinchSelectButtonElement = HTMLElement & {
28
28
  /** Size, `m` by default */
29
29
  setAttribute(name: 'size', value: TSinchSize): void;
30
30
  };
31
- export declare type TSinchSelectButtonReact = TSinchElementReact<TSinchSelectButtonElement> & {
31
+ export type TSinchSelectButtonReact = TSinchElementReact<TSinchSelectButtonElement> & {
32
32
  /** Text */
33
33
  text: string;
34
34
  /** Label that is used for a11y` */
@@ -251,7 +251,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
251
251
  const hasRows = this.hasAttribute('rows');
252
252
  for (const $op of this.#getOptionElements()) {
253
253
  const isSelected = $op === $option;
254
-
255
254
  updateBooleanAttribute($op, 'data-selected', isSelected);
256
255
  if (isSelected && hasRows) {
257
256
  $op.scrollIntoView?.({
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchSelectMenuElement = HTMLElement & {
2
+ export type TSinchSelectMenuElement = HTMLElement & {
3
3
  /** Selected value, CSV when multiple */
4
4
  value: string;
5
5
  /** How many rows to show and scroll the rest */
@@ -15,7 +15,7 @@ export declare type TSinchSelectMenuElement = HTMLElement & {
15
15
  /** Allows multiple selection */
16
16
  setAttribute(name: 'multiple', value: ''): void;
17
17
  };
18
- export declare type TSinchSelectMenuReact = TSinchElementReact<TSinchSelectMenuElement> & {
18
+ export type TSinchSelectMenuReact = TSinchElementReact<TSinchSelectMenuElement> & {
19
19
  /** Selected value, CSV when multiple */
20
20
  value: string;
21
21
  /** How many rows to show and scroll the rest */
@@ -1,7 +1,7 @@
1
1
  import '../icons/check';
2
2
  import '../text';
3
3
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
4
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;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:1}:host(:hover:not([disabled]))>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-400)}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled])>#wrapper{cursor:initial;color:var(--sinch-color-text-disabled);--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text><sinch-icon-check id="check"></sinch-icon-check></div>';
4
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;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:1}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled])>#wrapper{cursor:initial;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><sinch-icon-check id="check"></sinch-icon-check></div>';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  export class SelectMenuOption extends NectaryElement {
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchSelectMenuOptionElement = HTMLElement & {
2
+ export type TSinchSelectMenuOptionElement = HTMLElement & {
3
3
  /** Value */
4
4
  value: string;
5
5
  /** Display text */
@@ -14,7 +14,7 @@ export declare type TSinchSelectMenuOptionElement = HTMLElement & {
14
14
  /** Disabled state */
15
15
  setAttribute(name: 'disabled', value: ''): void;
16
16
  };
17
- export declare type TSinchSelectMenuOptionReact = TSinchElementReact<TSinchSelectMenuOptionElement> & {
17
+ export type TSinchSelectMenuOptionReact = TSinchElementReact<TSinchSelectMenuOptionElement> & {
18
18
  /** Value */
19
19
  value: string;
20
20
  /** Display text */
@@ -1,9 +1,9 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { TSinchSize } from '../utils/size';
3
- export declare type TSinchSpinnerElement = HTMLElement & {
3
+ export type TSinchSpinnerElement = HTMLElement & {
4
4
  size: TSinchSize;
5
5
  setAttribute(name: 'size', value: TSinchSize): void;
6
6
  };
7
- export declare type TSinchSpinnerReact = TSinchElementReact<TSinchSpinnerElement> & {
7
+ export type TSinchSpinnerReact = TSinchElementReact<TSinchSpinnerElement> & {
8
8
  size?: TSinchSize;
9
9
  };
package/table/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchTableElement = HTMLElement;
3
- export declare type TSinchTableReact = TSinchElementReact<TSinchTableElement>;
2
+ export type TSinchTableElement = HTMLElement;
3
+ export type TSinchTableReact = TSinchElementReact<TSinchTableElement>;
@@ -1,3 +1,3 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchTableBodyElement = HTMLElement;
3
- export declare type TSinchTableBodyReact = TSinchElementReact<TSinchTableBodyElement>;
2
+ export type TSinchTableBodyElement = HTMLElement;
3
+ export type TSinchTableBodyReact = TSinchElementReact<TSinchTableBodyElement>;
@@ -1,9 +1,9 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchTableAlignType = 'start' | 'center' | 'end';
3
- export declare type TSinchTableCellElement = HTMLElement & {
2
+ export type TSinchTableAlignType = 'start' | 'center' | 'end';
3
+ export type TSinchTableCellElement = HTMLElement & {
4
4
  align: TSinchTableAlignType;
5
5
  setAttribute(name: 'align', value: TSinchTableAlignType): void;
6
6
  };
7
- export declare type TSinchTableCellReact = TSinchElementReact<TSinchTableCellElement> & {
7
+ export type TSinchTableCellReact = TSinchElementReact<TSinchTableCellElement> & {
8
8
  align?: TSinchTableAlignType;
9
9
  };
@@ -1,3 +1,3 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchTableHeadElement = HTMLElement;
3
- export declare type TSinchTableHeadReact = TSinchElementReact<TSinchTableHeadElement>;
2
+ export type TSinchTableHeadElement = HTMLElement;
3
+ export type TSinchTableHeadReact = TSinchElementReact<TSinchTableHeadElement>;
@@ -1,6 +1,6 @@
1
1
  import type { TSinchTableAlignType } from '../table-cell/types';
2
2
  import type { TSinchElementReact } from '../types';
3
- export declare type TSinchTableHeaderCellElement = HTMLElement & {
3
+ export type TSinchTableHeaderCellElement = HTMLElement & {
4
4
  text: string | null;
5
5
  align: TSinchTableAlignType;
6
6
  fit: boolean;
@@ -8,7 +8,7 @@ export declare type TSinchTableHeaderCellElement = HTMLElement & {
8
8
  setAttribute(name: 'align', value: TSinchTableAlignType): void;
9
9
  setAttribute(name: 'fit', value: ''): void;
10
10
  };
11
- export declare type TSinchTableHeaderCellReact = TSinchElementReact<TSinchTableHeaderCellElement> & {
11
+ export type TSinchTableHeaderCellReact = TSinchElementReact<TSinchTableHeaderCellElement> & {
12
12
  text?: string;
13
13
  fit?: boolean;
14
14
  align?: TSinchTableAlignType;
@@ -1,11 +1,11 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchTableRowElement = HTMLElement & {
2
+ export type TSinchTableRowElement = HTMLElement & {
3
3
  sticky: boolean;
4
4
  selected: boolean;
5
5
  setAttribute(name: 'sticky', value: ''): void;
6
6
  setAttribute(name: 'selected', value: ''): void;
7
7
  };
8
- export declare type TSinchTableRowReact = TSinchElementReact<TSinchTableRowElement> & {
8
+ export type TSinchTableRowReact = TSinchElementReact<TSinchTableRowElement> & {
9
9
  sticky?: boolean;
10
10
  selected?: boolean;
11
11
  };