@nectary/components 2.0.0 → 2.1.1

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 (97) hide show
  1. package/accordion/index.js +0 -4
  2. package/action-menu/index.js +5 -1
  3. package/action-menu-option/index.js +2 -4
  4. package/alert/index.js +2 -9
  5. package/alert/utils.d.ts +0 -3
  6. package/alert/utils.js +1 -6
  7. package/avatar/index.js +4 -20
  8. package/avatar/utils.d.ts +0 -4
  9. package/avatar/utils.js +0 -13
  10. package/badge/index.js +2 -8
  11. package/badge/utils.d.ts +0 -3
  12. package/badge/utils.js +1 -6
  13. package/button/index.js +25 -27
  14. package/button/utils.d.ts +0 -3
  15. package/button/utils.js +1 -9
  16. package/chat-bubble/index.d.ts +0 -1
  17. package/chat-bubble/index.js +1 -2
  18. package/checkbox/index.js +6 -9
  19. package/chip/index.js +22 -19
  20. package/chip/utils.d.ts +0 -1
  21. package/chip/utils.js +0 -5
  22. package/color-menu/index.js +6 -3
  23. package/color-swatch/index.js +1 -4
  24. package/color-swatch/utils.d.ts +0 -1
  25. package/color-swatch/utils.js +0 -5
  26. package/date-picker/index.js +1 -27
  27. package/date-picker/utils.d.ts +0 -8
  28. package/date-picker/utils.js +0 -20
  29. package/dialog/index.js +1 -2
  30. package/emoji-picker/index.js +7 -14
  31. package/file-picker/index.js +11 -9
  32. package/file-status/index.js +2 -9
  33. package/file-status/utils.d.ts +0 -3
  34. package/file-status/utils.js +1 -6
  35. package/help-tooltip/index.d.ts +0 -1
  36. package/help-tooltip/index.js +1 -2
  37. package/icon/index.js +1 -1
  38. package/icon-button/index.js +23 -27
  39. package/icon-button/utils.d.ts +0 -3
  40. package/icon-button/utils.js +1 -9
  41. package/inline-alert/index.js +2 -9
  42. package/inline-alert/utils.d.ts +0 -3
  43. package/inline-alert/utils.js +1 -6
  44. package/input/index.js +10 -16
  45. package/input/utils.d.ts +0 -3
  46. package/input/utils.js +1 -6
  47. package/package.json +2 -3
  48. package/pagination/index.js +0 -4
  49. package/pagination/types.d.ts +0 -1
  50. package/pop/index.js +23 -25
  51. package/pop/utils.d.ts +0 -3
  52. package/pop/utils.js +0 -5
  53. package/popover/index.js +1 -4
  54. package/popover/utils.d.ts +0 -3
  55. package/popover/utils.js +0 -5
  56. package/radio/index.js +0 -4
  57. package/radio/types.d.ts +0 -1
  58. package/rich-text/index.js +2 -9
  59. package/rich-text/utils.d.ts +0 -3
  60. package/rich-text/utils.js +1 -6
  61. package/segment/index.js +1 -4
  62. package/segment-collapse/index.js +0 -4
  63. package/segment-collapse/types.d.ts +0 -1
  64. package/segmented-control/index.js +0 -4
  65. package/segmented-icon-control/index.js +0 -4
  66. package/select-button/index.js +23 -20
  67. package/select-menu/index.js +6 -3
  68. package/skeleton/index.js +45 -9
  69. package/skeleton-item/index.js +1 -28
  70. package/spinner/index.js +2 -9
  71. package/tabs/index.js +0 -4
  72. package/tag/index.js +1 -4
  73. package/tag/utils.d.ts +0 -1
  74. package/tag/utils.js +0 -5
  75. package/text/index.js +2 -9
  76. package/text/utils.d.ts +0 -3
  77. package/text/utils.js +1 -6
  78. package/textarea/index.js +0 -4
  79. package/tile-control/index.js +0 -4
  80. package/time-picker/index.js +1 -9
  81. package/time-picker/utils.d.ts +1 -1
  82. package/time-picker/utils.js +17 -5
  83. package/title/index.js +2 -12
  84. package/title/utils.d.ts +0 -7
  85. package/title/utils.js +1 -29
  86. package/toast/index.js +2 -9
  87. package/toast/utils.d.ts +0 -3
  88. package/toast/utils.js +1 -6
  89. package/toggle/index.js +0 -4
  90. package/toggle/types.d.ts +0 -1
  91. package/tooltip/index.js +1 -7
  92. package/tooltip/utils.d.ts +0 -5
  93. package/tooltip/utils.js +0 -10
  94. package/utils/dom.js +0 -5
  95. package/utils/element.js +2 -2
  96. package/utils/size.d.ts +0 -5
  97. package/utils/size.js +1 -17
package/skeleton/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineCustomElement, getUid, isAttrTrue, NectaryElement, shouldReduceMotion } from '../utils';
1
+ import { attrValueToInteger, defineCustomElement, getCssVar, getUid, isAttrTrue, NectaryElement, shouldReduceMotion } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;height:100%;box-sizing:border-box;overflow:hidden}:host([card]:not([card=false]))>#wrapper{padding:16px;background-color:var(--sinch-sys-color-container-main-default);border-radius:var(--sinch-sys-shape-radius-l);border:1px solid var(--sinch-sys-color-border-light)}#shimmer{position:absolute;inset:0;background-image:linear-gradient(90deg,transparent 0,var(--sinch-sys-color-container-contrast-primary-default) 100px,transparent 200px);clip-path:url("#clip")}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"></div></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
@@ -7,14 +7,20 @@ const BORDER_WIDTH = 1;
7
7
  defineCustomElement('sinch-skeleton', class extends NectaryElement {
8
8
  #animation = null;
9
9
  #shimmer;
10
+ #wrapper;
11
+ #slot;
10
12
  #controller = null;
11
13
  #clip;
12
14
  #borderWidth = 0;
15
+ #bb = null;
16
+ #observer = null;
13
17
  constructor() {
14
18
  super();
15
19
  const shadowRoot = this.attachShadow();
16
20
  shadowRoot.appendChild(template.content.cloneNode(true));
17
21
  this.#shimmer = shadowRoot.querySelector('#shimmer');
22
+ this.#slot = shadowRoot.querySelector('slot');
23
+ this.#wrapper = shadowRoot.querySelector('#wrapper');
18
24
  this.#clip = shadowRoot.querySelector('#clip');
19
25
  }
20
26
  connectedCallback() {
@@ -23,10 +29,24 @@ defineCustomElement('sinch-skeleton', class extends NectaryElement {
23
29
  this.#clip.setAttribute('id', id);
24
30
  this.#controller = new AbortController();
25
31
  if (!shouldReduceMotion()) {
26
- this.addEventListener('skeleton-item-data', this.#onSkeletonItemData, {
32
+ this.#slot.addEventListener('slotchange', this.#onSlotChange, {
27
33
  signal: this.#controller.signal
28
34
  });
29
- this.#updateAnimation();
35
+ this.#observer = new IntersectionObserver(entries => {
36
+ this.#bb = entries[0].boundingClientRect;
37
+ if (this.#bb.width === 0) {
38
+ return;
39
+ }
40
+ this.#updateAnimation();
41
+ for (const child of this.#slot.assignedElements()) {
42
+ this.#handleSkeletonItemData(child);
43
+ }
44
+ this.#observer.disconnect();
45
+ this.#observer = null;
46
+ }, {
47
+ threshold: 1
48
+ });
49
+ this.#observer.observe(this.#wrapper);
30
50
  }
31
51
  }
32
52
  disconnectedCallback() {
@@ -34,6 +54,8 @@ defineCustomElement('sinch-skeleton', class extends NectaryElement {
34
54
  this.#animation = null;
35
55
  this.#controller.abort();
36
56
  this.#controller = null;
57
+ this.#observer?.disconnect();
58
+ this.#observer = null;
37
59
  }
38
60
  static get observedAttributes() {
39
61
  return ['card'];
@@ -51,7 +73,7 @@ defineCustomElement('sinch-skeleton', class extends NectaryElement {
51
73
  }
52
74
  }
53
75
  #updateAnimation() {
54
- const bb = this.getBoundingClientRect();
76
+ const bb = this.#bb;
55
77
  const bgWidth = bb.width * 4;
56
78
  this.#shimmer.style.setProperty('background-size', `${bgWidth}px`);
57
79
  this.#animation = this.#shimmer.animate({
@@ -61,15 +83,29 @@ defineCustomElement('sinch-skeleton', class extends NectaryElement {
61
83
  iterations: Infinity
62
84
  });
63
85
  }
64
- #onSkeletonItemData = e => {
65
- const bb = this.getBoundingClientRect();
66
- const data = e.detail;
86
+ #onSlotChange = () => {
87
+ this.#clip.innerHTML = '';
88
+ if (this.#bb === null) {
89
+ return;
90
+ }
91
+ for (const child of this.#slot.assignedElements()) {
92
+ this.#handleSkeletonItemData(child);
93
+ }
94
+ };
95
+ #handleSkeletonItemData(child) {
96
+ const data = child.getBoundingClientRect();
97
+ const radiusStr = getCssVar(child, '--sinch-local-shape-radius') ?? '0';
98
+ const radius = attrValueToInteger(radiusStr, {
99
+ min: 0,
100
+ defaultValue: 0
101
+ });
102
+ const bb = this.#bb;
67
103
  const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
68
104
  rect.setAttribute('x', (data.x - bb.x - this.#borderWidth).toString());
69
105
  rect.setAttribute('y', (data.y - bb.y - this.#borderWidth).toString());
70
106
  rect.setAttribute('width', data.width.toString());
71
107
  rect.setAttribute('height', data.height.toString());
72
- rect.setAttribute('rx', data.radius.toString());
108
+ rect.setAttribute('rx', radius.toString());
73
109
  this.#clip.appendChild(rect);
74
- };
110
+ }
75
111
  });
@@ -1,4 +1,4 @@
1
- import { defineCustomElement, getCssVar, NectaryElement, attrValueToInteger, shouldReduceMotion } from '../utils';
1
+ import { defineCustomElement, NectaryElement } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block;height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size=xs]){height:var(--sinch-sys-size-xs);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs)}:host([size="s"]){height:var(--sinch-sys-size-s);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s)}:host([size="m"]){height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size="l"]){height:var(--sinch-sys-size-l);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l)}#content{height:100%;background-color:var(--sinch-sys-color-border-light);border-radius:var(--sinch-local-shape-radius)}</style><div id="content"></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
@@ -8,31 +8,4 @@ defineCustomElement('sinch-skeleton-item', class extends NectaryElement {
8
8
  const shadowRoot = this.attachShadow();
9
9
  shadowRoot.appendChild(template.content.cloneNode(true));
10
10
  }
11
- connectedCallback() {
12
- if (!shouldReduceMotion()) {
13
- requestAnimationFrame(() => {
14
- const {
15
- x,
16
- y,
17
- width,
18
- height
19
- } = this.getBoundingClientRect();
20
- const radiusStr = getCssVar(this, '--sinch-shape-radius') ?? '0';
21
- const radius = attrValueToInteger(radiusStr, {
22
- min: 0,
23
- defaultValue: 0
24
- });
25
- this.dispatchEvent(new CustomEvent('skeleton-item-data', {
26
- bubbles: true,
27
- detail: {
28
- x,
29
- y,
30
- width,
31
- height,
32
- radius
33
- }
34
- }));
35
- });
36
- }
37
- }
38
11
  });
package/spinner/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getLiteralAttribute, NectaryElement, subscribeContext, updateAttribute, updateLiteralAttribute } from '../utils';
2
- import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
2
+ import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
3
  const templateHTML = '<style>@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}:host{display:block}#spinner-size-l,#spinner-size-m,#spinner-size-s{display:none;will-change:transform}:host([data-size="l"])>#spinner-size-l{display:block;animation:1s linear infinite spinner}:host([data-size="m"])>#spinner-size-m{display:block;animation:1s linear infinite spinner}:host([data-size="s"])>#spinner-size-s{display:block;animation:1s linear infinite spinner}.bg{opacity:.3;stroke:var(--sinch-global-color-icon,var(--sinch-sys-color-text-default))}.fg{stroke:var(--sinch-global-color-icon,var(--sinch-sys-color-text-default))}</style><svg id="spinner-size-l" width="50" height="50" fill="none"><circle class="bg" cx="25" cy="25" r="22" stroke-width="6"/><path class="fg" d="M25 3a22 22 0 0 1 22 22" stroke-width="6" stroke-linecap="round"/></svg><svg id="spinner-size-m" width="24" height="24" fill="none"><circle class="bg" cx="12" cy="12" r="9" stroke-width="4"/><path class="fg" d="M21 12a9 9 0 0 0-9-9" stroke-width="4" stroke-linecap="round"/></svg><svg id="spinner-size-s" width="16" height="16" fill="none"><circle class="bg" cx="8" cy="8" r="6" stroke-width="2"/><path class="fg" d="M14 8a6 6 0 0 0-6-6" stroke-width="2" stroke-linecap="round"/></svg>';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
@@ -20,7 +20,7 @@ defineCustomElement('sinch-spinner', class extends NectaryElement {
20
20
  this.#controller.abort();
21
21
  }
22
22
  static get observedAttributes() {
23
- return ['size', 'data-size'];
23
+ return ['size'];
24
24
  }
25
25
  attributeChangedCallback(name, oldVal, newVal) {
26
26
  if (oldVal === newVal) {
@@ -32,13 +32,6 @@ defineCustomElement('sinch-spinner', class extends NectaryElement {
32
32
  updateAttribute(this, 'data-size', newVal);
33
33
  break;
34
34
  }
35
- case 'data-size':
36
- {
37
- if ('production' !== 'production') {
38
- assertSize(newVal, 'sinch-spinner');
39
- }
40
- break;
41
- }
42
35
  }
43
36
  }
44
37
  set size(size) {
package/tabs/index.js CHANGED
@@ -69,10 +69,6 @@ defineCustomElement('sinch-tabs', class extends NectaryElement {
69
69
  }
70
70
  }
71
71
  #dispatchChangeEvent(value) {
72
- this.dispatchEvent(new CustomEvent('change', {
73
- detail: value,
74
- bubbles: true
75
- }));
76
72
  this.dispatchEvent(new CustomEvent('-change', {
77
73
  detail: value
78
74
  }));
package/tag/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import '../text';
2
2
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue } from '../utils';
3
3
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:var(--sinch-comp-tag-size-container-m);padding:0 9px;border-radius:var(--sinch-comp-tag-shape-radius);background-color:var(--sinch-comp-tag-color-default-background);box-sizing:border-box;user-select:none;--sinch-global-color-text:var(--sinch-comp-tag-color-default-foreground);--sinch-global-color-icon:var(--sinch-comp-tag-color-default-foreground);--sinch-global-size-icon:var(--sinch-comp-tag-size-icon-m)}:host([small]) #wrapper{height:var(--sinch-comp-tag-size-container-s);padding:0 8px;--sinch-global-size-icon:var(--sinch-comp-tag-size-icon-s)}#text{flex:1;--sinch-comp-text-font:var(--sinch-comp-tag-font-size-m-label)}:host([small]) #text{--sinch-comp-text-font:var(--sinch-comp-tag-font-size-s-label)}::slotted(*){margin-left:-4px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="text" type="s" ellipsis></sinch-text></div>';
4
- import { assertTagColor, getTagColorBg, getTagColorFg } from './utils';
4
+ import { getTagColorBg, getTagColorFg } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  defineCustomElement('sinch-tag', class extends NectaryElement {
@@ -67,9 +67,6 @@ defineCustomElement('sinch-tag', class extends NectaryElement {
67
67
  }
68
68
  const colorName = this.color;
69
69
  if (colorName !== null && colorName.length > 0) {
70
- if ('production' !== 'production') {
71
- assertTagColor(this, colorName);
72
- }
73
70
  const bg = getTagColorBg(colorName);
74
71
  const fg = getTagColorFg(colorName);
75
72
  this.#$wrapper.style.setProperty('background-color', bg);
package/tag/utils.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export declare const getTagColorBg: (id: string) => string;
2
2
  export declare const getTagColorFg: (id: string) => string;
3
- export declare const assertTagColor: (root: Element, id: string | null) => void;
package/tag/utils.js CHANGED
@@ -3,9 +3,4 @@ export const getTagColorBg = id => {
3
3
  };
4
4
  export const getTagColorFg = id => {
5
5
  return `var(--sinch-comp-tag-color-${id}-foreground)`;
6
- };
7
- export const assertTagColor = (root, id) => {
8
- if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-comp-tag-color-${id}-background`).length === 0) {
9
- throw new Error(`Invalid sinch-tag color name: ${id}`);
10
- }
11
6
  };
package/text/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block;font:var(--sinch-comp-text-font);color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));--sinch-comp-text-font:var(--sinch-sys-font-body-m)}:host([inline]){display:inline}:host([type="s"]){--sinch-comp-text-font:var(--sinch-sys-font-body-s)}:host([type=xs]){--sinch-comp-text-font:var(--sinch-sys-font-body-xs)}:host([type=xxs]){--sinch-comp-text-font:var(--sinch-sys-font-body-xxs)}:host([type="m"][emphasized]){--sinch-comp-text-font:var(--sinch-sys-font-body-emphasize)}:host([type="s"][emphasized]){--sinch-comp-text-font:var(--sinch-sys-font-body-emphasize-s)}:host([ellipsis]){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;--sinch-global-text-white-space:nowrap}</style><slot></slot>';
3
- import { assertType, typeValues } from './utils';
3
+ import { typeValues } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
6
6
  defineCustomElement('sinch-text', class extends NectaryElement {
@@ -13,17 +13,10 @@ defineCustomElement('sinch-text', class extends NectaryElement {
13
13
  this.#updateRole();
14
14
  }
15
15
  static get observedAttributes() {
16
- return ['type', 'inline', 'ellipsis', 'emphasized'];
16
+ return ['inline', 'ellipsis', 'emphasized'];
17
17
  }
18
18
  attributeChangedCallback(name, _, newVal) {
19
19
  switch (name) {
20
- case 'type':
21
- {
22
- if ('production' !== 'production') {
23
- assertType(newVal);
24
- }
25
- break;
26
- }
27
20
  case 'inline':
28
21
  {
29
22
  this.#updateRole();
package/text/utils.d.ts CHANGED
@@ -1,5 +1,2 @@
1
1
  import type { TSinchTextType } from './types';
2
2
  export declare const typeValues: readonly TSinchTextType[];
3
- type TAssertType = (value: string | null) => asserts value is TSinchTextType;
4
- export declare const assertType: TAssertType;
5
- export {};
package/text/utils.js CHANGED
@@ -1,6 +1 @@
1
- export const typeValues = ['m', 's', 'xs', 'xxs'];
2
- export const assertType = value => {
3
- if (value === null || !typeValues.includes(value)) {
4
- throw new Error(`sinch-text: invalid "type" attribute: "${value}"`);
5
- }
6
- };
1
+ export const typeValues = ['m', 's', 'xs', 'xxs'];
package/textarea/index.js CHANGED
@@ -185,10 +185,6 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
185
185
  }
186
186
  this.#isPendingDk = false;
187
187
  this.#cursorPos = nextCursorPos;
188
- this.dispatchEvent(new CustomEvent('change', {
189
- detail: nextValue,
190
- bubbles: true
191
- }));
192
188
  this.dispatchEvent(new CustomEvent('-change', {
193
189
  detail: nextValue
194
190
  }));
@@ -79,10 +79,6 @@ defineCustomElement('sinch-tile-control', class extends NectaryElement {
79
79
  const $elem = e.target;
80
80
  const value = e.detail;
81
81
  const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
82
- this.dispatchEvent(new CustomEvent('change', {
83
- detail,
84
- bubbles: true
85
- }));
86
82
  this.dispatchEvent(new CustomEvent('-change', {
87
83
  detail
88
84
  }));
@@ -97,7 +97,7 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
97
97
  signal: this.#controller.signal
98
98
  };
99
99
  this.#$pickerTouch.addEventListener('click', this.#onPickerClick, options);
100
- this.#$ampm.addEventListener('change', this.#onAmPmChange, options);
100
+ this.#$ampm.addEventListener('-change', this.#onAmPmChange, options);
101
101
  this.#$submitButton.addEventListener('click', this.#onSubmitButtonClick, options);
102
102
  this.#$needleHour.addEventListener('keydown', this.#onHoursKeydown, options);
103
103
  this.#$needleMinute.addEventListener('keydown', this.#onMinutesKeydown, options);
@@ -116,9 +116,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
116
116
  switch (name) {
117
117
  case 'value':
118
118
  {
119
- if (newVal === null) {
120
- throw new Error('Missing "value" attribute');
121
- }
122
119
  const {
123
120
  hours,
124
121
  minutes
@@ -272,7 +269,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
272
269
  this.#$needleMinute.style.transform = `rotate(${minuteCssDeg}deg)`;
273
270
  }
274
271
  #onAmPmChange = e => {
275
- e.stopPropagation();
276
272
  const value = e.detail;
277
273
  switch (value) {
278
274
  case 'am':
@@ -295,10 +291,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
295
291
  };
296
292
  #onSubmitButtonClick = () => {
297
293
  const value = stringifyTime(this.#hour, this.#minute);
298
- this.dispatchEvent(new CustomEvent('change', {
299
- bubbles: true,
300
- detail: value
301
- }));
302
294
  this.dispatchEvent(new CustomEvent('-change', {
303
295
  detail: value
304
296
  }));
@@ -1,4 +1,4 @@
1
- export declare const parseTime: (value: string) => {
1
+ export declare const parseTime: (value: string | null) => {
2
2
  hours: number;
3
3
  minutes: number;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  export const parseTime = value => {
2
- if (value === '') {
2
+ if (value === '' || value === null) {
3
3
  return {
4
4
  hours: 0,
5
5
  minutes: 0
@@ -7,19 +7,31 @@ export const parseTime = value => {
7
7
  }
8
8
  const timeParts = value.split(':');
9
9
  if (timeParts.length < 3) {
10
- throw new Error(`Incorrect time format: ${value}. Should be "hh:mm:ss"`);
10
+ return {
11
+ hours: 0,
12
+ minutes: 0
13
+ };
11
14
  }
12
15
  const hours = parseInt(timeParts[0]);
13
16
  const minutes = parseInt(timeParts[1]);
14
17
  const seconds = parseInt(timeParts[2]);
15
18
  if (isNaN(hours) || hours > 23 || hours < 0) {
16
- throw new Error(`Invalid hours value: ${value}`);
19
+ return {
20
+ hours: 0,
21
+ minutes: 0
22
+ };
17
23
  }
18
24
  if (isNaN(minutes) || minutes > 59 || minutes < 0) {
19
- throw new Error(`Invalid minutes value: ${value}`);
25
+ return {
26
+ hours: 0,
27
+ minutes: 0
28
+ };
20
29
  }
21
30
  if (isNaN(seconds) || seconds > 59 || seconds < 0) {
22
- throw new Error(`Invalid seconds value: ${value}`);
31
+ return {
32
+ hours: 0,
33
+ minutes: 0
34
+ };
23
35
  }
24
36
  return {
25
37
  hours,
package/title/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block;--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type=xl]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xl)}:host([type="l"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-l)}:host([type="m"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type="s"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-s)}:host([type=xs]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xs)}#text{letter-spacing:-2%;color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));font:var(--sinch-comp-title-font)}:host([ellipsis]) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
3
- import { assertLevel, assertType, typeValues } from './utils';
3
+ import { typeValues } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
6
6
  defineCustomElement('sinch-title', class extends NectaryElement {
@@ -15,7 +15,7 @@ defineCustomElement('sinch-title', class extends NectaryElement {
15
15
  this.setAttribute('role', 'heading');
16
16
  }
17
17
  static get observedAttributes() {
18
- return ['text', 'type', 'level', 'ellipsis'];
18
+ return ['text', 'level', 'ellipsis'];
19
19
  }
20
20
  attributeChangedCallback(name, oldVal, newVal) {
21
21
  if (oldVal === newVal) {
@@ -29,19 +29,9 @@ defineCustomElement('sinch-title', class extends NectaryElement {
29
29
  }
30
30
  case 'level':
31
31
  {
32
- if ('production' !== 'production') {
33
- assertLevel(newVal);
34
- }
35
32
  updateAttribute(this, 'aria-level', newVal);
36
33
  break;
37
34
  }
38
- case 'type':
39
- {
40
- if ('production' !== 'production') {
41
- assertType(newVal);
42
- }
43
- break;
44
- }
45
35
  case 'ellipsis':
46
36
  {
47
37
  updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
package/title/utils.d.ts CHANGED
@@ -1,10 +1,3 @@
1
1
  import type { TSinchTitleLevel, TSinchTitleType } from './types';
2
2
  export declare const typeValues: readonly TSinchTitleType[];
3
- export declare const levelValues: readonly TSinchTitleLevel[];
4
- type TAssertLevel = (value: string | null) => asserts value is TSinchTitleLevel;
5
- export declare const assertLevel: TAssertLevel;
6
- type TAssertType = (value: string | null) => asserts value is TSinchTitleType;
7
- export declare const assertType: TAssertType;
8
3
  export declare const getTitleLevelFromType: (type: TSinchTitleType) => TSinchTitleLevel;
9
- export declare const getTitleTypeFromLevel: (level: TSinchTitleLevel) => TSinchTitleType;
10
- export {};
package/title/utils.js CHANGED
@@ -1,15 +1,4 @@
1
1
  export const typeValues = ['xl', 'l', 'm', 's', 'xs'];
2
- export const levelValues = ['1', '2', '3', '4', '5', '6'];
3
- export const assertLevel = value => {
4
- if (value === null || !levelValues.includes(value)) {
5
- throw new Error(`sinch-title: invalid level attribute: ${value}`);
6
- }
7
- };
8
- export const assertType = value => {
9
- if (value === null || !typeValues.includes(value)) {
10
- throw new Error(`sinch-title: invalid type attribute: ${value}`);
11
- }
12
- };
13
2
  export const getTitleLevelFromType = type => {
14
3
  switch (type) {
15
4
  case 'xl':
@@ -23,23 +12,6 @@ export const getTitleLevelFromType = type => {
23
12
  case 'xs':
24
13
  return '5';
25
14
  default:
26
- throw new Error(`sinch-title: invalid type value: ${type}`);
27
- }
28
- };
29
- export const getTitleTypeFromLevel = level => {
30
- switch (level) {
31
- case '1':
32
- return 'xl';
33
- case '2':
34
- return 'l';
35
- case '3':
36
- return 'm';
37
- case '4':
38
- return 's';
39
- case '5':
40
- case '6':
41
- return 'xs';
42
- default:
43
- throw new Error(`sinch-title: invalid level value: ${level}`);
15
+ return '';
44
16
  }
45
17
  };
package/toast/index.js CHANGED
@@ -3,7 +3,7 @@ import '../title';
3
3
  import '../text';
4
4
  import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
5
5
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:center;gap:8px;width:328px;padding:8px 16px;box-sizing:border-box;border-radius:var(--sinch-comp-toast-shape-radius);box-shadow:var(--sinch-comp-toast-shadow)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-toast-color-success-default-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-toast-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-toast-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-toast-color-info-default-background)}#text{padding:4px 0 4px 4px;flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-toast-font-body)}:host([type=success]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-success-default-text)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-toast-color-info-default-text)}#icon{align-self:flex-start;margin:4px 0}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}#icon-success{--sinch-global-color-icon:var(--sinch-comp-toast-color-success-default-icon)}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-toast-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-toast-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-toast-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=success]) #icon-success,:host([type=warn]) #icon-warn{display:block}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-success" name="check_circle"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
6
- import { assertType, typeValues } from './utils';
6
+ import { typeValues } from './utils';
7
7
  const TIMEOUT = 5000;
8
8
  const template = document.createElement('template');
9
9
  template.innerHTML = templateHTML;
@@ -29,20 +29,13 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
29
29
  this.#clearTimeout();
30
30
  }
31
31
  static get observedAttributes() {
32
- return ['text', 'type', 'persistent'];
32
+ return ['text', 'persistent'];
33
33
  }
34
34
  attributeChangedCallback(name, oldVal, newVal) {
35
35
  if (oldVal === newVal) {
36
36
  return;
37
37
  }
38
38
  switch (name) {
39
- case 'type':
40
- {
41
- if ('production' !== 'production') {
42
- assertType(newVal);
43
- }
44
- break;
45
- }
46
39
  case 'text':
47
40
  {
48
41
  this.#$text.textContent = newVal;
package/toast/utils.d.ts CHANGED
@@ -1,5 +1,2 @@
1
1
  import type { TSinchToastType } from './types';
2
2
  export declare const typeValues: readonly TSinchToastType[];
3
- type TAssertType = (value: string | null) => asserts value is TSinchToastType;
4
- export declare const assertType: TAssertType;
5
- export {};
package/toast/utils.js CHANGED
@@ -1,6 +1 @@
1
- export const typeValues = ['info', 'success', 'warn', 'error'];
2
- export const assertType = value => {
3
- if (value === null || !typeValues.includes(value)) {
4
- throw new Error(`sinch-toast: invalid type attribute: ${value}`);
5
- }
6
- };
1
+ export const typeValues = ['info', 'success', 'warn', 'error'];
package/toggle/index.js CHANGED
@@ -107,10 +107,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
107
107
  e.stopPropagation();
108
108
  const isChecked = this.#$input.checked;
109
109
  this.#$input.checked = this.checked;
110
- this.dispatchEvent(new CustomEvent('change', {
111
- detail: isChecked,
112
- bubbles: true
113
- }));
114
110
  this.dispatchEvent(new CustomEvent('-change', {
115
111
  detail: isChecked
116
112
  }));
package/toggle/types.d.ts CHANGED
@@ -5,7 +5,6 @@ export type TSinchToggleElement = HTMLElement & {
5
5
  labeled: boolean;
6
6
  disabled: boolean;
7
7
  text: string | null;
8
- addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
9
8
  addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
10
9
  setAttribute(name: 'checked', value: ''): void;
11
10
  setAttribute(name: 'small', value: ''): void;
package/tooltip/index.js CHANGED
@@ -3,7 +3,7 @@ import '../pop';
3
3
  import { defineCustomElement, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, rectOverlap, getReactEventHandler, shouldReduceMotion } from '../utils';
4
4
  const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
5
5
  import { TooltipState } from './tooltip-state';
6
- import { assertOrientation, assertType, getPopOrientation, orientationValues, typeValues } from './utils';
6
+ import { getPopOrientation, orientationValues, typeValues } from './utils';
7
7
  const TIP_SIZE = 8;
8
8
  const SHOW_DELAY_SLOW = 1000;
9
9
  const SHOW_DELAY_FAST = 250;
@@ -73,9 +73,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
73
73
  }
74
74
  case 'orientation':
75
75
  {
76
- if ('production' !== 'production') {
77
- assertOrientation(newVal);
78
- }
79
76
  updateAttribute(this.#$pop, 'orientation', getPopOrientation(this.orientation));
80
77
  if (this.#isOpen()) {
81
78
  this.#resetTipOrientation();
@@ -85,9 +82,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
85
82
  }
86
83
  case 'type':
87
84
  {
88
- if ('production' !== 'production') {
89
- assertType(newVal);
90
- }
91
85
  this.#tooltipState.updateOptions({
92
86
  showDelay: newVal === 'fast' ? SHOW_DELAY_FAST : SHOW_DELAY_SLOW
93
87
  });
@@ -3,8 +3,3 @@ import type { TSinchPopOrientation } from '../pop/types';
3
3
  export declare const typeValues: readonly TSinchTooltipType[];
4
4
  export declare const orientationValues: readonly TSinchTooltipOrientation[];
5
5
  export declare const getPopOrientation: (orientation: TSinchTooltipOrientation) => TSinchPopOrientation;
6
- type TAssertOrientation = (value: string | null) => asserts value is TSinchTooltipOrientation;
7
- export declare const assertOrientation: TAssertOrientation;
8
- type TAssertType = (value: string | null) => asserts value is TSinchTooltipType;
9
- export declare const assertType: TAssertType;
10
- export {};
package/tooltip/utils.js CHANGED
@@ -14,14 +14,4 @@ export const getPopOrientation = orientation => {
14
14
  return 'center-right';
15
15
  }
16
16
  return orientation;
17
- };
18
- export const assertOrientation = value => {
19
- if (value !== null && !orientationValues.includes(value)) {
20
- throw new Error(`sinch-tooltip: invalid orientation attribute: ${value}`);
21
- }
22
- };
23
- export const assertType = value => {
24
- if (value !== null && !typeValues.includes(value)) {
25
- throw new Error(`sinch-tooltip: invalid type attribute: ${value}`);
26
- }
27
17
  };
package/utils/dom.js CHANGED
@@ -43,11 +43,6 @@ export function getLiteralAttribute($element, literals, attrName, defaultValue)
43
43
  if (isLiteralValue(literals, attrValue)) {
44
44
  return attrValue;
45
45
  }
46
- if (typeof defaultValue === 'undefined') {
47
- if ('production' !== 'production') {
48
- throw new Error(`Invalid attribute value: ${attrName} = ${attrValue}`);
49
- }
50
- }
51
46
  return defaultValue;
52
47
  }
53
48
  export const clampNumber = (value, min, max) => {
package/utils/element.js CHANGED
@@ -25,8 +25,8 @@ export const setNectaryRegistry = registry => {
25
25
  export class NectaryElement extends HTMLElement {
26
26
  attachShadow(options) {
27
27
  return super.attachShadow({
28
- mode: 'closed',
29
- delegatesFocus: false,
28
+ mode: 'open',
29
+ delegatesFocus: true,
30
30
  customElements: nectaryRegistry,
31
31
  ...options
32
32
  });
package/utils/size.d.ts CHANGED
@@ -3,8 +3,3 @@ export type TSinchSizeEx = TSinchSize | 'xs';
3
3
  export declare const DEFAULT_SIZE: TSinchSize;
4
4
  export declare const sizeValues: readonly TSinchSize[];
5
5
  export declare const sizeExValues: readonly TSinchSizeEx[];
6
- type TAssertSize = (value: string | null, name: string) => asserts value is TSinchSize;
7
- export declare const assertSize: TAssertSize;
8
- type TAssertSizeEx = (value: string | null, name: string) => asserts value is TSinchSizeEx;
9
- export declare const assertSizeEx: TAssertSizeEx;
10
- export {};