@nectary/components 1.3.3 → 2.0.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 (172) 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-option/index.js +2 -2
  6. package/alert/index.js +2 -12
  7. package/avatar/index.js +1 -1
  8. package/avatar/utils.js +3 -3
  9. package/badge/index.js +41 -67
  10. package/badge/types.d.ts +0 -4
  11. package/badge/utils.d.ts +0 -3
  12. package/badge/utils.js +0 -11
  13. package/button/index.js +1 -1
  14. package/button/types.d.ts +2 -2
  15. package/card/index.js +5 -16
  16. package/card/types.d.ts +0 -6
  17. package/card-container/index.js +1 -1
  18. package/chat-block/index.js +1 -1
  19. package/chat-bubble/index.js +3 -24
  20. package/checkbox/index.js +31 -30
  21. package/checkbox/types.d.ts +0 -3
  22. package/chip/index.js +34 -27
  23. package/chip/utils.js +3 -3
  24. package/code-tag/index.js +1 -1
  25. package/color-menu/index.d.ts +0 -3
  26. package/color-menu/index.js +50 -99
  27. package/color-menu/types.d.ts +0 -4
  28. package/color-menu-option/index.d.ts +14 -0
  29. package/color-menu-option/index.js +52 -0
  30. package/color-menu-option/types.d.ts +9 -0
  31. package/color-menu-option/utils.d.ts +1 -0
  32. package/color-menu-option/utils.js +11 -0
  33. package/color-swatch/index.js +1 -1
  34. package/color-swatch/utils.js +3 -3
  35. package/date-picker/index.js +2 -24
  36. package/date-picker/types.d.ts +0 -3
  37. package/dialog/index.js +2 -5
  38. package/dialog/types.d.ts +0 -2
  39. package/emoji/index.js +1 -1
  40. package/emoji-picker/index.d.ts +1 -0
  41. package/emoji-picker/index.js +32 -23
  42. package/field/index.js +39 -32
  43. package/file-drop/index.js +1 -1
  44. package/file-status/index.js +2 -16
  45. package/flag/index.js +1 -1
  46. package/grid/index.js +1 -1
  47. package/help-tooltip/index.js +3 -12
  48. package/horizontal-stepper/index.js +1 -1
  49. package/horizontal-stepper-item/index.d.ts +2 -0
  50. package/horizontal-stepper-item/index.js +8 -12
  51. package/icon/index.js +1 -1
  52. package/icon-button/index.js +1 -1
  53. package/inline-alert/index.js +19 -29
  54. package/input/index.d.ts +0 -3
  55. package/input/index.js +12 -46
  56. package/input/types.d.ts +1 -5
  57. package/link/index.js +35 -37
  58. package/list-item/index.js +1 -1
  59. package/package.json +10 -10
  60. package/pagination/index.js +8 -21
  61. package/pagination/types.d.ts +0 -3
  62. package/pop/index.js +16 -13
  63. package/popover/index.js +44 -50
  64. package/progress/index.js +20 -15
  65. package/radio/index.js +19 -6
  66. package/radio/types.d.ts +3 -3
  67. package/radio-option/index.js +35 -27
  68. package/rich-text/index.js +1 -1
  69. package/segment/index.js +2 -3
  70. package/segment-collapse/index.js +2 -11
  71. package/segment-collapse/types.d.ts +0 -3
  72. package/segmented-control/index.js +0 -3
  73. package/segmented-control/types.d.ts +0 -3
  74. package/segmented-control-option/index.js +20 -19
  75. package/segmented-icon-control/index.js +1 -4
  76. package/segmented-icon-control/types.d.ts +0 -3
  77. package/segmented-icon-control-option/index.js +18 -14
  78. package/select-button/index.js +7 -12
  79. package/select-menu/index.js +12 -5
  80. package/select-menu-option/index.js +2 -5
  81. package/skeleton/index.js +1 -1
  82. package/skeleton-item/index.js +1 -1
  83. package/spinner/index.js +1 -1
  84. package/table/index.js +1 -1
  85. package/table-body/index.js +1 -1
  86. package/table-cell/index.js +1 -1
  87. package/table-head-cell/index.d.ts +1 -0
  88. package/table-head-cell/index.js +12 -3
  89. package/table-row/index.js +18 -2
  90. package/tabs/index.js +1 -4
  91. package/tabs/types.d.ts +0 -3
  92. package/tabs-icon-option/index.js +4 -2
  93. package/tabs-option/index.js +25 -20
  94. package/tag/index.js +16 -8
  95. package/tag/utils.js +3 -3
  96. package/text/index.js +30 -20
  97. package/textarea/index.js +10 -6
  98. package/textarea/types.d.ts +0 -3
  99. package/tile-control/index.js +23 -25
  100. package/tile-control/types.d.ts +0 -3
  101. package/tile-control-option/index.js +1 -1
  102. package/time-picker/index.js +2 -8
  103. package/time-picker/types.d.ts +0 -3
  104. package/title/index.js +30 -22
  105. package/toast/index.js +20 -30
  106. package/toggle/index.js +33 -30
  107. package/toggle/types.d.ts +0 -3
  108. package/tooltip/index.js +41 -30
  109. package/tooltip/tooltip-state.d.ts +1 -0
  110. package/tooltip/tooltip-state.js +6 -0
  111. package/tooltip/types.d.ts +7 -12
  112. package/tooltip/utils.d.ts +4 -1
  113. package/tooltip/utils.js +7 -1
  114. package/vertical-stepper/index.js +1 -1
  115. package/vertical-stepper-item/index.d.ts +2 -0
  116. package/vertical-stepper-item/index.js +8 -12
  117. package/logo/create-logo-class.d.ts +0 -1
  118. package/logo/create-logo-class.js +0 -52
  119. package/logo/engage-icon/index.d.ts +0 -11
  120. package/logo/engage-icon/index.js +0 -4
  121. package/logo/engage-icon-wordmark/index.d.ts +0 -11
  122. package/logo/engage-icon-wordmark/index.js +0 -4
  123. package/logo/sinch-icon/index.d.ts +0 -11
  124. package/logo/sinch-icon/index.js +0 -4
  125. package/logo/sinch-icon-wordmark/index.d.ts +0 -11
  126. package/logo/sinch-icon-wordmark/index.js +0 -4
  127. package/logo/types.d.ts +0 -11
  128. package/theme/accordion-item.css +0 -4
  129. package/theme/alert.css +0 -6
  130. package/theme/avatar.css +0 -25
  131. package/theme/badge.css +0 -15
  132. package/theme/button.css +0 -146
  133. package/theme/chat.css +0 -9
  134. package/theme/chip.css +0 -68
  135. package/theme/color-menu.css +0 -4
  136. package/theme/color-swatch.css +0 -71
  137. package/theme/colors.d.ts +0 -4
  138. package/theme/colors.js +0 -4
  139. package/theme/contextual.css +0 -40
  140. package/theme/date-picker.css +0 -7
  141. package/theme/dialog.css +0 -4
  142. package/theme/elevation.css +0 -7
  143. package/theme/emoji-picker.css +0 -13
  144. package/theme/emoji.css +0 -5
  145. package/theme/file-status.css +0 -7
  146. package/theme/flag.css +0 -4
  147. package/theme/fonts.css +0 -86
  148. package/theme/fonts.json +0 -89
  149. package/theme/help-tooltip.css +0 -5
  150. package/theme/horizontal-stepper.css +0 -5
  151. package/theme/icon-button.css +0 -68
  152. package/theme/icon.css +0 -7
  153. package/theme/index.css +0 -4
  154. package/theme/index.d.ts +0 -39
  155. package/theme/index.js +0 -39
  156. package/theme/inline-alert.css +0 -7
  157. package/theme/input.css +0 -10
  158. package/theme/link.css +0 -5
  159. package/theme/pagination.css +0 -5
  160. package/theme/palette.css +0 -90
  161. package/theme/segment.css +0 -4
  162. package/theme/select-button.css +0 -10
  163. package/theme/select-menu.css +0 -6
  164. package/theme/shapes.css +0 -8
  165. package/theme/size.css +0 -9
  166. package/theme/spinner.css +0 -7
  167. package/theme/tag.css +0 -67
  168. package/theme/time-picker.css +0 -4
  169. package/theme/toast.css +0 -7
  170. package/theme/typography.css +0 -16
  171. package/theme/vertical-stepper.css +0 -5
  172. /package/{logo → color-menu-option}/types.js +0 -0
@@ -1,28 +1,19 @@
1
1
  import '../icon';
2
- import { defineCustomElement, getAttribute, getCssVar, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
3
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;padding:12px 16px;border-radius:16px;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#wrapper{background-color:var(--sinch-color-snow-500);border-top-left-radius:0}:host([data-type=agent-prev])>#wrapper{background-color:var(--sinch-color-snow-700);border-top-right-radius:0}:host([data-type=agent])>#wrapper{background-color:var(--sinch-color-honey-200);border-top-right-radius:0}#text{font:var(--sinch-font-text-m);color:var(--sinch-color-stormy-500)}#icon{display:none;position:absolute;right:16px;bottom:12px;--sinch-size-icon:16px;--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-icon-font-variation-settings:var(--sinch-chat-icon-font-variation-settings)}:host([status=error]) #icon,:host([status=received]) #icon,:host([status=seen]) #icon,:host([status=sending]) #icon,:host([status=sent]) #icon{display:block}:host([status=seen]) #icon{--sinch-color-icon:var(--sinch-color-feedback-success-icon)}:host([status=error]) #icon{--sinch-color-icon:var(--sinch-color-feedback-invalid-icon)}:host([status]:not([status=""])) #wrapper{padding-right:42px}</style><div id="wrapper"><span id="text"></span><sinch-icon id="icon"></sinch-icon></div>';
2
+ import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
3
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;padding:12px 16px;border-radius:16px;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-default);border-top-left-radius:0}:host([data-type=agent-prev])>#wrapper{background-color:var(--sinch-sys-color-container-contrast-primary-active);border-top-right-radius:0}:host([data-type=agent])>#wrapper{background-color:var(--sinch-sys-color-container-complement-primary-hover);border-top-right-radius:0}#text{--sinch-global-color-text:var(--sinch-sys-color-text-default)}#icon-error,#icon-received,#icon-seen,#icon-sending,#icon-sent{display:none;position:absolute;right:16px;bottom:12px;--sinch-global-size-icon:16px;--sinch-comp-icon-font-variation-settings:"FILL" 0}#icon-sending{--sinch-global-color-icon:var(--sinch-sys-color-text-default)}#icon-sent{--sinch-global-color-icon:var(--sinch-sys-color-text-default)}#icon-received{--sinch-global-color-icon:var(--sinch-sys-color-text-default)}#icon-seen{--sinch-global-color-icon:var(--sinch-sys-color-feedback-success-contrast)}#icon-error{--sinch-global-color-icon:var(--sinch-sys-color-feedback-invalid-contrast)}:host([status=error]) #icon-error,:host([status=received]) #icon-received,:host([status=seen]) #icon-seen,:host([status=sending]) #icon-sending,:host([status=sent]) #icon-sent{display:block}:host([status]:not([status=""])) #wrapper{padding-right:42px}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><sinch-icon id="icon-sending" name="query_builder"></sinch-icon><sinch-icon id="icon-sent" name="check"></sinch-icon><sinch-icon id="icon-received" name="done_all"></sinch-icon><sinch-icon id="icon-seen" name="done_all"></sinch-icon><sinch-icon id="icon-error" name="error_outline"></sinch-icon></div>';
4
4
  import { statusValues, typeValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
7
7
  defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
8
8
  #$text;
9
- #$icon;
10
9
  constructor() {
11
10
  super();
12
11
  const shadowRoot = this.attachShadow();
13
12
  shadowRoot.appendChild(template.content.cloneNode(true));
14
13
  this.#$text = shadowRoot.querySelector('#text');
15
- this.#$icon = shadowRoot.querySelector('#icon');
16
- }
17
- connectedCallback() {
18
- super.connectedCallback();
19
- this.#updateIcon();
20
- }
21
- disconnectedCallback() {
22
- super.disconnectedCallback();
23
14
  }
24
15
  static get observedAttributes() {
25
- return ['text', 'status'];
16
+ return ['text'];
26
17
  }
27
18
  attributeChangedCallback(name, _, newVal) {
28
19
  switch (name) {
@@ -31,11 +22,6 @@ defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
31
22
  this.#$text.textContent = newVal;
32
23
  break;
33
24
  }
34
- case 'status':
35
- {
36
- this.#updateIcon();
37
- break;
38
- }
39
25
  }
40
26
  }
41
27
  set text(value) {
@@ -53,11 +39,4 @@ defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
53
39
  get status() {
54
40
  return getLiteralAttribute(this, statusValues, 'status', null);
55
41
  }
56
- #updateIcon() {
57
- if (!this.isConnected) {
58
- return;
59
- }
60
- const status = this.status;
61
- updateAttribute(this.#$icon, 'name', status !== null ? getCssVar(this, `--sinch-chat-icon-${status}`) : null);
62
- }
63
42
  });
package/checkbox/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{--sinch-color-checkbox-circle:var(--sinch-color-transparent);--sinch-color-checkbox-background:var(--sinch-color-snow-100);--sinch-color-checkbox-border:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-hover:var(--sinch-color-snow-500);--sinch-color-checkbox-background-hover:var(--sinch-color-snow-100);--sinch-color-checkbox-border-hover:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-focus:var(--sinch-color-snow-700);--sinch-color-checkbox-background-focus:var(--sinch-color-snow-100);--sinch-color-checkbox-border-focus:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-active:var(--sinch-color-stormy-100);--sinch-color-checkbox-background-active:var(--sinch-color-snow-100);--sinch-color-checkbox-border-active:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-disabled:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled:var(--sinch-color-snow-100);--sinch-color-checkbox-border-disabled:var(--sinch-color-stormy-100);--sinch-color-checkbox-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-text:var(--sinch-color-text-default);--sinch-color-checkbox-text-disabled:var(--sinch-color-text-disabled);display:inline-block;vertical-align:middle;outline:0}:host([invalid]:not([invalid=false])){--sinch-color-checkbox-border:var(--sinch-color-raspberry-500);--sinch-color-checkbox-background-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-raspberry-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-raspberry-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-disabled:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-text:var(--sinch-color-text-invalid);--sinch-color-checkbox-text-disabled:var(--sinch-color-raspberry-200)}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px}#checkbox{all:initial;display:block;width:32px;height:32px;cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#checkbox::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:16px;pointer-events:none;background-color:var(--sinch-color-checkbox-circle);transition:background-color .1s linear}#checkbox::after{content:"";position:absolute;top:7px;left:7px;width:18px;height:18px;border-radius:var(--sinch-shape-radius-xs);pointer-events:none;background-color:var(--sinch-color-checkbox-background);border:2px solid var(--sinch-color-checkbox-border);transition:background-color .1s linear;box-sizing:border-box}#icon-checkmark{position:absolute;left:9px;top:10px;transition:opacity .1s linear;opacity:0;pointer-events:none}#icon-indeterminate{position:absolute;left:10px;top:15px;transition:opacity .1s linear;opacity:0;pointer-events:none}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:6px;font:var(--sinch-font-text-m);color:var(--sinch-color-checkbox-text)}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-checkbox-text-disabled)}:host(:is(:not([indeterminate]),[indeterminate=false])) #checkbox:checked~#icon-checkmark{opacity:1}:host([indeterminate]:not([indeterminate=false])) #checkbox:checked~#icon-indeterminate{opacity:1}#checkbox:checked::before{background-color:var(--sinch-color-checkbox-circle-checked)}#checkbox:checked::after{background-color:var(--sinch-color-checkbox-background-checked);border-color:var(--sinch-color-checkbox-border-checked)}#checkbox:focus-visible::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus-visible::after{background-color:var(--sinch-color-checkbox-background-focus);border-color:var(--sinch-color-checkbox-border-focus)}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);border-color:var(--sinch-color-checkbox-border-hover)}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);border-color:var(--sinch-color-checkbox-border-active)}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);border-color:var(--sinch-color-checkbox-border-disabled)}#checkbox:focus-visible:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus-visible:checked::after{background-color:var(--sinch-color-checkbox-background-focus-checked);border-color:var(--sinch-color-checkbox-border-focus-checked)}#checkbox:hover:checked::before{background-color:var(--sinch-color-checkbox-circle-hover-checked)}#checkbox:hover:checked::after{background-color:var(--sinch-color-checkbox-background-hover-checked);border-color:var(--sinch-color-checkbox-border-hover-checked)}#checkbox:active:checked::before{background-color:var(--sinch-color-checkbox-circle-active-checked)}#checkbox:active:checked::after{background-color:var(--sinch-color-checkbox-background-active-checked);border-color:var(--sinch-color-checkbox-border-active-checked)}#checkbox:disabled:checked::before{background-color:var(--sinch-color-checkbox-circle-disabled-checked)}#checkbox:disabled:checked::after{background-color:var(--sinch-color-checkbox-background-disabled-checked);border-color:var(--sinch-color-checkbox-border-disabled-checked)}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/><svg id="icon-checkmark" width="14" height="11" aria-hidden="true"><path d="M14 1.99999L12.59 0.579987L4.98995 8.17L1.49997 4.5L0.0799694 5.91L4.98995 11L14 1.99999Z" fill="white"/></svg><svg id="icon-indeterminate" width="12" height="2" aria-hidden="true"><line y1="1" x2="12" y2="1" stroke="white" stroke-width="2"/></svg></div><label for="checkbox" id="label"></label></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;--sinch-local-size:24px;--sinch-local-color-background:var(--sinch-comp-checkbox-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-default-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-default-text-initial)}:host([invalid])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-invalid-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-invalid-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-invalid-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-invalid-text-initial)}:host([checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-checked-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-checked-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-checkbox-color-disabled-text-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-disabled-border-initial)}#checkbox{all:initial;display:block;width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);align-self:flex-start}#checkbox::before{content:"";position:absolute;top:0;left:0;width:var(--sinch-local-size);height:var(--sinch-local-size);border:2px solid var(--sinch-comp-checkbox-color-default-outline-focus);border-radius:calc(var(--sinch-comp-checkbox-shape-radius) + 3px);transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}#checkbox:focus-visible::before{opacity:1}#checkbox::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:2px solid var(--sinch-local-color-border);border-radius:var(--sinch-comp-checkbox-shape-radius);transition:background-color .1s linear;box-sizing:border-box;pointer-events:none}#checkbox:enabled:hover::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}#checkbox:enabled:active::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#icon-checkmark,#icon-indeterminate{position:absolute;left:4px;top:4px;width:16px;height:16px;transition:opacity .1s linear;opacity:0;pointer-events:none;fill:var(--sinch-sys-color-container-main-default)}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;padding-left:7px;font:var(--sinch-comp-checkbox-font-label);color:var(--sinch-local-color-text);cursor:pointer}:host([disabled]) #label{cursor:initial}:host([text]:not([text=""])) #label{display:block}:host(:not([indeterminate])) #checkbox:checked~#icon-checkmark{opacity:1}:host([indeterminate]) #checkbox:checked~#icon-indeterminate{opacity:1}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/><svg id="icon-checkmark" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-indeterminate" viewBox="0 0 24 24" aria-hidden="true"><path d="M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1Z"/></svg></div><label for="checkbox" id="label"></label></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-checkbox', class extends NectaryElement {
@@ -32,13 +32,37 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
32
32
  this.removeEventListener('-blur', this.#onBlurReactHandler);
33
33
  }
34
34
  static get observedAttributes() {
35
- return ['checked', 'disabled', 'text'];
35
+ return ['checked', 'disabled', 'text', 'invalid', 'indeterminate'];
36
36
  }
37
- get type() {
38
- return 'text';
39
- }
40
- get nodeName() {
41
- return 'input';
37
+ attributeChangedCallback(name, _, newVal) {
38
+ switch (name) {
39
+ case 'text':
40
+ {
41
+ this.#$label.textContent = newVal;
42
+ break;
43
+ }
44
+ case 'checked':
45
+ {
46
+ const isChecked = isAttrTrue(newVal);
47
+ this.#$input.checked = isChecked;
48
+ updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
49
+ updateBooleanAttribute(this, 'checked', isChecked);
50
+ break;
51
+ }
52
+ case 'disabled':
53
+ {
54
+ const isDisabled = isAttrTrue(newVal);
55
+ this.#$input.disabled = isDisabled;
56
+ updateBooleanAttribute(this, 'disabled', isDisabled);
57
+ break;
58
+ }
59
+ case 'invalid':
60
+ case 'indeterminate':
61
+ {
62
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
63
+ break;
64
+ }
65
+ }
42
66
  }
43
67
  set checked(isChecked) {
44
68
  updateBooleanAttribute(this, 'checked', isChecked);
@@ -70,29 +94,6 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
70
94
  get text() {
71
95
  return getAttribute(this, 'text');
72
96
  }
73
- attributeChangedCallback(name, _, newVal) {
74
- switch (name) {
75
- case 'text':
76
- {
77
- this.#$label.textContent = newVal;
78
- break;
79
- }
80
- case 'checked':
81
- {
82
- const isChecked = isAttrTrue(newVal);
83
- this.#$input.checked = isChecked;
84
- updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
85
- break;
86
- }
87
- case 'disabled':
88
- {
89
- const isDisabled = isAttrTrue(newVal);
90
- this.#$input.disabled = isDisabled;
91
- updateBooleanAttribute(this, 'disabled', isDisabled);
92
- break;
93
- }
94
- }
95
- }
96
97
  get focusable() {
97
98
  return true;
98
99
  }
@@ -1,5 +1,4 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export type TSinchCheckboxElement = HTMLElement & {
4
3
  /** Value */
5
4
  checked: boolean;
@@ -41,8 +40,6 @@ export type TSinchCheckboxReact = TSinchElementReact<TSinchCheckboxElement> & {
41
40
  text?: string;
42
41
  /** Label that is used for a11y – might be different from `label` */
43
42
  'aria-label': string;
44
- /** @deprecated */
45
- onChange?: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
46
43
  /** Change value handler */
47
44
  'on-change'?: (e: CustomEvent<boolean>) => void;
48
45
  /** Focus handler */
package/chip/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import '../text';
2
2
  import '../icon';
3
- import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, getCssVar } from '../utils';
4
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{all:initial;position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:24px;padding:0 5px 0 9px;border-radius:12px;background-color:var(--sinch-chip-color-default-bg);color:var(--sinch-chip-color-default-fg);box-sizing:border-box;cursor:pointer;--sinch-color-icon:var(--sinch-chip-color-default-fg);--sinch-size-icon:16px}#button:focus-visible::after{content:"";position:absolute;inset:-4px;border-radius:16px;border:2px solid var(--sinch-color-border-focus);pointer-events:none}#text{flex:1}:host([small]:not([small=false])) #button{height:20px;border-radius:10px;padding:0 3px 0 7px}:host([small]:not([small=false])) #button:focus-visible::after{border-radius:14px}::slotted(*){margin-left:-4px}</style><button id="button"><slot name="icon"></slot><sinch-text id="text" type="xs" ellipsis></sinch-text><sinch-icon id="icon-close"></sinch-icon></button>';
3
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, isAttrTrue } from '../utils';
4
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{all:initial;position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:var(--sinch-comp-chip-size-container-m);padding:0 5px 0 9px;border-radius:var(--sinch-comp-chip-shape-radius);background-color:var(--sinch-comp-chip-color-neutral-default-background-initial);box-sizing:border-box;cursor:pointer;--sinch-global-color-text:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-color-icon:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-size-icon:var(--sinch-comp-chip-size-icon-m)}#button:focus-visible::after{content:"";position:absolute;inset:-4px;border-radius:calc(var(--sinch-comp-chip-shape-radius) + 4px);border:2px solid var(--sinch-comp-chip-color-outiline-focus);pointer-events:none}#text{flex:1;--sinch-comp-text-font:var(--sinch-comp-chip-font-size-m-label)}:host([small]) #button{height:var(--sinch-comp-chip-size-container-s);padding:0 3px 0 7px;--sinch-global-size-icon:var(--sinch-comp-chip-size-icon-s)}:host([small]) #text{--sinch-comp-text-font:var(--sinch-comp-chip-font-size-s-label)}::slotted(*){margin-left:-4px}</style><button id="button"><slot name="icon"></slot><sinch-text id="text" type="xs" ellipsis></sinch-text><sinch-icon id="icon-close" name="cancel"></sinch-icon></button>';
5
5
  import { assertChipColor, getChipColorBg, getChipColorFg } from './utils';
6
6
  const template = document.createElement('template');
7
7
  template.innerHTML = templateHTML;
8
8
  defineCustomElement('sinch-chip', class extends NectaryElement {
9
9
  #$text;
10
10
  #$button;
11
- #$iconClose;
12
11
  #controller = null;
13
12
  constructor() {
14
13
  super();
15
- const shadowRoot = this.attachShadow();
14
+ const shadowRoot = this.attachShadow({
15
+ delegatesFocus: true
16
+ });
16
17
  shadowRoot.appendChild(template.content.cloneNode(true));
17
18
  this.#$button = shadowRoot.querySelector('#button');
18
19
  this.#$text = shadowRoot.querySelector('#text');
19
- this.#$iconClose = shadowRoot.querySelector('#icon-close');
20
20
  }
21
21
  connectedCallback() {
22
22
  super.connectedCallback();
@@ -43,13 +43,37 @@ defineCustomElement('sinch-chip', class extends NectaryElement {
43
43
  this.addEventListener('-blur', this.#onBlurReactHandler, {
44
44
  signal
45
45
  });
46
- updateAttribute(this.#$iconClose, 'name', getCssVar(this, '--sinch-chip-icon-close'));
47
46
  this.#updateColor();
48
47
  }
49
48
  disconnectedCallback() {
50
49
  super.disconnectedCallback();
51
50
  this.#controller.abort();
52
51
  }
52
+ static get observedAttributes() {
53
+ return ['text', 'color', 'small'];
54
+ }
55
+ attributeChangedCallback(name, oldVal, newVal) {
56
+ if (oldVal === newVal) {
57
+ return;
58
+ }
59
+ switch (name) {
60
+ case 'color':
61
+ {
62
+ this.#updateColor();
63
+ break;
64
+ }
65
+ case 'text':
66
+ {
67
+ this.#$text.textContent = newVal;
68
+ break;
69
+ }
70
+ case 'small':
71
+ {
72
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
73
+ break;
74
+ }
75
+ }
76
+ }
53
77
  get color() {
54
78
  return getAttribute(this, 'color');
55
79
  }
@@ -68,23 +92,6 @@ defineCustomElement('sinch-chip', class extends NectaryElement {
68
92
  set small(isSmall) {
69
93
  updateBooleanAttribute(this, 'small', isSmall);
70
94
  }
71
- static get observedAttributes() {
72
- return ['text', 'color'];
73
- }
74
- attributeChangedCallback(name, _, newVal) {
75
- switch (name) {
76
- case 'color':
77
- {
78
- this.#updateColor();
79
- break;
80
- }
81
- case 'text':
82
- {
83
- this.#$text.textContent = newVal;
84
- break;
85
- }
86
- }
87
- }
88
95
  #updateColor() {
89
96
  if (!this.isConnected) {
90
97
  return;
@@ -97,12 +104,12 @@ defineCustomElement('sinch-chip', class extends NectaryElement {
97
104
  const bg = getChipColorBg(colorName);
98
105
  const fg = getChipColorFg(colorName);
99
106
  this.#$button.style.setProperty('background-color', bg);
100
- this.#$button.style.setProperty('color', fg);
101
- this.#$button.style.setProperty('--sinch-color-icon', fg);
107
+ this.#$button.style.setProperty('--sinch-global-color-text', fg);
108
+ this.#$button.style.setProperty('--sinch-global-color-icon', fg);
102
109
  } else {
103
110
  this.#$button.style.removeProperty('background-color');
104
- this.#$button.style.removeProperty('color');
105
- this.#$button.style.removeProperty('--sinch-color-icon');
111
+ this.#$button.style.removeProperty('--sinch-global-color-text');
112
+ this.#$button.style.removeProperty('--sinch-global-color-icon');
106
113
  }
107
114
  }
108
115
  get focusable() {
package/chip/utils.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export const getChipColorBg = id => {
2
- return `var(--sinch-chip-color-${id}-bg)`;
2
+ return `var(--sinch-comp-chip-color-${id}-default-background-initial)`;
3
3
  };
4
4
  export const getChipColorFg = id => {
5
- return `var(--sinch-chip-color-${id}-fg)`;
5
+ return `var(--sinch-comp-chip-color-${id}-default-foreground-initial)`;
6
6
  };
7
7
  export const assertChipColor = (root, id) => {
8
- if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-chip-color-${id}-bg`).length === 0) {
8
+ if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-comp-chip-color-${id}-default-background-initial`).length === 0) {
9
9
  throw new Error(`Invalid sinch-chip color name: ${id}`);
10
10
  }
11
11
  };
package/code-tag/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getAttribute, updateAttribute, NectaryElement } from '../utils';
2
- const templateHTML = '<style>:host{display:inline}#content{font:var(--sinch-font-mono-text-s);font-size:inherit;line-height:inherit;text-decoration:inherit;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)}</style><span id="content"></span>';
2
+ const templateHTML = '<style>:host{display:inline}#content{font:var(--sinch-comp-code-tag-font-text);font-size:inherit;line-height:inherit;color:var(--sinch-comp-code-tag-color-default-text-initial);border:1px solid var(--sinch-comp-code-tag-color-default-border-initial);background-color:var(--sinch-comp-code-tag-color-default-background-initial);padding:0 .25em;border-radius:var(--sinch-comp-code-tag-shape-radius);white-space:var(--sinch-global-text-white-space,normal)}</style><span id="content"></span>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-code-tag', class extends NectaryElement {
@@ -1,6 +1,3 @@
1
- import '../color-swatch';
2
- import '../tooltip';
3
- import '../icon';
4
1
  import type { TSinchColorMenuElement, TSinchColorMenuReact } from './types';
5
2
  declare global {
6
3
  namespace JSX {
@@ -1,29 +1,20 @@
1
- import '../color-swatch';
2
- import '../tooltip';
3
- import '../icon';
4
- import { getSwatchColorFg } from '../color-swatch/utils';
5
- import { lightColorNames, darkColorNames, vibrantColorNames } from '../theme/colors';
6
- import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getIntegerAttribute, getReactEventHandler, getRect, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, subscribeContext, getCssVar } from '../utils';
7
- const optionTemplateHTML = '<div class="option" role="option"><sinch-tooltip inverted class="tooltip"><div class="swatch-wrapper"><sinch-color-swatch class="swatch"></sinch-color-swatch><sinch-icon class="check"></sinch-icon></div></sinch-tooltip></div>';
8
- const templateHTML = '<style>:host{display:block;outline:0}#listbox{display:flex;flex-direction:row;flex-wrap:wrap;padding:4px 10px;overflow-y:auto}#listbox:empty{display:none}.option{padding:12px 6px;--sinch-color-icon:var(--sinch-color-stormy-500)}.swatch-wrapper{position:relative;cursor:pointer;width:32px;height:32px}.swatch-wrapper::after{content:"";position:absolute;width:34px;height:34px;inset:-3px;border:2px solid transparent;border-radius:50%;pointer-events:none}.option[data-selected]:not([data-checked]) .swatch-wrapper::after{border-color:var(--sinch-color-border-focus)}.check{display:none;position:absolute;left:4px;top:4px;pointer-events:none;--sinch-size-icon:24px}.option[data-checked] .check{display:block}</style><div id="listbox" role="presentation"></div>';
9
- import { getParentOption } from './utils';
1
+ import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, getRect, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, subscribeContext } from '../utils';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#listbox{display:flex;flex-direction:row;flex-wrap:wrap;padding:4px 10px;overflow-y:auto}#listbox.empty{display:none}</style><div id="listbox" role="presentation"><slot id="options"></slot></div>';
10
3
  const NUM_COLS_DEFAULT = 5;
11
4
  const ITEM_WIDTH = 44;
12
5
  const ITEM_HEIGHT = 56;
13
6
  const template = document.createElement('template');
14
- const optionTemplate = document.createElement('template');
15
7
  template.innerHTML = templateHTML;
16
- optionTemplate.innerHTML = optionTemplateHTML;
17
8
  defineCustomElement('sinch-color-menu', class extends NectaryElement {
18
9
  #$listbox;
10
+ #$optionsSlot;
19
11
  #controller = null;
20
- #prevColorsValue = '';
21
- #checkIconName = null;
22
12
  constructor() {
23
13
  super();
24
14
  const shadowRoot = this.attachShadow();
25
15
  shadowRoot.appendChild(template.content.cloneNode(true));
26
16
  this.#$listbox = shadowRoot.querySelector('#listbox');
17
+ this.#$optionsSlot = shadowRoot.querySelector('#options');
27
18
  }
28
19
  connectedCallback() {
29
20
  super.connectedCallback();
@@ -31,32 +22,53 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
31
22
  const {
32
23
  signal
33
24
  } = this.#controller;
25
+ const options = {
26
+ signal
27
+ };
34
28
  this.setAttribute('role', 'listbox');
35
29
  this.setAttribute('tabindex', '0');
36
- this.addEventListener('keydown', this.#onListboxKeyDown, {
37
- signal
38
- });
39
- this.addEventListener('blur', this.#onListboxBlur, {
40
- signal
41
- });
42
- this.#$listbox.addEventListener('click', this.#onListboxClick, {
43
- signal
44
- });
45
- this.addEventListener('-change', this.#onChangeReactHandler, {
46
- signal
47
- });
30
+ this.addEventListener('keydown', this.#onListboxKeyDown, options);
31
+ this.addEventListener('blur', this.#onListboxBlur, options);
32
+ this.#$listbox.addEventListener('click', this.#onListboxClick, options);
33
+ this.#$optionsSlot.addEventListener('slotchange', this.#onSlotChange, options);
34
+ this.addEventListener('-change', this.#onChangeReactHandler, options);
48
35
  subscribeContext(this, 'keydown', this.#onContextKeyDown, signal);
49
36
  subscribeContext(this, 'visibility', this.#onContextVisibility, signal);
50
- this.#checkIconName = getCssVar(this, '--sinch-color-menu-icon-check');
51
- requestAnimationFrame(this.#onMount);
37
+ this.#updateColumns();
52
38
  }
53
39
  disconnectedCallback() {
54
40
  super.disconnectedCallback();
55
- this.#prevColorsValue = null;
56
41
  this.#controller.abort();
42
+ this.#controller = null;
57
43
  }
58
44
  static get observedAttributes() {
59
- return ['value', 'rows', 'cols', 'colors'];
45
+ return ['value', 'rows', 'cols'];
46
+ }
47
+ attributeChangedCallback(name, oldVal, newVal) {
48
+ if (oldVal === newVal) {
49
+ return;
50
+ }
51
+ switch (name) {
52
+ case 'value':
53
+ {
54
+ if (this.isConnected) {
55
+ this.#onValueChange();
56
+ }
57
+ break;
58
+ }
59
+ case 'rows':
60
+ {
61
+ this.#updateRows();
62
+ break;
63
+ }
64
+ case 'cols':
65
+ {
66
+ if (this.isConnected) {
67
+ this.#updateColumns();
68
+ }
69
+ break;
70
+ }
71
+ }
60
72
  }
61
73
  set value(value) {
62
74
  updateAttribute(this, 'value', value);
@@ -86,73 +98,16 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
86
98
  return true;
87
99
  }
88
100
  nthItemRect(index) {
89
- const $item = this.#$listbox.children[index];
101
+ const $item = this.#getOptionElements()[index];
90
102
  if ($item != null) {
91
103
  return getRect($item);
92
104
  }
93
105
  return null;
94
106
  }
95
- attributeChangedCallback(name, oldVal, newVal) {
96
- if (oldVal === newVal) {
97
- return;
98
- }
99
- switch (name) {
100
- case 'value':
101
- {
102
- if (this.isConnected) {
103
- this.#onValueChange();
104
- }
105
- break;
106
- }
107
- case 'colors':
108
- {
109
- if (this.isConnected) {
110
- this.#updateColors();
111
- }
112
- break;
113
- }
114
- case 'rows':
115
- {
116
- this.#updateRows();
117
- break;
118
- }
119
- case 'cols':
120
- {
121
- if (this.isConnected) {
122
- this.#updateColumns();
123
- }
124
- break;
125
- }
126
- }
127
- }
128
- #updateColors() {
129
- const colorsValue = this.colors;
130
- if (colorsValue === this.#prevColorsValue) {
131
- return;
132
- }
133
- this.#prevColorsValue = colorsValue;
134
- const colorNames = unpackCsv(colorsValue ?? `${lightColorNames},${vibrantColorNames},${darkColorNames}`);
135
- const fragment = document.createDocumentFragment();
136
- for (const color of colorNames) {
137
- if (color.length === 0) {
138
- continue;
139
- }
140
- const optFrag = optionTemplate.content.cloneNode(true);
141
- const $option = optFrag.querySelector('.option');
142
- const $swatch = optFrag.querySelector('.swatch');
143
- const $tooltip = optFrag.querySelector('.tooltip');
144
- const $checkIcon = optFrag.querySelector('.check');
145
- updateAttribute($option, 'data-value', color);
146
- updateAttribute($tooltip, 'text', color);
147
- updateAttribute($swatch, 'name', color);
148
- updateAttribute($checkIcon, 'name', this.#checkIconName);
149
- $option.style.setProperty('--sinch-color-icon', getSwatchColorFg(color));
150
- fragment.appendChild(optFrag);
151
- }
152
- this.#$listbox.replaceChildren(fragment);
107
+ #onSlotChange = () => {
153
108
  this.#updateColumns();
154
109
  this.#onValueChange();
155
- }
110
+ };
156
111
  #updateRows() {
157
112
  const rowsValue = getAttribute(this, 'rows');
158
113
  this.#$listbox.style.maxHeight = attrValueToPixels(rowsValue, {
@@ -162,7 +117,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
162
117
  }
163
118
  #updateColumns() {
164
119
  const colsValue = getAttribute(this, 'cols');
165
- const numItems = this.#$listbox.children.length;
120
+ const numItems = this.#getOptionElements().length;
166
121
  this.#$listbox.style.width = attrValueToPixels(colsValue, {
167
122
  min: 1,
168
123
  max: numItems,
@@ -170,9 +125,6 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
170
125
  itemSizeMultiplier: ITEM_WIDTH
171
126
  });
172
127
  }
173
- #onMount = () => {
174
- this.#updateColors();
175
- };
176
128
  #onListboxBlur = () => {
177
129
  this.#selectOption(null);
178
130
  };
@@ -181,8 +133,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
181
133
  if ($elem === this.#$listbox) {
182
134
  return;
183
135
  }
184
- const $option = getParentOption($elem);
185
- this.#dispatchChangeEvent($option);
136
+ this.#dispatchChangeEvent($elem);
186
137
  };
187
138
  #onContextVisibility = e => {
188
139
  if (e.detail) {
@@ -238,7 +189,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
238
189
  #onValueChange() {
239
190
  const value = this.value;
240
191
  for (const $option of this.#getOptionElements()) {
241
- const isChecked = value === getAttribute($option, 'data-value', '');
192
+ const isChecked = value === getAttribute($option, 'value', '');
242
193
  updateBooleanAttribute($option, 'data-checked', isChecked);
243
194
  updateBooleanAttribute($option, 'data-selected', isChecked);
244
195
  updateExplicitBooleanAttribute($option, 'aria-selected', isChecked);
@@ -316,7 +267,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
316
267
  }
317
268
  }
318
269
  #getOptionElements() {
319
- return Array.from(this.#$listbox.children);
270
+ return this.#$optionsSlot.assignedElements();
320
271
  }
321
272
  #getSelectedOptionIndex() {
322
273
  const elements = this.#getOptionElements();
@@ -341,7 +292,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
341
292
  const elements = this.#getOptionElements();
342
293
  const value = this.value;
343
294
  for (const $el of elements) {
344
- if (getAttribute($el, 'data-value') === value) {
295
+ if (getAttribute($el, 'value') === value) {
345
296
  return $el;
346
297
  }
347
298
  }
@@ -353,7 +304,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
353
304
  }
354
305
  if ($opt !== null) {
355
306
  this.dispatchEvent(new CustomEvent('-change', {
356
- detail: getAttribute($opt, 'data-value')
307
+ detail: getAttribute($opt, 'value')
357
308
  }));
358
309
  }
359
310
  }
@@ -6,8 +6,6 @@ export type TSinchColorMenuElement = HTMLElement & {
6
6
  rows: number | null;
7
7
  /** How many cols to show and scroll the rest */
8
8
  cols: number | null;
9
- /** Comma-separated color names, all colors by default */
10
- colors: string | null;
11
9
  nthItemRect(index: number): TRect | null;
12
10
  /** Change event */
13
11
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
@@ -27,8 +25,6 @@ export type TSinchColorMenuReact = TSinchElementReact<TSinchColorMenuElement> &
27
25
  rows?: number;
28
26
  /** How many cols to show and scroll the rest */
29
27
  cols?: number;
30
- /** Comma-separated color names, all colors by default */
31
- colors?: string;
32
28
  /** Label that is used for a11y */
33
29
  'aria-label': string;
34
30
  /** Change event handler */
@@ -0,0 +1,14 @@
1
+ import '../color-swatch';
2
+ import '../tooltip';
3
+ import '../icon';
4
+ import type { TSinchColorMenuOptionElement, TSinchColorMenuOptionReact } from './types';
5
+ declare global {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'sinch-color-menu-option': TSinchColorMenuOptionReact;
9
+ }
10
+ }
11
+ interface HTMLElementTagNameMap {
12
+ 'sinch-color-menu-option': TSinchColorMenuOptionElement;
13
+ }
14
+ }