@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
@@ -2,8 +2,8 @@ import '../icon-button';
2
2
  import '../icon';
3
3
  import '../segmented-control';
4
4
  import '../segmented-control-option';
5
- import { defineCustomElement, getAttribute, getBooleanAttribute, getCssVar, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
6
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px;user-select:none}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-color-tropical-500)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-size-icon:24px}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">&colon;</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
5
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
6
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-comp-time-picker-header-font);line-height:48px;user-select:none;color:var(--sinch-comp-time-picker-header-color-default-text-initial)}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-comp-time-picker-watch-face-color-default-border-initial);background-color:var(--sinch-comp-time-picker-watch-face-color-default-background-initial)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;text-align:center;top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-12{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h12-initial)}.digit-hour-12.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h12);color:var(--sinch-comp-time-picker-digit-color-checked-h12-default)}.digit-hour-24{font:var(--sinch-comp-time-picker-digit-font-default-h24);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-h24-initial)}.digit-hour-24.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h24);color:var(--sinch-comp-time-picker-digit-color-checked-h24-initial)}.digit-minute{font:var(--sinch-comp-time-picker-digit-font-default-h12);line-height:28px;color:var(--sinch-comp-time-picker-digit-color-default-minute-initial)}.digit-minute.selected{color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-comp-time-picker-needle-color-default-background-initial)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-comp-time-picker-needle-color-default-background-focus)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}#submit-icon{--sinch-global-color-icon:var(--sinch-comp-time-picker-header-color-default-icon-initial)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">&colon;</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon" name="done"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
7
7
  import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
8
8
  const template = document.createElement('template');
9
9
  template.innerHTML = templateHTML;
@@ -29,7 +29,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
29
29
  #$headerMinutesText;
30
30
  #$ampm;
31
31
  #$submitButton;
32
- #$iconSubmit;
33
32
  #hour = 0;
34
33
  #minute = 0;
35
34
  #controller = null;
@@ -48,7 +47,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
48
47
  this.#$headerMinutesText = shadowRoot.querySelector('#header-minutes > span');
49
48
  this.#$ampm = shadowRoot.querySelector('#ampm');
50
49
  this.#$submitButton = shadowRoot.querySelector('#submit');
51
- this.#$iconSubmit = shadowRoot.querySelector('#icon-submit');
52
50
  this.#$needleMinute.style.height = `${NEEDLE_MINUTE_LENGTH}px`;
53
51
  this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
54
52
  const MINUTE_DIGIT_RADIUS = MINUTE_RADIUS + MINUTE_DIGIT_SIZE / 2;
@@ -104,7 +102,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
104
102
  this.#$needleHour.addEventListener('keydown', this.#onHoursKeydown, options);
105
103
  this.#$needleMinute.addEventListener('keydown', this.#onMinutesKeydown, options);
106
104
  this.addEventListener('-change', this.#onChangeReactHandler, options);
107
- updateAttribute(this.#$iconSubmit, 'name', getCssVar(this, '--sinch-time-picker-icon-submit'));
108
105
  }
109
106
  disconnectedCallback() {
110
107
  this.#controller.abort();
@@ -119,9 +116,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
119
116
  switch (name) {
120
117
  case 'value':
121
118
  {
122
- if (newVal === null) {
123
- throw new Error('Missing "value" attribute');
124
- }
125
119
  const {
126
120
  hours,
127
121
  minutes
@@ -145,9 +139,6 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
145
139
  }
146
140
  }
147
141
  }
148
- get nodeName() {
149
- return 'select';
150
- }
151
142
  set value(value) {
152
143
  updateAttribute(this, 'value', value);
153
144
  }
@@ -1,5 +1,4 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export type TSinchTimePickerElement = HTMLElement & {
4
3
  /** Time value in ISO 8601 format */
5
4
  value: string;
@@ -30,8 +29,6 @@ export type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerElement>
30
29
  'aria-label': string;
31
30
  /** Submit button label that is used for a11y */
32
31
  'submit-aria-label': string;
33
- /** @deprecated Change value handler, return time in ISO 8601 format */
34
- onChange?: (e: SyntheticEvent<TSinchTimePickerElement, CustomEvent<string>>) => void;
35
32
  /** Change value handler, return time in ISO 8601 format */
36
33
  'on-change'?: (e: CustomEvent<string>) => void;
37
34
  };
@@ -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
- import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:block}#text{letter-spacing:-2%}:host([type=xl]) #text{font:var(--sinch-font-title-xl)}:host([type="l"]) #text{font:var(--sinch-font-title-l)}:host([type="m"]) #text{font:var(--sinch-font-title-m)}:host([type="s"]) #text{font:var(--sinch-font-title-s)}:host([type=xs]) #text{font:var(--sinch-font-title-xs)}:host([ellipsis]:not([ellipsis=false])) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
3
- import { assertLevel, assertType, typeValues } from './utils';
1
+ import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue } from '../utils';
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 { typeValues } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
6
6
  defineCustomElement('sinch-title', class extends NectaryElement {
@@ -14,28 +14,13 @@ defineCustomElement('sinch-title', class extends NectaryElement {
14
14
  connectedCallback() {
15
15
  this.setAttribute('role', 'heading');
16
16
  }
17
- get text() {
18
- return getAttribute(this, 'text', '');
19
- }
20
- set text(value) {
21
- updateAttribute(this, 'text', value);
22
- }
23
- set type(value) {
24
- updateLiteralAttribute(this, typeValues, 'type', value);
25
- }
26
- get type() {
27
- return getLiteralAttribute(this, typeValues, 'type');
28
- }
29
- set ellipsis(isEllipsis) {
30
- updateBooleanAttribute(this, 'ellipsis', isEllipsis);
31
- }
32
- get ellipsis() {
33
- return getBooleanAttribute(this, 'ellipsis');
34
- }
35
17
  static get observedAttributes() {
36
- return ['text', 'type', 'level'];
18
+ return ['text', 'level', 'ellipsis'];
37
19
  }
38
- attributeChangedCallback(name, _, newVal) {
20
+ attributeChangedCallback(name, oldVal, newVal) {
21
+ if (oldVal === newVal) {
22
+ return;
23
+ }
39
24
  switch (name) {
40
25
  case 'text':
41
26
  {
@@ -44,19 +29,32 @@ defineCustomElement('sinch-title', class extends NectaryElement {
44
29
  }
45
30
  case 'level':
46
31
  {
47
- if ('production' !== 'production') {
48
- assertLevel(newVal);
49
- }
50
32
  updateAttribute(this, 'aria-level', newVal);
51
33
  break;
52
34
  }
53
- case 'type':
35
+ case 'ellipsis':
54
36
  {
55
- if ('production' !== 'production') {
56
- assertType(newVal);
57
- }
37
+ updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
58
38
  break;
59
39
  }
60
40
  }
61
41
  }
42
+ get text() {
43
+ return getAttribute(this, 'text', '');
44
+ }
45
+ set text(value) {
46
+ updateAttribute(this, 'text', value);
47
+ }
48
+ set type(value) {
49
+ updateLiteralAttribute(this, typeValues, 'type', value);
50
+ }
51
+ get type() {
52
+ return getLiteralAttribute(this, typeValues, 'type');
53
+ }
54
+ set ellipsis(isEllipsis) {
55
+ updateBooleanAttribute(this, 'ellipsis', isEllipsis);
56
+ }
57
+ get ellipsis() {
58
+ return getBooleanAttribute(this, 'ellipsis');
59
+ }
62
60
  });
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
@@ -1,14 +1,13 @@
1
1
  import '../icon';
2
2
  import '../title';
3
3
  import '../text';
4
- import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute, getCssVar } from '../utils';
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-shape-radius-l);box-shadow:var(--sinch-elevation-level-3)}#text{color:var(--sinch-color-stormy-500);padding:4px 0 4px 4px;flex:1;min-width:0}#icon{align-self:flex-start;margin:4px 0}:host([type=success]) #wrapper{background-color:var(--sinch-color-feedback-success-bg)}: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=success]) #icon{--sinch-color-icon:var(--sinch-color-feedback-success-icon)}: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-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
6
- import { assertType, typeValues } from './utils';
4
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
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 { typeValues } from './utils';
7
7
  const TIMEOUT = 5000;
8
8
  const template = document.createElement('template');
9
9
  template.innerHTML = templateHTML;
10
10
  defineCustomElement('sinch-toast', class extends NectaryElement {
11
- #$icon;
12
11
  #$text;
13
12
  #tid = null;
14
13
  constructor() {
@@ -16,7 +15,6 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
16
15
  const shadowRoot = this.attachShadow();
17
16
  shadowRoot.appendChild(template.content.cloneNode(true));
18
17
  this.#$text = shadowRoot.querySelector('#text');
19
- this.#$icon = shadowRoot.querySelector('#icon');
20
18
  }
21
19
  connectedCallback() {
22
20
  super.connectedCallback();
@@ -24,47 +22,20 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
24
22
  this.setAttribute('aria-live', 'polite');
25
23
  this.addEventListener('-timeout', this.#onTimeoutReactHandler);
26
24
  this.#updateTimeout();
27
- this.#updateIcon();
28
25
  }
29
26
  disconnectedCallback() {
30
27
  super.disconnectedCallback();
31
28
  this.removeEventListener('-timeout', this.#onTimeoutReactHandler);
32
29
  this.#clearTimeout();
33
30
  }
34
- get type() {
35
- return getLiteralAttribute(this, typeValues, 'type');
36
- }
37
- set type(value) {
38
- updateLiteralAttribute(this, typeValues, 'type', value);
39
- }
40
- get text() {
41
- return getAttribute(this, 'text', '');
42
- }
43
- set text(value) {
44
- updateAttribute(this, 'text', value);
45
- }
46
- get persistent() {
47
- return getBooleanAttribute(this, 'persistent');
48
- }
49
- set persistent(isPersistent) {
50
- updateBooleanAttribute(this, 'persistent', isPersistent);
51
- }
52
31
  static get observedAttributes() {
53
- return ['text', 'type', 'persistent'];
32
+ return ['text', 'persistent'];
54
33
  }
55
34
  attributeChangedCallback(name, oldVal, newVal) {
56
35
  if (oldVal === newVal) {
57
36
  return;
58
37
  }
59
38
  switch (name) {
60
- case 'type':
61
- {
62
- if ('production' !== 'production') {
63
- assertType(newVal);
64
- }
65
- this.#updateIcon();
66
- break;
67
- }
68
39
  case 'text':
69
40
  {
70
41
  this.#$text.textContent = newVal;
@@ -77,6 +48,24 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
77
48
  }
78
49
  }
79
50
  }
51
+ get type() {
52
+ return getLiteralAttribute(this, typeValues, 'type');
53
+ }
54
+ set type(value) {
55
+ updateLiteralAttribute(this, typeValues, 'type', value);
56
+ }
57
+ get text() {
58
+ return getAttribute(this, 'text', '');
59
+ }
60
+ set text(value) {
61
+ updateAttribute(this, 'text', value);
62
+ }
63
+ get persistent() {
64
+ return getBooleanAttribute(this, 'persistent');
65
+ }
66
+ set persistent(isPersistent) {
67
+ updateBooleanAttribute(this, 'persistent', isPersistent);
68
+ }
80
69
  #updateTimeout() {
81
70
  if (this.persistent) {
82
71
  this.#clearTimeout();
@@ -86,12 +75,6 @@ defineCustomElement('sinch-toast', class extends NectaryElement {
86
75
  this.#tid = window.setTimeout(this.#onTimeout, TIMEOUT);
87
76
  }
88
77
  }
89
- #updateIcon() {
90
- if (!this.isConnected) {
91
- return;
92
- }
93
- updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-toast-icon-${this.type}`));
94
- }
95
78
  #onTimeout = () => {
96
79
  this.dispatchEvent(new CustomEvent('-timeout'));
97
80
  };
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
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:32px}:host([small]:not([small=false])) #wrapper{font:var(--sinch-font-text-s)}#input{all:initial;display:block;position:absolute;left:0;top:6px;width:40px;height:20px;cursor:pointer;pointer-events:initial}#input:disabled{cursor:initial}:host([small]:not([small=false])) #input{width:32px;height:16px;top:8px}#input:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-border-focus);border-radius:18px;pointer-events:none}:host([small]:not([small=false])) #input:focus-visible::after{border-radius:14px}#knob-container{position:relative;box-sizing:border-box;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-color-stormy-100);overflow:hidden}:host([small]:not([small=false])) #knob-container{width:32px;height:16px;border-radius:8px}#input:checked~#knob-container{background-color:var(--sinch-color-tropical-500)}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-1);transform:translateX(0);transition:transform .1s ease-in-out}:host([small]:not([small=false])) #knob{width:12px;height:12px}#input:checked~#knob-container>#knob{transform:translateX(20px)}:host([small]:not([small=false])) #input:checked~#knob-container>#knob{transform:translateX(16px)}#knob::after,#knob::before{font:var(--sinch-font-text-m);color:var(--sinch-color-snow-100);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::after,:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-font-text-m);color:var(--sinch-color-text-default)}#label:empty{display:none}#input:disabled~#label{color:var(--sinch-color-stormy-200)}#input:disabled~#knob-container{background-color:var(--sinch-color-snow-700)}#input:checked:disabled~#knob-container{background-color:var(--sinch-color-tropical-100)}</style><div id="wrapper"><input id="input" type="checkbox"><div id="knob-container"><div id="knob"></div></div><label id="label" for="input"></label></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:var(--sinch-local-size);--sinch-local-size:24px}:host([small]) #wrapper{--sinch-local-size:22px}#input{all:initial;display:block;position:absolute;left:0;top:2px;width:40px;height:20px;cursor:pointer;pointer-events:initial}#input:disabled{cursor:initial}#input:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-comp-toggle-color-default-outline-focus);border-radius:18px;pointer-events:none}:host([small]) #input{width:32px;height:16px;top:3px}#knob-container{position:relative;box-sizing:border-box;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-comp-toggle-color-default-background-initial);overflow:hidden}:host([small]) #knob-container{width:32px;height:16px;border-radius:8px}#input:checked~#knob-container{background-color:var(--sinch-comp-toggle-color-checked-background-initial)}#input:disabled~#knob-container{background-color:var(--sinch-comp-toggle-color-disabled-background-initial)}#input:checked:disabled~#knob-container{background-color:var(--sinch-comp-toggle-color-checked-disabled-background-initial)}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-comp-toggle-color-default-knob-background-initial);box-shadow:var(--sinch-comp-toggle-shadow-knob-default);transform:translateX(0);transition:transform .1s ease-in-out;will-change:transform}:host([small]) #knob{width:12px;height:12px}#input:disabled+#knob-container>#knob{box-shadow:var(--sinch-comp-toggle-shadow-knob-disabled)}#input:checked+#knob-container>#knob{transform:translateX(20px)}:host([small]) #input:checked+#knob-container>#knob{transform:translateX(16px)}#knob::after,#knob::before{font:var(--sinch-comp-toggle-font-size-m-inside-text);color:var(--sinch-comp-toggle-color-default-text-inside-initial);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([small])) #knob::after,:host([labeled]:not([small])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-comp-toggle-font-size-m-label);color:var(--sinch-comp-toggle-color-default-label-initial)}#label:empty{display:none}:host([small]) #label{font:var(--sinch-comp-toggle-font-size-s-label)}#input:disabled~#label{color:var(--sinch-comp-toggle-color-disabled-label-initial)}</style><div id="wrapper"><input id="input" type="checkbox"><div id="knob-container"><div id="knob"></div></div><label id="label" for="input"></label></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-toggle', class extends NectaryElement {
@@ -30,13 +30,39 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
30
30
  this.removeEventListener('-blur', this.#onBlurReactHandler);
31
31
  }
32
32
  static get observedAttributes() {
33
- return ['checked', 'disabled', 'text'];
33
+ return ['checked', 'disabled', 'text', 'labeled', 'small'];
34
34
  }
35
- get type() {
36
- return 'text';
37
- }
38
- get nodeName() {
39
- return 'input';
35
+ attributeChangedCallback(name, oldVal, newVal) {
36
+ if (oldVal === newVal) {
37
+ return;
38
+ }
39
+ switch (name) {
40
+ case 'text':
41
+ {
42
+ this.#$label.textContent = newVal;
43
+ break;
44
+ }
45
+ case 'checked':
46
+ {
47
+ const isChecked = isAttrTrue(newVal);
48
+ this.#$input.checked = isChecked;
49
+ updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
50
+ break;
51
+ }
52
+ case 'disabled':
53
+ {
54
+ const isDisabled = isAttrTrue(newVal);
55
+ this.#$input.disabled = isDisabled;
56
+ updateBooleanAttribute(this, name, isDisabled);
57
+ break;
58
+ }
59
+ case 'small':
60
+ case 'labeled':
61
+ {
62
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
63
+ break;
64
+ }
65
+ }
40
66
  }
41
67
  set checked(isChecked) {
42
68
  updateBooleanAttribute(this, 'checked', isChecked);
@@ -68,29 +94,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
68
94
  get text() {
69
95
  return getAttribute(this, 'text');
70
96
  }
71
- attributeChangedCallback(name, _, newVal) {
72
- switch (name) {
73
- case 'text':
74
- {
75
- this.#$label.textContent = newVal;
76
- break;
77
- }
78
- case 'checked':
79
- {
80
- const isChecked = isAttrTrue(newVal);
81
- this.#$input.checked = isChecked;
82
- updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
83
- break;
84
- }
85
- case 'disabled':
86
- {
87
- const isDisabled = isAttrTrue(newVal);
88
- this.#$input.disabled = isDisabled;
89
- updateBooleanAttribute(this, 'disabled', isDisabled);
90
- break;
91
- }
92
- }
93
- }
94
97
  get focusable() {
95
98
  return true;
96
99
  }
package/toggle/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export type TSinchToggleElement = HTMLElement & {
4
3
  checked: boolean;
5
4
  small: boolean;
@@ -21,7 +20,5 @@ export type TSinchToggleReact = TSinchElementReact<TSinchToggleElement> & {
21
20
  disabled?: boolean;
22
21
  text?: string;
23
22
  'aria-label': string;
24
- /** @deprecated */
25
- onChange?: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
26
23
  'on-change'?: (e: CustomEvent<boolean>) => void;
27
24
  };
package/tooltip/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import '../text';
2
2
  import '../pop';
3
- import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, rectOverlap, getReactEventHandler, shouldReduceMotion } from '../utils';
4
- const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);border-radius:var(--sinch-shape-radius-xs);pointer-events:none;opacity:0}: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}#text{word-break:break-word;pointer-events:none}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-color-snow-600);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}:host([inverted]:not([inverted=false])) #content{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-text-inverted)}:host([inverted]:not([inverted=false])) #tip{fill:var(--sinch-color-stormy-500)}</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>';
3
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, rectOverlap, getReactEventHandler, shouldReduceMotion } from '../utils';
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
  });
@@ -101,12 +95,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
101
95
  set text(value) {
102
96
  updateAttribute(this, 'text', value);
103
97
  }
104
- get inverted() {
105
- return getBooleanAttribute(this, 'inverted');
106
- }
107
- set inverted(isInverted) {
108
- updateBooleanAttribute(this, 'inverted', isInverted);
109
- }
110
98
  get orientation() {
111
99
  return getLiteralAttribute(this, orientationValues, 'orientation', 'top');
112
100
  }
@@ -4,10 +4,6 @@ export type TSinchTooltipType = 'slow' | 'fast';
4
4
  export type TSinchTooltipElement = HTMLElement & {
5
5
  /** Text */
6
6
  text: string;
7
- /** @deprecated */
8
- width: number | null;
9
- /** Inverted */
10
- inverted: boolean;
11
7
  /** Orientation, where it *points to* from origin */
12
8
  orientation: TSinchTooltipOrientation;
13
9
  /** Type */
@@ -20,10 +16,6 @@ export type TSinchTooltipElement = HTMLElement & {
20
16
  addEventListener(type: '-hide', listener: (e: CustomEvent<void>) => void): void;
21
17
  /** Text */
22
18
  setAttribute(name: 'text', value: string): void;
23
- /** @deprecated */
24
- setAttribute(name: 'width', value: string): void;
25
- /** Inverted */
26
- setAttribute(name: 'inverted', value: ''): void;
27
19
  /** Orientation, where it *points to* from origin */
28
20
  setAttribute(name: 'orientation', value: TSinchTooltipOrientation): void;
29
21
  /** Type */
@@ -32,10 +24,6 @@ export type TSinchTooltipElement = HTMLElement & {
32
24
  export type TSinchTooltipReact = TSinchElementReact<TSinchTooltipElement> & {
33
25
  /** Text */
34
26
  text: string;
35
- /** @deprecated */
36
- width?: number;
37
- /** Inverted */
38
- inverted?: boolean;
39
27
  /** Orientation, where it *points to* from origin */
40
28
  orientation?: TSinchTooltipOrientation;
41
29
  /** Type */
@@ -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) => {